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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

bool is_fizzbuzz_num(int n) {
    return (n % 3 != 0) && (n % 5 != 0);
}

int main() {
    // get values from input
    int N;
    READ(N);

    // main procedure
    ll sum = 0;
    for (int i = 1; i <= N; ++i) {
        if (is_fizzbuzz_num(i)) {
            sum += i;
        }
    }

    // output
    WRITE_N(sum);

    return 0;
}


Measured memory_bytes: 3620
#モンスターの体力は H
#トキはN種類の魔法が使え、
#i番目の魔法を使うと、モンスターの体力を Ai減らすことができますが、
#トキの魔力を Bi消耗します。

#dp[i] = モンスターの体力を i 減らすため消耗する魔力の最小値
#dp[i+1] = min(dp[i-Ai]+Bi,dp[i])
#dp[0]=0

import numpy as np
 
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab = np.array(ab)
 
a = ab[:, 0]
b = ab[:, 1]
 
dp = np.zeros(100001, dtype=np.int)
for i in range(1, h+1):
    dp[i] = (dp[i-a]+b).min()
print(dp[h])


Measured memory_bytes: 21528
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = arr_data[0][0]

print("ABC"+n)



Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define answer(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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 main() {
    Int a, b;
    cin >> a >> b;

    cout << Lcm(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
template<class T>
inline T ab(T a){
	return (a > 0) ? a : -a;
}
template<class T>
inline void swa(T &a, T &b){
	a ^= b ^= a ^= b;
	return ;
}
ll k, a, b;
int main(){
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	qread(k);
	qread(a);
	qread(b);
	if(b / k * k >= a){
		puts("OK");
	} else {
		puts("NG");
	}
	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int stack[1000];
int last = 0;

void pop(void)
{
	last--;
}
void push(int x)
{
	stack[last] = x;
	last++;
}
int top(void)
{
	return (stack[last - 1]);
}

int main(void)
{
	char str[1000000];
	int x;
	int i;
	int l, r;
	
	while (scanf("%s", str) == 1){
		x = 0;
		switch(str[0]){
			case '+':
				l = top();
				pop();
				r = top();
				pop();
				push(l + r);
			break;
			
			case '-':
				l = top();
				pop();
				r = top();
				pop();
				push(r - l);
			break;
			
			case '*':
				l = top();
				pop();
				r = top();
				pop();
				push(l * r);
			break;
		}
		if (str[0] != '+' && str[0] != '-' && str[0] != '*'){
			for (i = 0; str[i] != '\0'; i++){
				x = x * 10 + str[i] - '0';
			}
			push(x);
		}
	}
	
	printf("%d\n", top());
	
	return (0);
}

Measured memory_bytes: 548
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		
		Arrays.sort(s);
		if (String.valueOf(s).equals("abc")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int h, w;
    char a[110][110];
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < w+2; i++) {
        cout << '#';
    }
    cout << endl;
    for (int i = 0; i < h; i++) {
        cout <<'#';
        for (int j = 0; j < w; j++) {
            cout << a[i][j];
        }
        cout << '#' << endl;
    }
    for (int i = 0; i < w+2; i++) {
        cout << '#';
    }
    cout << endl;
	return 0;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const D = parseInt(arg[0].split(" ")[0]);
    const T = parseInt(arg[0].split(" ")[1]);
    const S = parseInt(arg[0].split(" ")[2]);

    console.log(D / S <= T ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29688
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
    
    char str[1000];
    char *tok;
    int x,y;
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    x=strtol(tok,NULL,10);
    tok=strtok(NULL," ");
    y=strtol(tok,NULL,10);
    if(x%y==0){
        printf("-1");
    }else{
        printf("%d",x);  
    }
        
    
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    vector<ll> a(N);
    rep(i, 0, N) { cin >> a[i]; }
    ll mini = 0, sum = 0;

    for(int i = 0; i < N; i++) {
        if(mini < a[i]) {
            mini = a[i];
        } else {
            sum += abs(mini - a[i]);
        }
    }
    cout << sum << endl;
    return 0;
}


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

using namespace std;;
int n;
vector<int>a;
int memo[100001];

int dp(int i){
    if(i == n-1){
        return 0;
    }
    if(memo[i] !=-1) return memo[i];
    int ans = 1e9;
    ans = min(ans,dp(i+1)+abs(a[i]-a[i+1]));
    if(i < n-2){
        ans = min(ans,abs(a[i]-a[i+2])+dp(i+2));
    }
    return memo[i] = ans;
}


int main(){
    memset(memo,-1,sizeof(memo));
    cin >> n;
    a.resize(n);
    for(int&i: a) cin >> i;
    cout << dp(0);

}


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

using namespace std;

bool g[5][5];
string path = "0123";

int main() 
{
    for (int i = 0; i < 3; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;b--;
        g[a][b] = g[b][a] = 1;
    }
    
    do
    {
        bool bb = 1;
        for (int i = 0; i < 3; i++)
        {
            int a = path[i] - '0', b = path[i + 1] - '0';
            if (!g[a][b])
                bb = 0;
        }
        if (bb)
        {
            cout << "YES";
            return 0;
        }
    }while(next_permutation(path.begin(), path.end()));
    
    cout << "NO";
}


Measured memory_bytes: 256
int main(){
	int n, x;
	scanf("%d %d",&n,&x);
	int l[n];
	int i, j;
	int p[n];
	p[0] = 0;
	int count=1;
	for(i=0;i<n;i++){
		scanf("%d",&l[i]);
	}
	for(j=0;j<n;j++){
		p[j+1] = p[j] + l[j];
		if(p[j+1]<=x){
			count++;
		}
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;
vector<int>ok(600000,0),memo(600000,-1),fl(600000,0);
int inf=1e9+7,res=0;

int dfs(int node,int sl,int tl)
{
//  cout<<node<<" "<<fl[node]<<memo[node]<<endl;

  if(fl[node]==1&&memo[node]==-1)return inf;
  if(memo[node]>-1)return memo[node];
  fl[node]=1;
  int r=0;
  if(ok[node])r=dfs((node+tl)%sl,sl,tl)+1;
  else r=0;
  return memo[node]=r;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string t,s;
  cin>>s;
  cin>>t;
  int l=t.length(),sl=s.length();
  vector<int>A(l+1);
  A[0] = -1;
  int j = -1;
  for (int i = 0; i < t.size(); i++)
  {
    while (j >= 0 && t[i] != t[j]) j = A[j];
    j++;
    if (j>0&&t[i+1] == t[j]) A[i+1] = A[j];else A[i+1] = j;
  }
  rep(i,l+1)A[i]=i-A[i];
  int m=0,i=0;
  while(m<sl)
  {
    if(t[i]==s[(m+i)%sl])
    {
      i++;
      if(i==l)ok[m]=1;
    }
    else
    {
      m+=A[i];
      if(i>0)i=i-A[i];
    }

  }
//  rep(i,sl)cout<<ok[i]<<endl;

  rep(i,sl)dfs(i,sl,l);
  rep(i,sl)chmax(res,memo[i]);
  //rep(i,sl)cout<<memo[i]<<endl
  if(res>=inf)res=-1;
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 18588
#include<bits/stdc++.h>
long long bags[2];
long long C(long long a, long long b) {
	if (a - b < b)b = a - b;
	long long tot = 1;
	for (int i = 1; i <= b; i++) {
		tot = (tot*(a - i+1))/i;
	}
	return tot;
}
int main()
{
	int N, P;
	int temp;
	long long tot = 0;
	scanf("%d%d", &N, &P);
	for (int i = 0; i < N; i++) {
		scanf("%d", &temp);
		bags[temp % 2]++;
	}
	if (P == 0 && bags[1] % 2) {
		tot = 0;
		for (int i = 1; i <= bags[1] + bags[0]; i++) {
			for (int j = 1; j <= i&&j <= bags[1]; j+=2) {
				if (bags[0] >= i - j)tot += C(bags[0], i - j)*C(bags[1], j);
			}
		}
	}
	else if (P == 0 && bags[1] % 2 == 0) {
		tot = 1;
		for (int i = 1; i <= bags[1] + bags[0]; i++) {
			for (int j = 0; j <= i&&j<=bags[1]; j += 2) {
				if(bags[0]>=i-j)tot += C(bags[0], i-j)*C(bags[1], j);
			}
		}
	}
	else if (P&&bags[1] % 2 == 1) {
		tot = 1;
		for (int i = 1; i <= bags[1] + bags[0]; i++) {
			for (int j = 0; j <= i&&j <= bags[1]; j += 2) {
				if (bags[0] >= i - j)tot += C(bags[0], i - j)*C(bags[1], j);
			}
		}
	}
	else {
		tot = 0;
		for (int i = 1; i <= bags[1] + bags[0]; i++) {
			for (int j = 1; j <= i&&j<=bags[1]; j += 2) {
				if (bags[0] >= i - j)tot += C(bags[0], i - j)*C(bags[1], j);
			}
		}
	}
	printf("%lld", tot);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e3 + 10;
const int maxm = 200 + 10;
int n, m, top;
int b[maxn][maxm], sta[maxn], l[maxn][maxm], r[maxn][maxm];
ll ans, a[maxn], c[maxn][maxn];
void add(int lx, int rx, int ly, int ry, int val)
{
	c[lx][ly] += val;
	c[lx][ry + 1] -= val;
	c[rx + 1][ly] -= val;
	c[rx + 1][ry + 1] += val;
} 
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 2; i <= n; ++i) 
	{
		scanf("%lld", &a[i]);
		a[i] += a[i - 1];
	}
	for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) scanf("%d", &b[i][j]);
	for(int j = 1; j <= m; ++j)
	{
		top = 0;
		for(int i = 1; i <= n; ++i)
		{
			while(top && b[sta[top - 1]][j] <= b[i][j]) --top;
			if(top) l[i][j] = sta[top - 1];
			else l[i][j] = 0;
			sta[top++] = i;
		}
		top =  0;
		for(int i = n; i; --i)
		{
			while(top && b[sta[top - 1]][j] < b[i][j]) --top;
			if(top) r[i][j] = sta[top - 1];
			else r[i][j] = n + 1;
			sta[top++] = i;
		}
	}
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			add(l[i][j] + 1, i, i, r[i][j] - 1, b[i][j]);
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
		{
			c[i][j] = c[i][j] + c[i - 1][j] + c[i][j - 1] - c[i - 1][j - 1];
			if(i <= j) ans = max(ans, c[i][j] - (a[j] - a[i]));
		}
	cout << ans << endl;
	return 0;
}
	

Measured memory_bytes: 211684
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
      int i = 0;
      if(a<=3){
        i += (4-a)*100000;
      }if(b<=3){
        i += (4-b)*100000;
      }if(a==1 & b==1){
        i = 1000000;
      }
      System.out.println(i); 
        
        

	}
}

Measured memory_bytes: 21844
// And you curse yourself for things you never done

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef pair<ld,ld> pld;

const int maxn = (1<<19) + 10;

const ld pi=acos(-1);

pld operator +(pld a,pld b) {return {a.F+b.F,a.S+b.S};}
pld operator -(pld a,pld b) {return {a.F-b.F,a.S-b.S};}
pld operator *(pld a,pld b) {return {a.F*b.F-a.S*b.S,a.F*b.S+a.S*b.F};}
void operator/=(pld &a,ld b) { a.F/=b;a.S/=b;}

void fft(vector<pld> &a,bool rev){
    if(a.empty()) return;
    int n=32-__builtin_clz(sz(a));
    if(sz(a)==(1<<(n-1))) --n;
    a.resize((1<<n));
    
    for(int i=1;i<(1<<n);i++){
	int x=0;
	for(int j=0;j<n;j++)
	    if(bit(i,j)) x+=(1<<(n-1-j));
	if(i<x) swap(a[i],a[x]);
    }
    int N=(1<<n);
    for(int ln=0,Ln1=1,Ln2=2;ln<n;ln++,Ln1<<=1,Ln2<<=1){
	for(int start=0;start<N;start+=Ln2){
	    ld alpha=(rev?-1:1)*2*pi/Ln2;
	    pld w={cos(alpha),sin(alpha)},nw={1,0};
	    for(int i=start;i<start+Ln1;i++){
		pld &A=a[i],&B=a[i+Ln1],x=B*nw;
		nw=nw*w;
		B=A-x;A=A+x;
		if(rev)	B/=2,A/=2;
	    }
	}
    }
}

const int mod = 2e5 + 3;

int tolg[maxn], reallg[maxn];

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

    int nw = 1;
    for(int i = 0; i < mod - 1; i++){
	reallg[i] = nw;
	tolg[nw] = i;
	nw = 2ll * nw % mod;
    }
    int n;
    cin >> n;
    vector<int> vec;
    vector<pld> ff(2 * mod);
    ll ans = 0;
    for(int i = 0; i < n; i++){
	int x;
	cin >> x;
	if(x == 0)
	    continue;
	ff[tolg[x]].F++;
	ans = (1ll * ans - 1ll * x * x % mod);
    }
    fft(ff, 0);
    for(int i = 0; i < sz(ff); i++)
	ff[i] = ff[i] * ff[i];
    fft(ff, 1);
    for(int i = 0; i < sz(ff); i++){
	ans+= 1ll * reallg[i % (mod-1)] * (ll(ff[i].F + 0.5));
    }
    ans/=2;
    return cout << ans << endl, 0;
}


Measured memory_bytes: 33556
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.ArrayBuffer

class Node(val data:Int) {
  var prev:Node = null
  var next:Node = null
}

class DList {
  var first = new Node(-1)
  var last = new Node(-1)
  first.next = last
  first.next.prev = first

  def insert(data:Int) = {
    var newNode = new Node(data)
    newNode.next = first.next
    if(first.next!=null) first.next.prev = newNode
    first.next = newNode
    newNode.prev = first
  }

  def search(data:Int) = {
    var node = first.next
    while(node != last && node.data != data) {
      node = node.next
    }
    node
  }

  def delete(node:Node):Unit = {
    if(node!=last) {
      node.prev.next = node.next
      node.next.prev = node.prev
    }
  }

  def delete(data:Int):Unit = delete(search(data))
  def deleteFirst() = delete(first.next)
  def deleteLast() = delete(last.prev)

  def print() = {
    val b = new ArrayBuffer[Int]
    var node = first.next
    while(node != last) {
      b += node.data
      node = node.next
    }
    println(b.toArray.mkString(" "))
  }
}

object Main {
  def main(args:Array[String]) = {
    val dlist = new DList()
    val n = readInt
    for(i<-1 to n) {
      val s = readLine.split(" ")
      if(s(0)=="insert") dlist.insert(s(1).toInt)
      else if(s(0)=="delete") dlist.delete(s(1).toInt)
      else if(s(0)=="deleteFirst") dlist.deleteFirst
      else if(s(0)=="deleteLast") dlist.deleteLast
    }
    dlist.print()
  }
}

Measured memory_bytes: 459632
S = input()
T = input()
anslist = []
for i in range(len(S)-len(T)+1):
    kouho = [0]*len(S)
    ok = 1
    for j in range(len(T)):
        if S[i+j] == T[j] or S[i+j] == "?":
            kouho[i+j] = T[j]
        else:
            ok = 0
            break
    if ok == 1:
        for k in range(len(S)):
            if kouho[k] == 0:
                if S[k] != "?":
                    kouho[k] = S[k]
                else:
                    kouho[k] = "a"
        kouho = ''.join(kouho)
        anslist.append(kouho)
if len(anslist) == 0:
    ans = "UNRESTORABLE"
else:
    anslist.sort()
    ans = anslist[0]
print(ans)


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int mod = 1e9 + 7;
#define int long long int

int32_t main() {
    IOS ;
    // int t ; cin >> t ; while(t--) {}
    int n ; cin >> n ; int x[n], y[n] ; 
    for(int i=0; i<n; i++) cin >> x[i] >> y[i] ; 
    
    int a, b, c, d, res = -1 ; 
    a = -x[0] - y[0] ;
    b = -x[0] + y[0] ;
    c = x[0] - y[0] ;
    d = x[0] + y[0] ;
    
    for(int i=1; i<n; i++) {
        res = max(res, x[i]+y[i] + a) ;
        res = max(res, x[i]-y[i] + b) ;
        res = max(res, -x[i]+y[i] + c) ;
        res = max(res, -x[i]-y[i] + d) ;
        
        a = max(a, -x[i]-y[i]) ;
        b = max(b, -x[i]+y[i]) ;
        c = max(c, x[i]-y[i]) ;
        d = max(d, x[i]+y[i]) ;
    }
    
    cout << res ;
    
    return 0 ;
}


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

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

    static class BFindSymmetries {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            char[][] c = new char[n][];
            for (int i = 0; i < n; i++) {
                c[i] = in.next().toCharArray();
            }

            char[][] b = new char[n][n];
            int answer = 0;
            for (int offset = 0; offset < n; offset++) {
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < n; j++) {
                        b[i][j] = c[i][(j + offset) % n];
                    }
                }
                boolean valid = true;
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < n; j++) {
                        valid &= b[i][j] == b[j][i];
                    }
                }
                if (valid) {
                    answer++;
                }
            }

            answer *= n;

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }
}



