akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
// using ll = boost::multiprecision::int128_t;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;


int main() {
  ll h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;

  ll ans = (h2-h1)*60 + (m2-m1);
  ans -= k;
  cout << ans << "\n";
  return 0;
}


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

int main()
{
string row;
cin >> row;
int i, count;
i = row.size();
char mozi[i];
count = 0;

for(int j = 0; j < i; j++)
	{
	mozi[j] = row.at(j);
	}
if( i%2 == 0)
	{
		for( int j = 0;j < i/2; j++)
		{
		if(row.at(j) != row.at(i-j-1))
			count++;
		}
	}
if( i%2 != 0)
	{
		for( int j = 0;j < i/2; j++)
		{
		if(row.at(j) != row.at(i-j-1))
			count++;
		}
	}
cout << count << endl;


return 0;
}

Measured memory_bytes: 256
let n = Scanf.scanf "%d" (fun x -> x)
let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x))
let () =
  for i = 0 to (n-1)/2 do
    Printf.printf "%d " a.(n-1-2*i)
  done;
  let o = n mod 2 in
  for i = 0 to n/2-1 do
    Printf.printf "%d " a.(2*i + o)
  done;
  print_newline ()

Measured memory_bytes: 8064
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	t := iSScan(n)
	ans := sum(t)
	m := iScan()
	for i := 0; i < m; i++ {
		p, x := iScan()-1, iScan()
		fmt.Println(ans - t[p] + x)
	}
}


Measured memory_bytes: 1772
#include<stdio.h>
int main(void){
  double weight;
  while(scanf("%lf",&weight)!=EOF){
    if(weight <= 48.00) printf("light fly\n");
    else if(48.00 < weight && weight <= 51.00) printf("fly\n");
    else if(51.00 < weight && weight <= 54.00) printf("bantam\n");
    else if(54.00 < weight && weight <= 57.00) printf("feather\n");
    else if(57.00 < weight && weight <= 60.00) printf("light\n");
    else if(60.00 < weight && weight <= 64.00) printf("light welter\n");
    else if(64.00 < weight && weight <= 69.00) printf("welter\n");
    else if(69.00 < weight && weight <= 75.00) printf("light middle\n");
    else if(75.00 < weight && weight <= 81.00) printf("middle\n");
    else if(81.00 < weight && weight <= 91.00) printf("light heavy\n");
    else if(91.00 < weight) printf("heavy\n");
  }
  return 0;
}

Measured memory_bytes: 608
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    // Duplicates
    // https://www.hackmath.net/en/calculator/combinations-and-permutations?n=26&k=5&order=0&repeat=1
    static class Combinations {
        long[] factorial;
        long[] facInverse;
        long[] inverse;

        void init(int n) {
            final int MAX = n + 2;
            factorial = new long[MAX];
            facInverse = new long[MAX];
            inverse = new long[MAX];
            factorial[0] = factorial[1] = 1;
            facInverse[0] = facInverse[1] = 1;
            inverse[1] = 1;
            for (int i = 2; i < MAX; i++) {
                factorial[i] = factorial[i - 1] * i % MOD;
                final long inv = inverse[i] = MOD - inverse[MOD % i] * (MOD / i) % MOD;
                facInverse[i] = facInverse[i - 1] * inv % MOD;
            }
        }

        long ncr(int n, int r) {
            if (n < r) { return 0; }
            if (n < 0 || r < 0) { return 0; }
            return factorial[n] * (facInverse[r] * facInverse[n - r] % MOD) % MOD;
        }

        long modpow(long a, long n) {
            long res = 1;
            while (n > 0) {
                if (n % 2 == 1) {
                    res = res * a % MOD;
                }
                a = a * a % MOD;
                n /= 2;
            }
            return res;
        }
    }

    private static final int MOD = (int) (1e9 + 7);

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int k = Integer.parseInt(in.nextLine());
        final int n = in.nextLine().length();
        final Combinations solver = new Combinations();
        solver.init(2 * (int) 1e6);
        long res = 0;
        for (int i = 0; i <= k; ++i) {
            final long add = solver.modpow(26, k - i) *
                             solver.ncr(n - 1 + i, i) % MOD *
                             solver.modpow(25, i) % MOD;
            res = (res + add) % MOD;
        }
        System.out.println(res % MOD);
    }
}


Measured memory_bytes: 104192
#include<iostream>

using namespace std;


