akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {
	
	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	
	int N;
	cin >> N;
	vint A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	vint memo(N);
	for (int i = 0; i < N; i++) {
		memo[i] = 0;
	}

	if (N % 2 == 0) {

		for (int i = 0; i < N; i++) {

			if (A[i] % 2 == 0) {
				cout << 0;
				return 0;
			}

			memo[A[i]/2]++;
		}

		ll ans = 1;
		for (int i = 0; i < N / 2; i++) {
			if (memo[i] != 2) {
				cout << 0;
				return 0;
			}
			ans *= 2;
			ans %= MOD;
		}

		cout << ans;

		
	}
	else {

		for (int i = 0; i< N; i++) {

			if (A[i] % 2 == 1) {
				cout << 0;
				return 0;
			}

			memo[N/ 2 - A[i]/2]++;
		}

		ll ans = 1;
		for (int i = 0; i < N / 2; i++) {
			if (memo[i] != 2) {
				cout << 0;
				return 0;
			}
			ans *= 2;
			ans %= MOD;
		}

		if (memo[N / 2] != 1) {
			cout << 0;
			return 0;
		}

		cout << ans;

	}






}




Measured memory_bytes: 1024
n=int(input())
lists=list(map(int,input().split()))
counter=1
uselist=[0,0,0]
for j in range(n):
    human=lists[j]
    sub=0
    for p in range(3):
        if uselist[p]==human:
            sub+=1
    for q in range(3):
        if uselist[q]==human:
            uselist[q]+=1
            break
    counter=counter*sub
    counter=counter%(10**9+7)
if lists[0]==0:
    print(counter)
else:
    print(0)

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

int main(){
    char a[50][50];
    char b[50][50];
    int n,m;
    cin >> n >> m;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            cin >> b[i][j];
        }
    }

    bool exist=false;
    for(int ly=0;ly<n;ly++){
        for(int lx=0;lx<n;lx++){
            if(ly+m-1>=n || lx+m-1>=n)continue;

            bool match=true;
            for(int y=0;y<m;y++){
                for(int x=0;x<m;x++){
                    if(a[ly+y][lx+x]!=b[y][x])match=false;
                }
            }
            if(match)exist=true;
        }
    }
    if(exist)
    puts("Yes");
    else
    puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
  int n;
  cin>>n;
  unordered_map<string,int>mp;
  rep(i,n){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  ll ans=0;
  for (auto& p:mp){
    int s=p.second;
    ans+=(ll)s*(s-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 10660
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        myQueue que=new myQueue();
        
        int n=in.nextInt(),limit=in.nextInt(),sum=0;
        for(int i=0;i<n;i++)que.push(new process(in.next(), in.nextInt()));

        while(!que.isEmpty()){
            process p=que.pop();
            if(p.time<=limit){
                sum+=p.time;
                System.out.println(p.p+" "+sum);
            }
            else{
                sum+=limit;
                p.time-=limit;
                que.push(p);
            }
        }
    }
}

class process{
    String p;
    int time;

    process(String p,int time){
        this.p=p;
        this.time=time;
    }
}

class myQueue{
    process array[];
    int top,tail;

    myQueue(){
        array=new process[1000000];
        top=1; tail=1;
    }

    boolean isEmpty(){
        if(top==tail)return true;
        else return false;
    }

    void push(process x){
        array[tail]=x;
        tail++;
    }

    process pop(){
        process res=array[top];
        top++;
        return res;
    }
}


Measured memory_bytes: 83876
class Dice
  def initialize(t,s,e,w,n,b)
    @val = [t,s,e,w,n,b]
  end
  def roll(d)
    case d
    when "N" then
      @val = [@val[1],@val[5],@val[2],@val[3],@val[0],@val[4]]
    when "E" then
      @val = [@val[3],@val[1],@val[0],@val[5],@val[4],@val[2]]
    when "W" then
      @val = [@val[2],@val[1],@val[5],@val[0],@val[4],@val[3]]
    when "S" then
      @val = [@val[4],@val[0],@val[2],@val[3],@val[5],@val[1]]
    end
  end
  def getTop
    return @val[0]
  end
end

t,s,e,w,n,b = gets.chomp.split(" ").map{|x| x.to_i}
commands = gets.chomp.split("")
d = Dice.new(t,s,e,w,n,b)
for c in commands do
  d.roll(c)
end
result = d.getTop
printf("%d\n",result)


Measured memory_bytes: 6888
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int n;
    string s;
    cin >> n >> s;

    int dp[2][3000] = {};
    rep(j, n) dp[0][j] = 1;
    FOR(i, 1, n) {
        if(s[i - 1] == '<') {
            dp[i & 1][n - 1 - i] = dp[i + 1 & 1][n - i];
            for(int j = n - 1 - i; j > 0; j--)
                dp[i & 1][j - 1] = (dp[i & 1][j] + dp[i + 1 & 1][j]) % mod;
        } else {
            dp[i & 1][0] = dp[i + 1 & 1][0];
            rep(j, n - 1 - i) dp[i & 1][j + 1] =
                (dp[i & 1][j] + dp[i + 1 & 1][j + 1]) % mod;
        }
    }

    cout << dp[n + 1 & 1][0] << endl;

    return 0;
}

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

