akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
using namespace std;
 
int main(){
    int a,b;
    cin >> a >> b;
    cout << fixed;
    cout << setprecision(5);
    cout << a/b << " " << a%b << " " << (double)a/b << endl;
    return 0;
}


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


int main()
{
	double a, b, c, d;
	int x, y;
	cin>>a>>b>>c>>d;
	x = ceil(c/b);
	y = ceil(a/d);
	
	if(x<=y)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 3688
x, k, d = map(int, input().split())


if x == 0:

    if k % 2 == 0:
        ans = 0
    else:
        ans = d

elif x > 0:
    amari = x % d
    kouho1 = amari
    kouho2 = amari - d
    kyori1 = abs(x - kouho1)
    kyori2 = abs(x - kouho2)
    if kyori1 // d > k:
        ans = x - k * d

    elif (kyori1 // d) % 2 == 1:
        if k % 2 == 1:
            ans = abs(kouho1)
        else:
            ans = abs(kouho2)
    else:
        if k % 2 == 0:
            ans = abs(kouho1)
        else:
            ans = abs(kouho2)
else:
    x *= -1
    amari = x % d
    kyori1 = abs(x - amari)
    kyori2 = abs(x - (amari - d))
    if kyori1 // d > k:
        ans = abs(x - k * d)
    elif (kyori1 // d) % 2 == 1:
        if k % 2 == 1:
            ans = abs(amari)
        else:
            ans = abs(amari - d)
    else:
        if k % 2 == 0:
            ans = abs(amari)
        else:
            ans = abs(amari - d)
print(ans)


Measured memory_bytes: 9252
from itertools import accumulate
n=int(input())
l=[0]+list(accumulate(list(map(int,input().split()))))
ans=float("INf")
lnow=1
rnow=3
for center in range(2,n-1):

    laim=l[center]//2
    while lnow+1<center and l[lnow+1]<laim:lnow+=1
    if rnow<=center:rnow=center+1
    raim=(l[-1]-l[center])//2
    while rnow+1<n and l[rnow+1]-l[center]<raim:rnow+=1
    for i,j in ((0,0),(1,0),(1,1),(0,1)):
        if lnow+i<center and rnow+j<n:
            a=(l[lnow+i],l[center]-l[lnow+i],l[rnow+j]-l[center],l[-1]-l[rnow+j])
            ans=min(ans,max(a)-min(a))
print(ans)

Measured memory_bytes: 32728
def rec(num, d)
    num == 0 ? 0 : num % d + rec(num/d, d)
end

N = gets.to_i
ans = 10**18
(0..N).each do |i|
    j = N - i
    ans = [ans, rec(i, 6) + rec(j, 9)].min
end
puts ans

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

listForStudent = []
index=0
while index < n:
    listI = list(map(int, input().split()))
    listForStudent.append(listI)
    index+=1

listForCheck=[]
index2=0
while index2 < m:
    listI2= list(map(int, input().split()))
    listForCheck.append(listI2)
    index2+=1

index3=0
listForAnswer=[]
while index3 < len(listForStudent):
    answer=2*(10**8)
    index4=0
    while index4 < len(listForCheck):
        if index4==0:
            indexA = index4+1
        distX = max(listForCheck[index4][0], listForStudent[index3][0]) - \
            min(listForCheck[index4][0], listForStudent[index3][0])
        distY = max(listForCheck[index4][1], listForStudent[index3][1]) - \
            min(listForCheck[index4][1], listForStudent[index3][1])
        totalDist = distX+distY
        if answer > totalDist:
            answer = totalDist
            indexA = index4+1
        index4+=1
    listForAnswer.append(indexA)
    index3+=1

for ans in listForAnswer:
    print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}

int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//これは昇べきの順のソート

//int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
//これは降べきの順のソート

//qsort(配列, 長さ, sizeof(int), compare_int);

double BS(int array[],int len,int target);


void merge(long long a1[],long long len_a1,long long a2[],long long len_a2,long long a[]){
    long long i = 0,j = 0;
    while(i<len_a1 || j<len_a2){
        if(j>=len_a2 || (i<len_a1 && a1[i]<a2[j])){
            a[i+j] = a1[i];
            i++;
        }else{
            a[i+j] = a2[j];
            j++;
        }
    }
}
void mergeSort(long long a[],long long len_a){
    if(len_a > 1){
        long long m = len_a/2;
        long long n = len_a - m;
        long long a1[m];
        long long a2[n];
        for(long long i = 0;i < m;i++) a1[i] = a[i];
        for(long long i = 0;i < n;i++) a2[i] = a[m+i];
        mergeSort(a1,m);
        mergeSort(a2,n);
        merge(a1,m,a2,n,a);
    }
}
 
//////////////////////////////////////////


int A,B,C;

int main(){
    scanf("%d%d%d",&A,&B,&C);
    if((A<C && C<B) || (B<C && C<A)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}



///////////////////////////////////////////


double BS(int array[],int len,int target){ //(配列,長さ,見つける値)
    int low,mid,high;

    low = 0;
    high = len-1;

    int mark;

    while(low <= high){
        mid = (low + high) / 2;
        if(array[mid] == target){
            mark = 0;
            break;
        }else if(array[mid] < target){
            low = mid + 1;
            mark = 1;
        }else{
            high = mid - 1;
            mark = -1;
        }
    }
    if(mark == 0){
        return mid; //配列の何番目か（０から）
    }else if(mark == 1){
        return (double)mid + 0.5;//なかったらどこのあいだか
    }else{
        return (double)mid - 0.5;
    }
}


Measured memory_bytes: 128
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    
    print(int(a)//3)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define dump(x)      cerr << #x << " = " << (x) << endl;


int main() {
    LL A, P;
    cin >> A >> P;
    P += A * 3;
    cout << P / 2 << endl;
	
    return 0;
}


Measured memory_bytes: 256
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Wed Mar  7 22:15:30 2018
//
package main

import (
	"fmt"
)

var n, m int

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

func main() {
	fmt.Scan(&n, &m)
	arr := make([]int, m)

	for i := 0; i < m; i++ {
		fmt.Scan(&arr[i])
	}

	dp := make([]int, n+1)
	for i := 0; i < len(dp); i++ {
		dp[i] = 1 << 30
	}
	dp[0] = 0
	for i := 0; i < len(dp); i++ {
		for _, val := range arr {
			if 0 <= i-val {
				dp[i] = min(dp[i], dp[i-val]+1)
			}
		}
	}

	fmt.Println(dp[n])
}



Measured memory_bytes: 1568
//AcFreak

#include<bits/stdc++.h>
#define  lint long long int 
#define MOD (lint )(1e9+7)
using namespace std;

int main()
{
      int a,b;
      cin>>a>>b;
      
      if(a>8 ||b>8)
      cout<<":("<<endl;
      else
      cout<<"Yay!"<<endl;
      return 0;
}

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

int main(){
    int a,b;
    cin>>a>>b;
    if(a>0&&b>0)cout<<"Positive"<<endl;
    else if(a<=0&&b>=0)cout<<"Zero"<<endl;
    else if(a<0&&b<0){
        if((b-a)%2==0&&b!=a)cout<<"Negative"<<endl;
        else cout<<"Positive"<<endl;
    }
    return 0;
}

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

a, b=[0], [0]
for i in range(N):
  a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])
    
ans, j=0, M
for i in range(N+1):
  if a[i]>K:
    break
  while b[j]>K-a[i]:
    j-=1
  ans=max(ans, i+j)
  
print(ans)

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

#define INF -1

struct Node{
  int parent,left,right;
};

Node T[30];
int F[30];

void Preorder(int u);
void Inorder(int u);
void Postorder(int u);

int main(){
  int n,r,l,id,root;
  cin>>n;
  //初期化
  for(int i=0;i<n;i++){
    T[i].parent=INF;
  }
  //入力
  for(int i=0;i<n;i++){
    cin>>id>>l>>r;
    T[id].left=l;
    T[id].right=r;
    if(l!=INF)T[l].parent=id;
    if(r!=INF)T[r].parent=id;
  }
  //root確認
  for(int i=0;i<n;i++){
    if(T[i].parent==INF)root=i;
  }
  
  cout<<"Preorder"<<endl;
  Preorder(root);
  cout<<endl;
  
  cout<<"Inorder"<<endl;
  Inorder(root);
  cout<<endl;

  cout<<"Postorder"<<endl;
  Postorder(root);
  cout<<endl;
}

void Postorder(int u){
  if(T[u].left!=INF)Postorder(T[u].left);
  if(T[u].right!=INF)Postorder(T[u].right);
  //if(T[u].parent!=INF)
    cout<<" "<<u;
  return;
}

void Preorder(int u){
  // if(F[u]==0)
    cout<<" "<<u;
  if(T[u].left!=INF)Preorder(T[u].left);
  if(T[u].right!=INF)Preorder(T[u].right);
  return;
}

void Inorder(int u){
  if(T[u].left!=INF)Inorder(T[u].left);
  cout<<" "<<u;
  if(T[u].right!=INF)Inorder(T[u].right);
  return;
}

Measured memory_bytes: 1168
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]


N, hit_point = fetch_int_input()
swords = fetch_ints_inputs(N)
SLASH, THROW = 0, 1

max_slash_id, max_slash = -1, -1

for idx, sword in enumerate(swords):
    if max_slash <= sword[SLASH]:
        if max_slash == sword[SLASH] and sword[THROW] < swords[max_slash_id][THROW]:
            continue

        max_slash = sword[SLASH]
        max_slash_id = idx


max_slash_throw = swords[max_slash_id][THROW]
# del swords[max_slash_id]
large_throw_swords = list(filter(lambda x: x[THROW] > max_slash, swords[:]))
large_throw_swords.sort(key=lambda x: x[1], reverse=True)

count = 0
is_clear = False

for s in large_throw_swords:

    # if max_slash_throw >= H:
    #    count += 1
    #    H -= max_slash_throw
    #    break

    hit_point -= s[THROW]
    count += 1
    if hit_point <= 0:
        break

import math
if hit_point > 0:
    count += math.ceil(hit_point / max_slash)

print(count)



Measured memory_bytes: 64092
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]

