akhauriyash/Code-Regression huggingface dataset:
//yewala
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)        (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007 
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;

inline LL moduloMultiplication(LL x, LL y) { return (x%mod * 1LL * y%mod) % mod; }
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}

inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL inv(LL a) { return power(a, mod - 2) % mod; }


int main()
{
	int n;
	string s;
	cin >> n >> s;
	int count = 0;
	rep(i, n-2)
	{
		if (s.substr(i, 3) == "ABC")count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m;
typedef long long ll;
const int max_n = 1e6;
int main(){
  cin >> n >> m;
  vector<int> p(m), y(m);
  for(int i=0 ; i<m ; i++){
    cin >> p[i] >> y[i];
    --p[i];
  }
  vector<vector<int> > vals(n);
  for(int i=0 ; i<m ; i++){
    vals[p[i]].push_back(y[i]);
  }

  for(int v=0 ; v<n ; v++){
    sort(vals[v].begin(), vals[v].end());
  }
  for(int i=0 ; i<m ; i++){
    int v = p[i];
    printf("%06d", v+1);

    int ite = lower_bound(vals[v].begin(), vals[v].end(), y[i]) - vals[v].begin();
    printf("%06d\n", ite+1);
  }
  return 0;
}


Measured memory_bytes: 7808
#include<stdio.h>

int main(void){
  int a,b,c[100000],i,j;
  scanf("%d%d",&a,&b);
  j=0;
  for(i=1;i<=a;i++){
    scanf("%d",&c[i]);
    if(b<=c[i]){
      j=j+1;
    }
  }
  printf("%d",j);
  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n=sc.nextInt();
	  String s=sc.next();
	  int count=0;
	  for(int i=0;i<s.length()-2;i++) {
		  if(s.substring(i, i+3).equals("ABC"))count++;
	  }
	  System.out.println(count);
  }
}


Measured memory_bytes: 35548
N, M =map(int,input().split())
ab = [list(map(int,input().split())) for i in range(M)]
ans = [0]*N
for i in range(M):
    ans[ab[i][0]-1]+=1
    ans[ab[i][1]-1]+=1
for i in range(N):
    print(ans[i])

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

int main() {
  string w;cin>>w;
  vector<int> g(26);
  for(int i=0; i<w.size(); i++){
    g[w[i]-'a']++;
  }
  string ans="Yes";
  for(int i=0; i<26; i++){
    if(g[i]%2!=0)ans="No";
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K,S;
  cin >> K >> S;
  int count = 0;
  for(int i = 0; i < K+1; i++){
    for(int j = 0; j < K+1; j++){
      if(S-i-j >= 0 && S-i-j <= K){
        count ++;
      }
    }
  }
  cout << count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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 argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  fi(1, n + 1)
    fj(1, n + 1)
    fk(1, n + 1)
    ans += gcd(i, gcd(j, k));
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3672
import math

def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))

n = getN()
yakusuu = []
for i in range(1,int(math.sqrt(n)) + 1):
    if n % i == 0:
        yakusuu.append(i)

a = yakusuu[-1]
b = n//a
#print(a,b)
ans = max(len(str(a)), len(str(b)))
print(ans)


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

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}

