akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2595959595959595959ll
#define MAXN 400013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N;
ll K;
int arr[MAXN];
int loc[MAXN];
int to[MAXN];
__int128_t go[61][MAXN];
ll pos;
vl seq;

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> K;
	FOR(i, 0, N)
	{
		cin >> arr[i];
		arr[i + N] = arr[i];
	}
	FORD(i, 2 * N, N)
	{
		loc[arr[i]] = i;
	}
	FORD(i, N, 0)
	{
		to[i] = loc[arr[i]] + 1 - i;
		loc[arr[i]] = i;
	}
	FOR(i, 0, N)
	{
		go[0][i] = to[i];
	}
	bool die = false;
	FOR(i, 1, 60)
	{
		FOR(j, 0, N)
		{
			go[i][j] = go[i - 1][j] + go[i - 1][(j + go[i - 1][j]) % N];
		}
	}
	pos = 0;
	FORD(i, 59, 0)
	{
		if (pos + go[i][pos % N] <= K * N)
		{
			pos += go[i][pos % N];
		}
	}
	if (pos == K * N)
	{
		return 0;
	}
	FOR(i, 0, MAXN)
	{
		loc[i] = 0;
	}
	pos %= N;
	//so now you just have a sequence!
	FOR(i, pos, N)
	{
		ll x = arr[i % N];
		if (loc[x])
		{
			while(true)
			{
				assert(!seq.empty());
				int y = seq.back();
				seq.pop_back();
				loc[y]--;
				if (x == y) break;
			}
		}
		else
		{
			seq.PB(x);
			loc[x]++;
		}
	}
	FOR(i, 0, SZ(seq))
	{
		if (i) cout << ' ';
		cout << seq[i];
	}
	cout << '\n';
	return 0;
	//now keep on applying this thing till we hit like smth in N*(K-1)...N*K-1
}


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

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 999999999
#define MAX_V 100010
#define MAX_E 2019

    /*Solve*/

int main(){
    ll N;
    cin >> N;
    long double ans=0;
    
    rep(i,N){
        long double a;
        string u;
        cin >> a;
        cin >> u;
        if(u=="BTC"){
            ans+=a*380000;
        }else
            ans+=a;
    }
    cout << ans;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//

using namespace std;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0,1,-1,-1,1}; //次に行くところ
int dx[] = {0,1,0,-1,1,1,-1,-1}; //上に同じ

int n,k;
vector<int> h,mem;

int dp(int p){
  if (p == 0){
    mem[p] = 0;
    return mem[p];
  }
  if (mem[p] == INT_MAX){
    for (int i = 1; i <= k; i++){
      if (p - i < 0){
        continue;
      }
      mem[p] = min(mem[p],dp(p-i)+abs(h[p]-h[p-i]));
    }
  }
  return (mem[p]);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  h.resize(n);
  mem.resize(n,INT_MAX);
  for (int i = 0; i < n; i++){
    cin >> h[i];
  }
  cout << dp(n-1) << '\n'; 
  return 0;
}

Measured memory_bytes: 8684
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int x = sc.nextInt();
		int y = sc.nextInt();

		pr.println(x + y / 2);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main() {
 
  int N; cin >> N;
  vector<vector<int>> v(N, vector<int>(3));
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 3; j++){
        cin >> v.at(i).at(j);
    }
  }
  bool can = true;
  if(N == 1){
    if(v.at(0).at(0) 
       >= abs( v.at(0).at(1) ) + abs( v.at(0).at(2) ) &&
      v.at(0).at(0) % 2 == (abs( v.at(0).at(1)) + abs(v.at(0).at(2))) % 2){
      cout << "Yes" << endl;
    }else cout << "No" << endl;
  }else{ //N > 1
  	for(int i = 0; i < N-1; i++){
  	  if(( v.at(i+1).at(0) - v.at(i).at(0) ) % 2 
  	     == ( abs(v.at(i+1).at(1) - v.at(i).at(1) )
    	      + abs(v.at(i+1).at(2) - v.at(i).at(2))) % 2  &&
    	  v.at(i+1).at(0) - v.at(i).at(0)
      	>= abs( v.at(i+1).at(1) - v.at(i).at(1) )
       	 + abs( v.at(i+1).at(2) - v.at(i).at(2) ) ){
      	  continue;
    	}else{
      	  can = false;
      	  break;
      }
  	}
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  }
}

Measured memory_bytes: 5760
#include <stdio.h>
#define LENGTH 256

