akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;

	LL _ = N;
	while (N % 2 == 0) N /= 2;
	if (N == 1)
	{
		out << "No" << std::endl;
		return 0;
	}
	N = _;

	std::vector<std::pair<LL, LL>>ans;
	ans.push_back({ 1,2 });
	ans.push_back({ 2,3 });
	ans.push_back({ 3,1 + N });
	ans.push_back({ 1 + N,2 + N });
	ans.push_back({ 2 + N,3 + N });
	for (LL i = 4; i < N; i += 2)
	{
		ans.push_back({ i,i + 1 });
		ans.push_back({ i + 1,1 + N });
		ans.push_back({ 1 + N,i + N });
		ans.push_back({ i + N,i + 1 + N });
	}
	if (N % 2 == 0)
	{
		ans.push_back({ N,N - 1 });
		ans.push_back({ ((N - 1) ^ 1 ^ N) + N,2 * N });
	}

	out << "Yes" << std::endl;
	rep(i, ans.size()) out << ans[i].first << " " << ans[i].second << std::endl;
}


Measured memory_bytes: 6508
import re

# Wを受け取る
W = input()
wlen = len(W)

# Tを受け取る
T = ""
while True:
    Ti = input()
    if Ti == "END_OF_TEXT":
        break
    T += Ti + " "

# 処理実行
T_list = list(T.split(" "))
result = 0
for t in T_list:
    cnt = len(re.findall(W, t, flags=re.IGNORECASE))
    strlen = len(t)
    if cnt == 1 and strlen == wlen:
        result += 1
    else:
        pass

print(result)



Measured memory_bytes: 6496
H,N=map(int,input().split())
ABC=[]
for _ in range(N):
  a,b=map(int,input().split())
  ABC.append((a,b,a/b))
A=[ABC[i][0] for i in range(N)]
B=[ABC[i][1] for i in range(N)]
dp=[[float('inf')]*(H+1) for i in range(N+1)]
for i in range(N+1):
  dp[i][0]=0
  
for i in range(N):
  for j in range(1,H+1):
    if j-A[i]>=0:
      dp[i+1][j]=min(dp[i][j],dp[i+1][j-A[i]]+B[i])
    else:
      dp[i+1][j]=min(dp[i][j],dp[i+1][0]+B[i])
print(dp[N][H])

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