Measured memory_bytes: 24456
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define INF 1<<29
int main(){
  int N;
  cin>>N;
  vi X(N);
  rep(i, N){
    cin>>X[i];
  }

  int ans = INF;
  rep(P, 101){
    int ansp = 0;
    rep(x, N){
      ansp += (X[x]-P)*(X[x]-P);
    }
    ans = min(ans, ansp);
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int i = 0, ans = 0, flag = 0;
	char s[12], t[12];

	cin >> s >> t;
	//s列まで一致
	while (s[i] >= 'a' and s[i] <= 'z') {
		//cout << i <<flag << "\n";
		if (s[i] != t[i]) flag = 1;
		i++;
	}
	//cout << flag << "\n";
	//tに1文字のみ追加確認
	if (t[i] >= 'a' and t[i] <= 'z') {
		i++;
	}
	else flag = 1;

	if(flag==1){
		cout << "No" << "\n";
	}
	else {
		cout << "Yes" << "\n";
	}
}


Measured memory_bytes: 3640
#include <stdio.h>

const int MAX_H = 110, MAX_W = 110;
int H, W;

char field[MAX_H][MAX_W];

int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

bool infield(int h, int w){
    return (0<=h && h<H && 0<=w && w<W);
}

void dfs(int h, int w){
    //果物の定義
    char fruits = field[h][w];
    field[h][w] = '.';
    for(int i=0; i<4; i++){
        int nh = h+dh[i];
        int nw = w+dw[i];
        if(infield(nh, nw) && field[nh][nw]==fruits)
            dfs(nh, nw);
    }
}

void solve(){
    int ans = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            //更新された点は'.'にする
            if(field[i][j] != '.'){
                dfs(i, j);
                ans++;
            }
        }
    }
    printf("%d\n", ans);
}

