akhauriyash/Code-Regression huggingface dataset:
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int = 0, 0, 0

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	_, _ = strconv.Atoi(read())
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i], _ = strconv.Atoi(read())
	}
	var big, small int = 0, 1e9
	mark := make(map[int]int)
	for i := 0; i < N; i++ {
		if big < A[i] {
			big = A[i]
			mark[big-small]++
		}
		if A[i] < small {
			small = A[i]
			big = A[i]
		}
	}
	for key, value := range mark {
		if cnt < key {
			cnt = key
			ans = value
		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


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

int main(){
    int n,k,r=0;
    cin>>n>>k;
    vector<int> l(n);
    for(int i=0;i<n;i++) cin>>l.at(i);
    sort(l.begin(),l.end());
    for(int i=n-1;i>n-1-k;i--) r+=l.at(i);
    cout<<r<<endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for cnt_500 in range(a + 1):
    for cnt_100 in range(b + 1):
        for cnt_50 in range(c + 1):
            price = 500 * cnt_500 + 100 * cnt_100 + 50 * cnt_50
            if price == x:
                cnt += 1
print(cnt)

Measured memory_bytes: 3064
# ABC120B - K-th Common Divisor
a, b, k = list(map(int, input().rstrip().split()))
a, b = sorted([a, b])
div = []

for i in range(1, a + 1):
    if a % i == 0 and b % i == 0:
        div.append(i)

print(sorted(div, reverse=True)[k - 1])

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

class Cmondai
{
    static void Main()
    {

        var N = Int32.Parse(Console.ReadLine());
        var A = new long[N];
        var ans = 0;
        var currentNum = 0L;
        var currentNumCount = 0;
        for (int i=0;i<N;++i) A[i] = Int64.Parse(Console.ReadLine());
        A=A.OrderBy(x=>x).ToArray();
        for (int i = 0; i < N; ++i)
        {
            if (A[i] == currentNum)
            {
                currentNumCount++;
                if (i == N - 1) if (currentNumCount % 2 != 0) ans++;
            }
            else
            {
                if (currentNumCount % 2 != 0) ans++;
                currentNum = A[i];
                currentNumCount = 1;
                if (i == N - 1) if (currentNumCount % 2 != 0) ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 20700
#include<bits/stdc++.h>
#define ll long long int
#define MEM(a, b) memset(a, (b), sizeof(a))
using namespace std;
ll dp[3001][3001];
ll arr[3001]={};
ll dfs(int i,int j,int temp)
{
  if(dp[i][j]!=-1) return dp[i][j];
  if(temp==0)
  {
    if(i==j) return dp[i][j]=arr[i];
    return dp[i][j]=max(arr[i]+dfs(i+1,j,1-temp),arr[j]+dfs(i,j-1,1-temp));
  }
  if(temp==1)
  {
    if(i==j) return dp[i][j]=0;
    return dp[i][j]=min(dfs(i+1,j,1-temp),dfs(i,j-1,1-temp));
  }
	// temp=0 means take max //temp=1 means take min
  return 0;
}
int main()
{  	ios_base::sync_with_stdio(false); cin.tie(0);
    int n;cin>>n;
    MEM(dp ,-1);
    ll sum=0;
    for(int i=1;i<=n;i++)
		{
			cin>>arr[i];
      sum+=arr[i];
		}
    cout<<2*dfs(1,n,0)-sum<<"\n";
    // for(int i=0;i<=4;i++)
    // {
    //   for(int j=0;j<=4;j++)
    //   cout<<dp[i][j]<<"  ";
    //   cout<<"\n";
    // }
return 0;
}


Measured memory_bytes: 70784
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <memory.h>
#include <set>
#include <cmath>
#define fio ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
ll _pow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; b >> i; i++) {
		if ((b >> i) & 1) ans *= a;
		a *= a;
	}
	return ans;
}
int main(void) {
	int N, L; scanf("%d %d", &N, &L);
	int allsum = N * (N + 2 * L - 1) / 2;
	if (N + L - 1 < 0) printf("%d\n", allsum - (N + L - 1));
	else if (L < 0) printf("%d\n", allsum);
	else printf("%d\n", allsum - L);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)    for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<int, int>
#define    FO           find_by_order
#define    OK           order_of_key
#define    mem(a)       memset(a,0,sizeof(a))
#define    ff           first
#define    ss           second


typedef tree <
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update >
set_t;


void fio()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
	double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
	time_taken *= 1e-9;
	cout << "\nExecuted in: " << fixed
	     << time_taken << setprecision(9);
	cout << " sec";
#endif
}

///----------------------------- | FUNCTIONS | --------------------------------------///

/*
const int N = 2e5 + 5;

vector<int> adj[N];
bool visited[N];
//int val[N];
int depth[N];
//int parent[N];

void dfs(int v)
{
	visited[v] = true;
	for (int u : adj[v])
	{
		if (!visited[u])
		{
			//parent[u] = v;
			depth[u] = depth[v] + 1;
			dfs(u);
		}
	}
}
*/

// left shift << multiply by 2
// right shift >> divide by 2

///----------------------------- | START FROM HERE | --------------------------------------///

//#define int long long //change int main to int32_t main


void solve()
{
	string s, t;
	cin >> s >> t;
	int m = s.size(), n = t.size();
	int dp[m + 5][n + 5];
	mem(dp);
	char path[m + 5][n + 5];
	mem(path);
	fr(i, 1, m + 1) fr(j, 1, n + 1)
	{
		if (s[i - 1] == t[j - 1])
		{
			dp[i][j] = 1 + dp[i - 1][j - 1];
			path[i][j] = 'x';
		}

		else
		{
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if (dp[i][j] == dp[i - 1][j])
				path[i][j] = 'd';
			else path[i][j] = 'l';
		}
	}
	string ans;
	int i = m, j = n;
	while (i != 0 && j != 0)
	{
		if (path[i][j] == 'x')
		{
			ans.pb(s[i - 1]);

			i--, j--;
		}
		else if (path[i][j] == 'd')
		{
			i--;
		}
		else j--; //cout << "sda";
	}

	reverse(ans.begin(), ans.end());
	cout << ans << nl;
}





int main()
{
	auto start = chrono::high_resolution_clock::now();
	boost;
	fio();
	int t;
	t = 1;
	//cin >> t;
	while (t--) solve();
	auto end = chrono::high_resolution_clock::now();
	TIME(start, end);
	return 0;
}




Measured memory_bytes: 47680
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define   ull unsigned long long 
#define mp make_pair
#define pb push_back
const int MAX=2e5+9;
const long long mod=1e9+7;
using namespace std;
vector<int>adj[MAX];
int main(){
	int n ;
	cin>>n;
	int cnt=0;
	int arr[n+1];
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		if(a!=i)
			cnt++;
	}
	if(cnt<=2)
		cout<<"YES";
	else
		cout<<"NO";

}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int x;
  cin >> x;
  cout << (x < 1200 ? "ABC" : "ARC") << endl;
}


Measured memory_bytes: 256
X = int(input())
if 400<=X<=599:
  print(8)
elif 600<=X<=799:
  print(7)
elif 800<=X<=999:
  print(6)
elif 1000<=X<=1199:
  print(5)
elif 1200<=X<=1399:
  print(4)
elif 1400<=X<=1599:
  print(3)
elif 1600<=X<=1799:
  print(2)
elif 1800<=X<=1999:
  print(1)

Measured memory_bytes: 9032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int n = ni();
 
        out.println(n * 800 - 200 * (n / 15));
    }
 
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

int main(){
    int a,b;
    int ans = 0;
    cin >> a >> b;
    for(int i = 1; i <= 2; i++){
        if(a >= b){
            ans += a;
            a--;
        }else{
            ans += b;
            b--;
        }
    }
    cout << ans << endl;
}

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

int main()
{
  int n;
  cin >> n;
  vector<pair<int, int>> point(n);
  for (int i = 0; i < n; ++i)
  {
    cin >> point.at(i).first >> point.at(i).second;
  }

  vector<double> edge(n * (n - 1));
  for (int i = 0; i < n - 1; ++i)
  {
    for (int j = i + 1; j < n; ++j)
    {
      edge.at(i * n + j) = sqrt(pow(point.at(i).first - point.at(j).first, 2) + pow(point.at(i).second - point.at(j).second, 2));
    }
  }
  double ans = 0;
  for (int i = 0; i < n * (n - 1); ++i)
  {
    ans += edge.at(i);
  }
  ans = ans * 2.0 / n;
  cout << setprecision(20) << ans << endl;
}


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

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 100 + 7
#define pi 3.1415926536
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int dx[4] = {0, 0, 1, -1};
int dy[4] = {-1, 1, 0, 0};
int a[100005];
vector<pair<int, int>> v;

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        int l, r;
        sf(l);
        sf(r);
        a[l] += 1;
        a[r + 1] -= 1;
    }
    int cnt = 0;
    for (int i = 2; i <= n; ++i)
    {
        a[i] += a[i - 1];
    }
    for (int i = 1; i <= n; ++i)
    {
        if (a[i] == m)
            cnt += 1;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  //input
  string S,T;
  cin >> S >> T;

  //S[i]から始めた文字列がTと一致するか調べる
  string str,ans = "~";
  bool findT;
  int Slen = S.length();
  int Tlen = T.length();
  for(int i = 0; i <= Slen - Tlen; i++){
    //文字列Tが存在するかチェック
    findT = true;
    for(int j = 0; j < T.size() ; j++){
      if( S[i+j] == T[j] || S[i+j] == '?' ) continue;
      else findT = false ;
    }

    if(findT){
      str = S.substr(0,i) + T + S.substr(i + T.size());
      for(int l = 0; l < str.size(); l++) if(str[l] == '?') str[l] = 'a';
      ans = min(ans,str);
    }
  }
  if(ans == "~") cout << "UNRESTORABLE" << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

bool test = true;
#define log(x) cout << "#x" << " : " << x << "\n";

int main()
{
    FIO;
    long long n, d;
    cin >> n >> d;
    d*=d;
    int cnt = 0;
    for(int i=0; i<n; i++) {
        long long x, y;
        cin >> x >> y;
        long long tmp = (x*x) + (y*y);
        if(tmp <= d)
            cnt++;
    }
    cout << cnt << "\n";
}



Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;

const int SIZE=5007;
int a[SIZE],can[SIZE];
int n,k; 

bool isneeded(int x)
{
	memset(can,0,sizeof(can));can[0]=1;
	int skip=-1;
	REP(i,n)if(a[i]==x && skip==-1)skip=i;
	REP(i,n)if(i!=skip)for(int j=k-1;j>=0;j--)if(can[j] && j+a[i]<k)can[j+a[i]]=1;
	REP(i,k)if(can[i]==1 && i+x>=k)return true;
	return false;
}

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>k;
	REP(i,n)cin>>a[i];
	sort(a,a+n);
	int l=-1,r=n;
	while(l+1<r)
	{
		int mid=(l+r)/2;
		if(isneeded(a[mid]))r=mid;
		else l=mid;
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 3684
#include<stdio.h>
int main()
{
	int masu[12][12];
	int n,i,j,w=0,h=0,t=0;
	
	for(;;h=0,w=0,t=0){
		for(i=0;i<11;i++){
			for(j=0;j<11;j++){
				masu[i][j]=0;
			}
		}
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				scanf("%d",&masu[i][j]);
			}
		}
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				w+=masu[i][j];
				h+=masu[j][i];
			}
			masu[i][j]=w;
			masu[j][i]=h;
			w=0;
			h=0;
		}
		
		for(i=0;i<=n;i++){
			t+=masu[n][i];
		}
		masu[i-1][j]=t;
		for(i=0;i<=n;i++){
			for(j=0;j<=n;j++){
				printf("%5d",masu[i][j]);
			}
			puts("");
		}
	}
	return 0;
}

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

