akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  (B) <= (A) && (A) <= (C)
#define AIN(A, B, C) assert(IN(A, B, C))
void solve(){
     cout<<fixed<<setprecision(10);
     double x;
     cin>>x;
     x=2*(3.14000)*x;
     cout<<x;
}
int main() {
    ios;
	int t=1;
	//cin>>t;
	while(t--)solve();
 
    
}


Measured memory_bytes: 3800
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		// 計算
		int result = -1;
		if(a <= 9 && b <= 9) result = a * b;
		
		// 出力
		System.out.println(result);
		
	}
}

Measured memory_bytes: 23764
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>



using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  string s,ss;
  cin >> s;
  int q;
  scanf("%d", &q);
  int cnt = 0;
  rep(i,q){
    int a;
    scanf("%d", &a);
    if(a%2){
      cnt++;
      continue;
    }else{
      int f;
      scanf("%d", &f);
      string m;
      cin >> m;
      if((f+cnt)%2){
        ss += m;
      }else{
        s += m;
      }
    }
  }
  if(cnt%2){
    for(int i = s.size()-1;i>=0;i--)cout << s.at(i);
    rep(i,ss.size())cout << ss.at(i);
    cout << endl;
    return 0;
  }else{
    for(int i = ss.size()-1;i >=0;i--)cout << ss.at(i);
    cout << s << endl;
  }
}


Measured memory_bytes: 964
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define int long long
#define ll long long
#define moder 1000000007
#define INF LLONG_MAX/3
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;