int main(){
	fast();
	ll n;
	cin>>n;
	string s;
	cin>>s;
	if(n<3200)cout<<"red";
	else
	cout<<s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs              v.size()
#define sot(v)        sort(v.begin(),v.end())
#define rev(v)        reverse(v.begin(),v.end())
#define ii                pair<int, int>
#define int              long long
#define ull              unsigned long long
#define pb              push_back
#define mpp          make_pair
#define Okay         0
#define pi               3.14159

const int inf = 1e6;
const int cont = 1e18;
const int mod = 1e9+7;
using namespace std;

vector<int>prime;

void seive(){
    bool ar[1010];
    memset(ar, 0, sizeof ar);
    for(int i=4; i*i<1005; i+=2)ar[i] = 1;
    for(int i=3; i<1005; i+=2){
        if(!ar[i]){
            for(int j = i*i; j<=1005; j+=(i+i)){
                ar[j] = true;
            }
        }
    }
    prime.pb(2);
    for(int i=3; i<=1005; i+=2)if(!ar[i])prime.pb(i);
}

void solve(){
  seive();
  int n;
  cin>>n;
  int res = 1;
  for(int i=0; i<prime.size(); i++){
    if(prime[i] > n)break;
    int temp = n;
    int ans = 0;
    while(temp>0){
        temp/=prime[i];
        ans+=temp;
    }
    res *= (ans+1);
    res %=mod;
  }
  cout<<res<<endl;
}

int32_t main() {
    Fast;
    solve();
    return Okay;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(s == u){
        a--;
    }
    else{
        b--;
    }
    cout << a << " " << b << endl;
    return 0;
}



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

int main(){
    ll K,N;
    cin >> K >> N;
    vector<ll> A(N),L(N);
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N-1){
        L[i] = abs(A[i+1] - A[i]);
    }
    L[N-1] = min(abs(A[0] - A[N-1]), K-abs(A[0] - A[N-1]));
    sort(L.begin(),L.end());

    cout << K - L[N-1] << endl;
    
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <functional>
#include <string>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

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

  ll N, M;

  cin >> N >> M;

  if (N == M && N == 1) {
    cout << 1 << endl;
  }
  else if (N == 1) {
    cout << M - 2 << endl;
  }
  else if (M == 1) {
    cout << N - 2 << endl;
  }
  else {
    cout << (N - 2) * (M - 2) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
    ll N, ans = 0;
    cin >> N;
    vi d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }

    if (N % 2 != 0) {
        cout << 0 << endl;
        return 0;
    }

    sort(d.begin(), d.end());  // 昇順
    cout << d[N / 2] - d[N / 2 - 1] << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

#define NON 0
#define BLK 1
#define WHT -1
#define SIZE 3

int isGameSet(int iField[SIZE][SIZE]);

int main(void){
    int board[SIZE][SIZE];
    char buf[4];
    
    while(1){
        for (int y=0; y<SIZE; y++){
            scanf("%s", buf);
            if (buf[0]=='0') return 0;
            for (int x=0; x<SIZE; x++){
                if (buf[x]=='b') board[x][y]=BLK;
                else if (buf[x]=='w') board[x][y]=WHT;
                else if (buf[x]=='+') board[x][y]=NON;
            }
        }
        switch (isGameSet(board)){
        case BLK:
            puts("b"); break;
        case WHT:
            puts("w"); break;
        case NON:
            puts("NA"); break;
        }
    }
    return 0;
}

int isGameSet(int iField[SIZE][SIZE]){
	int i, j;
	int tmp;

	// vertical
	for (i = 0; i < SIZE; i++){
		for (j = 0, tmp = 0; j < SIZE; j++){
			tmp += iField[i][j];
		}
		if (tmp == SIZE*WHT) return WHT;
		if (tmp == SIZE*BLK) return BLK;
	}
	// horizontal
	for (i = 0; i < SIZE; i++){
		for (j = 0, tmp = 0; j < SIZE; j++){
			tmp += iField[j][i];
		}
		if (tmp == SIZE*WHT) return WHT;
		if (tmp == SIZE*BLK) return BLK;
	}
	// diagonal
	for (i = 0, tmp = 0; i < SIZE; i++){
		tmp += iField[i][i];
	}
	if (tmp == SIZE*WHT) return WHT;
	if (tmp == SIZE*BLK) return BLK;
	for (i = 0, tmp = 0; i < SIZE; i++){
		tmp += iField[i][SIZE - 1 - i];
	}
	if (tmp == SIZE*WHT) return WHT;
	if (tmp == SIZE*BLK) return BLK;
	return NON;
}

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

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

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

string func(int n){
  string s;
  string t=to_string(n);
  rep(i,0,6-t.size()){
    s+='0';
  }
  return s+t;
}

int main(){
  int n,m;
  cin>>n>>m;
  vector<P> a[n];
  rep(i,0,m){
    int p,y;
    cin>>p>>y;
    a[p-1].push_back(P(y,i));
  }
  rep(i,0,n){
    sort(a[i].begin(),a[i].end());
  }
  string ans[m];
  rep(i,0,n){
    rep(j,0,a[i].size()){
      string s;
      s+=func(i+1);
      s+=func(j+1);
      ans[a[i][j].second]=s;
    }
  }
  rep(i,0,m){
    cout<<ans[i]<<endl;
  }
}

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

using namespace std;

int main() {
    int h, w;
    char pic[102][102];

    cin >> h >> w;
    for (int i = 0; i < w+2; i++) {
        pic[0][i] = '#';
    }

    for (int i = 0; i < h; i++) {
        pic[i+1][0] = '#';
        for (int j = 0; j < w; j++) {
            cin >> pic[i+1][j+1];
        }
        pic[i+1][w+1] = '#';
    }

    for (int i = 0; i < w+2; i++) {
        pic[h+1][i] = '#';
    }

    for (int i = 0; i < h+2; i++) {
        for (int j = 0; j < w+2; j++) {
            cout << pic[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <vector>
#include <algorithm>
using namespace std;

#define iter(i, n) for (int i = 1; i <= n; ++i)

#define NR 101000

const int inf = 1e9;

vector<int> g[NR], add[NR << 2], del[NR << 2];
int n, bg[NR], sz[NR], son[NR], dsz, ex[NR], ey[NR], fa[NR], top[NR], dep[NR];
int t[NR << 2];
bool vis[NR];

#define lx x << 1
#define rx x << 1 | 1
#define RT 1, 1, n
#define SL lx, l, mid
#define SR rx, mid + 1, r

void upd(int x) {
	t[x] = min(t[lx], t[rx]) + add[x].size() - del[x].size();
//	printf("!%d %d\n", x, t[x]);
}

void seg_modify(int x, int l, int r, int ml, int mr, int tag, int d) {
	if (ml <= l && r <= mr) { d == +1 ? add[x].push_back(tag) : del[x].push_back(tag); t[x] += d; return; }

	int mid = (l + r) / 2;
	if (ml <= mid) seg_modify(SL, ml, mr, tag, d);
	if (mr > mid) seg_modify(SR, ml, mr, tag, d);
	upd(x);
}

#define fx top[x]
#define fy top[y]

void modify(int x, int y, int tag, int d) {
	while (fx != fy) {
		if (dep[fx] < dep[fy]) swap(x, y);
		seg_modify(RT, bg[fx], bg[x], tag, d); x = fa[fx];
	}
	if (dep[x] > dep[y]) swap(x, y);
	if (x != y) seg_modify(RT, bg[x] + 1, bg[y], tag, d);
}

void dfs(int x) {
	sz[x] = 1, son[x] = 0;
	for (int v : g[x]) if (v != fa[x]) {
		dep[v] = dep[x] + 1, fa[v] = x, dfs(v), sz[x] += sz[v];
		if (sz[v] > sz[son[x]]) son[x] = v;
	}
}

void bt(int x, int tp) {
	top[x] = tp; bg[x] = ++dsz;
	if (son[x] != 0) bt(son[x], tp);
	for (int v : g[x]) if (v != fa[x] && v != son[x]) bt(v, v);
}

void seg_clr(int x, int l, int r) {
	if (l == r) { t[x] = 2 * inf; return; }
	int mid = (l + r) / 2;
	if (t[lx] < t[rx]) seg_clr(SL);
	else seg_clr(SR);
	upd(x);
}

int seg_min(int x, int l, int r) {
	int res = -1;
	if (add[x].size() == del[x].size()) add[x].clear(), del[x].clear();
	else if (add[x].size() == del[x].size() + 1) {
		for (int i : del[x]) vis[i] = true;
		for (int i : add[x]) if (!vis[i]) res = i;
		for (int i : del[x]) vis[i] = false;	
		
		del[x].clear();
		add[x].clear();
		
		add[x].push_back(res);
	} else assert(0);

	if (res != -1) return res;
	assert(l != r);
	int mid = (l + r) / 2;

	if (t[lx] < t[rx]) return seg_min(SL);
	else return seg_min(SR);
}

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

	iter(i, n - 1) {
		int x, y;
		scanf("%d%d", &x, &y);
		g[x].push_back(y), g[y].push_back(x);
	}

	dfs(1); bt(1, 1);

	iter(i, n) {
		scanf("%d%d", &ex[i], &ey[i]);
		modify(ex[i], ey[i], i, +1);
	}

	

	while (t[1] < inf) {
		//printf("!%d\n", t[1]);
		if (t[1] > 1) { puts("NO"); return 0; }
		if (t[1] == 1) {
			int i = seg_min(RT);
			seg_clr(RT);
			modify(ex[i], ey[i], i, -1);
		} else seg_clr(RT);
	}

	puts("YES");
	return 0;
}


Measured memory_bytes: 60500
#include<cstdio>
using namespace std;

bool grid[1000][1000];
int num[1001][1001];
int h,w,n,tmp;

int main(){
  while(scanf("%d %d %d",&h,&w,&n) && (h||w||n)){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	scanf("%d",&tmp);
	grid[i][j] = (tmp)?true:false;
	num[i][j] = 0;
      }

    num[0][0] = n-1;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	int N=num[i][j];
	if(grid[i][j]){
	  num[i+1][j] += N/2;
	  num[i][j+1] += N-N/2;
	}else{
	  num[i][j+1] += N/2;
	  num[i+1][j] += N-N/2;
	}
	if(N&1)grid[i][j] = !grid[i][j];
      }
    }

    int y=0,x=0;
    while(y<h && x<w){
      if(grid[y][x])x++;
      else y++;
    }
    printf("%d %d\n",y+1,x+1);
  }
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
import math


def read():
    N, K = map(int, input().strip().split())
    return N, K


def solve(N, K):
    # Kの倍数の数
    nk = math.floor(N / K)
    if K % 2 == 1:
        return nk ** 3
    else:
        nhk = math.floor(N / (K//2))
        return nk ** 3 + (nhk - nk) ** 3


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9120
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int n =sc.nextInt();//整数(10進数)
      int k =sc.nextInt();//進数 
      
      //10進数→k進数
      //int i_k = Integer.parseInt(Integer.toString(n,k));
      String i_k = Integer.toString(n,k);
      
      //桁数を出力
      System.out.println((i_k).length());
    }
}

Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main()
{
	int n,a[10002],b[10002],ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
	}
	for(int i=1;i<=n;i++)
	{
		ans+=b[i]-a[i]+1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    int n;
    cin>>n;
    vector<unsigned long long> data(n + 1, 1);
    for(int i=2;i<=n;i++){
        for(int j=i;j<=n;j+=i){
            data[j]++;
        }
    }
    unsigned long long ans = 0;
    for(int i=1;i<=n;i++){
        ans+=i*data[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 81328
// ------------------------------------
// Date:2018/ 3/ 1
// Problem:ABC 075 Minesweeper b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

int main()
{
  int dx[8] = {1, 1, 0, -1, -1, -1,  0,  1};
  int dy[8] = {0, 1, 1,  1,  0, -1, -1, -1};
  int H, W;
  cin >> H >> W;
  string field[60];
  char ans[50][50];
  memset(ans, -1, sizeof(ans));
  REP(hi, H) cin >> field[hi];
  int cnt;
  REP(hi, H) {
    REP(wi, W) {
      cnt = 0;
      if (field[hi][wi] == '#') {
        ans[hi][wi] = '#';
        continue;
      }
      REP(dist, 8) {
        if (0 <= hi + dy[dist] && hi + dy[dist] <= H - 1 &&
            0 <= wi + dx[dist] && wi + dx[dist] <= W - 1 &&
            field[hi + dy[dist]][wi + dx[dist]] == '#') {
          ++cnt;
        }
      }
      ans[hi][wi] = cnt + '0';
    }
  }
  REP(hi, H) {
    REP(wi, W) {
      cout << ans[hi][wi];
    }
    cout << endl;
  }
  return 0;
}



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

#pragma GCC optimize ("O3")
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define TIME cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef map<int, int> mi;
typedef map<ll, ll> ml;
#define fr(i, n) for (int i = 0; i < n; i++)

const int N = 5e5 + 5;
const int M = 998244353;
ll fact[N], inv[N];
vector<bool> prime;
vector<int> drow4{1, -1,  0,  0};
vector<int> dcol4{0,  0, -1,  1};
vector<int> drow8{0,  1,  1,  1,  0, -1, -1, -1};
vector<int> dcol8{1,  1,  0, -1, -1, -1,  0,  1};

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

ll powerModM(ll x, ll y){ 
    ll res = 1; 
    while(y){ 
        if(y & 1) 
            res=(res * x)%M; 
        y = y >> 1; 
        x = (x *x) % M;
    } 
    return res % M; 
}

ll power(ll x, ll y){ 
    ll res = 1; 
    while(y){ 
        if(y & 1) 
            res = res * x; 
        y = y >> 1; 
        x = x*x;
    } 
    return res; 
}
 
void preCalcFactorial(int n){
    fact[0] = inv[0] = 1;
    for(ll i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % M;
        inv[i] = powerModM(fact[i], M - 2);
    }
}
 
ll nCr(ll n,ll r){
    ll ans = ((fact[n] * inv[r]) % M + M) % M;
    ans = ((ans * inv[n-r]) % M + M) % M;
    return ans;
}

void sieve(int n) { 
    prime.resize(n+1, true);
    prime[1] = false;
    for (int p = 2; p * p <= n; p++){ 
        if (prime[p] == true) {
            for (int i = p*p; i <= n; i += p) 
                prime[i] = false; 
        } 
    }
} 

class BIT{
public:
    int size;
    vector<int> v;
    BIT(int s){
        size = s;
        v.resize(s, 0);
    }
    void update(int i, int delta){
        while(i < size){
            v[i] += delta;
            i += i & (-i);
        }
    }
    int sum(int i){
        int s = 0;
        while(i > 0){
            s += v[i];
            i -= i & (-i);
        }
        return s;
    }
};

void testCase(){
    int n;
	cin >> n;
	vi v(n);
	fr(i, n) cin >> v[i];
	sort(v.rbegin(), v.rend());
	ll sum = 0;
	priority_queue<int> pq;
	pq.push(v[0]);
	for(int i = 1; i < n; i++) {
		sum += pq.top();
		pq.pop();
		pq.push(v[i]);
		pq.push(v[i]);
	}
	cout << sum << endl;
}

int main(){
    FAST
    int t = 1;
    //cin >> t;
    while(t--){
        testCase();
    }
}


Measured memory_bytes: 5064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    string a, b;
    cin >> a >> b;
    ll aa = stoll(a);
    string tmp;
    for (char c : b)
    {
        if (c != '.')
        {
            tmp.push_back(c);
        }
    }
    ll bb = stoll(tmp);
    ll ans = (aa * bb) / 100;
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3628
function myout(text){console.log(text);}//standard output
function Main(input) {
	input = input.trim();
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var len = parseInt(input[0]);
  var tabejun = input[1].split(" ").map((a)=>Number(a));
  var manzokudo = input[2].split(" ").map((a)=>Number(a));
  var tyokugo = input[3].split(" ").map((a)=>Number(a));
  var output = 0;
  var mae = null;
  for(var i = 0; i < len; i++){
    var no = tabejun[i] - 1;
    output += manzokudo[no];
    //myout(output);
    if(mae == (no - 1)){
       output += tyokugo[no - 1];
    }
    mae = no;
  }
  myout(output);
  
}

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


Measured memory_bytes: 21064
#include <iostream>
using namespace std;
int main() 
{
	int n,W;
	cin >> n >> W;
	long long int v[n+1];
	long long int w[n+1];
	v[0] = 0; w[0] = 0;
	for(int i = 1 ; i <= n ; i++) cin >> w[i] >> v[i];
	long long int dp[n+1][W+1];
	for(int i = 0 ; i < W+1 ; i++) dp[0][i] = 0;
	for(int i = 1 ; i < n+1 ; i++)
	{
	      dp[i][0] = 0;
	      for(int j = 1 ; j < W+1 ; j++)
	      {
	            if(j-w[i] < 0) dp[i][j] = dp[i-1][j];
	            else dp[i][j] = max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
	      }
	}
	cout << (dp[n][W]);
	return 0;
}

Measured memory_bytes: 79104
# include "iostream"
# include "cstdio"
# include "cmath"
# include "algorithm" 

using namespace std;

const int maxm=1000+10; 

int n,	//n个蛋糕 
	m; 	//取出m个蛋糕 

long long 
	dp[5][maxm], 
	ans,now1,now2; 

inline long long read(){
	long long s=0,w=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-') w=-w;
		ch=getchar();
	}
	while(ch>='0' && ch<='9'){
		s=s*10+ch-'0';
		ch=getchar();
	}
	return s*w;
}

int main(){
	long long x,y,z;
	register int i,j; 
	n=read(),m=read();
	for(i=1;i<=n;i++){
		x=read(),y=read(),z=read(); 
		dp[1][i]=x+y+z; //-x-y-z
		dp[2][i]=x+y-z;	//-x-y+z
		dp[3][i]=x-y+z;	//-x+y-z
		dp[4][i]=x-y-z;	//-x+y+z
	}
	for(i=1;i<=4;i++){
		sort(dp[i]+1,dp[i]+1+n,greater<long long>());
		now1=now2=0; 
		for(j=1;j<=m;j++){
			now1+=dp[i][j];
			now2+=dp[i][n-j+1]; 
		}
		ans=max(ans,max(abs(now1),abs(now2))); 
	}
	printf("%lld",ans); 
	return 0; 
} 

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

#define INT_MAX 2147483647
#define INT_MIN -2147483648

int max(int a, int b);
int min(int a, int b);
int abs(int a);

int a, b, c;
int main() {
	scanf("%d/%d/%d", &a, &b, &c);
	printf("%d/%02d/%02d\n", 2018, b, c);
	return 0;
}

void swap(int *a, int *b) {
	int temp = *a;
	*a = *b;
	*b = temp;	
}

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

int min(int a, int b) {
	return (a < b) ? a : b;
}

int abs(int a) {
	return (a < 0) ? -a : a;
}


Measured memory_bytes: 1732
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)]

a, b = list(map(int,sys.stdin.readline().rstrip().split()))

if a > 0:
    print('Positive')
elif a <= 0 and b >= 0:
    print('Zero')
else:
    if (a+b)%2 == 0:
        print('Negative')
    else:
        print('Positive')

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N, D;
	cin >> N >> D;

	ll ans = 0, pos = 0, d = 0, pret = 0;
	for(int i = 0; i < N; i++){
		int t, F;
		cin >> t >> F;
		F--;
		int diff = t - pret;
		int t1 = pos + F;
		int t2 = abs(pos - F);
		if(d > 0 && t1 <= diff){
			ans += pos * d;
			d = 0;
		}
		else{
			if(d == D || t2 > diff){
				cout << -1 << endl;
				return 0;
			}
			ans += diff * d;
		}
		d++;
		pret = t;
		pos = F;
	}
	ans += pos * d;

	cout << ans << endl;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
char a[maxn],b[maxn];
int main()
{
	int n;cin>>n;
	scanf("%s%s",a,b);
	for(int i=0;i<n;i++){
		cout << a[i]<<b[i];
	}
	cout<<endl;
}


Measured memory_bytes: 256
H,W=[int(x) for x in input().split()]

bom_list=[]
serch_list=[-1,0,1]

for h in range(H):
  str_list=[x for x in input()]
  for w in range(W):
    if str_list[w]=='#':
      bom_list.append([h,w])
      
for h in range(H):
  out_list=[]
  for w in range(W):
    bom_num=0
    
    if [h,w] in bom_list:
      out_list.append('#')
    else:
      for x in [-1,0,1]:
        for y in [-1,0,1]:
          if [h+x,w+y] in bom_list:
            bom_num += 1
      out_list.append(bom_num)
  
  out_str=''
  for s in out_list:
    out_str+=str(s)
    
  print(out_str)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
typedef unsigned long long llu;
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f  first
#define s  second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define FOR(x,a,b) for (int x=a;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)
#define EL printf("\n")
#define debug 1
string s;
int main()
{
	IO;
	cin>>s;
	if(s=="Sunny") {cout<<"Cloudy";return 0;}
	if(s=="Cloudy") {cout<<"Rainy";return 0;}
	if(s=="Rainy") {cout<<"Sunny";return 0;}
	return 0;
}


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

namespace ConsoleApp1 {
    public class Class1 {
        static void Main(string[] args) {
            var N = long.Parse(Console.ReadLine());
            var tmp = new string[N];
            for (var i = 0; i < N; i++) {
                var t = Console.ReadLine().ToArray();
                Array.Sort(t);
                tmp[i] = string.Join(null,t);
            }
            var A = tmp.GroupBy(_ => _).Where(_ => _.Count() > 1).Select(_=>(long)_.Count()).ToArray();
            for (var i = 0; i < A.Length; i++) A[i] = Comb(A[i], 2);
            Console.Write(A.Sum());
        }

        static long Comb(long n,int m) {
            if (m == 0) return 1;
            return n * Comb(n - 1, m - 1) / m;
        }
    }
}

Measured memory_bytes: 29172
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
using namespace std;
int n, a[300];
double dp[301][301][301];
bool vis[301][301][301];
double calc(int one, int two, int three) {
	if (one == 0 && two == 0 && three == 0) return 0.0;
	if (vis[one][two][three]) return dp[one][two][three];
	double res = 0.0;
	if (one > 0) res += (calc(one - 1, two, three) + 1.0) * ((double)one / (double)n);
	if (two > 0) res += (calc(one + 1, two - 1, three) + 1.0) * ((double)two / (double)n);
	if (three > 0) res += (calc(one, two + 1, three - 1) + 1.0) * ((double)three / (double)n);
	res += (double)(n - one - two - three) / (double)n;
	res /= 1.0 - (double)(n - one - two - three) / (double)n;
	vis[one][two][three] = 1;
	return dp[one][two][three] = res;
}
int main() {
	scanf("%d", &n);
	int one = 0, two = 0, three = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] == 1) one++;
		else if (a[i] == 2) two++;
		else three++;
	}
	memset(vis, 0, sizeof(vis));
	double ans = calc(one, two, three);
	printf("%.12lf\n", ans);
	return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007