def warshal_floyd(d):
  for k in range(n):
    for i in range(n):
      for j in range(n):
        d[i][j] = min(d[i][j], d[i][k]+d[k][j])
  return d

import copy
B = copy.deepcopy(A)
B = warshal_floyd(B)

ans = 0
for i in range(n):
    for j in range(n):
        if B[i][j] < A[i][j]:
            print(-1)
            exit()
        else:
            for k in range(n):
                if k == i or k == j:
                    continue
                if B[i][j] == B[i][k] + B[k][j]:
                    break
            else:
                ans += A[i][j]
ans //=2
print(ans)

Measured memory_bytes: 56540
#include "bits/stdc++.h"

using namespace std;

char getchar(size_t i, size_t j)
{
    return (i + j) % 2 == 0 ? '#' : '.';
}

int main()
{
    while (true) {
        size_t n, m;
        cin >> n >> m;
        if (n == 0 || m == 0) break;
        for (size_t i = 0; i < n; ++i) {
            for (size_t j = 0; j < m; ++j) {
                cout << getchar(i, j);
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


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

vector<string> kouho;

void fn( int A, string S ){
  if( A == 0 ){
    kouho.push_back(S);
  }else{
    for( char i = 'a'; i <= 'd'; i++ ){
      fn( A-1, S+i);
    }
  }
}

signed main(){
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  
  fn(N, "");
  
  vector<int> L(N);
  for( int i = 0; i < N; i++ ) cin >> L.at(i);
  
  int ans = 30000000;
  for( int i = 0; i < kouho.size(); i++ ){
    int a = 0;
    int b = 0;
    int c = 0;
    int now = 0;
    for( int j = 0; j < N; j++ ){
      if( kouho.at(i).at(j) == 'a' ){
        if( a > 0 ) now += 10;
        a += L.at(j);
      }else if( kouho.at(i).at(j) == 'b' ){
        if( b > 0 ) now += 10;
        b += L.at(j);
      }else if( kouho.at(i).at(j) == 'c' ){
        if( c > 0 ) now += 10;
        c += L.at(j);
      }
    }
    
    if( a == 0 || b == 0 || c == 0 ) continue;
    now += abs(A-a)+abs(B-b)+abs(C-c);
    ans = min(ans, now);
  }
  
  cout << ans << endl;


}

Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define pii pair<int, int>
ld const pi = 3.141592653589793238462;
int const mod = 1e9+7;

int power(int a,int b){
    int f=1;
    while(b>0){
        if(b&1){
            f=f*a;
        }
        a=a*a;
        b=b/2;
    }
    return f;
}

vector<pair<pair<string, int> ,int> > v;

bool cmp(pair<pair<string, int> ,int> a ,pair<pair<string, int> ,int> b)
{
    if(a.ff.ff < b.ff.ff) return true;
    else if(a.ff.ff == b.ff.ff){
        if(a.ff.ss >= b.ff.ss) return true;
        else return false;
    }
    else return false;
}

int32_t main(){
    IOS;
    int n,i,j,l;
    cin>>n;
    for(i=0;i<n;i++){
        string s;
        int x;
        cin>>s>>x;
        v.pb(mp(mp(s,x),i+1));
    }
    sort(v.begin(),v.end(),cmp);
    for(i=0;i<n;i++){
        cout<<v[i].ss<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
 * URL 		: https://atcoder.jp/contests/dp/tasks/dp_c
 * DATE		: 26th Jan, 2019
 */

//___________________________________________________________________________________________________________
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;

#define rep(i,a,b)  for(int i=a; i<b; i++)
#define req(i,a,b)  for(int i=b-1; i>=a; i--)
#define trv(it,s)   for(auto it=s.begin(); it!=s.end(); it++)
#define trs(it,s)   for(auto &it : s)

#define endl        '\n'
#define pb          push_back
#define F           first
#define S           second
#define ll          long long
#define pii         pair<int,int>
#define vpii        vector<pii>
#define vi          vector<int>
#define vii         vector<vi>
#define mi          map<int,int>
#define umap        unordered_map
#define uset        unordered_set
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define fill(a,x)   memset(a,x,sizeof(a))
#define num1(x)     __builtin_popcount(x)

#define db(a)       cout<<"---DEBUG : "<<a<<"\n"
#define wa(x)       cout << (#x) << " -------- " << (x) << endl
#define line1	    printf("---------------------------------------\n")
#define line2	    printf("_______________________________________\n")

#define MOD         1000000007 
#define PI          2 * acos(0.0)

//#define int 		long long
//#define printf      //

//___________________________________________________________________________________________________________
void pmap(auto l){
	trv(itt,l) printf("%d %d\n", itt->fi, itt->se);
	line1;
}

void pvi(vector<int> pvec, string name="") {
	if(name != "") cout<<"Output of "<<name<<" : ";
	for(int i=0;i<pvec.size();i++) cout<<pvec[i]<<" ";
	cout<<endl;
}

int gcd(int n,int m) {return m==0?n:gcd(m,n%m);}

int o(ll a) {return a%MOD;}

ll mpow(ll base, ll power){
	if(power==0) return 1;
	if(power==1) return base;
	ll exp = mpow(base,power/2);
	exp = exp*exp;
	if(power%2==1) exp = exp * base;
	return exp;
}
//___________________________________________________________________________________________________________

void solve();

int32_t main() {

//	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int notc = 1; 
//	cin>>notc;

	while(notc--) {
		solve();
		//printf("========================================================\n");
	}
}
//___________________________________________________________________________________________________________


void solve() {

	int n;
	cin>>n;

	vii v;
	vii dp;

	rep(i,0,n){
		vi r(3,0);

		cin>>r[0]>>r[1]>>r[2];
		v.pb(r);

		dp.pb(r);
		
		if(i != 0){
			dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + v[i][0];
			dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + v[i][1];
			dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + v[i][2];

			int ans = max(max(dp[i][0], dp[i][1]), dp[i][2]);
			// wa(ans);	
		}
	}

	int ans = max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]);
	cout << ans << endl;
















}

Measured memory_bytes: 11872
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int N = scanner.nextInt();
		    int M = scanner.nextInt();
		    
		    System.out.println((N-1)*(M-1));
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 21844
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author kessido
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFairness solver = new AFairness();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFairness {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long A = in.NextInt();
            long B = in.NextInt();
            long C = in.NextInt();
            long K = in.NextLong();
            if (K % 2 == 0) {
                out.println(A - B);
            } else {
                out.println(B - A);
            }
//      0  A                          B                        C
//      1  B+C                     A+C                     A + B
//      2  2A+B+C                 A+2B+C                   A+B+2C
//      3  2A+3B+3C               3A+2B+3C                 3A+3B+2C
//      4  6A+5B+5C               5A+6B+5C                 5A+5B+6C
//      5  10A+11B+11C            11A+10B+11C              11A+11B+10C
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine(), " \t\n\r\f,");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NextInt() {
            return Integer.parseInt(next());
        }

        public long NextLong() {
            return Long.parseLong(next());
        }

    }
}



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


int main() {
	int n, a, b;
	cin >> n >> a >> b;

	int sum = 0;
	for (int i = 1; i <= n; i++) {
		string s = to_string(i);
		int sum_num = 0;
		for (int j = 0; j < s.size(); j++) {
			sum_num += s.at(j) - '0';
		}
		if (a <= sum_num && sum_num <= b) sum += i;
	}

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    K, S = map(int, input().split())
    ans = 0
    for X in range(K + 1):
        for Y in range(K + 1):
            Z = S - X - Y
            if Z >= 0 and Z <= K:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, M;
	cin >> N >> M;

	vector<vector<Int>> ab(N, vector<Int>(2, 0));
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < 2; j++) {
			cin >> ab[i][j];
		}
	}

	sort(ab.begin(), ab.end());

	Int ans = 0;
	Int res = 0;//通算購入本数
	for (Int i = 0; i < N; i++) {
		if (res + ab[i][1] <= M) {
			ans += ab[i][1] * ab[i][0];
			res += ab[i][1];
			continue;
		}
		else {
			ans += ab[i][0] * (M - res);
			break;
		}
	}

	cout << ans << endl;

}

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