int main(void){
  long a,b,k;
  
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  a=atol(p);
  p=strtok(NULL," \n");
  b=atol(p);
  
  if((a+b)%2==1){
    printf("IMPOSSIBLE");
    return 0;
  }
  
  k=(a+b)/2;
  
  printf("%ld\n",k);
  
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int x[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> x[i];
	}
	
	int ans = 1e9;
	for (int i = 1; i <= 100; ++i)
	{
		int tmp = 0;
		for (int j = 0; j < n; ++j)
		{
			tmp += pow(x[j] - i, 2);
		}
		
		ans = min(ans, tmp);
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  bool ans = false;
  for (int i = A; i <= B; i++) {
    if (i % K == 0) {
      ans = true;
      break;
    }
  }
  cout << (ans ? "OK" : "NG") << endl;
}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A, B) << ' ';
    if(A + B < N) cout << 0 << endl;
    else if(A < B) cout << B - (N - A) << endl;
    else cout << A - (N - B) << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int A, B, C;
	ll K;
	cin >> A >> B >> C >> K;

	if (K & 1) co(B - A);
	else co(A - B);

	Would you please return 0;
}

Measured memory_bytes: 256
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())

sys.setrecursionlimit(10 ** 9)


def main():
    H = INT()
    W = INT()
    N = INT()

    num = max(H, W)

    for i in range(num):
        if num * (i+1) >= N:
            print(i+1)
            sys.exit()


if __name__ == '__main__':
    main()

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

using namespace std;
using ll = long long;

const int N = 500005;

int ft[N];

void add(int x, int val) {
	x++;
	for(; x < N; x += x & -x) {
		ft[x] += val;
	}
}
int get(int x) {
	x++;
	int ans = 0;
	for(; x > 0; x -= x & -x) ans += ft[x];
	return ans;
}

int n, q;
int a[N];
int ans[N];
int last[N];

vector<int> rem[N];
vector<pair<int, int>> put[N];

int main() {
	scanf("%d %d", &n, &q);

	for(int i = 1; i <= n; i++) scanf("%d", a + i);

	for(int i = 0; i < q; i++) {
		int l, r;
		scanf("%d %d", &l, &r);
		rem[l - 1].push_back(i);
		put[r].emplace_back(i, l);
	}
	
	for(int i = 1; i <= n; i++) {
		add(last[ a[i] ], 1);
		last[ a[i] ] = i;
		for(int id : rem[i]) {
			ans[id] -= get(i);
		}
		for(pair<int, int> e : put[i]) {
			int id, l;
			tie(id, l) = e;
			ans[id] += get(l - 1);
		}
	}

	for(int i = 0; i < q; i++) {
		printf("%d\n", ans[i]);
	}
	
}


Measured memory_bytes: 53120
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int x,y;
    cin>>x>>y;
    cout<<(x+y+1)/2;
    return 0;
}


Measured memory_bytes: 256
N, W = [int(x) for x in input().split()]
vs = [0] * N
ws = [0] * N

for i in range(N):
    vs[i], ws[i] = [int(x) for x in input().split()]

vmax = sum(vs) + 1
dp = [[float('inf')] * vmax for x in range(N + 1)]
dp[0][0] = 0

for i in range(1, N + 1):
    v = vs[i - 1]
    w = ws[i - 1]
    for j in range(vmax):
        if j < v:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v] + w)

print(max(i for i, x in enumerate(dp[N]) if x <= W))



Measured memory_bytes: 13876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const int maxn = 200005;

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

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

def main():
    N = int(input())
    X = list(map(int, input().split()))

    ans = int(1e10)

    for i in range(1, 101):
        tmp = 0
        for x in X:
            tmp += (x - i)**2
        ans = min(ans, tmp)
    
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
using namespace std;
string s;
vector<string> parse(string str) {
	vector<string> ret; string t; str += " ";
	for(int i = 0; i < str.size(); i++) {
		if(str[i] == ' ') ret.push_back(t), t = "";
		else t += str[i];
	}
	return ret;
}
int main() {
	while(s = "", getline(cin, s)) {
		vector<string> v = parse(s);
		vector<double> w;
		for(int i = 0; i < v.size(); i++) {
			double a, b;
			if(w.size() > 1) a = *(w.end() - 2), b = *(w.end() - 1);
			if(v[i] == "+") *(w.end() - 2) = a + b, w.pop_back();
			else if(v[i] == "-") *(w.end() - 2) = a - b, w.pop_back();
			else if(v[i] == "*") *(w.end() - 2) = a * b, w.pop_back();
			else if(v[i] == "/") *(w.end() - 2) = a / b, w.pop_back();
			else w.push_back(stoi(v[i]));
		}
		cout << fixed << setprecision(12) << *(w.end() - 1) << endl;
	}
}