int n;
signed main(){
	cin>>n;
	for(int i=1;i<=3500;i++){
		for(int j=1;j<=3500;j++){
			if(4*i*j-n*i-n*j<=0)continue;
			if((n*i*j)%(4*i*j-n*i-n*j)==0){
				cout<<i<<" "<<j<<" "<<(n*i*j)/(4*i*j-n*i-n*j)<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
void check(int a[14][14],int i,int j){
	a[i][j]=0;
	if(a[i][j+1]==1)check(a,i,j+1);
	if(a[i][j-1]==1)check(a,i,j-1);
	if(a[i+1][j]==1)check(a,i+1,j);
	if(a[i-1][j]==1)check(a,i-1,j);
}
int main(void){
	int a[14][14],i,j,ans;
	for(i=0;i<14;i++){for(j=0;j<14;j++){a[i][j]=0;}}
	while(1){
		for(i=1;i<13;i++){
			for(j=1;j<13;j++){
				if(scanf("%1d",&a[i][j])==EOF)return 0;
			}
		}
		ans=0;
		for(i=1;i<13;i++){
			for(j=1;j<13;j++){
				if(a[i][j]==1){ans++;check(a,i,j);}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

int main()
{
    string A, B;
    cin >> A;
    cin >> B;

    if ( A.size() == B.size())
    {
        for(long i = 0; i < A.size(); i++)
        {
            if (A[i] > B[i]) 
            {
                cout << "GREATER" << endl;
                break;
            }
            else if (A[i] < B[i])
            {
                cout << "LESS" << endl;
                break;
            }
            
            if(i == A.size()-1)
            {
                cout << "EQUAL" << endl;
            }
        }
        
    }
    else if ( A.size() > B.size())
    {
        cout << "GREATER" << endl;
    }
    else
    {
        cout << "LESS" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC103 A - Task Scheduling Problem
// 2020.06.12

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> A(3, 0);
  REP(i, 3){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int ans = A[2]-A[0];
  cout << ans << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $c);
if ($a % 2 == 0 && $a == $b && $b == $c) exit('-1');
$x = 0;
while ($a % 2 + $b % 2 + $c % 2 == 0) {
	$a /= 2;
	$b /= 2;
	$c /= 2;
	list($a, $b, $c) = [$b + $c, $a + $c, $a + $b];
	if (++$x > 64) exit('-1');
}
echo $x;

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

#define ll long long

using namespace std;



int main(){
    string S;
    int ans = 0;
    cin >> S;
    if(S == "SUN") ans = 7;
    else if (S == "MON") ans = 6;
    else if(S == "TUE") ans = 5;
    else if(S == "WED") ans = 4;
    else if(S == "THU") ans = 3;
    else if(S == "FRI") ans = 2;
    else ans = 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
string s;
void input(){
  cin>>s;
}
bool judge(int i){
  return s[i]==s[i-1];
}
int main(){
  input();
  int n=(int)s.length();
  int ans=1;
  int sum=0;
  int buf=0;
  int i=1;
  while(i<n){
    int tmp=i;
      if(tmp==n-1){
      if(judge(tmp) && buf==0)
      ans--;
    }

    if(judge(i) && buf==0){
      i++;
      ans++;
      buf=1;
    }
    else{
      ans++;
      buf=0;
    }
    i++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
S_input = input()
T_input= input()

S = [str(i) for i in S_input]
T = [str(i) for i in T_input]

flag = 0

for i in range(len(S)):
    if S == T:
        flag = 1
        break
    else:
        tar = S[0]
        for j in range(len(S)-1):
            S[j] = S[j+1]
        S[-1] = tar
if flag == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		int h = in.nextInt();
		int w = in.nextInt();
		String[] a = new String[h];
		for (int i = 0; i < h; i++) {
			a[i] = in.next();
		}

		boolean[] row = new boolean[h];
		Arrays.fill(row, false);
		boolean[] col = new boolean[w];
		Arrays.fill(col, false);
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (a[i].charAt(j) == '#') {
					row[i] = true;
					col[j] = true;
				}
			}
		}

		for (int i = 0; i < h; i++) {
			if (row[i]) {
				for (int j = 0; j < w; j++) {
					if (col[j]) {
						System.out.print(a[i].charAt(j));
					}
				}
				System.out.println();
			}
		}
	}
}


Measured memory_bytes: 24788
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Mon Dec 24 16:20:10 2018
//
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	ans := 0
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		for a%2 == 0 {
			a /= 2
			ans++
		}
	}
	fmt.Println(ans)
}


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

const int MAXN = 300005;

int a[MAXN], n;

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n*3; i++) scanf("%d", &a[i]);
	sort(a+1, a+n*3+1);
	long long ans = 0;
	for (int i = 1, pos = n*3-1; i <= n; i++, pos -= 2)
		ans += a[pos];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
n = int(input())

p_list = [int(p) for p in input().split()]

c = 0
for i in range(1,n-1):
    p_1 = p_list[i-1]
    p_2 = p_list[i]
    p_3 = p_list[i+1]

    #print(i,c)
    if (p_1 <= p_2 <= p_3) or (p_3 <= p_2 <= p_1):
        c += 1
        #print(i,c)                                                                      

print(c)

Measured memory_bytes: 3060
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi

MOD = 10 ** 9 + 7
SIZE = 10 ** 6

N, P = map(int, input().split())
S = input()

answer = 0
if P == 2 or P == 5:
    for i, s in enumerate(S):
        if int(s) % P == 0:
            answer += i + 1
else:
    S = S[::-1]
    cnt = defaultdict(int)
    tmp = 0
    for i, s in enumerate(S):
        tmp += int(s) * pow(10, i, P)
        if tmp % P == 0:
            answer += 1
        answer += cnt[tmp % P]
        cnt[tmp % P] += 1

print(answer)

Measured memory_bytes: 43768
def f(n):
	if n == 0:
		return '0'
	r = []

	while(n):
		if n % 2:
			r.append(1)
		else:
			r.append(0)
		n = (n-r[-1])/-2
	return ''.join(map(str,r[::-1]))
print f(int(raw_input()))

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

#define pb push_back
#define pbk pop_back
#define mk_pr make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<string> vss;
typedef queue<int> qi;

const int MX = 123456;
ll ar[MX];

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

        ll n, a, b;
        cin >> n >> a >> b;
        for(int i=0; i<n; i++) cin >> ar[i];

        ll lo=0, hi=1e9, mid;

        while( lo <= hi ) {
                mid = lo + (hi-lo)/2;

                ll cnt = 0;
                for(int i=0; i<n; i++) {
                        ll rst = max( 0LL, ar[i] - b*mid );
                        cnt += rst/(a-b);
                        if( rst%(a-b) ) cnt++;
                 }

                if( cnt <= mid ) hi = mid-1;
                else lo = mid+1;
        }

        cout << lo << endl;

        return 0;
}


Measured memory_bytes: 1024
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

r,g,b,n=MI()
count=0
for i in range(n//r+1):
    for j in range((n-r*i)//g+1):
        #print(i,j,n-r*i-g*j)
        if n-r*i-g*j>=0 and (n-r*i-g*j)%b==0:
            count+=1
print(count)

Measured memory_bytes: 70728
fun main(arg: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    val L = java.util.LinkedList<Int>()
    var rev = false
    A.forEach { a ->
        if (rev) L.addFirst(a) else L.addLast(a)
        rev = !rev
    }
    val ans = if (rev) L.asIterable().reversed() else L.asIterable().toList()
    println(ans.joinToString(" "))
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 100000
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	string s;
	getline(cin,s);
	
	bool flag = true;
	
	if( s[0] != 'A' ) flag = false;
	
	int cnt = 0;
	int cntL = 0;
	for(int i=2; i < s.size()-1; ++i){
		if(s[i] == 'C'){
			cnt++;
		}
	}
	
	for(int i=0; i < s.size(); ++i){
		if('A' <= s[i] && s[i] <= 'Z' ){
			cntL++;
		}
	}
	if(cnt != 1) flag = false;
	if(cntL != 2) flag = false;
	
	if(flag) cout << "AC" << endl;
	else  cout << "WA" << endl;
	

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int *A;
char **zeroone;

void makezeroone(int loop, int n){
  int i, j, num;

  zeroone = (char **)malloc(sizeof(char *) * loop);
  for(i=0; i<loop; i++){
    zeroone[i] = (char *)malloc(sizeof(char) * n);
  }

  for(i=0; i<loop; i++){
    num = i;
    for(j=n-1; 0<=j; j--){
      zeroone[i][j] = num % 2;
      num /= 2;
    }
  }
}

int isMake(int loop, int n, int m){
  int i, j, sum;
  for(i=0; i<loop; i++){
    sum = 0;
    for(j=0; j<n; j++){
      // printf("A[%d] %d  zeroone[%d][%d] %d\n",j,A[j], i,j,zeroone[i][j]);
      sum += A[j] * (int)zeroone[i][j];
      // printf("sum %d\n",sum);
      //if(sum > m) return 0;
      if(sum == m) return 1;
    }
    // printf("\n");
  }
  return 0;
}

int main(){
  int n, q, m;
  int i, j, sum, loop=1;

// get data
  scanf("%d",&n);
  A = (int *)malloc(sizeof(int) * n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
    loop *= 2;
  }

  makezeroone(loop, n);

  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&m);
// printf("-----%d-----\n",m);
    if(isMake(loop, n, m)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}



Measured memory_bytes: 42580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
//PDが多いほうがいい
//PならD
int main(){
  string t;
  cin >> t;

  char last = 'P';
  for(int i=0;i<t.size();i++){
    if(t[i]=='?'){
      if(last=='P')t[i]='D';
      else t[i]='P';
      if(i==t.size()-1)t[i]='D';
      else if(t[i+1]=='P')t[i]='D';
    }
    last = t[i];
  }
  
  cout << t;
  return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) {
        int n, m;
        cin >> n >> m;
        if(n == 0 && m == 0) {
            break;
        }
        vector<int> a(n);
        for(int i = 0; i < n; i++) {
            cin >> a[i];
        }
        int ans = -INF;
        for(int i = 0; i < n; i++) {
            for(int j = i + 1; j < n; j++) {
                int tmp = a[i] + a[j];
                if(tmp <= m) {
                    chmax(ans, tmp);
                }
            }
        }
        if(ans == -INF) {
            cout << "NONE" << endl;
        } else {
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 400 + 10;
int n; 
ll ans;
ll a[maxn][4], b[maxn][4], tmp[4];
map<ll, int> M;
void solve(int x, int y, int z)
{
	ll ret = 1;
	vector<ll> res;
	for(int i = 0; i < 4; ++i) --M[b[x][i]], res.push_back(b[x][i]);
	for(int i = 0; i < 4; ++i) --M[b[y][i]], res.push_back(b[y][i]);
	for(int i = 0; i < 4; ++i)
	{
		tmp[0] = a[x][(i + 1) % 4]; tmp[1] = a[x][i]; tmp[2] = a[y][(3 - i + z) % 4]; tmp[3] = a[y][(6 - i + z) % 4]; 
		ll id = 0; for(int j = 0; j < 4; ++j) id = id * 1000 + tmp[j];
		if(M[id] == 0) 
		{
			ret = 0;
			break;
		}
		ret = ret * M[id];
		for(int j = 0; j < 4; ++j)
		{
			id = 0;
			for(int k = 0; k < 4; ++k)
				id = id * 1000 + tmp[(j + k) % 4];
			--M[id], res.push_back(id);
		}
	}
	ans += ret;
	for(auto v : res) ++M[v];
}
int main()
{
	cin >> n;
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 0; j < 4; ++j)
			cin >> a[i][j];
		for(int j = 0; j < 4; ++j)
		{
			for(int k = 0; k < 4; ++k)
				b[i][j] = b[i][j] * 1000 + a[i][(j + k) % 4];
			M[b[i][j]]++;
		}
	}
	for(int i = 1; i <= n; ++i)
		for(int j = i + 1; j <= n; ++j)
			for(int k = 0; k < 4; ++k)
				solve(i, j, k);
	ans /= 3;
	cout << ans << endl;
	return 0;
}
	
	

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

int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

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

    return a;
}

int main(void){
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> a(n), b(m);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < m; i++) cin >> b[i];
    sort(a.begin(), a.end(), greater<int>());
    sort(b.begin(), b.end());

    if(a[0] > b[0]){
        cout << "War" << endl;
    }
    else{
        bool war = true;
        for(int i = a[0] + 1; i <= b[0]; i++){
            if(x < i && i <= y) war = false; 
        }
        if(war) cout << "War" << endl;
        else cout << "No War" << endl;
    }
    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a, b, c, d, e, f;
  while(scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f) != EOF){
    double ans1 = (double)(e*c-b*f)/(double)(a*e-b*d);
    double ans2 = (double)(-d*c+a*f)/(double)(a*e-b*d);
    if (ans1 == 0) ans1 = 0;
    if (ans2 == 0) ans2 = 0;
    printf("%.3lf %.3lf\n", ans1, ans2);
  }
  return 0;
}

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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var ans = 0;
            var st = new List<string[]>();
            for (int i = 0; i < N; i++)
            {
                st.Add(Read().Split(' '));
                ans += int.Parse(st[i][1]);
            }
            var X = Read();
            for (int i = 0; i < N; i++)
            {
                ans -= int.Parse(st[i][1]);
                if (st[i][0] == X) break;
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>

using namespace std;
#define PI 3.14159265359



int main()
{
    int N, ans = 0;
    cin >> N;

    for(int i = 1; i <= N; i++){
        int temp = i;
        int count = 0;
        while(1){
            temp /= 10;
            count++;
            if(temp == 0) break;
        }
        if(count % 2 == 1) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int H, W; vector<string> s;
int main() {
	ios::sync_with_stdio(false);
	cin >> H >> W; s.resize(H);
	for (int i = 0; i < H; i++) cin >> s[i];
	vector<pair<int, int> > v;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '.' || s[i][j] == '9') continue;
			int cnt = 0;
			for (int k = -1; k <= 1; k++) {
				for (int l = -1; l <= 1; l++) {
					int tx = j + l, ty = i + k;
					if (0 <= tx && tx < W && 0 <= ty && ty < H && s[ty][tx] == '.') cnt++;
				}
			}
			if (cnt >= s[i][j] - 48) v.push_back(make_pair(j, i));
		}
	}
	int ret = 0;
	for (; !v.empty(); ret++) {
		for (pair<int, int> i : v) s[i.second][i.first] = '.';
		vector<pair<int, int> > w;
		for (pair<int, int> i : v) {
			int sx = i.first, sy = i.second;
			for (int j = -1; j <= 1; j++) {
				for (int k = -1; k <= 1; k++) {
					int tx = sx + k, ty = sy + j;
					if (!(0 <= tx && tx < W && 0 <= ty && ty < H)) continue;
					if (s[ty][tx] == '.' || s[ty][tx] == '9') continue;
					int cnt = 0;
					for (int l = -1; l <= 1; l++) {
						for (int m = -1; m <= 1; m++) {
							int ux = tx + m, uy = ty + l;
							if (0 <= ux && ux < W && 0 <= uy && uy < H && s[uy][ux] == '.') cnt++;
						}
					}
					if (cnt >= s[ty][tx] - 48) w.push_back(make_pair(tx, ty));
				}
			}
		}
		sort(w.begin(), w.end());
		w.resize(unique(w.begin(), w.end()) - w.begin());
		v = w;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 4084
#include <iostream>
using namespace std;
int q, n, m, v[111]; double p[111], r[12];
int main() {
	cin >> q;
	for (int i = 0; i <= q; i++) {
		cin >> n >> m;
		double sum = 0.0;
		for (int j = 0; j < m; j++) cin >> v[j] >> p[j], sum += p[j];
		for (int j = 0; j < m; j++) r[i] += v[j] * p[j] / sum;
	}
	bool flag = false;
	for (int i = 0; i < q; i++) if (r[i] > r[q] + 0.0000001) flag = true;
	cout << (flag ? "YES" : "NO") << endl;
	return 0;
}

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

vector<string> split(string str, set<char> st) {
  vector<string> v;
  string s = "";
  for(int i = 0; i < str.size(); ++i) {
    if(st.find(str[i]) != st.end()) {
      if(s.size()) v.push_back(s);
      s = "";
    } else {
      s += str[i];
    }
  }
  if(s.size()) v.push_back(s);
  return v;
}
string line;
set<char> s1, s2;


bool isTrue(string s) {
  vector<string> v = split(s, s2);
  int d[3];
  for(int i = 0; i < 3; ++i) {
    if(v[i].size() == 1) d[i] = v[i][0];
    else                 d[i] = -v[i][1];
  }
  for(int i = 0; i < 3; ++i) {
    if(d[i] + d[(i+1)%3] == 0) return false;
  }
  return true;
}

string solve() {
  vector<string> v = split(line, s1);
  for(int i = 0; i < v.size(); ++i) {
    if(isTrue(v[i])) return "yes";
  }
  return "no";
}

int main() {
  s1.insert('(');
  s1.insert(')');
  s1.insert('|');
  s2.insert('&');
  while(getline(cin, line) && line != "#") {
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut ans = "APPROVED";
    for _ in 0..n {
        let x:usize = read();
        if x % 2 != 0 {
            continue;
        }
        if x % 3 != 0 && x % 5 != 0 {
            ans = "DENIED";
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2136
_, t, *L = map(int, open(0).read().split())
d = [0] * (t + max(L[::2]))
for w, v in sorted((x, y) for x, y in zip(*[iter(L)] * 2)):
	for i in range(t + w - 1, w - 1, -1):
		if d[i - w] + v > d[i]:
			d[i] = d[i - w] + v
print(max(d))


Measured memory_bytes: 42860
#include<iostream>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n,q; cin >>n >>q;
  
  dsu g(n);
  rep(_,q){
    int t,u,v; cin >>t >>u >>v;
    if(t==0) g.merge(u,v);
    else print(g.same(u,v));
  }
  
}


Measured memory_bytes: 4012
using static System.Console;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine().Split().Select(x=>int.Parse(x)).ToArray();
        int k = str[0], s = str[1];
        var cnt = 0;
        for(var x = k;x>=0;x--)
        {
            for(var y = k; y >= 0; y--)
            {
                var z = s - x - y;
                if (z >= 0 && z <= k) cnt++;
            }
        }
        WriteLine(cnt);                    
    }
}

Measured memory_bytes: 2904
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 100000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}


bool vis[100000+10];
int main()
{
  int n;
  cin>>n;
  string s,pat;
  cin>>s;
  pat="ABC";
  int cnt=0;
  for(int i=0;i<=s.size()-pat.size();i++)
  {

      if(s[i]==pat[0])
      {
         int f=0;
         for(int j=0;j<3;j++)
         {
             if(s[i+j]!=pat[j]) f=1;
         }
         if(f==0) cnt++;
      }
  }
  cout<<cnt<<endl;



}

















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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0)
#define int long long int
#define endl "\n"
#define N 200009
#define all(a) a.begin(), a.end()

int n;
int a[N];
int nxt[N];

int32_t main()
{
	IOS;
	cin>>n;

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

	int ans = 0;

	int prev = 0;

	for(int i=1;i<n;i++)
	{
		if(a[i]<=a[i-1])
		{
			ans = max(ans ,  i - prev);
		}
		else
		{
			prev = i;
		}
		
	}

	cout<<ans<<endl;


}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> int3;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int X, Y, Z, K;
ll A[1000], B[1000], C[1000];

int main() {
	cin >> X >> Y >> Z >> K;
	REP(i, X) scanf("%lld", A + i);
	REP(i, Y) scanf("%lld", B + i);
	REP(i, Z) scanf("%lld", C + i);
	
	sort(A, A + X, greater<ll>());
	sort(B, B + Y, greater<ll>());
	sort(C, C + Z, greater<ll>());
	
	vector<ll> v;
	REP(i, X) {
		REP(j, Y) {
			REP(k, Z) {
				if (i * j * k < 100000) v.push_back(A[i] + B[j] + C[k]);
			}
		}
	}
	sort(ALL(v), greater<ll>());
	
	REP(i, K) printf("%lld\n", v[i]);
	
	
	return 0;
}


Measured memory_bytes: 67808
N = int(input())
a_list = list(map(int, input().split()))

dp = [[[0]*(N+2) for _ in range(N+2)] for _ in range(N+2)]

cnt = {1:0, 2:0, 3:0}
for a in a_list:
    cnt[a] += 1

for i in range(N+1):
    for j in range(N+1):
        for k in range(N+1):
            if i==0 and j==0 and k==0:
                continue
            dp[i][j][k] += (N/(i+j+k))
            if k >= 1:
                dp[i][j][k] += dp[i][j][k-1] * (k/(i+j+k))
            if j >= 1:
                dp[i][j][k] += dp[i][j-1][k+1] * (j/(i+j+k))
            if i >= 1:
                dp[i][j][k] += dp[i-1][j+1][k] * (i/(i+j+k))
print(dp[cnt[3]][cnt[2]][cnt[1]])

Measured memory_bytes: 440660
#!/usr/bin/env ruby
x, n = gets.chomp.split(" ").map(&:to_i)
p = gets.chomp.split(" ").map(&:to_i)

p = p.sort

ans = 0

if p.empty?
  puts x
else
  0.upto(101) do |i|
    next if p.include?(i)

    if (x - i).abs < (x - ans).abs
      ans = i
    elsif (x - i).abs == (x - ans).abs && i < ans
      ans = i
    end
  end
  puts ans
end



Measured memory_bytes: 14344
#include<stdio.h>

int main(void){
	int f = 0, s = 0, t = 0, temp, i;

	for (i = 0; i < 10; i++) {
		scanf("%d", &temp);
		
		if ( temp >= f ) {
			t = s;
			s = f;
  			f = temp;
		} else if ( temp < f && temp >= s ) {
			t = s;
			s = temp;
		} else if ( temp < s && temp >= t ) {
			t = temp;
		}
	}	

	printf("%d\n%d\n%d\n", f, s, t);

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
using namespace std;


#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef pair<int, int> Edge;

vector<long long int> divi;


int main() {
	vector<pair<long long int,long long int> > pairs;
	long long int n, m,a,b;
	cin >> n >> m;
	for (long long int i = 0; i < n; i++) {
		cin >> a >> b;
		pairs.push_back(make_pair(a, b));
	}
	sort(pairs.begin(), pairs.end());
	long long int j = 0,count=0;
	while (m > 0) {
		if (pairs[j].second > m) {
			count += pairs[j].first*m;
			break;
		}
		else {
			m -= pairs[j].second;
			count += pairs[j].first*pairs[j].second;
		}
		j++;
	}
	cout << count << endl;
}


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

int main(){

  while(1){
  stack <char> stk[2];
  string str;
  for(int i=0;i<2;i++){
    cin>>str;
    if(str=="-")return 0;
    for(int j=str.size()-1;j>=0;j--) stk[i].push(str[j]);
  }
  cin>>str;

  string ans;
  int idx=1,i=0;
  while(i!=(int)str.size()){
    char ima=stk[idx].top();stk[idx].pop();
    if(str[i]==ima){
      if(idx==1) idx=0;
      i++;
    }
    else{
      ans+=ima;
      if(idx==0) idx=1;
    }
  }
  for(int i=0;i<2;i++)
    while(!stk[i].empty()) ans+=stk[i].top(),stk[i].pop();

   cout <<ans<<endl;

  }
  return 0;
}

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


namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] n_x = sc.intarr;
            int n = n_x[0];
            int x = n_x[1];
            int[] ms = new int[n];

            for(int i=0; i<n; i++)
            {
                ms[i] = sc.intarr[0];
            }

            Array.Sort(ms);

            for(int i=0; i<n; i++)
            {
                x -= ms[i];
            }
            int ex = 0;
            while(ex * ms[0] <= x-ms[0])
            {
                ex++;
            }
            wr.wri(n + ex);
        }
    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    vector<int> a(4);
    cin >> a;
    sort(ALL(a));
    vector<int> b = {1, 4, 7, 9};
    cout << (a == b ? "YES" : "NO") << endl;
    return (0^_^0);
}



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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define forup(i,a,b) for(int i=(a); i<(b); ++i)
#define fordn(i,a,b) for(int i=(a); i>(b); --i)
#define rep(i,a) for(int i=0; i<(a); ++i)

#define gi(x) scanf("%d",&x)
#define gl(x) cin>>x
#define gd(x) scanf("%lf",&x)
#define gs(x) scanf(" %s",x)

#define D(x) cout << #x << " : " << x << endl;

#define fs first
#define sc second

#define pb push_back
#define mp make_pair

const int inf=numeric_limits<int>::max();
const LL linf=numeric_limits<LL>::max();

const int max_n=110, max_k=100010, first=0, second=1;

int n, k, a[max_n], dp[max_k];

int f(int cnt){
    if(cnt <= 0) return false;
    if(dp[cnt]!=-1){
        return dp[cnt];
    }

    dp[cnt] = -1;
    rep(i,n){
        if(cnt<a[i]) continue;
        if(!f(cnt-a[i])) dp[cnt] = true;
    }
    if(dp[cnt]==-1) dp[cnt] = false;
    return dp[cnt];
}

int main() {
    int mn = inf;
    gi(n);gi(k);
    memset(dp,-1,sizeof dp);
    rep(i,n){
        gl(a[i]);
        mn = min(a[i], mn);
    }
    rep(i,n){
        dp[a[i]] = true;
    }
    rep(i,mn){
        dp[i]= false;
    }
    f(k);
    cout << (f(k)?"First":"Second") << endl;
    return 0;
}

Measured memory_bytes: 5376
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

fn solve() {
	let n = read!(i64);
	let mut sum = 0;
	for i in 1..(n+1) {
		if i%3==0 || i%5==0 {
			continue;
		}
		sum += i;
	}
	println!("{}", sum);
}

fn run() {
    solve();
}


Measured memory_bytes: 2212
#X:座標
#K：試行回数
#D：移動距離

X,K,D=map(int,input().split())
b=0
Xabs=abs(X)
J=Xabs%D
N=Xabs//D

if N>K:
    b=Xabs-K*D

else:
    if (K-N)%2==0 :
        b=J
   
    #取れる数字はXをKで割った時のあまり(J)or(K-J)
    #残りは試行回数でどうなるか
    
    else:
        b=D-J
        

print(b)

Measured memory_bytes: 9080
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N;
	cin >> N;
	vector<int> T(N),V(N);
	for(int i=0;i<N;i++) cin >> T[i];
	for(int i=0;i<N;i++) cin >> V[i];
	
	vector<int> H(N+1);
	int Inf = (int) 1e9;
	for(int i=1;i<N;i++) H[i] = Inf;
	for(int i=0;i<N;i++){
		H[i] = min(H[i], V[i]);
		H[i+1] = min(H[i+1], V[i]);
	}
	for(int i=0;i<N;i++){
		int tt = 0;
		for(int j=i;j<N;j++){
			tt += T[j];
			H[j + 1] = min(H[j + 1], H[i] + tt);
		}
	}
	for(int i=N;i>0;i--){
		int tt = 0;
		for(int j=i;j>0;j--){
			tt += T[j-1];
			H[j - 1] = min(H[j - 1], H[i] + tt); 
		}
	}
	
//for(int i=0;i<N+1;i++) cout << H[i] << " "; cout << endl;	
	double tot = 0;
	for(int i=0;i<N;i++){
		int l = V[i] - H[i];
		int r = V[i] - H[i + 1];
		if(l + r > T[i]){
			double t0 = -1.0 * (double) (H[i] - T[i] - H[i+1]) / 2.0;
			tot += t0 * (H[i] + H[i] + t0) / 2.0;
			tot += (T[i] - t0) * (H[i + 1] + H[i + 1] + (T[i] - t0)) / 2.0;
		} else {
			tot += V[i] * (T[i] - l - r);
			tot += (double) l * (H[i] + H[i] + l) / 2.0;
			tot += (double) r * (H[i + 1] + H[i + 1] + r) / 2.0;
		}
//cout << "tot: " << tot << endl;
	}
	
	//cout << tot << endl;
	printf("%.12f\n", tot);
	
    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long n, a, b;
  cin >> n >> a >> b;
  long long res = n / (a + b) * a;
  n %= a + b;
  res += min(n, a);
  cout << res << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,i,x,sum=0;
	cin>>a>>b>>x;
	if(a%x==0)
	{
		sum++;
	}
	sum=sum+b/x-a/x;
	cout<<sum;
	return 0;
 } 

Measured memory_bytes: 256
n = int(input())
lst = list(map(int,input().split()))
ans = []
some = 0
for i in range(n):
    some += lst[i]*(((-1)**i))
for i in range(n):
    if i == 0:
        ans.append(str(int(some)))
    else:
        ans.append(str(2*int(lst[i-1]-int(ans[i-1])/2)))
print(" ".join(ans))

Measured memory_bytes: 17348
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll dp[5050][5050];

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

  dp[0][0]=1;
  for(int k=0;k<n;k++){
      for(int j=0;j<n;j++){
          dp[k+1][j+1]+=2*dp[k][j];
          dp[k+1][j+1]%=MOD;
          if(j==0){
              dp[k+1][j]+=dp[k][j];
              dp[k+1][j]%=MOD;
          }else{
              dp[k+1][j-1]+=dp[k][j];
              dp[k+1][j-1]%=MOD;
          }
      }
  }

  for(int k=1;k<=s.size();k++){
      dp[n][s.size()]=dp[n][s.size()]*(-MOD/2)%MOD;
      dp[n][s.size()]%=MOD;
  }  

  cout<<(dp[n][s.size()]+MOD)%MOD<<endl;

  return 0;
}


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


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

	string ans = "Yes";
	for( int i = 0; i < S.size(); i++ ) {
		if( i % 2 == 0 && S[i] != 'R' && S[i] != 'U' && S[i] != 'D' ) {
			ans = "No";
			break;
		}
		if( i % 2 && S[i] != 'L' && S[i] != 'U' && S[i] != 'D' ) {
			ans = "No";
			break;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()
# 予め-Kした状態で用意しておく
A = [a-K for a in LIST()]

MAX = N * K * 2
# dp[i][k] := i枚目までのカードで、合計をkにする通り数
dp = list2d(N+1, MAX+1, 0)
# 負の数を考慮して、N*K位置を0とする
dp[0][N*K] = 1
for i in range(N):
    a = A[i]
    for k in range(MAX+1):
        dp[i+1][k] += dp[i][k]
        if 0 <= k+a <= MAX:
            dp[i+1][k+a] += dp[i][k]
# N回終わって合計が0になっている通り数 - 1枚も取らないケース
print(dp[N][N*K]-1)


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

#define ll long long
#define mod 1000000007

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

    for(int i=0;i<s.size();i++)
    {
        int val=s[i]-'A';
        val+=n;

        if(val>25)val-=26;

        char re='A'+val;
        cout<<re;
    }
    cout<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
using namespace std;

int main(void) {
	int n;
	int count = 0;
	long long int a, b;
	long long int *t;
	cin >> n >> a >> b;
	t = new long long int[n + 1];
	FOR(i, 1, n) {
		cin >> t[i];
		if (t[i] >= a&&t[i] < b) {

		}
		else {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
# bfs, time O(k), space O(k)

from collections import deque
k = int(input())
q = deque([i for i in range(1, 10)])
# sz = 10
for _ in range(k):
    cur = q.popleft()
    nxt = cur * 10 + cur % 10
    if cur % 10 != 0:
        q.append(nxt - 1)
    q.append(nxt)
    if cur % 10 != 9:
        q.append(nxt + 1)
#     sz = max(sz, len(q))
# print(sz)
print(cur)

Measured memory_bytes: 40816
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,ab,x,y;
	cin>>a>>b>>ab>>x>>y;
//	int tmp=max(x,y)-min(x,y);
	int tmp=min(x,y),tmp2,tmp3=0;
	int sum=0;
	if(x>y){
		tmp3=x*(ab*2);
	}else{
		tmp3=y*(ab*2);
	}
	if(a+b>ab*2){
		sum+=tmp*(ab*2);
		if(x>y){
			tmp2=x-y;
			sum+=a*tmp2;
		}else if(y>x){
			tmp2=y-x;
			sum+=b*tmp2;
		}else{
		}
	}else{
		sum+=a*x;
		sum+=b*y;
	}
	sum=min(sum,tmp3);
	cout<<sum<<endl;
}


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


set<int> SET;

int main(){

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

	int command,x;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d %d",&command,&x);

		if(command == 0){

			SET.insert(x);
			printf("%lld\n",SET.size());

		}else if(command == 1){

			if(SET.count(x) > 0){

				printf("1\n");
			}else{

				printf("0\n");
			}
		}else{

			SET.erase(x);
		}
	}

	return 0;
}



Measured memory_bytes: 12500
#include <stdio.h>
#include <math.h>

int main(void){

  int n,m;
  long x;
  scanf("%d %d %ld", &n, &m, &x);
  long c[n],a[n][m];
  for (int i = 0; i < n; i++) {
    scanf("%ld", &c[i]);
    for (int j = 0; j < m; j++) {
      scanf("%ld", &a[i][j]);
    }
  }
  int bit[n];
  for (int i = 0; i < n; i++) {
    bit[i] = 0;
  }
  bit[0] = -1;
  long understand[m];
  int flag;
  long cost;
  long min = -1;
  for (int i = 0; i < pow(2,n); i++) {
    bit[0]++;
    for (int j = 1; j < n; j++) {
      bit[j] += bit[j-1]/2;
      bit[j-1] %= 2;
    }
    for (int j = 0; j < m; j++) {
      understand[j] = 0;
    }
    cost = 0;
    for (int j = 0; j < n; j++) {
      if (bit[j] == 1) {
        for (int k = 0; k < m; k++) {
          understand[k] += a[j][k];
        }
        cost += c[j];
      }
    }
    flag = 1;
    for (int j = 0; j < m; j++) {
      if (understand[j] < x) {
        flag = 0;
        break;
      }
    }
    if (flag == 1) {
      if (min == -1 || cost < min) {
        min = cost;
      }
    }
  }
  printf("%ld\n", min);

  return 0;
}

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

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

  string s;
  cin >> s;
  string ans = "Good";
  rep(i, 0, s.size() - 1) {
    if (s[i] == s[i + 1]) ans = "Bad";
  }
  cout << ans << endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++){
    cin >> A[i];
  }

  double ans = 1;
  for (int i=0; i<N; i++){
    double inv = 1 / (double)A[i];
    ans *= exp(inv);
  }
  ans = 1 / (log(ans));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512