akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

struct Node {
    int id;
    vector<int> nexts;
};

int N;
vector<Node> nodes;

// idx, dist
pair<int, int> f(int start) {
    vector<int> dist(N, 1234567);
    dist[start] = 1;
    queue<int> q;
    q.push(start);
    int maxIdx = -1;
    int maxDist = 0;
    while (!q.empty()) {
        int now = q.front(); q.pop();
        maxIdx = now;
        int d = dist[now];
        for (int next : nodes[now].nexts) {
            if (dist[next] <= d + 1) continue;
            dist[next] = d + 1;
            maxDist = max(maxDist, d + 1);
            q.push(next);
        }
    }
    return mp(maxIdx, maxDist);
}

signed main() {
    cin >> N;

    nodes.resize(N);

    if (N == 1) {
        cout << "First" << endl;
        return 0;
    }

    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        nodes[a].nexts.push_back(b);
        nodes[b].nexts.push_back(a);
    }

    auto pr = f(0);
    pr = f(pr.first);

    int sz = pr.second;

    if (sz % 3 == 2) cout << "Second" << endl;
    else cout << "First" << endl;

    return 0;
}


Measured memory_bytes: 17520
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;
  
  if(S.at(K-1) == 'A'){
    S.at(K-1) = 'a';    
  }
  if(S.at(K-1) == 'B'){
    S.at(K-1) = 'b';
  }
  if(S.at(K-1) == 'C'){
    S.at(K-1) = 'c';
  }
  cout << S << endl;
  return 0;
}
    
  


Measured memory_bytes: 256
// AOJ 0515 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0515)
#include<cstdio>
#include<cstring>
#define rep(i,a) for(int i=0;i<(a);++i)
#define clr(a,v) memset((a),(v),sizeof(a))

typedef long long ll;

int a, b;
bool used[17][17];
ll dp[17][17];

int main()
{
	while( scanf( "%d%d", &a, &b ), a|b )
	{
		int n;
		scanf( "%d", &n );

		clr( used, false );
		clr( dp, 0 );

		rep( i, n )
		{
			int x, y;
			scanf( "%d%d", &x, &y );
			used[y-1][x-1] = true;
		}

		dp[0][0] = 1;

		rep( j, a ) rep( i, b ) if( !used[i][j] && (i||j) )
			dp[i][j] = (j-1>=0?dp[i][j-1]:0)+(i-1>=0?dp[i-1][j]:0);

		printf( "%lld\n", dp[b-1][a-1] );
	}

	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,k;
	cin>>a>>b>>k;
	int c=a,d=b;
	if(k>=((b-a+1)/2+1))
	{
		for(int i=a;i<=b;i++)
		cout<<i<<endl;
		return 0;
	}
	for(int i=0;i<k;i++)
	cout<<c++<<endl;
	d-=(k-1);
	for(int i=d;i<=b;i++)
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
x = list(map(int,input().split()))
y = list(map(int,input().split()))
z = list(map(int,input().split()))
n = int(input())
for i in range(n):
    b = int(input())
    if b in x:
        x[x.index(b)] = 'T'
    if b in y:
        y[y.index(b)] = 'T'
    if b in z:
        z[z.index(b)] = 'T'
if x[0] == 'T' and x[1] == 'T' and x[2] == 'T':
    print('Yes')
elif y[0] == 'T' and y[1] == 'T' and y[2] == 'T':
    print('Yes')
elif z[0] == 'T' and z[1] == 'T' and z[2] == 'T':
    print('Yes')
elif x[0] == 'T' and y[0] == 'T' and z[0] == 'T':
    print('Yes')
elif x[1] == 'T' and y[1] == 'T' and z[1] == 'T':
    print('Yes')
elif x[2] == 'T' and y[2] == 'T' and z[2] == 'T':
    print('Yes')
elif x[0] == 'T' and y[1] == 'T' and z[2] == 'T':
    print('Yes')
elif x[2] == 'T' and y[1] == 'T' and z[0] == 'T':
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9296
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

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

	int N, K;
	vector<long long> H;
	
	cin >> N >> K;
	

	for(int i = 1; i <=N; i++){
		long long h;
		cin >> h;
		H.push_back(h);
	}

	sort(H.begin(), H.end());

	long long ans = 0;
	if(K >= N){
		printf("%lld\n", ans);
		return 0;
	}

	for(int j=1; j<=K; j++){ H.pop_back(); }
	for(int i=0; i<H.size(); i++){ ans += H[i]; }
	printf("%lld\n", ans);
	return 0;
}

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

