akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
typedef unsigned long long ll;
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
   if(a>b)
    swap(a,b);
     if(a>c)
    swap(a,c);
   if(b>c)
    swap(b,c);
 ll maxi=c;
    if(maxi%2==0)
    {
        cout<<0<<endl;
    }
    else
    {
        ll res=a*b;
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
numList = input().split()
minNum = numList[0]
maxNum = numList[n-1]

for i in range(len(numList)):
    if int(minNum) > int(numList[i]):
        minNum = numList[i]
    elif int(maxNum) < int(numList[i]):
        maxNum = numList[i]

print(int(maxNum) - int(minNum))

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

//約数の個数
long long calc(long long N) {
	vector<long long> x;
	for (long long i = 2; i*i <= N; i++) {
		int m = 0;
		while (N%i == 0) { // 素数で割り切れなくなるまで割っていく
			m++;//割った個数を配列に足す
			N /= i;
		}
		if (0 != m) {
			x.push_back(m);
		}
		if (1 == N) {
			break;
		}
	}
	if (1 != N) {
		x.push_back(1);
	}

	long long nAns = 1;
	for (long long n = 0; n < x.size(); ++n) {
		nAns *= x[n] + 1;
	}
	return nAns;
}

int main() {
	long long N;
	cin >> N;
	long long ans = 0;
	for (long long i = 1; i < N; ++i) {
		long long memo = calc(i);
		ans += memo;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
long double ans,sum,n,d,x,d1,x1,sum1;
int main()
{
//	freopen("Pushing Balls.in","r",stdin);
	cin>>n>>d>>x; sum=2*d*n+n*x*(2*n-1);
	for(int i=n;i;i--)
	{
		ans+=sum/2/n;
		d1=(2*d+2*n*d+5*x)/2/n, sum1=sum-(2*d+(2*n-1)*x)/n;
		n-=1;
		x1=(sum1-2*d1*n)/n/(2*n-1);
		d=d1, x=x1, sum=sum1;
	}
	printf("%.15lf\n",(double)ans);
	return 0;
}

Measured memory_bytes: 256
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

func main() {
	n, k := scanInt(), scanInt()
	p := scanInts(n)
	sort.Ints(p)
	minPrice := 0
	for i := 0; i < k; i++ {
		minPrice += p[i]
	}
	fmt.Println(minPrice)
}

func debug(a ...interface{}) {
	fmt.Println(a...)
}


Measured memory_bytes: 1776
a = [[int(i) for i in input().split()] for j in range(3)]
n = int(input())
for i in range(n):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if b==a[j][k]:
        a[j][k] = 0
ans = 'No'
for i in range(3):
  if a[i][0]==0 and a[i][1]==0 and a[i][2]==0:
    ans = 'Yes'
for i in range(3):
  if a[0][i]==0 and a[1][i]==0 and a[2][i]==0:
    ans = 'Yes'
if a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
  ans = 'Yes'
if a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
  ans = 'Yes'
print(ans)


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

int main(){
  int n, x;
  while (1) {
    cin >> n >> x;
    if (n==0 && x==0) break;
    int cnt = 0;
    for (int i=1; i<=n-2; i++){
      for (int j=i+1;j<=n-1; j++){
        for (int k=j+1;k<=n; k++){
          if (i+j+k == x) cnt += 1;
        }
      }
    }
    cout << cnt << endl;
  }
return 0;
}


Measured memory_bytes: 3096
import heapq
import sys

input = sys.stdin.readline

def dijkstra_heap(s,edge,n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

def main():
    N, u, v = map(int, input().split())
    u -= 1
    v -= 1
    edge = [[] for i in range(N)]
    for _ in range(N-1):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        edge[A].append([1,B])
        edge[B].append([1,A])
    
    d1 = dijkstra_heap(u,edge, N)
    d2 = dijkstra_heap(v,edge, N)
    ans = 0
    for i in range(N):
        if d1[i] < d2[i]:
            ans = max(ans, d2[i]-1)

    print(ans)


if __name__ == "__main__":
    main()

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    int H,W;
    cin >> H >> W;
    VVI dp(10,VI(10,0));
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> dp[i][j];
        }
    }

    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }

    LL ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int a;
            cin >> a;
            if (a != -1) {
                ans += dp[a][1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef pair<int,int> P;

int main() {
    int i,j,n,p,q,temp;
    int t=0;
    int flag=0;
    string s;
    cin>>s;
    if(s[0]=='a'){
        if(s[1]=='b'){
            if(s[2]=='c'){flag=1;}
        }
        if(s[1]=='c'){
            if(s[2]=='b'){flag=1;}
        }
    }
    if(s[0]=='b'){
        if(s[1]=='a'){
            if(s[2]=='c'){flag=1;}
        }
        if(s[1]=='c'){
            if(s[2]=='a'){flag=1;}
        }
    }
    if(s[0]=='c'){
        if(s[1]=='b'){
            if(s[2]=='a'){flag=1;}
        }
        if(s[1]=='a'){
            if(s[2]=='b'){flag=1;}
        }
    }
    if(flag==1){cout<<"Yes";}
    else{cout<<"No";}
    return 0;
}

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

#define INF INT_MAX/2
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

   int N;
   cin>>N;
   vector<pair<int,int> > red(N),blue(N);
   for(int i=0;i<N;i++)cin>>red[i].first>>red[i].second;
   for(int i=0;i<N;i++)cin>>blue[i].first>>blue[i].second;

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

   ll ans = 0;
   for(int i=0;i<N;i++){
      int MAX = -INF;
      int point = -1;
      for(int j=0;j<N;j++){
         if(blue[i].first > red[j].first && blue[i].second > red[j].second){
            if(MAX < red[j].second){
               MAX = red[j].second;
               point = j;
            }
         }
      }
      if(point!=-1){
         ans++;
         red[point].first = INF;
      }
   }
   cout<<ans<<endl;
   return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int f[26][26];

int main(){
    string s,t;
    cin>>s>>t;

    int n=s.size();
    rep(i,n){
        int a=s[i]-'a';
        int b=t[i]-'a';
        f[a][b]=1;
    }

    rep(i,26){
        int cn=0;
        rep(j,26){
            if(f[i][j]) cn++;
        }
        if(2<=cn){
            cout<<"No"<<endl;
            return 0;
        }
    }

    rep(j,26){
        int cn=0;
        rep(i,26){
            if(f[i][j]) cn++;
        }
        if(2<=cn){
            cout<<"No"<<endl;
            return 0;
        }
    }


    cout<<"Yes"<<endl;
}


Measured memory_bytes: 3844
//
//  Created by Henry Cafaro
//  Copyright © 2020 Henry Cafaro. All rights reserved.
//

# include <iostream>
# include <string>
# include <vector>
# include <algorithm>
# include <bitset>
# include <queue>
# include <cstring>
# include <map>


#define ll long long

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    
    string s;
    
    map<string, int> mp;
    
    for(int i = 0; i < n; i++){
        cin >> s;
        mp[s]  = mp[s] + 1;
    }
    
    cout <<"AC x " << mp["AC"] << endl;
        cout <<"WA x " << mp["WA"] << endl;
    cout <<"TLE x " << mp["TLE"] << endl;
    cout <<"RE x " << mp["RE"] << endl;

        
   
    
    
    
    
    
    
    
    
    
    
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{ 
  string s;
  cin>>s;
  int n;
  n=s.size();
  if(s[n-1]=='s'){s=s+"es";}
  else{s=s+'s';}
  cout<<s<<endl;
  
  return 0;
}

Measured memory_bytes: 3600
//        VIVEK UPADHYAY
//        MANIT, BHOPAL(M.P)
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<endl
#define ok cout<<"ok\n" ;
typedef long long ll;
const int MAXN = 1e5 + 10 ;
const int MAX = 1e7 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;

int main(){
    vector<ll> a(3) ;
    for(int i=0;i<3;i++)
        cin >>a[i] ;
    sort(a.begin(),a.end());
    ll sum =0 ;
    for(int i=1;i<3;i++)
        sum+=a[i]-a[i-1] ;
    cout<<sum<<endl;
}


Measured memory_bytes: 256
h={}
r=t=0
gets;$<.each{|_|
	n=_.to_i
	h[n^(n-1)]=1
	t^=n
}
29.downto(0){|i|
	t[i]==0&&next
	!h[k=(1<<-~i)-1]&&(p -1;exit)
	t^=k
	r+=1
}
p r

Measured memory_bytes: 1788
(defun f (a b n)
  (cond
    ((zerop n) 0)
    ((> a b) (+ a (f (1- a) b (1- n))))
    (t (+ b (f a (1- b) (1- n))))))

(let ((a (read))
      (b (read)))

  (format t "~A~%" (f a b 2)))

Measured memory_bytes: 5472
#include <iostream>
#include <vector>

using namespace std;

#define N_MAX 1000000
bool primes[N_MAX];

void sieve() {
  for (int i = 0; i < N_MAX; ++i)
    primes[i] = true;

  primes[0] = false; primes[1] = false;
  for (int i = 2; i < N_MAX; ++i) {
    if (!primes[i])
      continue;
    for (int j = i * 2; j < N_MAX; j += i) {
      primes[j] = false;
    }
  }
}

int main(int argc, char const* argv[])
{
  sieve();

  while (true) {
    int a, d, n;
    cin >> a >> d >> n;
    if (!(a || d || n)) break;

    int n_primes = 0;
    for (int i = a; ; i += d) {
      if (primes[i]) {
        ++n_primes;
        if (n == n_primes) {
          cout << i << endl;
          break;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2136
#include<bits/stdc++.h>
#include<vector>
#define inf 1000000
#define ll unsigned long long 
#define boostUP ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fsr(i,n) for(ll i=0;i<n;i++)
#define fcr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define sz(arr) sizeof(arr)/sizeof(arr[0])

using namespace std;

int main(){
    int n, count = 0;
    cin >> n;
    vector<int>v (n,0);
    fsr(i, n) cin >> v[i];

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

    for(int i = 0; i < n; i++)
        for(int j = i+1; j<n; j++)
            for(int k = j+1; k<n; k++)
                count += v[i]+v[j] > v[k];
                    
    cout << count << endl;
}




Measured memory_bytes: 3624
import fractions as f

A,B,C,D = map(int,input().split())
L = C * D // f.gcd(C,D)

c = B // C - A // C
d = B // D - A // D
l = B // L - A // L

if A % C == 0:  c += 1
if A % D == 0:  d += 1
if A % L == 0:  l += 1

print( int( (2*(B-A+1) - (c+d) - (c+d-2*l)) // 2 ) )



Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;

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

int main(){
	int X, Y, A, B, C;
	scanf("%d%d%d%d%d", &X, &Y, &A, &B, &C);
	for (int i = 1; i <= A; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= B; i++) scanf("%d", &b[i]);
	for (int i = 1; i <= C; i++) scanf("%d", &c[i]);
	sort(a + 1, a + A + 1);
	sort(b + 1, b + B + 1);
	sort(c + 1, c + C + 1);
	long long ans = 0;
	for (int i = A - X + 1; i <= A; i++){
		ans += a[i];
	}
	for (int i = B - Y + 1; i <= B; i++){
		ans += b[i];
	}

	int i = A - X + 1, j = B - Y + 1, k = C;
	while ((i <= A || j <= B) && k > 0){
		if (i > A || (j <= B && a[i] > b[j])){
			if (c[k] > b[j]) ans += c[k--] - b[j++];
			else break;
		} else if (j > B || (i <= A && a[i] <= b[j])){
			if (c[k] > a[i]) ans += c[k--] - a[i++];
			else break;
		} else break;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a,c;
string b;
 
int main(){
	cin>>a>>b;
	int d=(b[0]-'0')*100+(b[2]-'0')*10+b[3]-'0';
	c=a*d/100;
	cout<<c;
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    i64 ng = -1;
    i64 ok = a[0];

    auto is_ok = [&](i64 x)
    {
        i64 y = x;        
        rep(i,n) y = a[i]-y;
        return x >= y;
    };

    while(abs(ok-ng)>1)
    {
        i64 mid = (ok+ng)/2;
        if(is_ok(mid)) ok = mid;
        else ng = mid;
    }

    int x = ok;
    rep(i,n)
    {
        cout << 2*x << " ";
        x = a[i]-x;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;


int main() {

    int A, B, C;
    cin >> A >> B >> C;

    int m = max(max(A, B), C);

    int x = m;

    if ((3 * m - (A + B + C)) % 2 != 0) {
        x = m + 1;
    }


    int result = ((3 * x) - (A + B + C)) / 2;

    cout << result << "\n";

    return 0;

}

Measured memory_bytes: 256
#include<cstdio>
long long mod=1000000007;
long long inv(long long n, long long p) {
	long long x = p, y = n, b = 0, b2 = 1;
	long long q, r, b3;
	while (y > 0) {
		q = x / y;
		r = x - q*y;
		if (b < q*b2) {
			b += ((q*b2 - b) / p + 1)*p;
		}
		b3 = (b - q*b2) % p;
		x = y;
		y = r;
		b = b2;
		b2 = b3;
	}
	return b;
}
long long factorial[200001],factinv[200001];
long long combi(long long n, long long r,long long p) {
	return ((factorial[n] * factinv[r]) % p)*factinv[n - r] % p;
}
int main() {
	int h, w, a, b, i;
	scanf("%d%d%d%d", &h, &w, &a, &b);
	factorial[0] = 1;
	factinv[0] = 1;
	for (i = 1; i < h + w; i++) {
		factorial[i] = (factorial[i - 1] * i) % mod;
	}
	factinv[h + w - 1] = inv(factorial[h + w - 1], mod);
	for (i = h + w - 1; i > 1; i--) {
		factinv[i - 1] = (factinv[i] * i) % mod;
	}
	long long ans = 0;
	for (i = b + 1; i <= w; i++) {
		ans = (ans + combi(h - a + i - 2, i-1, mod)*combi(a + w - i - 1, a-1, mod)) % mod;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 3328
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func intMax(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	H := make([]int, N)
	for i := 0; i < N; i++ {
		H[i] = scanInt()
	}

	ans := 0
	tmp := 0
	for i := 0; i < N-1; i++ {
		if H[i] >= H[i+1] {
			tmp++
		} else {
			ans = intMax(ans, tmp)
			tmp = 0
		}
	}
	ans = intMax(ans, tmp)

	fmt.Println(ans)
}


Measured memory_bytes: 3072
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [set() for i in range(N)]
for i in range(M):
    A,B = map(int,input().split())
    AB[A-1].add(B-1)
    AB[B-1].add(A-1)
ans = 0
for i in range(N):
    res = True
    for x in AB[i]:
        if H[i]<=H[x]:
            res = False
            break
    if res:
        ans += 1
print(ans)

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

using namespace std;

int main() {
    long long a,b,c;
    cin>>a>>b>>c;
    
    if(a>b)
    {
        long long temp=a;
        a=b;
        b=a;
    }
    long long tot=0;
    for(long long i=a;i<=b;++i)
    {
        if(i%c==0)
        {
            tot++;
        }
    }
    
    cout<<tot<<endl;
}

Measured memory_bytes: 3616
from operator import itemgetter
n1, n2 = [int(i) for i in input().split()]

n3 = []

for i1 in range(n2):
    n3.append([int(i) for i in input().split()])
    n3[i1].append(i1)
    n3[i1].append(0)

n3.sort(key=itemgetter(1))

n4 = [0] * n1

for i2 in range(n2):
    n4[n3[i2][0] - 1] += 1
    n3[i2][3] = n4[n3[i2][0] - 1]

n3.sort(key=itemgetter(2))

for i3 in range(n2):
    print(str(n3[i3][0]).zfill(6) + str(n3[i3][3]).zfill(6))

Measured memory_bytes: 29800
//Unionfind

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

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

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


int main() {
  int n,m; cin >> n >> m;
  UnionFind tree(n+1);
  for(int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        tree.merge(x, y); // xの木とyの木を併合する
  }
  ll ans = 0;
  rep(i,n+1)  chmax( ans, tree.size(i) );

  cout << ans << endl;
}

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

typedef long long ll;

int main() {
	ll N, M;
	cin >> N >> M;

	ll ans;
	for (int i = M/N; i > 0; i--) {
		if (M%i == 0 && i*N <= M) {
			ans = i;
			break;
		}
	}

	cout << ans << endl;

}

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

works = []
for i in range(N):
    A, B = map(int, input().split())
    works.append([A, B])

works = sorted(works, key=lambda x: x[1], reverse=False)

flag = TabError
spend_time = 0
for i in range(len(works)):
    spend_time += works[i][0]
    if spend_time > works[i][1]:
        flag = False
        break

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 39596
#include<bits/stdc++.h>
using namespace std;
const int mx = 200005;
int n, q, l, r, a[2];
char s[mx], t1, t2;
pair<char, bool> p[mx];

bool C(int now, bool left){
    for(int i = 0; i < q; i++){
        if(p[i].first == s[now]){
            if(now == 0 && p[i].second) return !left;
            if(now == n-1 && !(p[i].second)) return left;
            now += p[i].second ? -1 : 1;
        }
    }
    return true;
}
int main(){
    scanf("%d%d%s\n", &n, &q, s);
    for(int i = 0; i < q; i++){
        scanf("%c %c\n", &t1, &t2);
        p[i] = make_pair(t1, t2 == 'L');
    }
    for(int i = 0; i < 2; i++){
        l = -1; r = n;
        while(l+1 < r){
            int mid = (l+r) / 2;
            (C(mid, i == 0)^(i == 0) ? l : r) = mid;
        }
        a[i] = r;
    }
    printf("%d\n", a[1] - a[0]);
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N, K; cin >> N >> K;
  cout << N - K + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define scan(n)      scanf("%I64d",&n);
#define scan2(a,b)   scanf("%I64d%I64d",&a,&b);
#define scan3(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c);
#define sc(n)        scanf("%c",&n);
#define sf(n)        scanf("%lf",&n);
#define ss(n)        scanf("%s",n);
#define forall(i,a,b)for(long long int i=a;i<b;i++)
#define all(a)       a.begin(), a.end()
#define pb           push_back
#define mp           make_pair
#define FAST_IO      ios_base::sync_with_stdio(false); cin.tie(NULL);
#define minimum(a)   *min_element(a.begin(),a.end())
#define maximum(a)   *max_element(a.begin(), a.end())
#define display(a)   for(auto i : a) cout<<i<<" ";
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
using namespace std;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
vector<ll> scanVector(ll n, vector<ll> &v)
{
  ll temp;
  for(ll i = 0; i < n ; i++)
  {
     cin>>temp;
     v.pb(temp);
  }
  return v;
}

// bool fun(vector<ll> &v, ll su)
// {
//     if(su == 0) return true;
//     bool flag = true;
//     for(auto i : v)
//     {
//         if(su >= i)
//         {
//             flag = flag && !fun(v,su-i);
//         }
//     }
//     return flag;
// }
int main() {
    FAST_IO
    ll t;
    //cin>>t;
    t = 1;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        vector<ll> v;
        v=scanVector(n,v);
        bool dp[k+1];
        dp[0] = true;
        for(int i = 1; i <= k ; i++)
        {
            dp[i] = false;
            int f = 0;
            for(int j = 0; j < n ; j++)
            {
                if(i == v[j])
                {
                    f = 1;
                    dp[i] = true;
                    break;
                }
                if(i-v[j] >= 0)
                {
                    if(dp[i-v[j]] == false)
                    {
                        f = 1;
                        dp[i] = true;
                        break;
                    }
                }
            }
            if(f == 0) dp[i]= false;
        }
        // for(ll i = 0; i <= k ; i++) cout<<i<<" "<<dp[i]<<endl;
        // cout<<endl;
        if(dp[k] == true) cout<<"First\n";
        else cout<<"Second\n";
    }
    return 0;
}

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

int main(){
    string n;
    cin >> n;
    if (n[0] == '7' || n[1] == '7' || n[2] == '7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define debug(V) rep(i, V.size()) cout << V[i] << " ";
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v;
string S, T;
vl A, B;
void input() { cin >> S; }
void solve() {
    x = S[0] - 'A';
    if(x > -1 && x < 26)
        cout << "A" << endl;
    else
        cout << "a" << endl;
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long D){
    cout << "Christmas";
    while(D != 25) {
        cout << " Eve";
        D++;
    }
    cout << endl;
}

int main(){
    long long D;
    scanf("%lld",&D);
    solve(D);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define reps(i,s,n) for (int i = s; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define per1(i,n) for (int i = n; i >= 1; --i)
#define all(c) begin(c),end(c)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
// if(nextY >= 0 && nextY < H && nextX >= 0 && nextX < W)
static const long double pi = acos(-1.0);
typedef complex<ld> cd;

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

    int N; cin >> N;
    vector<string> G(N);
    rep(i, N) cin >> G[i];

    int ans = 0;
    rep(sh, N) {
        bool ok = 1;
        rep(i, N) {
            if(!ok) break;
            rep(j, N) {
                if(G[(i + sh) % N][j] != G[(j + sh) % N][i]) {
                    ok = 0;
                    break;
                }
            }
        }
        if(ok) ++ans;
    }

    ans *= N;
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

int dx[] = {0,-1,0,1};
int dy[] = {-1,0,1,0};

void solve() {
    int h,w;
    cin >> h >> w;
    int ch,cw,dh,dw;
    cin >> ch >> cw >> dh >> dw;
    --ch;--cw;--dh;--dw;
    VS s(h);
    REP(i,0,h) cin >> s[i];
    VVI d(h,VI(w,1<<30));
    d[ch][cw] = 0;
    priority_queue<pair<int,PII>,vector<pair<int,PII>>,greater<pair<int,PII>>> q;
    q.emplace(0,MP(ch,cw));
    while (!q.empty()) {
        auto p = q.top();
        q.pop();
        int v = p.first;
        int r = p.second.first, c = p.second.second;
        if (d[r][c] < v) continue;
        // d[r][c] = v;
        REP(i,0,4) {
            int nr = r + dx[i], nc = c + dy[i];
            if (nr < 0 || nr >= h || nc < 0 || nc >= w) continue;
            if (s[nr][nc] == '#') continue;
            if (d[nr][nc] <= v) continue;
            d[nr][nc] = v;
            q.emplace(d[nr][nc], MP(nr,nc));
        }
        REP(i,-2,3) REP(j,-2,3) {
            int nr = r + i, nc = c + j;
            if (nr < 0 || nr >= h || nc < 0 || nc >= w) continue;
            if (s[nr][nc] == '#') continue;
            if (d[nr][nc] <= v + 1) continue;
            d[nr][nc] = v + 1;
            q.emplace(d[nr][nc], MP(nr,nc));
        }
    }
    if (d[dh][dw] == 1<<30) cout << -1 << endl;
    else cout << d[dh][dw] << endl;
}

signed main() {
    solve();
    
    return 0;
}

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

using namespace std;
priority_queue<pair<int,int> , vector<pair<int,int> >,greater<pair<int,int> > >pq;
int main(){
	int a;
	cin>>a;
	int x,y;
	for(int i=0;i<a;i++){
		cin>>x>>y;
		pq.push(make_pair(y,x));
	}
	
	int i=0;
	int toplam =0;
	while(pq.size()>0){
		int kl=pq.top().second;
		int kls=pq.top().first;
		pq.pop();
		if(i+kl>kls){
			continue;
		}
		else{
			toplam++;
			i=i+kl;
		}
	}
	(toplam==a)?cout<<"Yes":cout<<"No";
}

Measured memory_bytes: 2420
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

int n,m;
int vis[10];

inline void file() {
	freopen("ARC058C.in","r",stdin);
	freopen("ARC058C.out","w",stdout);
}

inline int read() {
	int x=0,p=1;
	char c=getchar();
	while (!isdigit(c)) { if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) { x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	return x*p;
}

inline bool check(int n) {
	while (n) {
		int x=n%10; n/=10;
		if (vis[x]) return 0;
	}
	return 1;
}

int main() {
//	file();
	n=read(); m=read();
	For (i,1,m) {
		int x=read(); vis[x]=1;
	}
	while (1) {
		if (check(n)) break;
		++n;
	}
	printf("%d\n",n);
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

const int dx[]={0,-1,1,0},dy[]={-1,0,0,1};

int main(){

  ll n,k;cin>>n>>k;
  ll h[n];rep(i,0,n)cin>>h[i];

  sort(h,h+n);
  ll mi=INF;
  rep(i,0,n-k+1){
    mi=min(mi,h[i+k-1]-h[i]);
  }

  out(mi);







  return 0;
}


Measured memory_bytes: 1024
import java.io.*;
   
class Main{
    public static void main(String[] args) throws IOException{
 
        int x,y,i,j;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        while(true){
            String[] str = br.readLine().split(" ");
            x = Integer.parseInt(str[0]);
            y = Integer.parseInt(str[1]);
 
            if(x == 0 && y ==0){
                break;
            }
 
            for(i = 0; i < x; i++){
                for(j = 0; j < y; j++){
                    if(i == 0 || i+1 == x){
                        System.out.printf("#");
                    }else if(j ==0 || j+1 == y){
                        System.out.printf("#");
                    }else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}

Measured memory_bytes: 57092
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

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

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

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll S,W;
    cin>>S>>W;
    if(W>=S)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
    
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18;

int main(){
    int n, m;
    cin >> n >> m;

    vector<pair<long long int, long long int>> s(n), cp(m);// student, checkpoint
    for(int i=0; i<n; i++){
        long long int a, b;
        cin >> a >> b;
        s[i] = make_pair(a,b);
    }
    for(int i=0; i<m; i++){
        long long int c, d;
        cin >> c >> d;
        cp[i] = make_pair(c,d);
    }

    // solve
    for(int i=0; i<n; i++){
        pair<int, long long int> ans = {-1,INF};
        for(int j=0; j<m; j++){
            long long int dist = abs(s[i].first - cp[j].first) + abs(s[i].second - cp[j].second);
            if(ans.second > dist){
                ans.first = j+1;
                ans.second = dist;
            }
        }
        cout << ans.first << endl;
    }
    return 0;
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int n,m;
vector<vector<int>> to;
vector<int> vis;
int ans=0;

void dsp(int pos){
    vis[pos]=1;
    for(int npos : to[pos]){
        if(vis[npos]==1)continue;
        vis[npos]=1;
        dsp(npos);
        vis[npos]=0;
    }
    bool judge=true;
    rep(i,n){
        judge=judge && (vis[i]==1);
    }
    if(judge) ans++;
}

int main(){
    cin>>n>>m;
    to.resize(n);
    vis.resize(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dsp(0);
    cout<<ans<<endl;
    return 0;
}

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


int main(){
int n,mn=1000000;
  string s;
  cin>>n>>s;
  vector<int> v(n+2);
  vector<int> u(n+2);
  v[0]=0;u[0]=0;
  for(int i=0;i<n;i++){
  if(s[i]=='W'){v[i+1]=v[i]+1;}
  else v[i+1]=v[i];
  }
  reverse(s.begin(),s.end());
  for(int j=0;j<n;j++){
  if(s[j]=='E'){u[j+1]=u[j]+1;}
  else u[j+1]=u[j];
  }
  reverse(u.begin(),u.end());
  u.push_back(0);
  for(int k=0;k<=n;k++){
  mn=min(v[k]+u[k+1],mn);
  }
  cout<<mn;
  return 0;
}



Measured memory_bytes: 7204
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int64_t gcd_(int64_t a, int64_t b){
    int64_t x = max(a,b);
    int64_t y = min(a,b);
    if(x%y==0){
        return y;
    }
    return gcd_(y, x%y);
}

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b,c,d;
    cin >> a >> b >> c >> d;
    int64_t div_c = b/c - a/c;
    if(a%c == 0){
        div_c += 1;
    }
    int64_t div_d = b/d - a/d;
    if(a%d == 0){
        div_d += 1;
    }
    int64_t gcd = c * d / gcd_(c, d);
    int64_t div_cd = b/(gcd) - a/(gcd);
    if(a%(gcd) == 0){
        div_cd += 1;
    }
    int64_t res = b - a + 1 - (div_c + div_d - div_cd);
    cout << res << endl;
}


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

int main () {
  string s;
  cin >> s;
  int ans = 10000;
  for(int i = 0; i <= s.size() - 3; i++) {
    ans = min(ans, abs(753-stoi(s.substr(i, 3))));
  }
  cout << ans << endl;
  return 0;
}


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

ll i,j,k;
vector<ll> a,p;//a:層数　p:パティ数

ll hamburger(ll level,ll x){//探索しているlevel
    if(level==0){
        if(x<=0){return 0;}
        else{return 1;}
    }
    
    if(x<=1+a[level-1]){//xが(下のバン+level内に含まれるlevel-1のlayer数)以下の時
        return hamburger(level-1,x-1);//一つ下のlevelへ(xもバン1つ分減る)
    }
    else{
        return p[level-1]+1+hamburger(level-1,x-2-a[level-1]);
        //level-1に収まらないとき:level-1を完全に含むので、(そのパティ数+真ん中のパティ)+向かいのlevel-1の探索
    }
}

int main(){
    ll n,x;cin>>n>>x;
    a.resize(n+1);p.resize(n+1);
    a[0]=p[0]=1;
    for(i=0;i<n;i++){
        a[i+1]=a[i]*2+3;//level iの層数
        p[i+1]=p[i]*2+1;//level iのパティ数
    }

    cout<<hamburger(n,x)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()
 
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;
 
signed main() {
  int N;
  vector<int> v;
 
  cin >> N;
  int pre = -1;
  Rep(i, N) {
    int a; cin >> a;
    if ( pre == a ) v.pb(i);
    pre = a;
  }
  v.pb(N);
  //Rep(i, v.size()) cout << v[i] << endl;
 
  int a = 0, b = 0, c = 0, d = 0;;
  int ans = 0;
  Rep(i, v.size()) {
    a = v[i];
    ans = max(ans, (a-b)+(b-c)+(c-d));
    d = c; c = b; b = a;
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 3412
const main = (input) => {

  input = input.trim().split('\n')
  let n = parseInt(input[0], 10) - 2
  const nums = input[1].split(' ').map(Number).sort((a, b) => b - a)

  let r = [1]
  for (n; n >= 2; n-=2) r.push(2)
  r.push(n)

  return console.log(r.reduce((a, b, i) => a + (b * nums[i]), 0))
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 55424
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let (h,w) = {
        let t = read_vec::<i64>();
        (t[0],t[1])
    };
    let mut field:Vec<Vec<char>> = vec![];
    for _ in 0..h {
        field.push(read::<String>().chars().collect());
    }
    for j in 0..h {
        for k in 0..w {
            if 0 <= j - 1 && j + 1  < h &&  0 <= k-1 && k+1 < w{
                let mut v = vec![];
                v.push(field[(j-1) as usize][k as usize]);
                v.push(field[(j+1) as usize][k as usize]);
                v.push(field[j as usize][(k-1) as usize]);
                v.push(field[j as usize][(k+1) as usize]);
                if field[j as usize][k as usize] == '#'{
                    if v.into_iter().filter(|&x| x == '.').count() == 4 {
                        println!("No");
                        return;
                    }
                }
            } 
        }
    }
    println!("Yes");
}

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



int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 1;
    for(int i = 0 ; i < n ; i++){
        if(i != 0){
            if(s[i] == s[i-1]){
                continue;
            }else{++cnt;}
        }
    }
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pp;

int main(void){
    int n;
    cin >> n;
    int ans = 0;
    vector<pp> a;
    vector<pii> b;
    vector<int> c;
    for (int i = 0; i < n; i++) {
        int x,y,z;
        cin>>x>>y>>z;
        a.push_back(make_pair(x, make_pair(y,z)));
    }
    sort(a.begin(), a.end());
    
    for (int i = 0; i < n; i++) {
        int l = i;
        map<int,int> t, u;
        int y = a[i].second.first;
        int z = a[i].second.second;
        t[y] = z;
        while (i+1 < n && a[i].first == a[i+1].first) {
            i++;
            y = a[i].second.first;
            z = a[i].second.second;
            t[y] = z;
        }
        int j = i;
        if (a[j].first+1 == a[j+1].first) {
            j++;
            y = a[j].second.first;
            z = a[j].second.second;
            u[y] = z;
            while (j+1 < n && a[j].first == a[j+1].first) {
                j++;
                y = a[j].second.first;
                z = a[j].second.second;
                u[y] = z;
            }
        }
        for (int j = l; j < i+1; j++) {
            y = a[j].second.first;
            ans = max(ans, t[y]+t[y+1]+u[y]+u[y+1]);
            ans = max(ans, t[y]+t[y-1]+u[y]+u[y-1]);
        }
    }
    cout << ans << " / 1" << endl;
}

Measured memory_bytes: 4512
/*
        FFFFFFFFFFFFFFFFFFFFFF
        F::::::::::::::::::::F
        F::::::::::::::::::::F
        FF::::::FFFFFFFFF::::F
          F:::::F       FFFFFF
          F:::::F
          F::::::FFFFFFFFFF
          F:::::::::::::::F
          F:::::::::::::::F
          F::::::FFFFFFFFFF
          F:::::F
          F:::::F
        FF:::::::FF
        F::::::::FF
        F::::::::FF
        FFFFFFFFFFF
*/
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define int long long
#define mod 1000000007 //998244353
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define nl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<nl
#define cout2(a,b) cout<<a<<" "<<b<<nl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<nl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<nl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<nl
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define ms(v,n) memset((v),n,sizeof(v));
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define inf 9e18
#define cases ll T;cin>>T;while(T--)
#define BLOCK 500
//const double PI = 3.141592653589793238460;
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T> T add(T &a, T b){ return (a+=b)%=mod; }
template<typename T> T sub(T &a, T b){ (a-=b); if(a<0) a+=mod; }
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
// const int N=...;

int32_t main()
{
    
	fast
	
	ll x;
	cin>>x;
	
	
	cout<<(x/500)*1000 + ((x%500)/5)*5;
	

	



    

	return 0;
    
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

ll A, B, C, X, Y;

signed main()
{
    cin >> A >> B >> C >> X >> Y;

    ll ans = 0;
    ll minP = min(X, Y);
    ll maxP = max(X, Y);
    if(A + B > C * 2) {
        ans += minP * C * 2;
        // あとは A か B を買うだけ
        if(X > Y) {
            // A をまともに買うか C 2 枚か
            if(A > C * 2) {
                ans += (X - Y) * C * 2;
            } else {
                ans += (X - Y) * A;
            }
        } else {
            if(B > C * 2) {
                ans += (Y - X) * C * 2;
            } else {
                ans += (Y - X) * B;
            }
        }
    } else {
        ans += A * X + B * Y;
    }
    printf("%lld\n", ans);
    return 0;
}


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

DP = [[[1,0,0,0,],[0,0,0,0]] for i in range(len(N)+1)]
for i in range(len(N)):
    if N[-1-i] == '0':
        for k in range(K):
            DP[i+1][0][k+1] = DP[i][0][k+1]
            DP[i+1][1][k+1] = DP[i][1][k+1]
    else:
        for k in range(K):
            DP[i+1][0][k+1] = DP[i][0][k+1]+DP[i][1][k+1]
    for j in range(1,10):
        for k in range(K):
            if j > int(N[-1-i]):
                DP[i+1][1][k+1] += DP[i][1][k] + DP[i][0][k]
            elif j < int(N[-1-i]):
                DP[i+1][0][k+1] += DP[i][1][k] + DP[i][0][k]
            elif j == int(N[-1-i]):
                DP[i+1][0][k+1] += DP[i][0][k]
                DP[i+1][1][k+1] += DP[i][1][k]
"""
for i in DP:
    for j in i:
        print(j)
    print()
"""
print(DP[-1][0][K]) 


Measured memory_bytes: 3064