akhauriyash/Code-Regression huggingface dataset:
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func main() {
	io := NewIo()
	defer io.Flush()

	A := io.NextInt()
	B := io.NextInt()
	C := io.NextInt()

	if A < B && A < C && C < B {
		io.PrintLn("Yes")
		return
	}

	if B < A && B < C && C < A {
		io.PrintLn("Yes")
		return
	}

	io.PrintLn("No")

}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var dg = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();

            var n = dg[0];
            var x = dg[1];

            dg = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();

            var list = new List<int>(dg);
            list.Add(x);
            list.Sort();
            list.Reverse();

            var d = list[0] - list[1];
            for (int i = 1; i < n; ++i)
            {
                var diff = list[i] - list[i + 1];
                if (diff == 0) continue;

                d = Gcd(diff, d);
            }

            Console.WriteLine(d);
        }

        static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }

            while (b != 0)
            {
                var r = a % b;
                a = b;
                b = r;
            }

            return a;
        }
    }
}


Measured memory_bytes: 18784
def is_prime(n):
    if n == 2:
        return True
    else:
        for i in range(2, int((n**(1/2)))+1):
            if n % i == 0:
                return False
        return n > 1

from collections import Counter
N = int(input())
MOD = 10**9+7

primes = [i for i in range(N+1) if is_prime(i)] # N以下の素数

c = Counter(primes) # 各素数で何回割れるかを記録する
                    # 最後に約数の個数を求める時、
                    # (各素因数の指数+1)を掛け合わせるので1で初期化されるCounterは都合が良い

# N以下の数について、各素数で割れた回数を数えていく
for j in range(2, N+1):
    for prime in primes:
        while j % prime == 0:
            j //= prime
            c[prime] += 1

ans = 1
for cnt in c.values():
    ans *= cnt # 初期値が1なので1を足す必要はない
print(ans%MOD) # 剰余で答えるのを忘れずに

Measured memory_bytes: 39536
#include <stdio.h>
int main()
{
    int a,b,c;
    while (scanf("%d %d %d",&a,&b,&c)!=EOF)
    {
        if (a==b&&b==c) printf("Yes\n");
        else
        {
            if (c>a&&c<b) printf("Yes\n");
            else printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
def main():
	maximum = 0
	global h, w
	h, w = map(int, input().split())
	street = [[True if z=="." else False for z in input()] for y in range(h)]
	for y in range(h):
		for x in range(w):
			if get(x, y, street):
				r = bfs(x, y, [i[::] for i in street])
				# print(f"x: {x} and y: {y} and r: {r} and max: {maximum}")
				# print(street)
				maximum = max(maximum, r)
	print(maximum)
	return		

def get(x, y, l):
	return l[y][x]

def setter(x, y, z, l):
	l[y][x] = z

def bfs(x, y, visited):
	queue = [(x, y, 0)]
	maximum = 0
	setter(x, y, False, visited)
	for x, y, d in queue:
		if x>0 and get(x-1, y, visited):
			queue.append((x-1, y, d+1))
			setter(x-1, y, False, visited)
		if x<w-1 and get(x+1, y, visited):
			queue.append((x+1, y, d+1))
			setter(x+1, y, False, visited)
		if y>0 and get(x, y-1, visited):
			queue.append((x, y-1, d+1))
			setter(x, y-1, False, visited)
		if y<h-1 and get(x, y+1, visited):
			queue.append((x, y+1, d+1))
			setter(x, y+1, False, visited)
		maximum = max(maximum, d)
	return maximum



main()

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Abc162F
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ');

            var d = long.Parse(input[0]);
            var m = long.Parse(input[1]);

            var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            var sum = a.Sum();

            if (sum > d)
                Console.Write("-1");
            if (sum == d)
                Console.Write("0");
            if (sum < d)
                Console.Write((d - sum));


        }
    }
}


Measured memory_bytes: 20444
a,b = input().split()
if a == 'H' and b == 'H':
	answer = 'H'
if a == 'H' and b == 'D':
	answer = 'D'
if a == 'D' and b == 'H':
	answer = 'D'
if a == 'D' and b == 'D':
	answer = 'H'
print(answer)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using ll = long long;

signed main(){
	int N, K, S;
	std::cin >> N >> K >> S;
	std::vector<int> ans(N, 1e9);
	for(int i = 0; i < K; i++) ans[i] = S;
	if(S == 1e9){
		for(int i = K; i < N; i++) ans[i] = 1;
	}
	for(auto i : ans) std::cout << i << std::endl;
}