int LIMIT = 200000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    string t;
    cin >> s;
    cin >> t;
    unordered_map<char, vector<int>> m;
    for (int i = 0; i < s.length(); i++) {
        m[s[i]].push_back(i + 1);
    }
    // にぶたんで配列外参照を起こさないように
    for (char i = 'a'; i <= 'z'; i++) {
        m[i].push_back(LIMIT);
    }

    long long ans = 0;
    int p = 0;
    for (auto i : t) {
        if (m[i][0] == LIMIT) {
            cout << -1 << endl;
            return 0;
        }
        int c = *lower_bound(m[i].begin(), m[i].end(), p + 1) == LIMIT
                    ? m[i][0]
                    : *lower_bound(m[i].begin(), m[i].end(), p + 1);
        if (c <= p) {
            ans += s.length() - p;
            p = 0;
        }
        ans += (c - p);
        p = c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1228
import sys
import math

n = int(sys.stdin.readline().rstrip())
point = []
for i in range(n):
    ax = list(map(int, sys.stdin.readline().rstrip().split()))
    if ax[0] != 0 or ax[1] != 0:
        point.append(ax)

result = 0
plen = len(point)
if plen == 0:
    print(0)
    exit()

point = sorted(point, key=lambda x: math.atan2(x[1], x[0]))

point = point + point
for i in range(plen):
    maxdig = 0
    maxp = [0, 0]
    for j in range(i, i + plen):
        tmpp = (maxp[0] + point[j][0]) ** 2 + (maxp[1] + point[j][1]) ** 2
        if maxdig > tmpp:
            if result < maxdig:
                result = maxdig
            break
        else:
            maxdig = tmpp
            maxp[0] += point[j][0]
            maxp[1] += point[j][1]
            if j == i + plen -1 and result < maxdig:
                result = maxdig


print(result ** 0.5)



Measured memory_bytes: 39028
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a[4];
  string s; cin >> s;
  rep(i, 4) a[i] = s[i]-'0';
  rep(i, 1<<3) {
    int tmp = a[0];
    rep(j, 3) {
      if((i>>j)&1) tmp += a[j+1];
      else tmp -= a[j+1];
    }
    if(tmp == 7) {
      cout << a[0];
      rep(j, 3) {
        if((i>>j)&1) cout << '+';
        else cout << '-';
        cout << a[j+1];
      }
      cout << "=7" << endk;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n;cin>>n;
    string s;cin>>s;
    int ans=1;
    for(int i=1;i<n;i++)ans+=(s[i]!=s[i-1]);
    cout<<ans;
}

Measured memory_bytes: 512
a=0
L=[]
N=int(input())
for i in range(1,N+1):
  if i%2==1: 
    a=0
    for j in range(1,i+1):
      if i%j==0:
        a+=1
    L.append(a)
    
  
print(L.count(8))
  

Measured memory_bytes: 2940
#include <stdio.h>
#define MAX 100000

typedef struct{
  int parent;
  int left;
  int right;
  int depth;
  int height;
}Node;

Node T[MAX];
int c[2];

int getDepth(int);
int getHeight(int);
void print(int);

int main(){
  int l, n, m, i, j, k;

  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }
  
  for(i = 0; i < n; i++){
    scanf("%d", &l);
    for(j = 0; j < 2; j++){
      scanf("%d", &c[j]);
      if(c[j] != -1){
	T[c[j]].parent = l;
	if(j == 0) T[l].left = c[j];
	else T[l].right = c[j];
      }
    }
  }

  for(i = 0; i < n; i++){
    T[i].depth = getDepth(i);
    T[i].height = getHeight(i);
  }

  print(n);
  
  return 0;
}

void print(int n){
  int m, i, j;
  
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, sibling = ", i, T[i].parent);

    if(T[i].parent == -1) printf("-1, ");
    else if(T[T[i].parent].left == i && T[T[i].parent].right == -1) printf("-1, ");
    else if(T[T[i].parent].right == i && T[T[i].parent].left == -1) printf("-1, ");
    else if(T[T[i].parent].left == i) printf("%d, ", T[T[i].parent].right);
    else if(T[T[i].parent].right == i) printf("%d, ", T[T[i].parent].left);
    
    printf(T[i].left == -1 && T[i].right == -1 ? "degree = 0, " :
	   T[i].left != -1 && T[i].right != -1 ? "degree = 2, " : "degree = 1, ");
    
    printf("depth = %d, ", T[i].depth);
    printf("height = %d, ", T[i].height);
    
    printf(T[i].parent == -1 ? "root" :
	   T[i].left == -1 && T[i].right == -1 ? "leaf" : "internal node");
    printf("\n");
  }
}

int getDepth(int u){
  if(T[u].parent == -1) return 0;
  return getDepth(T[u].parent) + 1;
}