int main()
{
    char input[LENGTH];
    int num1, num2;
    int result;
    fgets(input, LENGTH-1, stdin);
    sscanf(input, "%d %d", &num1, &num2);
    if (num1 < num2)
    {
        result = 0;
    }else
    {
        result = 10;
    }
    printf("%d\n", result);
    
    return 0;
}


Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import accumulate
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    A=list(accumulate(A))
    min_A=100000000000
    for a in A:
        min_A=min(min_A,abs(A[-1]/2-a))
    print(int(min_A*2))

if __name__=='__main__':
    main()

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif


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

    ll x;

    cin >> x;

    for(ll a=-119; a<119; a++){
        for(ll b=-119; b<119; b++){
            if(a*a*a*a*a-b*b*b*b*b==x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3608
import sys
from collections import deque
 
 
class MaxFlow:
    class Edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, node_size, inf):
        self._node = node_size
        self._inf = inf
        self._level = [-1]*self._node
        self._iter = [0]*self._node
        self._graph = [[] for _ in range(self._node)]

    def add_edge(self, from_, to, cap):
        self._graph[from_].append(self.Edge(to, cap, len(self._graph[to])))
        self._graph[to].append(self.Edge(from_, 0, len(self._graph[from_])-1))

    def bfs(self, start):
        self._level = [-1]*self._node
        que = deque()
        self._level[start] = 0
        que.append(start)
        while que:
            cur_vertex = que.popleft()
            for e in self._graph[cur_vertex]:
                if e.cap > 0 > self._level[e.to]:
                    self._level[e.to] = self._level[cur_vertex] + 1
                    que.append(e.to)

    def dfs(self, cur_vertex, end_vertex, flow):
        if cur_vertex == end_vertex:
            return flow
        while self._iter[cur_vertex] < len(self._graph[cur_vertex]):
            e = self._graph[cur_vertex][self._iter[cur_vertex]]
            if e.cap > 0 and self._level[cur_vertex] < self._level[e.to]:
                flowed = self.dfs(e.to, end_vertex, min(flow, e.cap))
                if flowed > 0:
                    e.cap -= flowed
                    self._graph[e.to][e.rev].cap += flowed
                    return flowed
            self._iter[cur_vertex] += 1
        return 0

    def solve(self, source, sink):
        flow = 0
        while True:
            self.bfs(source)
            if self._level[sink] < 0:
                return flow
            self._iter = [0]*self._node
            while True:
                f = self.dfs(source, sink, self._inf)
                if f == 0:
                    break
                flow += f
 
if __name__ == '__main__':
    n, m = map(int, sys.stdin.readline().split())
    mf = MaxFlow(n, 10**10)
    for _ in range(m):
        u, v, c = map(int, sys.stdin.readline().split())
        mf.add_edge(u, v, c)
    print(mf.solve(0, n-1))


Measured memory_bytes: 6336
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int64 n, D, ret = 0;
  scanf("%lld%lld", &n, &D);
  for (int i = 0; i < n; ++i) {
    int64 x, y;
    scanf("%lld%lld", &x, &y);
    if (x * x + y * y <= D * D) ++ret;
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 3240
#include <iostream>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <cstring>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <cassert>
#include <set>
#include <complex>
#include <bitset>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <string>


#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define EPS 1e-7
#define io  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define file freopen ("in.txt", "r", stdin),freopen ("out.txt", "w", stdout);
#define mid ((st + en) >> 1)
#define fileIn freopen ("in.txt", "r", stdin);
#define all(v) ((v).begin()), ((v).end())
#define de(a) #a<<" = "<<a


using namespace std;

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

const int N = 3e5 + 5;

int n;
int a[N], b[N];

int main () {
#ifndef ONLINE_JUDGE
  //fileIn;
#endif
  cin >> n;
  for(int i = 0; i < n; i++) {
    scanf("%d%d", &a[i], &b[i]);
  }
  ll cnt = 0;
  for(int i = n - 1; i >= 0; i--) {
    cnt += (b[i] - (a[i] + cnt) % b[i]) % b[i];
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
count = 0
ans = 0
for i in range(1, n+1):
    if i % 2 == 1:
        count = 0
        for j in range(1, i+1):
            if i % j == 0:
                count += 1
        if count == 8:
            ans += 1
        else:
            continue
    else:
        continue
print(ans)

Measured memory_bytes: 38640
package main

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

func main() {
	S := getStdin()
	T := getStdin()

	ans := 0
	for i := 0; i < len(S); i++ {
		if S[i] == T[i] {
			ans++
		}
	}

	fmt.Printf("%d\n", ans)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntU64() uint64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return uint64(rtn)
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func getStdinIntArrU64() []uint64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]uint64, len(list))
	for idx, val := range list {
		r, _ := strconv.ParseInt(val, 10, 64)
		rtn[idx] = uint64(r)
	}
	return rtn
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
func abs64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2168
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    n = int(input())
    a = [-1] * n
    print(0,flush = True)
    s = input()
    if s == 'Vacant':
        return
    elif s == 'Male':
        a[0] = 0
    else:
        a[0] = 1
    
    l = 0
    r = n
    for _ in range(19):
        mid = (r + l)//2
        print(mid,flush = True)
        s = input()
        if s == 'Vacant':
            return
        elif s == 'Male':
            a[mid] = 0
            if a[l] == 0:
                if (mid - l)%2 == 0:
                    l = mid
                else:
                    r = mid
            else:
                if (mid - l)%2 == 1:
                    l = mid
                else:
                    r = mid
        else:
            a[mid] = 1
            if a[l] == 0:
                if (mid - l)%2 == 1:
                    l = mid
                else:
                    r = mid
            else:
                if (mid - l)%2 == 0:
                    l = mid
                else:
                    r = mid
            
    return

if __name__ =='__main__':
    main()  

Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
#define LOOP(i,o) for(i=0;i<o;i++)
#define ALL(a)  (a).begin(),(a).end()            
int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  int i;
  LOOP(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int ans=0;
  for(int i=n-1;i>=2;i--){
    for(int j=i-1;j>=1;j--){
      int p=a[i]-a[j];

      auto Iter1 = upper_bound(ALL(a), p);
      if(Iter1 - a.begin()>=j){
        continue;
      }
     
      ans+=i+1-(Iter1 - a.begin()+(i-j+1));
     
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a[] = new int[3];
        for(int i = 0;i<3;i++){
            a[i] = sc.nextInt();
        }
        int k = sc.nextInt();
        Arrays.sort(a);
        for(int i = 0;i<k;i++){
            a[2] *= 2;
        }
        int result = a[0] + a[1] + a[2];
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  int N=S.size(),flag=1;
  
  string sample;
  for(int i=0;i<7;i++){
    sample=S.substr(0,i)+S.substr(N-7+i,7-i);
    if(sample=="keyence")flag=0;
  }
  if(S.substr(0,7)=="keyence")flag==0;
  if(flag==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
n,x=map(int,input().split())
a,p=[1],[1]
for i in range(n):
  a.append(a[-1]*2+3)
  p.append(p[-1]*2+1)
def f(n,x):
  if n==0:return+(x>0)
  elif x<=1+a[n-1]:return f(n-1,x-1)
  else:return p[n-1]+1+f(n-1,x-2-a[n-1])
print(f(n,x))

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

int main() {
  int H, W;
  cin >> H >> W;
  char A[H][W];
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> A[i][j];
    }
  }
  int L[H][W];
  int R[H][W];
  int U[H][W];
  int D[H][W];
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(A[i][j] == '#') {
        L[i][j] = 0;
      }
      else {
        if(j == 0) {
          L[i][j] = 1;
        }
        else {
          L[i][j] = L[i][j-1] + 1;
        }
      }
    }
  }
  for(int i = 0; i < H; i++) {
    for(int j = W-1; j >= 0; j--) {
      if(A[i][j] == '#') {
        R[i][j] = 0;
      }
      else {
        if(j == W-1) {
          R[i][j] = 1;
        }
        else {
          R[i][j] = R[i][j+1] + 1;
        }
      }
    }
  }
  for(int i = 0; i < W; i++) {
    for(int j = 0; j < H; j++) {
      if(A[j][i] == '#') {
        D[j][i] = 0;
      }
      else {
        if(j == 0) {
          D[j][i] = 1;
        }
        else {
          D[j][i] = D[j-1][i] + 1;
        }
      }
    }
  }
  for(int i = 0; i < W; i++) {
    for(int j = H-1; j >= 0; j--) {
      if(A[j][i] == '#') {
        U[j][i] = 0;
      }
      else {
        if(j == H-1) {
          U[j][i] = 1;
        }
        else {
          U[j][i] = U[j+1][i] + 1;
        }
      }
    }
  }
  int ans[H][W];
  int answer = 0;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      ans[i][j] = U[i][j] + D[i][j] + L[i][j] + R[i][j];
      answer = max(answer, ans[i][j]);  
    }
  }
  cout << answer - 3 << endl;
}

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

const int N = 18;
using ii = pair<int, int>;
#define x first
#define y second

namespace my {
	ii merge(ii a, ii b) {
		a.y = max(a.y, b.x);
		if(a.y > a.x) swap(a.x, a.y);
		a.y = max(a.y, b.y);
		if(a.y > a.x) swap(a.x, a.y);
		return a;
	}
}

int n;
ii f[2][1 << N];

int main(int argc, char const *argv[])
{
	// freopen("in", "r", stdin);
	cin >> n;
	for(int i = 0; i < (1 << n); i++) {
		cin >> f[0][i].x;
	}
	int t = 1;
	for(int i = 0; i < 18; i++) {
		for(int j = 0; j < (1 << n); j++) {
			f[t][j] = f[t ^ 1][j];
			if(j >> i & 1) {
				f[t][j] = my::merge(f[t ^ 1][j ^ (1 << i)], f[t][j]);
			}
		}
		t ^= 1;
	}
	t ^= 1;
	int mx = 0;
	for(int i = 1; i < (1 << n); i++) {
		mx = max(mx, f[t][i].x + f[t][i].y);
		cout << mx << '\n';
	}
	return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<int> Ans(N - 1, 0);
    for(int i = 1; i <= N; i++) {
        for(int j = i + 1; j <= N; j++) {
            //iとjの距離
            int d;
            if(j <= X || Y <= i)
                d = j - i;
            else {
                if(i < X && Y < j) d = min(j - i, X - i + 1 + j - Y);
                if(X <= i && i <= Y && Y < j) d = min(i - X + 1, Y - i) + j - Y;
                if(i < X && X <= j && j <= Y) d = X - i + min(j - X, 1 + Y - j);
                if(X <= i && j <= Y) d = min(j - i, i - X + 1 + Y - j);
            }
            //if(i == 1 && j == 4) cout << d << endl;
            Ans[d - 1]++;
        }
    }
    for(auto x : Ans) cout << x << endl;
}


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

using namespace std;

typedef long long int ll;

const ll maxn = 1e5+5;

int main() {
	int n;

	cin >> n;

	vector <ll> a(n);
	vector <ll> counts(maxn, 0);
	ll sum = 0;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		
		counts[a[i]]++;
		sum += a[i];
	}

	int q;

	cin >> q;

	while (q--) {
		ll b, c;

		cin >> b >> c;

		sum = sum - b*counts[b];
		sum = sum - c*counts[c];
		counts[c] += counts[b];
		counts[b] = 0;
		sum = sum + c*counts[c];

		cout << sum << "\n";
	}

	return 0;
}

Measured memory_bytes: 4848
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

typedef complex<double> P;
const int INF = 1<<29;
const double EPS = 1e-8;

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}