int main()
{
  	int n, m;
  	cin>>n>>m;
  	int c[n][n];
  	memset(c, 0, sizeof(c));
  	for(int i = 0; i < m; i++)
    {
    	int a, b;
      	cin>>a>>b;
      	c[a-1][b-1] += 1;
      	c[b-1][a-1] += 1;
    }
  	for(int i = 0; i < n; i++)
    {
    	int sum = 0;
      	for(int j = 0; j < n; j++)
        {
        	sum += c[i][j];
        }
      	cout<<sum<<"\n";
    }
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        s: String,
    }
    let f_half: u64 = s[0..2].parse().unwrap();
    let l_half: u64 = s[2..].parse().unwrap();
    if 0 < f_half && f_half <= 12 {
        if 0 < l_half && l_half <= 12 {
            println!("AMBIGUOUS");
            return;
        } else {
            println!("MMYY");
            return;
        }
    } else {
        if 0 < l_half && l_half <= 12 {
            println!("YYMM");
            return;
        } else {
            println!("NA");
            return;
        }
    }

}


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

const int MAXN = 100005;
const int MOD = 1000000007;

int N;
int t[MAXN], a[MAXN];
int x[MAXN], y[MAXN];

void load() {
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
		scanf("%d", t + i);
	for (int i = 1; i <= N; i++)
		scanf("%d", a + i);
}

