akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <stack>

using namespace std;

int main(){

	string str;

	while(1){
		getline(cin,str);
		stack<int> data;
		if(str.at(0)=='.')break;

		int flag=0;
	
		for(int i=0;i<str.size();i++){

		if(str.at(i) =='('){
			data.push(1);
		}

		if(str.at(i) == '['){
			data.push(2);
		}

		if(str.at(i) ==')'){
			if(data.size()==0){
				cout<<"no"<<endl;
				flag=1;
			}
			else if(data.top() != 1){
				cout<<"no"<<endl;
				flag=1;
			}
			else{
				data.pop();
			}
		}
		if(str.at(i) == ']'){
			if(data.size()==0){
				cout<<"no"<<endl;
				flag=1;
			}
			else if(data.top() != 2){
				cout<<"no"<<endl;
				flag=1;
			}
			else{
				data.pop();
			}
		}

		if(flag==1)break;
		}

		if(flag==1)continue;

		if(data.size()!=0){
			cout<<"no"<<endl;
			continue;
		}

		cout<<"yes"<<endl;
	}

	return 0;
}

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

int n;
long long a[200010];
long long b[200010];
long long ans;
priority_queue<pair<long long, int> > pQ;

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

    cin >> n;

    for(int i=0; i<n; i++) {
        cin >> a[i];
    }

    for(int i=0; i<n; i++) {
        cin >> b[i];
        pQ.push({b[i], i});
    }

    while(pQ.size()) {
        int i = pQ.top().second;
        pQ.pop();

        if(b[i] < a[i]) {
            cout << -1;
            return 0;
        }
        if(b[i] == a[i])  continue;

        long long t = (b[i] - max(b[(i + n - 1) % n ], b[(i+1)%n])) / (b[(i + n - 1) % n] + b[(i+1)%n]) + 1;
        t = min(t, (b[i] - a[i]) / (b[(i + n - 1) % n] + b[(i+1)%n]));
        ans += t;
        b[i] -= t * (b[(i + n - 1) % n ] + b[(i+1)%n]);

        //cout << t << " " << b[i] << " " << i << endl;
        if(t==0) {
            cout << -1;
            return 0;
        }
        pQ.push({b[i], i});
    }

    cout << ans;
}


Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
typedef complex<double> P;
double dot(P a, P b){ //内積
    return (a.real() * b.real() + a.imag() * b.imag());
}

double cross(P a, P b){ //外積
    return (a.real() * b.imag() - a.imag() * b.real());
}

bool is_orth(P a1, P a2, P b1, P b2){ //垂直か
    return EQ(dot(a1 - a2, b1 - b2), 0.0);
}

bool is_para(P a1, P a2, P b1, P b2){ //平行か
    return EQ(cross(a1 - a2, b1 - b2), 0.0);
}

bool is_online(P a, P b, P c){ //cが線分上か
    return (abs(a-c) + abs(c-b) < abs(a-b) + EPS);
}

bool distance_lp(P a, P b, P c){ //直線abと点cの距離
    return abs(cross(b-a, c-a)) / abs(b-a);
}

bool is_intersect(P a1, P a2, P b1, P b2){ //線分の交差判定
    return (cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS) && 
        (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS);
}

P intersect_pos(P a1, P a2, P b1, P b2){ //直線同士の交点
    P a = a2 - a1;
    P b = b2 - b1;
    return a1 + a * cross(b, b1 - a1) / cross(b, a);
}