int main(void){
	
	while(1){
		int n;
		cin>>n;
		
		if(n==0)break;
		
		int ans = 0;
		while(1){
			if(n==0)break;
			ans += n/5;
			n/=5;
		}
		
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
import java.util.*;
 
class Sushi{
	long v;
	long x;
	public Sushi(long a,long b){
		x = a;
		v = b;
	}
}

public class Main{	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long C = sc.nextLong();
		long ans = 0;
		if(N==1){
			long position = sc.nextLong();
			long value = sc.nextLong();
			long distance = Math.min(position, C-position);
			if(value > distance) System.out.println(value-distance);
			else System.out.println(0);
			return;
		}
		
		ArrayList<Sushi> al = new ArrayList<Sushi>();
		for(int i=0;i<N;++i) al.add( new Sushi(sc.nextLong(),sc.nextLong()) );
		Collections.sort( al, new Comparator<Sushi>(){
	        public int compare(Sushi a, Sushi b){
	          if(a.x >= b.x) return 1;
	          else return -1;
	        }
	    });
		
		long[] calL = new long[N];
		calL[0] = al.get(0).v;
		for(int i=1;i<N;++i) calL[i] = calL[i-1] + al.get(i).v;
		for(int i=0;i<N;++i) calL[i] -= al.get(i).x;
		long[] calR = new long[N];
		calR[N-1] = al.get(N-1).v;
		for(int i=N-2;i>=0;--i) calR[i] = calR[i+1] + al.get(i).v;
		for(int i=N-1;i>=0;--i) calR[i] -= (C-al.get(i).x);
		
		long[] maxL = new long[N];
		maxL[0] = Math.max(0, calL[0]);
		for(int i=1;i<N;++i) maxL[i] = Math.max(calL[i], maxL[i-1]);	
		ans = Math.max(ans, maxL[N-1]);
		long[] maxR = new long[N];
		maxR[N-1] = Math.max(0, calR[N-1]);
		for(int i=N-2;i>=0;--i) maxR[i] = Math.max(calR[i], maxR[i+1]);
		ans = Math.max(ans, maxR[0]);
		
		long now = 0;
		for(int i=0;i<N-1;++i){
			now += al.get(i).v;
			ans = Math.max(ans, maxR[i+1]+now-2*al.get(i).x);
		}
		now = 0;
		for(int i=N-1;i>0;--i){
			now += al.get(i).v;
			ans = Math.max(ans, maxL[i-1]+now-2*(C-al.get(i).x));
		}
		
		System.out.println(ans);
		return;
	}
}

Measured memory_bytes: 94856
//自称高知能系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 INF 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;
    char a, t;
    cin >> a >> t;
    if (a==t) cout << "H" << endl;
    else cout << "D" << endl;
    
    //cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

int gcd(int a,int b);

int main(){
	int a,b,c;
	while(cin >> a >> b){
		c = gcd(a,b);
		printf("%d %d\n",c,a/c*b);
	}


	return 0;
}

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

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int maxn = 4005;
constexpr int mod = 998244353;
int n,k,c[maxn][maxn],bin[maxn];

void init(){
    c[0][0] = 1;
    for(int i = 1; i <= 4000; i++){
        c[i][0] = 1;
        for(int j = 1; j <= i; j++){
            c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
        }
    }
    bin[0] = 1;
    for(int i = 1; i <= 4000; i++) bin[i] = (bin[i - 1] * 2) % mod;
}

ll calc(int p, int y){
    if(y < 0) return 0;
    ll res = 0;
    for(int q = 0; q <= p && q <= n; q++){
        if(q + y - 1 < 0) continue;
        if(n + y - 1 < q + y - 1) continue;
        ll tmp = 1ll * c[p][q] * bin[q] % mod;
        tmp = tmp * c[n + y - 1][q + y - 1] % mod;
        res = (res + tmp) % mod;
    }
    return res;
}

void work(){
    
    for(int i = 2; i <= 2 * k; i++){
        ll ans = 0;
        int cnt = 0;
        for(int j = 1; j <= k; j++){
            if(1 <= i - j && i - j <= k) cnt++;
        }
        if(i & 1) ans = calc(cnt / 2, k - cnt);
        else {
            ans += calc((cnt - 1) / 2, k - cnt);
            n--;
            ans = (ans + calc((cnt - 1) / 2, k - cnt)) % mod;
            n++; 
        }
        cout<<ans<<endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin>>k>>n;
    init();
    work();

    return 0;
}

Measured memory_bytes: 61440
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 * 
 * https://atcoder.jp/contests/abc098/submissions/14897650 にも参考
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long[] a = IntStream.range(0, n).mapToLong(i -> scanner.nextLong()).toArray();
			long answer = 0L, sum = 0L;
			int right = 0;
			for (int left = 0; left < n; left++) {
				while ((right < n) && (sum + a[right] == (sum ^ a[right]))) {
					sum += a[right];
					right++;
				}
				answer += right - left;
				sum -= a[left];
			}
			System.out.println(answer);
		}
	}
}