int solve() {
	int sol = 1;
	for (int i = 1; i <= N; i++) {
		if (t[i] > t[i - 1])
			x[i] = t[i];
		if (a[i] > a[i + 1])
			y[i] = a[i];
		if (x[i] && y[i] && x[i] != y[i])
			return 0;
		if (y[i] > t[i] || x[i] > a[i])
			return 0;
		if (!x[i] && !y[i])
			sol = (long long)sol * min(t[i], a[i]) % MOD;
	}
	
	return sol;	
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
int a,b,c,d,s1,s2;
cin >>a>>b>>c>>d;

s1 = a*b;
s2 = c*d;
if (s1>=s2)
{
    cout << s1 << endl;
}else
{
    cout << s2 << endl;
}









  
 
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import numpy as np
N, *A = map(int, open(0).read().split())
A = np.array(A, dtype=np.int64)
mod = 10**9 + 7

ans = 0
for i in range(60):
    mask = 1 << i
    cnt = np.count_nonzero(A&mask)
    x = cnt * (N-cnt)
    x *= mask % mod
    ans += x
    ans %= mod

print(ans)

Measured memory_bytes: 65676
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
A = []
B = []
for _ in range(N):
    a, b = inpl()
    A.append(a)
    B.append(b)

L = K + 1
ans = 0
for i in range(31):
    L_shift = L >> i
    if L_shift & 1 == 0:
        continue
    else:
        L_shift ^= 1
    value = 0
    for j in range(N):
        a_shift = A[j] >> i
        if (a_shift | L_shift) == L_shift:
            value += B[j]
    ans = max(ans,value)

print(ans)

Measured memory_bytes: 11084
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a, b;
	char S;
	while (true) {
		cin >> a >> S >> b;
		if (S == '+') cout << a + b << endl;
		if (S == '-')cout << a - b << endl;
		if (S == '*')cout << a * b << endl;
		if (S == '/')cout << a / b << endl;
		if (S == '?') break;
	}
}


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