Measured memory_bytes: 3768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		StringTokenizer stk;
		float[] kanri=new float[8];
		float[] vec1=new float[2];
		float[] vec2=new float[2];
		String aa="";
		float gaiseki=0;

		try {
			str=bfr.readLine();
			int kaisu=Integer.parseInt(str);

			for(int jj=0; jj<kaisu; jj++) {
				str=bfr.readLine();
				stk=new StringTokenizer(str," ");
				for(int i=0; i<8; i++) {
					kanri[i]=Float.parseFloat(stk.nextToken());
				}
				for(int i=0; i<2; i++) {
					vec1[i]=kanri[i+2]-kanri[i];
					vec2[i]=kanri[i+6]-kanri[i+4];
				}
				gaiseki=vec1[1]*vec2[0]-vec1[0]*vec2[1];
				if(gaiseki==0.0f) {
					System.out.println("YES");
				}
				else {
					System.out.println("NO");
				}
			}

		}catch(IOException e) {

		}
	}
}



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

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] input = br.readLine().split(" ");
            int favoriteSoundCharge = Integer.parseInt(input[0]);
            int pocketMoney = Integer.parseInt(input[1]);
            int maxCount = Integer.parseInt(input[2]);

            int result = maxCount;
            if (pocketMoney < favoriteSoundCharge * maxCount) {
                result = 0;
                while (pocketMoney >= favoriteSoundCharge) {
                    result += 1;
                    pocketMoney -= favoriteSoundCharge;
                }
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
char a[9999],b[9999];
int main()
{
    cin>>a;
    cin>>b;
    int la=strlen(a),lb=strlen(b);
    int l=min(la,lb),ll=max(la,lb);
    for(int i=0;i<=l-1;i++)
        cout<<a[i]<<b[i];
    if(la>lb)
        for(int i=l;i<=ll-1;i++)
            cout<<a[i];
    else for(int i=l;i<=ll-1;i++)
            cout<<b[i];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  for (auto it = vc.begin(); it != vc.end(); ++it)
  {
    if (std::next(it) == vc.end())
      os << *it;
    else
      os << *it << '\n';
  }
  return os;
}

template<class T1, class T2>
inline
std::ostream & operator<<(std::ostream & os, const std::pair<T1, T2> & p)
{
  return os << p.first << ' ' << p.second;
}

struct UnionFind {
  typedef std::pair<ui, ull> Pair;
  std::vector<std::pair<ui, Pair>> node;

  UnionFind(ui N) : node(N)
  {
    rep(0, N) node[i] = {i, {1, 0}};
  }

  ui root(ui x)
  {
    if(node[x].first == x)
    {
      return x;
    }
    else
    {
      return node[x].first = root(node[x].first);
    }
  }

  void unite_tree(ui x, ui y)
  {
    x = root(x);
    y = root(y);
    if(x == y) return;

    if(node[x].second.second < node[y].second.second)
    {
      node[x].first = y;
      node[y].second.first += node[x].second.first;
    }
    else
    {
      node[y].first = x;
      node[x].second.first += node[y].second.first;
      if(node[x].second.second == node[y].second.second) ++node[x].second.second;
    }
  }

  bool isSame(ui x, ui y)
  {
    return root(x) == root(y);
  }

  ui sizeOf(ui x)
  {
    return node[root(x)].second.first;
  }

};

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  using std::cout;
  ui N{}, M{}; std::cin >> N >> M;

  typedef pair<ui, ui> Pair;
  vector<Pair> branch(M);
  rep(0, M) cin >> branch[i].first >> branch[i].second;
  boost::reverse(branch);

  vector<ull> ans(M, 0);
  ans[0] = N * (ull)(N - 1) / 2;

  UnionFind tree(N);
  rep(1, M)
  {
    ui f = branch[i - 1].first - 1;
    ui s = branch[i - 1].second - 1;
    if(tree.isSame(f, s))
    {
      ans[i] = ans[i - 1];
    }
    else
    {
      ans[i] = ans[i - 1] - (ull)tree.sizeOf(f) * tree.sizeOf(s);
      tree.unite_tree(f, s);
    }
  }

  boost::reverse(ans);
  cout << ans << '\n';
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005

int table[SIZE];

int main(){

	int N;
	scanf("%d",&N);

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

		scanf("%d",&table[i]);
	}

	sort(table,table+N);

	int ans = 0,pre = -1;

	for(int i = 0; i < N; i++){
		if(table[i] == pre)continue;

		ans++;
		pre = table[i];
	}

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

	return 0;
}



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