Measured memory_bytes: 63900
a,b,k=map(int,input().split())
ans = []
ans.append(a)
for i in range(min(k,b-a)):
    ans.append(a+i)
for j in range(min(k,b-a)):
    ans.append(b-j)
ans.append(b)
for k in range(len(set(ans))):
    print(sorted(set(ans))[k])

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;
int main(void){
    int n;
    cin>>n;
    set<long int> b;
    int c;
    for(int i=0;i<n;i++){
        long int a;
        cin>>a;
        b.insert(a);
        if(c==b.size()){
            b.erase(a);
        }
        c=b.size();
    }
    cout<<b.size()<<endl;
    return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    set<int> st;
    st.insert(0);
    vector<int> c(n,1);
    for(int i = 0;i < m;i ++){
        int x,y;
        cin >> x >> y;x --;y --;
        c[x] --;c[y] ++;
        if(st.find(x)!=st.end()) {
            if(!c[x]) st.erase(x);
            st.insert(y);
        }
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 5376
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

def main():
    N,M,K=mis()
    uf = UnionFindEx(N)
    frs = tuple(set() for _ in range(N))
    bls = tuple(set() for _ in range(N))
    for _ in range(M):
        a, b = mis()
        uf.connect(a-1, b-1)
        frs[a-1].add(b-1)
        frs[b-1].add(a-1)
    for _ in range(K):
        a, b = mis()
        bls[a-1].add(b-1)
        bls[b-1].add(a-1)
    for i in range(N):
        print(uf.getGroupSize(i) - len(frs[i]) - sum(uf.getRootID(i)==uf.getRootID(k) for k in bls[i]) - 1, end=' ')


main()







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

int main() {
    int n;
    std::cin >> n;

    int t_score = 0;
    int h_score = 0;

    for (int i = 0; i < n; ++i) {
        std::string t, h;
        std::cin >> t >> h;

        if (t == h) {
            t_score += 1;
            h_score += 1;
        } else if (t > h) {
            t_score += 3;
        } else {
            h_score += 3;
        }
    }

    std::cout << t_score << " " << h_score << std::endl;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,ans=0,k=0,nedan=0;
  cin>>n>>m;
  int a[m],b[m],memo[1000];
  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];
    if(ans<m-1){
      if(a[i]>=b[i]){
	ans++;
      }else {
	memo[k]=b[i];
	k++;
      }
    }
  }
  sort(memo,memo+k);
  if(ans<m-1){
    for(int i=0;i<k;i++){
      if(ans==m-1){
	break;
      }
      nedan+=memo[i]-n;
      ans++;
    }
  }
  cout<<nedan<<endl;
}

Measured memory_bytes: 3056
use std::io::Read;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let c = s.trim_right().as_bytes();
    let n = c.len();
    let mut res = vec!(0; n);
    let mut cnt = 0;
    for i in 0..n {
        if c[i] == 'L' as u8 {
            res[i] += cnt / 2;
            res[i-1] += (cnt + 1) / 2;
            cnt = 0;
        } else {
            cnt += 1;
        }
    }
    for i in (0..n).rev() {
        if c[i] == 'R' as u8 {
            res[i] += cnt / 2;
            res[i+1] += (cnt + 1) / 2;
            cnt = 0;
        } else {
            cnt += 1;
        }
    }
    print!("{}", res[0]);
    for i in 1..n { print!(" {}", res[i]); }
    println!("");
}


Measured memory_bytes: 4476
import bisect
N = int(input())
Ds = sorted(list(map(int,input().split())))
index = len(Ds)//2
if Ds[index]== Ds[index-1]:
    print(0)
else:
    print(Ds[index]-Ds[index-1])
    #for k in range(Ds[index-1],Ds[index]):
        #print(k)


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a = 111, i = 1;
  while (a*i < n) {
    i++;
  }
  cout << i*a << '\n';
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        s: [String; n]
    };
    let mut ans = vec![0; 4];
    for t in s.iter() {
        let idx = match t.as_str() {
            "AC" => 0,
            "WA" => 1,
            "TLE" => 2,
            "RE" => 3,
            _ => panic!(),
        };
        ans[idx] += 1;
    }
    println!("AC x {}", ans[0]);
    println!("WA x {}", ans[1]);
    println!("TLE x {}", ans[2]);
    println!("RE x {}", ans[3]);
}