void main(){
    auto tmp = readln.chomp.split.to!(int[]);
  	auto a = tmp[0], b = tmp[1];
  
	char[100][100] field;
  	foreach(i; 0 .. 50) foreach(j; 0 .. 100) field[i][j] = '.';
  	foreach(i; 50 .. 100) foreach(j; 0 .. 100) field[i][j] = '#';
    
    foreach(k; 0 .. a - 1){
      field[51 + (k / 50) * 2][(k % 50) * 2] = '.';
    }
    foreach(k; 0 .. b - 1){
      field[(k / 50) * 2][(k % 50) * 2] = '#';
    }
    
    writeln("100 100");
  	foreach(i; 0 .. 100) field[i].to!string.writeln;
}

Measured memory_bytes: 256
from collections import Counter

n, k = map(int, input().split())
a = [int(an) for an in input().split()]
ans = 0
set_a = set(a)
num_of_types = len(set_a)
if num_of_types > k:
  cnt = Counter(a)
  ans = sum(sorted(cnt.values())[: num_of_types - k])

print(ans)

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

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

    int out = L * (N - 1) + N * (N - 1) / 2;
    if (L >= 0);
    else if (L + N > 0) {
        out += L;
    } else {
        out -= N - 1;
    }

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def solve(N: Long): Int = {
    val a = (1 to math.sqrt(N).toInt).reverse.find { a =>
      N % a == 0
    }.get
    val b = N / a
    math.log10(b).toInt + 1 // aは(1-√N)なので必ずbが大きい
  }

  def main(args: Array[String]): Unit = {
    val N = new Scanner(System.in).nextLong()
    println(solve(N))
  }
}


Measured memory_bytes: 27840
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
using namespace std;