#define NMAX 200005

typedef long long ll;

using namespace std;

ll abs(ll a, ll b)
{
    return a > b ? a - b : b - a;
}
int main()
{
    ll N;
    ll a[NMAX];
    ll sum = 0;
    cin >> N;
    REP(i, N)
    {
        cin >> a[i];
        sum += a[i];
    }

    ll ans = LONG_MAX;
    ll sumS = 0;
    REP(i, N - 1)
    {
        sumS += a[i];
        ans = min(ans, abs(sumS, sum - sumS));
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}


int n,m;
const int n_max = 100005;
vector<int> Graph[n_max];
int saityou[n_max];

void solve(int v){
    if(Graph[v].size() == 0){
        saityou[v] = 1;
    }
    else{
        itrfor(itr,Graph[v]){
            int to = *itr;
            if(saityou[to] == -1)  solve(to);
            chmax(saityou[v], saityou[to] + 1);
        }
    }
}


signed main(){
    cin >> n >> m;
    int x,y;
    REP(i,m){
        cin >> x >> y;
        x --;
        y --;
        Graph[x].push_back(y);
    }

    REP(i,n) saityou[i] = -1;
    
    REP(i,n) if(saityou[i] == -1) solve(i);

    int ans = - INF;
    REP(i,n) chmax(ans,saityou[i]);
    cout << ans - 1<< endl;


}

Measured memory_bytes: 8576
import numpy as np
N = int(input())
XY = np.array([list(map(int,input().split())) for _ in [0]*N])
th = np.arctan2(XY[:,1],XY[:,0])
XY = XY[th.argsort()]
ans = 0
n = np.linalg.norm
for i in range(N):
    for j in range(i+1,i+N+1):
        r = n(XY[i:j].sum(axis=0)+XY[:max(0,j-N)].sum(axis=0))
        ans = max(ans,r)
print(ans)

Measured memory_bytes: 14404
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	P p[N];
	rep(i,N){
		int a;
		cin >> a;
		p[i] = P(a, i); 
	}
	sort(p, p+N);
	multiset<int> st;
	st.insert(-1);
	st.insert(N);
	int ans = 0;
	rep(i,N){
		int x = p[i].second;
		int y = p[i].first;
		st.insert(x);
		auto itr = st.lower_bound(x);
		int q = *itr++;
		int w = *itr--;
		itr--;
		int r = *itr;
		ans += (w-q) * (q-r) * y;
	}
	cout << ans << endl;
}

