akhauriyash/Code-Regression huggingface dataset:
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c := getInt(), getInt(), getInt()

	if b-a == c-b {
		out("YES")
	} else {
		out("NO")
	}
}


Measured memory_bytes: 640
N,M = map(int,input().split())
UVS = [list(map(int,input().split())) for _ in [0]*M]

E = [[] for _ in [0]*N]
for u,v,s in UVS:
    u-=1;v-=1
    E[u].append((v,s))
    E[v].append((u,s))

V = [None]*N
V[0] = (0,1)
q = [0]
while q:
    i = q.pop()
    d,n = V[i]
    for j,s in E[i]:
        if V[j] != None: continue
        V[j] = (1-d,s-n)
        q.append(j)

INF = 10**18
checkD = False
checkSum = []
checkMin = [INF]*2
checkMax = [-INF]*2
for i in range(N):
    for j,s in E[i]:
        if j<i: continue
        checkD = checkD or (V[i][0] == V[j][0])
        if V[i][1]+V[j][1]!=s:
            checkSum.append((V[i][0],V[j][0],s-V[i][1]-V[j][1]))
    d = V[i][0]
    checkMin[d] = min(checkMin[d],V[i][1])

if checkD:
    ansFlg = True
    cnt = set()
    for di,dj,s in checkSum:
        if di != dj:
            ansFlg = False
            break
        if di == 1: s *= -1
        cnt.add(s)
    if len(cnt)>1:
        ansFlg = False
    elif cnt:
        d = cnt.pop()
        if d%2: ansFlg = False
        d //= 2
        if min(checkMin[0]+d,checkMin[1]-d) <= 0: ansFlg = False
    ans = int(ansFlg)
else:
    ans = max(sum(checkMin)-1,0)
    if checkSum: ans = 0
print(ans)

Measured memory_bytes: 69348
import pdb


def main():
    num = int(input())
    price = []
    for i in range(num):
        price.append(int(input()))

    price.sort()
    ans = 0
    loop_num = len(price)
    for i in range(loop_num):
        if i == 0:
            ans += (price.pop()) / 2
        else:
            ans += price.pop()


    print("%d" % ans)

        
if __name__ == '__main__':
    main()


Measured memory_bytes: 5248
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

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<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int a[3];

int main() {
	int x, y; cin >> x >> y;
	x--; y--;
	a[x] = 1;
	a[y] = 1;

	for (int i = 0; i < 3; i++) {
		if (a[i] != 1)cout << (i + 1) << endl; 
	}
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val x = readLine()!!.toInt()
    val n = x / 100
    var y = x % 100
    repeat(n) {
        for (i in 5 downTo 1) {
            if (y >= i) {
                y -= i
                return@repeat
            }
        }
    }
    println(if (y == 0) 1 else 0)
}


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

int main() {
  string s1, s2; cin >> s1 >> s2;
  vector<char> c1, c2;
  for (ll i = 0; i < s1.size(); i++) {
    c1.push_back(s1[i]);
  }
  sort(c1.begin(), c1.end());
  for (ll i = 0; i < s2.size(); i++) {
    c2.push_back(s2[i]);
  }
  sort(c2.begin(), c2.end());
  string s = "";
  string t = "";
  
  for (ll i = 0; i < c1.size(); i++) {
    s = s + c1[i];
  }
  for (ll i = c2.size()-1; i >= 0; i--) {
    t = t + c2[i];
  }
  if (s < t) {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
}

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

using namespace std;
using ll = long long;
using VI = vector<ll>;
using VVI = vector<VI>;
using P = pair<ll, ll>;

int idx(VI v, ll k) { return lower_bound(v.begin(), v.end(), k) - v.begin(); }

int main(int argc, char const* argv[]) {
  ll n, m;
  cin >> n >> m;

  vector<P> ts(n, make_pair(0, 0));
  VI x(n), xs(n);
  VI y(n), ys(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    xs[i] = x[i];
    ys[i] = y[i];
  }
  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());

  sort(ys.begin(), ys.end());
  ys.erase(unique(ys.begin(), ys.end()), ys.end());

  VVI tbl = VVI(xs.size() + 2, VI(ys.size() + 2, 0));

  for (int i = 0; i < n; i++) {
    ll tx = idx(xs, x[i]);
    ll ty = idx(ys, y[i]);
    tbl[tx + 1][ty + 1]++;
  }
  for (int i = 0; i < xs.size(); i++) {
    for (int j = 0; j < ys.size(); j++) {
      tbl[i + 1][j + 1] += tbl[i + 1][j] + tbl[i][j + 1] - tbl[i][j];
    }
  }

  for (int i = 0; i < m; i++) {
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1 = idx(xs, x1); // ret === x1 の時k、小さい値が返る, x1 < retの時も実質そう
    y1 = idx(ys, y1);
    x2 = idx(xs, x2+1); // x2 == val の時 ret = idx(x2)+1 ,
    y2 = idx(ys, y2+1);
    cout << tbl[x2][y2] - tbl[x2][y1] - tbl[x1][y2] + tbl[x1][y1] << endl;
  }

  return 0;
}



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