ul binomialCoeff(int n, int k)
{
    ul *C = new ul[k];
    C[0] = 1;  // nC0 is 1

    for (int i = 1; i <= n; i++)
    {
        // Compute next row of pascal triangle using
        // the previous row
        for (int j = min(i, k); j > 0; j--)
            C[j] = C[j] + C[j-1];
    }
    delete[] C;
    return C[k];
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n] ={};
    int maxA =-1;
    int maxPoint = -1;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        if (a[i] > maxA){
            maxA = a[i];
            maxPoint = i;
        }
    }
    int closeness = std::numeric_limits<int>::max();
    int target = maxA / 2;
    ul ans = 0;
    for(int i = 0; i < n; i++){
        if(i != maxPoint){
            int tmp = std::abs(target - a[i]);
            if (tmp < closeness){
                ans = a[i];
                closeness = tmp;
            }
        }
    }
    cout << maxA << " " << ans << endl;

    return 0;
}

Measured memory_bytes: 640
url = "https://atcoder.jp//contests/abc154/tasks/abc154_d"

def search_ind(lis, k):
    tmp = sum(lis[0:k])
    m = tmp
    inds = [0, k - 1]
    for i in range(0, len(lis) - k):
        tmp = tmp - lis[i] + lis[i + k]
        # print(tmp, lis[i + k])
        if tmp > m:
            inds = [i + 1, i + k]
            m = tmp
    return inds

def main():
    n, k = list(map(int, input().split()))
    daice = list(map(int, input().split()))
    f, t = search_ind(daice, k)
    kitai = daice[f:t + 1]
    ans = 0
    for v in kitai:
        sumt = 0
        for i in range(1, v + 1):
            sumt += i * (1 / v)
        ans += sumt
    print(ans)




if __name__ == '__main__':
    main()


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;  cin >> s;
    if (s[0] == s[2]) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }

    return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < n; i++)
#define REP(n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using INT64 = long long;
using UINT64 = unsigned long long;
#define MOD 1000000007

int main(void)
{
    IOS
    int x,a;
    cin >> x >> a;
    if (x < a) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 2000
#define true 1
#define false 0

int solve(int,int);

int n,A[N];

int main(){
  int q,x,i;
  int B[N];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&B[i]);
  }

  for(i=0;i<q;i++){
    x = solve(0,B[i]);
    if(x == 1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m){

   int res;

  if(m == 0){
    return true;
  }
  if(i >= n){
    return false;
  }
  res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}

Measured memory_bytes: 588
INF = 10 ** 10

N = int(input())
h = list(map(int, input().split()))

dp = [INF for _ in range(N)]
dp[0] = 0
# 0-indexed

for i in range(1, N):
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    if i - 2 >= 0:
        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[N - 1])