int main(){
    int n;
    
    cin >> n;
    
    string l1[n],l2[n],l3[n];
    
    for(int i = 0; i < n; i++){
        cin >> l1[i];
        l3[i] = l2[i] = l1[i];
    }

    for(int i = 0; i < n; i++){
        for(int j = n-1; j >= i+1; j--){
            if(l1[j][1] < l1[j-1][1]){
                string tmp = l1[j];
                l1[j] = l1[j-1];
                l1[j-1] = tmp;
            }
        }
    }
    for(int i = 0; i < n-1; i++){
        cout << l1[i] << " ";
    }
    cout << l1[n-1] << endl;
    
    cout << "Stable" << endl;
    

    for(int i = 0; i < n; i++){
        int minj = i;
        for(int j = i; j < n; j++){
            if(l2[j][1] < l2[minj][1]){
                minj = j;
            }
        }
        string tmp = l2[i];
        l2[i] = l2[minj];
        l2[minj] = tmp;
    }
    for(int i = 0; i < n-1; i++){
        cout << l2[i] << " ";
    }
    cout << l2[n-1] << endl;

    bool judge = true;
    for(int i = 0; i < n; i++){
        if(l1[i] != l2[i]){
            judge = false;
        }
    }
    if(judge){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
#ifdef LOCAL
#include "1.h"
#else
#define dbg(...) 
#endif
ll n,m,i,j,k,in,cnt = 0,l,r,u,v,x,y,tc = 1,mod = 1000000007  ;
const ll  mx = 100001 ;
vector<ll> a(mx);
vector<int> dp(mx,-1);
ll foo(int src){
    if(dp[src]!=-1)
        return dp[src];
    if(src==n-1){
        return 0;
    }
    else{
        ll ans  = abs(a[src]- a[src+1]) + foo(src+1);
        if(src+2 < n)
            ans = min(ans,abs(a[src]- a[src+2]) + foo(src+2));
        return dp[src]=ans;
    }
}
void solve(){
    cin>>n;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    cout<<foo(0)<<endl;
}
signed main(){                                          //F
    clock_t time = clock();                             //A
    ios_base::sync_with_stdio(0);                       //S
    cin.tie(0);                                         //T
    cout.tie(0);                                        //I
    cerr.tie(0);                                        //O
    if(0) cin>>tc;
    while(tc--)
        solve();
    dbg("Author - Amit dwivedi");
    return 0&fprintf(stderr, "Time ::%.3lf ms.\n",((clock() - time)*1000.0)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 6144
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<deque>
using namespace std;

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

int N, M;
map<pair<int, int>, int> mp;
vector<int> a[100000];
int mark[100000] = {0};
const int INF = 100000000;
int dist[100000];


int main() {
  cin >> N >> M;
  rep(i, N) {
    dist[i] = INF;
  }

  rep(i, M) {
    int x, y;
    cin >> x >> y;
    a[x-1].push_back(y-1);
    a[y-1].push_back(x-1);
    // mp[make_pair(x-1, y-1)] = 1;
    // mp[make_pair(y-1, x-1)] = 1;
  }

  dist[0] = 0;
  deque<int> que;
  que.push_back(0);

  mark[0] = 0;

  while(que.size()) {
    int p = que.front();
    que.pop_front();
    // for(int i = 0; i < N; i++) {
      for(auto v : a[p]) {
          if(dist[v] > dist[p] + 1) {
            // cout << dist[1] << endl;
            dist[v] = dist[p] + 1;
            mark[v] = p + 1;
            que.push_back(v);
          }
      }
      // }
    }

  // cout << dist[1] << endl;
  cout << "Yes" << endl;

  for(int i = 1; i < N; i++) {
    cout << mark[i] << endl;
  }



  return 0;
}

Measured memory_bytes: 10416
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main(){
    int n,q;
    cin >> n >> q;
    vector<int> value(n+1);
    vector<vector<int>> G(n+1);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,q){
        int a,b;
        cin >> a >> b;
        value[a] += b;
    }

    queue<int> q1;
    q1.push(1);
    vector<bool> visited(n+1,false);

    while(!q1.empty()){
        int nq = q1.front();
        q1.pop();
        visited[nq] = true;


        rep(i,G[nq].size()){
            if(visited[G[nq][i]] == true) continue;
            value[G[nq][i]] += value[nq];
            q1.push(G[nq][i]);
        }
    }

    for(int i = 1;i <= n;i++) cout << value[i] << " ";
    cout << endl;

}

Measured memory_bytes: 16576
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define yes(a) printf(a ? "yes\n" : "no\n")
#define Yes(a) printf(a ? "Yes\n" : "No\n")
#define YES(a) printf(a ? "YES\n" : "NO\n") 
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  ll n;
  cin >> n;
  vector<ll> a(n+1);
  vector<ll> b(n);
  for(ll i = 0; i < n+1; i++) cin >> a[i];
  for(ll i = 0; i < n; i++) cin >> b[i];

  ll ans = 0;
  for(ll i = 0; i < n; i++){
    if(a[i] - b[i] >= 0){
      ans += b[i];
      b[i] = 0;
    }else{
      //cout << i << endl;
      ans += a[i];
      b[i] -= a[i];
      if(a[i+1] - b[i] >= 0){
        ans += b[i];
        a[i+1] -= b[i];
      }else{
        ans += a[i+1];
        a[i+1] = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, C = MAP()
xv = [LIST() for _ in range(N)]

#左回り用
energy_left_1 = [0]
energy_left_2 = [0] #折り返し用
tmp_v = 0
for x, v in xv:
	tmp_v += v
	energy_left_1.append(tmp_v-x)
	energy_left_2.append(tmp_v-2*x)

#右周り用
energy_right_1 = [0]
energy_right_2 = [0] #折り返し用
tmp_v = 0 
for x, v in xv[::-1]:
	y = C-x
	tmp_v += v
	energy_right_1.append(tmp_v-y)
	energy_right_2.append(tmp_v-2*y)

energy_left_1_acc = list(accumulate(energy_left_1, max))
energy_left_2_acc = list(accumulate(energy_left_2, max))
energy_right_1_acc = list(accumulate(energy_right_1, max))
energy_right_2_acc = list(accumulate(energy_right_2, max))

ans = -INF
for i in range(N+1):
	ans = max(ans, energy_left_1_acc[i]+energy_right_2_acc[N-i])
	ans = max(ans, energy_left_2_acc[i]+energy_right_1_acc[N-i])
print(ans)

Measured memory_bytes: 48300
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define NUM_ALPHABET (26)
static int aiCountS[NUM_ALPHABET] = {0};
static int aiCountT[NUM_ALPHABET] = {0};
static char strS[2*100000+1];
static char strT[2*100000+1];

int main()
{
	int i, j;

	scanf("%s", strS);
	scanf("%s", strT);

	int L = strlen(strS);
	if (strlen(strT) != L) {
		printf("No");
		return 0;
	}
	if (sizeof(strS) <= L) {
		printf("No");
		return 0;
	}

	//アルファベット文字をカウント
	for (i = 0; i < L; i++) {
		int iCode;

		iCode = strS[i] - 'a';
		if ((iCode < 0) || (NUM_ALPHABET <= iCode)) {
			printf("No");
			return 0;
		}
		aiCountS[iCode]++;

		iCode = strT[i] - 'a';
		if ((iCode < 0) || (NUM_ALPHABET <= iCode)) {
			printf("No");
			return 0;
		}
		aiCountT[iCode]++;
	}

	//照合。一致したら消していく(0にする)。一致するものがなければNo。
	for (i = 0; i < NUM_ALPHABET; i++) {
		int iNum;
		bool bIsFound = false;

		iNum = aiCountS[i];
		if (0 == iNum) {
			continue;
		}

		for (j = 0; j < NUM_ALPHABET; j++) {
			if (iNum == aiCountT[j]) {
				aiCountT[j] = 0;
				bIsFound = true;
				break;
			}
		}

		if (!bIsFound) {
			printf("No");
			return 0;
		}
	}

	printf("Yes");
	return 0;
}


Measured memory_bytes: 512
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (a,b,k) = scan "%d %d %d" Tuple3.make

let () =
  Printf.printf "%d %d" (max 0 (a-k)) @@ max 0 (if a-k < 0 then b + a -k else b)


Measured memory_bytes: 1408
from collections import Counter

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

Counted_A = Counter(a)

comp_dict = {}
not_dict = {}
for i in Counted_A.items():
    comp_dict[i[0]] = i[1]*(i[1]-1)/2
    not_dict[i[0]] = (i[1]-1)*(i[1]-2)/2

ans = 0
for i in comp_dict.items():
    ans += i[-1]


for i in a:
    temp = ans - comp_dict[i] + not_dict[i]
    print(int(temp))


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)


int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
 
  ll n,k;
  cin >> n >> k;
  vll h(n);
  rep(i,0,n) cin >> h[i];
  
  sort(h.begin(),h.end());
  
  ll res=0;
  rep(i,0,n-k) res+=h[i];
  
  cout << res << endl;
}

Measured memory_bytes: 1792
n=int(input())
s=input()
R=s.count("R")
G=s.count("G")
B=s.count("B")
cnt=0
for i in range(n-1):
  for j in range(i+1,n):
    if j-i <= n-1-j:
      if s[i]!=s[j] and s[j]!=s[2*j-i] and s[i]!=s[2*j-i]:
        cnt+=1
print(R*G*B-cnt)

Measured memory_bytes: 9228
local n,q=io.read("*n","*n","*l")
local s=io.read()
local t={0}
for i=1,n-1 do
    t[i+1]=t[i]+(s:sub(i,i+1)=="AC" and 1 or 0)
end
for i=1,q do
    local l,r=io.read("*n","*n")
    print(t[r]-t[l])
end

Measured memory_bytes: 2140
#include <stdio.h>
int main(void)
{
    long deposit;
    long X;
    int i;
    scanf("%ld", &X);
    deposit = 100;
    for (i = 0; deposit < X; i++)
    {
        deposit *= 1.01;
    }
    printf("%d\n", i);
    return 0;
}

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

#define rep1(i, a, n) for (int i = a; i < n; i++)
#define rep2(i, a, n) for (int i = n; i >= a; i--)
#define asc(v) sort(v.begin(), v.end())
#define desc(v) sort(v.begin(), v.end(), greater<int>())

using namespace std;

int main() {
  int N;
  cin >> N;
  int ans = 0;
  rep1(i, 0, N) {
    int a, cnt = 0;
    cin >> a;
    while (a % 2 == 0) {
      if (a % 2 == 0) {
        a = a / 2;
        cnt++;
      }
    }
    ans += cnt;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    private static class Field {
        static final int MAX_COORDINATE = 10000;
        BitSet[] horizonFieldLines;
        BitSet[] verticalFieldLines;

        private Field() {
            horizonFieldLines  = new BitSet[MAX_COORDINATE + 2];
            for (int i=0; i<horizonFieldLines.length; i++) {
                horizonFieldLines[i] = new BitSet();
            }
        }

        private void addSheet(int x1, int y1, int x2, int y2) {
            for (int i=y1+1; i<=y2; i++) {
                horizonFieldLines[i].set(x1+1, x2+1);
            }
        }

        private void makeInvertedIndex() {
            verticalFieldLines = new BitSet[MAX_COORDINATE + 2];
            for (int i=0; i<verticalFieldLines.length; i++) {
                verticalFieldLines[i] = new BitSet();
            }

            for (int y=0; y<MAX_COORDINATE; y++) {
                for (int x=0; x<horizonFieldLines[y].length(); x++) {
                    if (horizonFieldLines[y].get(x)) {
                        verticalFieldLines[x].set(y);
                    }
                }
            }
        }

        private int measureDimention() {
            int dimention = 0;

            for (BitSet hfLine: horizonFieldLines) {
                dimention += hfLine.cardinality();
            }

            return dimention;
        }

        private int mesureSurroundLength() {
            int surroundLength = 0;

            for (BitSet hfLine: horizonFieldLines) {
                if (!hfLine.isEmpty()) {
                    BitSet shiftBS = hfLine.get(1, hfLine.length());
                    shiftBS.xor(hfLine);
                    surroundLength += shiftBS.cardinality();
                }
            }

            for (BitSet vfLine:verticalFieldLines) {
                if (!vfLine.isEmpty()) {
                    BitSet shiftBS = vfLine.get(1, vfLine.length());
                    shiftBS.xor(vfLine);
                    surroundLength += shiftBS.cardinality();
                }
            }

            return surroundLength;
        }
     }

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

        for (int dataIt=0; dataIt<10; dataIt++) {
            int n = Integer.parseInt(sc.next());
            int r = Integer.parseInt(sc.next());
            if (r <= 0) {
                break;
            }

            Field field = new Field();

            for (int sheetIt=0; sheetIt<n; sheetIt++) {
                int x1 = Integer.parseInt(sc.next());
                int y1 = Integer.parseInt(sc.next());
                int x2 = Integer.parseInt(sc.next());
                int y2 = Integer.parseInt(sc.next());
                field.addSheet(x1, y1, x2, y2);
            }

            System.out.println(field.measureDimention());
            if (r == 2) {
                field.makeInvertedIndex();
                System.out.println(field.mesureSurroundLength());
            }
        }
    }
}

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

void print(int n, int A[]){
    
    for(int i = 0; i < n; i++){
        cout << A[i] << (i != n-1 ? " " : "\n");
    }
    
}

void select_sort(int n, int A[]){
    
    
    int i = 0, j, count = 0, position = 0;
    
    while(i < n - 1){
        
        // 最小値を求める
        int min = 100;
        for(j = i; j < n; j++){
            if(min > A[j]){
                min = A[j];
                position = j;
            }
        }
        
        if(A[i] > A[position]){
            swap(A[i], A[position]);
            count++;
        }
        
        i++;
        
    }
        
    print(n, A);
    cout << count << endl;
    
}



int main(void){
    
    int n, A[100] = {};
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    
    select_sort(n, A);
    
}



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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int A[330];
signed main() {
    cin >> N;
    rep(i, N) { cin >> A[i]; }
    int X = A[0] + A[1], C = 0;
    for (int i = 2; i < N; i++) { C ^= A[i]; }
    (X -= C) >>= 1;
    int S = A[0] + A[1] - (X << 1);
    for (int i = 63; i >= 0; i--) {
        if (X & bit(i) || ~S & bit(i)) { continue; }
        if ((X | bit(i)) <= A[0]) { X |= bit(i); }
    }
    if (0 < X && X <= A[0] && (X ^ (A[0] + A[1] - X)) == C) { cout << A[0] - X << endl; }
    else { cout << -1 << endl; }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

    ll k, ans = 0;
    cin >> k;
    for (ll i = 1; i <= k; i++)
    {
        for (ll j = 1; j <= k; j++)
        {
            for (ll l = 1; l <= k; l++)
                ans += gcd(i, gcd(j, l));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include<stdio.h>
#define MAXSIZE 100
#define PI 3.141592653589
using namespace std;
int main(){
  int n,m;
  std::cin >> n>>m;
  int a[MAXSIZE][MAXSIZE]={0};
  int b[MAXSIZE]={0};

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      std::cin >>a[i][j];
    }
  }
  for(int i=0;i<m;i++){
    std::cin >> b[i];
  }

  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<m;j++){
      sum+=b[j]*a[i][j];
    }
    std::cout << sum << '\n';
  }
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long n,cnt[60];
    for(long long i = 0 ; i < 60 ; i += 1){
        cnt[i] = 0;
    }
    cin >> n;
    long long val1=0,val2=0,sum;
    for(long long i = 0 ; i < n ; i += 1){
        long long a;
        cin >> a;
        if(i == 0){
        	val1 = a;
        	continue;
        }else if(i == 1){
        	val2 = a;
        	continue;
        }
        long long tag=0;
        while(a){
            if(a % 2 == 1){
                cnt[tag] += 1;
            }
            a /= 2;
            tag += 1;
        }
    }
    sum = val1+val2;
    long long val3 = 0;
    for(long long i = 0 ; i < 60 ; i += 1){
    	if(cnt[i] % 2 == 1){
    		val3 += (1ll<<i);
    	}
    }
    if(val3 > sum){
    	cout << -1 << endl;
    	return 0;
    }
    if((sum-val3)%2 == 1){
    	cout << -1 << endl;
    	return 0;
    }
    long long val4 = (sum-val3)/2;
    if(val4 & val3){
    	cout << -1 << endl;
    	return 0;
    }
    long long ans = val4;
    for(long long i = 59 ; i >= 0 ; i -= 1){
    	if(ans + (1ll << i) < val1 && (val3 & (1ll<<i))){
    		ans += (1ll<<i);
    	}
    }
    if(ans == 0 || ans > val1){
    	cout << -1 << endl;
    	return 0;
    }
    cout << val1-ans << endl;
}


Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int x1 = Integer.parseInt(str[0]);
    int y1 = Integer.parseInt(str[1]);
    int x2 = Integer.parseInt(str[2]);
    int y2 = Integer.parseInt(str[3]);
    
    int x = x2-x1;
    int y = y2-y1;
    
    System.out.println(String.format("%d %d %d %d",x2-y, y2+x, x1-y, y1+x));
  }
}

Measured memory_bytes: 34172
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long Nim(long A,long K){
	while(1){
		if(A < K){
			return 0;
		}
		if(A % K == 0){
			return A / K;
		}
		long t = A / K;
		long m = t*K;
		long d = max((A-m) - (A-m) % (t+1),t+1);
		A -= d;
	}
}
void Calc(){
	int N = rei();
	long ans = 0;
	for(int i=0;i<N;i++){
		long A = rel();
		long K = rel();
		ans ^= Nim(A,K);
	}
	if(ans == 0){
		cout << "Aoki" << endl;
	}
	else{
		cout << "Takahashi" << endl;
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def get_ans(n):
    if n <= 1:
        return 0
    return get_ans(n - 1) + n - 1


def main():
    n, m = map(int, input().split())
    print(get_ans(n) + get_ans(m))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	int al=99999,vl=0,n;
	cin>>n;
	int a,v;
	for(int i=0;i<n;i++){
		cin>>a>>v;
		if(v>vl){
			vl=v;
			al=a;
		}else if(v==vl){
			if(al>a)al=a;
		}
	}
	cout<<al<<" "<<vl<<endl;
}
		
			
	

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

long long n, t, r;
map<long long, long long> m;
int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> t;
		if(m.count(t) == 0) m[t] = 1;
		else m[t]++;
	}
	for(map<long long, long long>::iterator it = m.begin(); it != m.end(); it++){
		if(it->second > it->first) r += it->second-it->first;
		else if(it->second < it->first) r+= it->second;
	}
	cout << r;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, q;
	cin >> n >> q;
	vector<vector<int>> g(n);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> rec(n);
	rep(i, q) {
		int p, x;
		cin >> p >> x;
		p--;
		rec[p] += x;
	}
	vector<int> ans(n);
	function<void(int, int, int)> Dfs = [&](int v, int p, int sum) {
		ans[v] = rec[v] + sum;
		sum += rec[v];
		for (int c : g[v]) {
			if (c == p) continue;
			Dfs(c, v, sum);
		}
	};
	Dfs(0, -1, 0);
	rep(i, n) cout << ans[i] << (i == n - 1 ? "\n" : " ");
	return 0;
}