int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    P p1(x1,y1), p2(x2,y2), p12(x2-x1, y2-y1);
    ll q;
    cin >> q;
    P n = p12 * P(0,1);
    while(q--){
        double x,y;
        cin >> x >> y;
        P p(x,y);
        P ans = intersect_pos(p1, p2, p, p+n);
        cout << setprecision(16) << ans.real() << " " << ans.imag() << endl;

    }
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int A = 2e5 + 5;
const int mod = 1e9 + 7;
int add(int x, int y) {
    return ((x + y) % mod + mod) % mod;
}
int mul(int x, int y) {
    return (1LL * x * y) % mod;
}
int fp (int x, int y) {
    if (!y) return 1;
    int acc = fp(x, y / 2);
    acc = mul(acc, acc);
    if (y & 1) acc = mul(acc, x);
    return acc;
}
int fact[A], inv[A];
void pre() {
    fact[0] = inv[0] = 1;
    for (int i = 1; i < A; i++) {
        fact[i] = mul(fact[i - 1], i);
        inv[i] = fp(fact[i] , mod - 2);
    }
}
int ncr(int n, int r) {
    return mul(fact[n], mul(inv[n - r], inv[r]));
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k;
    cin >> n >> k;
    n++, pre();
    int ans = 0;
    for (int i = k; i <= n; i++) {
//        int l = i * (i - 1) / 2, r = n * (n - 1) / 2 - (n - i) * (n - i - 1) / 2;
        int l = ncr(i, 2) , r = add(ncr(n, 2), -ncr(n - i, 2));
        ans = add(ans, add(add(r, -l), 1));
//        cout << l << ' ' << r << '\n';
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 5216
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
num=float("inf")
ans=0
for i in range(N):
    H[i]=T-0.006*H[i]
    if abs(A-H[i])<num:
        ans=i+1
        num=abs(A-H[i])
print(ans)

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

using namespace std;

void w(int z[],int len,int num){
	int i;
	for(i = 0; i < len; i++) z[i] = num;
}

void bsort(int a[],int b[],double c[], int size){
	int i, j, k,atmp;
	double ctmp;
	for(i = 1; i < size; i++){
		k = b[i];
		atmp = a[i];
		ctmp = c[i];
		j = i - 1;
		while((j >= 0) && (b[j] < k)){
			b[j+1] = b[j];
			a[j+1] = a[j];
			c[j+1] = c[j];
			j--;
		}
		b[j+1] = k;
		a[j+1] = atmp;
		c[j+1] = ctmp;
	}
}

void csort(int a[],int b[],double c[], int size){
	int i, j, k,atmp;
	double ctmp;
	for(i = 1; i < size; i++){
		k = b[i];
		atmp = a[i];
		ctmp = c[i];
		j = i - 1;
		while((j >= 0) && (c[j] < ctmp)){
			b[j+1] = b[j];
			a[j+1] = a[j];
			c[j+1] = c[j];
			j--;
		}
		b[j+1] = k;
		a[j+1] = atmp;
		c[j+1] = ctmp;
	}
}

int main(void)
{
	int h,n;
	cin >> h >> n;
	int i,j, a[n+1],b[n+1],dp[n+1][h+1];
	double c[n+1];
	for(i = 0; i < n+1; i++){
		if(i == 0){
			a[i] = 0; b[i] = 0;
			c[i] = 0.0;
			w(dp[0],h+1,300000000);
		}
		else{
			cin>>a[i]>>b[i];
			c[i] = (double)a[i] / (double)b[i];
		}
	}
	
	/*
	for(i = 0; i < n+1; i++){
		printf("i = %4d\n",i);
		printf("a[i] = %4d\n",a[i]);
		printf("b[i] = %4d\n",b[i]);
		printf("c[i] = %4f\n",c[i]);
		printf("\n\n");
	}
	*/
	
	//sort();
	bsort(a,b,c,n+1);
	csort(a,b,c,n+1);
	for(i = n; i > 0; i--){
		a[i] = a[i-1];
		b[i] = b[i-1];
		c[i] = c[i-1];
	}
	int min,aaa;
	for(i = 1; i < n+1; i++){
		for( j = 1; j < h+1; j++){
			if(j <= a[i]) aaa = 0;
			else aaa = dp[i][j-a[i]];
			if(aaa+b[i] < dp[i-1][j]){
				dp[i][j] = aaa+b[i];
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
		//printf("i = %3d, j = %3d, dp[i][j] = %3d");
	}
	
	/*
	for(i = 0; i < n+1; i++){
		printf("i = %4d\n",i);
		printf("a[i] = %4d\n",a[i]);
		printf("b[i] = %4d\n",b[i]);
		printf("c[i] = %4f\n",c[i]);
		printf("\n\n");
	}
	
	for(i = 1; i < n+1; i++){
		for( j = 1; j < h+1; j++){
			printf("%d ",dp[i][j]);
		}
		printf("\n");
	}
	
	printf("\n\n\n\n");
	printf("dp[n][h] = %d\n",dp[n][h]);
	*/
	
	printf("%d\n",dp[n][h]);
	return 0;
}





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

int main(void){
  long int a,b,c;
  cin >> a >> b >> c;
  long int A,B,C;
  if(a % 2 == 0){
    cout << 0 << endl;
    return 0;
  }
  else if(a % 2 == 1){
    A = b*c;
  }

  if(b % 2 == 0){
    cout << 0 << endl;
    return 0;
  }
  else if(b % 2 == 1){
    B = a*c;
  }

  if(c % 2 == 0){
    cout << 0 << endl;
    return 0;
  }
  else if(c % 2 == 1){
    C = a*b;
  }

  long int min = A;
  if(min > B){
    min = B;
  }
  if(min > C){
    min = C;
  }
  cout << min << endl;
}


Measured memory_bytes: 256
nl = list(map(int, input().split()))
n = nl[0]
l = nl[1]

sumN = (l-1) * n + sum([i for i in range(1,n+1)])

diff = 10000000000
ans = 0
for i in range(1,n+1):
    ansSum = (l-1) * (n-1) + sum([j for j in range(1,n+1) if j != i])
    if abs(sumN - ansSum) < diff:
        ans = ansSum
        diff = abs(sumN - ansSum)
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;

struct Node
{
	int key;
	Node *pre, *next;
};

Node *nil;

void init()
{
	nil = (Node *)malloc(sizeof(Node));
	nil->pre = nil;
	nil->next = nil;
}

void insert(int key)
{
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	x->pre = nil;
	nil->next->pre = x;
	nil->next = x;
}

Node* search(int key)
{
	Node *cur = nil->next;
	while(cur != nil && cur->key != key)
		cur = cur->next;
	return cur;
}

void deleteNode(Node *t)
{
	if (t == nil)
		return;
	t->pre->next = t->next;
	t->next->pre = t->pre;
	free(t);
}

void deleteKey(int key)
{
	return deleteNode(search(key));
}

void deleteFirst()
{
	return deleteNode(nil->next);
}

void deleteLast()
{
	return deleteNode(nil->pre);
}

void printList()
{
	int i = 0;
	Node *cur = nil->next;
	while(cur != nil)
	{
		if (i++ > 0) 
			printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}


int main()
{
	int n, key;
	char com[20];
	scanf("%d", &n);
	init();
	for (int i = 0; i < n; i++)
	{
		scanf("%s%d", com, &key);
		if (com[0] == 'i')
			insert(key);
		else if(com[0] == 'd')
		{
			if(strlen(com) > 6)
			{
				if(com[6] == 'F')
					deleteFirst();
				else if(com[6] == 'L')
					deleteLast();
			}
			else
				deleteKey(key);
		}
	}
	printList();
}



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

public class Main{
  public static void main(String[] args) {
    try {
      BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
      String line;
      while ((line = stdReader.readLine()) != null) { 
    	  int x = Integer.parseInt(line);
        System.out.println(x*x*x);
      }
      stdReader.close();
    } catch (Exception e) {
      e.getStackTrace();
      /*?????´??????0??????*/
      System.exit(0); 
    }
  }
}

Measured memory_bytes: 24256
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    ii = collections.defaultdict(int)
    jj = collections.defaultdict(int)

    for i, aa in enumerate(a):
        ii[i+aa] += 1
        jj[i-aa] += 1

    ans = 0


    ans = 0
    for k in ii:
        ans += ii[k]*jj[k]
    print(ans)
if __name__=='__main__':
    main()


Measured memory_bytes: 73744
n, m = map(int,input().split())
a = []
for i in range(m):
    a.append(int(input()))
dp = []
dp.append(1)
if m == 0:
    a.append(-1)
j = 0
k = len(a)-1
if 1 == a[j]:
    dp.append(0)
    j = min(k,j+1)
else:
    dp.append(1)

for i in range(2,n+1):
    if i == a[j]:
        dp.append(0)
        j = min(k,j+1)
    else:
        dp.append(dp[i-1] + dp[i-2])

print(dp[n]%(1000000007))

Measured memory_bytes: 460020
N = input()
S = raw_input()
lcnt = [0]*N
rcnt = [0]*N
run = 0
for i,c in enumerate(S):
    lcnt[i] = run
    run+=c=='W'
run=0
for i,c in enumerate(reversed(S)):
    rcnt[N-i-1] = run
    run+=c=='E'

print min(map(lambda i:lcnt[i]+rcnt[i],range(N)))


Measured memory_bytes: 41088
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool ans=true;
    REP(i, n-1){
        if(s[i]!=s[i+1]) ans=false;
    }
    if(ans) cout << "No" << endl;
    else cout <<"Yes"<< endl;
}
    




Measured memory_bytes: 256
#include <iostream>

int main() {
  unsigned int N;
  std::cin >> N;

  unsigned long sum = 0;
  for (unsigned int i = 1; i < N + 1; ++i) {
    if (i % 3 != 0 && i % 5 != 0) {
      sum += i;
    }
  }

  std::cout << sum << std::endl;

  return 0;
}


Measured memory_bytes: 3632
// AOJ 1266: How I Wonder What You Are!
// 2017.10.16 bal4u@uu

#include <stdio.h>
#include <math.h>

#define EPS 1e-7
typedef struct { double x, y, z; } PP;
PP s[502], t[52];
double phi[52];

double dist(PP *a) { return sqrt(a->x*a->x + a->y*a->y + a->z*a->z); }
double dot(PP *a, PP *b) { return a->x*b->x + a->y*b->y + a->z*b->z; }

int main()
{
	int n, m, i, j, ans;

	while (scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) scanf("%lf%lf%lf", &s[i].x, &s[i].y, &s[i].z);
		scanf("%d", &m);
		for (i = 0; i < m; i++) scanf("%lf%lf%lf%lf", &t[i].x, &t[i].y, &t[i].z, &phi[i]);
		for (ans = 0, i = 0; i < n; i++) for (j = 0; j < m; j++) {
			if (acos(dot(s+i, t+j) / (dist(s+i) * dist(t+j))) < phi[j] + EPS) {
				ans++;
				break;
			}
		}
		printf("%d\n",ans);
    }
	return 0;
}

Measured memory_bytes: 2036
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int diffX = x2 - x1;
	int diffY = y2 - y1;

	int x3 = x2 - diffY;
	int y3 = y2 + diffX;
	
	int x4 = x1 - diffY;
	int y4 = y1 + diffX;

	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

	return 0;
}


Measured memory_bytes: 256
/***
*	author  :_shamim
*	created : 05.05.2020
*
***/

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <list>
#include <set>
#include <queue>
#include <iterator>
#include <bitset>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll             long long
#define _              ios_base::sync_with_stdio(0);cin.tie(0);
#define loop           for(i=0;i<n;i++)
#define pb             push_back
#define tc()           int t;cin>>t;while(t--)          

using namespace std;

ll i,j,temp;

int main()
{_
	int n,cnt=0;

	cin>>n;
	for(i=1;i<=n;i++){
		if((i>=1 && i<=9) || (i>=100 && i<=999) ||(i>=10000 && i<=99999)){
			cnt++;
		}
	}
	cout<<cnt<<endl;



	return 0;
}

Measured memory_bytes: 256
from itertools import product
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]

ans = -10**18
for p in product([0, 1], repeat = 10):
    if sum(p) == 0:
        continue
    res = 0
    for i in range(N):
        cnt = 0
        for j in range(10):
            if p[j]:
                cnt += F[i][j]
        res += P[i][cnt]
    ans = max(ans, res)
print(ans)

Measured memory_bytes: 3064
#define ENABLE_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#if ENABLE_DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                \
  do {                            \
    cerr << " \033[33m (L";       \
    cerr << __LINE__ << ") ";     \
    cerr << #__VA_ARGS__ << ": "; \
    cerr << "\033[0m";            \
    debug(__VA_ARGS__);           \
    cerr << endl;                 \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  string S;
  cin >> S;
  int Q;
  cin >> Q;
  REP(i, Q) {
    i64 k;
    cin >> k;

    i64 nd = 0, nm = 0, ndm = 0, ans = 0;
    for (int i = 0; i < N; ++i) {
      if (i >= k) {
        int j = i - k;
        if (S[j] == 'D') {
          nd--;
          ndm -= nm;
        } else if (S[j] == 'M') {
          nm--;
        }
      }

      if (S[i] == 'D') {
        nd++;
      } else if (S[i] == 'M') {
        nm++;
        ndm += nd;
      } else if (S[i] == 'C') {
        ans += ndm;
      }
    }
    cout << ans << '\n';
  }
}


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

int main() {

    int n;
    cin >> n;
    int arr[n];
    for (int i=0; i<n; i++) cin >> arr[i];
    sort(arr, arr+n);
    int sm = 0;
    for (int i=0; i<n-1; i++) {
        sm += arr[i];
    }
    sm += arr[n-1] / 2;
    cout << sm;

}

Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B = get_ints

c = A - 2 * B
c = 0 if c < 0

puts c


Measured memory_bytes: 14376
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 2000010;

int n,m,T;
int main()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   a=max(a,c);
   b=min(b,d);
   int ans=b-a;
    if(ans<0)
        cout<<0<<endl;
    else cout<<ans<<endl;

    return 0;
}


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