#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}

ll mod(ll a, ll b) {return (a % b + b) % b;}

ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}

using namespace std;

int main() 
{	
	fast;
	ll n,m; cin>>n>>m;
	vector<ll>*graph = new vector<ll>[n+2];
	ll height[n+1];
	for(ll i = 1; i <= n; i++)
	{
		cin>>height[i];
	}
	for(ll i = 0; i < m; i++)
	{
		ll x,y; cin>>x>>y;
		graph[x].push_back(y);
		graph[y].push_back(x);
	} ll ans = 0;
	for(ll i = 1; i <= n; i++)
	{
		ll flag = 0; 
		ll kk = height[i];
		for(ll j = 0; j < graph[i].size(); j++)
		{
			if(kk <= height[graph[i][j]])
				flag = 1;
		}
		if(flag == 0)
		{
		//	cout << i << endl;
			ans++;
		}
	}
	cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 10240
//                                                   ¯\_(ツ)_/¯
  #pragma GCC optimize("Ofast")
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
#define pi pair<int,int>
const int N=1e5,MOD=998244353;

using namespace std;

int n,W;
ll dp[105][100005];
ll ans;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	scanf("%d %d",&n,&W);

	std::vector<int> v(n),w(n);
	
	for(int i=0;i<n;i++)scanf("%d %d",&w[i],&v[i]);

	for(int i=0;i<n;i++)for(int j=0;j<100005;j++)dp[i][j]=W+1;

	dp[0][v[0]]=w[0];

	for(int i=0;i<n;i++)dp[i][0]=0;
		

	for(int i=1;i<n;i++){

		for(int j=0;j<=N;j++){
			if(j>=v[i])dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
			else dp[i][j]=dp[i-1][j];
		}
	}

	for(int i=N;i>=0;i--){

		if(dp[n-1][i]<=W)return !printf("%d\n",i );
	}
}