Measured memory_bytes: 13924
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
    public:
    ll n,s;
    ll dsum(ll b){
        ll sum=0;
        ll t=n;
        while(t){
            sum+=t%b;
            t/=b;
        }
        return sum;
    }
    void solve(){
        ios::sync_with_stdio(false);
        cin>>n>>s;
        if(n==s){
            cout<<n+1;
            return;
        }
        else if(n<s){
            cout<<-1;
            return;
        }
        ll ans=1e18;
        for(ll b=2;b*b<=n;b++){
            if(dsum(b)==s){
                ans=min(ans,b);
            }
        }
        for(ll p=1;p*p<=n-s;p++){
            if((n-s)%p==0){
                ll b=(n-s)/p+1;
                ll q=n-p*b;
                if(p>=b||p<=0||q>=b||q<0)continue;
                if(p+q==s)ans=min(ans,b);
            }
        }
        if(ans==1e18)ans=-1;
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

Measured memory_bytes: 256
from collections import deque

import sys 
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N,M=map(int,input().split())
g=[[] for _ in range(N)]
gr=[[] for _ in range(N)]
for _ in range(M):
    u,v=map(int,input().split())
    g[u-1].append(v-1)
    gr[v-1].append(u-1)
S,T=map(int,input().split())


f = [[-1,-1,-1] for _ in range(N)]
f[S-1][0] = 0
q=deque([[S-1,0]])

while q:
    d,s = q.popleft()
    s += 1
    for sd in g[d]:
        if f[sd][s%3]==-1:
            f[sd][s%3] = s//3
            q.append([sd,s])


print(f[T-1][0])


Measured memory_bytes: 77744
// https://dwacon5th-prelims.contest.atcoder.jp/tasks/dwacon5th_prelims_b

#include<cstdio>
#include<vector>
using namespace std;
const int N=1000+10;
const int M=N*(N+1)/2+10;
const int BIT=39;
int n,m;
bool f[M][BIT+10]; // 1000*1e9(10) == 1110100011010100101001010001000000000000(2)
long long sum[N],ans,s;
vector<long long>a,b;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&s);
		sum[i]=sum[i-1]+s;
		for(int j=0;j<i;j++)
			a.push_back(sum[i]-sum[j]);
	}
	for(int i=BIT;i>=0;i--)
	{

		b.clear();
		s=1ll<<(i*1ll);
		for(int j=0;j<a.size();j++)
			if(s&a[j])b.push_back(a[j]);
		if(b.size()>=m)
		{
			ans+=s;
			a=b;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 6512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;

int main() {
  ll n, k;
  cin >> n >> k;
  ll remain = n % k;
  ll ans = min(remain, abs(remain - k));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int n,x,t;
	cin>>n>>x>>t;
	cout<<(n%x? (n/x+1)*t:n/x*t);
    return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
vector<int> v[3];

void init()
{
    for(int i=1;;i++)
    {
        if(v[0].size()>=100&&v[1].size()>=100&&v[2].size()>=100) return;
        if(i%100) v[0].push_back(i);
        else if(i/100%100) v[1].push_back(i);
        else if(i/100/100%100) v[2].push_back(i);
    }
}

int main()
{
    init();
    int d,n;
    scanf("%d %d",&d,&n);
    printf("%d\n",v[d][n-1]);
    return 0;
}


Measured memory_bytes: 6512
#include<stdio.h>
#define MAX 2000000

int left(int i){ return 2*i; }
int right(int i){ return 2*i+1; }

int H,A[MAX+1];

void maxHeapfy(int i){

  int l = left(i);
  int r = right(i);
  int largest,n;
  
  if(l<=H&&A[l]>A[i]) largest = l;
  else largest =i;

  if(r<=H&&A[r]>A[largest]) largest=r;

  if(largest!=i){
    n=A[i];
    A[i]=A[largest];
    A[largest]=n;
    maxHeapfy(largest);
  }
}


int main(){
  int i;

  scanf("%d",&H);
  
  for(i=1;i<=H;i++) scanf("%d",&A[i]);

  for(i=H/2;i>=1;i--) maxHeapfy(i);

  for(i=1;i<=H;i++) printf(" %d",A[i]);

  printf("\n");

  return 0;

}



Measured memory_bytes: 3732
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)
const int MOD = 1000000007;

const ll M = MOD;
vector<ll> fac(300001);   // n!(mod M)
vector<ll> ifac(300001);  // k!^{M-2} (mod M)
// a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x,
        ll n) {  // x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
  ll ans = 1;
  while (n != 0) {
    if (n & 1) ans = ans * x % M;
    x = x * x % M;
    n = n >> 1;
  }
  return ans;
}

ll comb(ll a, ll b) {  // aCbをmod計算
  if (a == 0 && b == 0) return 1;
  if (a < b || a < 0) return 0;
  ll tmp = ifac[a - b] * ifac[b] % M;
  return tmp * fac[a] % M;
}

// a^b
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

// a^x ≡ b (mod. m) となる最小の正の整数 x を求める
long long modlog(long long a, long long b, int m) {
  a %= m, b %= m;

  // calc sqrt{M}
  long long lo = -1, hi = m;
  while (hi - lo > 1) {
    long long mid = (lo + hi) / 2;
    if (mid * mid >= m)
      hi = mid;
    else
      lo = mid;
  }
  long long sqrtM = hi;

  // {a^0, a^1, a^2, ..., a^sqrt(m)}
  map<long long, long long> apow;
  long long amari = 1;
  for (long long r = 0; r < sqrtM; ++r) {
    if (!apow.count(amari)) apow[amari] = r;
    (amari *= a) %= m;
  }

  // check each A^p
  long long A = modpow(modinv(a, m), sqrtM, m);
  amari = b;
  for (long long q = 0; q < sqrtM; ++q) {
    if (apow.count(amari)) {
      long long res = q * sqrtM + apow[amari];
      if (res > 0) return res;
    }
    (amari *= A) %= m;
  }

  // no solutions
  return -1;
}

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

  fac[0] = 1;
  ifac[0] = 1;
  for (ll i = 0; i < 300000; i++) {
    fac[i + 1] = fac[i] * (i + 1) % M;  // n!(mod M)
    ifac[i + 1] =
        ifac[i] * mpow(i + 1, M - 2) % M;  // k!^{M-2} (mod M) ←累乗にmpowを採用
  }
  int N, K;
  cin >> N >> K;
  for (int i = 1; i <= K; ++i) {
    cout << comb(K - 1, i - 1) % MOD * comb(N - K + 1, i) % MOD << endl;
  }
  return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>

int main()
{
  int a,b,c;
  int max=-1;
  int p;
  int ans;
  scanf("%d%d%d",&a,&b,&c);
  if(max<a){
    max=a;
    p=1;
  }
  if(max<b){
    max=b;
    p=2;
  }
  if(max<c){
    max=c;
    p=3;
  }
  if((3*max)%2==(a+b+c)%2){
    if(p==1){
      ans=(2*max-b-c)/2;
    }
    else if(p==2){
      ans=(2*max-a-c)/2;
    }
    else if(p==3){
      ans=(2*max-a-b)/2;
    }
  }
  else{
    if(p==1){
      ans=(2*max+3-b-c)/2;
    }
    else if(p==2){
      ans=(2*max+3-a-c)/2;
    }
    else if(p==3){
      ans=(2*max+3-a-b)/2;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
 ll n,k;
 cin>>n>>k;
 ll s=n%k;
 if(s>=k/2 && s>0)
 s=k-s;
 cout<<s<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N, K;
    std::cin >> N >> K;
    
    int ans = 1;
    ans *= K;

    for (int i = 0; i < N-1; i++) {
        ans *= (K-1);
    }

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

Measured memory_bytes: 256
t=int(input())
l=[]
b=0
c=0
for j in range(t):
    a=int(input())
    l.append(a)
    if(a>b):
        b=a
    elif(a>c):
        c=a
for i in l:
    if(i!=b):
        print(b)
    else:
        print(c)

Measured memory_bytes: 12520
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1000000000000
#define fr first
#define sc second
using vl =vector<ll>;
using vvl =vector<vl>;
const ll md = 998244353;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = max(a*c, max(a*d, max(b*c, b*d)));
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int n;
    cin>>n;
    vl bs(n - 1);
    cin>>bs;

    ll ss = bs[0];
    rep(i, n - 2) {
        ss += min(bs[i], bs[i + 1]);
    }
    ss += bs.back();
    cout<<ss<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int K = Integer.parseInt(S[1]);
    long sum = 0;
    for(int i = 0; i < K; i++){
      sum += Long.parseLong(sc.next());
    }

    System.out.println(sum >= N ? "Yes" : "No");
  }
}

Measured memory_bytes: 46908
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

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

int main() {

    double W,H,x,y;
    cin >> W >> H >> x >> y;
    double out = W*H/2;
    ll cnt = 0;
    if(x==W/2&&y==H/2) cnt = 1;
    cout << fixed << setprecision(9) << out << " ";
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
(function() {
  var isInRange, isNum, reader;

  isNum = function(n) {
    return n.match(/\d{1,5}/);
  };

  isInRange = function(n) {
    return n >= 0 && n <= 86400;
  };

  reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
  });

  reader.on('line', function(line) {
    var a, h, m, s;
    a = isNum(line) ? parseInt(line, 10) : void 0;
    if (isInRange(a)) {
      s = a % 60;
      h = (a - a % 3600) / 3600;
      m = (a - s - h * 3600) / 60;
      return console.log(h + ":" + m + ":" + s);
    }
  });

}).call(this);

Measured memory_bytes: 15884
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
struct apapun{
	int panjang,l,r;
	apapun(int _panjang,int _l,int _r)
	{
		panjang=_panjang;
		l=_l;
		r=_r;
	}
	apapun(){
	}
};
int tree[100005]={},n,m,ans[100005]={};
vector <apapun> daftar;
int lsone(int angka){
	return (angka&-angka);
}
void update(int indeks,int tambah){
	while(indeks<=m){
		tree[indeks]+=tambah;
		indeks+=lsone(indeks);
	}
}
int nilai(int indeks){
	int ret=0;
	while(indeks>0){
		ret+=tree[indeks];
		indeks-=lsone(indeks);
	}
	return ret;
}
bool cmp(apapun a,apapun b){
	return (a.panjang<b.panjang);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		daftar.push_back(apapun(r-l+1,l,r));
	}
	sort(daftar.begin(),daftar.end(),cmp);
	int ind=0,sisa=daftar.size();
	for(int i=1;i<=m;i++){
		while(ind<daftar.size()&&daftar[ind].panjang<i){
			update(daftar[ind].l,1);
			update(daftar[ind].r+1,-1);
			ind++;
			sisa--;
		}
		//cout<<"tai "<<i<<" "<<sisa<<" "<<ind<<endl;
		ans[i]=sisa;
		for(int j=i;j<=m;j+=i)
			ans[i]+=nilai(j);
	}
	for(int i=1;i<=m;i++)
		printf("%d\n",ans[i]);
}

