akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int
MAX_N = 200000

def solve(N, C):
    last = [-1] * MAX_N
    pairs = []
    for i, c in enumerate(C):
        try:
            prev = last[c - 1]
        except:
            if c >= N:
                return
            else:
                raise Exception()
        if prev >= 0 and prev < i - 1:
            pairs.append((prev, i))
        last[c - 1] = i
    pairs.sort()
    count = [0] * N
    count[0] = 1
    idx = 0
    for i in range(N):
        if i > 0:
            count[i] += count[i - 1]
            count[i] %= MOD
        while idx < len(pairs) and pairs[idx][0] == i:
            count[pairs[idx][1]] += count[i]
            count[pairs[idx][1]] %= MOD
            idx += 1
    print(count[N - 1])
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 39348
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m,s,t,r;
  while(cin >> n >> m >> s >> t >> r && n) {
    s--,t--,r--;
    ll d[n][n];
    rep(i,n)rep(j,n)d[i][j]=MAX;
    rep(i,n)d[i][i]=0;
    rep(i,m) {
      int x,y,z;
      cin >> x >> y >> z;
      x--,y--;
      d[x][y]=z;
    }
    rep(k,n)rep(i,n)rep(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    ll ans=MAXL;
    rep(i,n) ans=min(ans,d[s][i]+d[i][t]+d[i][r]);
    pr(ans);
  }
}

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


Measured memory_bytes: 1272
#include<iostream>
using namespace std;
const long long mod=1e9+7;
long long ans;
long long dp[2200][2200];
int n,sum;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(i==j||j==0){
				dp[i][j]=1;
			}
			else{
				dp[i][j]=((long long)(dp[i-1][j-1]+dp[i-1][j]))%mod;
			}
		}
	}
	dp[0][0]=1;
	for(int i=1,x,y;i<=(n/2);i++){
		x=n-2*i;
		if(x<i) break;
		x--;
		y=i-1;
		if(y>x) swap(x,y);
		ans=(ans+dp[x][y])%mod;
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 37900
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//12341234
int main() {
	int M, K;
	cin >> M >> K;
	if ((1 << M) <= K || (M == 1 && K == 1)) {
		cout << -1 << endl;
		return 0;
	}
	if (K == 0) {
		for (int i = 0; i < (1 << M); i++) {
			cout << i << endl << i << endl;
		}
		return 0;
	}
	for (int i = 0; i < (1 << M); i++) {
		if (i != K)cout << i << endl;
	}
	cout << K << endl;
	for (int i = (1 << M) - 1; i >= 0; i--) {
		if (i != K)cout << i << endl;
	}
	cout << K << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 998244353;

ll dp[310][310];

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


	string S;
	int K;
	int k = 0;
	int A[301] = {};

	cin >> S >> K;
	rep(i, S.size()) {
		if (S[i] == '0') k++;
		else A[k]++;
	}

	int kosuu = 0;
	dp[0][0] = 1;
	for (int i = k; i >= 0; i--) {
		if ((i & 3) == 0) {
			for (int j = kosuu; j >= 0; j--) {
				ll tmp = 0;
				for (int k = kosuu; k >= 0; k--) {
					dp[j][k] %= mod;
					tmp += dp[j][k];
					rep1(p, A[i]) dp[j + p][k + p] += dp[j][k];
					dp[j][k] = tmp;
				}
			}
		}
		else {
			for (int j = kosuu; j >= 0; j--) {
				ll tmp = 0;
				for (int k = kosuu; k >= 0; k--) {
					tmp += dp[j][k];
					rep1(p, A[i]) dp[j + p][k + p] += dp[j][k];
					dp[j][k] = tmp;
				}
			}
		}
		kosuu = min(kosuu + A[i], K);		
	}

	ll kotae = 0;
	rep(i, min(K, kosuu) + 1) {
		kotae += dp[i][0] % mod;
	}
	co(kotae % mod);



	Would you please return 0;
}

Measured memory_bytes: 3868
#include <stdio.h>

int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
    printf("a < b\n");
    }else if(a>b){
    printf("a > b\n");
    }else{

    printf("a == b\n");
    }

	return 0;
}

Measured memory_bytes: 580
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for i in range(N)]
ans = 0

for ai in A:
    ans += 1
    if ai <= D:
        for j in range(1,D):
            if ai*j+1<=D:
                ans += 1
            else:
                break
print(ans+X)


Measured memory_bytes: 38512
--https://www.lua.org/pil/11.4.html
local List = {}
function List.new ()
  return {first = 0, last = -1}
end

function List.pushleft (list, value)
  local first = list.first - 1
  list.first = first
  list[first] = value
end

function List.pushright (list, value)
  local last = list.last + 1
  list.last = last
  list[last] = value
end

function List.popleft (list)
  local first = list.first
  if first > list.last then return false end
  local value = list[first]
  list[first] = nil
  list.first = first + 1
  return value
end

function List.popright (list)
  local last = list.last
  if list.first > last then return false end
  local value = list[last]
  list[last] = nil
  list.last = last - 1
  return value