Measured memory_bytes: 80128
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def sigma(b):
    return (b+1)*b//2


S = input()[:-1]
N = len(S)
L = []
if S[0] == ">":
    L.append(("U", 0))
else:
    L.append(("D", 0))
for i, a, b in zip(range(1, N), S, S[1:]):
    if a == b:
        continue
    else:
        if a == "<" and b == ">":
            L.append(["U", i])
        else:
            L.append(["D", i])
if S[-1] == ">":
    L.append(["D", N])
else:
    L.append(["U", N])

ans = 0
if L[0][0] == "U":
    ans += sigma(L[1][1]-L[0][1])
if L[-1][0] == "U":
    ans += sigma(L[-1][1]-L[-2][1])
for i in range(1, len(L)-1):
    if L[i][0] == "U":
        dist_long = max(L[i][1]-L[i-1][1], L[i+1][1]-L[i][1])
        dist_small = min(L[i][1]-L[i-1][1], L[i+1][1]-L[i][1])
        ans += sigma(dist_long) + sigma(dist_small-1)
print(ans)


Measured memory_bytes: 37512
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 3 * 1000 * 100+47;
const double EPS = 1e-8;
const int MOD = 1000 * 1000 * 1000 + 7;

pair<PII, int> A[MAX];
int B[MAX];
int L[MAX], R[MAX];
int T[MAX];