int main(){
    
    while(scanf("%d%d", &H, &W), H|W){
        for(int i=0; i<H; i++)
            scanf("%s", field[i]);
        solve();
    }
    return 0;
}

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

int main() {
  int N=0;
  int K=0;
  int ans=0;
  cin >> N >> K;
  if(0==N%2) {
    ans = N/2;
  }
  else
  {
    ans = N/2 + 1;
  }
  if(ans<K){
    cout << "NO" << endl;
  }
  else {
    cout << "YES" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
int n;
long long a[110];
int main()
{
	scanf("%d",&n);
	a[0]=2;
	a[1]=1;
	for(int i=2;i<=n;i++)
	{
		a[i]=a[i-1]+a[i-2];
	}
	printf("%lld\n",a[n]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << a * b << "\n";
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

ll a[111111];
ll pref[111111];
ll suf[111111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n; a[0] = 0;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=0;i<=n-1;i++)
	{
		pref[i] = abs(a[i]-a[i+1]);
		if(i>0) pref[i] += pref[i-1];
	}
	for(int i=n-1;i>=0;i--)
	{
		suf[i] = abs(a[i]-a[i+1]);
		if(i<n-1) suf[i]+=suf[i+1];
	}
	for(int i=1;i<=n;i++)
	{
		ll ans = 0;
		if(i>1) ans+=pref[i-2];
		if(i<n) ans+=suf[i+1];
		if(i+1<=n) ans += abs(a[i-1] - a[i+1]);
		if(i==n) ans+=abs(a[i-1]);
		else ans+=abs(a[n]);
		cout<<ans<<'\n';
	}
}


Measured memory_bytes: 3584
w, h, n = gets.split.map(&:to_i)
points = n.times.map { gets.split.map(&:to_i) }

x1 = points.select{|x,y,a| a == 1 }.map{|x,_,_| x}.max || 0
x2 = points.select{|x,y,a| a == 2 }.map{|x,_,_| x}.min || w
y1 = points.select{|x,y,a| a == 3 }.map{|_,y,_| y}.max || 0
y2 = points.select{|x,y,a| a == 4 }.map{|_,y,_| y}.min || h
puts [x2-x1, 0].max * [y2-y1, 0].max

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

using namespace std;
bool e;
string s;
int a, b;
int main()
{
    cin >> a >> b;
    cin >> s;
    if (s[a] == '-') e = true;
    if (s[a] != '-') e = false;
    for (int i = 0; i < a; i++){
        if (s[i] == '-') e = false;
    }
    for (int i = a + 1; i < a+b+1; i++){
        if (s[i] == '-') e = false;
    }
    if (e == true) cout << "Yes";
    if (e == false) cout << "No";
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"runtime/pprof"
	"strconv"
)

func main() {
	f, err := os.Create("cpu.prof")
	if err != nil {
		log.Fatal("could not create CPU profile: ", err)
	}
	if err := pprof.StartCPUProfile(f); err != nil {
		log.Fatal("could not start CPU profile: ", err)
	}
	defer pprof.StopCPUProfile()

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

	result := 0
	bs := make([]int, N)
	for b := 0; b < 60; b++ {
		t := 0
		bs[N-1] = (A[N-1] >> uint(b)) & 1
		for i := N - 2; i > -1; i-- {
			a := (A[i] >> uint(b)) & 1
			bs[i] = bs[i+1] + a
			if a == 0 {
				t += bs[i+1]
			} else {
				t += (N - (i + 1)) - bs[i+1]
			}
		}
		t %= 1000000007
		B := (1 << uint(b)) % 1000000007
		result += (t * B) % 1000000007
		result %= 1000000007
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 13184
#include<cstdio>
using namespace std;
inline int read(){
	char ch=getchar();
	int x=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	return x;
}
int main(){
	bool f=0;
	int a=read();
	if(getchar()=='+') f=1;
	int b=read();
	if(f) printf("%d",a+b);
	else printf("%d",a-b);
	putchar('\n');
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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 gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,t,a,x,y;
	cin >> n >> x >> y;
	rep(i,n-1){
		cin >> t >> a;
		ll tmp=max((x+(t-1))/t,(y+(a-1))/a);
		x=t*tmp;
		y=a*tmp;
	}
	cout << x+y << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>

using namespace std;

#define MAX 102
int n;

vector<long long int> v;
int main() {
	cin >> n;
	long long int sum = 0;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		sum += a;
		v.push_back(a);
	}
	long long int cur = LLONG_MAX;
	int ans = -1;
	for (int i = 0; i < n; i++) {
		long long int dif = abs(v[i] * n - sum);
		if (cur > dif) {
			cur = dif;
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
function main(lines) {
  const [H, W] = na();
  const [Ch, Cw] = sa().map(v => v-1);
  const [Dh, Dw] = sa().map(v => v-1);
  const maze = getLines(H);
  
  let stack = [[Ch, Cw, 0]];
  let _stack = [];
  const done = Array(H).fill(0).map(_ => Array(W).fill(false));
  while (stack.length) {
    const [h, w, cost] = stack.pop();
    if (h == Dh && w == Dw) return cost;
    if (!done[h][w]) {
      done[h][w] = true;
      for (let _h = h-2; _h <= h+2; _h++) {
        if (!maze[_h]) continue;
        for (let _w = w-2; _w <= w+2; _w++) {
          if (maze[_h][_w] != '.' || done[_h][_w]) continue;
          if (Math.hypot(_h-h, _w-w) <= 1) {
            stack.push([_h, _w, cost]);
          } else {
            _stack.push([_h, _w, cost+1]);
          }
        }
      }
    }
    if (!stack.length) [stack, _stack] = [_stack, []];
  }
  return -1;
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);
const getLines = (n) => lines.slice(lineCount, lineCount += n);

const ans = main(lines);
console.log( ans );

Measured memory_bytes: 105264
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll d,t,s;
    cin >> d >> t >> s;
    if(t*s >= d)  cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3048
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long

int main() {
	int N, K; cin >> N >> K;
	cout << (K>1 ? N-K : 0) << endl;
	return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


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

    vector<int>s(n);
    rep(i,n)cin>>s[i];

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

    rep(i,s.size()-1){
        if(s[i]==s[i+1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }

    cout<<"YES"<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int func(int n){
  int ans = 0;
  while(n){
    ans+=n%10;
    n/=10;
  }
  return ans;
}

int main() {
  int N;
  cin >> N;
  if(N%func(N)==0)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
S = input()
dp = len(S)*[0]
dp[0] = int(S[0])

for i in range(1,len(S)):
    dp[i]=int(S[:i+1])+sum(dp[j-1]+int(S[j:i+1])*2**(j-1) for j in range(1,i+1))
    
print(dp[-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(void){
    // Your code here!
    int x,y;
    std::cin >> x >> y;
    int k = 0;
    if(x <= 3){
        k = k + (4 - x) * 100000;
    }
    if(y <= 3){
        k = k + (4 - y) * 100000;
    }
    if(x == 1 && y == 1){
        k = k + 400000;
    }
    std::cout << k << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>

using namespace std;

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

	int ans = 0;
	for (int i = a; i <= b; i++) {
		int x = 0;
		for (int j = 0; j < 5; j++) {
			int d = i / (int)pow(10, j) % 10;
			x += d * pow(10, 4 - j);


		}
		if (x == i) {
			ans++;
		}
		// printf("%5d %5d\n", i, x);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

vector<pair<ll, ll>> g[50000];
vector<ll> enumdiv(ll x) {
    vector<ll> res;
    for (ll i = 1; i * i <= x; i++) {
        if (x % i == 0) {
            res.emplace_back(i);
            if (i != x / i) res.emplace_back(x / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

void solve() {
    ll m, n; scanf("%lld %lld", &m, &n);
    ll t = m * m + n * n;
    auto d = enumdiv(t);
    for (auto e : d) {
        if (e == 1 or e == t) continue;
        if (g[e].size() > 0 and t / e != 1 and t /e != t) {
            for (auto p : g[e]) {
                for (auto q : g[t / e]) {
                    if (p.first * q.first - p.second * q.second == m and p.first * q.second + p.second * q.first == n) {
                        puts("C");
                        return;
                    }
                }
            }
        }
    }
    puts("P");
}

int main()
{
    /*
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    */
    {
        for (ll i = 0; i * i <= 20000; i++) {
            for (ll j = 0; i * i + j * j <= 20000; j++) {
                g[i * i + j * j].emplace_back(i, j);
                g[i * i + j * j].emplace_back(-i, j);
                g[i * i + j * j].emplace_back(i, -j);
                g[i * i + j * j].emplace_back(-i, -j);
            }
        }
    }
    int kkt; scanf("%d", &kkt);
    while (kkt--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5292
import heapq

def dijkstra(s, G):
    que = [(0, s)]
    d = [float("inf")]*len(G)
    d[s] = 0
    while que:
        c, v = heapq.heappop(que)
        if d[v] > c: continue
        for to, cost in G[v]:
            if d[to] > d[v] + cost:
                d[to] = d[v] + cost
                heapq.heappush(que, (d[to], to))
    return d

n, m, s, t = map(int, raw_input().split())
s, t = s - 1, t - 1 
G0, G1 = [[] for i in xrange(n)], [[] for i in xrange(n)]
for i in range(m):
    ui, vi, ai, bi = map(int, raw_input().split())
    ui, vi = ui - 1, vi - 1
    G0[ui].append((vi, ai))
    G0[vi].append((ui, ai))
    G1[ui].append((vi, bi))
    G1[vi].append((ui, bi))

d0 = dijkstra(s, G0)
d1 = dijkstra(t, G1)

yen = 10**15
ans = [float("inf")]*(n + 1)
for i in xrange(n - 1, -1, -1):
    ans[i] = min(ans[i + 1], d0[i] + d1[i])

for i in xrange(n):
    print yen - ans[i]



Measured memory_bytes: 83356
import java.io.*
import java.util.*

fun solve(S: String){
    println((0..S.length-3).map{ Math.abs(S.slice(it..it+2).toInt() - 753) }.min())
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val S = sc.next()
    solve(S)
}



Measured memory_bytes: 29828
#include<stdio.h>
int main(void)
{
	int n;
	int i;
	int pm,pe,pj;
	
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d %d",&pm,&pe,&pj);
			if(pm==100 || pe==100 || pj==100){
				printf("A\n");
			}
			else if((pm+pe)/2>=90){
				printf("A\n");
			}
			else if((pm+pe+pj)/3>=80){
				printf("A\n");
			}
			else if((pm+pe+pj)/3>=70){
				printf("B\n");
			}
			else if((pm+pe+pj)/3>=50 && pm>=80 || pe>=80){
				printf("B\n");
			}
			else{
				printf("C\n");
			}
		}
	scanf("%d",&n);
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

const double PI { acos(-1.0) };

double solve(long double A, long double B, long double X)
{
    long double a = 0.0, b = 90.0, ans = 90.0;
    int iterations = 100;

    while (iterations--)
    {
        auto m = (a + b)/2.0;
        auto alpha = (m * PI)/180.0;
        auto beta = PI/2.0 - alpha;

        auto b2 = B*cos(beta);
        auto h2 = B*sin(beta);
        auto total = b2*h2/2.0;

        auto x = h2/sin(alpha);

#ifdef DEBUG
    cout << "=== m = " << m << ", total = " << total << ", x = " << endl << endl;
#endif
        if (x <= A)
        {
            auto b1 = x*cos(alpha);
            auto h1 = h2;

            total += b1*h1/2.0; 

#ifdef DEBUG
    cout << "+++ area = " << (b1*h1/2.0) << ", total = " << total << endl;
#endif
        } else
        {
            auto b1 = A*cos(alpha);
            auto h1 = A*sin(alpha);
            auto b2 = h1*cos(beta)/sin(beta);

            auto At = b1*h1/2.0 + b2*h1/2.0;
            total = At + (b1 + b2)*(h2 - h1);

#ifdef DEBUG
    cout << "--- area = " << (b1*h1/2.0 + b2*h1/2.0) << ", total = " << total << endl;
#endif
        }

        if (A*total < X)
            b = m;
        else
            ans = a = m;
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int a, b, x;
    cin >> a >> b >> x;

    auto ans = solve(a, b, x);

    cout << setprecision(10) << fixed << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))

A = []
ans = 0
for i in range(N-1):
    if i == 0:
        A.append(B[i])
        continue
    if B[i] >= B[i-1]:
        A.append(B[i-1])
    else:
        A.append(B[i])
A.append(B[N-2])
for i in range(N):
    ans += A[i]

print(ans)

Measured memory_bytes: 9080
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#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<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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 P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe





vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}
int main(void){ios::sync_with_stdio(false);cin.tie(0);
///////////////////////////////////////////////////////
// vector<int> v=enum_div(2n-1);
// rep(i,v.size())cout<<v[i]<<"";
// cout<<endl;
int ans=0,n;
cin >> n;
for(int i=1;i<=n;i+=2){
    vector<int> v=enum_div(i);

    if(v.size()+1==8){
    ans++;
    } 
}
cout << ans << endl;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];

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

    ll ans = 0;
    rep(i, n) {
        REP(j, i + 1, n) {
            int k = lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();
            ans += max(k - j - 1, 0);
        }
    }

    cout << ans << endl;

    return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    string d[] = {
        "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

    string S;
    cin >> S;

    int idx;
    for (idx = 0; idx < 7; idx++) {
        if (S == d[idx]) break;
    }

    cout << 7 - idx << endl;

    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 std;
using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long 
// #define int ll
//#define slld(t) scanf("%lld",&t)
// #define sd(t) scanf("%d",&t)
// #define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define pdd pair<double , double>
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N    200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
#define s3   1.73205080757          // square root 3
const  int inf = (int)1e18+10 ;
const int MAX= 100;

 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set S;

int powmod(int x , int y){
	int res = 1;
	while(y > 0){
		if(y%2==1)
			res = (res*x)%mod;
		x = (x*x)%mod;
		y/=2;
	}
	return res;
}
int mul(int x , int y){
	return (x*y)%mod;
}

signed main(){
  fast;
  
 int n;
 string s;
 cin >> s;
 n = s.length();
 int ans = 0;
 for(int i = 0 ; i < n/2 ; i++){
 	   if(s[i]  != s[n-1-i]) ans++;
 }
 cout << ans << endl;
 }

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

int main() {
  int A,B,C,D,L,R;
  cin>>A>>B>>C>>D;
  L=A+B,R=C+D;
  if (L>R){cout<<"Left"<<endl;}
  else if(L<R){cout<<"Right"<<endl;}
  else {cout<<"Balanced"<<endl;}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <functional>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
using namespace std;
#define		ll		long long
#define		ull		unsigned long long
#define		vi		vector<int>
#define 	vll		vector<long long>
#define		pii		pair<int,int>
#define		pll		pair<long long,long long>
#define		mii		map<int,int>
#define		mll		map<long long,long long>
#define		PB		push_back
#define		MP		make_pair
#define 	ff		first
#define		ss		second
#define		IT		iterator
#define		IOS		ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define		DB		cout<<"DEBUG "
#define		CS		<<" "<<
#define		LB		cout<<"\n"
#define		endl	"\n"

int n;
int rs=0,re,pv,mid,pp;
string s;

int parse(string s){ return s=="Male"; }

int main(){

	cin >> n;
	re = n-1;
	mid = (rs+re)/2;
	cout << 0 << endl << flush;
	cin >> s;
	if(s=="Vacant") return 0;
	pv = parse(s);
	cout << mid << endl << flush;
	pp = rs;

	while(cin >> s && s != "Vacant"){


		if((mid-pp)%2==0){
			if(parse(s)==pv){
				if(pp==rs) rs = mid;
				else re = mid;
			}
			else{
				if(pp==rs) re = mid;
				else rs = mid;
			}
		} else{
			if(parse(s)==pv){
				if(pp==rs) re = mid;
				else rs = mid;
			}
			else{
				if(pp==rs) rs = mid;
				else re = mid;
			}
		}

		//cout << rs << "~" << re << endl;

		pp = mid;
		pv = parse(s);
		mid = (rs+re)/2;
		if(re-rs==1 && re==n-1) cout << n-1 << endl << flush;
		else cout << mid << endl << flush;


	}

}

Measured memory_bytes: 852