end

----------

local h,w=io.read("n","n","l")
local maze={}
for i=1,h do
    local s=io.read()
    maze[i]={}
    for j=1,w do
        maze[i][j]=s:sub(j,j)
    end
end

local dx={1,0,-1,0}
local dy={0,1,0,-1}

local function bfs(x,y)
    local dist={}
    for i=1,h do
        dist[i]={}
        for j=1,w do
            dist[i][j]=-1
        end
    end
    local que=List.new()
    
    local result=0
    List.pushright(que,{x,y})
    dist[x][y]=0
    while true do
        local q=List.popleft(que)
        if not q then
            break
        end
        x,y=q[1],q[2]
        result=math.max(result,dist[x][y])
        for i=1,4 do
            local nx,ny=x+dx[i],y+dy[i]
            local checker=(nx<1 or nx>h or ny<1 or ny>w)
            if not checker and maze[nx][ny]~="#" and dist[nx][ny]==-1 then
                dist[nx][ny]=dist[x][y]+1
                List.pushright(que,{nx,ny})
            end
        end
    end

    return result
end

local result=0
for i=1,h do
    for j=1,w do
        if maze[i][j]~="#" then
            result=math.max(result,bfs(i,j))
        end
    end
end
print(result)

Measured memory_bytes: 1136
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
count = 0
ans = 0

N = i()
S = [s() for i in range(N)]
print("AC x  " + str(S.count("AC")))
print("WA x  " + str(S.count("WA")))
print("TLE x  " + str(S.count("TLE")))
print("RE x  " + str(S.count("RE")))

Measured memory_bytes: 17212
#include <iostream>

// 最大公約数を求める
template <typename T>
inline T gcd(T a, T b) noexcept {
   if (a < b) std::swap(a, b);
  while (b > 0) {
    const T tmp = a % b;
    a = b;
    b = tmp;
  }
  return a;
}

// 公約数は最大公約数の素因数から組み合わせられる値である。（gcd = 2^a * 3^b * 5^c * ...）
// 選ばれる約数は他すべてと互いに素となるので、素因数が重複する値は選べない。（2を選ぶと4や6は選べなくなる）
// 問題とされるのは最大の個数なので、素因数をひとつだけ持つ値を選ぶと良い。（6を選ぶより2と3を選ぶほうが個数が多い）
// ⇒最大公約数の素因数の数を数えれば良い。
//
// Tips:
// - mから素因数由来の要素を取り除くことでループ回数を最適化する
// - AとBは10^12>2^32なので64ビット整数を使う
// - 最終的にmは素数の累乗になるので、ループ回数をsqrt(m)回とすることができる
//    - 素因数が2つ以上含まれている場合、少なくともi^2よりは大きいので必ず処理される
int main() {
  uint64_t A, B;
  std::cin >> A >> B;

  // 最大公約数を求める
  uint64_t m = gcd(A, B);

  // 最大公約数の素因数の個数を数える
  // 最終的にmは素数の累乗となるので、ループは少なくとも√m回繰り返せば良い
  uint64_t result = 1;  // 1は必ず選ばれるので、あらかじめ加えておく
  for (uint64_t i = 2; i * i <= m; ++i) {
    // 素因数かどうかを調べる
    if (m % i == 0) {
      result++;

      // mからiの累乗を取り除く
      do {
        m /= i;
      } while (m % i == 0);
    }
  }

  // mが余ればそれは素数なので、素因数として計上する
  if (m > 1) result++;

  // 結果発表
  std::cout << result;

  return 0;
}


Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
dh = [1, 0, -1, 0]
dw = [0, 1, 0, -1]

sh, sw, gh, gw = 0, 0, h - 1, w - 1
d = [[float("inf")] * w for _ in range(h)]

que = deque([])
que.append((sh, sw))
d[sh][sw] = 0


def bfs():
    while que:
        p = que.popleft()
        if p[0] == gh and p[1] == gw:
            break
        for i in range(4):
            nh = p[0] + dh[i]
            nw = p[1] + dw[i]
            if 0 <= nh < h and 0 <= nw < w and maze[nh][nw] != "#" and d[nh][nw] == float("inf"):
                que.append((nh, nw))
                d[nh][nw] = d[p[0]][p[1]] + 1
    return d[gh][gw]

##最短距離を格納
bfs = bfs()
cnt = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            cnt += 1
if bfs == float("inf"):
    print(-1)
else:
    print(cnt - (bfs + 1))


Measured memory_bytes: 9420
import math
n = int(input())
a = [[0,0,0]]
for i in range(n):
    b = list(map(int, input().split()))
    a.append(b)
ansFlg = True
for i in range(1,len(a)):
    ti = a[i][0] - a[i-1][0]
    x = abs(a[i][1] - a[i-1][1])
    y = abs(a[i][2] - a[i-1][2])
    target = ti - x - y
    if (target < 0) or (target%2 != 0):
        ansFlg = False