double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}


struct ufo{
    P pos,v;
    int xs,ys,vs,r,id;
};

double dist(const ufo& a, int t){
    return sqrt(a.xs*a.xs+a.ys*a.ys) - a.vs * t;
}


int main(){
    while(1){
        int R,N;
        scanf("%d %d",&R,&N);
        if(N==0)break;

        vector<ufo> enemys(N);
        for(int i=0;i<N;i++){
            int x,y,r,vs;
            scanf("%d %d %d %d",&x,&y,&r,&vs);
            P pos = P(x,y);
            P v = -(double)vs * pos / abs(pos);
            enemys[i] = (ufo){pos,v,x,y,vs,r,i};
        }

        int ans = 0, t = 1;
        while(enemys.size()){
            double min_d = 1500;
            int min_i = -1;
            for(int i=0;i<enemys.size();i++){
                enemys[i].pos += enemys[i].v;
                double d = dist(enemys[i],t);
                //printf("%d d = %lf\n",enemys[i].id,d);
                if(d <= R+EPS){
                    enemys.erase(enemys.begin()+i);
                    i--;
                    ans++;
                    continue;
                }
                if(min_d>d){
                    min_d = d;
                    min_i = i;
                }
            }
            if(enemys.size()==0) break;

            ufo min_e = enemys[min_i];
            double min_abs = abs(min_e.pos);
            for(int i=0;i<enemys.size();i++){
                double d = abs(cross(min_e.pos, enemys[i].pos)) / min_abs;
                if(d <= enemys[i].r+EPS){
                    P R_vec = (double)R * min_e.pos / min_abs;
                    P A = enemys[i].pos - R_vec;
                    if (dot(R_vec, A) > 0 || abs(A) < enemys[i].r){
                        enemys.erase(enemys.begin()+i);
                        i--;
                    }
                }
            }
            t++;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1236
import java.io.*;
import java.util.*;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        char[] S = new char[3];
        in.read(S);
        S[1] = (char)('B' + 'R' - S[1]);
        System.out.println(S);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; i <= cbuf.length; i++) {
            if ((c = next()) == ' ' || c == '\n') break;
            cbuf[i] = c;
        }
        return i;
    }
}


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