Measured memory_bytes: 12800
#!/usr/bin/env python3
def main():
    from collections import defaultdict

    N = int(input())
    S = [input() for _ in range(N)]

    d = defaultdict(int)
    for s in S:
        d[s] += 1
    
    # d = sorted(d.items())
    d = sorted(d.items(), key=lambda d: d[1], reverse=True)
    res = d[0][1]
    lst = []
    for i in d:
        if res > i[1]:
            break
        lst.append(i[0])
        res = i[1]
    for i in sorted(lst):
        print(i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49556
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef struct _data {
	int N;
	int P;
} data;

int  main()
{
 int n,m;
 cin >> n >> m;
 if (n == m)
    cout << "Yes\n";
 else 
    cout << "No\n";
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, i, l, r;
  int result = 0;
  cin >> n;

  for(i = 0; i < n; i++) {
    cin >> l >> r;

    result += (r - l + 1);
  }
  
  cout << result << endl;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

vll r[200005];
ll points[200005];

mll finished;

void calc(ll index, ll plus) {
  if (finished[index]) {
    return;
  }
  points[index] += plus;

  vll list = r[index];

  finished[index] = 1;

  for (ll i = 0; i < list.size(); i++) {
    ll next_index = list[i];

    calc(next_index, points[index]);
  }
}

int main() {
  ll N, Q;
  scanf("%lld %lld", &N, &Q);

  for (ll i = 0; i < N - 1; i++) {
    ll a, b;
    scanf("%lld %lld", &a, &b);

    r[a].emplace_back(b);
    r[b].emplace_back(a);
  }

  for (ll i = 0; i < Q; i++) {
    ll p, x;
    scanf("%lld %lld", &p, &x);

    points[p] += x;
  }

  calc(1, 0);

  cout << points[1];
  for (ll i = 2; i <= N; i++) {
    cout << " " << points[i];
  }
}


Measured memory_bytes: 45916
import math
from fractions import Fraction
n = int(input())
# t0, a0 = map(int, input().split())
anst = 1
ansa = 1
for _ in range(n):
    ti, ai = map(int, input().split())
    anst = ti * math.ceil(max(Fraction(anst, ti), Fraction(ansa, ai)))
    ansa = ai * math.ceil(max(Fraction(anst, ti), Fraction(ansa, ai)))
    # p
    # if math.ceil(anst/ti) < math.ceil(ansa/ai):
    #     # if math.ceil(anst/ti)*ai >= ansa:
    #     #     anst = ti * math.ceil(anst/ti)
    #     #     ansa = ai * math.ceil(anst/ti)
    #     # else:
    #     ansa = ai * math.ceil(ansa/ai)
    #     anst = ti * math.ceil(ansa/ai)
    # else:
    #     # if math.ceil(ansa/ai)*ti >= anst:
    #     #     ansa = ai * math.ceil(ansa/ai)
    #     #     anst = ti * math.ceil(ansa/ai)
    #     # else:
    #     ansa = ai * math.ceil(anst/ti)
    #     anst = ti * math.ceil(anst/ti)
    # # print("anst", anst,"ansa = ", ansa)
        
print(int(anst + ansa))
    


Measured memory_bytes: 5052
import collections

[N,M]=list(map(int,input().split()))
R=[list(map(int,input().split())) for _ in range(M)]

#print(R)
c = collections.Counter(sum(R,[]))
keys=c.keys()
for n in range(1,N+1):
  if n not in keys:
    print(0)
  else:
    print(c[n])

Measured memory_bytes: 3316
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.cos
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, h) = readIntegerList()
    val abList = Array(n) {
        val (a, b) = readLongList()
        a to b
    }
    val amax = abList.maxBy { it.first }!!.first
    val b = abList
        .map { it.second }
        .filter { it >= amax }
        .sortedDescending()
    var damage = 0L
    var ans = 0L
    for (i in b) {
        if (damage >= h) break
        damage += i
        ans++
    }

    ans = if (damage < h) {
        ans + (h - damage + amax - 1) / amax
    } else ans
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 67572
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int sum = A + B + C;
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(A);
        list.add(B);
        list.add(C);
        Collections.sort(list);

        if(sum%2==list.get(2)%2){
            System.out.println((list.get(2) - list.get(1) + list.get(2) - list.get(0)) / 2);
        }
        else if(sum%2!=list.get(2)%2){
            System.out.println((list.get(2) - list.get(1) + list.get(2) - list.get(0) + 1) / 2 + 1);
        }
    }
}

