akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;

const int MAX_N = 2e5 + 5;
lint A[MAX_N], S[MAX_N];

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int N; cin >> N;
    for(int i=1;i<=N;i++) {cin >> A[i]; A[i] += A[i-1];}

    lint ans = 1e15;
    for(int i=2;i<N-1;i++){
        int j = distance(A, lower_bound(A, A+i+1, A[i]/2));
        int k = distance(A, lower_bound(A+i+1, A+N+1, A[i]+(A[N]-A[i])/2));

        lint a, b, c, d;
        if(abs(A[i]-2*A[j]) < abs(A[i]-2*A[j-1])) {a = A[j], b = A[i]-A[j];}
        else {a = A[j-1], b = A[i]-A[j-1];}
        if(abs(A[N]-2*A[k]+A[i]) < abs(A[N]-2*A[k-1]+A[i])) {c = A[k]-A[i], d = A[N]-A[k];}
        else {c = A[k-1]-A[i], d = A[N]-A[k-1];}
        ans = min(ans, max(max(a, b), max(c, d))-min(min(a, b), min(c, d)));
    }

    cout << ans << endl;
    return 0;
}

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

int main()
{
  int N;
  cin >> N;
  vector<int64_t> C(N - 1), S(N - 1), F(N - 1);
  for (int i = 0; i < N - 1; i++)
  {
    cin >> C.at(i) >> S.at(i) >> F.at(i);
  }
  for (int i = 0; i < N - 1; i++)
  {
    int64_t t = 0;
    for (int j = i; j < N - 1; j++)
    {
      int64_t nextf = F.at(j) * ((t + F.at(j) - 1) / F.at(j));
      t = max(S.at(j), nextf);
      t += C.at(j);
    }
    cout << t << endl;
  }
  cout << 0 << endl;
}


Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define mp make_pair
#define ll long long
#define SIZE 1005
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, k, c;
int main() {
	io(); cin >> n >> k >> c;
	string s; cin >> s;
	int pos = -1, res = 0;
	set<int> st, st2;
	rep(i, 0, (s.length() - 1)) {
		if (pos >= i) continue;
		if (s[i] == 'x') continue;
		if (st.size() == k) {
			++res;
			break;
		}
		pos = i + c;
		st.insert(i);
		//cout << i << ' ';
	}
	if (res) return 0;
	pos = s.length();
	for (int i = s.length() - 1; i >= 0; --i) {
		if (s[i] == 'x') continue;
		if (pos <= i) continue;
		if (st2.size() == k) {
			++res;
			break;
		}
		pos = i - c;
		if (st.count(i)) st2.insert(i);
		//cout << i << ' ';
	}
	if (res) return 0;
	//cout << st2.size() << '\n';
	for (auto i : st2) cout << i + 1 << '\n';
}


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