const int N=5e2+20;

int n,k,a[N],s,ans;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]),s+=a[i];

	int root=sqrt(s);
	vector <int> vec;
	for(int i=1;i<=root;i++)
		if(s%i==0)
			vec.push_back(i),
			vec.push_back(s/i);

	for(auto divisor:vec)
	{
		vector <int> v;
		for(int i=0;i<n;i++) v.push_back(a[i]%divisor);

		sort(v.begin(),v.end());
		int l=0,r=1ll*divisor*v.size()-accumulate(v.begin(),v.end(),0);
		for(int i=0;i<v.size();i++)
		{
			
			l+=v[i];
			r-=divisor-v[i];
			if(l==r and l<=k) ans=max(ans,divisor);
		}
	}

	printf("%d",ans);
}

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

int main(){
    string s; cin >> s;
	if(s == "SUN") cout << 7 << endl;
    else if(s == "MON") cout << 6 << endl;
    else if(s == "TUE") cout << 5 << endl;
    else if(s == "WED") cout << 4 << endl;
    else if(s == "THU") cout << 3 << endl;
    else if(s == "FRI") cout << 2 << endl;
    else if(s == "SAT") cout << 1 << endl;
	return 0;
}


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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define llong long long

int main(){
	int n,k;
	int x;
	int ans=0;
	cin>>n>>k;
	REP(i,n){
		cin>>x;
		if(abs(x-k)<x)
			ans+=abs(x-k)*2;
		else
			ans+=x*2;
	}
	cout<<ans<<endl;
	return 0;
}


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