Measured memory_bytes: 21588
#include <cstdio>
#include <vector>

using namespace std;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;

int n, root;
vector <int> graph[MAXN];
int child[MAXN];
int T[MAXN][2];

void read_input()
{
    scanf("%d", &n);

    int v, w;

    for(int i = 0; i < n - 1; i++)
    {
        scanf("%d %d", &v, &w);
        graph[v].push_back(w);
        graph[w].push_back(v);
        child[v]++;
        child[w]++;
    }
    for(int i = 1; i <= n; i++)
    {
        if(child[i] > child[root])
        {
            root = i;
        }
    }
}

int mul(int f, int s)
{
    long long temp = 1LL * f * s;
    temp %= MOD;
    return temp;
}

int add(int f, int s)
{
    f += s;
    return f % MOD;
}

int rec(int index, int color, int p)
{
    if(T[index][color])
    {
        return T[index][color];
    }

    int z = graph[index].size();

    int ans = 1;

    for(int i = 0; i < z; i++)
    {
        int to = graph[index][i];

        if(to == p) continue;
        int temp = rec(to, color ^ 1, index);
        if(color == 0)
        {
            temp = add(temp, rec(to, color, index));
        }
        ans = mul(ans, temp);
    }

    return T[index][color] = ans;
}

void solve()
{
    int ans = add(rec(root, 0, root), rec(root, 1, root));
    printf("%d\n", ans);
}