Measured memory_bytes: 3100
N, M = map(int, input().split())
ks = [[int(i) for i in input().split()] for j in range(M)]
p = [int(i) for i in input().split()]

ans = 0
for i in range((1 << N)):
    count = 0
    for j in range(M):
        k = ks[j][0]
        on = 0
        for s in ks[j][1:]:
            if i & (1 << (s-1)):
                on += 1
        
        if on % 2 == p[j]:
            count += 1

    if count == M:
        ans += 1

print(ans)

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

const int NOT_FOUND=-1;

int LinearSearch(int key, int A[], int n){
  int i=0;
  A[n]=key;
  while(A[i]!=key){
    i++;
  }
  if(i==n){
    return NOT_FOUND;
  }
  return i;
}

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

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

  int T[500];
  for(int i=0; i<q; i++){
    cin >> T[i];
  }
  int C=0;

  for(int i=0; i<q; i++){
    if(LinearSearch(T[i], S, n)!=NOT_FOUND){
      C++;
    }
  }
  cout << C << endl;
  return 0;
}


Measured memory_bytes: 3120
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque

N, M = map(int, input().split())

edges_list = [[] for _ in range(N)]
seen_list = [-1] * N

for i in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    edges_list[A].append(B)
    edges_list[B].append(A)

queue = deque([0])
seen_list[0] = 0

while queue:
    current = queue.popleft()
    for n in edges_list[current]:
        if seen_list[n] == -1:
            seen_list[n] = current
            queue.append(n)

if -1 in seen_list:
    print("No")
else:
    print("Yes")
    for i in range(len(seen_list) - 1):
        print(seen_list[i+1] + 1)

Measured memory_bytes: 91988
import java.util.Scanner;
public class Main{
	static int[]heap;
    static int MAXHEAP=2000000;
    static int n;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int i;
		heap=new int[MAXHEAP+1];
       Scanner sca= new Scanner(System.in);
       n=sca.nextInt();
       for(i=1;i<=n;i++){
    	   heap[i]=sca.nextInt();
    	   heap[i*2]=heap[i*2+1]=Integer.MIN_VALUE;
       }
       buildMaxHeap();
       for(i=1;i<=n;i++){
      System.out.print(" "+heap[i]);
      if(i==n)System.out.println("");
       }
	}
	public static void maxHeapify(int i){
		int l=i*2,r=i*2+1,largest,hz;
		if(i<=n&&heap[l]>heap[i]){
			largest=l;
		}else{
			largest=i;
		}
		if(r<=n&&heap[r]>heap[largest])largest=r;
		if(largest!=i){
			hz=heap[largest];
			heap[largest]=heap[i];
			heap[i]=hz;
			maxHeapify(largest);
		}
	}
	public static void buildMaxHeap(){
		int i;
		for(i=n/2;i>=1;i--){
			maxHeapify(i);
		}
	}

}



Measured memory_bytes: 179004
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    bool a=(s.size()%2==0);
    bool b=(s[0]==s[s.size()-1]);
    if(a^b){
        cout << "Second" << endl;
    }
    else{
        cout << "First" << endl;
    }
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);

		int x = A + B;
		x = Math.max(x, A - B);
		x = Math.max(x, A * B);

		System.out.println(x);

	}
}


Measured memory_bytes: 20820
import java.io.*;
import java.util.*;
 
public class Main{
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      
      //begin
      int l = sc.nextInt();
      int r = sc.nextInt();
      int min = 2019;
      for(int i = l; i < r; i++)
      {
        for(int j = l + 1; j <= r; j++)
        {
            int k = (i % 2019) * (j % 2019) % 2019;
            if(k < min)
                min = k;
            if(min == 0)
                break;
        }
        if(min == 0)
            break;
      }
      out.println(min);
      //end
      out.close();
   }
 
   public static PrintWriter out;
      
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
      long nextLong() {
          return Long.parseLong(next());
      }
      double nextDouble() {
          return Double.parseDouble(next());
      }
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }
   }
}

