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

int main(){
  int N, K;
  cin >> N >> K;

  vector<int> l(N);
  for(int i = 0; i < N; i++){
    cin >> l.at(i);
  }

  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());

  int sum = 0;

  for(int i = 0; i < K; i++){
    sum += l.at(i);
  }

  cout << sum <<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define endl "\n"
long long int dp[105][100005];
long long int getAns(int a[],int b[],int i,int k,int n){
    if(i >= n)return 0;
    if(dp[i][k] != -1)return dp[i][k];
    //Pick ith
    long long int x = 0;
    if(k - a[i] >= 0)x = b[i] + getAns(a,b,i+1,k-a[i],n);

    //Not pick ith
    long long int y = 0;
    y = getAns(a,b,i+1,k,n);

    return dp[i][k] = max(x,y);
}
int main(){
    FASTIO
    int n,k;
    cin>>n>>k;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        cin>>b[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<getAns(a,b,0,k,n)<<endl;
}


Measured memory_bytes: 82304
// ABC073 D-joisino's travel ワーシャルフロイド
// https://atcoder.jp/contests/abc073/tasks/abc073_d
// はまりポイント１　
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r;
    for(int i = 0; i < R; i++) {
        int temp;
        cin >> temp;
        r.push_back(temp);
    }
    int cost[N + 1][N + 1];
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= N; j++) {
            if(i == j) {
                cost[i][j] = 0;
            } else {
                cost[i][j] = INT_MAX/8;
            }
        }
    }
    for(int i = 0; i < M; i++) {
        int A, B, C;
        cin >> A >> B >> C;
        cost[A][B] = C;
        cost[B][A] = C;
    }
    for(int k = 1; k <= N; ++k) {
        for(int i = 1; i <= N; ++i) {
            for(int j = 1; j <= N; ++j) {
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }
    int min = INT_MAX;
    sort(r.begin(),r.end());
    do {
        int tempcost = 0;
        for(int i = 1; i < r.size(); i++) {
            tempcost += cost[r[i - 1]][r[i]];
        }
        if(tempcost < min)
            min = tempcost;
    } while(next_permutation(r.begin(), r.end()));

    cout << min << endl;
    return 0;
}


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

int main() {
  int i, j, printi, l, num=0, temp, minj;
  int array[100];

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

  for(i=0 ; i<l ; i++) {
    minj = i;

    for(j = i ; j<l ; j++){
      if(array[j] < array[minj]){
	minj = j;
      }
    }

    if(i != minj) {
      temp = array[i];
      array[i] = array[minj];
      array[minj] = temp;
      num++;
    }
  }

  for(printi = 0 ; printi < l; printi++) {
    printf("%d", array[printi]);
    if(printi != l-1) printf(" ");
  }
  printf("\n");

  printf("%d\n", num);
  
  return 0;
}



Measured memory_bytes: 2120
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }


const int M = 100000;
vector<int> graph[3*M+1];
int visit[3*M+1];

int bfs(int start, int goal) {
  queue<int> remain;
  remain.push(start);
  visit[start] = 0;
  while (remain.size() > 0) {
    int from = remain.front(); remain.pop();
    for (int to: graph[from]) {
      if (visit[to] != -1) continue;
      remain.push(to);
      visit[to] = visit[from] + 1;
    }
  }
  if (visit[goal] == -1) return -1;
  return visit[goal] / 3;
}

int main() {
  memset(visit, -1, sizeof(visit));

  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int from, to;
    cin >> from >> to;
    graph[from].push_back(M+to);
    graph[M+from].push_back(2*M+to);
    graph[2*M+from].push_back(to);
  }
  int s, t;
  cin >> s >> t;
  int ans = bfs(s, t);
  cout << ans << endl;
}


Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int A, B;
    cin >> A >> B;
    cout << A - B + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	static int n = 26, d;
	static int[] c;
	static int[][] s;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		d = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		c = new int[n];
		for (int i = 0; i < n; i++) {
			c[i] = Integer.parseInt(sa[i]);
		}
		s = new int[d][n];
		for (int i = 0; i < d; i++) {
			sa = br.readLine().split(" ");
			for (int j = 0; j < n; j++) {
				s[i][j] = Integer.parseInt(sa[j]);
			}
		}