int main() {
	int n;
	cin >> n;
	int a[n];
	for (auto &i : a) {
		cin >> i;
	}
	bitset<4000001> s, t;
	s[0] = 1;
	for (auto &i : a) {
		t = s | (s << i);
		swap(s, t);
	}
	for (int sum = (accumulate(a, a + n, 0) + 1) / 2; ; sum++) {
		if (s[sum]) {
			cout << sum << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 2816
A,B = map(int,input().split())
cnt = 0
for i in range(A,B+1):
  a = i//10000
  i = i%10000
  b = i//1000
  i = i%1000
  c = i//100
  i = i%100
  d = i//10
  e = i%10
  if b==d and a==e:
    cnt+=1
print(cnt)

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

int main() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ans=0,x=k-a-b;
    if(x<0) x=0; 
    ans = min(a,k)-min(c,x);
  cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def factorize(n, d):
  # if n == 0 or n == 1:
    # return []
    arr = []
    tmp = n
    while True:
      i = d[tmp]
      if i == 1:
        break
      #cnt=0
      while tmp%i==0:
        #cnt+=1
        tmp //= i
      arr.append(i)
    if tmp!=1:
      arr.append(tmp)
    if arr==[]:
      arr.append(n)
    return arr

def minimum_prime(n):
  # 試し割りをする際の最小の素数
  # エラトステネスの篩と同様の実装
    d = list(range(n+1))
    d[0] = 1
    for i in range(2, int(n**0.5) + 1):
        if d[i] != i:
          continue
        for j in range(i * 2, n + 1, i):
          if d[j] == j:
            d[j] = i
    return d  

def main():
  n = int(input())
  arr = list(map(int, input().split()))
  max_arr = max(arr)
  d = minimum_prime(max_arr)
  dp = [0]*(max_arr+1)
  
  if gcd(*arr) != 1:
    print('not coprime')
    exit()
  
  searched = []
  for a in arr:
    if a != 1:
      primes = factorize(a, d)
      for p in primes:
        dp[p] += 1

  if max(dp) < 2:
    print('pairwise coprime')
  else:
    print('setwise coprime')
    

main()

Measured memory_bytes: 127748
#include<bits/stdc++.h>
using namespace std;
int num[10000];
char a[100000];
int main(){
    memset(num,0,sizeof(num));
    scanf("%s",a);
    int len = strlen(a);
    for(int i = 0; i < len; i++)
        num[a[i]]++;
    int flag = 1;
    for(int i = 0; i < 10000 ; i++)
        if(num[i]>=2){
            flag = 0;
            break;
        }
    printf("%s\n",flag?"yes":"no");

    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	while (K--) {
		vector<int>w(N);
		for (int i = 0; i < N; i++) {
			w[max(0, i - v[i])]++;
			if (i + v[i] + 1 < N)w[i + v[i] + 1]--;
		}
		for (int i = 1; i < N; i++)w[i] += w[i - 1];
		v = w;
		if (*min_element(w.begin(), w.end()) == N)K = 0;
	}
	for (auto i : v)cout << i << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 4948
def fib(n):
    if n <= 1:
        return n
    result = [1, 0, 0, 1]
    matrix = [1, 1, 1, 0]
    while n > 0:
        if n % 2:
            result = mul(matrix, result)
        matrix = mul(matrix, matrix)
        n //= 2
    return result[2]

def mul(a, b):
    return [a[0]*b[0] + a[1]*b[2],
            a[0]*b[1] + a[1]*b[3],
            a[2]*b[0] + a[3]*b[2],
            a[2]*b[1] + a[3]*b[3]]


n, m = [int(i) for i in input().split()]
a = []
frag = 1
ans = 0
step = []
for i in range(m):
    a.append(int(input()))
for i in range(m-1):
    if(a[i] == a[i+1] - 1):
        frag = 0
if(frag == 0):
    ans = 0
else:
    ans = 1
    sirusi = 0
    for i in range(len(a)):
        step.append(a[i] - 1 - sirusi)
        sirusi = a[i] + 1
    step.append(n - sirusi)
    for i in range(len(step)):
        ans = ans * fib(step[i]+1)
    ans = ans % 1000000007
print(ans)

Measured memory_bytes: 7076
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define F first
#define S second

#define ALL(x)      (x).begin(), (x).end()
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#ifndef ONLINE_JUDGE
#define DBG(x)      cout << __LINE__ << " says: " << #x << " = " << (x) << endl
#else
#define DBG(x)
#endif

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 2e5+7;

void solve(const vector<LL>&arr,int k)
{
    int n  = arr.size();

    LL window = 1;
    LL prev = -1;
    LL no = -1;

    for (int i = 0; i < n; i++)
    {
        LL cur = arr[i];

        if (i >= k)
        {
            if(cur>arr[i-k]) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
}


int main()
{
    optimizeIO();

    int tc = 1;

    while(tc--)
    {
        int n,k;
        cin>>n>>k;

        vector<LL>v(n);

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

        solve(v,k);
    }

    return 0;
}

/**
5
5
1000000000
1000000000
1000000000
1000000000
1000000000
**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




Measured memory_bytes: 4768
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto ss = reads!string;
    int a = ss[0].to!int;
    int b = ss[2].to!int;

    switch (ss[1]) {
    case "+":
        writeln(a + b);
        break;
    case "-":
        writeln(a - b);
        break;
    default: break;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char n;
int main()
{
	int sum=0;
	while(cin>>n)
	{
		n=(int)n;
		sum=sum+n-48;
	}
	if(sum%9==0)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


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

namespace
{
int N;
int M;
int a[ 60 ];
int b[ 60 ];
int c[ 60 ];
int d[ 60 ];
int iAns[ 60 ];
}

int main( int argc, char *argv[] )
{
int i;
int j;
int iMin;
int iChk;

	cin >> N;
	cin >> M;
	for( i = 1; i <= N; i++ ) cin >> a[ i ] >> b[ i ];
	for( j = 1; j <= M; j++ ) cin >> c[ j ] >> d[ j ];

	for( i = 1; i <= N; i++ )
	{
		j = 1;
		iAns[ i ] = j;
		iChk = abs( a[ i ] - c[ j ] ) + abs( b[ i ] - d[ j ] );
		iMin = iChk;
		for( j = 2; j <= M; j++ )
		{
			iChk = abs( a[ i ] - c[ j ] ) + abs( b[ i ] - d[ j ] );
			if( iMin > iChk )
			{
				iAns[ i ] = j;
				iMin = iChk;
			}
		}
	}

	for( i = 1; i <= N; i++ ) cout << iAns[ i ] << endl;

	return 0;

}




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

const int mod = 1000000007;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
int remod(LL x) { x %= mod; return x + (x >> 63 & mod); }

const int MAXN = 1000010;
int f[MAXN], g[MAXN];

int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	int ans = 0, n; std::cin >> n;
	f[0] = g[0] = 1;
	for (int i = 1; i <= n; ++i) {
		reduce(f[i] += f[i - 1] - mod);
		if (i - 3 >= 0) reduce(f[i] += g[i - 3] - mod);
		reduce(g[i] = f[i] + g[i - 1] - mod);
		reduce(ans += mul(f[i - 1], std::min(i, n - 1)) - mod);
		if (i + 1 <= n)
		reduce(ans += mul(f[i - 1], mul(n - 1, n - 1)) - mod);
	}
	reduce(ans += f[n] - mod);
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 8064
#include<stdio.h>
#include<math.h>
#define compile 1
#define FIRST_PRIME 2
#define TRUE 1
#define FALSE 0
void func_init_array(int array[], int n);
int func_prime(int array[], int n);
int func_prime_counter(int array[], int n);
void func_output(int array[], int n);
main()
{
	int n = 0, result = 0;
	while(scanf("%d", &n) != EOF)
	{
		int number[n];
		func_init_array(number, n);
		result = func_prime(number, n);
		printf("%d\n", result);
	}
	//func_output(number, n);
	return 0;
}
void func_init_array(int array[], int n) //デバッグ済み
{
	int i = FIRST_PRIME;
	for(i = FIRST_PRIME; i <= n; i++)
	{
		array[i] = TRUE;
	}
}
void func_output(int array[], int n)
{
	int i = FIRST_PRIME;
	for(i = FIRST_PRIME; i < n; i++)
	{
		printf("array[%d] = %d\n", i, array[i]);
	}
}
int func_prime(int array[], int n)
{
	int root_n = sqrt(n);
	int i = FIRST_PRIME, j = 0;
	int result = 0;
	for(i = FIRST_PRIME; i <= root_n; i++)
	{
		if(array[i] == TRUE)
		{
			j = i;
			for(j += i; j <=n; j += i)
			{
				if((j % i) == 0)
				{
					array[j] = FALSE;
				}
			}
		}
	}
	//func_output(array, n);
	result = func_prime_counter(array, n);
	return result;
}
int func_prime_counter(int array[], int n)
{
	int counter = 0, i = FIRST_PRIME;
	for(i = FIRST_PRIME; i <= n; i++)
	{
		if(array[i] == TRUE)
		{
			counter++;
		}
	}
	return counter;
}

Measured memory_bytes: 4500
# coding: utf-8
# Your code here!
# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ！！

N=int(input())
count=0
for i in range(1,N+1):
    if i % 3 ==0 or i % 5==0:
        continue
    else:
        count+=i
print(count)

Measured memory_bytes: 9084
n,k=map(int,input().split())
d=input().split()
while 1:
    t=0
    p=list(str(n))
    q=len(p)
    for c in range(q):
        if t==1:
            break
        for b in range(k):
            if p[c]==d[b]:
                r=10**(q-c-1)
                n=int(n/r+1)*r
                t=1
                break
    if t==0:
        break
print(n)

Measured memory_bytes: 3060
n = int(input())
#s = input()
#a,b= map(int,input().split())
#da = list(map(int,input().split()))
#a = [int(input()) for i in range(n)]

da = [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]
print(da[n-1])

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    int x,y;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0 && y==0){
            break;
        }else if(x<y){
            printf("%d %d\n",x,y);
        }else{
            printf("%d %d\n",y,x);
        }
    }
    return 0;
}


Measured memory_bytes: 1980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;

map<ll,ll> mp; 

void factorsFactorial(ll n){
    vector<bool> nPrime(n+1);
    for(int i = 2;i < n+1;i ++){
        if(nPrime[i]) continue;
        ll si = i*2;
        while(si<n+1) {nPrime[si]=1;si+=i;}
    }
    for(int i = 2;i < n+1;i ++){
        if(nPrime[i]) continue;
        ll si = i;
        while(n/si){
            mp[i] += n/si;
            si *= i;
        }
    }
}

int main(){
    ll n,ans=1;
    cin >> n;
    factorsFactorial(n);
    for(auto ite = mp.begin();ite != mp.end();++ite){
        ans = ans*(ite->second+1)%mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BIncrementDecrement {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    string s;
	    in >> n >> s;
	    int res = 0;
	    int x = 0;
	    for(int i=0; i<n; i++){
            if(s[i] == 'I') x++;
            else x--;
            chmax(res, x);
	    }

	    out << res << endl;
	}
};


int main() {
	BIncrementDecrement solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = InputNumList();
            var n = a[0];
            var k = a[1];
            var q = a[2];
            int[] f = new int[100010];
            for (int i = 0; i < q; i++)
            {
                var tmp = InputNum();
                f[tmp]++;
            }
            for (int i = 1; i <= n; i++)
            {
                if (k - q + f[i] > 0)
                {
                    WriteLine("Yes");
                }
                else
                {
                    WriteLine("No");
                }
            }
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 17856
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
int kaijou(int n){
    int a=1;
  if(n==0){
    return 1;
  }
    REP(i,n){
        a*=i+1;
    }
    return a;
}
int ncr(int n,int r){
  int a;
  if(n<0||r<0||n<r){
    return 0;
  }
  a=kaijou(n)/kaijou(r)/kaijou(n-r);
  return a;
}
//cout << setprecision(123);
int main(){
  ll L,R,ans=inf;
  ll aaa;
  cin>>L>>R;
  bool ok=false;
  
  if(R-L>=672)cout<<0<<endl;
  else{
   for(ll i=L;i<R;i++){
     for(ll j=i+1;j<R+1;j++){
       aaa=i*j;
       ans=min(ans,aaa%2019);
       if(ans==0){
         ok=true;
         break;
       }
     }
       if(ok){
         break;
       }
   }
  
  
  cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int

using namespace std;
const double pi = 3.14159265358979323846;
int main () {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    ll hour,minutes;double h1,m1,angle;
    hour=h;minutes=m;
     h1 = (hour%12 * 30) + ((double)minutes/60 * 30);
        
         // Degree covered by minute hand (Each minute = 6 degree)
         m1 = minutes * 6;
        
         // Absolute angle between them
         angle = abs(m1 - h1);
        
         // If the angle is obtuse (>180), convert it to acute (0<=x<=180)
        if (angle > 180) angle = 360.0 - angle;
        double c=cos((angle*pi)/180);
         double ans=a*a+b*b-2*a*b*c;
         double x=sqrt(ans);
        cout<<setprecision(15)<<x<<endl;
        
    return 0;
}



Measured memory_bytes: 4168
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

typedef struct UnionFindTree{
  vector<int> par;
  vector<int> treerank;
  
  UnionFindTree(int n){
    par.resize(n); treerank.resize(n);
    rep(i, n) par[i] = i, treerank[i] = 0;
  }
  
  int find(int x){
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }
  
  void unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return;
    if(treerank[x] < treerank[y]) swap(x, y);
    if(treerank[x] == treerank[y]) treerank[x]++;
    par[y] = x;
    return;
  }
  
  bool same(int x, int y){
    return find(x) == find(y);
  }
}UF;
 
template<class T> struct edge{
    int from, to; T cost;
    edge(int f, int t, T c){
        from = f; to = t; cost = c;
    }
};
 
template<class T> struct Graph{
    vector<vector<edge<T>>> G;
    int n;
    
    Graph(int n_){
        n = n_;
        G.resize(n);
    }
    
    void add_edge(int f, int t, T c){
        G[f].emplace_back(f, t, c);
    }
    
    vector<T> dijkstra(int s){
        using P = pair<T, int>;
        priority_queue<P, vector<P>, greater<P>> que;
        vector<T> d(n, numeric_limits<T>::max());
        d[s] = 0;
        que.push(P((T)0, s));
        while(!que.empty()){
            P p = que.top(); que.pop();
            int v = p.second;
            if(d[v] < p.first) continue;
            for(edge<T> &e : G[v]){
                if(d[e.to] > d[v] + e.cost){
                    d[e.to] = d[v] + e.cost;
                    que.push(P(d[e.to], e.to));
                }
            }
        }
        return d;
    }
    
    T kruskal(){
        vector<edge<T>> E;
        rep(i, n)for(edge<T> &e: G[i]) E.push_back(e);
        sort(E.begin(), E.end(), [](const edge<T> &e1, const edge<T> &e2){return e1.cost < e2.cost;});
        UF uf(n);
        T res = 0;
        for(edge<T> &e: E){
            if(!uf.same(e.from, e.to)){
                uf.unite(e.from, e.to);
                res += e.cost;
            }
        }
        return res;
    }
    
    vector<int> toposo(){
        vector<int> ret(n), in(n, 0);
        rep(i, n)for(edge<T> &e: G[i]) ++in[e.to];
        int cur = 0;
        stack<int> st;
        rep(i, n)if(!in[i]) st.push(i);
        while(!st.empty()){
            int v = st.top(); st.pop();
            ret[cur++] = v;
            for(edge<T> &e: G[v]){
                --in[e.to];
                if(!in[e.to]) st.push(e.to);
            }
        }
        return ret;
    }
};

int main(){
    int n;
    scanf("%d", &n);
    Graph<int> g(n);
    rep(i, n)rep(j, n){
        int a;
        scanf("%d", &a);
        if(a >= 0) g.add_edge(i, j, a);
    }
    printf("%d\n", g.kruskal());
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define int long long int
#define double long double
using namespace std;
double DP[3000][3000] = {0};
signed main() {
    int n;
    cin>>n;
    double p[n];
    for(int i=0;i<n;i++)
    cin>>p[i];

    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            
            if(i==0 && j==0)
            {
                DP[i][j]=1;
                continue;
            }
            if(i==0)
            {
                DP[i][j]=0;
                continue;
            }
            if(j==0)
            DP[i][j] = (double)(1-p[i-1])*DP[i-1][j];
            else
            {
                DP[i][j] = (double)p[i-1]*DP[i-1][j-1] + (double)(1-p[i-1])*DP[i-1][j];
            }
        }
    }
    double d = (double)n/2;
    int k = ceil(d);
    //cout<<d<<endl;
    double ans=0;
    for(int i=k;i<=n;i++)
    {ans += DP[n][i];
    //cout<<n<<" "<<i<<endl;
    }
    cout<<setprecision(10)<<ans;

    return 0;
}

Measured memory_bytes: 140928
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

bool isPrime(ll num) {

	bool flag = true;
	for (int i = 2; i <= sqrt(num); i++) {
		if (num%i == 0) {
			flag = false;
			break;
		}
	}

	return flag;
}


void solve() {

	ll N;
	cin >> N;

	vector<ll> A(N), B(N), C(N-1);
	rep(i, N) {
		cin >> A[i];
		A[i]--;
	}
	rep(i, N) cin >> B[i];
	rep(i, N - 1) cin >> C[i];

	ll ans = 0;

	for (int i = 0; i < N; i++) {

		ans += B[A[i]];
		if (i != 0) {
			if (A[i] == A[i - 1] + 1) ans += C[A[i - 1]];
		}

	}

	cout << ans;
}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
int main(void)
{
    int w,h,x,y,r,flg=1;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if(w<x+r||0>x-r) flg=0;
	if(h<y+r||0>y-r) flg=0;
	if(flg==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 2688
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
co=0
for i in range(len(B)):
    co+=B[i]
for j in range(len(C)):
    if A[j+1]==A[j]+1:
        co+=C[A[j]-1]
print(co)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

/*
 貪欲
 ①決定問題 必ず解に含まれる(含むように変換できる)ものから決めていく みんプロ本選B
 ②最適化問題 任意の解から評価を落とさず解に含められるようなものから決めていく 区間スケジューリングとか
 ③
 */

/*
 DP
 ①DPはある程度決め打ちをするべき(解を帰納的に構成できないか？)
 */

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	ll sum=0;
	REP(i,n) sum+=a[i];
	vector<ll> acm(n);
	acm[0]=a[0];
	REP(i,n-1) acm[i+1]=acm[i]+a[i+1];
	ll ret=INF*INF;
	REP(i,n-1) {
		ret=min(ret,abs(acm[i]-(sum-acm[i])));
	}
	cout<<ret<<endl;
}


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

using namespace std;
typedef long long ll;
 
void solve() {
  ll c, a, b;
  cin >> a >> b >> c;
  
  ll ret = 0;
  ret = b / a;
  if ( ret > c ) ret = c;
  std::cout << ret << std::endl;
}

int main(int argc, char *argv[])
{
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
 
int main()
{
	string s;
	cin>>s;
	if(*(s.end()-1)=='s')
	{
		s.append("es");
		cout<<s;
	}
	else {
		s.append("s");
		cout<<s;
	}
}


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

int main()
{
    long long n,m,i,j,s=0,ans=0;
    map<long long,long long> ma;
    cin>>n>>m;
    ma[0]=1;
    for(i=1;i<=n;i++)
    {
    	cin>>j;
    	s+=j;
    	ans+=ma[s%m];
    	ma[s%m]++;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define f(i,p,q) for(int i=p;i<q;i++)
using namespace std;
typedef long long ll;
int ar[64];
int main()
{//freopen("in.txt","r",stdin);
 //freopen("out.txt","w",stdout);
  long long  int n,k;cin>>n>>k;
  long long  int t; int l=0;
  long long int kk=k;
   while(k!=0)
     {  k=k>>1;
     	l++; 
	 }
	long long  int m=n;
	long long  int arr[m];
   for(int i=0;i<n;i++)
   {  cin>>arr[i];
     t=arr[i];
  long long int index=0;
   	 while(t!=0)
   	 {   
		if((t&1)==1)
   	      ar[index]++;
   	 	index++;
        t=t>>1;
		}
   }
  long long  int ans=0;
  
  
   for(int i=l-1;i>=0;i--)
   {  if(m-ar[i]>ar[i]&&(ans^(1ll<<i))<=kk)
          ans=ans^(1ll<<i);
   	  
   	   //cout<<i<<" "<<ar[i]<<"  "<<ans<<"\n";
   }  
  
 
  long long  int res=0;
   for(int i=0;i<m;i++)
     res+=ans^arr[i];
      cout<<res;
}

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

int main() {
    int N;
    cin >> N;
    int ans = N / 2 + (N % 2);
    cout << ans << endl;
  return 0;
}


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

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

const int INF = 1000000007;

int main(void){
	int n, k; cin>>n>>k;
	int x[100010] = {0};
	for(int i=0;i<n;i++) cin>>x[i];

	ll minl = INF, minr = INF, tmpl, tmpr;
	for(int i=0;i < n - k + 1;i++) {
		int l = x[i];
		int r = x[i + k - 1];
		tmpl = abs(l) + abs(l - r);
		tmpr = abs(r) + abs(l - r);
		minl = min(minl, tmpl);
		minr = min(minr, tmpr);
	}
	ll ans = min(minl, minr);

	cout<< ans <<endl;
	
	return 0;
}

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

using namespace std;

int memo[100010];

int calc(int n) {
	if (n == 0) return 0;
	if (memo[n] != -1) return memo[n];
	else {
		int rem = n;
		for (int i = 1; i <= n; i *= 6) {
			rem = min(rem, calc(n - i) + 1);
		}
		for (int i = 1; i <= n; i *= 9) {
			rem = min(rem, calc(n - i) + 1);
		}
		memo[n] = rem;
		return memo[n] = rem;
	}
}

int main() {
	int N; cin >> N;

	memo[0] = 0;
	for (int i = 1; i <= N; i++)
	{
		memo[i] = -1;
	}

	int ans = calc(N);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
const string yes = "Yes";
const string no = "No";

int main()
{
  ll a; cin >> a;
  ll b; cin >> b;
  ll c; cin >> c;
  ll d; cin >> d;
  ll x = (c+b-1)/b;
  ll y = (a+d-1)/d;
  if (x > y) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 3648
import sys
def inpl(): return list(map(int, sys.stdin.readline().split()))

x = inpl()
N = []
cnt = 0
for i in range(0, x[0]):
    N.append(0)

for i in range(0, x[1]):
    tem = int(input())
    A = inpl()

    for j in range(0, tem):
        N[A[j]-1] += 1

for k in range(0, len(N)):
    if N[k] == 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 9204
//#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)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=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	string S;
	scan(S);
	int N=S.size();
	int flag=1;
	rep(i,N){
		if(S[i]!=S[N-i-1]) flag=0;
	}
	rep(i,(N-1)/2){
		if(S[i]!=S[(N-1)/2-1-i]) flag=0;
		if(S[i+(N+1)/2]!=S[(N-1)/2-1-i+(N+1)/2]) flag=0;
		debug(i,(N-1)/2-1-i);
		debug(i+(N+1)/2,(N-1)/2-1-i+(N+1)/2);
	}
	if(flag) prin("Yes");
	else prin("No");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {
	
	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	
	ll N;
	cin >> N;
	vll A(N);
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
	}


	// 位ごとに計算する
	vvll bits(N);
	for (ll i = 0; i < N; i++) {
		for (ll j = 0; j < 60; j++) {
			bits[i].emplace_back((A[i] >> j) & 1);
		}
	}



	ll ans = 0;
	for (ll  keta = 0; keta < 60; keta++) {

		ll sum1 = 0;
		ll sum2 = 0;

		vll ruiseki(N);
		ruiseki[0] = bits[0][keta];
		for (ll i = 1; i < N; i++) {
			ruiseki[i] = ruiseki[i - 1] + bits[i][keta];
		}

		//　大きいΣ
		for (ll i = 0; i < N-1; i++) {

			// i番目より後ろの１の数
			ll sigma = ruiseki[N - 1] - ruiseki[i];

			if (bits[i][keta] == 0) {
				// 1を数える（小さいΣ）
				sum1 += sigma;
			}
			else {
				sum2 += (N-1 - i) - (ruiseki[N - 1] - ruiseki[i]);
			}

		}

		ll ans1 = sum1;
		ll ans2 = sum2;
		for (ll i = 0; i < keta; i++) {
			ans1 *= 2;
			ans1 %= MOD;

			ans2 *= 2;
			ans2 %= MOD;

		}

		ans += (ans1 + ans2) % MOD;

	}

	ans %= MOD;
	cout << ans;


}




Measured memory_bytes: 166656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define mod 1000000007
int comp(const void *a, const void * b){
    string c = *(string *) a;
    string d = *(string *) b;
    for(int i=0;i<10;i++){
        if(c[i]<d[i]) return -1;
        else if(c[i]>d[i]) return 1;
    }
    return 0;
}
int main(void){
    int n; cin >> n;
    string s[n];
    rep(i,n){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
    }
    qsort(s,n,sizeof(string),comp);
    //rep(i,n) cout << s[i] << endl;
    string target = s[0];
    ll ans = 0;
    ll cnt = 1;
    rep(i,n-1){
        if(s[i+1]==target){
            ans += cnt++;
        }else{
            target = s[i+1];
            cnt = 1;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 8060
#include <stdio.h>
#define N 10000
#define Q 500

int search(int [],int [],int,int);

int main(void){

  int n,q;
  int S[N];
  int T[Q];
  int i;
  int count;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    scanf("%d",&S[i]);

  scanf("%d",&q);

  for(i=0;i<q;i++)
    scanf("%d",&T[i]);

  count = search(S,T,n,q);

  printf("%d\n",count);

  return 0;
}

int search(int S[],int T[],int n,int q){

  int i,j;
  int count=0;

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i] == S[j]){
	count++;
	break;
      }
    }
  }

  return count;
}

Measured memory_bytes: 640
import sys
from functools import lru_cache


sys.setrecursionlimit(200000)
fin = sys.stdin.readline
num_matches_required = {n: nmatches for n, nmatches 
    in zip(range(1, 10), (2, 5, 5, 4, 5, 6, 3, 7, 6))}

N, M = map(int, fin().split())
nums = sorted(map(int, fin().split()), reverse=True)

@lru_cache(None)
def rec(i):
    if i < 0: 
        return float('-inf')
    elif i == 0: 
        return 0
    else:
        return max(
            rec(i - num_matches_required[num]) for num in nums
        ) + 1


num_digits = rec(N)
cur_num_matches = N
result = []
while cur_num_matches:
    for num in nums:
        if rec(cur_num_matches - num_matches_required[num]) == num_digits - len(result) - 1:
            result.append(str(num))
            cur_num_matches -= num_matches_required[num]
            break

print("".join(result))


Measured memory_bytes: 10080
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  ll a[N];
  REP(i, N) { cin >> a[i]; }
  ll ans = 0;
  REP(i, N) { ans += a[i] - 1; }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

const ll L = 1e5+5;

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

    ll H, A;
    cin >> H >> A;

    ll ans = H/A;

    if(H % A)
    {
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll              long long int
#define int             ll
#define double          long double
#define ff              first
#define ss              second
#define pb              emplace_back
#define mpair           make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define sbits(x)      __builtin_popcountll(x)
#define zbits(x)      __builtin_popcountlliltin_ctzll(x)
#define w(t)            int t;cin>>t;while(t--)
#define uset            unordered_set
#define dor(i, a, b)    for(int i =(a);i<=(b);i++)
#define mem(a,val)      memset((a),(val),sizeof((a))); 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
    template <typename Arg1>
     void __f(const char* name,Arg1&& arg1){
        cout<<name<<" : "<<arg1<<std::endl;
     }
     template <typename Arg1, typename... Args>
     void __f(const char* names,Arg1&& arg1,Args&&... args){
        const char* comma = strchr(names+1 ,',');
        cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
     }
#else
#define trace(...)
#endif
/*     
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
*/
double pi = 2.0*acos(0);
void fast(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout<<fixed<<setprecision(10);}
int max2(int a,int b){ if(a>b) return a;return b;}
int min2(int a,int b){ if(a<b)return a;return b;}
int max3(int a,int b,int c){ return max2(a,max2(b,c));}
int min3(int a,int b,int c){ return min2(a,min2(b,c));}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
double absd(double a)
{
    if(a<=0)
      return -a;
    else
      return a;
}
double mind(double a,double b)
{
   if(a<=b)
    return a;
   else
    return b;
}

double calcAngle(double h, double m)  
{  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
  
    // Calculate the angles moved  
    // by hour and minute hands  
    // with reference to 12:00  
    double hour_angle =(h*30+m/2.0);  
    double minute_angle = 6 * m;  
  
    // Find the difference between two angles  
    double angle = absd((hour_angle - minute_angle));  
  
   
    angle = mind(360.0-angle, angle);  
  
    return angle; 
}
void solve()
{
   double pp =3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132/180.0;
    int a,b,h,m;
    cin>>a>>b>>h>>m;
   double angle = calcAngle(h,m)*pp;
    double cc = cos(angle);
    double ans = a*a+b*b-2.0*a*b*cc;
    cout<<fixed<<setprecision(20)<<sqrtl(ans)<<endl;
}

signed main(void)
{
     
      solve();

}


Measured memory_bytes: 4168
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD=1000000007;
using Graph = vector<vector<int>>;

int cut(int a, int b) {//切り捨て
    return (a - a % b) / b;
}
int up(int a, int b) {
    return (a + a % b) / b;
}
int n, x, y;
ll ans[2005];

int main() {
    cin >> n >> x >> y; 
    --x; --y;
    Graph G(n);
    for (int i = 0; i < n; i++) {
        if(i<n-1) G[i].push_back(i + 1);
        if(i>0) G[i].push_back(i - 1);
    }
    G[x].push_back(y);
    G[y].push_back(x);
    for (int sv = 0; sv < n; sv++) {
        vector<int> dist(n, INF);
        queue<int> q;
        q.push(sv);
        dist[sv] = 0;
        while (!q.empty()) {
            int v = q.front(); q.pop();
            for (int nv: G[v]) {
                if (dist[nv] != INF) continue;
                q.push(nv);
                dist[nv] = dist[v] + 1;
            }
        }
        rep(i, n) ans[dist[i]]++;
    }
    rep(i, n) ans[i] /= 2;
    for (int i = 1; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let r = read::<u32>();
    if r < 1200 {
        println!("ABC");
    } else if r < 2800 {
        println!("ARC");
    } else {
        println!("AGC");
    }
}


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

long long mat[207][207];
int ord[10];
long long ans = 1e16;
long long inf = 1e16;
int main(){
	int n,m,r;
	int a,b,c;
	
	cin >> n >> m >> r;
	
	for(int i = 1;i<=n;i++){
		for(int j = 1;j<=n;j++){
			if(i==j){
				mat[i][j] = 0;
				mat[j][i] = 0;
			}
			else{
				mat[i][j] = inf;
				mat[j][i] = inf;
			}
		}
	}
	
	for(int i = 0;i < r;i++){
		cin >> ord[i];
	}
	
	while(m--){
		cin >> a >> b >> c;
		mat[a][b] = c;
		mat[b][a] = c;
	}
	
	for(int k = 1;k<=n;k++){
		for(int i = 1;i<=n;i++){
			for(int j = 1;j<=n;j++){
				if(mat[i][j]>mat[i][k]+mat[k][j]){
					mat[i][j] = mat[i][k]+mat[k][j];
				}
			}
		}
	}
	sort(ord,ord+r);
	while(next_permutation(ord,ord+r)){
		long long sum = 0;
		for(int i = 1;i < r;i++){
			sum+=mat[ord[i]][ord[i-1]];
		}
		ans = min(sum,ans);
	}
	cout << ans;
}

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

string s;
lli x,y;

vll mvx;
vll mvy;

vector<string> split(string::iterator begin,string::iterator end,char sep){
  vector<string> ret;
  for(auto itr = begin;;itr++){
    auto jtr = itr;
    while(jtr != end && *jtr != sep) jtr++;
    // cout << string(itr,jtr) << endl;
    ret.push_back(string(itr,jtr));
    itr = jtr;
    if(itr == end) break;
  }
  return ret;
}

bool solve(vll &x,lli t){
  lli s = accumulate(x.begin(),x.end(),0)+10;
  mat dp = mat(x.size()+1,vll(s*2+1,0));
  dp[0][s] = 1;
  for(lli i = 0;i < x.size();i++){
    for(lli j = 0;j < s*2;j++){
      if(dp[i][j] == 1) dp[i+1][j-x[i]] = dp[i+1][j+x[i]] = 1;
    }
  }
  if(s+t < dp[x.size()].size() && dp[x.size()][s+t] == 1) return true;
  else return false;
}

int main(){
  cin >> s;
  cin >> x >> y;
  vector<string> order = split(s.begin(),s.end(),'T');
  x -= order[0].size();
  for(lli i = 1;i < order.size();i++){
    if(i%2 == 0) mvx.push_back(order[i].size());
    else mvy.push_back(order[i].size());
  }
  // for(lli i = 0;i < mvx.size();i++) cout << mvx[i] << endl;
  // for(lli i = 0;i < mvy.size();i++) cout << mvy[i] << endl;
  if(solve(mvx,x) && solve(mvy,y)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 125964
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N;
    int h[100000] = {};
    
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    
    // DPの宣言と初期値を設定
    long long dp[100001];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    
    for(int i = 1; i < N-1; i++){
        int jump_One = dp[i] + abs(h[i+1] - h[i]);
        int jump_Tow = dp[i-1] + abs(h[i+1] - h[i-1]);
        dp[i+1] = min(jump_One, jump_Tow);
    }

    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1408
dic = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

n = int(input())

for i in range(n):
    s = input()
    dic[s] += 1

print("AC x {}".format(dic["AC"]))
print("WA x {}".format(dic["WA"]))
print("TLE x {}".format(dic["TLE"]))
print("RE x {}".format(dic["RE"]))


Measured memory_bytes: 9188