signed main() {
  int N;
  cin >> N;
  
  vector<pair<int, int>> sanka(N);
  int A, B;
  for( int i = 0; i < N; i++ ){
    cin >> A >> B;
    sanka.at(i) = make_pair(A, B);
  }
  
  sort(sanka.begin(), sanka.end());
  int ans = sanka.at(N-1).first + sanka.at(N-1).second;
  cout << ans << endl;
  
  
}

Measured memory_bytes: 1792
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, L, *A = map(int, read().split())

def main(L, A):
    N = len(A)
    is_long = [x + y >= L for x, y in zip(A, A[1:])]
    if not any(is_long):
        print('Impossible')
        return
    print('Possible')
    i = is_long.index(True)
    nums = list(range(1, i + 1)) + list(range(N - 1, i, -1))
    print(*nums, sep='\n')

main(L, A)

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

int main(void) {
	int A,B,C;

	cin >> A >> B >> C;

	for (int i = 0; i < B; i++) {
		if ((A*i) % B == C) {
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;

}

Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N,M = map(int,input().split())

    next = [[] for i in range(N)]
    for i in range(M):
        temp1,temp2 = map(int,input().split())
        next[temp1-1].append(temp2)
        next[temp2-1].append(temp1)

    visited = set([1])
    test = set([i+1 for i in range(N)])

    res = [0 for i in range(N)]
    res[0] = 'No'

    temp = next[0]
    queue = deque(next[0])
    for i in temp:
        res[i-1] = 1
        visited.add(i)

    while queue:
        v = queue.popleft()
        temp = next[v-1]
        for i in temp:
            if i not in visited:
                res[i-1] = v
                queue.append(i)
                visited.add(i)

    # print(visited)
    # print(test)

    if test != visited:
        print(res[0])
    else:
        res[0] = 'Yes'
        for i in range(N):
            print(res[i])



main()


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

class Program
{
	static void Main() => new Program().Solve();

	void Solve()
	{
		var n = ReadLong();
		var a = ReadLongArray();
		var m = 1000L;

		for (var i = 0; i < n; i++) {
			var now = a[i];
			if (i + 1 < n && a[i + 1] <= now) continue;

			for (var j = i + 1; j < n; j++) {
				if (a[j] > now) {
					var kabu = m / now;
					m -= kabu * now;
					m += kabu * a[j];
					i = j - 1;
					break;
				} else if (j == n - 1) {
					goto L1;
				}
			}
		}
	L1:
		Console.WriteLine(m);
	}

	#region Console.Read 関係
	long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	long ReadLong() => long.Parse(Console.ReadLine());
	#endregion
}


Measured memory_bytes: 27536
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
tempmin = 10**5
ans = 0

for i,height in enumerate(h,1):
    temp = abs(a-(t-height*0.006))
    if tempmin > temp:
        ans = i
        tempmin = temp

print(ans)

Measured memory_bytes: 3060
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    map <int,int> cnt;
    int stair,n,a; cin>>stair>>n; 
    vi res(stair+1,0);
    for (int i=0;i<n;i++) {
        cin>>a; 
        cnt[a]++;
    }
    res[0]=1;
    if (!cnt[1]) res[1]=1;
    for (int i=2;i<=stair;i++){
        if (!cnt[i]) res[i] =  res[i-1]+res[i-2]; 
        res[i] = res[i]%1000000007;
    } 
    cout << res[stair] << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}
/*
100 5
1
23
45
67
89
output: 608200469

6 1
3
output: 4

*/

Measured memory_bytes: 10312
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int N, K; cin >> N >> K;
  vector<int> H(N);
  rep(i, N) cin >> H[i];
  sort(H.rbegin(), H.rend());
  rep(i, min(K, N)) H[i] = 0;
  ll ans = 0;
  rep(i, N) ans += H[i];
  cout << ans << endl;

  return 0;
}


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

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
	    int b = sc.nextInt(); 
	    if(b%a == 0) System.out.println(a+b);
	    else System.out.println(b-a);
	}
}

Measured memory_bytes: 23252
n, k = map(int, input().split())
A = list(map(int, input().split()))