int main()
{
    int x;
    // scanf("%d %d", &a, &b);
    cin >> x;
    int h = x / 3600.0;
    x = x % 3600;
    int m = x / 60;
    int s = x % 60;
    cout << h << ":" << m << ":" << s << endl;

    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<string,string> pss;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;
typedef complex<ld> point;
#define MAXN 100005

ll a[MAXN],ac[MAXN];

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

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

    ac[n]=a[n];
    for(int i=n-1;i>=0;i--)
        ac[i]=ac[i+1]+a[i];

    ll res=0;
    ll po=1;
    for(int i=0;i<=n;i++)
    {
//        cout << po << ' ' << a[i] << '\n';
        po=min(po,ac[i]);
        res+=po;
        po-=a[i];
        if(po<0)
        {
            res=-1;
            break;
        }
        po*=2;
    }

    db(res)
    return 0;
}
/**
3
0 1 1 2
4
0 0 1 0 2
**/


Measured memory_bytes: 5216
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int N;
	get(N);

	std::vector<std::pair<int, int>> edge;
	if (N % 2) {
		for (int i = 1; i <= N; i++) {
			for (int j = i + 1; j <= N; j++) {
				if (j == (N - i)) continue;
				edge.push_back(std::pair<int, int>(i, j));
			}
		}
	}
	else {
		for (int i = 1; i <= N; i++) {
			for (int j = i + 1; j <= N; j++) {
				if (j == (N + 1 - i)) continue;
				edge.push_back(std::pair<int, int>(i, j));
			}
		}
	}

	int size = edge.size();
	printf("%d\n", size);
	for (int i = 0; i < size; i++) {
		printf("%d %d\n", edge[i].first, edge[i].second);
	}
}


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


int main() {
  int N, result;
  char S[100];
  int i;
  scanf ("%d", &N);
  scanf ("%s", S);
  
  result = 1;
  if (N%2) {
	  printf("%s", "No");
	  return 0;
  }
  for (i=0;i<N/2;i++) {
  	if (S[i]!=S[i+N/2]) {
  		result = 0;
  		break;
  	}
  }
  
  
  printf("%s", result?"Yes":"No");
  return 0;
}




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

const int mx=100010;
const ll mod=1e9+7;

typedef vector<vector<pair<ll,int>>> wgraph;
typedef pair<ll,int> pli;

vector<ll> bfs(wgraph v,int x){
  priority_queue<pli,vector<pli>,greater<pli>> q;
  vector<ll> dist(v.size(),longinf);
  dist[x]=0;
  q.push({0LL,x});
  
  while(q.size()){
    pli p=q.top(); q.pop();
    ll d=p.F, now=p.S;
    if(dist[now]<d){ continue; }
    for(auto to:v[now]){
      if(dist[to.S]>d+to.F){
        dist[to.S] = d+to.F;
        q.push({dist[to.S], to.S});
      }
    }
  }
  return dist;
}

int main(){
  int n,m,s,t;
  cin >> n >> m >> s >> t;
  s--; t--;
  wgraph v1(n),v2(n);
  rep(i,m){
    int x,y,z1,z2;
    cin >> x >> y >> z1 >> z2; x--; y--;
    v1[x].push_back({z1,y});
    v1[y].push_back({z1,x});
    v2[x].push_back({z2,y});
    v2[y].push_back({z2,x});
  }
  vector<ll> dist1=bfs(v1,s);
  vector<ll> dist2=bfs(v2,t);
  vector<ll> ans(n);
  rep(i,n){ ans[i] = 1e15-dist1[i]-dist2[i]; } //i:exchange point
  rep(i,n-1){ ans[n-i-2]=max(ans[n-i-2],ans[n-i-1]); }//ans[n]
  rep(i,n){ cout << ans[i] <<endl; }
  return 0;
}


Measured memory_bytes: 26684
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        aa: [[usize;3];3],
        n: usize,
        bb: [usize;n]
    }
    let mut v = vec![vec![false;3];3];
    for b in bb {
        for i in 0..3 {
            for j in 0..3 {
                if aa[i][j] == b {
                    v[i][j] = true;
                }
            }
        }
    }
    for i in 0..3 {
        let mut r = true;
        let mut c = true;
        for j in 0..3 {
            if !v[i][j] {
                r = false;
            }
            if !v[j][i] {
                c = false;
            }
        }
        if r || c {
            println!("Yes");
            return;
        }
    }
    if (v[0][0] && v[1][1] && v[2][2]) ||
        (v[0][2] && v[1][1] && v[2][0]) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    cnt = defaultdict(int)
    for _ in range(n):
        s = [x for x in input()]
        s.sort()
        s = ''.join(s)
        cnt[s] += 1
    ans = 0
    for k in cnt:
        n = cnt[k]
        ans += n * (n - 1) // 2
    print(ans)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