#define MAXN 100111

bool solve(int ans[], int a[], int n) {
  for (int i = 2; i <= n + 1; ++i) {
    if (ans[i - 1] == 1)
      ans[i] = a[i - 1] ? ans[i - 2] : 1 - ans[i - 2];
    else
      ans[i] = (1 - a[i - 1]) ? ans[i - 2] : 1 - ans[i - 2];
  }

  return ans[0] == ans[n] && ans[1] == ans[n + 1];
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int a[MAXN];
  for (int i = 0; i < n; ++i) a[i] = s[i] == 'o' ? 1 : 0;
  a[n] = a[0];
  a[n + 1] = a[1];

  int ans[MAXN];
  for (int i = 0; i < 4; ++i) {
    ans[0] = i / 2;
    ans[1] = i % 2;
    if (solve(ans, a, n)) {
      for (int j = 0; j < n; ++j) cout << (ans[j] ? 'S' : 'W');
      cout << endl;
      return 0;
    }
  }

  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 1408
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        w: usize,
        a: usize,
        b: usize,
    }
    let (a, b) = if a > b {
        (b, a)
    } else {
        (a, b)
    };
    if a + w > b {
        println!("0");
        return;
    }
    println!("{}", b - a - w);
}


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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;



int main(){

    string s;
    cin >> s;

    int size = s.size();

    vector<int> digitmod(size);
    digitmod[size - 1] = 1;

    for(int i = size - 2; i >= 0; i--){
        digitmod[i] = (digitmod[i + 1] * 10) % 2019;
    }

    vector<int> mod(size);
    mod[size - 1] = (s[size - 1] - '0') * digitmod[size - 1];

    for(int i = size - 2; i >= 0; i--){
        mod[i] = ((s[i] - '0') * digitmod[i] + mod[i + 1]) % 2019;
    }

    ll ans = 0;
    map<int, ll> m;
    m[0]++;

    for(int i = size - 1; i >= 0; i--){
        m[mod[i]]++;
        ll tmp = m[mod[i]] - 1;
        ans += tmp;
    }

    /*
    for(int i = 0; i < size; i++){
        cerr << mod[i] << " ";
    }
    cerr << endl;
    */

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define all(a) a.begin(), a.end()

signed main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int a,b,c;
	cin >> a >> b >> c;
	int k = min({a*b, b*c, a*c}), ans;
	
	if(a % 2 == 0 or b%2 == 0 or c % 2 == 0) {
		ans = 0;
	} else {
		ans = k;
	}

	cout << ans << endl;


	return 0;
}

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