int main()
{
    int n;
    scanf("%d", &n);
    FOR(i, 0, n)
    {
        int x, y;
        scanf("%d%d", &A[i].first.first, &A[i].first.second);
    }
    sort(A, A + n);
    FOR(i, 0, n)A[i].second = i;
    FOR(i, 0, n)swap(A[i].first.first, A[i].first.second);
    sort(A, A+n);
    FOR(i, 0, n)B[A[i].second] = i;
    
    FOR(i, 0, n)R[i] = max(i ? R[i-1] : -INF, B[i]);
    RFOR(i, n, 0)L[i] = min(i == n - 1 ? INF : L[i+1], B[i]) ;
    FOR(i, 0, n)R[i]++, L[i]++;
    
    FOR(j, 0, n)
    {
        int res = 0;
        for(int i = R[j]; i; i -= i & (-i))
            (res += T[i]) %= MOD;
        for(int i = max(0, L[j]-2); i; i -= i & (-i))
            (res += MOD - T[i]) %= MOD;
        (res += (L[j] == 1)) %= MOD;
        for(int i = R[j]; i <= n; i += i & (-i))
            (T[i] += res) %= MOD;
    }
    
    
    int ans = 0;
    for(int i = n; i; i -= i & (-i)) (ans += T[i]) %= MOD;
    for(int i = n-1; i; i -= i & (-i)) (ans += MOD - T[i]) %= MOD;
    printf("%d\n", ans);
    
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
map<ll, int> enumpr(ll n) {
    map<ll, int> V;
    for (ll i = 2; i*i <= n; i++) while (n%i == 0) V[i]++, n /= i;
    if (n > 1) V[n]++;
    return V;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/












ll N;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;

    auto ep = enumpr(N);

    int ans1 = ep.size();
    int ans2 = 1;
    fore(p, ep) ans2 *= (p.second + 1);
    ans2--;

    printf("%d %d\n", ans1, ans2);
}




/*

18 = 2 * 3^2

1 2 3 6 9

2 * 3 * 5

2^2 * 3 * 5

*/


Measured memory_bytes: 3244
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define FastIO ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL)

int main(){
    FastIO;
    int x;
    cin >> x;
    if(x >= 400 && x <= 599){
        cout << 8 << "\n";
    }
    else if(x >= 600 && x <= 799){
        cout << 7 << "\n";
    }
    else if(x >= 800 && x <= 999){
        cout << 6 << "\n";
    }
    else if(x >= 1000 && x <= 1199){
        cout << 5 << "\n";
    }
    else if(x >= 1200 && x <= 1399){
        cout << 4 << "\n";
    }
    else if(x >= 1400 && x <= 1599){
        cout << 3 << "\n";
    }
    else if(x >= 1600 && x <= 1799){
        cout << 2 << "\n";
    }
    else if(x >= 1800 && x <= 1999){
        cout << 1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  cout << (n + 1) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 1;
            while (true)//???????????????
            {
                string a = Console.ReadLine();
                int x = int.Parse(a);

                if (x == 0)
                    break;

                Console.WriteLine(string.Format("Case {0}: {1}", i, x));

                i++;
            }
        }
    }
}

Measured memory_bytes: 9324
#include<math.h>
#include<algorithm>
#include <iostream>
using namespace std;
typedef long long int LL;
const int N=1e5+5;
int a[N];
int b[N];
int c[N];
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
	cin>>a[i];
for(int i=0;i<n;i++)
	cin>>b[i];
for(int i=0;i<n;i++)
	cin>>c[i];