int main()
{
    read_input();
    solve();

    return 0;
}


Measured memory_bytes: 15232
# coding: utf-8
S = input()
N = len(S)
n1 = (N-1)//2 -1
n2 = (N+3)//2 - 1
if S == S[::-1]:
  if S[:n1+1] == S[:n1+1][::-1]:
    if S[n2:] == S[n2:][::-1]:
      print('Yes')
    else:
      print('No')
  else:
    print('No')     
else:
  print('No')


Measured memory_bytes: 2940
W,H,N=map(int,input().split())
d=[]
for i in range(H):
  d.append([1]*W)
for j in range(N):
  x,y,a=map(int,input().split())
  if a==1:
    for i1 in range(H):
      for x1 in range(x):
        d[i1][x1]=0
  elif a==2:
    for i2 in range(H):
      for x2 in range(x,W):
        d[i2][x2]=0
  elif a==3:
    for i3 in range(y):
      for y1 in range(W):
        d[i3][y1]=0
  else:
    for i4 in range(y,H):
      for y2 in range(W):
        d[i4][y2]=0
ans=0
for k in d:
  ans+=sum(k)
print(ans)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;


int main(){
    int n;cin>>n;
    if(n<1000)puts("ABC");
    else puts("ABD");
    return 0;
}

Measured memory_bytes: 3532
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int a;
	while(cin>>a,a){
		int b;
		string s;
		cin>>b>>s;
		string q="I";
		rep(i,a)q+="OI";
		int co=0;
		rep(i,b-a*2)if(s.substr(i,a*2+1)==q)co++;
		cout<<co<<endl;
	}
}