int getHeight(int u){
  int a = 0, b = 0;
  if(T[u].left != -1) a = getHeight(T[u].left) + 1;
  if(T[u].right != -1) b = getHeight(T[u].right) + 1;
  return a>b ? a : b;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
vector<int> solve(int now,int x,int y){
	//cout<<now<<' '<<x<<' '<<y<<endl;
	vector<int> temp,temp1,ans;
	if(x==1&&y==0&&now==1){
		temp.push_back(1);
		temp.push_back(0);
		return temp;
	}
	if(x==0&&y==1&&now==1){
		temp.push_back(0);
		temp.push_back(1);
		return temp;
	}
	int i,j,k,l;
	for(i=0;i<now;i++){
		if((x&(1<<i))!=(y&(1<<i))){
			//cout<<i<<endl;
			j=(1<<i);
			k=x%j+((x>>(i+1))<<i);
			l=y%j+((y>>(i+1))<<i);
			if((__builtin_popcount(k)&1)==1){
				temp=solve(now-1,k,0);
				temp1=solve(now-1,0,l);
			}
			else{
				temp=solve(now-1,k,1);
				temp1=solve(now-1,1,l);
			}
			for(k=0;k<temp.size();k++){
				l=temp[k]%j+(x&j)+((temp[k]>>i)<<(i+1));
				//cout<<temp[k]<<' '<<temp[k]%j+(x&j)+((temp[k]>>i)<<(i+1))<<endl;
				ans.push_back(l);
			}
			for(k=0;k<temp1.size();k++){
				l=temp1[k]%j+(y&j)+((temp1[k]>>i)<<(i+1));
				ans.push_back(l);
			}
			break;
		}
	}
	return ans;
}
int main(){
	int n,a,b,i,j,k,l;
	cin>>n>>a>>b;
	if((__builtin_popcount(a)&1)==(__builtin_popcount(b)&1)){
		cout<<"NO";
		return 0;
	}
	cout<<"YES\n";
	vector<int> temp=solve(n,a,b);
	for(i=0;i<temp.size();i++){
		cout<<temp[i]<<' ';
	}
}

Measured memory_bytes: 1628
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin >> a;
	int l = a.length();
	int pd1 = 1, pd2 = 1;
	for(int i = 0 ; i < l ; i++){
		if(a[i] == 'C') pd1 = 2;
		if(pd1 == 2 && a[i] == 'F'){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import deque
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

S = input()
T = input()

for i in range(len(S)+1):
    if S == T[i:] + T[:i]:
        print("Yes")
        break
else:
    print("No")

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/28  Problem: ABC 105 D / Link: http://abc105.contest.atcoder.jp/tasks/abc105_d  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	LL N, M; cin >> N >> M;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	map<LL, LL>m;
	LL prefixsum = 0;
	FOR(i, 0, N) {
		m[prefixsum]++;
		prefixsum += a[i];
		prefixsum %= M;
		ans += m[prefixsum];
	}


	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		ArrayList<Word> list = new ArrayList<Word>();

		while( null !=(str=br.readLine())){
			String voc = str.substring(0, str.indexOf(" "));
			int n = Integer.parseInt(str.substring(str.indexOf(" ")+1, str.length()));

			if(list.isEmpty()){
				list.add(new Word(voc, n));
			}else{
				boolean judge=false;
				for(int i=0; i<list.size(); i++){
					if(list.get(i).getString().equals(voc)){
						list.get(i).ListIn(n);
						judge=true;
						break;
					}
				}
				if(!judge){
					list.add(new Word(voc, n));
				}
			}
		}
		Collections.sort(list, new Comparator<Word>() {
			public int compare(Word o1, Word o2) {
				return o1.getString().compareTo(o2.getString());
			}
		});

		for(int i=0; i<list.size(); i++){
			System.out.println(list.get(i).getString());
			System.out.println(list.get(i).getNumbers());
		}

	}
}

class Word{
	String str;
	ArrayList<Integer> Index = new ArrayList<Integer>();

	Word(String str, int n){
		this.str = str;
		this.Index.add(n);
	}

	void ListIn(int n){
		Index.add(n);
		Collections.sort(Index);
	}

	String getString(){
		return this.str;
	}

	String getNumbers(){
		String str="";
		for(int i=0; i<Index.size(); i++){
			if(i == Index.size()-1){
				str += Index.get(i);
			}else{
				str += Index.get(i) + " ";
			}
		}
		return str;
	}

}

Measured memory_bytes: 16932
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    int n;
    cin>>n;
    vector<int>h(n);
    for(int i=0;i<n;i++){
        cin>>h.at(i);
    }
    int ans=0;
    int tmp=0;
    for(int i=0;i<n-1;i++){
        if(h.at(i)>=h.at(i+1)){
            tmp++;
        }
        else{
            tmp=0;
        }
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;





    return 0;
}


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


int main() {
  string s;
  int num0, num1;

  cin >> s;
  num0 = atoi(s.c_str());
  num1 = num0 % 100;
  num0 /= 100;

  if ((num0 == 0 || 12 < num0) && (num1 == 0 || 12 < num1)) {
    cout << "NA" << endl;
  } else if ((1 <= num0  && num0 <= 12) && (1 <= num1 && num1 <= 12)) {
    cout << "AMBIGUOUS" << endl;
  } else {
    if (1 <= num0  && num0 <= 12) {
      cout << "MMYY" << endl;
    } else if (1 <= num1 && num1 <= 12) {
      cout << "YYMM" << endl;
    }
  }
}
/* 2 10 20 */


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
	char s[201];
	scanf("%s",s);
	int i,j,k;
	int n = strlen(s);
	int ans = 0;
	int temp;
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n-1;j++){
			if(s[i]==s[j]){
				temp = 2;
				for(k=1;k<j-i;k++){
					if( (j+k)>=n-1){
						break;
					}
					if(s[i+k]==s[j+k]){
						temp += 2;
					}else{
						temp = 0;
					}
				}
				if(temp == 2*(j-i)){
					if(ans<temp){
						ans = temp;
					}
				}
			}
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

s = list(inp())
q = iinp()

l = []

p = 0
o = 1

for i in range(q):
  a = inps()
  if o == 1 and a[0] == 1:
    continue
  if a[0] == "2":
    if a[1] == "1":
      if p == 0:
        l.append(a[2])
        o += 1
      else:
        s.append(a[2])
        o += 1
    else:
      if p == 0:
        s.append(a[2])
        o += 1
      else:
        l.append(a[2])
        o += 1
  if a[0] == "1":
    if p == 0:
      p = 1
    else:
      p = 0

if p == 0:
  for i in range(len(l)):
    print(l[len(l)-1-i],end="")
  for i in s:
    print(i,end="")
  print("")
else:
  for i in range(len(s)):
    print(s[len(s)-1-i],end="")
  for i in l:
    print(i,end="")
  print("")

Measured memory_bytes: 7188
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    cout << ((N + 1) / 2) * 1.0 / N;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 1000005;
const LL MOD = 998244353;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, m;
LL fac[MAXN], inv[MAXN], finv[MAXN];

inline LL ksm(LL x, LL k) {
	LL ret = 1;
	while (k) {
		if (k & 1) ret = ret * x % MOD;
		x = x * x % MOD;
		k >>= 1;
	}
	return ret;
}

inline LL C(int x, int y) {
	return fac[x] * finv[y] % MOD * finv[x-y] % MOD;
}

inline LL Calc(int x, int y) {
	return C(x + y, y);
}

void init() {
	read(n); read(m);
	fac[0] = fac[1] = inv[0] = inv[1] = finv[0] = finv[1] = 1;
	for (int i=2;i<=n+m;++i) {
		fac[i] = fac[i-1] * i % MOD;
		inv[i] = (MOD-MOD/i) * inv[MOD%i] % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
}

void solve() {
	if (n < m) swap(n, m);
	LL sum = Calc(n, m), ans = sum * n % MOD;
	for (int i=1;i<=m;++i) {
		ans = (ans + Calc(n-i, m-i) * Calc(i, i-1)) % MOD;
	}
	ans = ans * ksm(sum, MOD-2) % MOD;
	printf("%lld\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
const int N = 1e5+7 ;
string s ;

int main(){fast ;
	int n,k ;
	cin >> n ;
	vector<int> a(N,0) , b(N,0) ;
	for(int i = 0 ; i < n ; i++){
		cin >> k ;
		if(i&1)
			a[k]++ ;
		else
			b[k]++ ;	
	}
	int x = 0 , y = 0 ;
	for(int i = 0 ; i < N ; i++)
		if(a[i] > a[x]) x = i ;
	for(int i = 0 ; i < N ; i++)
		if(b[i] > b[y]) y = i ;
	if(x != y)
		n -= (a[x] + b[y]) ; // sum of max of both
	else{
		int c = 0, d = 0;
		for(int i = 0 ; i< N ; i++){
			if(i != y){
				c = max(c,b[i]) ; // second max from b
			}
		}
		for(int i = 0 ; i < N ; i++){
			if(i != x){
				d = max(d,a[i]) ; // second max from a 
			}
		}
		n -= max(a[x]+c , b[y]+d) ;
	}
	cout << n << endl ;
}




Measured memory_bytes: 1148
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>

using namespace std;


int main(){
	string s;
	cin >> s;

	int count = 0;

	for (int i = 0; i < s.length(); i++) {
		int count1=0;
		int l = i;
		while (s[l] == 'A' || s[l] == 'T' || s[l] == 'C' || s[l] == 'G') {
			count1++;
			l++;
		}
		if (count1 > count)count = count1;
	}

	cout << count << endl;

	return 0;
}


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

using namespace std;

int main(void)
{
    string S;
    int N, K;
    cin >> N >> K >> S;
    S[K - 1] += 'a' - 'A';
    cout << S << endl;
    return 0;
}

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

int main()
{
  ll x;
  ll n = 100, cnt = 0;
  cin >> x;
  while(n < x)
  {
    n *= 1.01;
    cnt++;
  }
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
ll N,A,B,C,D;
map<ll,ll> reach;
inline ll calmin(ll p,ll q)
{
	if(q>=p)return p;
	return min(q*D,p);
}
void check(ll x)
{
	if(reach.count(x))
	{
	//	cout<<x<<" "<<reach[x]<<endl;
		return;
	}
	ll& res=reach[x];
	res=linf;
	for(int mi=0;mi<5;mi++)
	{
		if(mi<2&&(x+mi)%2==0)
		{
			check((x+mi)/2);
			res=min(res,reach[(x+mi)/2]+1ll*D*mi+calmin(A,1ll*(x+mi)/2));
		//	cout<<x<<" "<<2<<" "<<res<<" "<<(x+mi)/2<<" "<<reach[(x+mi)/2]<<endl;
		}
		if(mi<3&&(x+mi)%3==0)
		{
			check((x+mi)/3);
			res=min(res,reach[(x+mi)/3]+1ll*D*mi+calmin(B,2ll*(x+mi)/3));
		//	cout<<x<<" "<<3<<" "<<res<<" "<<(x+mi)/3<<" "<<reach[(x+mi)/3]<<endl;
		}
		if(mi<5&&(x+mi)%5==0)
		{
			check((x+mi)/5);
			res=min(res,reach[(x+mi)/5]+1ll*D*mi+calmin(C,4ll*(x+mi)/5));
		//	cout<<x<<" "<<5<<" "<<res<<" "<<(x+mi)/5<<" "<<reach[(x+mi)/5]<<endl;
		}
		
		if(mi<2&&mi<=x&&(x-mi)%2==0)
		{
			check((x-mi)/2);
			res=min(res,reach[(x-mi)/2]+1ll*D*mi+calmin(A,1ll*(x-mi)/2));
		//	cout<<x<<" "<<2<<" "<<res<<" "<<(x+mi)/2<<" "<<reach[(x+mi)/2]<<endl;
		}
		if(mi<3&&mi<=x&&(x-mi)%3==0)
		{
			check((x-mi)/3);
			res=min(res,reach[(x-mi)/3]+1ll*D*mi+calmin(B,2ll*(x-mi)/3));
		//	cout<<x<<" "<<3<<" "<<res<<" "<<(x+mi)/3<<" "<<reach[(x+mi)/3]<<endl;
		}
		if(mi<5&&mi<=x&&(x-mi)%5==0)
		{
			check((x-mi)/5);
			res=min(res,reach[(x-mi)/5]+1ll*D*mi+calmin(C,4ll*(x-mi)/5));
		//	cout<<x<<" "<<5<<" "<<res<<" "<<(x+mi)/5<<" "<<reach[(x+mi)/5]<<endl;
		}
	}
//	cout<<x<<' '<<res<<endl; 
}
void solve()
{
	scanf("%lld%lld%lld%lld%lld",&N,&A,&B,&C,&D);
	reach.clear();
	reach[0]=0;
	reach[1]=D;
	check(N);
	printf("%lld\n",reach[N]);
}
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 4584
def sum_(s, e):
    return (s + e) * (e - s + 1) / 2

n = int(input())

num_3 = n // 3
num_5 = n // 5
num_15 = n // 15
sum_3 = sum_(1, num_3) * 3
sum_5 = sum_(1, num_5) * 5
sum_15 = sum_(1, num_15) * 15
ans = int(sum_(1, n) - (sum_3 + sum_5 - sum_15))

print(ans)


Measured memory_bytes: 9180
N, L = map(int, input().split())
A = list(map(int, input().split()))

s = 0
for i in range(N-1):
    if A[i] + A[i+1] > s:
        s = A[i] + A[i+1]
        ind = i

if s < L:
    print('Impossible')
else:
    print('Possible')
    for i in range(N-1):
        if i == ind:
            break
        print(i+1)
    for i in reversed(range(N-1)):
        if i == ind:
            break
        print(i+1)
    print(ind+1) 

Measured memory_bytes: 14060
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 10;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

vector<int> G[2 * MAX]; //次に行くところを管理する
bool used[2 * MAX];

int dfs(int v, int N){
    bool all_visited = true;
    for(int i = 1; i <= N; i ++) if(!used[i]) all_visited = false;
    if(all_visited) return 1;
    int ans = 0;
    for(int s: G[v]){ //cout << s << endl;
        if(used[s]) continue;
        used[s] = true;
        ans += dfs(s, N);
        used[s] = false;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    rep(i, MAX) used[i] = false;
    int n, m;
    cin >> n >> m;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    used[1] = true;
    cout << dfs(1, n) << endl;


}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -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 ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    map<P, vector<P>> graph;
    rep(i, M) {
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        graph[make_pair(u, 0)].push_back(make_pair(v, 1));
        graph[make_pair(u, 1)].push_back(make_pair(v, 2));
        graph[make_pair(u, 2)].push_back(make_pair(v, 0));
    }
    ll S, T;
    cin >> S >> T;
    S--;
    T--;
    vector<vector<ll>> dist(N, vector<ll>(3, INF));
    dist[S][0] = 0;
    queue<pair<P, ll>> que;
    que.push(make_pair(make_pair(S, 0), 0));
    while (!que.empty()) {
        auto q = que.front();
        que.pop();
        P p = q.first;
        ll d = q.second;
        for (P v : graph[p]) {
            if (dist[v.first][v.second] == INF) {
                dist[v.first][v.second] = d + (p.second == 0 ? 1 : 0);
                que.push(make_pair(make_pair(v.first, v.second), dist[v.first][v.second]));
            }
        }
    }
    ll ans = dist[T][0];
    if (ans == INF) {
        cout << -1 << '\n';
    } else {
        cout << ans << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 38528
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long a,b;
    cin>>a>>b;
    if(a>b){
        a=a%b;
    }
    cout<<min(a,b-a)<<endl;;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  int a[15][15];
  rep(i, n){
    cin >> c[i];
    rep(j, m){
      cin >> a[i][j];
    }
  }
  int ans=INF;
  for(int i=0; i<(1<<n); i++){
    int cost=0;
    vector<int> und(m);
    rep(j, n){
      if(i &(1<<j)){
        cost+=c[j];
        rep(k, m){
          und[k]+=a[j][k];
        }
      }
    }
    bool flag=true;
    rep(k, m){
      if(und[k]<x){
        flag=false;
        break;
      }
    }
    if(flag){
      ans=min(ans, cost);
    }
  }
  if(ans==INF){
    cout << "-1" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	scanner.Scan()

	a := strings.Split(scanner.Text(), " ")
	for i := len(a) - 1; i > 0; i-- {
		fmt.Printf("%s ", a[i])
	}
	fmt.Printf("%s\n", a[0])
}



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

int main(){
    int  n, m;  cin >> n >> m;
    ll left=0, right=1e+10;
    for(int i=0; i<m; i++){
        ll a, b;   cin >> a >> b;
        left = max(a, left);
        right = min(b, right);
    }
    cout << max(0LL, right-left+1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int n;
int a[101];

int main() {
    cin >> n;
    rep(i, n) cin >> a[i];

    for (int k = 0; k < n; k++) {
        if (k > 0) cout << " ";
        cout << a[k];
    }
    cout << endl;

    for (int i = 1; i < n; i++) {
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        for (int k = 0; k < n; k++) {
            if (k > 0) cout << " ";
            cout << a[k];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3084
/***********************************
*******AUTHOR SHASHI KANT **********         
****GMAIL Shshiksnt140895@gmail.com*
************************************                                  
***********************************/
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
/*class graph
{
	map<int,list<int>>adj;
	public :
	       void addedge(int a, int b)
	       {
	           adj[a].push_back(b);
	           adj[b].push_back(a);
	       }

}*/
	ll dp[3001][3001];
ll max_value(int arr[], int i, int j, int turn)
{

       //cout<< "hello" <<" ";
        if(i>j)
        	return 0;

        if(dp[i][j] != -1)
        	return dp[i][j];

       if(turn == 1)
       	return  dp[i][j] =  max(arr[i]+max_value(arr, i+1, j, 0), arr[j]+max_value(arr, i, j-1, 0));
       else
       	 return dp[i][j] = min(max_value(arr,i+1, j , 1), max_value(arr,i, j-1, 1 ));
}
int main(){
       int n;
       cin>>n;
       int arr[n];
       ll sum =0;
               memset(dp, -1, sizeof(dp));
       for(int i=0; i<n; i++)
       {
           cin>>arr[i];
           sum+=arr[i];
       }

       ll max1  = max_value(arr, 0, n-1,1) ;
      // cout<< max1 <<" ";
       ll max2 = sum - max1;
       cout<< max1 - max2 <<endl;

	return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int A, B, C, D;

int main() {
    vector<int> N(4);
    for (int i = 0; i < 4; i++) {
        cin >> N[i];
    }
    sort(N.begin(), N.end());
    if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 1000

int push(int A[], int *top, int val){
    if(*top == MAX -1) return 0;
    A[++(*top)]=val;
    return val;
}

int pop(int A[], int *top){
    if(*top == 0) return 0;
    (*top)--;
    return A[(*top)+1];
}

int main(){
    int arr[1000], a, b;
    int top=0;
    char val[100];
    while(scanf("%s", val) != EOF){
        if(val[0]=='+'){
            a=pop(arr, &top);
            b=pop(arr, &top);
            push(arr, &top, a+b);
        }else if(val[0]=='-'){
            a=pop(arr, &top);
            b=pop(arr, &top);
            push(arr, &top, b-a);
        }else if(val[0]=='*'){
            a=pop(arr, &top);
            b=pop(arr, &top);
            push(arr, &top, a*b);
        }else{
            push(arr, &top, atoi(val));
        }
    }
    printf("%d\n", pop(arr, &top));
    return 0;
}

Measured memory_bytes: 2688
#include<stdio.h>
#define mod 1000000007
int main(){
  int n;
  scanf("%d",&n);
  long long int ans,ten=1,nine=1,ei=1;
  int i;
  for (i=0;i<n;i++){
    ten=(ten*10)%mod;
    nine=(nine*9)%mod;
    ei=(ei*8)%mod;
  }
  ans=(ten-(2*nine)%mod+ei)%mod;
  if (ans<0) ans=mod+ans;
  printf("%lli\n",ans);
  return 0;
}

Measured memory_bytes: 1736
import java.util.*;

class Main {
    static long solve(int weight[], int value[], int N, int W) {
        long ans = Integer.MIN_VALUE;
        long dp[][] = new long[N + 1][W + 1];

        for (int w = 0; w <= W; w++) {
            dp[1][w] = 0;
        }
        dp[1][weight[1]] = value[1];

        for (int i = 2; i <= N; i++) {
            for (int w = 0; w <= W; w++) {
                dp[i][w] = dp[i - 1][w];
                if (weight[i] <= w)
                    dp[i][w] = Math.max(dp[i][w], value[i] + dp[i - 1][w - weight[i]]);
            }
        }
        for (int w = 0; w <= W; w++) {
            ans = Math.max(ans, dp[N][w]);
        }
        return ans;
    }

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

        int weight[] = new int[n + 1];
        int value[] = new int[n + 1];

        for (int i = 1; i <= n; i++) {
            weight[i] = sc.nextInt();
            value[i] = sc.nextInt();
        }

        System.out.println(solve(weight, value, n, w));
    }
}

Measured memory_bytes: 132308
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);
    
    const S = arg[1].split("").map(n=>parseInt(n));
    
    // 奇数番目に連続する1の数、偶数版目に連続する0の数 の配列を用意
    let list = [];
    
    if(S.indexOf(0) === -1) {
        console.log(N);
        return;
    }
    
    if(S.indexOf(1) === -1) {
        console.log(N);
        return;
    }
    
    if(S[0] !== 1) {
        list.push(0);
    }
    
    let streak = 0;
    
    for(let i=1; i<S.length; i++) {
        if(S[i] === S[i - 1]) {
            streak++;
        } else {
            streak++;
            list.push(streak);
            streak = 0;
        }
    }
    
    streak++;
    list.push(streak);
    
    if(S[S.length - 1] !== 1) {
        list.push(0);
    }
    
    let answer = 0;
    
    if(K + K > list.length) {
        
        answer = list.reduce((m,n)=>m+n)
    
    } else {
        
        // 累積和
        let cumulativeSum = [list[0]];
        
        for(let i=1; i<list.length; i++) {
            cumulativeSum[i] = cumulativeSum[i-1] + list[i];
        }
        
        for(let left=0; left<list.length - (K + K); left += 2) {
            let sum = cumulativeSum[left + K + K];
            let minus = left - 1 > 0 ? cumulativeSum[left - 1] : 0;

            answer = Math.max(sum - minus, answer);
        }
        
    }

    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 15156
#include <cstdio>
#define int long long
using namespace std;
int n,m,a[55],f[55][8005],ans;
signed main(){
	scanf("%lld %lld",&n,&m);
	f[0][0]=1;
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
		for(int j=i;j>0;j--)
			for(int k=m*n;k>=a[i];k--)
				f[j][k]+=f[j-1][k-a[i]];
	for(int i=1;i<=n;i++)
		ans+=f[i][i*m];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define INF 0x3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n" 
#define pb push_back
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define print(v); for(auto x:v) cout<<x<<" "; cout<<endl;
typedef long long int ll;
int main()
{
    fast;
    ll n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

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

int main(){
	int yama[51];
	int n,r;
	int tmp[51];

	while(std::cin >> n >> r && (n || r)){
		int c,p;
		rep(i,n){
			yama[i] = n-i;
		}
		rep(i,r){
			std::cin >> p >> c;
			rep(j,c){
				tmp[j] = yama[p-1+j];
			}
			rep(k,p-1){
				yama[p-1+c-k-1] = yama[p-1-k-1];
			}
			rep(l,c){
				yama[l] = tmp[l];
			}
		}
		std::cout << yama[0] << std::endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int[]po=new int[3];
        for(int i=0;i<3;i++){
            po[i]=sc.nextInt();
        }
        Arrays.sort(po);
        int ans=0;
        while(po[0]<po[1]){
            po[0]+=2;
            ans++;
        }
            System.out.println(ans+(po[2]-po[1]+(po[0]-po[1])));
    }
    
    
}

Measured memory_bytes: 21844
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	if a%3 == 0 || b%3 == 0 || (a+b)%3 == 0 {
		println!("Possible");
	}else{
		println!("Impossible");
	}
}

Measured memory_bytes: 4352
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
from fractions  import gcd
#input=sys.stdin.readline
import bisect
a,b,c=map(int,input().split())
print(max(a+10*b+c,10*a+b+c,10*c+a+b))

Measured memory_bytes: 77376
"use strict";
const main = arg => {
  let NumAmount = arg.split("\n")[0]*1;
  let row1 = arg.split("\n")[1].split(" ").map(x => x*1);
  // ansのデフォルト設定
  let ans = "Yes";
  // ループする
  // ループ用に小さい値を設定
  let pre = -1000;
  for(let i = 0; i < NumAmount; i++){
    // もしも前の方は大きいならそのまま
    if(row1[i] - 1 >= pre){
 		pre = row1[i] - 1;
    } else if(row1[i] >= pre){
      	pre = row1[i];
    } else {
    	ans = "No";
    }
  }
  console.log(ans);
}

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


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

using namespace std;
typedef  long long ll;

#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sdo(a) scanf("%lf",&a)
#define sdo2(a,b) scanf("%lf %lf",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
const int maxn=1e6+10;
const int mod=1e9+7;
int x[maxn];

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        sint(x[i]);
    int sum=0;
    int mi=mod;
    for(int i=1;i<=n;i++)
    {
        if(x[i]<=mi)
            sum++,mi=x[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>

using namespace std;

char a[105][105];
int len,h,w;

int main(){
	scanf("%d %d",&h,&w);
	for(int i = 1;i <= h;i ++){
		scanf("%s",a[i]);
	}
	for(int i = 0;i <= w + 1;i++){
		if(i == w + 1) {
			printf("#\n");
			break;
		}
		printf("#");
	}
	for(int i = 1;i <= h;i++){
		printf("#");
		printf("%s",a[i]);
		printf("#\n");
	}
	for(int i = 0;i <= w + 1;i ++){
		if(i == w + 1) {
			printf("#\n");
			break;
		}
		printf("#");
	}
}

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

const int INF = 0x3f3f3f3f;
const int MAXN = 312;

int n;
bool stat[MAXN][MAXN][MAXN];
double pd[MAXN][MAXN][MAXN];

double rec(int q_1, int q_2, int q_3)
{
	// cout << q_1 << ' ' << q_2 << ' ' << q_3 << endl;

	if(stat[q_1][q_2][q_3])
		return pd[q_1][q_2][q_3];

	double p = (n*1.00)/(q_1+q_2+q_3);

	if(q_1==1 && q_2==0 && q_3==0)
		return p;

	double sum = 0.0;

	int nn = (q_1-1)+q_2+q_3;
	if(nn>0 && q_1>0)
		sum += rec(q_1-1, q_2, q_3)*q_1;

	nn = (q_1+1)+(q_2-1)+q_3;
	if(nn>0 && q_2>0)
		sum += rec(q_1+1, q_2-1, q_3)*q_2;

	nn = q_1+(q_2+1)+(q_3-1);
	if(nn>0 && q_3>0)
		sum += rec(q_1, q_2+1, q_3-1)*q_3;

	stat[q_1][q_2][q_3] = true;
	return pd[q_1][q_2][q_3] = p+(sum/(q_1+q_2+q_3));
}

int main(){
	int q_1 = 0, q_2 = 0, q_3 = 0;

	cin >> n;
	for(int i=0; i<n; i++){
		int tmp;
		cin >> tmp;
		if(tmp==1) q_1++;
		if(tmp==2) q_2++;
		if(tmp==3) q_3++;
	}

	printf("%.9lf\n", rec(q_1, q_2, q_3));

	return 0;
}

Measured memory_bytes: 260352
#include <iostream>
#include <limits>

#define INFTY 1000000000
using namespace std;



int n;
int cnt=0;

void printArray(int* A){
	for(int i=0; i<n; i++){
		cout << A[i];
		if(i < n-1)
			cout << " ";
	}
	cout << endl;
}

void merge(int* A, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;

	int L[n1+1], R[n2+1];
	for(int i=0; i<n1; i++)
		L[i] = A[left+i];
	for(int i=0; i<n2; i++)
		R[i] = A[mid+i];
	L[n1] = INFTY; R[n2] = INFTY;
	int i=0, j=0;
	for(int k=left; k < right; k++){
		if(L[i] <= R[j])
			A[k] = L[i++];
		else
			A[k] = R[j++];
		cnt++;
	}
//	printArray(A);
}

void mergeSort(int* A, int left, int right){
	if(left + 1 < right){
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main(){
	cin >> n;
	int A[n];
	for(int i=0; i<n; i++)
		cin >> A[i];
	mergeSort(A, 0, n);
	printArray(A);
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 6956
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long

int main() {
    int n, a, b;

    cin >> n >> a >> b;

    cout << min(a, b) << " " << max(a + b - n, 0) << endl;

    return 0;
}


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

#print(n)
a = list(map(int, input().split()))

sum = 0
a.sort()
#print(a)
for i in range(min(n,k)): a.pop()
#print(a)
for i in range(len(a)):
    sum += a[i]
print(sum)


Measured memory_bytes: 26024
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
/*------------------junk----------------------*/

typedef long long int lli;
typedef unsigned long long int ulli;
const int MOD = 1e9 + 7;
#define F first
#define S second
#define gc getchar_unlocked
#define fri(i, j , n) for (auto (i) = (j); (i) < (n); ++(i))
#define frie(i, j , n) for (auto (i) = (j); (i) <= (n); ++(i))
#define frb(i,j, n) for (auto (i) = (j); (i) >= (n); (i)--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define rall(x) (x).rbegin(),(x).rend()
#define f2a(x , n , v)  fill(&(x)[0][0], &(x)[0][0] + (0 + n) *(0 + n) , (v))
#define fa(x , n , v) fill( (x), (x)+(n), (v)) 
#define ra(a) for(int &x : (a)) in(x)
#define pa(a) for(int &x : (a)) cout << (x) << " ";cout << "\n"
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vlli vector<lli>

/*----------check constraints again-------------*/

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  int n;
  cin >> n >> s;
  (n < 3200) ? cout << "red" : cout << s;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int data[10000],n,i,max,min;
  long long sum=0;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    scanf("%d",&data[i]);
    sum+=data[i];  
}
  i=0;
  min=data[i];
  max=data[i];
  for(i=1;i<n;i++){
    if(min>data[i]){
      min=data[i];
    }
    if(max<data[i]){
      max=data[i];
    }
  }
  printf("%d %d %lld\n",min,max,sum);
    return 0;
  }

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <algorithm>

int main() {
  std::string s, t;
  std::cin >> s >> t;

  std::sort(s.begin(), s.end());
  std::sort(t.rbegin(), t.rend());
  if (s < t) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 256
N=int(input())
if N==1:
    print("Yes")
    print(2)
    print(1,1)
    print(1,1)
    exit()

for i in range(2,1000):
    if i*(i+1)//2==N:
        print("Yes")
        print(i+1)
        L=[]
        cnt=1
        for j in range(i+1):
            l=[]
            for k in range(len(L)):
                l.append(L[k][len(L)-1])
            while len(l)<i:
                l.append(cnt)
                cnt+=1
            L.append(l)
        for i in range(len(L)):
            print(len(L[i]),*L[i])
        exit()
        
    elif i*(i+1)//2>N:
        print("No")
        exit()

Measured memory_bytes: 13960
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> s(1 << n), v(1 << n);
    for (int i = 0; i < (1 << n); i++) {
        cin >> s[i];
    }
    sort(all(s), greater<int>());
    v[0] = 1;
    vector<int> vv;
    vv.push_back(s[0]);
    for (int i = 0; i < n; i++) {
        int id = 0;
        sort(all(vv), greater<int>());
        for (int j = 0; j < (1 << i); j++) {
            while (id < (1 << n) && (v[id] || vv[j] <= s[id])) {
                id++;
            }
            if (id == (1 << n)) {
                cout << "No" << endl;
                return 0;
            }
            vv.push_back(s[id]);
            v[id] = 1;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3448
n = input()
a = int(n[-1])
b = 10 - int(n[-1])

for i in range(len(n)-2,-1,-1):
    a,b = min(a+int(n[i]), b + int(n[i]) + 1), min(a + 10-int(n[i]), b + 9 -int(n[i]))

print(min(a,b+1))

Measured memory_bytes: 5492