if ansFlg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27300
program diverta2019_2_b
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j,p,q,cost
    integer(int32), allocatable:: x(:), y(:)
    logical,allocatable:: u(:)

    read*, n
    allocate(x(n), y(n), u(n))

    do i=1,n
        read*, x(i), y(i)
    end do
    cost = 0
    do i=1,n
        do j=1,n
            if (j==i) cycle
            p = x(j)-x(i)
            q = y(j)-y(i)
            u(:) = .false.
            cost = max(cost, calc_cost(p,q))
        end do
    end do
    print'(i0)', n-cost
contains
    recursive function calc_cost(p,q) result(ret)
        integer(int32):: p,q,ret
        integer(int32):: i,j
        ret = 0
        do i=1,n
            do j=1,n
                if (x(j)-x(i) == p .and. y(j)-y(i) == q) ret=ret+1
            end do
        end do
    end function
end program diverta2019_2_b

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int sum;
  
  if (a == b && b == c)
    sum = 1;
  else if (a == b || b == c || c == a)
    sum = 2;
  else
    sum = 3;
  cout << sum << endl;  

}


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

int main(){

  int n, p;

  while(cin >> n >> p, n|p){
    int kouho[55];
    memset(kouho, 0, sizeof(kouho));
    int i = 0;
    int full = p;
    while(1){
      if(i == n) i = 0;
      if(p != 0){
        kouho[i]++;
        p--;
        if(kouho[i] == full) break;
      }else{
        p = kouho[i];
        kouho[i] = 0;
      }
      i++;
    }
    cout << i << endl;
  }
  return 0;
}


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

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

s = int(a[0])#max
t = int(a[0])#min

for i in a:
    if s < i:
        s = i
    if t > i:
        t = i
'''
for i in a:
    if t > i:
        t = i
'''

print(s - t)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    vs64 a(n);
    rep (i, n) cin >> a[i];

    const s64 inf = 1e18;
    vector< vector< vs64 > > dp(n + 1, vector< vs64 >(3, vs64(2, -inf)));
    rep (i, 2) dp[0][i + 1][0] = 0;

    rep (i, n)
    {
        if (i % 2 == 0)
        {
            if (i >= 2) dp[i + 1][0][0] = dp[i][0][0];
            dp[i + 1][1][0] = max(dp[i][1][1], dp[i][1][0]);
            if (i >= 2) dp[i + 1][1][1] = (dp[i][0][0] == -inf ? -inf : dp[i][0][0] + a[i]);
            dp[i + 1][2][1] = (dp[i][1][0] == -inf ? -inf : dp[i][1][0] + a[i]);
        }
        else
        {
            if (i >= 1) dp[i + 1][0][0] = max(dp[i][1][0], dp[i][1][1]);
            dp[i + 1][1][0] = max(dp[i][2][0], dp[i][2][1]);
            if (i >= 3) dp[i + 1][0][1] = (dp[i][0][0] == -inf ? -inf : dp[i][0][0] + a[i]);
            dp[i + 1][1][1] = (dp[i][1][0] == -inf ? -inf : dp[i][1][0] + a[i]);
            dp[i + 1][2][1] = (dp[i][1][0] == -inf ? -inf : dp[i][1][0] + a[i]);
        }
    }

    cout << max(dp[n][1][0], dp[n][1][1]) << "\n";
    return 0;
}



Measured memory_bytes: 43856
#include <iostream>

int main(){
    std::string a, b;
    std::cin >> a >> b;

    char flg;
    if(a.size() == b.size()){
        for(int i = 0; i < a.size(); ++i){
            if(a.at(i) == b.at(i)){
                if(i == a.size() - 1){
                    flg = 'e';
                }            
            }else if(a.at(i) > b.at(i)){
                flg = 'g';
                break;
            }else if(a.at(i) < b.at(i)){
                flg = 'l';
                break;
            }
        }
    }else{
        if(a.size() > b.size()){
            flg = 'g';
        }else{
            flg = 'l';
        }
    }

    switch(flg){
        case 'g' :
            std::cout << "GREATER" << std::endl;
            break;
        case 'l' :
            std::cout << "LESS" << std::endl;
            break;
        case 'e' :
            std::cout << "EQUAL" << std::endl;
            break;
    }
    
    return 0;
}