Measured memory_bytes: 2124
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	cout<<setprecision(20);
	while(-1){
		int n,i;cin>>n;
		if(n==0){RE;}
		lldo wa=0,ni=0;
		for(i=0;i<n;i++){
			lldo s;cin>>s;
			wa+=s;ni+=s*s;
		}
		cout<<sqrt((ni-wa*wa/n)/n)<<endl;
	}
	RE;
}


Measured memory_bytes: 3292
h, w = map(int, raw_input().split())
arr = []

for i in range(h):
    row = map(int, raw_input().split())
    arr.append(row)
num = 0
move = []
for i in range(h):
    for j in range(w-1):
        if arr[i][j] % 2 == 1:
            arr[i][j + 1] += 1
            num += 1
            move.append([i + 1, j + 1, i + 1, j + 2])
    if i < h-1:
        if arr[i][w - 1] % 2 == 1:
            arr[i + 1][w - 1] += 1
            num += 1
            move.append([i + 1, w, i + 2, w])
print num
for i in move:
    for j in i:
        print j,
    print






Measured memory_bytes: 29576
s = input()
ans = 0
for i in range(2**(len(s)-1)):
    eq = s[0]
    for j in range(len(s)-1):
        if (i >> j) & 1: eq += "+" + s[j+1]
        else: eq += s[j+1]
    ans += eval(eq)
print(ans)

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

int main()
{
	int h, w;
	char a[100][101], b[102][102];
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			b[i][j] = '#';
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			b[i + 1][j + 1] = a[i][j];
		}
	}
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			cout << b[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

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

    string s;
    cin >> s;

    cout << s;
    cout << (s.back() == 's' ? "es" : "s") << endl;

    return 0;
}

Measured memory_bytes: 3620