sort(a,a+n);
sort(b,b+n);
sort(c,c+n);
LL j=0;//用于统计第一部分里面小于第二部分的个数
LL k=0;//用于统计第三部分里面小于第二部分的个数
LL sum=0;
for(int i=0;i<n;i++){
	while(a[j]<b[i]&&j<n){
	j++;
	}
	while(c[k]<=b[i]&&k<n){
	k++;
	}
	sum+=(j*(n-k));
}
 
cout<<sum<<endl;
 
	return 0;
}

Measured memory_bytes: 4764
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
n = ni()
alp = "abcdefghijklmnopqrstuvwxyz"
ans = ""

while True:
    n-=1
    r =  n%26
    ans=  alp[r] +ans
    n //= 26

    if n==0:break
print(ans)


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

int n;
long long tw;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> tw;
	long long w[n], v[n], dp[tw + 1];
	memset(dp, 0, sizeof(dp));
	for (int i=0; i<n; i++) {
		cin >> w[i] >> v[i];
		for (int j=tw; j>=w[i]; j--) {
			dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
		}
	}
	cout << dp[tw] << endl;
}

Measured memory_bytes: 1024
n,k=map(int,input().split())
d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int,input().split())))
for i in range(1,len(a)):
    a[0].extend(a[i])
ans=set(a[0])
count=0
for an in ans:
    for i in range(1,n+1):
        if an == i:
            count+=1
print(n-count)

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

int main()
{
    char str[1000];
    int n;
    cin>>str;
    cin>>n;
    for(int i=0; i<n; i++){
        if(str[i]=='1'){
            continue;
        } else{
            cout<<str[i]<<endl;
      return 0;        }
    }
    cout<<"1"<<endl;

}



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

int main(void) {
	string S;
	cin >> S;

	int ans = 700;
	for (int i = 0; i < 3; ++i) {
		if (S[i] == 'o')
			ans += 100;
	}

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


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

int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {    
    string S;
    cin >> S;
    
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if (i != N-1) {
      continue;
    }
    else
      cout << "Three" << endl;    
  }
}

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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c)

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}


int main()
{
  ios::sync_with_stdio(0);
  int n;
  cin >> n;

  ll ans = 0;

  for(int i = 1; i <= n; i++)
  {
    for(int j = 1; j <= n; j++)
    {
      for(int k = 1; k <= n; k++)
      {
        ans += __gcd(__gcd(i,j),k);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int T = sc.nextInt();
        int S = sc.nextInt();
        if((double)S >= (double)D/(double)T) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35664
n = gets.to_i
taro_p = 0
hanako_p = 0 
n.times do
  cards = gets.chomp.split(" ")
  case cards[0].bytes <=> cards[1].bytes
  when 1
    taro_p += 3
  when 0 
    taro_p += 1
    hanako_p += 1
  when -1
    hanako_p += 3
  end
end
puts "#{taro_p} #{hanako_p}"

Measured memory_bytes: 8784
s, t = input(), input()
alp_dict = {}
alp_dict2 = {}
for i, j in zip(s, t):
    if not j in alp_dict:
        alp_dict[j] = i
    elif alp_dict[j] == i:
        pass
    else:
        print("No")
        exit()  
    if not i in alp_dict2:
        alp_dict2[i] = j
    elif alp_dict2[i] == j:
        pass
    else:
        print("No")
        exit()  

print("Yes")

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

int main() {
  int n,Alice = 0, Bob = 0;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      Alice += vec.at(i);
    } else {
      Bob += vec.at(i);
    }
  }
  cout << Alice - Bob << endl;
}


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][]v = new int[2][n];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < n; j++) {
                v[i][j] = sc.nextInt();
            }
        }
        int sum1 = 0;
        int sum2 = 0;
        for (int j = 0; j < n; j++) {
            int tmp1 = v[0][j];
            int tmp2 = v[1][j];
            if(tmp1 - tmp2 > 0) {
                sum1 += tmp1;
                sum2 += tmp2;
            }
        }
        System.out.println(sum1 - sum2);
    }
}

Measured memory_bytes: 35716
def main():
  ## IMPORT MODULE
  #import sys

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    n = 2
    A = [1000000000, 1000000000]

  else:
    ##INPUT 
    n = input()
    A = list(map(int, input().split()))

  ## SUBMITION CODES HERE
  if 0 in A:
    print(0)
    exit()
  
  ans = 1
  for a in A:
    ans *= a
    if ans > 10**18:
      ans = -1
      break
  
  print(ans)
    
main()

Measured memory_bytes: 21636
n = int(input())
s=(n-1)
if n==2:
    print(1)