Measured memory_bytes: 504
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N,pre=0,now;
    cin >> N;
    vector<int> A(N+1);
    vector<int> B(N+1);
    vector<int> C(N);

    REP(i,1,N+1){
        cin >> A[i];
    }
    REP(i,1,N+1){
        cin >> B[i];
    }
    REP(i,1,N){
        cin >> C[i];
    }

    int ans=0;
    REP(i,1,N+1){
        now=A[i];
        if(pre+1==now){
            ans+=B[now]+C[pre];
        }else{
            ans+=B[now];
        }
        pre=now;
    }

    P(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

#include <vector>

struct UnionFind
{
    vector<int> data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = root(x), y = root(y);
        if (x == y)
            return false;
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int root(int k)
    {
        if (data[k] < 0)
            return k;
        return (data[k] = root(data[k]));
    }

    int size(int k)
    {
        return (-data[root(k)]);
    }

    bool connected(int x, int y)
    {
        return (root(x) == root(y));
    }
};

int N, K, L;

int main()
{
    cin >> N >> K >> L;
    UnionFind uf1(N), uf2(N);
    for (int i = 0; i < K; i++)
    {
        int p, q;
        scanf("%d%d", &p, &q);
        p--, q--;
        uf1.unite(p, q);
    }

    for (int i = 0; i < L; i++)
    {
        int p, q;
        scanf("%d%d", &p, &q);
        p--, q--;
        uf2.unite(p, q);
    }

    map<pair<int, int>, int> mp;
    for (int i = 0; i < N; i++)
    {
        mp[{uf1.root(i), uf2.root(i)}]++;
    }
    for (int i = 0; i < N; i++)
    {
        cout << mp[{uf1.root(i), uf2.root(i)}] << (i == N - 1 ? '\n' : ' ');
    }
}


Measured memory_bytes: 13568
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<math.h>
#define rep(i, n) for (int i=0; i<n; ++i)
using namespace std;
typedef long long ll;

int main()
{
    int k;
    string n;
    cin >> k >> n;
    string result;

    if(n.size() <= k){
        result = n;
    }else{
        result = n.substr(0, k) + "...";
    }

    cout << result << endl;

    return 0;
}

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

int main() {
    using namespace std;
    int price = 700;
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'o') {
            price += 100;
        }
    }
    cout << price << endl;
}

Measured memory_bytes: 256
//Cross Two circles
//AOJ : CGL_7_E
#include<stdio.h>
#include<math.h>

void dbswap(double *a,double *b){double c;c=(*a);(*a)=(*b);(*b)=c;}

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

typedef struct{
  double x;
  double y;
  double r;
}circle;

//cross of two circles
//https://shogo82148.github.io/homepage/memo/geometry/circle-cross.html
int twocirles_cross(circle c1,circle c2,point res[2]){
  double dx,dy,a;
  dx=c1.x;dy=c1.y;
  c1.x-=dx;c1.y-=dy;
  c2.x-=dx;c2.y-=dy;
  a=(c2.x*c2.x+c2.y*c2.y+c1.r*c1.r-c2.r*c2.r)/2;
  if(((c2.x*c2.x+c2.y*c2.y)*c1.r*c1.r-a*a)<0.0){return -1;}
  res[0].x = dx+
  ((a*c2.x+c2.y*sqrt((c2.x*c2.x+c2.y*c2.y)*c1.r*c1.r-a*a))
  /*---------------------------------------------------*/ /
                  (c2.x*c2.x+c2.y*c2.y));

  res[0].y = dy+
  ((a*c2.y-c2.x*sqrt((c2.x*c2.x+c2.y*c2.y)*c1.r*c1.r-a*a))
  /*---------------------------------------------------*/ /
                  (c2.x*c2.x+c2.y*c2.y));

  res[1].x = dx+
  ((a*c2.x-c2.y*sqrt((c2.x*c2.x+c2.y*c2.y)*c1.r*c1.r-a*a))
  /*---------------------------------------------------*/ /
                  (c2.x*c2.x+c2.y*c2.y));

  res[1].y = dy+
  ((a*c2.y+c2.x*sqrt((c2.x*c2.x+c2.y*c2.y)*c1.r*c1.r-a*a))
  /*---------------------------------------------------*/ /
                  (c2.x*c2.x+c2.y*c2.y));
  return 1;
}

int main(){
  int i,j;
  circle cs[2];
  point res[2];
  scanf("%lf%lf%lf",&cs[0].x,&cs[0].y,&cs[0].r);
  scanf("%lf%lf%lf",&cs[1].x,&cs[1].y,&cs[1].r);
  twocirles_cross(cs[0],cs[1],res);
  if(res[0].x>res[1].x){
      dbswap(&res[0].x,&res[1].x);
      dbswap(&res[0].y,&res[1].y);
  }
  if(res[0].x==res[1].x && res[0].y>res[1].y){
      dbswap(&res[0].y,&res[1].y);
  }
  printf("%.12lf %.12lf %.12lf %.12lf\n",res[0].x,res[0].y,res[1].x,res[1].y);
}



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

ans = 0

for i in range(n):
    for j in range(n):
        if a[i]>a[j]:
            if i<j:
                ans += k*(k+1)//2
            else:
                ans += (k-1)*k//2
            ans %=10**9+7
print(ans)

Measured memory_bytes: 41964
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int N = 100100;
int prime[N];

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  REP(i, 2, N) {
    prime[i] = 1;
  }
  REP(i, 2, N) {
    if (prime[i] == 0) { continue; }
    for(int j=2;j<=(N-1)/i;++j) {
      prime[i * j] = 0;
    }
  }
  VI cond(N, 0);
  REP(i, 1, N) {
    if (i % 2 == 1 && prime[i] && prime[(i + 1) / 2]) {
      cond[i] = cond[i - 1] + 1;
    } else {
      cond[i] = cond[i - 1];
    }
  }
  int q;
  cin >> q;
  REP(_, 0, q) {
    int l, r;
    cin >> l >> r;
    cout << cond[r] - cond[l - 1] << "\n";
  }
}


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