Measured memory_bytes: 6512
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int hit,brow;
    char a[5],b[5];
    for(;;){
        hit=0,brow=0;
        cin>>a>>b;
        if(a[0]=='0'&&a[1]=='\0'){
            break;
        }
        for(int i=0;i<3;i++){
            for(int j=i+1;j<4;j++){
                if(a[i]==b[j]){
                    brow++;
                }
                if(b[i]==a[j]){
                    brow++;
                }
            }
        }
        for(int i=0;i<4;i++){
            if(a[i]==b[i]){
                hit++;
            }
        }
        cout<<hit<<" "<<brow<<endl;
    }
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

void add(ll& a, ll b){a = (a+b) % MOD;}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;
    cin>>x>>y;
    if(x%y==0){
        cout<<"-1"<<endl;
        return 0;
    }
    else{
        cout<<x<<endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << p.first << " " << p.second;return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if (it != v.begin())os << " ";os << *it;
  }return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void print(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void print(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int f[1000];
string t[10000];
list<int> lst;
void init(){
  rep(i,1000)f[i] = 0;
  lst.clear();
}
  
signed main(){
  rep(i,10000){
    if((i+1)%3 != 0 and (i+1)%5 != 0){t[i] = to_string(i+1);continue;}
    if((i+1)%3 == 0)t[i] += "Fizz";
    if((i+1)%5 == 0)t[i] += "Buzz";
  }
  rep(i,5)lst.pb(i);
	while(1){
    int n, m;
    scanf("%lld%lld", &n, &m);
    if(n == 0 and m == 0)break;
    init();
    rep(i,n)lst.pb(i);
    
    auto it = lst.begin();
    rep(i,m){
      string str;
      cin >> str;
      if(lst.size() == 1)continue;
      if(t[i] != str)it = lst.erase(it);
      else it++;
      if(it == lst.end())it = lst.begin();
    }
    
    for(auto it = lst.begin();it != lst.end();++it)f[*it] = 1;
    vector<int> ans;
    rep(i,n)if(f[i])ans.pb(i+1);
    cout << ans << endl;
  }
	return 0;
}







Measured memory_bytes: 3756
#include <stdio.h>
#include <stdlib.h>
#include <vector>

#define MAX_N (100000L)
#define MAX_M (100000L)

using namespace std;

long is_bipartite(const vector<vector<long>> &adj_lists, vector<long> &cs,
                  long i) {
  for (long j : adj_lists[i]) {
    if (cs[j] < 0) {
      cs[j] = 1 - cs[i];
      if (!is_bipartite(adj_lists, cs, j)) {
        return 0;
      }
    } else {
      if (cs[j] == cs[i]) {
        return 0;
      }
    }
  }
  return 1;
}

int main() {
  // read inputs
  long N, M, as[MAX_M], bs[MAX_M];
  scanf("%ld %ld", &N, &M);
  for (long i = 0; i < M; i++) {
    scanf("%ld %ld", &as[i], &bs[i]);
    as[i]--;  // NOTE : modified input
    bs[i]--;  // NOTE : modified input
  }

  // create graph
  vector<vector<long>> adj_lists(N, vector<long>());
  for (long i = 0; i < M; i++) {
    const long a = as[i], b = bs[i];
    adj_lists[a].push_back(b);
    adj_lists[b].push_back(a);
  }

  // check if the graph is a bipartite graph
  vector<long> cs(N, -1);
  cs[0] = 0;
  const long b = is_bipartite(adj_lists, cs, 0);

  // print answer
  if (b) {
    long cnt0 = 0, cnt1 = 0;
    for (long i = 0; i < N; i++) {
      if (cs[i] == 0) {
        cnt0++;
      } else {
        cnt1++;
      }
    }
    printf("%ld\n", cnt0 * cnt1 - M);
  } else {
    printf("%ld\n", N * (N - 1) / 2 - M);
  }
}

Measured memory_bytes: 9088