Measured memory_bytes: 37492
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    int n,k;
    cin >> n >> k;
    ll ans=1;
    int i=0;
    while(i<n){
        if(i==0) ans*=k;
        else ans*=k-1;
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

set<pair<ll, ll>> done;
set<pair<ll, ll>> brack_points;
ll H, W, N;
vector<ll> sum(10);

signed main(void) {
	ll i, j, k, l;
	cin >> H >> W >> N;
	rep(i, N) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		brack_points.insert({ a,b });
	}
	for (auto brack_point : brack_points) {
		ll y = brack_point.first;
		ll x = brack_point.second;
		for (ll dy = -1; dy < 2; dy++) {
			for (ll dx = -1; dx < 2; dx++) {
				ll ny = y + dy;
				ll nx = x + dx;
				if (ny < 1 || H - 1 <= ny) continue;
				if (nx < 1 || W - 1 <= nx) continue;
				if (done.count({ ny,nx }) > 0) continue;

				done.insert({ ny, nx });
				ll dx_brack_count = 0;
				for (i = ny - 1; i < ny + 2; i++) {
					for (j = nx - 1; j < nx + 2; j++) {
						if (brack_points.count({ i,j }) > 0) {
							dx_brack_count++;
						}
					}
				}
				if (dx_brack_count != 0) {
					sum[dx_brack_count]++;
				}
			}
		}
	}
	ll sum2 = (H - 2)*(W - 2);
	rep(i, 10) sum2 -= sum[i];
	cout << sum2 << endl;
	REP(i, 1, 10) {
		cout << sum[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 62720
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int rolls = sc.nextInt();
		
		String output = "No";
		int doubleRollCount = 0;
		
		for(int i = 0; i < rolls; i++) {
			int rollOne = sc.nextInt();
			int rollTwo = sc.nextInt();
			
			if(rollOne == rollTwo) {
				doubleRollCount++;
			}
			else {
				doubleRollCount = 0;
			}
			
			if(doubleRollCount == 3) {
				output = "Yes";
			}
		}
		
		System.out.println(output);
		
	}
}

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

namespace AOJ_ICPC1 {
	class Program {
		static void Main(string[] args) {

			while (true) {
				string[] str1 = Console.ReadLine().Split(' ');
				int n = int.Parse(str1[0]);
				int r = int.Parse(str1[1]);
				if (n == 0 && r==0 ) break;

				int[] p = new int[r];
				int[] c = new int[r];
				for (int i = 0; i < r; i++) {
					string[] str2 = Console.ReadLine().Split(' ');
					p[i] = int.Parse(str2[0]);
					c[i] = int.Parse(str2[1]);
				}
				Console.WriteLine(result(n, p, c).ToString());
			}
		}

		static int result(int n, int[] p, int[] c) {
			List<int> card = Enumerable.Range(1, n).ToList() ;
			int r = p.Length;
			for (int t = 0; t < r; t++) {
				var cut = card.Skip(n - p[t] - c[t] + 1).Take(c[t]).ToList();
				card.RemoveRange(n - p[t] - c[t] + 1, c[t]);
				card.AddRange(cut);
			}
			return card.Last();
		}
	}
}

Measured memory_bytes: 6032
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
    

  int gcd(int a,int b)
  {
    if(b==0)
    {
      return a;
    }
    return gcd(b,a%b);
  }

  bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
  {

    if(a.s==b.s)
    {
      return a.f<b.f;
    }
    return a.s<b.s;
  }
  int32_t main()
  {         

      IOS

      
      int a,b,k;
      cin>>a>>b>>k;

      int z=gcd(a,b);

      int ans=0;
      for(int i=z;i>=1;i--)
      {
        if(z%i==0)
          {
            ans++;
          }
          if(ans==k)
          {
            cout<<i;
            return 0;
          }
      }

      return 0;
  }           

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

int main()
{
  long long int N,M;
  long long int i,j,k;
  char buff[256];

  scanf("%lld",&N);

  j = 0;
  for(i=1;i<=N;i++){
    if( i%3 == 0 ){
      continue;
    }
    else if( i%5 == 0 ){
      continue;
    }
    else{
      j = j + i;
    }
  }

  printf("%lld\n",j);
  return 0;

}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define db(...) " [" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "] "
using ii=long long;
const int N = 1 << 17;
vector<int> v[N];
ii dp[N][3]; // musta, valkoinen (musta ohi), valkoinen (musta alkamatta)
ii mod;
ii res[N];
void h(int s, int e)
{
    dp[s][0] = 1;
    dp[s][1] = 1;
    dp[s][2] = 1;
    for (int u : v[s]) {
        if (u == e) continue;
        h(u, s);
        (dp[s][0] *= (dp[u][0] + dp[u][2] % mod)) %= mod;
        (dp[s][1] *= (dp[u][0] + dp[u][1] % mod)) %= mod;
    }
}
void p(int s, int e, ii x)
{
    res[s] = x * dp[s][0] % mod;
    vector<ii> prodp;
    prodp.push_back(1);
    ii y = 1;
    for (int i = v[s].size() - 1; i >= 0; --i) {
        if (v[s][i] == e) continue;
        (y *= (dp[v[s][i]][0] + 1)) %= mod;
        prodp.push_back(y);
    }
    prodp.pop_back();
    ii z = 1;
    for (int u : v[s]) {
        if (u == e) continue;
        p(u, s, 1 + x * z % mod * prodp.back() % mod);
        prodp.pop_back();
        (z *= (dp[u][0] + 1)) %= mod;
    }
}
int main()
{
    int n;
    cin >> n;
    cin >> mod;
    for (int i = 2; i <= n; ++i) {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    h(1, 1);
    p(1, 1, 1);
    for (int i = 1; i <= n; ++i) {
        cout << res[i] << "\n";
    }
}


Measured memory_bytes: 22656
<?php
/*
    Problem URL : http://arc064.contest.atcoder.jp/tasks/arc064_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d %d", $N, $x);
$a = explode(" ", trim(fgets(STDIN)));

$ans = 0;
for ($i = 0; $i < $N-1; $i++) {
    $b[$i] = $a[$i] + $a[$i+1];
}
if (DEBUG) echo implode(" ", $b) . PHP_EOL;

for ($i = 0; $i < $N; $i++) {
    if ($b[$i] > $x) {
        $ov = $b[$i] - $x;
        $ov = min($ov, $a[$i+1]);
        $a[$i+1] -= $ov;
        $b[$i] = $a[$i]+$a[$i+1];
        $b[$i+1] = $a[$i+1]+$a[$i+2];
        $ans += $ov;

        // if (DEBUG) {
        //     echo "\n";
        //     echo "ans: " . $ans . PHP_EOL;
        //     echo "a: " . implode(" ", $a) . PHP_EOL;
        //     echo "b: " . implode(" ", $b) . PHP_EOL;
        // }

    }
}

if ($a[0] > $x) {
    $ans += $a[0] - $x;
}

echo $ans . PHP_EOL;

Measured memory_bytes: 15220
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    vector<double> P(N); for (auto& p : P) cin >> p;
    vector<vector<double>> dp(N, vector<double>(N + 1));
    dp[0][0] = 1.0 - P[0];
    dp[0][1] = P[0];
    for (int i = 1; i < N; i++) {
        dp[i][0] = dp[i-1][0] * (1.0 - P[i]);
        for (int j = 1; j <= i + 1; j++) {
            dp[i][j] = dp[i-1][j] * (1.0 - P[i]) + dp[i-1][j-1] * P[i];
        }
    }
    double ans = 0.0;
    for (int j = N / 2 + 1; j <= N; j++) {
        ans += dp[N-1][j];
    }
    cout << fixed << setprecision(16) << ans << endl;
    return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	tuple<int, int, int, string> t[10];
	for (int n; cin >> n&&n;) {
		rep(h, 0, n) {
			string s; cin >> s;
			int w = 0, l = 0;
			rep(i, 0, n - 1) {
				int r; cin >> r;
				if (r == 0)w++;
				if (r == 1)l++;
			}
			t[h] = make_tuple(-w, l, h, s);
		}
		sort(t, t + n);
		rep(i, 0, n) {
			cout << get<3>(t[i]) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int n = Integer.parseInt(tmpArray[0]);
		int z = Integer.parseInt(tmpArray[1]);//Xの最初のカード
		int w = Integer.parseInt(tmpArray[2]);//Yの最初のカード
		
		int[] input = new int[n];//山札
		tmpArray = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			input[i] = Integer.parseInt(tmpArray[i]);
		}
		
		int score = 0;
		
		if(n == 1){
			score = Math.abs(w - input[n-1]);
		}
		else {
			score = Math.max(Math.abs(input[n-2] - input[n-1]), Math.abs(w - input[n-1]));
		}
		
		System.out.println(score);
	}


}


Measured memory_bytes: 22996
from math import sin, cos, pi
N, L = map(int, input().split())
NN = N * (N-1) * (N-2) // 6
T = [int(input())*pi/L for _ in range(N)]
print(sum([sum([cos((T[i]+T[j])) * (N+2*(i-j)) for j in range(i+1, N)]) for i in range(N)])/NN, sum([sum([sin((T[i]+T[j])) * (N+2*(i-j)) for j in range(i+1, N)]) for i in range(N)])/NN)


Measured memory_bytes: 3188
def func(A, B, K):
    if K >= A + B:
        ans1, ans2 = 0, 0
    else:
        if K >= A:
            ans1, ans2 = 0, A + B - K
        else:
            ans1, ans2 = A - K, B
    return ans1, ans2


if __name__ == "__main__":
    A, B, K = map(int, input().split())
    print(*func(A, B, K))


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int x1,x2,x3,x4,x,s;
    long long sum,s1,s2,i;
    scanf("%d%d%d%d%d",&x1,&x2,&x3,&x4,&x);
    x1=x1*4;
    x2=x2*2;
    s=min(x1,x2);
    s=min(s,x3);
    s1=(long long)s*x;
    i=x/2;
    s2=i*x4;
    if(x%2==1)
    s2=s2+(long long)s;
    printf("%lld\n",min(s1,s2));
    return 0;
}

Measured memory_bytes: 128
N, M= (int(i) for i in input().split())
if (N<M):
    X = list(int(i) for i in input().split())
    X.sort()
    Y = [X[i] - X[i-1] for i in range(1, len(X))]
    Y.sort()
    print(sum(Y[0:M-N]))
else:
    print(0)


"""
N個のコマ：N-1個の閉経路が存在する
各座標の距離を求める(M-1個)
M：座標の数　N:駒の数
移動しなくても通っている座標の数: N
M - N
"""



Measured memory_bytes: 13960
import Data.List

main :: IO ()
main = do
    -- read inputs
    _ <- getLine
    as <- (map read) . words <$> getLine
    bs <- (map read) . words <$> getLine
    let ds = zipWith (-) as bs
        ds' = reverse . sort . (filter (>=0)) $ ds
        ds'' = filter (<0) ds
        numNotEnough = length ds''
        scoreNotEnough = negate . sum $ ds''
        scoreEnough = sum ds'
    if scoreEnough >= scoreNotEnough 
        then print $ numNotEnough + calcNumEnough ds' scoreNotEnough
        else print $ -1

calcNumEnough :: [Int] -> Int -> Int
calcNumEnough [] y
    | y <= 0 = 0
    | otherwise = error "something is wrong."
calcNumEnough (x:xs) y
    | y <= 0 = 0
    | otherwise = 1 + calcNumEnough xs (y - x)

Measured memory_bytes: 103804
// https://atcoder.jp/contests/abc139/tasks/abc139_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    int cnt = 0;
    cin >> s >> t;
    REP(i, 3) cnt += (s[i] == t[i]);
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100005;
struct node { int y,next; } a[N<<1];
int f[N],s[N],head[N],i,j,k,n,m,an;
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

void jb(int x,int y)
{
	a[++k]=(node){y,head[x]},head[x]=k,
	a[++k]=(node){x,head[y]},head[y]=k;
}

void dfs(int w,int sp)
{
	int z=0;
	for (register int j=head[w];j;j=a[j].next)
		if ((j^1)!=sp)
		{
			int c=a[j].y;
			dfs(c,j),
			z|=s[w]&s[c],
			s[w]|=s[c];
		}
	if (s[w])
	{
		while ((1<<f[w])<=z||(s[w]>>f[w]&1)) ++f[w];
		s[w]>>=f[w],s[w]<<=f[w],s[w]|=1<<f[w];
	}
	else
		s[w]=1;
	an=max(an,f[w]);
}

int main()
{
	n=read(),k=1;
	for (i=1;i<n;++i) jb(read(),read());
	dfs(1,0);
	printf("%d\n",an);
	return 0;
}

Measured memory_bytes: 7680
//Now you are making me a boy with luvv...
//I don't want to do this but I'm being forced to ....pls help!!
#include <bits/stdc++.h>
using namespace std;
#define loop(x,n) for(int x = 0; x < n; ++x)
#define ed end()  
#define bg begin()
# define ld long double
#define ll long long
#define ub(v,a) upper_bound(all(v),a)
#define lb(v,a) lower_bound(all(v),a)
#define sz(a) (int)(a.size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tr(v,it) for(auto it=v.begin();it!=v.end();it++)
#define present(v,x) (v.find(x)!=v.end()) //set/map etc.
#define vpresent(v,x) (find(all(v),x)!=v.end()) // vector
typedef vector< int > vi;
typedef vector< long long > vll;
typedef vector<pair<ll,ll>> vp;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
const long long max_sz = 1e5 + 1;
const long long mod = 1e9 + 7;
const long long MAXN = 4e18 + 1;
char flip(char k){ if(k=='0') return '1'; return '0'; }
ll sum_digit(ll n){ ll a=0,i; for(i=n;i>0;i=i/10){ a+=(i%10);} return a; }
ll gcd(ll a, ll b){
	if(b == 0) return a;
	return gcd(b, a%b);
}
int main(){
                   // ios_base::sync_with_stdio(false);
                    //cin.tie(NULL);
                    //cout.tie(NULL);
 
                     ll t;
                    // cin >> t;
                     t=1;
                     while (t--){
                             ll h1,m1,h2,m2,k;cin>>h1>>m1>>h2>>m2>>k;
                             if(m2>m1){
                                 ll diff=(h2-h1)*60 + m2-m1;
                                 cout<<diff-k<<endl;
                             }
                             else{
                                 ll diff=(h2-h1)*60 +m2-m1;
                                 cout<<diff -k<<endl;
                             }
                     }
                    cerr << endl
                                  << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
                      return 0;
}


Measured memory_bytes: 3756
#!/usr/bin/env python3
# coding: utf-8

import sys
import math
#from pprint import pprint
import numpy as np
def myinput_int():
    return list(map(int, input().split()))

N,D = myinput_int()

X=[]
for i in range(N) :
    X.append(myinput_int())

X = np.asarray(X)

counter=0
for i in range(N) :
    for j in range(i+1, N) :
        if np.sqrt(np.sum((X[i]-X[j])**2)).is_integer()==True:
            counter+=1

print(counter)


Measured memory_bytes: 12488
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int n;
    cin >> n;
    vector<bool> V;
    for(int i = 0; i < n; ++i){
        int l, r;
        cin >> l >> r;
        V.push_back(l == r);
    }
    int i = 0;
    while(i < n){
        int j = i + 1;
        while(j < n && V[i] == V[j]){
            j++;
        }
        if(V[i] && j - i >= 3){
            cout << "Yes" << endl;
            return;
        }
        i = j;
    }
    cout << "No" << endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


Measured memory_bytes: 3656
S = input()

x = y = 0
for i, c in enumerate(S):
    if i % 2:
        a, b = 0, 1
    else:
        a, b = 1, 0
    if int(c) == a:
        x += 1
    if int(c) == b:
        y += 1
print(min(x, y))


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<sstream>

using namespace std;

int main (void) {
    string str;
    size_t w;
    cin >> str;
    cin >> w;
    stringstream ss;
    for (size_t i = 0; w*i < str.size(); ++i) {
        ss << str[w*i];
    }
    cout << ss.str() << endl;
}

Measured memory_bytes: 256
import numpy as np
A,B,H,M=list(map(float,input().split()))

h_tip_rad=(60*H+M)*2*np.pi/12/60
m_tip_rad=M*np.pi/30

rad=abs(m_tip_rad-h_tip_rad)

ans=np.sqrt(A**2+B**2-2*A*B*np.cos(rad))

print(ans)

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

int main(){
  int H, W;
  cin >> H >> W;
  
  for(int i = 0; i < W + 2; i++){
    cout << '#';
  }
  
  cout << endl;
  
  for(int i = 0; i < H; i++){
    cout << '#';
    for(int j = 0; j < W; j++){
      char a;
      cin >> a;
      cout << a;
      
    }
    
    cout << '#';
    cout << endl;
  }
  
  
  
  for(int i = 0; i < W + 2; i++){
    cout << '#';
  }
}

Measured memory_bytes: 3600