else:
    ab = n//2 if n%2==0 else n//2 + 1
    for x in range(2,ab):
        if n%x==0:
            s+=(n//x - 1)
        else:
            s+=(n//x)
    print(s + n//2)


Measured memory_bytes: 9100
//Rochy'.'
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define fl(i,a,b) for(int i=a;i<b;++i)
#define fa(i,a) for(auto i:a)
#define ii pair <int,int>
#define vi vector <int>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
using namespace std;
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));
if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar()))x=x*10+c-48;if(nega)x=-x;}
template <typename T> inline void writep(T x){if(x>9)writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
template <typename R, typename D> inline void Min(R &a, D b){if(a>b) a=b;}
template <typename D, typename R> inline void Max(D &a, R b){if(a<b) a=b;}
const int N = 200005;
string t,s;
int k,cnt,cnt2;
int main(){
    ios_base::sync_with_stdio(NULL);
    cin. tie(NULL); cout. tie(NULL);
//    freopen(".inp" , "r", stdin);
//    freopen(".out", "w", stdout);
	cin>>t;s=t;cin>>k;
	bool ok=1;
	fl(i,1,s.size()){
		if(s[i]!=s[i-1]){
			ok=0;
			break;
		}
	}
	if(ok)return!(cout<<(1ll*s.size()*k)/2);
	fl(i,1,s.size()){
		if(s[i]==s[i-1]){
			++cnt;
			s[i]='?';
		}
	}
	if(s.back()=='?'||s.back()!=t[0])return!(cout<<1ll*cnt*k);
	int a=0,b=0;
	fl(i,0,t.size()){
		if(t[i]!=t[0])break;
		++a;
	}
	fd(i,t.size()-1,0){
		if(t[i]!=t[0])break;
		++b;
	}
	cout<<1ll*cnt*k-1ll*((a/2)+(b/2)-(a+b)/2)*(k-1);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
dp = [[0] * n for _ in range(n)]
for i in range(n):
    dp[i][i] = a[i]

for i in range(n - 2, -1, -1):
    for j in range(i + 1, n):
        dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])

print(dp[0][n - 1])


Measured memory_bytes: 111836
#include<bits/stdc++.h>
#define N 5000005

using namespace std;

int n,b[N];char s[N];

inline int gt(char ch){if(ch=='R')return 1;return 0;}

int main(){
    scanf("%d%s",&n,s+1);
    for (int i=1;i<=n;i++) b[gt(s[i])]++;
    if (b[1]>b[0]) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int n;
int m;
pair<int,int> a[100005];
long long ans[100005];
int f[100005];
long long aa;
long long num[100005];
int find(int x) {
	if(f[x]==x) return x;
	return f[x] = find(f[x]);
}
void merge(int x, int y) {
	aa -= num[find(x)] * num[find(y)];
	num[find(x)] += num[find(y)];
	f[find(y)] = find(x);
}
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1; i<=m; i++) scanf("%d%d",&a[i].first,&a[i].second);
	for(int i=1; i<=n; i++) {
		f[i] = i;
		num[i] = 1LL;
	}
	aa = n*(n-1LL)/2; 
	for(int i=m; i>=1; i--) {
		if(find(a[i].first) == find(a[i].second)) {
			ans[i] = aa;
			continue;
		}
		ans[i] = aa;
		merge(a[i].first,a[i].second);
	}
	for(int i=1; i<=m; i++) {
		printf("%lld\n",ans[i]);
	} 
	
}

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

int main(){
    string s;
    cin >> s;
    ll l;
    l=s.size();
    ll t;

    vector <ll> al(26,0);
    rep(i,l){
        t=s[i];
        ++al[t-97];
    }
    ll ans=0;
    rep(i,26){
        //cout << ans << endl;
        ans+=al[i]*(al[i]-1)/2;
    }

    cout << l*(l-1)/2-ans+1 << endl;
    

    return 0;
}

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

int n,m,sm = 10000000;
int w[100],v[100];
int DP[10001];

int rec(int j){
	if(DP[j]>=0)	return DP[j];
	if(j<sm)	return DP[j] = 0;

	int res = 0;
	for(int i=0;i<n;i++){
		if(w[i]<=j){
			int tmp = rec(j-w[i])+v[i];
			if(tmp > res){
				res = tmp;
			}
		}
	}
	return DP[j] = res;
}

int main(){
	cin >> n >> m;
	for(int i=0;i<n;i++){
		cin >> v[i] >> w[i];
		if(w[i]<sm){
			sm = w[i];
		}
	}
	
	for(int i=0;i<=m;i++){
		DP[i]=-1;
	}

	cout << rec(m) << endl;

	return 0;
}


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

int main(){
  long long x; cin >> x;
  long long ca, cb;
  for (long long a = 0; a < 1000; a++){
    for (long long b = -1000; b < 1000; b++){
      if ((a*a*a*a*a - b*b*b*b*b) == x){
        ca = a;
        cb = b;
        break;
      }
    }
  }
  cout << ca << " " << cb << endl;
  return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int func(long long n, long long m, std::vector<long long> x) {
    // ソートしておく。
    sort(all(x));
    vi d;
    // 地点のそれぞれの差分を取る。
    rep(i, m - 1) { d.push_back(x[i + 1] - x[i]); }
    // 差分をソート
    sort(all(d));
    ll ans = 0;
    // m-nがスキップできる回数
    // 0なら0が答え（m≦n）
    int cnt = max((ll)0, m - n);
    // ソートしてあるのでコマ間が短い順に並んでいる。
    // 後は合計するだけ
    rep(i, cnt) ans += d[i];
    cout << ans << endl;

    return 0;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> X(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &X[i]);
    }

    func(N, M, std::move(X));

    return 0;
}


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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int N, K;
  cin >> N >> K;
  if(N % K == 0) cout << 0 <<endl;
  else cout << 1 <<endl;
}