Measured memory_bytes: 24916
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int a, b, t;
    cin >> a >> b >> t;
    int now = 0;
    int res = 0;
    while (1) {
        now += a;
        if (now > t) break;
        res += b;
    }
    cout << res;
    return 0; 
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int n;
    cin >> n;
    vi h(n);
    rep(i, n) cin >> h[i];
    vi dp(n, INF);
    dp[0] = 0;

    rep(i, n) {
        if (i + 1 < n) dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        if (i + 2 < n) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));

        // debug(i);
        // debug(dp[i]);
    }

    out(dp[n - 1]);
    return 0;
}


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

int n, ans;
vector<string> v;
int a[4];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	v.resize(n);
	for(auto &i:v) cin >> i;
	for(auto i:v){
		int t = (i[0] == 'B') * 2 + (i[i.size()-1] == 'A');
		++a[t];
		for(int j=0; j<i.size()-1; ++j)
			if(i.substr(j, 2) == "AB")
				++ans;
	}
	if(a[3] >= 2) ans += a[3] - 1;
	if(a[3] >= 1){
		if(a[2] > 0){
			++ans;
			--a[2];
		}
		if(a[1] > 0){
			++ans;
			--a[1];
		}
	}
	ans += min(a[2], a[1]);
	cout << ans << "\n";
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
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 vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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 SQ(a) ((a)*(a))
#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())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  int X,t;
  cin >> X >> t;
  int ans = X-t;
  
  if(ans < 0) ans = 0;
  
  cout << ans << endl;
  
  return 0;
}


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