int main(void){
    int n;
    cin >> n;
    int ans = 0;
    int a;
    rep(i,n){
        cin >> a;
        ans+=a-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	int N; cin >> N;
	VI h(N);
	for (int i = 0;i < N;i++) {
		cin >> h[i];
	}
	int res = 0;

	while (true) {
		if (*MAX(h.begin(),h.end()) == 0) break;
		int i = 0;
		while (i < N) {
			if(h[i] == 0) ++i;
			else {
				++res;
				while (i < N && h[i]>0){
					--h[i];
					++i;
				}
			}
		}
	}
	cout << res << endl;
}


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

int main() {
    int n; std::cin >> n;
    std::set<std::string> words;
    std::string last; std::cin >> last;
    words.insert(last);
    for (int i = 1; i < n; ++i) {
        std::string temp; std::cin >> temp;
        if (temp.front() != last.back() || words.find(temp) != words.end()) {
            std::cout << "No"; return 0;
        }
        words.insert(temp);
        last = temp;
    }
    std::cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define all(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

int main()
{
    ll h;
    int n;
    cin >> h >> n;
    ll goukei=0;
    REP(i,n){
        ll input;
        cin >> input;
        goukei+=input;
    }
    if(goukei>=h){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(N)]
rest = M
ans = 0
for a, b in sorted(AB, key=lambda x: x[0]):
    if (b < rest):
        ans += a*b
        rest -= b
    else:
        ans += (a*rest)
        break
print(ans)


Measured memory_bytes: 65240
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define itn int

int dp[100100];
int h[100100];

signed main ( ) {

    ios::sync_with_stdio(0);
    cin.tie(0);

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

    dp[0] = 0;
    for ( int i = 0; i < n; i++ ) {
        for ( int j = 1; j <= 2; j++ ) {
            dp[i+j] = min ( dp[i+j], dp[i] + abs(h[i]-h[i+j]) );
        }
    }

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

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define dbg(x) cerr<<#x<<" = "<<x<<endl;
#define dbg_v(v,n) {cerr<<#v<<" = [";for(int III=0;III<=n;III++)cerr<<v[III]<<(III!=n?",":"]\n");}
#define ll long long
#define ld long double
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x

using namespace std;

ll n, a, b, c, d;

int main(){
    ios::sync_with_stdio(false);
    cin >> n >> a >> b >> c >> d;
    a = abs(a-b);
    n--;
    for (int i=0;i<=n;i++){
        ll x = -d * i + c * (n-i);
        ll y = d * (n-i) + -c * i;
        if (x <= a && a <= y){
            cout << "YES\n";
            return 0;
        }
    }

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


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

struct Node{
	int key;
	struct Node *r,*l,*p;
}Node;

struct Node *root , *NIL;

void insert( int k ){
	struct Node *y = NIL;
	struct Node *x = root;
	struct Node *z;
	
	z = ( struct Node *)malloc( sizeof(struct Node) );
	z->key = k;
	z->l = NIL;
	z->r = NIL;
	
	while( x != NIL ){
		y = x;
		if( z->key < x->key ){
			x = x->l;
		}else{
			x = x->r;
		}
	}
	z->p = y;
	
	if( y == NIL ){
		root = z;
	}else{
		if( z->key < y->key ){
			y->l = z;
		}else{
			y->r = z;
		}
	}
}

void preorder( struct Node *u ){
	
	if( u == NIL ){
		return;
	}
	printf( " %d" , u->key );
	preorder( u->l );
	preorder( u->r );
}

void inorder( struct Node *u ){
	
	if( u == NIL ){
		return;
	}
	inorder( u->l );
	printf( " %d" , u->key );
	inorder( u->r );
}

struct Node * find( struct Node *u , int k ){
	while( u != NIL && k != u->key ){
		if( k < u->key ){
			u = u->l;
		}else{
			u = u->r;
		}
	}
	return u;
}

int main( void ){
	
	int n , i , x;
	char com[10];
	
	scanf( "%d" , &n );
	
	for( i = 0; i < n; i++ ){
		
		scanf( "%s" , com );
		if( strcmp(com , "find") == 0 ) {
			scanf( "%d" , &x );
			struct Node *t = find(root,x);
			if( t!= NIL ){
				printf( "yes\n" );
			}else{
				printf( "no\n" );
			}
		}else if( strcmp(com ,"insert") == 0 ){
			scanf( "%d" , &x );
			insert(x);
		}else if( strcmp(com ,"print") == 0 ){
			inorder(root);
			printf( "\n" );
			preorder(root);
			printf( "\n" );
		}
	}
	
	return 0;
}
		


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

using namespace std;

unsigned long long int gcd(unsigned long long int x, unsigned long long int y){
	unsigned long long int r=x%y;
	while(r>0){
		x=y;
		y=r;
		r=x%y;
	}

	return y;
}

int main(){
    long A, B;
    cin>>A>>B;

    cout<<A/gcd(A, B)*B<<endl;

    return 0;
}




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

int main(void)
{
    int n,a[100];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int o=(n-1);o>=0;o--){
        cout<<a[o];
        if(o==0){
            break;
        }
        cout<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<cstdio>
#include<queue>
using namespace std;
#pragma warning(disable:4996)
int n, k, dist[3000];
vector<int>X[3000];
queue<int>Q; bool I[3000];
int search_1(int p) {
	int maxn = 0;
	for (int i = 1; i <= n; i++) {
		for (int i = 0; i < 3000; i++)dist[i] = 100000;
		dist[i] = 0; Q.push(i);
		while (!Q.empty()) {
			int a1 = Q.front(); Q.pop();
			for (int i = 0; i < X[a1].size(); i++) {
				if (dist[X[a1][i]]>dist[a1] + 1) {
					dist[X[a1][i]] = dist[a1] + 1;
					Q.push(X[a1][i]);
				}
			}
		}
		int sum = 0;
		for (int i = 1; i <= n; i++) {
			if (dist[i] <= p)sum++;
		}
		maxn = max(maxn, sum);
	}
	return n - maxn;
}
int search_2(int p) {
	int maxn = 0;
	for (int t = 1; t <= n; t++) {
		for (int i = 0; i < 3000; i++)dist[i] = 100000;
		dist[t] = 0; Q.push(t);
		while (!Q.empty()) {
			int a1 = Q.front(); Q.pop();
			for (int i = 0; i < X[a1].size(); i++) {
				if (dist[X[a1][i]]>dist[a1] + 1) {
					dist[X[a1][i]] = dist[a1] + 1;
					Q.push(X[a1][i]);
				}
			}
		}
		int sum = 0;
		for (int i = 1; i <= n; i++) {
			if (dist[i] <= p)sum++;
		}
		int D = 0;
		for (int i = 0; i < X[t].size(); i++) {
			for (int j = 0; j < 3000; j++)I[j] = false;
			Q.push(X[t][i]); I[X[t][i]] = true;
			while (!Q.empty()) {
				int a1 = Q.front(); Q.pop();
				for (int j = 0; j < X[a1].size(); j++) {
					int to = X[a1][j];
					if (to == t)continue;
					if (I[to] == false) {
						I[to] = true; Q.push(to);
					}
				}
			}
			int sum1 = 0;
			for (int i = 1; i <= n; i++) {
				if (I[i] == true && dist[i] == p + 1)sum1++;
			}
			D = max(D, sum1);
		}
		maxn = max(maxn, D + sum);
	}
	return n - maxn;
}
int main() {
	cin >> n >> k;
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b; X[a].push_back(b); X[b].push_back(a);
	}
	if (k % 2 == 0) {
		cout << search_1(k / 2) << endl;
	}
	else {
		cout << search_2((k - 1) / 2) << endl;
	}
	return 0;
}

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

using namespace std;

#define MAX 5010
#define INF 1e9
#define F first
#define S second
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
 
int N,K;
pii taxi[MAX];
vector<int> G[MAX];
int cost[MAX][MAX];

int dijkstra(){
  priority_queue<piii,vector<piii>,greater<piii> > Q;
  Q.push(piii(pii(0,0),0));
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < N ; j++){
      cost[i][j] = INF;
    }
  }
  cost[0][0] = 0;

  while(!Q.empty()){
    piii p = Q.top(); Q.pop();
    int v = p.F.S, r = p.S;
    if(cost[v][r] < p.F.F) continue;

    if(r > 0){
      for(int i = 0 ; i < (int)G[v].size() ; i++){
        int to = G[v][i];
        if(cost[v][r] < cost[to][r-1]){
          cost[to][r-1] = cost[v][r];
          Q.push(piii(pii(cost[to][r-1],to),r-1));
        }
      }
    }
    pii t = taxi[v];
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      int to = G[v][i];
      if(cost[v][r] + t.F < cost[to][t.S-1]){
        cost[to][t.S-1] = cost[v][r] + t.F;
        Q.push(piii(pii(cost[to][t.S-1],to),t.S-1));
      }
    }
  }
  return *min_element(cost[N-1],cost[N-1]+N);
}

int main(){
  int C,R,A,B;
  cin >> N >> K;
  for(int i = 0 ; i < N ; i++){
    cin >> C >> R;
    taxi[i] = pii(C,R);
  }
  for(int i = 0 ; i < K ; i++){
    cin >> A >> B; A--; B--;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  cout << dijkstra() << endl;
  return 0;
}

Measured memory_bytes: 99608
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int


struct item{
    ll weight;
    ll value;
};


ll solve(ll n,ll w,vector<item> &v)
{
    ll dp[n+1][w+1]; // w is the maximum capacity that the bag can hold....
    // agr app 1 pr hu to sirf vo he item ko le sakte hu jiska weight hu...
    // items are not breakable....
    for(ll j=0;j<=w;j++)   // j can be zero...
    {
        dp[1][j]=0;  // kisi ko bhi nhi le rha hu..
    }
    dp[1][v.at(1).weight]=v.at(1).value;
    for(ll i=2;i<=n;i++)
    {
        for(ll j=0;j<=w;j++)  // zero se suru karenge...// bag pura empty hu ye tu eik valid case hai...
        {
            ll option1,option2;
            option1=option2=LLONG_MIN;
            option1=dp[i-1][j];
            if(j-v.at(i).weight>=0)  // uss element ko le sakte hain ki nhi ye check krna hai.....
            {
                option2=v.at(i).value+dp[i-1][j-v.at(i).weight];
            }
            dp[i][j]=max(option1,option2);
        }
    }
    return *max_element(dp[n],dp[n]+w+1);
    
}

int main()
{
    ll n,w;
    cin>>n>>w;
    vector<item> v(n+1);   // item is a user defined data type....
    for(ll i=1;i<=n;i++)
    {
        cin>>v.at(i).weight>>v.at(i).value;
    }
    cout<<solve(n,w,v);
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  unordered_map<char, set<int>> M;
  for(int i=0; i<n; i++)
    M[s[i]].insert(i);
  
  long long ans = M['R'].size() * M['G'].size() * M['B'].size();
  
  for(auto i: M['R']){
    for(auto j: M['G']){
      if((i+j) & 1) continue;
      if(M['B'].find((i+j)/2) != M['B'].end()) ans--;
    }
  }
        
  for(auto i: M['R']){
    for(auto j: M['B']){
      if((i+j) & 1) continue;
      if(M['G'].find((i+j)/2) != M['G'].end()) ans--;
    }
  }
  
  for(auto i: M['B']){
    for(auto j: M['G']){
      if((i+j) & 1) continue;
      if(M['R'].find((i+j)/2) != M['R'].end()) ans--;
    }
  }
        
   cout << ans;
}


Measured memory_bytes: 3696
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    cout << (int)(m1 != m2) << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())

L=[]
for i in range(N):
    L.append([2]*N)

for i in range(N):
    A=int(input())
    for j in range(A):
        x,y=map(int,input().split())
        L[i][x-1]=int(y)

max=0

for i in range(2**N):
    b=list(map(int,list(bin(i))[2:]))
    b=[0]*(N-len(b))+b
    s=0

    for j in range(N):
        for k in range(N):
            if b[j]==1 and b[k]==1:
                if L[j][k]==0 or L[k][j]==0:
                    s=1
            if b[j]==1 and b[k]==0:
                if L[j][k]==1:
                    s=1

    if s==0:
        max=sum(b)

print(max)

Measured memory_bytes: 44764
#include<bits/stdc++.h>
#define For(i,j,k) for(register int i=(j);i<=(k);++i)
#define Forr(i,j,k) for(register int i=(j);i>=(k);--i)
using namespace std;

template<typename T>
inline void read(T &x){
	T p=1,c=getchar();
	x=0;
	while(!isdigit(c)){
		if(c=='-') p=-1;
		c=getchar();
	}
	while(isdigit(c)){
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	x*=p;
}

const int N=100+10;
int n,m,x,d,a[N];

int main(){
	read(n);
	read(d),read(x);
	For(i,1,n){
		read(a[i]);
		x+=(d-1)/a[i]+1;
	}
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll w,h,n;
	cin >> w >> h >> n;
	//w++;h++;
	bool ma[w][h];
	FOR(i,0,w)FOR(j,0,h)ma[i][j]=true;
	FOR(i,0,n){
		ll x,y,a;
		cin>>x>>y>>a;
		if(a==1){
			FOR(i,0,x)FOR(j,0,h)ma[i][j]=false;
		}
		if(a==2){
			FOR(i,x,w)FOR(j,0,h)ma[i][j]=false;
		}
		if(a==3){
			FOR(i,0,w)FOR(j,0,y)ma[i][j]=false;
		}
		if(a==4){
			FOR(i,0,w)FOR(j,y,h)ma[i][j]=false;
		}	
	}
	ll ans = 0;
	FOR(i,0,w){
		FOR(j,0,h){
			if(ma[i][j])ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int cnt = 0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='L' && i-1>=0 && s[i-1]=='L')
        cnt++;
        if(s[i]=='R' && i+1<n && s[i+1]=='R')
        cnt++;
    }
    cout<<min(n-1,cnt+2*k)<<"\n";
    return 0;
}


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

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	vi prime_p(1000000, 1);
	prime_p[0] = 0;
	prime_p[1] = 0;

	FOR(i, 2, 1000000) {
		if(prime_p[i]) {
			for(int j = i*2; j < 1000000; j += i) {
				prime_p[j] = 0;
			}
		}
	}

	vi prime;

	FOR(i, 2, 1000000) {
		if(prime_p[i]) {
			prime.push_back(i);
		}
	}

	int a, d, n;

	while(cin >> a >> d >> n, a) {
		vi num;
		int k = a-d;
		if(a == 1) {
			k += d;
		}

		do {
		check:
			k += d;
			for(int i = 0; prime[i] < k; i++) {
				if(k%prime[i] == 0) {
					goto check;
				}
			}
			num.push_back(k);
		} while(num.size() <= n);
	
		cout << num[n-1] << endl; 
	}
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

signed main(void){
    string S,T;
    cin >> S >> T;
    T.pop_back();
    if(S==T){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}




Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int arr[] = {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};
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  int k;
  cin >> k;
  cout << arr[--k] << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N,M; cin>>N>>M;
  cout<<maxx(N+M,N-M,N*M);
		
}

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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int>X(M);
  for(int i=0;i<M;i++)
    cin>>X.at(i);
  sort(X.begin(),X.end());
  if(N>=M)
    cout<<0;
  else{
    vector<int>dX(M-1);
    for(int i=0;i<M-1;i++)
      dX.at(i)=X.at(i+1)-X.at(i);
    sort(dX.begin(),dX.end());
    reverse(dX.begin(),dX.end());
    for(int i=0;i<N-1;i++)
      dX.at(i)=0;
    int res=0;
    for(int i=0;i<M-1;i++)
      res+=dX.at(i);
    cout<<res;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#define MAX 10000000
using namespace std;

int main(){
  bool hantei[MAX];
  vector<int> data;
  vector<int> ans;


  hantei[0]=hantei[1]=false;
  for(int i=0;i<=MAX;i+=2) hantei[i]=false;
  hantei[2]=true;
  for(int i=3;i<=MAX;i+=2){
    hantei[i]=true;
  }
  int limit=(int)sqrt((double)MAX)+1;
  for(int i=3;i<=limit;i+=2){
    if(hantei[i]==false) continue;
    for(int j=i+i;j<=MAX;j+=i) hantei[j]=false;
  }
  for(int i=0;i<=MAX;i++){
    if(hantei[i]==true) data.push_back(i);
  }

  for(int i=0;i+3<data.size();i++){
    if((data[i]+2)==data[i+1] && (data[i]+6)==data[i+2] && (data[i]+8)==data[i+3]){
      ans.push_back(data[i+3]);
    }
  }

  while(1){
    int n;
    int f=0;
    int temp;
    cin >> n;
    if(n==0) break;
    for(int i=0;i<ans.size();i++){
      if(ans[i]<=n) temp=ans[i];
      if(ans[i]>n){
        cout << ans[i-1] << endl;
        f=1;
	break;
      }
    }
    if(f==0) cout << temp << endl;
  }
  return 0;
}

Measured memory_bytes: 13000
def ishitach(str):

    length_str = len(str)

    if length_str < len('hi'):
        return 'No'
    else:
        start_index = 0
        end_index = len('hi')
        while end_index <= length_str:
            if str[start_index:end_index] == 'hi':
                pass
            else:
                return 'No'

            start_index = start_index + 2
            end_index = end_index + 2
            if length_str < end_index and str[start_index:] != '':
                return 'No'

    return 'Yes'


if __name__ == '__main__':
    print(ishitach(str(input())))


Measured memory_bytes: 3060