int main(){

    vector< int>N(3);

    for (int i = 0; i < 3; i++) cin >> N.at(i);

    sort(N.begin(),N.end());
    
    cout << N.at(0) << " " << N.at(1)<< " " << N.at(2) <<endl;

}




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

int main()
{
    int n;
    cin >> n;
    string s;
    vector<string > ans;
    int mx = 0;
    map<string,int> mp;
    for(int i = 0; i < n; i++)
    {
        cin >> s;
        mp[s]++;
        mx = max(mx,mp[s]);
    }
    for(auto i : mp)
    {
        if(i.second == mx)
        {
            ans.push_back(i.first);
        }
    }
    sort(ans.begin(),ans.end());
    for(auto i : ans)
        cout << i << '\n' ;
    return 0;
}

Measured memory_bytes: 28916
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353

long long modpow(int n, int r) {
    long long ret = 1; long long tmp = (long long) n;
    while (r != 0) {
        if (r % 2) ret *= tmp;
        tmp *= tmp; tmp %= mod; ret %= mod;
        r /= 2;
    }
    return ret;
}

int main() {
    int n; cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) cin >> d[i];
    map<int, int> m;
    for (int i = 0; i < n; i++) m[d[i]]++;
    if (d[0] != 0 || m[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
    long long ans = 1;
    for (int i = 1; i < n; i++) {
        if (m[i] == 0 && m[i-1] == 0) continue;
        ans = ans * modpow(m[i-1], m[i]) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 string N;
 int K;
 int i;
 cin >> N >> K;
 long long int ans = 0;
 if(K==1){
     ans = (N.length()-1)*9 + (N[0]-'0');
 }
else if(K==2){
    ans = ((N.length()-1)*(N.length()-2)*81/2);
    ans += (N[0]-'0'-1)*(N.length()-1)*9;
    int find = 0;
    for(i=1;i<N.length();i++){
        if(N[i]-'0'>0){
            find=i;
            break;
        }
    }
    if(find>0)ans += (N.length()-find-1)*9+(N[find]-'0');
}
else if(K==3){
    ans = ((N.length()-1)*(N.length()-2)*(N.length()-3)*243/2);
    ans += (N[0]-'0'-1)*((N.length()-1)*(N.length()-2)*81/2);
    long long int dp[N.length()][K];
    dp[0][0]=1;
    dp[0][1]=0;
    dp[0][2]=0;
    int find1=0;
    int find2=0;
    for(i=1;i<N.length();i++){
        if(find1==0 && N[i]-'0'>0)find1=i;
        else if(find1>0 && N[i]-'0'){
            find2=i;
            break;
        }}
    if(find1>0){
        ans+=(N.length()-find1-1)*(N.length()-find1-2)*81/2;
        ans+=(N[find1]-'0'-1)*(N.length()-find1-1)*9;
        if(find2>0)ans+=(N.length()-find2-1)*9+(N[find2]-'0');
}}
cout << ans << endl;
}

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

int main(){
    int n, temp, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if(i % 2 == 0) continue;
        temp = 0;
        for (int j = 1; j <= i; j++) {
            if(i % j == 0) temp++;
        }
        if(temp == 8) ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
x = list(map(int, input().split()))

if n >= m:
    print(0)
    exit()


x.sort()
sub = [0]*(m - 1)
for i in range(m - 1):
    sub[i] = x[i+1] - x[i]
sub.sort()

for _ in range(n-1):
    sub.pop(-1)
print(sum(sub))

Measured memory_bytes: 13308
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b;
  cin >> a >> b;
  if (a < b)
    cout << "a < b" << endl;
  else if (a > b)
    cout << "a > b" << endl;
  else
    cout << "a == b" << endl;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
it qpow(int x,int k,int mod){
	int res=1,bas=x;
	while(k){
		if(k&1) res=1ll*res*bas%mod;
		bas=1ll*bas*bas%mod,k>>=1;
	}
	return res;
}
const int N = 2e6+10,mod = 1e9+7;
int a,b,c,d,ans,fac[N],ifac[N];
it add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
it mul(int x,int y){return 1ll*x*y%mod;}
il inc(int &x,int y){x=add(x,y);}
it C(int n,int m){return mul(mul(ifac[n-m],ifac[m]),fac[n]);}
it Calc(int x,int y){
	if(x==-1||y==-1) return 0;
	return add(C(x+y+2,y+1),mod-1);
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(a),read(b),read(c),read(d);
	fac[0]=1;
	for(ri i=1;i<=c+d+9;++i) fac[i]=mul(fac[i-1],i);
	ifac[c+d+9]=qpow(fac[c+d+9],mod-2,mod);
	for(ri i=c+d+8;i>=0;--i) ifac[i]=mul(ifac[i+1],i+1);
	ans=add(Calc(c,d),Calc(a-1,b-1));
	ans=add(ans,mod-add(Calc(c,b-1),Calc(a-1,d)));
	print(ans);
	return 0;
}

Measured memory_bytes: 15872
# -*- coding: utf-8 -*-

import sys

def parse_input(lines_as_string = None):


    lines = []
    if lines_as_string is None:
        lines.append(input())
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    tokens = lines[0].split(" ")
    b = tokens[0]

    return (b,)


def solve(b):
    
    m = {
        "A": "T",
        "C": "G",
        "G": "C",
        "T": "A",
    }

    return m[b]

def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

//////////////////////////////////////////////////
//nCr Calculation/////////////////////////////////
//////////////////////////////////////////////////
static const ll FACT_SIZE = 1000000;
ll fact[FACT_SIZE] = {};

ll Pow(ll n, ll p) {
	if (p == 0)return 1;
	if (p == 1)return n;
	ll t = Pow(n, p / 2);
	if (p & 1) return (t * t % MOD) * n % MOD;
	else return t * t % MOD;
}
void factorial(ll f) {
	fact[0] = fact[1] = 1;
	rep(i, 1, FACT_SIZE) fact[i] = fact[i - 1] * i % MOD;
}

ll nCr(ll n, ll r) {
	if (fact[0] == 0)	factorial(1000000);
	return ((fact[n] * (Pow(fact[r], MOD - 2) % MOD)) % MOD * Pow(fact[n - r], MOD - 2)) % MOD;
}
// Combination Table
ll C[51][51]; // C[n][k] -> nCk

void comb_table(int N) {
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= i; ++j) {
			if (j == 0 or j == i) {
				C[i][j] = 1LL;
			}
			else {
				C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
			}
		}
	}
}

ll v[51];
map<ll, ll> m;
int main() {
	comb_table(50);

	ll n, a, b; cin >> n >> a >> b;
	rep(i, 0, n) {
		cin >> v[i];
		m[v[i]]++;
	}
	sort(v, v + n);
	reverse(v, v + n);

	double ans = 0;
	rep(i, 0, a) {
		ans += v[i];
	}
	printf("%.7f\n", ans / a);

	ll minV = v[a - 1];
	ll M = m[minV];

	bool all = true;
	rep(i, 0, a) {
		if (minV != v[i]) {
			all = false;
			break;
		}
		//if (i > 0) {
		//	all &= (v[i] == v[i - 1]);
		//}
	}

	if (!all) {
		ll P = 0;
		rep(i, 0, a) {
			if (v[i] == minV) P++;
		}
		cout << C[M][P] << endl;
	}
	else {
		ll cnt = 0;
		repe(i, a, b) cnt += C[M][i];
		//repe(i, a, min(b, M)) cnt += C[M][i];
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 384
using System;

class aoj
{
    static void Main()
    {
        int[] k= new int[100];
        int b = 0;
        while (true)
        {
            string a = Console.ReadLine();
            if (String.IsNullOrEmpty(a)) break;
            k[b] = int.Parse(a);
            b++;
        }
        int[] arry = new int[b];
        for(int i = 0; i < b; i++)
        {
            arry[i] = k[i];
        }
        int[] f = new int[b];    
        int d = 0;
        Array.Sort(arry);
        for(int i = 0; i < b; i++)
        {
            if (i==0||arry[i] != arry[i - 1])
            {
                f[d] = arry[i];
                d++;
            }
        }
        int h = d;
        int []c = new int[d];
        int[] e = new int[d];
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < b; j++)
            {
                if (arry[j] == f[i])
                {
                    c[i]++;
                    e[i]++;
                }
            }
        }
        Array.Sort(c);
        int g=c[d-1];
        for(int i = 0; i <d; i++)
        {
            if (e[i] == g)
            {
                Console.WriteLine(f[i]);
            }
        }
    }
}

Measured memory_bytes: 9116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            //var length = c2i(RL());
            var rl = spr(RL()).Select(x=>(double)c2i(x)).ToList();
            var A = rl[0];
            var B = rl[1];
            var H = rl[2];
            var M = rl[3];

            var Sin_720 = (H * 60 + M)-12*(M);

            var ans = Math.Sqrt(A * A + B * B - 2*(A * B * Math.Cos(Math.Abs(Sin_720) * (Math.PI * 2)/720)));


            Console.WriteLine(ans);
            Console.ReadLine();
        
        }
 
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