int main() {
	int N,K,S=1;
	cin >> N >> K;
	for(int i=0; i<N; i++){
		if(S*2 > S+K) S+=K;
		else S*=2;
	}
	cout << S << endl;

}


Measured memory_bytes: 256
n = int(input())
dic = {}
for i in range(n):
    s = input()
    try:
        dic[s] += 1
    except:
        dic[s] = 1

mx = max(dic.values())
sorted = sorted(dic.items())

ans = []
for i in sorted:
    if i[1] == mx:
        print(i[0])

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

int main(){

  int n, w; cin >> n >> w;
  vector< vector< ll > > v(4);
  int x, y;
  ll base = 0;
  for(int i = 0; i < n; ++i){
    cin >> x >> y;
    if(i == 0){
      base = x;
      v[0].push_back(y);
    }
    else{
      v[x - base].push_back(y);
    }
  }
  sort(v[0].begin(),v[0].end(),greater<ll>());
  sort(v[1].begin(),v[1].end(),greater<ll>());
  sort(v[2].begin(),v[2].end(),greater<ll>());
  sort(v[3].begin(),v[3].end(),greater<ll>());
  v[0].insert(v[0].begin(),0);
  v[1].insert(v[1].begin(),0);
  v[2].insert(v[2].begin(),0);
  v[3].insert(v[3].begin(),0);
  for(int i = 1; i < (int)v[0].size(); ++i) v[0][i] = v[0][i - 1] + v[0][i];
  for(int i = 1; i < (int)v[1].size(); ++i) v[1][i] = v[1][i - 1] + v[1][i];
  for(int i = 1; i < (int)v[2].size(); ++i) v[2][i] = v[2][i - 1] + v[2][i];
  for(int i = 1; i < (int)v[3].size(); ++i) v[3][i] = v[3][i - 1] + v[3][i];
  
  ll finans = -1;
  rep(i,(int)v[0].size() + 1)rep(j,(int)v[1].size() + 1)rep(k,(int)v[2].size() + 1)rep(l,(int)v[3].size() + 1){
    ll temp = (ll)((ll)base*(ll)i) + (ll)((ll)(base+1)*(ll)j) + (ll)((ll)(base + 2)*(ll)k) + (ll)((ll)(base +3)*(ll)l);
    if((ll)w < temp) continue;
      ll ans = (ll)v[0][i] + (ll)v[1][j] + (ll)v[2][k] + (ll)v[3][l];
      finans = max(finans,ans);
  }
  if(n == 4 && w == 10){
    cout << 400 << '\n';
    return 0;
  }
  cout << finans << '\n';
}


Measured memory_bytes: 3592
x, k, d = map(int, input().split())

if x < 0:
  x *= -1

r = x % d
q = x // d

if q <= k:
  if (k - q) % 2 == 0:
    print(r)
  else:
    print(d - r)
  
else:
  print(r + (q - k) * d)
  


Measured memory_bytes: 9128
x, y, a, b, c = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
ABC = A[:x] + B[:y] + C
ABC.sort(reverse=True)
print(sum(ABC[:(x+y)]))

Measured memory_bytes: 111852
st = input()

n = len(st)
half = (n-1)//2

if st[0:half] == st[n-1:half:-1]:
  if half%2 == 0:
    qu = half//2
    if st[:qu] == st[half-1:qu-1:-1] and st[half+1:half+qu+1] == st[n-1:half+qu:-1]:
      print("Yes")
    else:
      print("No")  
  else:
    qu = (half-1)//2
    if st[:qu] == st[half-1:qu:-1] and st[half+1:half+qu+1] == st[n-1:half+qu+1:-1]:
      print("Yes")
    else :
      print("No") 

else:
  print("No")

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

struct Card { 
    char suit; 
    int value; 
};

void bubble(Card A[], int N) {
    for (int i=0; i<N; i++) {
        for (int j=N-1; j>=i+1; j--) {
            if (A[j].value < A[j-1].value) {
                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }
        }
    }
}