Measured memory_bytes: 3644
import java.util.*;
class Main{
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		
		String q=s.nextLine();
	//	System.out.println(q);
		String[]key=q.split("\\.");
	//	System.out.println(key.length);
	//	for(int i=0;i<key.length;i++)System.out.println(key[i]);
		int now=1;
		int n=key.length;
		int d[]=new int[120];
		for(int i=0;i<120;i++)d[i]=-1;
		d[1]=0;
		boolean ok=false;
		while(s.hasNext()){
			String str=s.nextLine();
			int cnt=0;
			for(int i=0;i<str.length();i++){
				if(str.charAt(i)!=' ')break;
				cnt++;
			}
			if(d[now]==-1)d[now]=cnt;
			while(cnt<d[now]){
				d[now]=-1;
				now--;
			}
			String tmp=str.split(":")[0].substring(cnt);
		//	System.out.println(tmp);
			if(tmp.equals(key[now])){
				now++;
				if(n==now){
					if(str.split(":").length>1)System.out.println("string \""+str.split(":")[1].substring(1)+"\"");
					else System.out.println("object");
					ok=true;
					break;
				}
			}
		}
		if(!ok)System.out.println("no such property");
	}
}

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

int main() {
  string s;
  int a, c;
  a=0;
  c=0;
  cin >> s;
 for (int i = 0 ; i < s.size();i++){
 if (s.at(i) == 'A'){
c= c+1;
}
else if (s.at(i) == 'C'){
c= c+1;
}
else if (s.at(i) == 'G'){
c= c+1;
}
else if (s.at(i) == 'T'){
c= c+1;
}
else{
a = max(a,c);
c = 0;
}

}
 a = max(a,c);
  cout << a << endl;
}

Measured memory_bytes: 256
import java.util.*
import java.math.*

fun main(args: Array<String>) {

    var (N, M) = readLine()!!.split(" ").map { it.toInt() }
//    var N = readLine()!!.toInt()
//    val D = readLine()!!.split(" ").map { it.toLong() }
//    val A = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    val mod = 1000000007L
    val K = mutableListOf<IntArray>()
    for (n in 1..M) {
        val k = readLine()!!.split(" ").drop(1).map { it.toInt() }.toIntArray()
        K.add(k)
    }
    val p = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    var ans = 0
    val list = BooleanArray(N) { false }

    fun o(n: Int): Int {
        if (n < N){
            var res = 0
            list[n] = false
            res += o(n + 1)
            list[n] = true
            res += o(n + 1)
            return res
        }
//        println(list.toList())

        for ((i, k) in K.withIndex()) {
            var on = 0
            for (n in k) {
                if (list[n - 1]) on++
            }
            if (on % 2 != p[i]) {
                return 0
            }
        }

        return 1
    }

    println(o(0))

//    println("%.9f".format(ans))
}


Measured memory_bytes: 37876
import sys
import numpy as np

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
B = []
for _ in range(N):
    B.append(int(input()))

As = np.array([A1, A2, A3])

bingo = np.array([[False] * 3, [False] * 3, [False] * 3])
for b in B:
    for i, A in enumerate(As):
        for j, a in enumerate(A):
            if b == a:
                bingo[i][j] = True

for i in range(3):
    if bingo[i][0] and bingo[i][1] and bingo[i][2]:
        print('Yes')
        sys.exit(0)

    if bingo[0][i] and bingo[1][i] and bingo[2][i]:
        print('Yes')
        sys.exit(0)

if bingo[0][0] and bingo[1][1] and bingo[2][2]:
    print('Yes')
    sys.exit(0)

if bingo[0][2] and bingo[1][1] and bingo[2][0]:
    print('Yes')
    sys.exit(0)

print('No')


Measured memory_bytes: 27120
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int a[110];
int main()
{
    int n,i,s=0,q=0,x=100000,w,z;
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        s=s+a[i];
    }
    int p=s/2;
    for(i=0; i<n; i++)
    {
        q=q+a[i];
        w=abs(p-q);
        if(x>w){x=w;z=q;}
    }printf("%d\n",abs(z-(s-z)));
}


Measured memory_bytes: 256
#include <iostream>
#define NMAX 100
#define AMAX 100
using namespace std;

int selectionSort(int *A, int n) {
    int exc = 0;
    for (int i=0; i<n; i++) {
        int minj = i;
        for (int j=i; j<n; j++) {
            if ( A[j] < A[minj] ) {
                minj = j;
            }
        }
        if ( A[i] != A[minj] ) {
            swap( A[i], A[minj] );
            exc += 1;
        }
    }
    return exc;
}

int main() {
    // input
    int n;
    cin >> n;

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

    // solve
    int exc = selectionSort(A, n);

    // output
    for (int i=0; i<n; i++) {
        cout << A[i];
        if (i == n-1) {
            cout << endl;
        } else cout << " ";
    }
    cout << exc << endl;
}


Measured memory_bytes: 3088