Measured memory_bytes: 28700
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;
vector<string> w(N);
rep(i,N) cin >> w[i];

bool ok = true;

set <string> st;
st.insert(w[0]);

for(int i = 1 ; i < N ; i++ ) {
    st.insert(w[i]);
    int s = w[i-1].size();
    if(w[i][0] != w[i-1][s-1]) ok = false;
}

if( st.size() != N ) ok = false;

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

return 0;
}

Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
edges = [set() for _ in range(N)]
ins = [0]*N
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    ins[b] += 1
    edges[a].add(b)

dp = [-1]*N

start = []
for i in range(N):
    if ins[i] == 0:
        start.append(i)


def dfs(s):
    if dp[s] != -1:
        return dp[s]
    mx = 0
    if edges[s]:
        mx = max([dfs(dest)+1 for dest in edges[s]])
    dp[s] = mx
    return mx


ans = -1
for i in range(N):
    if ins[i] == 0:
        ans = max(ans, dfs(i))

print(ans)


Measured memory_bytes: 242472
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない


int main() {

	int a, b, c;
	cin >> a >> b >> c;

	if (c <= a + b) {
		cout << b+c << endl;
	}
	else{
		cout << 2 * b + a + 1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
n = str(input())
a = n[-1]
if a == '2' or a == '4' or a == '5' or a == '7' or a == '9':
    print('hon')
elif a == '0' or a == '1' or a == '6' or a == '8':
    print('pon')
elif a == '3':
    print('bon')

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

int main(){
  int a,b;
  cin >>a>>b;
  int s=a+b;
  
  if(s%2==1) cout <<s/2+1<<endl;
  else if(s%2==0) cout <<s/2<<endl;
  
  return 0;
}


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

using namespace std;

#define MAX 100001
#define MOD 1000000007
typedef long long ll;

int par[MAX],rank[MAX];

void init(int N){
  for(int i = 0 ; i < N ; i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  }
  return par[x] = find(par[x]);
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y){ return; }
  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank[x] == rank[y]){
      rank[x]++;
    }
  }
}