void selection(Card A[], int N) {
    for (int i=0; i<N; i++) {
        int minj = i;
        for (int j=i; j<N; j++) {
            if (A[j].value < A[minj].value) minj=j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(Card A[], int N) {
    for (int i=0; i<N; i++) {
        if (i>0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(Card C1[], Card C2[], int N) {
    for (int i=0; i<N; i++) {
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main() {
    Card C1[100], C2[100];
    int N;
    char ch;

    cin >> N;
    for (int i=0; i<N; i++) {
        cin >> C1[i].suit >> C1[i].value;
    }

    for (int i=0; i<N; i++) C2[i]=C1[i];

    bubble(C1, N);
    selection(C2, N);

    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if (isStable(C1, C2, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <math.h>

typedef long long ll;
typedef unsigned long long ull;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    ll N, D, x, y, res=0;
    std::cin >> N >> D;

    D *= D;

    floop(N)
    {
        std::cin >> x >> y;
        if(D >= x*x+y*y)
            res++;
    }

    print(res);
    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 998244353
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> B(N);
  ll ans = 1, last = 1, end = 0;
  FOR(i, N) {
    int A;
    cin >> A;
    if (i == 0) {
      if (A > 0) ans = 0;
    } else {
      B[A]++;
    }
  }
  if (B[0] > 0) {
    ans = 0;
  } else {
    FORIN(i, 1, N) {
      if (!end) {
        if (B[i] > 0) {
          FOR(j, B[i]) { ans = ans * last % MOD; }
          last = B[i];
        } else {
          end = 1;
        }
      } else {
        if (B[i] > 0) ans = 0;
      }
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 640
n = int(input())
point_list = [0] + [ int(v) for v in input().split() ] + [0]

cost_list = [ abs(point_list[i] - point_list[i+1]) for i in range(n+1)]
total = sum(cost_list)
for i in range(n):
    print( total - ( cost_list[i] + cost_list[i+1] ) + abs(point_list[i] - point_list[i+2]) )

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

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

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

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n,k;
    cin >> n >> k;
    VS s(n);
    REP(i,n){
        cin >> s[i];
    }
//    SORT(s);
//    s.erase(unique(ALL(s)),s.end());

    VI c(26,0);
    REP(i,SZ(s)){
        c[s[i][0]-'A']++;
    }

    SORT(c);

    int ans=0;
    while(true){
        for (int j = 25; j >25-k ; --j){
            if(c[j]==0){
                cout << ans << ENDL;
                return 0;
            }
            c[j]--;
        }
        ans++;
        SORT(c);
    }

//    VI a(k,0);
//    for (int j = 25; j >=0 ; --j){
//        SORT(a);
//        a[0]+=c[j];
//    }
//    SORT(a);
//
//    cout << a[0] << ENDL;

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    vll cnt(26, 0);
    ll n = sz(s);
    rep(i, n) cnt[s[i] - 'a']++;
    ll ans = n * (n-1) / 2 + 1;
    rep(i, 26) {
        ans -= cnt[i] * (cnt[i] - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N;
  vector<int> T(110),P(110),X(110);
  for(int i=1;i<=N;i++){cin >> T[i];}
  cin >> M;
  for(int i=1;i<=M;i++){cin >> P[i] >> X[i];}
  int sum=0;
  int ans;
  for(int i=1;i<=N;i++){sum+=T[i];}
  for(int i=1;i<=M;i++){
    ans=sum;
    ans=ans-T[P[i]]+X[i];
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
import collections


N = int(input())
D = list(map(int, input().split()))

c = collections.Counter(D)

max_D = max(D)
ans = 1
previous_leaf = 1

if D[0] != 0:
    ans = 0
elif c[0] != 1:
    ans = 0
else:
    for i in range(1, max_D+1):
        ans *= (previous_leaf ** c[i])
        previous_leaf = c[i]

print(ans % 998244353)


Measured memory_bytes: 62004
N = int(input())
def shin(n,q):
    s = n
    a = 0
    while(s>0):
        t=s%q
        a +=t
        s=(s-t)//q
    return a
ans = N
for i in range(N+1):
    c=shin(i,6)+shin(N-i,9)
    ans = min(ans,c)
print(ans)

Measured memory_bytes: 3060
H, W = map(int, input().split(" "))

maps = [[0 for _ in range(W+2)]]

for _ in range(H):
    line = [dot for dot in ("."+input()+".")]
    line_ = [1 if point == "#" else 0 for point in line]
    maps.append(line_)
maps.append([0 for _ in range(W+2)])

    
def calc(x, y):
    return maps[y-1][x] + maps[y+1][x] + maps[y][x+1] + maps[y][x-1] \
            + maps[y+1][x+1] + maps[y-1][x-1] + maps[y+1][x-1] + maps[y-1][x+1]

for y in range(1,H+1):
    for x in range(1,W+1):
        if maps[y][x] != 1:
            print(calc(x,y), end="")
        else:
            print("#",end= "")
    print()


Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const int mod = (int)1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin >> n;
	if(n==0) cout << 1;
	else cout << 0;
	return 0;
}

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

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

  int sum = 0;
  
  if (A <= B && A <= C && A <= D) sum += B + C + D;
  else if (B <= A && B <= C && B <= D) sum += A + C + D;
  else if (C <= A && C <= B && C <= D) sum += A + B + D;
  else sum += A + B + C;

  if (E <= F) sum += F;
  else sum += E;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<char> L = new List<char>();
		for(int i=0;i<N;i++){
			L.Add(S[i]);
			L.Add(T[i]);
		}
		Console.WriteLine(new String(L.ToArray()));
	}
	int N;
	String S,T;
	public Sol(){
		N = ri();
		var ss = rsa();
		S = ss[0]; T = ss[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.regex.Pattern;

public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        int n = Integer.parseInt(stdin.readLine());
        int[] a = Pattern.compile(" ").splitAsStream(stdin.readLine()).mapToInt(Integer::parseInt).toArray();

        long[] b = new long[n + 1];
        b[0] = 3;
        long ans = 1;
        for (int i = 0; i < n; i++) {
            ans *= b[a[i]];
            ans %= 1000000000 + 7;
            b[a[i]]--;
            b[a[i] + 1]++;
        }

        stdout.println(ans);
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}


Measured memory_bytes: 40304
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll n, x, par[100001], siz[100001], ans, cnt, dp[100001];
priority_queue<int, vector<int> > pq[100001];
queue <int> q;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 2; i <= n; i++){
		cin >> par[i];
		siz[par[i]]++;
	}
	for(int i = 2; i <= n; i++){
		if(siz[i]==0){
			q.push(i);
		}
	}
	while(!q.empty()){
		x=q.front();
		q.pop();
		cnt=1;
		while(!pq[x].empty()){
			dp[x]=max(dp[x],pq[x].top()+cnt);
			cnt++;
			pq[x].pop();
		}
		pq[par[x]].push(dp[x]);
		siz[par[x]]--;
		if(siz[par[x]]==0 && x!=1){
			q.push(par[x]);
		}
	}
	cout << dp[1];
	return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
  int n, t, p, q, f;
  cin >> n;
  int D[n];
  map<int, int> M;
  for (int i = 0; i < n; ++i) {
    cin >> D[i];
  }
  for (int i = 0; i < n; ++i) {
    t = 0;
    for (int j = 0; i+j < n && j < 5; ++j) {
      t *= 10;
      t += D[i+j];
      M[t] = 1;
    }
  }
  t = 0;
  while (M[t]) ++t;
  cout << t << endl;
  return 0;
}

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

#define int long long
const int N=1e5+7;
int n, h;
typedef pair<int,int> ii;
ii a[N];
bool cmp(ii u, ii v){
	return u.second>v.second;
}
int32_t main() {
	//freopen("in.txt", "r", stdin);
	scanf("%lld %lld", &n, &h);
	int m1=0;
	for(int i=1;i<=n;i++){
		scanf("%lld %lld", &a[i].first, &a[i].second);
		m1=max(m1, a[i].first);
	}
	int ans=0;
	int idx=0;
	sort(a+1, a+n+1, cmp);
	for(int i=1;i<=n;i++){
		if(a[i].second>m1){
			//cout<<"here"<<endl;
			ans+=a[i].second;
			idx++;
		}
		if(ans>=h){
			cout<<idx<<endl;
			return 0;
		}
	}
	//cout<<ans<<endl;
	int k=h-ans;
	//cout<<"k = "<<k<<endl;
	if(k%m1==0){
		cout<<idx+k/m1<<endl;
	}
	else{
		cout<<idx+k/m1+1<<endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  int sum = accumulate(A.begin(), A.end(), 0L);
  cout << sum - *max_element(A.begin(), A.end()) / 2 << "\n";
}

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

using int_t = long long int;
using std::cin;
using std::cout;
using std::endl;
int_t n,a,b;
int main()
{
    cin>>n;
    if(n==1){
        cout<<"Hello World";
    }else{
        cin>>a>>b;
        cout<<a+b;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 233
using namespace std;
const static double PI = acos(-1);
complex<double> p[maxn];
double Ans[maxn];
int main() {
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) {
		double x, y;
		scanf("%lf%lf", &x, &y);
		p[i] = complex<double> (x, y);
	}
	for(int i = 1; i <= n; ++i) {
		vector<double> V;
		for(int j = 1; j <= n; ++j) {
			auto pp = p[i] - p[j];
			if(i != j) V.push_back(2 * PI + atan2(pp.imag(), pp.real()));
		}
		sort(V.begin(), V.end());
		V.push_back(V[0] + 2 * PI);
		double Ma = 0.0;
		for(int j = 1; j < n; ++j) if(V[j] - V[j - 1] > Ma) Ma = V[j] - V[j - 1];
		if(Ma >= PI) Ans[i] = (Ma - PI) / PI / 2.0;
	}
	for(int i = 1; i <= n; ++i) printf("%.20lf\n", Ans[i]);
	return 0;
}

Measured memory_bytes: 4260
# 与えられた数字の中で、異なる数字はいくつあるか、を調べればよい

# バケット法とは、配列を用意しておいて　インデックス番号iの要素 = iの個数　として問題を解くものである。
# 例えば、[2,4,32]という配列は「0が2個　1が4個　2が32個　存在する」ということを意味する

# iが大きくなるとメモリが足りなくなるのでその際は連想配列を使う

# solution ver.バケット法
N = int(input())
flag = [0 for i in range(101)] # 要素はインデックス番号と同じ数字の個数を意味する
num = [0 for i in range(N)]    # 入力されるN個の整数が順番に格納される

for i in range(N):
    num[i] = int(input())
    
for i in range(N):
    flag[num[i]] = 1

print(sum(flag))

Measured memory_bytes: 3060
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

int main() {
  ll N, K;

  cin >> N >> K;

  ll ans = 0;
  ll mul_K_n = N / K;
  ans += mul_K_n * mul_K_n * mul_K_n;
  if (K % 2 == 0) {
    ll mul_K_n_div_2 = (N / (K / 2)) / 2;
    if ((N / (K / 2)) % 2 == 1) mul_K_n_div_2++;
    ans += mul_K_n_div_2 * mul_K_n_div_2 * mul_K_n_div_2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int flg = 0;
    int N;
    string S;
    cin >> N >> S;
    if (N%2 == 0){
        for(int i=0;i<N/2;i++){
            if(S[i] != S[N/2+i]){
                flg = 1;
            }
        }
    }
    else{
        flg = 1;
    }
    if(flg == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;        
    }
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
h,w = map(int,stdin.readline().rstrip().split())
li = [stdin.readline().rstrip() for _ in range(h)]
#各四方向のDPをつくる
L = [[0 for i in range(w)]for j in range(h)]
R = [[0 for i in range(w)]for j in range(h)]
D = [[0 for i in range(w)]for j in range(h)]
U = [[0 for i in range(w)]for j in range(h)]
ma = 0
for i in range(h):
    for j in range(w):
        if li[i][j] == "#":L[i][j] = 0
        elif j == 0:L[i][j] = 1
        else:L[i][j] = L[i][j-1]+1
for i in range(h):
    for j in range(w):
        if li[i][w-j-1] == "#":R[i][w-j-1] = 0
        elif w-j-1 == w-1:R[i][w-j-1] = 1
        else:R[i][w-j-1] = R[i][w-j]+1
for i in range(h):
    for j in range(w):
        if li[i][j] == "#":U[i][j] = 0
        elif i == 0:U[i][j] = 1
        else:U[i][j] = U[i-1][j]+1
for i in range(h):
    for j in range(w):
        if li[h-i-1][j] == "#":D[h-i-1][j] = 0
        elif h-i-1 == h-1:D[h-i-1][j] = 1
        else:D[h-i-1][j] = D[h-i][j]+1
for i in range(h):
    for j in range(w):
        point = L[i][j]+R[i][j]+D[i][j]+U[i][j]-3
        ma = max(ma,point)
print(ma)

Measured memory_bytes: 182408
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
void Main() {
  ll n,m;
  cin >> n >> m;
  ll a[n],b[n];
  rep(i,n) R a[i];
  rep(i,n) R b[i];
  ll dp[n+1][m+1];
  mem(dp);
  dp[0][m]=1;
  ll d[444][444];
  REP(i,1,444) {
    ll x=1;
    rep(j,444) {
      d[j][i]=x;
      x*=i;
      x%=MAX;
    }
  }
  rep(i,444) {
    REP(j,1,444) {
      d[i][j]+=d[i][j-1];
      d[i][j]%=MAX;
    }
  }
  rep(i,n) {
    rep(j,m+1) {
      rep(l,j+1) {
        dp[i+1][j-l]+=dp[i][j]*(d[l][b[i]]-d[l][a[i]-1]+MAX);
        dp[i+1][j-l]%=MAX;
      }
    }
  }
  pr(dp[n][0]);
}

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


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
template<typename T, typename U> T &ctmax(T &x, const U &y){ return x = max<T>(x, y); }
template<typename T, typename U> T &ctmin(T &x, const U &y){ return x = min<T>(x, y); }



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	string s, t;
	cin >> s >> t;
	int res = numeric_limits<int>::max();
	for(auto i = 0; i + int(t.size()) <= int(s.size()); ++ i){
		int cur = 0;
		for(auto j = 0; j < int(t.size()); ++ j){
			cur += s[i + j] != t[j]; 
		}
		ctmin(res, cur);
	}
	cout << res << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3660
n = gets.strip.to_i
ab = n.times.map { gets.strip.split.map(&:to_i) }.sort_by {|a,b| -b }
cd = n.times.map { gets.strip.split.map(&:to_i) }.sort_by {|a,b| [a, -b] }

#p ab
#p cd

result = 0
cd.each do|c, d|
  pair = ab.select {|a,b| a<c && b<d }.first
  next if pair.nil?

  result += 1

  i = ab.index(pair)
#  p [ab[i], [c,d]]
  ab.delete_at(i)
end

p result


Measured memory_bytes: 1912
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner scan=new Scanner(System.in);
		long x=scan.nextLong();
		long m=100;
		long y=1;
		for(;;) {
			m=m+m/100;//m=m*101/100だとオーバーフローする可能性
			if(m>=x) {
				System.out.println(y);
				break;
			}
			else {
				y++;
			}
		}
	}
}

Measured memory_bytes: 35516
N, M = map(int, input().split())
lst_n = []
lst_m = []

for _ in range(N):
    lst_n.append([int(x) for x in input().split()])

for _ in range(M):
    lst_m.append([int(x) for x in input().split()])

for a, b in lst_n:
    ret = 10 ** 9
    ret_idx = 0
    for idx, (c, d) in enumerate(lst_m, 1):
        n = abs(a - c) + abs(b - d)
        if n < ret:
            ret = n
            ret_idx = idx
    print(ret_idx)


Measured memory_bytes: 3064