int main(){
	long long answer=0;
	int n, k;
	std::cin>> n>> k;
	for(int i=k+1; i<=n; i++){
		int dev= n/i;
		int mod= n%i;

		answer+= dev*(i-k);
		if(mod-k>= 0){
			answer+= mod-k;
		
			if(k> 0)
				answer++;
		}
	}

	std::cout<<answer<<std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<string>
#include<cstdio>
#include<iostream>

using namespace std;
 
int main(){
	int m[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	string d[]={"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

	int x,y;

	while(scanf("%d %d", &x, &y) != EOF){
		if(0==x) break;
		int c=2;
		while(--x) c+=m[x];

		c+=y;
		cout<< d[c%7]<<endl;
	}

    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

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

  int alice = 0, bob = 0;
  sort(a.begin(), a.end(), greater<int>());
  for (int i=0; i<n; i++){
    if (i%2==0) alice += a[i];
    else bob += a[i];
  }

  cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007



int main() {
    int N;
    cin >> N;
    vi H(N);
    rep(i, N) cin >> H[i];

    int ans = 1;
    for (int i = 1; i < N; i++) {
        bool f = true;
        for (int j = 0; j < i; j++) {
            if (H[j] > H[i]) f = false;
        }
        if (f) ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int A, B, K;
  cin >> A >> B >> K;
  
  for (int i = 0; i < K; i++)
  {
    if (i % 2 == 0) //高橋
    {
      if (A % 2 == 1) A--;
      A /= 2;
      B += A;
    }
    else //青木
    {
      if (B % 2 == 1) B--;
      B /= 2;
      A += B;
    }
  }
  
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());

		System.out.println(Math.min(n, k)*x + Math.max(0, n-k)*y);
	}
}


Measured memory_bytes: 22868
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAX_N 100000
int x[MAX_N];

int main() {
	int n, a, b, c, d, e, maxn = 0;;
	while (true) {
		for (int i = 0; i < MAX_N; i++) {
			x[i] = 0;
		}
		cin >> n; maxn = 0;
		if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			scanf("%02d:%02d:%02d", &a, &b, &c);
			d = a * 3600 + b * 60 + c;
			scanf("%02d:%02d:%02d", &a, &b, &c);
			e = a * 3600 + b * 60 + c;
			x[d]++; x[e]--;
		}
		for (int i = 1; i < 99999; i++) {
			x[i] += x[i - 1];
			maxn = max(maxn, x[i]);
		}
		cout << maxn << endl;
	}
}

Measured memory_bytes: 1628
import queue
n=int(input())
cf=[0]*n
cg=[0]*(n-1)
ce=[[] for _ in range(n)]
e=[[]for _ in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  e[a-1]+=[b-1]
  e[b-1]+=[a-1]
  ce[a-1]+=[i]
  ce[b-1]+=[i]
k=len(max(e,key=len))
q=queue.Queue()
q.put(0)
while not q.empty():
  now=q.get()
  cf[now]=1
  c=0
  for i in ce[now]:
    if cg[i]:c=cg[i]
  j=1
  for i in ce[now]:
    if j==c:j+=1
    if cg[i]:continue
    cg[i]=j
    j+=1
  for i in e[now]:  
    if cf[i]:continue
    q.put(i)
print(k)
for i in cg:
  print(i)

Measured memory_bytes: 106936
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL //デバッグ出力系
#define dout(s) cout<<s<<"\n";
#define debug() if(true)
#else
#define dout(s)
#define debug() if(false)
#endif//
#define next asdnext
#define prev asdprev
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define vout(v) for(auto &i:v){cout<<i<<" ";}cout<<"\n"; //配列出力
#define vin(v) for(auto &i:v)cin>>i; //配列入力
#define vec(v,n) vector<int> v(n);
typedef long long ll;
typedef unsigned long long ull;

void Main() {
	vector<int> P(3);
	cin >> P[0] >> P[1] >> P[2];

	sort(all(P));
	cout << (P[0] + P[1]) << "\n";
}

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


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

int		main(void)
{
	vector<string> tmp(3);
	cin >> tmp.at(0) >> tmp.at(1) >> tmp.at(2);
	cout << "A" << tmp.at(1).at(0) << "C" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
    int t = n%10;
    if(t==0 || t==1||t==6||t==8)
      cout<<"pon"<<endl;
    else if(t==3)
      cout<<"bon"<<endl;
  	else
      cout<<"hon"<<endl;
 
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000LL;
constexpr auto MOD = 1000000007;

ll modpow(int p, int q) {
	ll ans = 1;
	ll pp = p;
	while (q) {
		if (q & 1) {
			ans *= pp;
			ans %= MOD;
		}
		q /= 2;
		pp *= pp;
		pp %= MOD;
	}
	return ans;
}

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

	bool ok = true;
	rep(i, n / 2) {
		if (a[n - 1 - 2 * i] != n - 2 * i - 1 || a[n - 2 - 2 * i] != n - 2 * i - 1)ok = false;
	}

	ll ans = modpow(2, n / 2);
	if (!ok)ans = 0;
	cout << ans << endl;

}

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

int main()
{
	int l, m, n, mu, f;

	while (cin >> l, l){
	mu = f = 0;
		for (int i = 0; i < 12; i++){
			cin >> m >> n;
			l -= (m - n);
			if (l <= 0 && f == 0){
				mu = i + 1;
				f = 1;
			}	
		}
		if (mu != 0) cout << mu << endl;
		else cout << "NA" << endl;
	}
	return (0);
}

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

using namespace std;

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

	string s;
	cin >> s;
	int res = 0;
	char prev = s[0];
	for (int i = 1; i < (int) s.length(); i++) {
		if (s[i] != prev) {
			res++;
			prev = s[i];
		}
	}
	cout << res << '\n';

	return 0;
}



Measured memory_bytes: 512
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
int main(){
	int n;
	string s;
	cin >> n >> s;
	if (n % 2 == 1){
		printf("No\n");
		return 0;
	}
	if (s.substr(0, n / 2) == s.substr(n / 2, n / 2)){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use proconio::{input, marker::Usize1};
use superslice::*;

fn dfs(
  v: usize,
  dp: &mut Vec<usize>,
  hasVisited: &mut Vec<bool>,
  res: &mut Vec<usize>,
  graph: &Vec<Vec<usize>>,
  a: &[usize],
) {
  hasVisited[v] = true;
  let t = dp.lower_bound(&a[v]);
  let snapshot = dp[t];
  dp[t] = a[v];
  res[v] = dp.lower_bound(&std::usize::MAX);
  for &w in &graph[v] {
    if hasVisited[w] {
      continue;
    }
    dfs(w, dp, hasVisited, res, graph, a);
  }
  dp[t] = snapshot;
}
fn main() {
  input! {
    N: usize,
    a: [usize; N],
    edges: [(Usize1, Usize1); N-1],
  }
  let mut graph = vec![vec![0; 0]; N];
  for &(u, v) in &edges {
    graph[u].push(v);
    graph[v].push(u);
  }
  let mut dp = vec![std::usize::MAX; N];
  let mut hasVisited = vec![false; N];
  let mut res = vec![0; N];
  dfs(0, &mut dp, &mut hasVisited, &mut res, &graph, &a);
  for r in res {
    println!("{}", r);
  }
}


Measured memory_bytes: 41340
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int n,m,k; cin>>n>>m>>k;
    int a[n],b[m];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        if(i) a[i]+=a[i-1];
    }
    for (int i = 0; i < m; ++i)
    {
        cin>>b[i];
        if(i) b[i]+=b[i-1];
    }
    int j=-1; int ans=0;
    for(int i=m-1; i>=0; i--){
        if(b[i]>k) continue;
        else{
            // if(j!=n-1){
                while(j<n-1&&a[j+1]+b[i]<=k){
                    j++;
                }
            // }
            ans=max(ans,i+1+j+1);
        }
    }
    j=-1;
    for(int i=n-1; i>=0; i--){
        if(a[i]>k) continue;
        else{
            // if(j!=n-1){
                while(j<m-1&&b[j+1]+a[i]<=k){
                    j++;
                }
            // }
            ans=max(ans,i+1+j+1);
        }
    }

    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 6736
/*input
6 15
6 5
5 6
6 4
6 6
3 5
7 2
*/

#include <functional>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility> 
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>

using namespace std;

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

const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define all(c)      (c).begin(),(c).end()
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(auto x: v) {
    os << x << " ";
  }
  return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}

/******************************** START *********************************/
const int N = 100005;
vector < vector < ll > > v;
ll dp[101][N];

ll func(int n, int w) 
{
  if(n == 0) {
    return 0;
  }
  if(dp[n][w] > -1) {
    return dp[n][w];
  }

  ll res = func(n - 1, w);
  if(w - v[n - 1][0] >= 0) {
    res = max(res, v[n - 1][1] + func(n - 1, w - v[n - 1][0]));
  }
  return dp[n][w] = res;
}

int main()
{
  ifalse;
  int n, w;
  cin >> n >> w;
  v.assign(n, vector < ll > (2, 0));
  cin >> v;

  for(int i = 1; i <= n; i ++) {
    for(int j = 0; j <= w; j ++) {
      dp[i][j] = dp[i - 1][j];
      if(j - v[i - 1][0] >= 0) {
        dp[i][j] = max(dp[i][j], v[i - 1][1] + dp[i - 1][j - v[i - 1][0]]);
      }
    }
  }
  cout << dp[n][w], nl;
  return 0;
}

Measured memory_bytes: 78464
<?php
$n = fgets(STDIN);
$s = trim(fgets(STDIN));

$t1 = substr($s, 0, $n/2);
$t2 = substr($s, $n/2);

if ($t1 === $t2) {
    echo "Yes\n";
} else {
    echo "No\n";
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int n,m,a[13],b[13];
string s[13],ss[13];
void dfs1(int x,bool allow){
	if(x==m){cout<<"YES"<<endl;exit(0);}
	else if(b[x]!=-1) dfs1(x+1,allow);
	else{
		for(int i=x+1;i<m;i++){
			if(b[i]!=-1) continue;
			bool ok=true;
			for(int j=0;j<n;j++)
				if(s[j][x]!=s[a[j]][i]){ok=false;break;}
			if(ok){
				b[x]=i;b[i]=x;dfs1(x+1,allow);b[x]=-1;b[i]=-1;
			}
		}
		if(allow){b[x]=x;dfs1(x+1,0);b[x]=-1;}
	}
} 
void dfs2(int x,bool allow){
	if(x==n) dfs1(0,(m%2));
	else if(a[x]!=-1) dfs2(x+1,allow);
	else{
		for(int i=x+1;i<n;i++)
			if(ss[i]==ss[x]&&a[i]==-1){
				a[x]=i;a[i]=x;dfs2(x+1,allow);a[x]=-1;a[i]=-1;
			}
		if(allow){a[x]=x;dfs2(x+1,0);a[x]=-1;}
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>s[i];
	memset(a,-1,sizeof(a));memset(b,-1,sizeof(b));
	for(int i=0;i<n;i++)
		ss[i]=s[i],sort(ss[i].begin(),ss[i].end());
	dfs2(0,(n%2));
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
 int N;
 cin>>N;
 double ans=2*N*3.14159265358979323846;
 cout<<fixed<<setprecision(20)<<ans<<endl;
 }

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

int main(void) {
  int N;
  cin >> N;
  
  vector<int> s(N);
  
  for(int i = 0; i < N; i++) {
    cin >> s[i]; 
  }
  
  int sum = 0;  
  for(int i = 0; i < N; i++) {
    sum += s[i];
  }
  if(sum % 10 != 0) {
    cout << sum << endl; 
    return 0;
  }
   
  sort(s.begin(), s.end());
  for(int i = 0; i < N; i++) {
    if(s[i] % 10 != 0) {
      sum -= s[i];
      cout << sum << endl;
      return 0;
    }
  }
  
  cout << 0 << endl;
  return 0; 
}

Measured memory_bytes: 256
//PCK2015予選4
#include<iostream>
using namespace std;

int main(){
    int N;
    while(cin>>N,N!=0){
        bool can = false;
        int cnt = 0;
        for(int i=0;i<N;++i){
            int k; cin>>k;
            if(k>1) can = true;
            if(k) ++cnt;
        }
        if(!can) cout<<"NA\n";
        else cout<<cnt+1<<endl;
    }
}



Measured memory_bytes: 3104
//According to all known laws of aviation, there is no way that a bee should be able to fly.
//Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway.
//Because bees don't care what humans think is impossible.
#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define mod 1000000007
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;

int main(){
    FAST_IO ;
    int N , K ; cin >> N >> K ;
    int arr[N] ;
    for( int i = 0 ; i < N ; i++ )
        cin >> arr[i] ;
    sort( arr , arr + N ) ;
    int sum = 0 ;
    for( int i = 0 ; i < K ; i++ )
        sum += arr[i] ;
    cout << sum << endl ;
    
return 0 ;
}


Measured memory_bytes: 3608
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define INF 1e9 + 7;
int cnt = 0;

void merge(vector<int>& A, int left, int mid, int right) {
    int n1 = mid - left, n2 = right - mid;
    vector<int> L(n1 + 1), R(n2 + 1);
    rep(i, n1) L[i] = A[left + i];
    rep(i, n2) R[i] = A[mid + i];
    L[n1] = INF;
    R[n2] = INF;
    int i = 0;
    int j = 0;
    for (int k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}
void merge_sort(vector<int>& A, int left, int right) {
    if (left + 1 < right) {
        int mid = left + (right - left) / 2;
        merge_sort(A, left, mid);
        merge_sort(A, mid, right);
        merge(A, left, mid, right);
    }
}

void solve() {
    int n;
    cin >> n;
    vector<int> A(n);
    for (auto& e : A) {
        cin >> e;
    }
    merge_sort(A, 0, n);
    rep(i, n) {
        if (i) cout << " ";
        cout << A.at(i);
    }
    cout << "\n" << cnt << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 6804
#include <iostream>
#include <vector>

using namespace std;

int main(){

    int N, M, C;
    cin >> N >> M >> C;

    vector<int> B(M);
    for(int i = 0; i < M; i++){
        cin >> B[i];
    }
    
    int count = 0;
    int sum = 0;

    for(int i = 0; i < N; i++){
        vector<int> A(M);

        for(int j = 0; j < M; j++){
            cin >> A[j];
            sum += A[j] * B[j];
        }
        if (sum > -1 * C){
            count += 1;
        }
        sum = 0;
    }

    cout << count << endl;
    return 0;
}

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

int main(void)
{
	char str[128];
	int i, len, a, b;
	
	while (scanf("%s", str), str[0] - '0'){
		len = strlen(str);
		a = b = 0;
		
		for (i = 1; i < len; i++){
			if (str[i] == 'A'){
				a++;
			}
			else {
				b++;
			}
		}
		
		if ((a + 1 == 11 && (a < 10 || b < 10)) || a + 1 - b == 2){
			a++;
		}
		else {
			b++;
		}
		
		printf("%d %d\n", a, b);
	}
	
	return (0);
}

Measured memory_bytes: 536
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Kenji
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC093C solver = new ABC093C();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC093C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] v = new int[3];
            for (int i = 0; i < 3; i++) {
                v[i] = in.nextInt();
            }
            Arrays.sort(v);
            int a = v[2] - v[0];
            int b = v[2] - v[1];
            int ans = 0;
            ans += a / 2;
            a = a % 2;
            ans += b / 2;
            b = b % 2;
            if (a == 0 && b == 0) {
                // do nothing.
            } else if (a == 1 && b == 1) {
                ans++;
            } else {
                ans += 2;
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 22228
s = gets.chomp

answer = "WA"
if s[0] == "A" && s[2..-2].count("C") == 1
    if i = s[2..-2].index("C")
        s[i + 2, 1] = ""
        answer = "AC" if s[1..-1] == s[1..-1].downcase
    end
end
puts answer

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
vector<string> ans;
int cur[12];

void solve(int v){
	string tt="";
	int mx=0;
	for(int i=0;i<v;i++){
		tt+=('a'+cur[i]);
		mx=max(mx,cur[i]);
	}
	if(v==n){
		ans.push_back(tt);
		return;
	}
	for(int i=0;i<=mx+1;i++){
		cur[v]=i;
		solve(v+1);
	}
}

int main(void){
	scanf("%d",&n);
	solve(1);
	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 9588
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int A, B, C, D;
   cin >> A >> B >> C >> D;
   cout << max(0, min(B, D) - max(A, C)) << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n, a, b;
  cin >> n >> a >> b;
  long long int ans = 0;
  ans += n / (a + b) * a;
  long long int temp;
  temp = n % (a + b) <= a ? n % (a + b) : a;
  ans += temp;
  cout << ans << endl;
}


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

int main() {
   ll n; string s; cin>>n;
   map<string,ll>m;
   while(n--)
   {
       cin>>s; m[s]++;
   }
   cout<<"AC x "<<m["AC"]<<endl;
   cout<<"WA x "<<m["WA"]<<endl;
   cout<<"TLE x "<<m["TLE"]<<endl;
   cout<<"RE x "<<m["RE"]<<endl;
	return 0;
}

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

    ll mod=998244353;

    ll fact[500001]={0};
    void func(){
        fact[0]=1;
        for(ll i=1;i<500001;i++){
            fact[i]=((fact[i-1]%mod)*(i%mod))%mod;
        }
    }

    ll power(ll x,ll y){
        ll ans=1;
        while(y>0){
            if(y%2==1)
                ans=((ans%mod)*(x%mod))%mod;
            y/=2;
            x=((x%mod)*(x%mod))%mod;
        }
        return ans%mod;
    }

    ll ncr(ll n,ll r){
        if(n<r) return 0;
        ll temp1=fact[n];
        ll temp2=((fact[n-r]%mod)*(fact[r]%mod))%mod;
        temp2=power(temp2,mod-2);
        temp1=(temp1)*(temp2);
        temp1=temp1%mod;
        return temp1;
    }


    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll a,b;
        cin>>a>>b;
        cout<<a*b<<endl;
    }


Measured memory_bytes: 3612
import numpy as np
a=[]#入力画面の二文字を別々の文字に格納
a=input().split(" ")
N=int(a[0])
M=int(a[1])
#cmdから2次元配列Gを作成
G = []
for i in range(M):
    array = list(map(int, input().strip().split()))
    G.append(array)
#列ごとに成分を抽出
b=[x[0] for x in G]#二次元配列Gの1列目
c=[x[1] for x in G]#二次元配列Gの2列目

B=max(b)
C=min(c)
y=C-B+1
if y>=0:
    print(y)
elif y<0:
    print('0')


Measured memory_bytes: 38204
#include <bits/stdc++.h>
using namespace std;
#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 pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=401000;
char s[N];
int n,m;

ll dp[N],sdp[N],ans;

int main() {
	scanf("%d%d",&n,&m);
	scanf("%s",s);
	bool mono=1;
	rep(i,0,m) mono&=s[i]==s[0];
	if (mono) {
		int a=2,b=1;
		rep(i,1,n) {
			a=(a+b)%mod;
			swap(a,b);
		}
		printf("%d\n",b);
		return 0;
	}
	int sR=2*n+1,sB=1;
	if (s[0]=='B') {
		rep(i,0,m) if (s[i]=='R') s[i]='B'; else s[i]='R';
	}
	rep(l,0,m) {
		int r=l;
		while (r<m&&s[r]==s[l]) r++;
		int len=r-l;
		if (len%2==0) {
			if (l==0) len=len+1;
			else len=2*n+1;
		}
		if (r==m) break;
		if (s[l]=='R') sR=min(sR,len);
		else sB=min(sB,len);
		l=r-1;
	}
	if (n%2==1) {
		puts("0");
		return 0;
	}
//	printf("%d %d\n",sR,sB);
	auto solve=[&](int sR,int sB) {
		memset(dp,0,sizeof(dp));
		memset(sdp,0,sizeof(sdp));
		dp[0]=1;
		sdp[2]=1;
		rep(i,1,n+1) {
			if (i%2==1) {
				dp[i]=(sdp[i+1]-sdp[max(0,i-sR)])%mod;
			} else {
				if (i!=n) {
					dp[i]=(sdp[i+1]-sdp[max(1,i-sB)])%mod;
				} else {
					for (int j=1;j<=sB&&j<=i;j+=2) {
						dp[i]=(dp[i]+dp[i-j]*j)%mod;
					}
					dp[i]%=mod;
				}
			}
			sdp[i+2]=(sdp[i]+dp[i])%mod;
		}
		ans+=dp[n];
	};
	solve(sR,sB);
	solve(sB,sR);
	ans%=mod;
	if (ans<0) ans+=mod;
	printf("%lld\n",ans);
}

Measured memory_bytes: 6656
import itertools
import math
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
x = 0
y = 0
for i in range(n):
    if v[i] > c[i]:
        x += v[i]
        y += c[i]

print(x - y)

Measured memory_bytes: 38384
N = gets.to_i

def number_length(n)
  n.to_s.length
end

ans = number_length(N)
for a in 1..Math.sqrt(N)
  next if N % a != 0
  b = N/a
  f_a_b = [number_length(a), number_length(b)].max
  ans = [ans, f_a_b].min
end

puts ans

Measured memory_bytes: 14364
#include<stdio.h>
#include<string.h>
 
int main(){
  char s[4];
  char t[4];
  
if (scanf("%4[^\n]%*[^\n]", s) < 1) *s = '\0';
getchar();
  if (scanf("%4[^\n]%*[^\n]", t) < 1) *t = '\0';
getchar();
  
  int count = 0;
  int i=0;
  for(i=0;i<3;i++){
    count += (s[i]==t[i] ? 1:0);
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128