akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n==1) cout<<"1";
	if(n==2||n==3) cout<<"2";
	if(n>=4&&n<=7) cout<<"4";
	if(n>=8&&n<=15) cout<<"8";
	if(n>=16&&n<=31) cout<<"16";
	if(n>=32&&n<=63) cout<<"32";
	if(n>=64) cout<<"64";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

const double PI=3.14159265358979323846;
  
int main() {
  int a,b,x;
  cin >> a >> b >> x;
  if(2 * x >=  a * a * b) {
    double tana = (double)(a * a * b - x) * (double)(2) / (double)(a * a * a);
    double theta = atan(tana);
    cout << setprecision(16)  <<  theta * (double)180 / PI << endl;
  } else {
    double tanb = (double)(x * 2) / (double)(a * b * b);
    double theta = (double)(PI / (double)2.0) - atan(tanb);
    cout << setprecision(16)  <<  theta * (double)180 / PI << endl;
  }
  return 0;
}

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

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(void){
    long l, r;
    cin >> l >> r;
    if(r - l > 2030){
        cout << 0 << endl;
    }else{
        long minv = INT_MAX;
        for(long i = l; i < r; i++){
            for(long j = i+1; j <= r; j++){
                minv = min((i*j)%2019, minv);
            }
        }
        cout << minv << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define NMAX 100005
#define DMAX 105
using namespace std;
string k;
int d;
int dp[NMAX][DMAX][2];
const int MOD=1e9+7;
int main()
{
    cin>>k;
    cin>>d;
    dp[0][0][0]=1;
    for(int i=1;i<=(int)k.size();i++)
    {
        for(int sum=0;sum<d;sum++)
        {
            for(int digit=0;digit<=(k[i-1]-'0');digit++)
            {
                dp[i][(sum+digit)%d][0 || (digit<k[i-1]-'0')]+=dp[i-1][sum][0];
                dp[i][(sum+digit)%d][0 || (digit<k[i-1]-'0')]%=MOD;
            }
            for(int digit=0;digit<=9;digit++)
            {
                dp[i][(sum+digit)%d][1]+=dp[i-1][sum][1];
                dp[i][(sum+digit)%d][1]%=MOD;
            }
        }
    }
    int sz=k.size();
    int sol=(dp[sz][0][0]+dp[sz][0][1])%MOD;
    sol=(MOD+sol-1)%MOD;
    cout<<sol;
    return 0;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  int N;
  cin >> N;

  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  ll sum = 0;
  REP(i,N){
    sum+=A.at(i);
  }
  ll sum2 = 0;
  ll sum3 = 0;
  REP(i,N-1){
    sum2+=A.at(i);
    sum3 = sum2+A.at(i+1);
    if(sum3>sum/2){
      break;
    }
  }
  cout << min(sum-sum2*2,sum3*2-sum) << endl;
}

Measured memory_bytes: 1792
package main

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

const mod = 2019
const facNum = 300001
const INF = 1001001001

func main() {
	sc := newScanner(os.Stdin)
	S := sc.s()
	S = Reverse(S)
	ans := 0
	cnt := make([]int, mod)
	x, tot := 1, 0
	for _, r := range S {
		cnt[tot]++
		tot += int(r-'0') * x
		tot %= mod
		ans += cnt[tot]
		x = x * 10 % mod
	}
	fmt.Println(ans)
}

// fmt.Println("Yes")
// fmt.Println("No")

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

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

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 3532
// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


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

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back


int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    int n = input<int>();
    int ans = 0;

    int prev_r = 0;
    
    for (int i = 0; i != n; ++i) {
        int a = input<int>();

        int lg = 31 - __builtin_clz(a);
//        while ((2 << lg) <= a)
//            ++lg;

        if ((1 << lg) == a) {
            ans += lg;
            ans -= min(prev_r, lg);
            prev_r = lg;
        } else {
            ans += lg + 1;

            if (prev_r <= lg)
                ans -= prev_r, prev_r = lg + 1;
            else
                ans -= lg + 1, prev_r = lg;
            
        }
    }

    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#ABC110 C String Transformation

S = input()
T = input()

StoT = {}
TtoS = {}

for s, t in zip(S, T):
    if s in StoT.keys():
        if StoT[s] != t:
            print('No')
            exit()
    elif t in TtoS.keys():
        if TtoS[t] != s:
            print('No')
            exit()
    else:
        StoT[s] = t
        TtoS[t] = s
        
print('Yes')

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

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

int MOD=1e9+7;
ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    int n, k; cin>>n>>k;
    vector<int> a(n);
    int MIN=MOD, MAX=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        MIN=min(MIN, a[i]);
        MAX=max(MAX, a[i]);

        if(a[i] == k){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    vector<int> div;
    for(int i=2; i<=sqrt(MIN); i++){
        if(MIN%i == 0){
            div.emplace_back(i);
            div.emplace_back(MIN/i);
        }
    }
    div.emplace_back(MIN);

    for(int i=0; i<div.size(); i++){
        bool f=true;
        for(int j=0; j<n; j++){
            if(a[j]%div[i] != 0) f=false;
        }

        if(f){
            if(k%div[i] != 0 || MAX-MIN < k){
                cout << "IMPOSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "POSSIBLE" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define MP make_pair
typedef long long ll;
typedef string str;


// 文字列sをランレングス圧縮し, 結果のpair-vectorを返す;
// pair : pair.first = 文字 : char, pair.second = 出現回数 : int
// 計算量 O(|S|)
vector<pair<char, int>> run_length(const str &s) {
    vector<pair<char, int>> res;

    // 前の文字列と比較するため, 1からスタートする.
    REP(i, s.length()) {
        int cnt = 1;

        // 前の文字と等しかったら等しい間だけカウントを続け, iも進める.
        // ※ s[i] == s[i + 1] としている理由は, s[i - 1] == s[i] とすると,
        //   sの末尾1文字のみが長さ位置のランレングスだった場合に,
        //   独立してif文で処理を書く必要が出てくるため, こちらの比較を採用.
        while(i + 1 < s.length() && s[i] == s[i + 1]) {
            cnt++;
            i++;
        }
        res.push_back(MP(s[i], cnt));
    }
    return res;
}


#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
// AtCoder ABC 143 C Slimes
// URL: https://atcoder.jp/contests/abc143/tasks/abc143_c
int main() {
    int n;
    cin >> n;
    str s;
    cin >> s;
    cout << run_length(s).size() << "\n";
    return 0;
}


Measured memory_bytes: 1528
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <math.h>
#define ll long long;

using namespace std;

class dice {
public:
	int a[7];
	int state[7];
	void move(char s);
	int rotate(int a, int b);
};

void dice::move(char s) {
	int t[7];//??????????????´???
	for (int i = 1; i <= 6; i++) {
		t[i] = state[i];
	}
	if (s == 'N') {
		state[1] = t[2];
		state[2] = t[6];
		state[6] = t[5];
		state[5] = t[1];
	}
	else if (s == 'S') {
		state[1] = t[5];
		state[5] = t[6];
		state[6] = t[2];
		state[2] = t[1];
	}
	else if (s == 'W') {
		state[1] = t[3];
		state[3] = t[6];
		state[6] = t[4];
		state[4] = t[1];
	}
	else {
		state[1] = t[4];
		state[4] = t[6];
		state[6] = t[3];
		state[3] = t[1];
	}
}

int dice::rotate(int a, int b) {
	int count = 0;
	while (state[2] != b) {
		move('N');
		if (state[2] == b) break;
		move('N');
		if (state[2] == b) break;
		move('N');
		if (state[2] == b) break;
		move('W');
		move('S');
		if (state[2] == b) break;
		move('S');
		move('S');
	}
	while (state[1] != a&&count<=3){
		move('E');
		count++;
	}
	if (state[1] == a) return state[3];
	else return -1;
}


int main() {
	
	dice dice1{
	};
	dice dice2{
	};

	for (int i = 1; i <= 6; i++) {
		cin >> dice1.a[i];
		dice1.state[i] = dice1.a[i];
	}
	for (int i = 1; i <= 6; i++) {
		cin >> dice2.a[i];
		dice2.state[i] = dice2.a[i];
	}
	sort(dice1.a+1, dice1.a + 7);
	sort(dice2.a+1, dice2.a + 7);

	bool same = true;
	for (int i = 1; i <= 6; i++) {
		if (dice1.a[i] != dice2.a[i]) {
			same = false;
			break;
		}
	}

	if (!same) {
		cout << "No" << endl;
	}
	else {
		if ((dice2.rotate(dice1.state[1], dice1.state[2]) == -1 || dice2.rotate(dice1.state[1], dice1.state[2]) != dice1.state[3])&&(dice2.rotate(dice1.state[3], dice1.state[6]) == -1 || dice2.rotate(dice1.state[3], dice1.state[6]) != dice1.state[5])&&(dice2.rotate(dice1.state[4], dice1.state[5]) == -1 || dice2.rotate(dice1.state[4], dice1.state[5]) != dice1.state[6])) {
			cout << "No" << endl;
		}
		else {
			dice1.move('E');
			dice1.move('E');
			dice1.move('S');

			if ((dice2.rotate(dice1.state[1], dice1.state[2]) == -1 || dice2.rotate(dice1.state[1], dice1.state[2]) != dice1.state[3]) && (dice2.rotate(dice1.state[3], dice1.state[6]) == -1 || dice2.rotate(dice1.state[3], dice1.state[6]) != dice1.state[5]) && (dice2.rotate(dice1.state[4], dice1.state[5]) == -1 || dice2.rotate(dice1.state[4], dice1.state[5]) != dice1.state[6])) {
				cout << "No" << endl;
			}
			else {
				cout << "Yes" << endl;
			}
		}
	}


	
}

Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    vector<int> vec={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    K--;
    cout << vec[K] << endl;
}

Measured memory_bytes: 256
x,y = map(int,input().split())
L = [1,3,5,7,8,10,12]
M = [4,6,9,11]
N = [2]
if ((x in L and y in L) or (x in M and y in M) or (x in N and y in N)):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
import collections
h,w,n=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
L=[]
for i in range(n):
  for j in range(3):
    for k in range(3):
      if 0<l[i][0]-j<h-1 and 0<l[i][1]-k<w-1:
        L.append((l[i][0]-j-1)*10**9+l[i][1]-k-1)
L=collections.Counter(L)
L2=list(L.values())
ans=[0 for i in range(10)]
for i in range(len(L2)):
  ans[L2[i]]+=1
ans[0]=(h-2)*(w-2)-len(L2)
for i in range(10):
  print(ans[i])

Measured memory_bytes: 158920
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>

using namespace std;


int main(){
    int l, i, min, diff, x;
    string S;
    cin >> S;
    
    l = S.size();
    min = 753;

    for (i=0; i<l-2; i++){
        x = (int)(S[i]-'0')*100 + (int)(S[i+1]-'0')*10 + (int)(S[i+2]-'0');
        diff = abs(x - 753);
        if (diff < min) min = diff;
    }
    cout << min << '\n';
}

   

Measured memory_bytes: 256
n, m, _=gets.split.map &:to_i
r=gets.split.map{|e|e.to_i-1}
INF=1e9
cost=(0...n).map{|i|[INF]*i+[0]+[INF]*(n-i-1)}

m.times{
    a, b, c=gets.split.map &:to_i
    cost[a-1][b-1]=c
    cost[b-1][a-1]=c
}

(0...n).each{|k|
    (0...n).each{|i|
        (0...n).each{|j|
            t=cost[i][k]+cost[k][j]
            cost[i][j]=t if cost[i][j]>t
        }
    }
}

p r.permutation.map{|v| v.each_cons(2).map{|x,y|cost[x][y]}.inject(:+)}.min


Measured memory_bytes: 2940
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <typeinfo>
#include <climits>
#include <ctype.h>
#include <string>
#include <stack>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i += 2){
        cout << s[i];
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>

using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;

int main()
{

	string s,t;
	cin>>s>>t;
	t+=s;
	cout<<t<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
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; }

int n;

int main() {
    cin >> n;
    vector<ll> Avec(n, 0);
    for(int i = 0; i < n; ++i) cin >> Avec.at(i);

    sort(Avec.begin(), Avec.end(), greater<ll>());
    ll sum = 0;
    priority_queue<ll> pque;
    for(int i = 0; i < n; ++i) {
        if(i == 0) {
            pque.push(Avec.at(i));
        }else {
            sum += pque.top();
            pque.pop();
            pque.push(Avec.at(i));
            pque.push(Avec.at(i));
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 6936
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define print(i) std::cout << (i) << '\n'
inline long long ceildiv(long long a, long long  b) { return (a+b-1)/b; }
typedef pair<long long,long long> P;
const long long inf = 10e7;
//int |x|<=2*10**9     long |x|<= 9*10**18
#define ll long long
double p[3300];
int n;
const long long mod = 1000000007;
double dp[3300][3300];
/*dp[i][j]:= [0,i)のコイン(i枚のコイン)を投げてj枚表の確率*/
int main(){cin>>n;rep(i,n){cin>>p[i];}
dp[0][0]=1;
rep(i,n){rep(j,n+1){dp[i+1][j]=dp[i][j]*(1-p[i]);
if (j>=1){dp[i+1][j]+=dp[i][j-1]*p[i];}}}
double ans;
for (int i=0;i<=n;i++){if(i>n-i)ans+=dp[n][i];}
printf("%.15lf\n",ans);
}

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

    let sa = Array.make (n + 1) 0 in
    let sb = Array.make (m + 1) 0 in
    for i = 0 to n - 1 do sa.(i + 1) <- sa.(i) + a.(i) done;
    for i = 0 to m - 1 do sb.(i + 1) <- sb.(i) + b.(i) done;

    let rec loop ia =
        if ia > n then n else
            if sa.(ia) <= k then loop (ia + 1) else ia - 1
    in
    let ia = loop 0 in
    let rec loop ib =
        if ib > m then m else
            if sb.(ib) + sa.(ia) <= k then loop (ib + 1) else ib - 1
    in
    let ib = loop 0 in
    let rec loop ia ib best =
        if ia < 0 || ib > m then best else
            if sa.(ia) + sb.(ib) <= k then (
                let best = max best (ia + ib) in
                loop ia (ib + 1) best
            ) else loop (ia - 1) ib best
    in
    loop ia ib (ia + ib) |> Printf.printf "%d\n"
)

Measured memory_bytes: 12308
#include <stdio.h>

int main()
{
	int m,f,r;
	
	while(1)
	{
		scanf("%d %d %d",&m,&f,&r);
		
		if(m == -1 && f == -1 && r == -1) break;
		
		if(m == -1 || f == -1)
		{
			printf("F\n");
			continue;
		}
		
		if(m + f >= 80)
		{
			printf("A\n");
			continue;
		}
		
		if(m + f >= 65 && m + f < 80)
		{
			printf("B\n");
			continue;
		}
		
		if(m + f >= 50 && m + f < 65)
		{
			printf("C\n");
			continue;
		}
		
		if(m + f >= 30 && m + f < 50)
		{
			if(r >= 50) 
			{
				printf("C\n");
				continue;
			}
			else
			{
				printf("D\n");
				continue;
			}
		}
		
		if(m + f < 30)
		{
			printf("F\n");
			continue;
		}
	}
	
	return 0;
}

Measured memory_bytes: 584
A=int(input())
B=int(input())
if A==1 and B==2:
    print(3)
elif A==2 and B==1:
    print(3)
elif A==3 and B==1:
    print(2)
elif A==1 and B==3:
    print(2)
elif A==2 and B==3:
    print(1)
elif A==3 and B==2:
    print(1)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;
const int MAX_V = 110;

struct Flow{
    struct edge{
        int to, cap, rev;
    };
    vector<edge> G[MAX_V];//隣接リスト
    bool used[MAX_V];

    void add_edge(int from, int to, int cap){
        G[from].push_back((edge){to, cap, (int)G[to].size()});//from -> to
        G[to].push_back((edge){from, 0, (int)G[from].size() - 1});//to -> from
    }

    //増加パスを探す
    int dfs(int v, int t, int f){
        if(v == t) return f;
        used[v] = true;
        for (int i = 0; i < G[v].size(); ++i){
            edge &e = G[v][i];
            if(!used[e.to] && e.cap > 0){
                int d = dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    //sからtへの最大流
    int max_flow(int s, int t){
        int flow = 0;
        while(1){
            memset(used, 0, sizeof(used));
            int f = dfs(s, t, INF);
            if(f == 0) return flow;
            flow += f;
        }
    }
};

int main(void){
    int V, E; cin >> V >> E;
    Flow mf;
    rep(i, E){
        int u, v, c; cin >> u >> v >> c;
        mf.add_edge(u, v, c);
    }
    printf("%d\n", mf.max_flow(0, V - 1));
    return 0;
}


Measured memory_bytes: 3300
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n,greater<int>());
    int ans=arr[0];
    int rem=n-2;
    for(int i=1;i<n;i++){
        if(rem==0) break;
        ans+=arr[i];
        rem--;
        if(rem==0)break;
        ans+=arr[i];
        rem--;
    }
    cout << ans << endl;
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 5180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int n;
vector<ll> a;
ll dp[3100][3100];

ll rec(int i, int j) {
    if(dp[i][j]!=0) return dp[i][j];
    if(i == j) return dp[i][j] = a[i];
    return dp[i][j] = max(a[i]-rec(i+1, j), a[j]-rec(i, j-1));
}


int main(){
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) dp[i][j] = 0;
    ll ans = rec(0, n-1);
    cout << ans << endl;
}

Measured memory_bytes: 74240
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
constexpr long long int NINF = std::numeric_limits<long long int>::min();
#define int long long int

void solve() {
  int N;
  cin >> N;

  if (N == 1) {
    cout << "Hello World" << endl;
  } else {
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
import copy
MAX_LENGTH = 1000
MAX_WEIGHT = 10001


def minimum_sort_cost(A):
    cost = 0
    n = len(A)
    s = min(A)
    B = sorted(A)
    V = [False] * n
    T = [None] * MAX_WEIGHT

    for i in range(n):
        T[B[i]] = i
    
    for i in range(n):
        if V[i]:
            continue

        cur = i
        circle_len = 0
        min_weight = MAX_WEIGHT
        circle_weight = 0

        while(True):
            V[cur] = True
            circle_len += 1
            weight = A[cur]
            min_weight = min(min_weight, weight)
            circle_weight += weight
            cur = T[weight]

            if V[cur]:
                break
        
        cost += min(circle_weight + (circle_len - 2) * min_weight,\
             min_weight + circle_weight + (circle_len + 1) * s)
    
    return cost


if __name__ == "__main__":
    n = int(input())
    *A, = map(int, input().split())
    print(minimum_sort_cost(A))


Measured memory_bytes: 6416
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

type intHeap []int

func (h intHeap) Len() int           { return len(h) }
func (h intHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h intHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *intHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *intHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for D - Powerful Discount Tickets
	var N, M int
	fmt.Scan(&N, &M)

	sc.Split(bufio.ScanWords)
	h := &intHeap{}
	heap.Init(h)
	for i := 0; i < N; i++ {
		heap.Push(h, nextInt())
	}

	for i := 0; i < M; i++ {
		heap.Push(h, (heap.Pop(h).(int))/2)
	}

	var ans int
	for h.Len() > 0 {
		ans += heap.Pop(h).(int)
	}

	fmt.Println(ans)
}


Measured memory_bytes: 6880
from heapq import heappush, heappop, heapify

n = int(input())
G = [[] for _ in range(n)]

for i in range(n):
    for j,dist in enumerate(map(int,input().split())):
        if dist != -1:
            G[i].append((j,dist))
sum = 0

def prim(n):
    que = [(w,c) for c,w in G[0]]
    heapify(que)
    color = [0]*n
    color[0] = 1
    global sum
    while que:
        w,node = heappop(que)
        if color[node] == 1:
            continue
        color[node] = 1
        sum += w
        for x,y in G[node]:
            if color[x] == 1:
                continue
            heappush(que,(y,x))
    return sum

print(prim(n))



Measured memory_bytes: 6660
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string N;
	int K;
	scan(N>>K);
	int L=N.size();
	int dp[101][2][5]={};
	dp[0][0][0]=1;
	rep(i,L){
		rep(j,2){
			rep(k,K+1){
				int lim= j ? 9 : N[i]-'0';
				rep(d,lim+1){
					dp[i+1][j||d<lim][k+(d!=0)]+=dp[i][j][k];
				}
			}
		}
	}
	ll ans=0;
	rep(j,2){
		ans+=dp[L][j][K];
	}
	prin(ans);
	return 0;
}


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

int main() {
  string s,t; cin >> s >> t;

  int index = -1;
  for ( int i = 0; i + t.length()-1 < s.length(); i++ ) {
    bool match = true;    
    for ( int j = 0; j < t.length(); j++ ) {
      if ( s[i+j] != t[j] && s[i+j] != '?' ) match = false;
    }
    if ( match ) index = i;
  }
  
  if ( index == -1 ) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  
  for ( int i = 0; i < t.length(); i++ ) {
    s[i+index] = t[i];
  }
  for ( int i = 0; i < s.length(); i++ ) {
    if ( s[i] == '?' ) s[i] = 'a';
  }

 cout << s << endl;
  return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    ll n, k; cin >> n >> k;
    vector<ll> v(100000 + 1, 0);
    for(int i = 0; i < n; i++){
        int a, b; cin >> a >> b;
        v[a] += b;
    }

    for(int i = 1; i <= 100000; i++){
        if(k <= v[i]){
            cout << i << endl;
            return 0;
        }
        k -= v[i];
    }
}


Measured memory_bytes: 1024
#include <iostream> 
#include <algorithm> 
#include <cstring> 
#include <cstdio>
#include <vector> 
#include <queue> 
#include <cstdlib> 
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime> 
#include <map> 
#include <set> 
using namespace std; 
#define lowbit(x) (x&(-x)) 
#define max(x,y) (x>y?x:y) 
#define min(x,y) (x<y?x:y) 
#define MAX 100000000000000000 
#define MOD 1000000007
#define pi acos(-1.0) 
#define ei exp(1) 
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
const int maxn=1e6+7;
struct cmp
{
	bool operator()(const ll &a,const ll &b)
	{
		return a>b;
	}
};
multiset<ll,cmp>s;
multiset<ll>::iterator it;
priority_queue<ll,vector<ll> >q;
ll cnt,x,n;
int main()
{
	while(scanf("%lld",&n)!=EOF)
	{
		s.clear();
		for(int i=0;i<n;i++)
		{
			scanf("%lld",&x);
			s.insert(x);
		}
		x=0;
		for(it=s.begin();it!=s.end();it++)
		{
			if(*it==x) cnt++;
			else x=*it,cnt=1;
			if(cnt==2) q.push(x),cnt=0;
		}
		if(q.size()<2) printf("0\n");
		else x=q.top(),q.pop(),printf("%lld\n",x*q.top());
		while(!q.empty()) q.pop();
	}
	return 0;
}

Measured memory_bytes: 5632
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main()
{
	long long int n, a, b; cin >> n >> a >> b;
	a = a - b;
	long long int hp[100001] = { 0 }, h[100001] = { 0 };
	REP(i, n) {
		cin >> h[i];
	}
	long long count = 1, ookii = 0, ok = 1000000000, no = 0;
	while (1) {
		REP(i, 100001) { hp[i] = h[i]; }
		ookii = 0; int mae = count;
		count = (no + ok) / 2; //cout << count << endl;
		if (ok - no < 2) {
			cout << ok << endl; break;
		}
		for (int i = 0; i < n; i++)
		{
			hp[i] -= b*count;
			if (hp[i] > 0) {
				ookii += hp[i]/a + !!(hp[i]%a);
				//hp[i] -= a; i--; ookii++; 
				if (ookii > count) {
					break;
				}
			}
		}
		if (ookii <= count) {
			ok = count;
		}
		else {
			no = count;
		}
	}
	return 0;
}

Measured memory_bytes: 1792
s=input()
if (len(s))==2:print(1,2)if s[1]==s[0]else print(-1,-1)
else:
    for i in range(2,len(s)):
        if s[i]==s[i-1]:print(i,i+1)
        elif s[i]==s[i-2]:print(i-1,i+1)
        else:continue
        break
    else:print(-1,-1)

Measured memory_bytes: 8928
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main() {
    ll N,A,B;
    cin>>N>>A>>B;
    vector<ll> P(N),a,b,c;
    rep0(i,N){cin>>P[i];}
    rep0(i,N){
        if(P[i]<=A){a.push_back(P[i]);}
        else if(P[i]>A&&P[i]<=B){b.push_back(P[i]);}
        else{c.push_back(P[i]);}
        
    }
    cout<<min(a.size(),min(b.size(),c.size()))<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n; cin >> n;
		if(!n)break;
		vector<pair<int,int>> v(n);
		for(int i=0;i<n;i++){
			cin >> v[i].first >> v[i].second;
		}
		int m; cin >> m;
		vector<pair<int,int>> vv(m);
		set<pair<int,int>> s;
		for(int i=0;i<m;i++){
			cin >> vv[i].first >> vv[i].second;
			s.insert(make_pair(vv[i].first,vv[i].second));
		}
		for(int i=0;i<m;i++){
			bool ok=1;
			int x=vv[i].first-v[0].first,y=vv[i].second-v[0].second;
			for(int j=1;j<n;j++){
				if(s.find({v[j].first+x,v[j].second+y})==s.end()){
					ok=0;
					break;
				}
			}
			if(ok){
				printf("%d %d\n",x,y);
				break;
			}
		}
	}
}


Measured memory_bytes: 3208
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

// ここまで

use std::io::Write;
use std::cmp::min;

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    input! {
        n: usize,
        m: usize,
        q: usize,
        a: [i64; n],
        b: [i64; m],
        x: [i64; q],
    }
    let a = {
        let mut a = a;
        let mut t = Vec::with_capacity(n + 2);
        t.push(-10_000_000_000 - 1);
        t.append(&mut a);
        t.push(20_000_000_000 + 1);
        t
    };
    let b = {
        let mut b = b;
        let mut t = Vec::with_capacity(m + 2);
        t.push(-10_000_000_000 - 1);
        t.append(&mut b);
        t.push(20_000_000_000 + 1);
        t
    };
    for x in x {
        let i = a.binary_search(&x).unwrap_err();
        let j = b.binary_search(&x).unwrap_err();
        let mut ans = 20_000_000_000i64;
        for &p in [a[i - 1], a[i]].iter() {
            for &q in [b[j - 1], b[j]].iter() {
                for &(s, t) in [(p, q), (q, p)].iter() {
                    let v = (s - x).abs() + (t - s).abs();
                    ans = min(ans, v);
                }
            }
        }
        writeln!(out, "{}", ans).unwrap();
    }
}

fn main() {
    run();
}


Measured memory_bytes: 13304
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);cerr<<fixed<<setprecision(5);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
/* VARIABLE DECLARATION START */
//int arr[8000][8000];
/*  FUCNTION TEMPLATE STARTS  HERE */
double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
   int t;cin>>t;
   vector<int>v(t);
   for(int &x:v)cin>>x;
   int sum=accumulate(all(v),0);
   int m;cin>>m;
   while(m--)
   {
    int a,b;
    cin>>a>>b;
    cout<<sum-v[a-1]+b<<endl;
   }
   

    
}




Measured memory_bytes: 256
use List::Util qw/min/;

$N = <>; chomp $N;
$K = <>; chomp $K;
$X = <>; chomp $X;
@x = split / /, $X;

$sum;
for (@x) {
    $robo_a = abs $_;
    $robo_b = abs $_ - $K;

    $sum += min $robo_a, $robo_b;
}

print $sum * 2;


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()
    cnt_lose = 0

    for i in s:
        if i == 'x':
            cnt_lose += 1
    
    if cnt_lose >=8:
        print('NO')
    else:
        print('YES')

solve()


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

pair<double,int> s[8],all[18],ans[8];


int main(){
	for(int i=0;i<3;i++){
		for(int j=0;j<8;j++){
			cin>>s[j].second>>s[j].first;
		}
		sort(s,s+8);
		for(int j=2;j<8;j++)
			all[i*6+j-2]=s[j];
		for(int j=0;j<2;j++)
			ans[i*2+j]=s[j];
	}
	sort(all,all+18);
	ans[6]=all[0];
	ans[7]=all[1];
	for(int i=0;i<8;i++){
		printf("%d %.2f\n",ans[i].second,ans[i].first);
	}
	return 0;
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (auto&& e : v) cin >> e;
  int ans = numeric_limits<int>::max();

  for (int i = 0, j = i + k - 1; j < n; i++, j++) {
    ans = min(ans, v[j] - v[i] + min(int(abs(v[i])), int(abs(v[j]))));
  }
  cout << ans << endl;
}


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

int field[101][101];
int main(void){
    int N, W, H, x, y, S, T;
    while(cin >> N && N) {
        cin >> W >> H;
        rep(i, W) rep(j, H) field[i][j] = 0;
        rep(i, N) {
            cin >> x >> y;
            field[x-1][y-1] = 1;
        }
        cin >> S >> T;
        int ans = 0;
        rep(i, W-S+1) {
            rep(j, H-T+1) {
                int tree = 0;
                rep(a, S) rep(b, T) tree += field[i+a][j+b];
                ans = max(ans, tree);
            }
        }
        cout << ans << endl;
    }
}

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

int main()
{

    int c=0 ;
    string S ,T ;
    cin>> S >> T ;
    for(int i=0 ; i< S.length() ; i++){
        if(S[i]!=T[i])
            c+=1 ;
    }
    cout<< c ;
    return 0;
}


Measured memory_bytes: 3896
import java.util.Scanner;


public class Main {
	static long Fact(int n){
		return n == 0 ? 1 : n * Fact(n - 1);
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int m = in.nextInt();
		System.out.println(Fact(m));
		in.close();
	}
}
				

Measured memory_bytes: 11000
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n;
	cin >> n;
	int sq = sqrt(n);
	cout << sq * sq << endl;
}

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

int main()
{
  int A , B, C, D;
  cin >> A >> B >> C >> D;
  if(A * B > C * D)
  {
    cout << A * B << endl;
  }
  else
  {
    cout << C * D << endl;
  }
  return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main()
{
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 764
H,W=map(int,input().split())
S = [list(str(input())) for i in range(H)]
judge=True
for i in range(H):
    for j in range(W):
        if S[i][j]=='#':
            judge1=True
            judge2=True
            judge3=True
            judge4=True
            
            try:S[i][j-1]
            except IndexError:judge1=False
            else:
                if S[i][j-1]=='.':
                    judge1=False
                    
            try:S[i][j+1]
            except IndexError:judge2=False
            else:
                if S[i][j+1]=='.':
                    judge2=False
                    
            try:S[i+1][j]
            except IndexError:judge3=False
            else:
                if S[i+1][j]=='.':
                    judge3=False
                    
            try:S[i-1][j]
            except IndexError:judge4=False
            else:
                if S[i-1][j]=='.':
                    judge4=False

            if judge1==False and judge2==False and judge3==False and judge4==False:
                judge=False
                break

    if judge==False:break


if judge:print('Yes')
else:print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1e9+1;

/*
dp[i][j]:高さiのあみだくじで、1がjに行く総数
dp[1][1]=
dp[i][j]=dp[i-1][j-1]+dp[i-1][j+1]
*/

ll f[9];
void filling(){
    f[0] = 1;
    f[1] = 1;
    rep(i,7){
        f[i+2] = f[i]+f[i+1];
    }
}

ll dp[105][10];

void solve(){
    filling();
    int h,w,k;
    cin >> h >> w >> k;
    rep(i,h){
        dp[i+1][0]=0;
        dp[i+1][w+1]=0;
    }
    dp[1][1] = f[w-1];
    dp[1][2] = f[w-2];
    //w=1,w=2で例外処理したい
    if(w==1) cout << 1 << endl;
    //else if(w==2){

    //}
    else{
    for(int i=3; i<=w; i++){
        dp[1][i]=0;
    }
    for(int i=2; i<=h; i++){
        for(int j=1; j<=w; j++){
            dp[i][j] = (((f[j-2]*f[w-j]*dp[i-1][j-1]) % MOD)
                     + ((f[j-1]*f[w-j]*dp[i-1][j]) % MOD)
                     + ((f[j-1]*f[w-1-j]*dp[i-1][j+1]) % MOD) )%MOD;
                     //cout << "i:" << i << " j:" << j << " dp:" << dp[i][j] << endl;
        }
    }
    cout << dp[h][k] << endl;
    }
}

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


Measured memory_bytes: 256