//		int[] t = inputB(br);
		br.close();

		int[] t = new int[d];
		int[] last = new int[n];
		for (int i = 0; i < d; i++) {
			int max = -1;
			int idx = -1;
			for (int j = 0; j < n; j++) {
				if (s[i][j] > max) {
					max = s[i][j] + c[j] * (i + 1 - last[j]);
					idx = j;
				}
			}
			t[i] = idx;
		}

		for (int i = 0; i < d; i++) {
			System.out.println(t[i] + 1);
		}
	}

	static int[] inputB(BufferedReader br) throws Exception {
		int[] t = new int[d];
		for (int i = 0; i < d; i++) {
			t[i] = Integer.parseInt(br.readLine()) - 1;
		}
		return t;
	}

	static int[] calc(int[] t) {
		int[] last = new int[n];
		int[] ret = new int[d];
		for (int i = 0; i < d; i++) {
			if (i > 0) {
				ret[i] += ret[i - 1];
			}
			ret[i] += s[i][t[i]];
			last[t[i]] = i + 1;
			for (int j = 0; j < n; j++) {
				ret[i] -= c[j] * (i + 1 - last[j]);
			}
		}
		return ret;
	}
}


Measured memory_bytes: 36324
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  vector<vector<int> > grid(3, vector<int> (3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++)
      cin>>grid[i][j];
    grid[i][1]-=grid[i][0], grid[i][2]-=grid[i][0], grid[i][0]=0;
  }

  for(int i=0;i<3;i++)
    if(!(grid[0][i]==grid[1][i]&&grid[1][i]==grid[2][i]))
      return cout<<"No\n", 0;

  cout<<"Yes\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String x;
        int i, sum;
        
        while(true) {
        	sum = 0;
        	x = sc.next();
        	if(x.equals("0")) break;
        	
        	for(i = 0; i < x.length(); i++) {
        		sum += x.charAt(i) - '0';
        	}
        	
        	System.out.println(sum);
        	
        }
    }
}


Measured memory_bytes: 26196
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
const int MaxN = 1e5 + 5;
typedef long long LL;

LL L[10];
LL a[MaxN];
int n;

int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+n+1);
//	for(int i = 1;i <= n;i++)printf("%d ",a[i]);
	int j =1;
	for(int i = n;i > 1;i--){
		//printf("%d\n",i);
		if(a[i] == a[i-1] && j != 3){
			L[j] = a[i];
			i--;
		//	printf("%d      ",i);
			j++;
		}
	}
	LL ans = L[1] * L[2];
	if(j == 3)printf("%lld\n",ans);
	else printf("0\n");
//	printf("%lld\n",j);
}

Measured memory_bytes: 896
#include"bits/stdc++.h"
using namespace std;
namespace ORIGIN {
	#define LL long long
	#define VLL vector<long long>
	#define SORT(x) sort(x.begin(),x.end())
	#define REVE(x) reverse(x.begin(),x.end())
	#define rep(i,n) for(int i=0;i<n;i++)
	#define COUT(x) cout<<x<<endl
	double pai = 3.1415926535;
	string atc = "atcodera";
	typedef pair<long long, long long> data_t;
	string strnum = "0123456789";
	string alpS = "abcdefghijklmnopqrstuvwxyz";
	string alpL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int sizealp = (int)(alpS.size());
	int mod = 1e9 + 7;
	bool test = false;
}
using namespace ORIGIN;

void Test(char a) {
	if (test) {
		printf("%c", a);
	}
}
int gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}

int main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int count = 0;
	int x;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			x = n - (r * i + g * j);
			if (x % b == 0&&x>=0) {
				count++;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#リーダーを向け

n=int(input())
s=input()
k=0
l=[]
for i in range(n):
    if s[i]=="W":
        k+=1
    l.append(k)
#print(l)
#既に追加されたものまで変更されはしなかった
#kが要素かどうか決めつけることはできないからかな
w=n
for i in range(n):
    if i==0:
        #if s[i]=="W":
        #    v=n-l[n-1]+1
        #else:
        #    v=n-l[n-1]
        #下のようにすれば分ける必要はない
        v=n-1-l[n-1]+l[0]
    else:
        v=l[i-1]+n-1-i-(l[n-1]-l[i])


    if v<w:
        w=v
    if v==0:
        w=0
        break    
print(w)

Measured memory_bytes: 15520
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int h,a;
    scanf("%d%d",&h,&a);
    int ans=0;
    while(1)
    {
        if(h<=0)
        {
            break;
        }
        h-=a;
        ans++;
    }
    printf("%d",ans);
}

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


for i in range(6):
    if 0 < n // 10 ** i < 10:
        k = i
        break