Measured memory_bytes: 7816
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

count=0
for i in range(0,N):
  y=B[i]-A[i]
  if y>=0:
    count+=A[i]
    z=y-A[i+1]
    if z>=0:
      count+=A[i+1]
      A[i+1]=0
    else:
      count+=y
      A[i+1]-=y
  else:
    p=A[i]-B[i]
    count+=B[i]
print(count)

Measured memory_bytes: 18476
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*
--------------------------------------------

	Optimizer

--------------------------------------------
*/
//#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*
--------------------------------------------
 
	Utility Algorithm

-------------------------------------------- 
*/

template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}
 
template <typename T1>
T1 euclideanAlgorithm(T1 a, T1 b) {
    T1 a_tmp = a;
    T1 b_tmp = b;
 
    if (a_tmp > b_tmp) {
        swapAlgorithm<T1>(a_tmp, b_tmp);
    }
 
    T1 r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

template <typename T2>
T2 getLCM(T2 a, T2 b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        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);
    }
};

const int INF = 1001001001;

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

    int H,N;
    cin >> H >> N;
    vector<int> dp(H+1, INF);
    dp[0] = 0;
    for(int i=0; i<N; i++) {
        int a, b;
        cin >> a >> b;
        for(int j=0; j<H; j++) {
            int nj = min(j+a,H);
            dp[nj] = min(dp[nj], dp[j]+b);
        }
    }

    cout << dp[H] << endl;
    return 0;

}

Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,k;
  cin >> n >> k;
  int sum =0;

  rep(i,n)
  {
    int x;cin >> x;
    sum += min(x,k - x);
  }

  cout << sum * 2 << endl;
  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int E=A+B, F=C+D;
  if (E>F){
    cout << "Left" << endl;
  }
  if (E==F){
    cout << "Balanced" << endl;
  }
  if (E<F){
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
AC=0
WA=0
TLE=0
RE=0
for i in range(n):
  s = input()
  if s=="AC":
    AC+=1
  elif s=="WA":
    WA+=1
  elif s=="TLE":
    TLE+=1
  elif s=="RE":
    RE+=1
print("AC x",AC)
print("WA x",WA)
print("TLE x",TLE)
print("RE x",RE)

Measured memory_bytes: 9204
#include<stdio.h>
#define MAX 150
int graph[MAX][MAX];
int d[MAX],f[MAX];
int time=0,n;

void dfs(i){
  int j;
  time++;
  d[i]=time;
  for(j=0;j<n;j++){
    if(graph[i][j]!=0 && d[j]==0){
      dfs(j);
    }
  }
  time++;
  f[i]=time;
}

int main(){
  int u,k,v;
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      graph[u-1][v-1]=1;
    }
  }
  for(i=0;i<n;i++){
    if(d[i]==0) dfs(i);
  }

  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}