def query(lamps):
    start_list = []
    end_list = []
    for idx, power in enumerate(lamps):
        start, end = idx - power, idx + power
        start_list.append(start)
        end_list.append(end)

    start_list.sort(reverse=True)
    end_list.sort(reverse=True)

    now = 0
    for idx in range(n):
        while start_list and start_list[-1] <= idx:
            start_list.pop()
            now += 1

        while end_list and end_list[-1] < idx:
            end_list.pop()
            now -= 1

        lamps[idx] = now


def full_check(counts, full):
    for count in counts:
        if count == full:
            continue
        else:
            return False

    return True


for _ in range(k):
    query(A)
    if full_check(A, n):
        break

print(*A)


Measured memory_bytes: 176244
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
int n;
cin>>n;
int i,a[n],b[n],c[n];
for(i=0;i<n;i++){
    cin>>a[i];
}
for(i=0;i<n;i++)
    cin>>b[i];
for(i=0;i<n-1;i++)
    cin>>c[i];
int sum=b[0];
for(i=1;i<n;i++){
    sum+=b[i];
    if(a[i]==a[i-1]+1)
        sum+=c[a[i-1]-1];
}
cout<<sum<<endl;
}


Measured memory_bytes: 256
//W4P3R
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define re register int 
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pa pair<int,int>
#define fr first
#define sd second
#define Z(x) (x>=mod?x-mod:x)
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
    char ch=getchar();
    ll s=0,w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*w;
}
ll A,B,ans;
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    A=read(),B=read();
    ll nowp=62;
    while(nowp>=0&&((A>>nowp)==(B>>nowp)))nowp--;
    if(nowp>=0)
    {
    	B&=(1LL<<nowp)-1;
    	A&=(1LL<<nowp)-1;
    	ans+=(1LL<<nowp)-A;ll x=1;
    	//cout<<"WTF:"<<A<<" "<<B<<" "<<(1LL<<nowp)<<endl; 
    	REP(i,nowp,0)if((B>>i)&1){x=(1LL<<(i+1));break;}
    	ans+=x;A=max(A,x);
    	ans+=(1LL<<nowp)-A;
	}
	else ans=1;
	printf("%lld\n",ans);
    return 0;
}
//code once,check twice
//bad&sad :(

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#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=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int a, b;
  cin>>a>>b;
  FOR(i, 1, 4){
    if(i!=a && i!= b){
      cout<<i<<'\n';
    }
  }
  return 0;
}


Measured memory_bytes: 256
s=list(input()) 

for i in range(len(s)):

   if s[i] =="?":
      try:
          if s[i+1] =="D" and s[i-1] =="D":
              s[i] ="P" 
          else:
            s[i] ="D" 
      except:
          s[i] ="D" 
print("".join(s)) 

Measured memory_bytes: 10836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pa = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const long double EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    vl a = {1, 4, 7, 9}, b(4);
    rep(i, 4) cin >> b[i];
    sort(all(b));
    cout << ((a == b) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

broken = [0 for _ in range(n+1)]
for i in range(m):
    a = int(input())
    broken[a] = True

    
mod = 1000000007
dp = [0 for _ in range(n+2)]

dp[n] = 1
for i in range(n-1, -1, -1):
    if(broken[i]):
        dp[i] = 0
        continue

    dp[i] = (dp[i+1] + dp[i+2]) % mod

print(dp[0])

Measured memory_bytes: 7832
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) { cout << x << " "; print(args...);}
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct info { int k, value; };


int n;
vector<int> A, dp, ans;
vector<vector<int> > G;
const int INF = 1001001001;

void dfs(int i, int par) {
  int k = lower_bound(all(dp), A[i]) - dp.begin();
  assert(k <= n);
  ll prev = dp[k];
  dp[k] = A[i];
  ans[i] = lower_bound(all(dp), INF) - dp.begin();
  for (auto to : G[i]) {
    if (to != par) dfs(to, i);
  }
  dp[k] = prev; //更新前に戻す
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  cin >> n;
  A = vector<int>(n);
  rep(i,n) cin >> A[i];
  G = vector<vector<int> >(n);
  rep(i,n-1) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  } 
  ans = vector<int>(n);
  dp = vector<int>(n+5, INF);
  dp[0] = A[0];
  for (auto to : G[0]) {
    dfs(to, 0);
  }
  ans[0] = 1;
  rep(i,n) {
    cout << ans[i] << "\n";
  }
  return 0;
}

Measured memory_bytes: 27904
import java.util.Scanner;

public class Main {

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

		String s = sc.next();
		int w = sc.nextInt();

		String ans = "";