count = 0
if k % 2 == 0:
    while k >= 0:
        count += n - 10 ** k + 1
        k -= 2
        n = 10 ** (k + 1) - 1
elif k % 2 == 1:
    k -= 1
    n = 10 ** (k + 1) - 1
    while k >= 0:
        count += n - 10 ** k + 1
        k -= 2
        n = 10 ** (k + 1) - 1

print(count)

Measured memory_bytes: 3064
N = int(input())
al = list(map(int,input().split()))
bit = [0]*35

for i in range(N):
  for j in range(35):
    if (al[i]>>j)&1 == 1:
      bit[j] += 1
      
for j in range(35):
  if bit[j] %2 == 1:
    print("No")
    exit()
    
print("Yes")

Measured memory_bytes: 14116
def f(x,y,x1,y1,x2,y2):
    return (x2-x1)*y-(y2-y1)*x+x1*y2-x2*y1

while True:
    try:
        ax,ay,bx,by,cx,cy,dx,dy = map(float, raw_input().split(","))
        if f(ax,ay,bx,by,dx,dy)*f(cx,cy,bx,by,dx,dy) < 0 and f(dx,dy,ax,ay,cx,cy)*f(bx,by,ax,ay,cx,cy) < 0:
            print "YES"
        else: print "NO"
    except:
        break

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

int main(void)
{
	int x;
	int i;
	
	i = 1;
	
	while (1){
		cin >> x;
		
		if (x == 0){
			break;
		}
		
		cout << "Case " << i << ": " << x << endl;
		i++;
	}
	
	return (0);
}

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

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int  MOD=1000000007;
const int  INF= int(1e9);


int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    int mi=a[0];
    int mx=a[0];
    for(int i=0;i<n;i++) {
        mi = min(a[i],mi);
        mx = max(a[i],mx);
    }
    int res = mx - mi ;
    cout<<res<<"\n";



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;
	cin >> n;
	cout <<  48 - n  << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.buffer.readline
sys.setrecursionlimit(10**9)

N = int(input())
# v = [list(map(int, input().split())) for _ in range(N-1)]

edge = [[] for _ in range(N)]

for i in range(N-1):
    v1, v2, w = map(int, input().split())
    edge[v1-1].append((v2-1, w))
    edge[v2-1].append((v1-1, w))

color = [-1 for _ in range(N)]
color[0] = 1

def dfs(x):
    for v, w in edge[x]:
        if color[v] == -1:
            color[v] = (w + color[x])%2
            dfs(v)



dfs(0)
print(*color, sep="\n")

Measured memory_bytes: 79512
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,m = readInts()
    S = []
    for i in range(m):
        x,y = readInts()
        x -=1
        S.append((x,y))
    for i in range(10**n):
        s = str(i)
        if len(s) != n:
            continue
        if all(s[a] == str(b) for a,b in S):
            print(i)
            exit()
    print(-1)
    """for i in range(n):
        S.append(0)
    La = False
    for i in range(m):
        s,c = readInts()
        s -=1
        if S[s] == 0 or S[s] == c:
            S[s] = c
            La = True
        else:
            print('-1')
            exit()
    if La:
        if n == 3 and S[0] == 0:
            print('-1')
            exit()
        if n == 2 and S[0] == 0:
            print('-1')
            exit()
    if S.count(0) == n and not n == 1: # もし0の数が桁数と一緒ならば、
        S[0] = 1
    print(*S,sep='')
    """
if __name__ == '__main__':
  main()


Measured memory_bytes: 3064
n,k=map(int,input().split())
s=list(str(input()))
r=[]
l=[]
c=0
d=1
for i in range(n):
	if s[i]=='1' and d==1:
		r.append(i)
		c=1
		d=0
	elif s[i]=='0' and c==1:
		l.append(i-1)
		c=0
		d=1
if c>0:
	l.append(i)
if len(r)<=k+1:
	r=[0]*(k+1-len(r))+r+[n-1]*(k+1-len(r))
	l=[0]*(k+1-len(l))+l+[n-1]*(k+1-len(l))
r=[0]+r+[n-1]
l=[0]+l+[n-1]
ans=0
for i in range(len(r)-k):
	ans=max(ans,l[i+k]-r[i]+1)
print(ans)

Measured memory_bytes: 62604
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define DEBUG_VARIABLE(variable) cout << #variable << ":" << variable << endl

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
#define INF (1 << 9)
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

void printArray(int *array, int);
void printVector(vector<string> &v);
void printDimention(DVector &dv);