bool same(int x,int y){
  return (find(x) == find(y));
}

ll mod_pow(ll x,ll n){
  if(n == 0){ return 1; }
  ll res = mod_pow(x*x%MOD,n/2);
  if(n & 1){ res = res*x%MOD; }
  return res;
}

int main(){
  int N,M,a,b;
  while(cin >> N >> M,N){
    init(N);
    for(int i = 0 ; i < M ; i++){
      cin >> a >> b; a--; b--;
      unite(a,b);
    }
    ll cnt = 0;
    bool visited[MAX] = {false};
    for(int i = 0 ; i < N ; i++){
      int x = find(i);
      if(!visited[x]){
        visited[x] = true;
        cnt++;
      }
    }
    ll res = mod_pow(2,cnt);
    if(cnt != N){ ++res; }
    cout << res%MOD << endl;
  }
  return 0;
}

Measured memory_bytes: 2040
#include <stdio.h>

typedef struct {
	double x;
	double y;
} POINT;

int main(void)
{
	POINT p1, p2, p3;
	double m1, n1, m2, n2, kai_x, kai_y;
	
	while (scanf("%lf,%lf,%lf,%lf,%lf,%lf", &p1.x, &p1.y, &p2.x, &p2.y, &p3.x, &p3.y) != EOF){
		if (p1.x == p2.x){
			printf("%f %f\n", p2.x - (p3.x - p2.x), p3.y);
		}
		else if (p1.y == p2.y){
			printf("%f %f\n", p3.x, p2.y - (p3.y - p2.y));
		}
		else {
			m1 = (p1.y - p2.y) / (p1.x - p2.x);
			n1 = p1.y - m1 * p1.x;
			
			m2 = -1 * 1 / m1;
			n2 = p3.y - m2 * p3.x;
			
			kai_x = (n1 - n2) / (m2 - m1);
			kai_y = m1 * kai_x + n1;
			printf("%f %f\n",2 * kai_x - p3.x, 2 * kai_y - p3.y);
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	h := iSScan(n)
	h[0]--
	ans := "Yes"
	for i := 1; i < n; i++ {
		if h[i-1] > h[i] {
			ans = "No"
			break
		} else if h[i-1] < h[i] {
			h[i]--
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0; i<n;i++){
        cin>>arr[i];
    }
    
    vector<int> ans(n,0);
    for(int i=1;i<n;i++){
        int tans=INT_MAX;
        for(int j=1;j<=k;j++){
            if(i-j>=0){
            tans=min(tans,abs(arr[i]-arr[i-j])+ans[i-j]);
            }
            else{
                break;
            }
        }
        ans[i]=tans;
    }
    cout<<ans[n-1];
}


Measured memory_bytes: 4028
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

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

    long long N;

    cin >> N;

    cout << N * (N - 1) / 2;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{a:String,b:String};
    if a.len() != b.len() {
        println!("{}", if a.len()>b.len(){"GREATER"} else {"LESS"});
        return();
    }
    println!("{}", if a>b {"GREATER"} else if a==b {"EQUAL"} else {"LESS"});
}


Measured memory_bytes: 4352
/* Tuan Kkura */
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
#define PROB "text"
#define MAXN 1005

int a[MAXN], b[MAXN];
ll dp[5*MAXN], cur[5*MAXN];

int main()
{
    _io
    int n, m; cin >> n >> m;
    FOR(i, 1, m)
    {
        int cnt;
        cin >> a[i] >> cnt;
        int val = 0;
        FOR(j, 1, cnt)
        {
            int x; cin >> x;
            val += (1<<(x-1));
        }
        b[i] = val;
    }
    fill(dp+1, dp+5000+1, INT_MAX);
    int MaxState = (1<<n)-1;
    FOR(i, 1, m)
    {
        FOR(state, 0, MaxState)
            cur[state] = dp[state];
        FOR(state, 0, MaxState)
        {
            int new_state = (state | b[i]);
            dp[new_state] = min(dp[new_state], cur[state] + a[i]);
        }
    }
    if(dp[MaxState] == INT_MAX) cout << -1;
    else cout << dp[MaxState];
}


Measured memory_bytes: 384