abc

"""


Measured memory_bytes: 22372
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

bool sqrt(double a)
{
	for(int i=1;i*i<=a;i++){
		if(double(i*i) == a){
			return true;
		}
	}
	return false;
}

int main()
{	
	int n, d;
	int x[10][10] = {0};
	cin >> n >> d;

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

	int ans = 0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			double dist = 0;
			for(int k=0;k<d;k++){
				dist += double((x[i][k] - x[j][k])*(x[i][k] - x[j][k]));
			}
			//cout << dist << endl;
			if(sqrt(dist)){
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 888
K,A,B = gets.chomp.split(" ").map(&:to_i)

#まず A-1ステップが必要
##そこからA=>B で何枚増えるか  == B-A (2ステップ)
n = (K-(A-1))/2
j = K - ((A-1)+(2*n))

if B-A >= 2
    p n*(B-A)+A+j
else
    p 1+K
end


Measured memory_bytes: 1788
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = [i for i in range(1, N+1)]

C = list(itertools.permutations(R, N))

a = 0
b = 0
for i in range(len(C)):
    if list(C[i]) == P: a = i
    if list(C[i]) == Q: b = i

print(abs(a-b))



Measured memory_bytes: 8052
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long 
#define fi first
#define se second
vector<int> v;
signed main(){
  int x,y,a,b,c;
  int p[10000000];
  int q[10000000];
  int r[10000000];
  int C=0,sum=0;
  cin>>x>>y>>a>>b>>c;
  for(int i=0;i<a;i++) cin>>p[i];
  for(int i=0;i<b;i++) cin>>q[i];
  for(int i=0;i<c;i++) cin>>r[i];
  sort(p,p+a,greater<int>());
  sort(q,q+b,greater<int>());
  sort(r,r+c,greater<int>());
  for(int i=0;i<x;i++) v.push_back(p[i]);
  for(int i=0;i<y;i++) v.push_back(q[i]);
  sort(v.begin(),v.end());
  for(int i=0;i<max(c,x+y)&&i<v.size();i++){
    if(v[i]<r[C]){
      v[i]=r[C];
      C++;
    }
    sum+=v[i];
  }
  cout<<sum<<"\n";
}

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

#define rep(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace(x) cout << #x << ": " << x << endl
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#define INF 1LL<<62

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

const ll MAX =1e7 +10;
int main(){
  ll x, y, a, b, c;
  scanf("%lld %lld %lld %lld %lld", &x, &y,&a,&b,&c);
  vi arr1(a);
  vi arr2(b);
  vi arr3(c);
  rep(i,0,a) scanf("%lld", &arr1[i]);
  rep(i,0,b) scanf("%lld", &arr2[i]);
  rep(i,0,c) scanf("%lld", &arr3[i]);
  sort(all(arr1));
  sort(all(arr2));
  sort(all(arr3));
  vi aux;
  rep(i,0,x) aux.pb(arr1[a-i-1]);
  rep(i,0,y) aux.pb(arr2[b-i-1]);
  rep(i,0,c) aux.pb(arr3[i]);
  sort(all(aux));
  ll rpta = 0;
  rep(i,0,x+y) rpta+=aux[aux.size()-1-i];
  printf("%lld\n", rpta);
}

Measured memory_bytes: 8688
#include <iostream>
#include <string>

auto print = [](auto x){ std::cout << x; };
auto println = [](auto x){ std::cout << x << std::endl; };
auto read = [](auto &x){ std::cin >> x; };

int main ()
{
  int n;
  std::string taro_card, hanako_card;
  int taro_score=0, hanako_score=0;

  read(n);

  for (int i=0; i<n; i++)
    {
      read(taro_card);
      read(hanako_card);

      if (taro_card == hanako_card){
        taro_score++;
        hanako_score++;
      }
      else
        {
          if (taro_card > hanako_card)
            taro_score += 3;
          else
            hanako_score += 3;
        }
    }
  print(taro_score);
  print(" ");
  println(hanako_score);
}



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

int main()
{
    int d;
    cin >> d;
    vector<int> c(26);
    vector<vector<int>> s(d,vector<int>(26));

    for (int i = 0; i < 26; i++)
    {
        cin >> c[i];
    }
    for (int i = 0; i < d; i++)
    {
        for (int j = 0; j < 26; j++)
        {
            cin >> s[i][j];
        }
    }

    for (int i = 0; i < d; i++)
    {
        cout << i % 26 + 1 << endl;
    }
    
}


Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());

    ll n;
    cin >> n;
    long double x[10] = {};
    string u[10] = {};
    for (ll i=0;i<n;i++){
        cin >> x[i] >> u[i];
    }
    long double ans = 0;
    for (ll i=0;i<n;i++){
        if(u[i] == "JPY"){
            ans += x[i];
        }else{
            ans += x[i] * 380000;
        }
    }
    cout << fixed;
    cout << setprecision(10);
    cout << ans << endl;
}

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

using namespace std;

int main() {
  int a, b=0, d=0;
  string s;
  cin >> a >> s;
  for(char c:s) {
    if (c=='B') b++;
    else d++;
  }
  cout << (d>b? "Yes" : "No") <<endl;
}

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

int main(){
    int64_t K, A, B, ans;
    cin >> K >> A >> B;
    if(B-A <= 2 || K <= A-1){
        ans = 1+K;
    }else{
        int64_t T = K - (A-1);
        ans = A + T/2 * (B-A) + T%2;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n, x, y;
  cin >> n >> x >> y;

  int l = n - (y - x) + 1;
  int r = y - x + 1;
  for (int k = 1; k < n; k++) {
    int score = 0;

    score += max(0, l - k);

    if (k == 1) {
      score += r - 1;
    } else if (r == k * 2) {
      score += r / 2;
    } else if (r > k * 2) {
      score += r;
    }

    if (k > 1) {
      int spl = (r - 1) / 2;
      int lpl = r / 2 - 1;
      int la = x - 1;
      int ra = n - y;

      score += max(0, min({k - 1, spl, la, la + spl + 1 - k}));
      score += max(0, min({k - 2, lpl, la, la + lpl + 2 - k}));
      score += max(0, min({k - 1, spl, ra, ra + spl + 1 - k}));
      score += max(0, min({k - 2, lpl, ra, ra + lpl + 2 - k}));
    }

    cout << score << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <algorithm> 
#include <ctime>

#define MaxN 1005
#define INF 2140000000
 
using namespace std;

int H,W,h,w;


int main()
{
	cin>>H>>W>>h>>w;
	if((H/h)*(W/w)*(1000*(h*w-1)+1)>1000*(H*W-(H/h)*(W/w)))
		cout<<"No\n";
	else
	{
		cout<<"Yes\n";
		for(int i=1;i<=H;i++)
		{
			for(int j=1;j<=W;j++)
			{
				if(i%h==0&&j%w==0)
					cout<<(-h*w+1)*1000-1<<' ';
				else cout<<1000<<' ';
			}
			cout<<'\n';
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;

#define MAX_N 2000

int x[MAX_N][MAX_N];
int col[MAX_N][MAX_N], cnt;
int h, w;

queue<int>Q;

void bfs(int c) {
	while (!Q.empty()) {
		int a = Q.front() / 10000;
		int b = Q.front() % 10000;
		Q.pop();
		if (x[a][b] == x[a - 1][b] && col[a - 1][b] == 0) {
			col[a - 1][b] = cnt;
			Q.push((a - 1) * 10000 + b);
		}
		if (x[a][b] == x[a + 1][b] && col[a + 1][b] == 0) {
			col[a + 1][b] = cnt;
			Q.push((a + 1) * 10000 + b);
		}
		if (x[a][b] == x[a][b - 1] && col[a][b - 1] == 0) {
			col[a][b - 1] = cnt;
			Q.push(a * 10000 + (b - 1));
		}
		if (x[a][b] == x[a][b + 1] && col[a][b + 1] == 0) {
			col[a][b + 1] = cnt;
			Q.push(a * 10000 + (b + 1));
		}
	}
}

int main() {
	while (true) {
		memset(col, 0, sizeof(col));
		memset(x, 0, sizeof(x));
		cin >> h >> w;
		if (h == 0 && w == 0) { break; }
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				char c;
				cin >> c;
				if (c == '@') { x[i][j] = 1; }
				if (c == '#') { x[i][j] = 2; }
				if (c == '*') { x[i][j] = 3; }
			}
		}
		cnt = 0;
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if (col[i][j] == 0) {
					Q.push(i*10000 + j);
					cnt++;
					col[i][j] = cnt;
					bfs(x[i][j]);
				}
			}
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 32468
#include<stdio.h>
#include<string.h>
int main(void){
    int n,shuffle;
    char str[500];
    char tmp;
    while(1){
        for(int i=0; i<500; i++){
            str[i] = '\0';
        }
        scanf("%s",str);
        if(!strcmp(str,"-")){
            break;
        }
        scanf("%d",&n);
        for(int i=0; i<n; i++){
            scanf("%d",&shuffle);
            for(int j=0; j<shuffle; j++){
                tmp = str[0];
                for(int k=0; k<strlen(str)-1; k++){
                    str[k] = str[k+1];
                }
                str[strlen(str)-1] = tmp;
            }
        }
        printf("%s\n",str);
    }
    return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	if( n==2){
		int a,b;
		scanf("%d",&a);
		scanf("%d",&b);
		printf("%d",a+b);
		return 0;
	}else{
		printf("Hello World");
		return 0;
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
vector<int> g[100005];
int dp[2][100005];

void dfs(int u, int p, int idx, int d) {
    dp[idx][u] = d;
    for (int i = 0; i < g[u].size(); ++i) {
        int v = g[u][i];
        if (v == p) continue;
        dfs(v, u, idx, d + 1);
    }
}

int main() {
    int n, u, v, a, b;
    scanf("%d %d %d", &n, &u, &v);
    for (int i = 1; i <= n - 1; ++i) {
        scanf("%d %d", &a, &b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(u, 0, 0, 0);
    dfs(v, 0, 1, 0);    
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (dp[0][i] < dp[1][i]) {
            ans = max(ans, dp[1][i] - 1);
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 12928
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"
exit $?
'''
import sys
import math

def _i(): return int(sys.stdin.readline().strip())

print(math.ceil(_i()/2))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a , b , c , d;
    while(~scanf("%d%d%d%d" , &a , &b , &c , &d))
    {
        int up = min(b , d);
        int down = max(a , c);
        int ans = max(0 , up - down);
        printf("%d\n" , ans);
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(auto &t:a)cin>>t;return i;}
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T> void prArr(T a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  int n,A,B;
  cin>>n>>A>>B;

  if((B-A)%2 == 1) cout<<"Borys"<<endl;
  else cout<<"Alice"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define SORT(v) sort(v.begin(), v.end());
#define REVERSE(v)  reverse(v.begin(), v;.end());
typedef long long lint;
using namespace std;

int main() {
  int R; cin>>R;
  if(R<1200) cout<<"ABC"<<endl;
  else if(R<2800) cout<<"ARC"<<endl;
  else cout<<"AGC"<<endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>

/*
 *変数
 */
int x;

/*
 *解 
 */
void solve(){
    if(x==3||x==5||x==7)printf("YES");
    else printf("NO");
}

/*
 *入力 
 */
int main(){
       std::cin.tie(0);
       std::ios::sync_with_stdio(false);
       std::cin>>x;
       solve();
       return 0;
}

Measured memory_bytes: 256
S_1 = gets.chomp # 回文をつくる
n = S_1.length

S_2 = S_1[0...(n - 1) / 2]
S_3 = S_1[((n + 3) / 2 - 1)...n]

if S_1 == S_1.reverse && S_2 == S_2.reverse && S_3 == S_3.reverse
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
# from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,T = map(int, input().split())
    ans = float('inf')
    for _ in range(N):
        c,t = map(int, input().split())
        if t > T: continue
        ans = min(ans, c)

    if ans == float('inf'):
        print('TLE')
    else:
        print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3952
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuilder b = new StringBuilder();

        int size = s.length();
        
        for(int i=0;i<size;i++){
            String x = s.substring(i,i+1);
            if(x.equals("B")){
                int a = b.length();
                if(a>0){
                    b.deleteCharAt(a-1);
                }
            }else{
                b.append(x);
            }
        }
        
        String result = b.toString();
        System.out.println(result);
    }
    
    
}


Measured memory_bytes: 9676
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long a=sc.nextInt();
		long b=sc.nextInt();
		long c=sc.nextInt();
		long d=sc.nextInt();
		
		

		System.out.println(Math.max(Math.max(a*c,a*d),Math.max(b*c,b*d)));
	}

}

Measured memory_bytes: 35652
N = int(input())
times = list(map(int,input().split()))
M = int(input())
drinks = []
for _ in range(M):
    drinks.append(list(map(int,input().split())))

for drink in drinks:
    total = 0
    for j in range(N):
        if drink[0] == j+1:
            total += drink[1]
        else:
            total += times[j]
    print(total)

Measured memory_bytes: 9068
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define iinf (3000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
double n,k;
int recur(int x,int y){
	if(y==n){
		return x;
	}
	return min(recur(x+k,y+1),recur(x*2,y+1));
}
int main(){
	std::ios::sync_with_stdio(false);
	//int n,k;
	cin>>n>>k;
	cout<<(double)2*k-n<<endl;
}

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

int num_of_children(int a, int b, int x){
    if((b-a)%2==1){
        return (b-a + 1)/2;
    }else if((x-a)%2==0){
        return (b-a)/2 + 1;
    }else{
        return (b-a)/ 2;
    }
}

int main(){
    string s;
    cin >> s;
    
    int children = 0;
    
    vector<int> index(0);
    index.push_back(-1);
    
    vector<int> answer(s.size());
    
    for(int i = 0; i < s.size() - 1; i++){
        if(s.at(i) != s.at(i + 1)){
            index.push_back(i);
        }
    }
    
    index.push_back(s.size() - 1);
    
    
    for(int i = 0; i < index.size() - 1; i += 2 ){
        answer.at(index.at(i + 1)) = num_of_children(index.at(i) + 1, index.at(i + 2), index.at(i + 1));
        answer.at(index.at(i + 1) + 1) = num_of_children(index.at(i) + 1, index.at(i + 2), index.at(i + 1) + 1);
    }
    
    for(int a: answer){
        cout << a << " ";
    }
    
}

Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef pair<int,int> P;
typedef pair<double,double> P_f;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define bitrep(bit,n) for(int bit=0; bit<=(1<<n);bit++)
#define MAX 100100
#define MAX_N 200100
#define MAX_T 2001001
#define SENTINEL 20010010010
#define NIL -1
static const int INF = 1 << 29;
const ll INFTY = 1LL<<50;
const int MOD=1e9+7;
int n;
int D[1010];
int main(){
    memset(D,0,sizeof(D));
    cin>>n;
    int temp=1;
    for(int i=1;i<=n;i++){
        temp=i;
        for(int j=2;j<=temp;j++){
            while(temp%j==0){
                D[j]++;temp/=j;
            }

            
        }
    }
    LL ans=1;
    for(int i=2;i<=1000;i++){
        ans=ans*(D[i]+1)%MOD;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

typedef long lint;
typedef pair<lint, lint> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint N; cin >> N;
    lint A; cin >> A;
    lint B; cin >> B;

    

    
    lint a0 = 0;
    lint a1 = 0;
    lint a2 = 0;

    REP(i, N) {
      lint p; cin >> p;
      if(p <= A) {
        a0++;
      } else if( p <= B) {
        a1++;
      } else {
        a2++;
      }
    }
    cout << min(a0,min(a1, a2)) << "\n";

    return 0;
}


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

int main() {
  int N, L; cin >> N >> L;
  int eat;
  int taste = 0;
  
  if (L > 0) {
    eat = 1;
  } else if (1 - L > N) {
    eat = N;
  } else {
    eat = 1 - L;
  }
  
  for (int i = 1; i <= N; ++i) {
    if (i == eat) continue;
    taste += L + i - 1;
  }
  
  cout << taste << endl;
  
  return 0;
}

Measured memory_bytes: 256
n=int(input())
arr=list(map(int,input().split()))
arr2=list(map(int,input().split()))
ans=0
for i in range(n):
	if(arr[i]-arr2[i]>0):
		ans+=arr[i]-arr2[i]

	#ans=max(ans,arr[i]-arr2[i])
print(ans)


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

int order[100000];

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int num;
        cin >> num;
        order[num-1] = i+1;
    }

    for(int i = 0; i < (n-1); i++)
        cout << order[i] << " ";
    cout << order[n-1] << "\n";
 
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second
typedef long long ll;
using namespace std;
const int N = 2e5;

int a[N+1];


int main() {
  ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
  int n,m = -1;
  cin >> n;
  
  int arr[n];
  for (int i=0; i<n; i++){
    cin >> arr[i];
    a[arr[i]]++;
    m=max(m,arr[i]);
  }
  
  for (int i=0; i<n; i++){
    for (int j=m; j>=0; j--){
      if (a[j]>1 || (arr[i]!=j&&a[j])){
        cout << j;
        break;
      }
    }
    cout << "\n";
  }
  return 0;
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main(void){
string s,t;cin>>s>>t;
int n=s.length(),c,p=0;
char x[n+1],y[n+1];
strcpy(x,s.c_str());
strcpy(y,t.c_str());
while(p<n-1){
for(int i=0;i<n;i++){
    if(x[i]!=y[i])
        break;
    if(i==(n-1)){
        cout<<"Yes"<<endl;return 0;
    }}
for(int i=0;i<n;i++){
    if(i==(n-1))
        break;
    c=x[n-1];
    x[n-1]=x[i];
    x[i]=c;
}
p+=1;
}
for(int i=0;i<n;i++){
    if(x[i]!=y[i])
        break;
    if(i==(n-1)){
        cout<<"Yes"<<endl;return 0;
    }}
cout<<"No"<<endl;
return 0;}


Measured memory_bytes: 3576
numsArray = Array.new
numsArray[0] = 0
i = 1

loop {
    numsArray[i] = gets.to_i
    if numsArray[i] == 0
        break
    end
    
    i += 1
}

i -= 1
caseNumber = 1

i.times do
    print "Case ", caseNumber, ": ", numsArray[caseNumber], "\n"
    caseNumber += 1
end

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

using namespace std;

#define LL long long
#define ULL unsigned LL
#define LD long double

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin>>n>>m;
	int w = n*(n-1) / 2;
	w+=(m*(m-1)/2);
	cout<<w;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int n;
  cin >> n;

  map<string, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }

  int max = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    chmax(max, itr->second);
  }

  vector<string> ss;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->second == max) ss.push_back(itr->first);
  }

  sort(ALL(ss));

  for (auto& a : ss) {
    cout << a << endl;
  }


  return 0;
}


Measured memory_bytes: 27632
package main

import "fmt"

func main() {

	var a, b, c, d, e int
	var k int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&d)
	fmt.Scan(&e)
	fmt.Scan(&k)
	ab := b - a
	ac := c - a
	ad := d - a
	ae := e - a
	bc := c - b
	bd := d - b
	be := e - b
	cd := d - c
	ce := e - c
	de := e - d
	if ab > k || ac > k || ad > k || ae > k || bc > k || bd > k || be > k || cd > k || ce > k || de > k {
		fmt.Println(":(")
	} else {
		fmt.Println("Yay!")
	}

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


char a[55][55];

int main(){FIN

    ll h,w;
    cin>>h>>w;

    REP(i,h) REP(j,w) cin>>a[i][j];
    REP(i,h){
        REP(j,w){
            if (a[i][j]=='#'){
                if (i-1>=0 && a[i-1][j]=='#') continue;
                else if(j-1>=0 && a[i][j-1]=='#') continue;
                else if (i+1<h && a[i+1][j]=='#') continue;
                else if (j+1<w && a[i][j+1]=='#') continue;
                else {
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std ;
template < class R > inline void Readin( R &K ) {bool F=K=0;char C=getchar();while(C<'0'||C>'9')
{if(C=='-')F=1;C=getchar();}while(C<='9'&&C>='0')K=(K<<1)+(K<<3)+C-'0',C=getchar();if(F)K=-K;}
template < class R > inline bool Checkmax( R &A , R B ) { return A < B ? A = B , 1 : 0 ; }
template < class R > inline bool Checkmin( R &A , R B ) { return A > B ? A = B , 1 : 0 ; }
long long A[3] ;
int main() {
	scanf( "%lld%lld%lld" , &A[0] , &A[1] , &A[2] ) ;
	if( ( A[0] & A[1] & A[2] & 1 ) == 0 )
		return not printf( "0\n" ) ;
	sort( A , A + 3 ) ;
	return not printf( "%lld\n" , A[0] * A[1] ) ;
}

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

using ll = long long;
using lli = long long int;

lli n, x, y;
std::vector<std::vector<lli>> vec;
std::vector<lli> answers;

int main() {
    std::cin >> n >> x >> y;
    answers.assign(n, 0);
    lli s = x + y;
    vec.assign(n+1, std::vector<lli>(n+1, -1));
    for (lli i = 1; i <= n; i++) {
        for (lli j = 1; j <= n; j++) {
            if (i == j) {
                vec[i][j] = 0;
                continue;
            }
            if (vec[j][i] != -1) {
                vec[i][j] = vec[j][i];
                continue;
            }
            lli direct_distance = std::abs(i - j);
            lli warp_distance;
            lli near_whole = (std::abs(i-x) <= std::abs(i-y) ? x : y);
            lli warp_dst = s - near_whole;
            warp_distance = std::abs(i-near_whole) + 1 + std::abs(j-warp_dst);
            lli res = std::min(direct_distance, warp_distance);
            vec[i][j] = res;
            answers[res]++;
        }
    }
    for (int i = 1; i < n; i++) {
        std::cout << answers[i] << std::endl;
    }
}


Measured memory_bytes: 34572
Scanf.scanf "%d %d %d" (fun n a b ->
    let p = Array.init n (fun _ -> Scanf.scanf " %d" (fun p -> p)) in

    let rec loop i cat1 cat2 cat3 =
        if i = n then min (min cat1 cat2) cat3 else
            if p.(i) <= a then loop (i + 1) (cat1 + 1) cat2 cat3 else
            if p.(i) <= b then loop (i + 1) cat1 (cat2 + 1) cat3 else
                               loop (i + 1) cat1 cat2 (cat3 + 1)
    in
    Printf.printf "%d\n" @@ loop 0 0 0 0
)

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  ll n,m,k;
  cin>>n>>m>>k;
  vector<ll>a(n+1),b(m+1);
  rep(i,n){
    int na;
    cin>>na;
    a[i+1]=a[i]+na;
  }
  rep(i,m){
    int nb;
    cin>>nb;
    b[i+1]=b[i]+nb;
  }
  int ans=0;
  rep(i,n+1){
    auto is=[&](int mid){
      if(a[i]+b[mid]<=k)return true;
      return false;
    };
    auto bs=[&](){
      int l=-1,r=m+1;
      while(r-l>1){
        int mid=(l+r)/2;
        if(is(mid)){
          l=mid;
        }
        else{
          r=mid;
        }
      }
      return l;
    };
    int j=bs();
    if(j<0)continue;
    chmax(ans,i+j);
  }
  cout<<ans<<endl;
  return(0);
}

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

int main() {
  string S;
  cin >> S;
  int a = stoi(S.substr(0, 2));
  int b = stoi(S.substr(2, 2));

  string ans = "";
  if (1 <= a && a <= 12 && 1 <= b && b <= 12) {
    ans = "AMBIGUOUS";
  } else if (1 <= b && b <= 12) {
    ans = "YYMM";
  } else if (1 <= a && a <= 12) {
    ans = "MMYY";
  } else {
    ans = "NA";
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
    ll n,a,b,ans=0;
    cin >> n >> a >> b;
    ll k = n%(a+b);
    if(k>=a) ans = (n/(a+b))*a + a;
    else  ans = (n/(a+b))*a + k;
    if(a==0) ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
using namespace std;

int main()
{
    multimap<string,int> mp;
    map<string,int>::iterator  it;
    int tp,q,val;
    string key;
    string r,l;
    cin>>q;
    while(q--){
        cin>>tp;
        if(tp==1)
        {
            cin>>key;
            it=mp.lower_bound(key);
            while(it!=mp.end()&&it->first==key){
                    cout<<it->second<<"\n";
                    it++;
            }

        }
        else if(tp==0){
            cin>>key>>val;
            //mp[key]=val;
            mp.insert(pair<string,int>(key,val));
        }
        else if(tp==2){
            cin>>key;
            if(mp.find(key)!=mp.end())mp.erase(key);
        }
        else if(tp==3){
            cin>>l>>r;
            it=mp.lower_bound(l);

            while(it!=mp.end()&&it->first<=r){
                cout<<it->first<<" "<<it->second<<"\n";
                it++;
            }
        }
    }
}





Measured memory_bytes: 24688
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, A, B; cin >> N >> A >> B;
    vec X(N); readvec(X);

    int ans = 0;
    REP(i, N - 1) ans += min(B, A * (X[i + 1] - X[i]));
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    string s, t;
    int ans = 0;
    cin >> s >> t;
    for (int i = 0; i < (int)s.size(); ++i) if (s.at(i) != t.at(i)) ++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3876
# AtCoder Beginner Contest 121
# https://atcoder.jp/contests/abc121
import sys
import numpy as np

s2nn = lambda s: map(int, s.split(' '))
ss2nn = lambda ss: map(int, ss)
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    H, W = i2nn()
    h, w = i2nn()
    n = (H - h) * (W - w)
    print(n)

main()


Measured memory_bytes: 14452
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int m=max(a,max(b,c));
  int ans=0;
  vector<int> vec;
  vec.push_back(a);
  vec.push_back(b);
  vec.push_back(c);
  for(int i=0;i<3;i++){
    ans+=(m-vec.at(i))/2;
    vec.at(i)+=(2*((m-vec.at(i))/2));
  }
  int cnt=0;
  for(int i=0;i<3;i++){
    if(m!=vec.at(i))cnt++;
  }
  if(cnt==0)cout<<ans<<endl;
  if(cnt==1)cout<<ans+2<<endl;
  if(cnt==2)cout<<ans+1<<endl;
  return 0;
}

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

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    string s; cin >> s;
    for (auto &&i : s)
        if (i == '?')i = 'D';
    cout << s << endl;
}

Measured memory_bytes: 3744
import itertools
import numpy as np

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

l=[]
for i in range(n):
    a=list(map(int,input().split()))
    l.append(a)

min=10000000000000000000000000
for i in range(1,n+1):
    a=list(itertools.combinations(list(range(n)), i))
    for j in a:
        cost=0
        l2=np.zeros(m)
        for k in j:
            b=np.array(l[k][1:])
            l2+=b
            cost+=l[k][0]
            if np.all(l2>=x) and cost<min:
                min=cost

if min==10000000000000000000000000:
    print(-1)
else:
    print(min)

        

Measured memory_bytes: 27612
S=input()
i=len(S)
isOK=True
while len(S[0:i])>0:
    if len(S[0:i])<5:
        isOK=False
        break

    if len(S[0:i])>=7:
        st=S[i-7:i]
        if st=="dreamer":
            i=i-7
            continue
    
    if len(S[0:i])>=6:
        st=S[i-6:i]
        if st=="eraser":
            i=i-6
            continue
    if len(S[0:i])>=5:
        st=S[i-5:i]
        if st=="erase" or st=="dream":
            i=i-5
            continue
        else:
            isOK=False
            break


if isOK:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9236
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,j,x,y,z,lx,ly,lz;
string st;
int main()
{
	lx=ly=0;
	cin>>n;
	while (n--)
	{
		cin>>z>>x>>y;
		if (abs(lx-x)+abs(ly-y)>(z-lz))
		{
			cout<<"No\n";
			return 0;
		}
		if ((abs(lx-x)+abs(ly-y))%2!=(z-lz)%2)
		{
			cout<<"No\n";
			return 0;
		}
		lx=x;
		ly=y;
		lz=z;
	}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
     
using namespace std;
     
const int MAXN = 3e5 + 10;
     
vector <int> adj[MAXN];
     
int main() {
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int v,u;
        cin >> v >> u ;
		v--;
		u--;
        adj[v].push_back(u);
		adj[u].push_back(v);
    }
	for(int i=0 ; i<n ; i++){
		cout << adj[i].size() << endl;
	}
}

Measured memory_bytes: 7296