		for (int i = 0; i< s.length(); i += w) {
			ans += s.charAt(i);
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 23508
/*
    Problem 98
    https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_e
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int MAX = 100000;
const int mod = 1000000007;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    ll ans = 1;
    vector<ll> cnt(MAX, 0);
    cnt[0] = 3;
    for (int i = 0; i < N; i++) {
        /*
        if (cnt[A[i] - 1] == 0 || cnt[A[i] - 1] <= cnt[A[i]]) {
            ans = 0;
            break;
        }
        */
        ans *= cnt[A[i]]--;
        ans %= mod;
        cnt[A[i] + 1]++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>
#include<limits>
#include <unordered_map>
#include <numeric>
#include <array>
#include <queue>
#include <chrono>
#include <random>
#include <fstream>


using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)
#define INF (1<<29)
#define MD 1000000007

int main() {
	
	long n,mid,nu,mid1,mid2;
	cin >> n;
	vector<long>num(n);
	vector<long>st;
	rep(i, 0, n)cin >> num[i];
	
	nu = (n / 2) - 1;

	copy(num.begin(), num.end(), back_inserter(st));
	sort(st.begin(), st.end());

	mid = st[nu];
	mid1 = st[nu + 1];

	rep(i, 0, n) {
		if (num[i] <= mid)cout << mid1 << endl;
		else cout << mid << endl;		
	}



	return 0;
}


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

int main() {
   int N;
   cin >> N;
   long long A[N];
   for (int i=0; i<N; i++) {
       cin >> A[i];
   }
   long long count=1000;
   int a=0;
   bool b=false;
   for (int i=1; i<N; i++) {
       if (A[i]>A[i-1]) b=true;
       if (b && i==N-1) {
         count+=(count/A[a])*(A[N-1]-A[a]);break;
       }
       if (b && A[i]>A[i+1]) {
           count+=(count/A[a])*(A[i]-A[a]);b=false;
       }
       if (A[i]<A[i-1]) {
           a=i;b=false;
       }
   }
   cout << count << endl;
}


Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	long long x;
	cin>>x;
	for(long long a=1;a<200;a++){
	    for(long long b=0;b<200;b++){
	        if(a>=b){
	            if(pow(a,5)-pow(b,5)==x){
	                cout<<a<<" "<<b;
	                return 0;
	            }
	            if(pow(a,5)+pow(b,5)==x){
	                cout<<a<<" "<<(b*-1);
	                return 0;
	            }
	        }
	    }
	}
	return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int K, T;
    cin >> K >> T;
    vector<int> A(T);
    rep(i, T) cin >> A[i];
    sort(all(A), greater<int>());