Measured memory_bytes: 2112
/*
	Nishant Singh
	nishant.ns19@gmail.com
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 
// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********
// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ook order_of_key    //count of strictly smaller elements
// #define fbo find_by_order   //find element at an index 
// ******** Using PBDS ********
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=998244353;
ll const inf=2e18;
// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********
inline ll add(ll a,ll b) 
{ 
	return (a%mod + b%mod + mod)%mod; 
}
inline ll mul(ll a,ll b) 
{ 
	return (a%mod * b%mod + mod)%mod; 
}
inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}
ll gcd(ll a,ll b)
{
	if (b == 0) 
		return a; 
	return gcd(b, a % b);  
}
ll modexp(ll x, ll n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
ll modinv(ll n)
{
	return modexp(n,mod-2);
}
// ******** GLOBAL VARIABLES ********
// ******** GLOBAL VARIABLES ********
void solve(){
	ll n,k;
	cin>>n>>k;
	pll a[n];
	REP(i,k){
		cin>>a[i].f>>a[i].s;
	}
	ll dp[n+5];
	ll pre[n+5];
	init(dp,0);
	init(pre,0);
	pre[n]=1;
	dp[n]=1;
	for(ll i=n-1;i>=1;i--){
		REP(j,k){
			int l=min(i + a[j].f, n + 1);
			int r=min(i + a[j].s, n + 1);
			dp[i]=add(dp[i],sub(pre[l],pre[r+1]));
		}
		// cout<<dp[i]<<" ";
		pre[i]=pre[i+1]+dp[i];
	}
	cout<<dp[1];
}  
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

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

int n, w;
long long dp[101][100002], ans=0;
pair<int,long long>item[101];

void max_self(long long &a, long long b){
	a=max(a,b);
}

int main(){
	memset(dp,-1,sizeof dp);
	dp[0][0]=0;
	cin >> n >> w;
	for (int i=0;i<n;i++) cin >> item[i].first >> item[i].second;
	for (int i=0;i<n;i++){
		for (int j=0;j<=w;j++){
			if (dp[i][j]==-1) continue;
			max_self(dp[i+1][j],dp[i][j]);
			if (j+item[i].first<=w) max_self(dp[i+1][j+item[i].first],dp[i][j]+item[i].second);
		}
	}
	for (int i=0;i<=w;i++) max_self(ans,dp[n][i]);
	cout << ans << "\n";
}

Measured memory_bytes: 79104
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using ll = long long;
signed
main(){
    int n,m;
    std::cin >> n >> m;
    std::vector<std::pair<ll,ll>>v;
    for(int i = 0; i < n; ++i){
        ll val;
        std:: cin >> val;
        v.push_back(std::make_pair(val,1LL));
    }
    for(int i = 0; i < m; ++i){
        std::pair<ll,ll>p;
        std::cin >> p.second  >> p.first;
        v.push_back(p);
    }
    std::sort(v.begin(),v.end(),std::greater<>());
    ll cnt = 0, sum = 0;
    for(auto p : v){
        if(cnt + p.second <= n){
            sum += p.second * p.first;
            cnt += p.second;
        } else {
            ll margin = n - cnt;
            sum += margin * p.first;
            break;
        }
    }
    std::cout << sum << std::endl;
}



Measured memory_bytes: 6256
#include<iostream>
int main(){
	int N,n, T, E,high,low;
	std::cin >> N >> T >> E;
	high = T + E;
	low = T - E;
	for (int i = 0; i < N; i++){
		std::cin >> n;
		if (high / n != 0){
			if (n*(high/n)>=low){
				std::cout << i + 1<<"\n";
				return 0;
			}
		}
	}
	std::cout << -1 << "\n";

}

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

#define   M             100005
#define   ll            long long
#define   PI            atan(1.0)*4
#define   mst(x,v)      memset(x,v,sizeof(x))
#define   inf           (int)1e9

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

	
	if( a%b  == 0)
		puts("-1");
	else {
		ll temp=a;
		while(1) {
			a+=temp;
			if(a%b!=0) break;
		}
		printf("%d\n",a);
	}
}




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

using namespace std;

const int nmax=8;
bool pass[nmax][nmax];

int dfs(int v,int n,bool *visited){

  bool all_visited=true;
  for(int i=1;i<n;i++){
   if(!visited[i]) all_visited=false;
  }
  if(all_visited) return 1;
  
  int ret=0;
  for(int i=0;i<n;i++){
   if(!pass[v][i]) continue;
   if(visited[i]) continue;
    
    visited[i]=true;
    ret+=dfs(i,n,visited);
    visited[i]=false;
  }
    
  return ret;

}

int main(){
 int n,m;
  cin >> n >> m;
 
 pass[nmax][nmax]={false};
  for(int i=0;i<m;i++){
   int a,b;
    cin >> a >> b;
    pass[a-1][b-1]=pass[b-1][a-1]=true;
  }
  
  bool visited[nmax]={false};
 
   visited[0]=true;
  
  cout << dfs(0,n,visited) << endl;
   

}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    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);
    }
};

vector<ll> dp;
const ll MOD = 1e9 + 7;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m;
    cin >> n >> m;
    dp.assign(n + 1, -1);
    dp[0] = 1;
    dp[1] = 1;
    F0R(i, m)
    {
        int t;
        cin >> t;
        dp[t] = 0;
    }
    FOR(i, 2, dp.sz())
    {
        if(dp[i] == 0) continue;
        dp[i] = (dp[i - 1] + dp[i - 2])%MOD;
    }
    cout << dp[n];
    return 0;
}

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

int main(){
    int x[3];
    for(int i;i<2;i++){
    x[i] = 0;
}
    int a=0,b=0;
    cin >> a >>b;



    x[0]=a+b;
    x[1]=a-b;
    x[2]=a*b;
    int max=x[0];
    for(int i=0;i<2;i++){
        if(max<x[i+1]){
            max=x[i+1];
        }
    }
    
    
    cout << max <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    int n;
    scanf("%d",&n);
    int a[110];
    memset(a,1,sizeof(a));
    for(int i = 1;i<=100;i++){
        if(i % 4 == 0 || i % 7 == 0){
            a[i] = 0;
        }else if(!(i - 4 < 0) && (a[i - 4] == 0 || a[i - 7] == 0)){
            a[i] = 0;
        }else{
            a[i] = 1;
        }
        // printf("a[%d]=%d\n",i,a[i]);
    }
    // printf("%d\n",a[2 % 4]);
    // printf("%d\n",a[2 % 7]);
    if(a[n] == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<long long int> erat(n+1,1);
  for (int i = 2; i <= n; i++){
    for (int j = 1; j <= n/i; j++){
      erat.at(i*j)++;
    }
  }
  long long int ans=0;
  for (int i = 1; i < n+1; i++){
    ans=ans+i*erat.at(i);
  }

  cout << ans << endl;
}

Measured memory_bytes: 81412
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

long long POW(long long x,long long n,long long mod){
  long long ans = 1;
  while(n){
    if(n%2)ans *= x;
    x *= x;
    x %= mod;
    ans %= mod;
    n >>= 1;
  }
  return ans;
}
vector<long long> factorial(2,1);
long long nckmodp(long long n,long long k,long long p){
  if(n < k || n <= 0 || k < 0)return 0;
  while(factorial.size() <= n){
    long long i = factorial.size();
    factorial.push_back(i*factorial[i-1]%p);
  }
  return ((factorial[n]*POW(factorial[k],p-2,p))%p)*POW(factorial[n-k],p-2,p)%p;
}
long long TwelvefoldWay6(long long n,long long k,long long MOD){
  return nckmodp(max((long long)1,n-1),k-1,MOD);
}

signed main(){
  ll n,k;
  cin >> n >> k;
  cout << TwelvefoldWay6(n,k,INF) << endl;
}


Measured memory_bytes: 3172
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    int h, w;
    cin >> h >> w;
    string s[h];
    rep(i, h) cin >> s[i];
    int u[h][w], d[h][w], r[h][w], l[h][w];
    for (int i = 0; i < h; i++){
        int num = 0;
        for (int j = 0; j < w; j++){
            if(s[i][j] == '.') num++;
            else num = 0;
            r[i][j] = num;
        }
    }
    for (int i = 0; i < h; i++){
        int num = 0;
        for (int j = w - 1; j >= 0; j--){
            if(s[i][j] == '.') num++;
            else num = 0;
            l[i][j] = num;
        }
    }
    for (int i = 0; i < w; i++){
        int num = 0;
        for (int j = 0; j < h; j++){
            if(s[j][i] == '.') num++;
            else num = 0;
            u[j][i] = num;
        }
    }
    for (int i = 0; i < w; i++){
        int num = 0;
        for (int j = h - 1; j >= 0; j--){
            if(s[j][i] == '.') num++;
            else num = 0;
            d[j][i] = num;
        }
    }
    int ans = 0;
    rep(i, h){
        rep(j, w){
            if(s[i][j] == '#') continue;
            ans = max(ans, r[i][j] + l[i][j] + u[i][j] + d[i][j] - 3);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 73696
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
#include <complex>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-6;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL mod = 1000000007;
const LL MAX = 1e5 + 47;
const LL MAXN = 2e5 + 47;

int n;
VPLL a;
VLD ans;

inline LD dist(PLL x, PLL y)
{
	return sqrt(.0+(x.X - y.X) * (x.X - y.X) + (x.Y - y.Y) * (x.Y - y.Y));
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	cin >> n;
	a.resize(n);
	ans.assign(n, 0);
	FOR(i, 0, n)
		cin >> a[i].X >> a[i].Y;

	FOR(i, 0, n)
	{
		VLD kuty;
		FOR(j, 0, n)
			if (i != j)
				kuty.push_back(atan2((a[i].Y - a[j].Y + 0.0) , (a[i].X - a[j].X + 0.0)));

		LD res = 0;
		sort(ALL(kuty));
		FOR(j, 0, SZ(kuty) - 1)
			res = max(res, kuty[j + 1] - kuty[j]);
	
		res = max(res, 2*PI -( kuty.back() - kuty[0]));
		if (res <= PI)
			continue;
		ans[i] = (res -PI)/ (2 * PI);
	}

	FOR(i, 0, n)
		cout << fixed << setprecision(10) << ans[i] << endl;
	cin >> n;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3];
     cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==5 && a[1]==5 && a[2]==7)
      cout<<"YES";
    else
        cout<<"NO";
}


Measured memory_bytes: 3548
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int height = reader.nextInt();
		int width = reader.nextInt();
		
		String[] inputArray = new String[height];

		for (int i = 0; i < height; i++) {
			inputArray[i] = reader.next();
		}
		
		System.out.println(String.join("", Collections.nCopies(width + 2, "#")));
		for (int i = 0; i < height; i++) {
			System.out.println("#" + inputArray[i] + "#");
		}
		System.out.println(String.join("", Collections.nCopies(width + 2, "#")));

		reader.close();
	}
}

Measured memory_bytes: 21972
#include <iostream>
#define llint long long

using namespace std;

llint x;

int main(void)
{
	cin >> x;
	
	llint ans = x / 11 * 2;
	if(x % 11 == 0) ans += 0;
	else if(x % 11 <= 6) ans += 1;
	else ans += 2;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct Card{
  char suit,value;
};

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

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

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

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

int main(){
  struct Card C1[100],C2[100];
  int N,i;
  char ch;
  cin >> N;
  for(i=0;i<N;i++){
    cin >> C1[i].suit >> C1[i].value;
  }
  for(i=0;i<N;i++)C2[i]=C1[i];

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

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

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

const LL INFLL = 999999999999999LL;

template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){fill((T*)array,(T*)(array+N),val);}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

LL dp[100005];
int main(){
    int n,k;
    cin>>n>>k;

    Vi h(n);
    for(int i=0; i<n; i++){
        cin>>h[i];
    }

    FILL(dp,INFLL);
    dp[0]=0;

    for(int i=1; i<n; i++){
        for(int j=1; j<=((i-k>=0)?k:i); j++) chmin(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
    }

    cout<<dp[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint int
using namespace std;
     
typedef long long lo;
     
template<typename tp> inline void read(tp &x) {
	x = 0; char c = getchar(); int f = 0;
	for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
	for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
	if (f) x = -x;
}
namespace {
    const int mo = 998244353;
    inline int add(int x, int y) { x += y; return x >= mo ? x - mo : x; }
    inline int sub(int x, int y) { x -= y; return x < 0 ? x + mo : x; }
    inline int mul(int x, int y) { return (lo) x * y % mo; }
    inline int power(int a, int k = mo - 2) {
		int ans = 1;
		for (; k; k >>= 1, a = mul(a, a))
			if (k & 1) ans = mul(ans, a);
		return ans;
    }
	inline void U(int &x, int y) { x = add(x, y); } 
}
const int N = (1 << 18) + 3;
int n, m, p[N], sum, r[N];

inline void FWT(int *p, int f) {
	int n = ::m;
	for (int l = 2; l <= n; l <<= 1)
		for (int *a = p, m = l >> 1; a != p + n; a += l)
			for (int k = 0; k < m; k++) {
				int x = a[k], y = a[k + m];
				a[k] = add(x, y); a[k + m] = sub(x, y);
			}
	if (f == -1) {
		int mult = power(n);
		for (int i = 0; i < n; i++)
			p[i] = mul(p[i], mult);
	}
}

int main(void) {
	read(n); m = 1 << n;
	for (int i = 0; i < m; i++) {
		read(p[i]); sum += p[i];
	}
	sum = power(sum);
	for (int i = 0; i < m; i++) {
		p[i] = mul(p[i], sum);
		r[i] = mo - 1;
	}
	r[0] = m - 1;
	p[0] = sub(p[0], 1);
	FWT(r, 1); FWT(p, 1);
	for (int i = 0; i < m; i++) 
		r[i] = mul(r[i], power(p[i]));
	FWT(r, -1);
	for (int i = 0; i < m; i++) {
		cout << sub(r[i], r[0]) << "\n";
	}
}


Measured memory_bytes: 4864
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, K = lr()
    MOD = pow(10, 9)+7
    ans = 0
    for i in range(K, N+2):
        ans += i*(N-i+1)+1
        ans %= MOD
    print(ans)
resolve()

Measured memory_bytes: 62992
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
int main()
{
  ll x;
  cin>>x;
  ll a=100;
  ll count=0;
  while(a<x)
  {
  	a+=a/100;
  	count++;
  }
  cout<<count;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define sort stable_sort 
using namespace std; 

int _; 

int n,fcnt,scnt;
bool vis[100050],F[100050],S[100050];
vector<int> G[100050],path;

bool dfs(int u)
{
	vis[u]=true;
	if(u == n)
		return true;
	for(auto v : G[u])
	{
		if(!vis[v] && dfs(v))
		{
			path.push_back(v); 
			return true;	
		} 
	}
	return false;
}

void fdfs(int u)
{
	F[u]=true;
//	D(u);
	fcnt++;
	for(auto v : G[u])
	{
	//	D(v);D(path);D(F[v]); 
		if(!F[v])
			fdfs(v);
			} 
}

void sdfs(int u)
{
	S[u]=true;
	scnt++;
	for(auto v : G[u])
		if(!S[v])
			sdfs(v);
}


int main()
{	
	//for(scanf("%d",&_);_;_--)
	scanf("%d",&n);
	for(int i=0;i<n-1;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1);
	path.push_back(1); 
	for(int i=0;i<(path.size() >> 1);i++)
		F[path[i]]=true; 
	for(int i=(path.size() >> 1);i<path.size();i++)
		S[path[i]]=true; 
	fdfs(1);
	sdfs(n);
	//D(fcnt,scnt);
	printf(fcnt>scnt ?"Fennec\n":"Snuke\n"); 
	return 0;
}  

Measured memory_bytes: 15952
N=int(input())
while True:
    try:
        listA=list(map(int,input().split()))
        #listA<-[1,2,2,3,1]
        #ここに逐次処理を書けばいいと思う。
    except:
        break;

product=1
for i in listA:
  if product<10**18+1:
  	product=product*i
    
if listA.count(0)>0:
  print(0)
    
elif product<10**18+1:
  print(product)
  
elif product>=10**18+1:
  print(-1)


Measured memory_bytes: 21660
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N; 
ll D;
ll arr[25];

int main() {
	scanf("%lld %lld", &N, &D);
	int ans = N;
	
	ans = min(ans * 1.0, ceil(N / (2.0 * D + 1)));
	printf("%d\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

const int N = 200005, inf = 1e9;

int n, dt[N][2];
char a[N];

int main()
{
	scanf("%s",a+1);
	n = strlen(a+1);
	for(int i=1;i<=n;i++) {
		dt[i][0] = dt[i][1] = -inf;
	}
	for(int i=1;i<=n;i++) {
		if(i > 1) {
			dt[i][1] = max(dt[i][1], dt[i-2][0] + 1);
			if(i < 4 || a[i-3] != a[i-1] || a[i-2] != a[i]) dt[i][1] = max(dt[i][1], dt[i-2][1] + 1);
		}
		dt[i][0] = max(dt[i][0], dt[i-1][1] + 1);
		if(i < 2 || a[i-1] != a[i]) dt[i][0] = max(dt[i][0], dt[i-1][0] + 1);
	}
	printf("%d\n", max(dt[n][0], dt[n][1]));
}


Measured memory_bytes: 2048
def main():
    s = input()
    n = len(s)
    k = int(input())
    # dp[使った回数][左端からの距離][左端]
    dp = [[[1]*(n-i) for i in range(n)] for _ in range(k+1)]

    if n == 1:
        print(1)
        return
    dp2 = dp[0][1]
    for i in range(n-1):
        if s[i] == s[i+1]:
            dp2[i] = 2
    if k > 0:
        for cnt in range(1, k+1):
            dp2 = dp[cnt][1]
            for i in range(n-1):
                dp2[i] = 2

    for cnt in range(k):
        dp2 = dp[cnt]
        dp4 = dp[cnt+1]
        for d in range(2, n):
            dp3 = dp2[d]
            dp5 = dp2[d-1]
            dp6 = dp2[d-2]
            dp7 = dp4[d]
            for left in range(n-d):
                right = left+d
                plus = (s[left] == s[right])*2
                dp3[left] = max(
                    dp3[left], dp5[left],
                    dp5[left+1], dp6[left+1]+plus)
                dp7[left] = max(
                    dp7[left], dp3[left], dp6[left+1]+2)
    dp2 = dp[k]
    for d in range(2, n):
        dp3 = dp2[d]
        dp4 = dp2[d-1]
        dp5 = dp2[d-2]
        for left in range(n-d):
            right = left+d
            plus = (s[left] == s[right])*2
            dp3[left] = max(
                dp3[left], dp4[left], dp4[left+1], dp5[left+1]+plus)
    print(dp[-1][-1][0])


main()


Measured memory_bytes: 154076
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    vector<ll> sub(N);
    vector<ll> sub_sum(N+1, 0);
    rep(i, N) sub[i] = A[i] - B[i];
    sort(sub.begin(), sub.end(), greater<int>());
    for(int i = 1; i < N+1; i++){
        sub_sum[i] = sub_sum[i-1] + sub[i-1];
    }
    ll lack_sum = 0;
    ll margin = 0;
    ll ans = 0;
    rep(i, N){
        if(A[i] < B[i]){
            lack_sum += (B[i] - A[i]);
            ans++;
        }else{
            margin += (A[i] - B[i]);
        }
    }
    if(margin < lack_sum){
        cout << -1 << endl;
        return 0;
    }
    rep(i, N+1){
        if(lack_sum <= sub_sum[i]){
            ans += i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6360