ll march_num[5];
void march(char tmp){
    //DEBUG_VARIABLE(tmp);
    if(tmp == 'M'){
        march_num[0]++;
    }else if(tmp == 'A'){
        march_num[1]++;
    }else if(tmp == 'R'){
        march_num[2]++;
    }else if(tmp == 'C'){
        march_num[3]++;
    }else if(tmp == 'H'){
        march_num[4]++;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    vector<string> str;
    
    string tmp;
    bool flg;
    
    rep(i, n){
        cin >> tmp;
        march(tmp[0]);
        str.push_back(tmp);
    }
    //printVector(str);
    //printArray(march_num, 5);
    ll total = 0;
    FOR(i, 0, 3){   //0~2
        FOR(j, i + 1, 4){   //1~3
            FOR(k, j + 1, 5){   //2~4
              total += march_num[i] * march_num[j] * march_num[k];  
            }
        }
    }
    cout << total << endl;
}

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

//Vectorの表示
void printVector(vector<string> &v){
    rep(i, (int)v.size()){
        if(i)   cout << " ";
        cout << v[i];
    }
    cout << endl;
}

//二次元配列の表示
void printDimention(DVector &dv){
    rep(i, (int)dv.size()){
        rep(j, (int)dv[i].size()){
            if(j)   cout << " ";
            cout << dv[i][j];
        }
        cout << endl;
    }
}

//numの中に何個2がかかってるか
int factor2(int num){
    int cnt = 0;
    while(num % 2 == 0){
        num /= 2;
        cnt++;
    }
    return cnt;
}

Measured memory_bytes: 5748
#coding:utf-8


o = list(str(raw_input()))  # 奇数
e = list(str(raw_input()))  # 偶数
out=[]
# print o
# print e
# print len(o)
# print len(e)
# count =0
if len(o)>len(e):
    for i in range(len(e)):
        # if i == len(o):
        #     out.append(o[i])
        #     print a
        #     break
        # else:
        out.append(o[i])
        out.append(e[i])
    out.append(o[-1])
        # count+=1
else:
    for i in range(len(e)):
        out.append(o[i])
        out.append(e[i])
        # count +=1
# print out
# out = [1,2,3,4,5]
# out_str = map(str,out)
# print out_str #=> "1,2,3,4,5"
# print count
print "".join(out)


Measured memory_bytes: 2568
n = int(input())
ans = set()
#n-1の約数は確定でOK

for i in range(1,int(pow(n-1,0.5)) + 1):
    if (n-1) % i == 0:
        ans.add((n-1)//i)
        ans.add(i)
#n = (1 + pk) * k^q の形になるkを探す。q ≠ 0のとき、kはnの約数
for i in range(2,int(pow(n,0.5)) + 1):
    if n % i == 0:
        tmp = n
        while tmp % i == 0:
            tmp = tmp // i
        if (tmp - 1) % i == 0:
            ans.add(i)
print(len(ans))



Measured memory_bytes: 64512
#include <iostream>
#include <string>
using namespace std;
int solve() {
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        s.pop_back();
        s.pop_back();
        if (s.substr(0, s.size() / 2) == s.substr(s.size() / 2)) return s.size();
    }
    return 0;
}
int main() {
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <limits>
#include <algorithm>

using namespace std;
typedef long long int ll;

int main() {
	ll A, B, C;
    cin >> A >> B >> C;

	vector<ll> x = {A, B, C};
	sort(x.begin(), x.end());

	ll a = (x[1] - x[0]) / 2;
	ll b = (x[0] + 2*a == x[1] ? 0 : 1);
	ll c = x[2] - x[1];
	cout << a + 2*b + c << endl;
}


Measured memory_bytes: 256
def gen_d_prim(n):
    D = [0] * (n+1)
    for i in [2, *range(3, n+1, 2)]:
        if D[i] > 0: continue
        for j in range(i, n+1, i): D[j] = i
    return D

def is_pairwise(A):
    D = gen_d_prim(10**6)
    past = set()
    for a in A:
        now = set()
        while a != 1:
            # 素数 D[a]: 今回は未済 & 過去で済
            if not D[a] in now and D[a] in past: return False
            now.add(D[a])
            past.add(D[a])
            a //= D[a]
    return True

def gcd_all(A):
    from math import gcd
    g = 0
    for a in A: g = gcd(g, a)
    return g

def solve():
    if is_pairwise(A): return 0
    if gcd_all(A) == 1: return 1
    return 2

n = int(input())
A = [*map(int, input().split())]
print(['pairwise','setwise','not'][solve()], 'coprime')


Measured memory_bytes: 126984
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define ll long long
#define rep(i, a, b) for(int i = a; i < b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int maxn = 17;
int n, a[maxn][maxn];
ll cost[1 << maxn], dp[1 << maxn];
int main()
{
    read(n);
    rep(i, 0, n) rep(j, 0, n) read(a[i][j]);
    rep(i, 0, 1 << n)
        rep(j, 0, n) rep(k, j + 1, n)
            if((i & (1 << j)) && (i & (1 << k))) cost[i] += a[j][k];
    rep(i, 0, 1 << n)
        for(int j = i; j; j = (j - 1) & i)
            dp[i] = max(dp[i], dp[i ^ j] + cost[j]);
    printf("%lld\n", dp[(1 << n) - 1]);
    return 0;
}

Measured memory_bytes: 1280
package main

import "fmt"

func main() {
	var S string
	fmt.Scanf("%s", &S)
	N := len(S)

	count := 0
	for i := 0; i < N/2; i++ {
		if S[i] != S[N-i-1] {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include <stdio.h>

long amari = 1e9 + 7;

long long int fact(int in){
  long long int out=1, i;
  for(i=1; i<=in; ++i){
    out *= i;
    out = out%amari;
  }
  return out;
}

int main(void){
  int n, m;
  long long int na, ma;
  scanf("%d%d", &n, &m);
  if (n-m  > 1 || m-n >1) {
    printf("%d\n", 0);
    return 0;
  }
  na = fact(n);
  ma = fact(m);
  if (n==m){
    printf("%lld\n", na*ma*2%amari);
  } else{
    printf("%lld\n", na*ma%amari);
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
	String sequence = scan.nextLine();
	int seqLength = sequence.length();
	int abcVariety = 26;
	int[] eachReqTime =new int[abcVariety];
	int[] eachLastPosition = new int[abcVariety];
	for(int i = 0; i < abcVariety; i++){
	    eachReqTime[i] = 0;
	    eachLastPosition[i] = -1;
	}

	char currentChar;
	int currentIndex;
	for(int i = 0; i < seqLength; i++){
	    currentChar = sequence.charAt(i);
	    currentIndex = (int)currentChar - (int)'a';
	    int currentReqTime = i - 1 - eachLastPosition[currentIndex];
	    eachReqTime[currentIndex] = Math.max(eachReqTime[currentIndex], currentReqTime);
	    eachLastPosition[currentIndex] = i;
	}
	char lastChar = sequence.charAt(seqLength - 1);
	int lastIndex = (int)lastChar - (int)'a';
	for(int i = 0; i < abcVariety; i++){
	    if((i != lastIndex) && (eachLastPosition[i] != -1)){
		int currentReqTime = seqLength - 1 - eachLastPosition[i];
		eachReqTime[i] = Math.max(eachReqTime[i], currentReqTime);
	    }
	}
	int reqTime = seqLength;
	for(int i = 0; i < abcVariety; i++){
	    if(eachLastPosition[i] != -1){
		reqTime = Math.min(reqTime, eachReqTime[i]);
	    }
	}
	System.out.print(reqTime);
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S;
    cin >> S;
    int sizes = S.size();
    sort(ALL(S));
    UNIQUE(S);
    cout << (sizes - S.size() ? "no" : "yes") << "\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  vector<int> cnt(100'000 + 1, 0);
  int64_t s = 0;
  int N;
  cin >> N;
  rep(i, N) {
    int a;
    cin >> a;
    s += a;
    cnt[a]++;
  }

  int Q;
  cin >> Q;
  rep(i, Q) {
    int b, c;
    cin >> b >> c;

    s += (int64_t)cnt[b] * (c - b);
    cnt[c] += cnt[b];
    cnt[b] = 0;
    cout << s << "\n";
  }
  return 0;
}

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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define pp pop_back()
#define ll long long
#define ld long double
#define ok puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

inline ll min(ll a, ll b) {
    return (a > b) ? b : a;
}

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

const int N = 1e6 + 7;
const int inf = 1e9 + 7;
const ll linf = 1e18 + 9;

int freq[26];

main() {
    string s; cin >> s;
    ll n = sz(s);
    ll res = 1;
    for (int i = 0; i < n; i++) {
        res += i - freq[s[i] - 'a'];
        freq[s[i] - 'a']++;
    }
    printf ("%lld", res);
}


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

typedef long long ll;
typedef vector<int> vi;            typedef vector<vi> vii;
typedef vector<ll> vl;             typedef vector<vl> vll;
typedef pair<int,int> pi;          typedef pair<pi,int> pii;
typedef pair<ll,ll> pl;            typedef pair<pl,ll> pll;
typedef pair<int,bool> pib;        typedef pair<ll,bool> plb;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define in insert
#define er erase
//user-defined hash table for pairs --------------------------------------------------------------------------------------------------
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

//returns (a^n mod p)---------------------------------------------------------------------------------------------------------------
ll power(ll a,ll n,ll p)
{
	if(n == 0)
	{
		return 1;
	}
	else if(n%2 == 0)
	{
		ll ans = power(a,n/2,p);
		return (ans*ans)%p;
	}
	else 
	{
		ll ans = power(a,n-1,p);
		return (ans*a)%p;
	}
}

//returns (a^-1 mod p)(if p is prime)----------------------------------------------------------------------------------------------
ll inverse(ll a,ll p)
{
   return power(a,p-2,p);
}
//----------------------------------------------------------------------------------------------------------------------------------


void solve()
{
   int x;
   cin>>x;
   cout<<1+(1999-x)/200<<endl;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef PAVANSAI006
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    ll t = 1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }
    
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;
int main(){
    ll n;
    std::cin >> n;
    VEC(ll,a,n);
    std::vector<ll> b(n+1);
    rep(i,n){
        b[a[i]]++;
    }
    ll ans=0;
    rep(i,n+1){
        ans+=b[i]*(b[i]-1)/2;
    }
    rep(i,n){
        std::cout << ans-(b[a[i]]*(b[a[i]]-1)/2)+((b[a[i]]-2)*(b[a[i]]-1)/2) << std::endl;
    }
}

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

int main(void) {
    int64_t N,M;
    int64_t testnum;
    cin >> N >> M;

    testnum = 1 << M;
    // 2^M回の試行
    // M*1900*試行
    // (N-M)*100*試行
    cout << (M*1900*testnum) + ((N-M)*100*testnum) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define HohleFeuerwerke using namespace std
#pragma GCC optimize(3)
#define int long long
HohleFeuerwerke;
inline int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}
int a[500]={0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,
1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int k;
signed main()
{
	k=read();
	printf("%lld\n",a[k]);
	return 0; 
}

Measured memory_bytes: 256
import math,sys
ans=0
def factorization(n):
    num=0
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
            num=num+1
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr,num
def kirisute(n):
    p=(-1+math.sqrt(1+8*n))/2
    q=math.floor(p)
    return q
N=int(input())
if N==1:
  print(0)
  sys.exit()
soinsuu,jigen=factorization(N)
for i in range(len(soinsuu)):
  ans=ans+kirisute(soinsuu[i][1])
print(ans)

Measured memory_bytes: 9504
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        for(int time =0; time<k; ){
        	if(a%2 == 1){
        		a -= 1;
        	}
        		a /= 2;
        		b += a;
        		time += 1;

        	if(time<k){
        		if(b%2 == 1){
        			b-= 1;
        		}
        		b /= 2;
        		a += b;
        		time += 1;
        	}
        }
        System.out.println(a + " " + b);

    }
}

Measured memory_bytes: 21844
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007
sys.setrecursionlimit(1000000)

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    n,m = LI()
    a = LIR(m)
    a.sort(key = lambda x:x[1])
    x = 0
    ans = 0
    for i in range(m):
        if a[i][0] >= x:
            x = a[i][1]
            ans += 1
    print(ans)
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 56368
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

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

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
map<string,int> data;
map<string,vector<string> >ren;

int res(string s){
	if(!ren.count(s))return data[s];
	int sum = 0;
	for(int i =0;i <ren[s].size();i++){
		sum +=res(ren[s][i]);
	}
	if(data[s]>sum){
		data[s]=sum;
	}
	return data[s];
}

int main(){
	int n,m;
	while(scanf("%d",&n),n){
		data.clear();
		ren.clear();
		for(int i =0;i < n;i++){
			string item;
			int cst;
			cin>>item>>cst;
			data[item] =cst;
		}
		cin>>m;
		int k;
		for(int i =0;i <m;i++){
			string renkin;
			cin>>renkin;
			scanf("%d",&k);
			//int sum=0;
			for(int j =0;j <k;j++){
				string tmp;
				cin>>tmp;
				ren[renkin].push_back(tmp);
			}
			//data[renkin]=min(sum,data[renkin]);
		}
		string ans;
		cin>>ans;
		cout <<res(ans)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1284
#include <stdio.h>
 
int main()
{
    int a, b;
    char op;
 
    scanf("%d %c %d", &a, &op, &b);
    while (op != '?') {
        switch (op) {
            case '+': printf("%d\n", a + b);
                break;
            case '-': printf("%d\n", a - b);
                break;
            case '*': printf("%d\n", a * b);
                break;
            case '/': printf("%d\n", a / b);
                break;
            default: break;
        }
        scanf("%d %c %d", &a, &op, &b);
    }
 
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define USE_MATH_DEFINES
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main()
{
    int n;
    cin >> n;
    int minv, maxv = INT_MIN;
    cin >> minv;
    for (int i = 1; i < n; i++)
    {
        int r;
        cin >> r;
        maxv = max(maxv, r - minv);
        minv = min(minv, r);
    }
    printf("%d\n", maxv);
}


Measured memory_bytes: 3224
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  int a, b;
  cin >> a >> b;
  if (a == b) cout << "Draw\n";
  else if (a > b){
    if (b == 1) cout << "Bob" << endl;
    else cout << "Alice" << endl;
  } else {
    if (a == 1) cout << "Alice" << endl;
    else cout << "Bob" << endl;
  }
}

Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i)
arr = gets.chomp.split(" ").map(&:to_i)

arr_sum = arr.sum

filtered = arr.select { |a| a >= arr_sum.to_f / (4 * m) }

if filtered.count >= m
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 14352
import fractions
N,X = map(int,input().split())

x = list(map(int,input().split()))
lst = [0]*N
for i in range(len(x)):
    lst[i] = x[i] - X
   
a=0
for e in lst:
  a=fractions.gcd(a,e)
print(abs(a))

Measured memory_bytes: 21436
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace AtCoder {
    class Practice {
        static void Main() => CustomMain();

        static void Solve() {
            var a = ReadIntArray();

            if (a[2] <= a[0] + a[1] && a[0] <= a[2]) {
                WriteAnswer("YES");
            } else {
                WriteAnswer("NO");
            }
        }


        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }

        static long GCD(long a, long b) {
            return b != 0 ? GCD(b, a % b) : a;
        }
    }
}


Measured memory_bytes: 11092
using System;
using System.Linq;
using static System.Console;

namespace C
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var input = ReadLine().Split(' ').Select(double.Parse).ToList();
            var degA = input[2] * (360d / 12) + 30 * input[3] / 60; // H+M/60
            var degB = input[3] * (360d / 60);
            var diff = degA - degB;
            var length = Math.Sqrt(Math.Pow(input[0], 2) + Math.Pow(input[1], 2) - 2 * input[0] * input[1] * Math.Cos(Deg2Rad(diff)));
            WriteLine($"{length:F20}");
        }

        static double Deg2Rad(double degree)
        {
            return degree * Math.PI / 180;
        }
    }
}

Measured memory_bytes: 28712
// abc056_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int w,a,b,ans;
  cin>>w>>a>>b;
  if (a<b) ans = b-a-w;
  else ans = a-b-w;
  if (ans < 0) cout << 0 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=255*2;
int n,mod;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
int f[N],g[N];
int dp[N][N][N];
pair <int,int> p[N];
bool cmp(pair <int,int> a,pair <int,int> b){
	if (a.fi!=b.fi)
		return a.fi<b.fi;
	return a.se>b.se;
}
int main(){
	n=read(),mod=read();
	For(i,0,n-1)
		while (i*i+f[i]*f[i]<n*n)
			f[i]++;
	For(i,0,n*2-1)
		while (g[i]<n*2&&i*i+g[i]*g[i]<=n*n*4)
			g[i]++;
	For(i,1,n)
		p[i]=mp(f[i-1],i-1);
	For(i,1,n)
		p[i+n]=mp(g[i+n-1],i+n-1);
	sort(p+1,p+n*2+1,cmp);
//	outarr(f,0,n-1);outarr(g,0,n*2-1);
//	For(i,1,n*2)
//		printf("p[%d] = (%d,%d)\n",i,p[i].fi,p[i].se);
	For(i,0,n)
		dp[0][0][i]=1;
	For(i,0,n*2)
		For(j,0,i)
			For(k,0,n){
				int v=dp[i][j][k];
				if (!v)
					continue;
//				printf("dp[%d][%d][%d] = %d\n",i,j,k,v);
				int nv=p[i+1].fi,id=p[i+1].se;
				if (id<n){
					if (k)
						Del(dp[i+1][j+1][k-1],(LL)v*max(0,nv-j)%mod);
					Add(dp[i+1][j][k],(LL)v*max(0,g[id]-k-n-(n-id-1))%mod);
				}
				else {
					Add(dp[i+1][j+1][k],(LL)v*max(0,nv-j)%mod);
				}
			}
	int ans=0;
	For(i,0,n*2)
		Add(ans,dp[n*2][i][0]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 508160
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n;
  string s;
  cin >> n >> s;
  vector<vector<ll>> dp(3010, vector<ll>(3010,0));
  //dp[i][j]=(i番目まで決めたとき、i番目の数より大きいものがj個残っているような場合の数)
  rep(i,n){ dp[1][i]=1; }
  
  for(int i=1; i<n; i++){
    ll rsk[3010];   //ruisekiwa
    rep(j,n-i+1){ rsk[j+1]=(rsk[j]+dp[i][j])%mod;}
    if(s[i-1]=='<'){
//      rep(k,n-1)for(int j=k+1; j<n-i+1; j++){ (dp[i+1][k]+=dp[i][j])%=mod;}
      rep(k,n-1){ dp[i+1][k]=(rsk[n-i+1]-rsk[k+1])%mod;}
    } else {
//      rep(k,n-i)for(int j=0; j<k+1; j++){ (dp[i+1][k]+=dp[i][j])%=mod;}
      rep(k,n-i){ dp[i+1][k]=rsk[k+1]; }
    }
  }
  
  ll ans = (dp[n][0]+mod)%mod;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    ll ans = 0;
    for (ll i = 1; i < s.size(); i++) {
        if (s[i] != '9') {
            break;
        }
        if (i == s.size()-1) {
            rep (i, s.size()) {
                ans += s[i]-'0';
            }
            cout << ans << endl;
            return 0;
        }
    }

    if (s.size() == 1) {
        cout << s << endl;
        return 0;
    }

    ans += s[0]-'1';
    for (ll i = 1; i < s.size(); i++) {
        ans += 9;
    }

    cout << ans << endl;
    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static int n;

        static void Main(string[] args)
        {
            //[summary]C - Linear Approximation
            n = int.Parse(Console.ReadLine());
            var a = ReadLine();
            var numbers = GetNumbers(a).OrderBy(x => x).ToList();

            int index = n / 2;
            int b = numbers[index];
            long sadness = CalcSadness(b, numbers);

            Console.WriteLine(sadness);
        }

        static long CalcSadness(int b, List<int> numbers)
        {
            long sadness = 0;

            for (int i = 0; i < n; i++)
            {
                sadness += Math.Abs(numbers[i] - b);
            }

            return sadness;
        }

        static IEnumerable<int> GetNumbers(List<int> a)
        {
            for (int i = 0; i < n; i++)
            {
                yield return a[i] - (i + 1);
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

int main(void){
    int i, n, k;
    scanf("%d %d", &n, &k);
    char s[n];
    scanf("%s", s);
    for(i=0; i<=strlen(s); i++){
        if(s[i]>=65 && s[i]<=90){
            if(i==k-1){
                s[i] += 32;
            }
        }
    }
    printf("%s\n", s);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main
{

	static int[] dp,height;
	static int j;


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

		int N = sc.nextInt();

		height = new int[N+1];
		dp = new int[N+1];

		//height入力
		for(int i=1;i<=N;i++)
		{
		height[i]=sc.nextInt();
		}

		//dp初期化
		for(int i=1;i<=N;i++)
		{
		dp[i]=0;
		}

		dp[2]=Math.abs(height[2]-height[1]);

		//dp実行
		for(j=3;j<=N;j++)
		{
			chmin(dp[j-1],dp[j-2]);
		}


		System.out.println(dp[N]);
	}

	//dp更新用の関数定義
	public static void chmin(int k,int l)
	{
		dp[j] = Math.min(k + Math.abs(height[j]-height[j-1]),l + Math.abs(height[j]-height[j-2]));
	}



}

Measured memory_bytes: 50948
n = input()
x = 0

a = len(n) - 1

for i in range(2 ** a):
    op = ['']*(a+1)
    for j in range(a):
        if ((i>>j) & 1):
            op[j] = '+'
    formula = ''
    for p,q in zip(n, op):
        formula += p + q
    x += eval(formula)
    
print(x)

Measured memory_bytes: 3060