    int need = A[0] - 1;
    for (int i = 1; i < T; i++)
        need = max(0, need - A[i]);
    cout << need << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()

if n>=m:
    print("0")
    exit()

li=[0]*(m-1)
for i in range(m-1):
    li[i]=x[i+1]-x[i]

li.sort()

ans=0
for i in range(m-n):
    ans+=li[i]
print(ans)

Measured memory_bytes: 13968
#D heapq
import heapq
def mainasu(n):
    return n*(-1)
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(mainasu,a))
b.sort()
for i in range(m):
    c=heapq.heappop(b)
    if c%2==0:
        heapq.heappush(b,c//2)
    else:
        heapq.heappush(b,c//2+1)
print((-1)*sum(b))

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


int main(){
  int t ;
  cin >> t;
  double max;
  // テ」ツつオテ」ツつ、テ」ツつウテ」ツδュテ」ツ?ョテヲツ閉ー
  for(int i = 0; i < t + 1; i++){
    int n,m;
    double p[200]={};
    double v[200]={};
    cin  >> n >> m;
    for(int j = 0; j < m; j++){
      cin >> v[j] >> p[j] ;
    }
    double exp=0,tmp=0;
    for(int j = 0; j < m; j++){
      tmp += p[j];
    }
    for(int j = 0; j < m; j++){
      exp += v[j] * p[j] /tmp;
    }
    if(i == 0) max = exp;
    else if(i == t) {
      if(max - exp >= 0.0000001) cout <<"YES"<<endl;
      else cout << "NO" << endl;
    }
    else{
      if(max < exp) max = exp;
    }
  }
  return 0;
}

Measured memory_bytes: 1232
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

void main()
{
    auto N = readln.chomp.to!size_t;
    auto AS = readln.split.to!(long[]);
    auto BS = readln.split.to!(long[]);
    auto CS = readln.split.to!(long[]);

    sort(AS);
    sort(BS);
    sort(CS);

    long[] bmemo;
    bmemo.length = N;
    size_t i;
    foreach (j, b; BS) {
        for (; i < N; ++i) if (AS[i] >= b) break;
        bmemo[j] = i + (j == 0 ? 0 : bmemo[j-1]);
    }

    i = 0;
    long ret;
    foreach (c; CS) {
        for (; i < N; ++i) if (BS[i] >= c) break;
        ret += i == 0 ? 0 :  bmemo[i-1];
    }

    writeln(ret);
}

Measured memory_bytes: 12156
N = int(input())
if N < 105:
    print(0)
else:
    ans = 0
    for i in range(N, 104, -1):
        tmp = sum((i%j==0)*1 for j in range(1, i+1))
        if tmp == 8 and i % 2:
            ans += 1
    print(ans)


Measured memory_bytes: 2940
n,k = map(int,input().split())
v = list(map(int,input().split()))
rev = v[::-1]
leftsum = [0]
rightsum = [0]
s = 0
for i in v:
    s = s+i
    leftsum.append(s)
s = 0
for i in v[::-1]:
    s = s+i
    rightsum.append(s)

m = 0
kn = min(k,n)
if kn==0:
    print(0)
    exit(0)

for x in range(1,k+1):
    for a in range(x+1):
        if a>n:
            break
        for b in range(x-a+1):
            if (b+a)>n:
                break
            minus= [i for i in v[:a] if i<0]
            minus.extend([i for i in rev[:b] if i<0])
            minus.sort()
            cd = x-a-b
            tmp = leftsum[a]+rightsum[b]-sum(minus[:cd])
            m = max(m,tmp)

print(m)

Measured memory_bytes: 50392
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  long long a, b, c;
 
  cin >> a >> b >> c;
  
  long long d = c - b - a;
  
  if(4 * a * b < d * d && d > 0){
    cout << "Yes";
    return 0;
  }
 
  cout << "No";
  return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std; 
ll N = pow(10,10);
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int n,k;cin>>n>>k;
	int ans=0;
	if(k==1){
		ans =0;
	}
	else{
		ans = n-k;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n,k,c=map(int,input().split())
S=list(input())
A=[]
B=[]
i=0
while i<n:
  if S[i]=="o":
    A.append(i)
    i=i+c+1
  else:
    i=i+1
i=n-1
while i>-1:
  if S[i]=="o":
    B.append(i)
    i=i-c-1
  else:
    i=i-1
if len(A)>k or len(B)>k:
  exit()
B.sort()
for i in range(k):
  if A[i]==B[i]:
    print(A[i]+1)

Measured memory_bytes: 21996
def main():
    n = int(input())
    mod = 10 ** 9 + 7 #素数
    
    def modpow(x, n, mod):
        res = 1
        while n:
            if n % 2:
                res *= x % mod
            x *= x % mod
            n >>= 1
        return res
 
    # 全パターン:10 ** n
    all_p = modpow(10, n, mod)
    # 0を含まないパタンーン:9 ** n
    not_0 = modpow(9, n, mod)
    # 9を含まないパターン:9 ** n
    not_9 = modpow(9, n, mod)
    # 0と９を含まないパターン:8 ** n
    not_0_9 = modpow(8, n, mod)
    # 条件のパターン
    ans = (all_p - not_0 - not_9 + not_0_9) % mod
    print(ans)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 9124
a=int(input())

res_list = []

for i in range(a):
  b,c = input().split()

  ref = {'name':b, 'point':int(c), 'num': i+1}
  res_list.append(ref)

  
scores_sorted = sorted(res_list, key=lambda x:(x['name'],-x['point']))

for k in scores_sorted:
  print(k['num'])

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner cin = new Scanner(System.in);
    int a, b, c;
    int aa, bb, cc;
    int ans = 0;
    int tmp_a, tmp_b;

    a = cin.nextInt();
    b = cin.nextInt();
    c = cin.nextInt();

    aa = a;
    bb = b;
    cc = c;

    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
      tmp_a = a;
      a = b / 2 + c / 2;
      tmp_b = b;
      b = tmp_a / 2 + c / 2;
      c = tmp_a / 2 + tmp_b / 2;
      ans ++;
      //System.out.println(a + " " + b + " " + c);
      if (a == aa & b == bb & c == cc){
        ans = -1;
        break;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
<?php

$text = fgets(STDIN);
$text = str_replace(array('apple', 'peach'), array('ppeeaacchh', 'aappppllee'), $text);
$text = str_replace(array('aappppllee', 'ppeeaacchh'), array('apple', 'peach'), $text);

echo $text;



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

int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int A,B,X;
  cin>>A>>B>>X;
  bool f=(A<=X&&X<=A+B);
  cout<<(f?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
//void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////



int main(){fastio
    ll n;cin>>n;
    ll v[n],c[n];
    rep(i,0,n-1)cin>>v[i];
    rep(i,0,n-1)cin>>c[i];
    ll ans=0;
    rep(i,0,(1<<n)-1){
        ll sum=0;
        rep(j,0,n-1){
            if((i>>j)&1){
                sum+=v[j]-c[j];
            }
        }
        Max(ans,sum);
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_YX = 1500;

int v[MAX_YX][MAX_YX], N;

double solve(){
  memset(v, 0, sizeof(v));
  vector<double> L, T, R, B;
  set<double> Ys, Xs;
  REP(i, N){
    double x, y, _r; cin >>x >>y >>_r;
    x += 210; y += 210;
    double l = x - _r, t = y + _r, r = x + _r, b = y - _r;
    L.push_back(l); T.push_back(t); R.push_back(r); B.push_back(b);
    Ys.insert(t); Ys.insert(b); Xs.insert(l); Xs.insert(r);
  }
  Ys.insert(0); Ys.insert(1e6 + 10);
  Xs.insert(0); Xs.insert(1e6 + 10);
  vector<double> Y(Ys.begin(), Ys.end());
  vector<double> X(Xs.begin(), Xs.end());
  double res = 0.0;
  REP(i, N){
    int xl = lower_bound(X.begin(), X.end(), L[i]) - X.begin();
    int xr = lower_bound(X.begin(), X.end(), R[i]) - X.begin();
    int yt = lower_bound(Y.begin(), Y.end(), T[i]) - Y.begin();
    int yb = lower_bound(Y.begin(), Y.end(), B[i]) - Y.begin();
    FOR(x, xl, xr){
      FOR(y, yb, yt){
        if(v[x][y] == 0) res += (Y[y + 1] - Y[y]) * (X[x + 1] - X[x]);
        v[x][y] = true;
      }
    }
  }
  return res;
}

int main(){
  int t = 1;
  while(cin >> N && N) printf("%d %.2lf\n", t++, solve());
  return 0;
}

Measured memory_bytes: 10072
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
double n,x[10],y[10],p,d[10][10],ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>x[i]>>y[i];
	p=1;
	for(int i=1;i<n;i++)
		p*=i;
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
			ans+=1.00000000*(n-1)*sqrt(1.00000000*(x[i]-x[j])*(x[i]-x[j])+1.00000000*(y[i]-y[j])*(y[i]-y[j]));
		cout<<fixed<<setprecision(8)<<ans/n/(n-1)*2;
	return 0;
}

Measured memory_bytes: 256
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

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

/* see https://github.com/pllk/cphb/
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;
 **/

typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

//typedef __int128 lll;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cins(s);
    cins(t);

    vvi f('z'+1);
    for(size_t i=0; i<s.size(); i++)
        f[s[i]].push_back(i);

    ll ans1=0;
    ll ans2=-1;
    for(size_t i=0; i<t.size(); i++) {
        if(f[t[i]].size()==0) {
            ans1=0;
            ans2=-2;
            break;
        }

        auto it=upper_bound(f[t[i]].begin(), f[t[i]].end(), ans2);
        if(it==f[t[i]].end()) {
            ans1++;
            ans2=f[t[i]][0];
        } else
            ans2=*it;
    }

    ans1*=s.size();
    ll ans=ans1+ans2+1;
    cout<<ans<<endl;
}



Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
int _I(){ int x ; scanf("%d", &x); return x; }
struct node
{
    int a , b;
    node(){};
    node( int x , int y )
    {
        a = x;
        b = y;
    }
};
node ar[ 1004 ];
int dp[ 1005 ][ 10005 ];
int n;
int goo( int idx , int w )
{
    if( w <= 0 ) return 0;
    if( idx == n ){
        if( w > 0 ) return 100000000;
        return 0;
    }
    if( dp[ idx ][ w ] != -1 ) return dp[ idx ][ w ];
    int ans = min( goo( idx , w-ar[ idx ].a )+ar[ idx ].b  , goo( idx+1 , w ) );
    return dp[ idx ][ w ] = ans;
}
void solve()
{
    int h = _I();
    n = _I();
    for( int i = 0 ; i < n; i++ )
    {
        int x = _I();
        int y = _I();
        ar[ i ] = node( x , y );
    }
    memset( dp , -1 , sizeof( dp ) );
    cout<<goo( 0 , h )<<"\n";
}
int main()
{
    solve();
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c);
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define mod          1000000007

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

#define scan(x)      do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//bool ok = true;
//char ch;
//string S, T, U;
ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;
double x=56, y, z;
int main()
{

    //scan(n);
    cin>>n;
    double A[n];
    f0(i,n)
    {
        cin>>A[i];
    }
    sort(A,A+n);
    for(ll i=1;i<(n);i++)
    {
        x = (A[i-1]+A[i])/2;
        A[i] = x;
    }
    printf("%.5f\n",x);
    return 0;
}


Measured memory_bytes: 256
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"2 4 6
" => r"YES",

r"2 5 6
" => r"NO",

r"3 2 1
" => r"YES"
}

use std::cmp;
use std::cmp::{max, min};
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: i32,
        b: i32,
        c: i32,
    }

    if b - a == c - b {
        "YES".to_string()
    } else {
        "NO".to_string()
    }
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main(){
ll n,a,b;
cin>>n>>a>>b;
if(a>b){
    cout<<0<<endl;
    
}else if(a==b){
    cout<<1<<endl;
}else if(a!=b&&n==1){
    cout<<0<<endl;
}

else{
    ll MAX=b+a*(n-1),MIN=a+b*(n-1);
    cout<<-MAX+MIN+1<<endl;
}



  return 0;
}


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

constexpr long lim = 1e6+1;
vector<vector<int>> pr(lim), id(lim);
vector<bool> is_pr(lim, true);

void all_fac() {
  is_pr.at(0) = 0;
  is_pr.at(1) = 0;
  for (int i = 2; i < lim; i++) {
    if (is_pr.at(i)) {
      pr.at(i).push_back(i);
      id.at(i).push_back(1);
      for (int j = 2 * i; j < lim; j += i) {
        is_pr.at(j) = false;
        int cnt = 0;
        int nw = j;
        while (nw % i == 0) {
          nw /= i;
          cnt++;
        }
        pr.at(j).push_back(i);
        id.at(j).push_back(cnt);
      }
    }
  }
}

constexpr int MOD = 1000000007;

long mpow(long a, long b) {
  long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

long inv(long a) {
  long b = MOD, u = 1, v = 0;
  while (b) {
    long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= MOD;
  if (u < 0) u += MOD;
  return u;
}

int main() {
  all_fac();
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  map<int, int> MA;
  for (int i = 0; i < N; i++) {
    int a = A.at(i);
    for (int i = 0; i < (int) pr.at(a).size(); i++) {
      MA[pr.at(a).at(i)] = max(MA[pr.at(a).at(i)], id.at(a).at(i));
    }
  }
  long L = 1;
  for (auto [a, b] : MA) {
    L *= mpow(a, b);
    L %= MOD;
  }
  long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += L * inv(A.at(i));
    ans %= MOD;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 114648
from collections import defaultdict

x, y = [int(i) for i in input().split()]
prize = defaultdict(int)
prize[1] = 300000
prize[2] = 200000
prize[3] = 100000

if x == 1 and y == 1:
  print(prize[1] + prize[1] + 400000)
  exit(0)

print(prize[x] + prize[y])

Measured memory_bytes: 9392
#include<iostream>
#include<string>
using namespace std;
int main(){
int n,i,j,k,l,m,u,v,c;
string s,t,w;
cin>>n;
for(k=0;k<n;k++){
cin>>s>>t;
l=s.size();if(l>80){cout<<"overflow"<<endl;continue;}
m=t.size();if(m>80){cout<<"overflow"<<endl;continue;}
if(l<m){w=s;s=t;t=w;c=l;l=m;m=c;}
for(c=0,i=l-1,j=m-1;j>=0;i--,j--){
u=s[i]-48;v=t[j]-48;
u+=(v+c);
if(c=(u>9))u-=10;
s[i]=u+48;
}
for(;i>=0;i--){
u=s[i]-48;
u+=c;
if(c=(u>9))u-=10;
s[i]=u+48;
}
if(l>=80&&c==1){cout<<"overflow"<<endl;continue;}
if(c==1)cout<<"1";cout<<s<<endl;
}
return 0;
}

Measured memory_bytes: 1208