akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

class Main
{
	public static void main(String[] args)
	{
		FastReader reader = new FastReader();
		PrintWriter writer = new PrintWriter(System.out);

		int[] array = new int[3];
		for (int i=0; i<3; i++)
			array[i] = reader.nextInt();

		Arrays.sort(array);

		int ans = array[2]-array[0];

		writer.println(ans);
		writer.close();
	}

	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
}

Measured memory_bytes: 22996
from heapq import heapify, heappop, heappush, heappushpop

heap = []
# データの入力
while True:
    tmp = input()
    if tmp.startswith('end'):
        break
    elif tmp.startswith('insert'):
        k = int(tmp.split()[1])
        heappush(heap, -k)
    elif tmp.startswith('extract'):
        print(-heappop(heap))



Measured memory_bytes: 45312
def main():
    n = int(input())
    zorome_counter = 0
    flag = False
    for i in range(n):
        d1,d2 = map(int,input().split())
        if d1 == d2:
            zorome_counter += 1
        else:
            zorome_counter = 0
        if zorome_counter >= 3:
            flag = True
            break
    if flag:
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
from fractions import gcd
from functools import reduce


def gcd_list(numbers):
    return reduce(gcd, numbers)


n, x = map(int, input().split())

x_arr = [0] * n

x_arr = list(map(int, input().split()))

for i in range(len(x_arr)):
    x_arr[i] = abs(x_arr[i] - x)
print(gcd_list(x_arr))


Measured memory_bytes: 17104
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,k;
const int Maxn=5005;
int a[Maxn];
bool can[Maxn];
bool check(int pos){
	zero(can);
	can[0]=true;
	rep(i,n){
		if(i==pos)continue;
		for(int j=k-1;j>=0;j--){
			if(can[j]&&j+a[i]<k){
				can[j+a[i]]=true;
			}
		}
	}
//	rep(i,k){
//		printf("%d ",can[i]);
//	}
//	printf("\n");
	rep(i,k){
		if(can[i]&&i+a[pos]>=k){
			return true;
		}
	}
	return false;
}
int main(){
	scanf("%d%d",&n,&k);
	rep(i,n){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
//	rep(i,n){
//		printf("%d ",a[i]);
//	}
//	printf("\n");
	int L=-1,R=n-1;
	if(!check(R)){
		printf("%d\n",n);
		return 0;
	}
	while(R-L>1){
		int mid=(L+R)/2;
//		printf("%d %d %d\n",L,R,mid);
		if(check(mid))R=mid;
		else L=mid;
	}
	printf("%d\n",L+1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

int main()
{
    int n; cin >> n;
    vector<int> p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    vector<int> a(n);
    rep(i, n) a[i] = i+1;
    int k = 1;
    rep(i, n) k*=i+1;
    int pn, qn;
    rep(i, k){
        // prvec(a);
        if(p==a) pn = i;
        if(q==a) qn = i; 
        next_permutation(ALL(a));
    }
    pr(abs(pn-qn));
    return 0;}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int func(int n) {
  int count = 0;
  while(n % 2 == 0) {
    n = n / 2;
    count++;
  }
  return count;
}
int main() {
  int n;
  cin >> n;
  int max = 0;
  int max_i = 1;
  for(int i = 1;i <= n;i++) {
    if(max < func(i)) {
      max = func(i);
      max_i = i;
    }
  }
  cout << max_i << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int n, i, j;
	scanf("%d", &n);
	
	float x[8], y[8], avg=0;
	lop(i, n){
		scanf("%f %f", &x[i], &y[i]);
	}
	
	lop(i, n-1){
		for(j=i+1; j<n; j++){
			float sum=pow(x[i]-x[j], 2.0)+pow(y[i]-y[j], 2.0);
			avg+=sqrt(sum);
		}
	}
	
	printf("%f", avg/n*2);
	
return 0;
}

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

using namespace std;
int main() {
	double a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;

	
	double X, Y;
	double mx = -1.0;

	vector<double> x;
	vector<double> y;

	for (int i = 0; i <= f; i++) {
		for (int j = 0; j <= f; j++) {
			X = 100.0 * a * i + 100.0 * b * j;
			Y = c * i + d * j;
			if (X <= f) {
				x.push_back(X);
			}
			if (Y <= f) {
				y.push_back(Y);
			}
		}
	}

	double p = e / 100.0;
	
	double ans1;
	double ans2;
	for (int i = 0; i < x.size(); i++) {
		for (int j = 0; j < y.size(); j++) {
			double t = x[i] + y[j];
			if (t <=  f) {
				//double s = y[j] / x[i];
				double s =  y[j] / x[i];
				if (s <= p) {
					if (mx <= s) {
						mx = s;
						ans1 = x[i]+y[j];
						ans2 = y[j];
					}
				}
			}
		}
	}

	cout << ans1 <<" "<< ans2 << endl;

	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, k;
    cin >> n >> k;
    vll h(n);
    ll ans = 0;
    rep(i, n){
        cin >> h[i];
        if(h[i] >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      int sum;
      
      while(true){
         sum = 0;
         str = sc.nextLine();
         if(str.equals("0")){
            break;
         }else{
            for(int i = 0; i < str.length(); i ++){
               sum += Character.getNumericValue(str.charAt(i));
            }
            System.out.println(sum);
         }
         
         
      }
   }//main
}//class

Measured memory_bytes: 26620
moji = str(input())
num = int(input())
for i in range(num):
  s = input().rstrip().split(' ')
  command = str(s[0])
  if command == "print":
    start = int(s[1])
    end = int(s[2])
    print(moji[start:end+1])
  elif command == "reverse":
    start = int(s[1])
    end = int(s[2]) + 1
    moji2 = moji[start:end]
    moji3 = ''.join(list(reversed(moji2)))
    moji = moji[:start] + moji3 + moji[end:]
  elif command == "replace":
    start = int(s[1])
    end = int(s[2]) + 1
    beforerep = moji[start:end+1]
    rep = str(s[3])
    moji = moji[:start] + rep + moji[end:]


Measured memory_bytes: 5616
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int n, m;


pair<pair<int, int>, int> p[100005];//year, pref, index

int lastind[100005]={0};
int ind[100005];
int pre[100005];

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for(int i = 0; i < m; ++i) {
		cin >> p[i].first.second >> p[i].first.first;
		p[i].second = i;
	}
	sort(p, p+m);
	for(int i = 0; i < m; ++i) {
		pre[p[i].second] = p[i].first.second;
		ind[p[i].second] = (++lastind[pre[p[i].second]]);
	}

	for(int i = 0; i < m; ++i) {
		printf("%06d%06d\n", pre[i], ind[i]);
	}



    return 0;
}


Measured memory_bytes: 3840
from pprint import PrettyPrinter

pp = PrettyPrinter()


def read_tiles(h, w):
    c = []
    for _ in range(h):
        c.append([int(x) for x in input().split()])
    return c


def make_histogram(h, w, c):
    hg = [[None] * w for _ in range(h)]
    for j in range(w):
        hg[0][j] = 1 if c[0][j] == 0 else 0
    for i in range(1, h):
        for j in range(w):
            hg[i][j] = hg[i - 1][j] + 1 if c[i][j] == 0 else 0
    return hg


def largest_rectangle(h, w, c):
    lr = 0
    hg = make_histogram(h, w, c)
    # pp.pprint(hg)
    s = []
    for i in range(h):
        hg[i] += [0]
        for j in range(w + 1):
            if len(s) == 0:
                if hg[i][j] > 0:
                    s.append((hg[i][j], j))
            else:
                top = s[-1]
                if top[0] < hg[i][j]:
                    s.append((hg[i][j], j))
                elif hg[i][j] == top[0]:
                    pass
                else:
                    while len(s) > 0 and s[-1][0] >= hg[i][j]:
                        top = s.pop()
                        lr = max(lr, top[0] * (j - top[1]))
                    s.append((hg[i][j], top[1]))
            # print(j, lr, s)
    return lr


def main():
    h, w = map(int, input().split())
    c = read_tiles(h, w)
    print(largest_rectangle(h, w, c))


main()



Measured memory_bytes: 66264
using System;

namespace _3_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = 1;
            bool z = true;
            string answer = "a";
            while (z)
            {
                answer = Console.ReadLine();
                if (!(answer == "0"))
                {
                    Console.WriteLine("Case " + x + ": " + answer);
                    x++;
                }
                else
                {
                    z = false;
                }
            }
        }
    }
}

Measured memory_bytes: 9316
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll n;
	cin >> n;
	ll ans = 0;
	rep(i, n) {
		ll a;
		cin >> a;
		ans += a;
	}
	cout << ans - n << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}


Measured memory_bytes: 3656
<?php

class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

$sc = new Scanner();

$n = $sc->nextInt();
if($n==7 or $n==5 or $n==3)print("YES");
else print("NO");

Measured memory_bytes: 4728
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	char S[101] = {0};
	int N = 0;
	scanf("%d", &N);
	scanf("%s", S);
	if (N%2 != 0) {
		printf("No\n");
	} else {
		int ret = 0;
		ret = strncmp(&S[0], &S[(N/2)], N/2);
		if (ret != 0) {
			printf("No\n");
		} else {
			printf("Yes\n");
		}
	}
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<string>
using namespace std;
typedef long long ll;
typedef vector < int > vi;
typedef pair<int,int> pi;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define re(i,a,b) for(ll i=a;i<b;i++)
//add below to remove endl in input just before getline()
//cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');
int main(){
	//ios::sync_with_stdio(0);cin.tie(0);
	//freopen("input.txt", "r", stdin);
	int t;cin>>t;
	cout<<(t+t*t+t*t*t)<<endl;

return 0;}


Measured memory_bytes: 3628
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int v = sc.nextInt();
        int b = sc.nextInt();
        int w = sc.nextInt();
        int t = sc.nextInt();
		int dis = Math.abs(a - b);
		int sp = v - w;
		if(sp <= 0){
			System.out.println("NO");
			System.exit(0);
		}
		if((dis / sp == t) && !(dis % sp == 0)){
		System.out.println("NO");
		}
		else if(dis / sp <= t){
			System.out.println("YES");
		}else{
		System.out.println("NO");
		}
    }
}

Measured memory_bytes: 35892
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
string s;
cin>>s;
int n=s.size();
for(int i=0;i<s.size();i++)
{
	if(s[i]=='?')
	{
		if(i==0)
		{
			if(s[i+1]=='P')
			{
				s[i]='D';
			}
			else
			{
				s[i]='D';
			}
		}
		else if(i==n-1)
		{
			if(s[i-1]=='P')
			{
				s[i]='D';
			}
			else
			{
				s[i]='D';
			}
		}
		else
		{
			if(s[i+1]=='P' && s[i-1]=='D')
			{
				s[i]='D';
			}
			else if(s[i+1]=='D' && s[i-1]=='P')
			{
				s[i]='D';
			}
			else if(s[i+1]=='D' && s[i-1]=='D')
			{
				s[i]='D';
			}
			else
			{
				s[i]='D';
			}
		}
		
	}
}
cout<<s;
}


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

ll N;
vector<int> S, a;

ll merge(int l, int m, int r) {
  int i, j, k;
  ll cnt = 0;
  int n1 = m - l;
  int n2 = r - m;
  vector<int> L(n1+1), R(n2+1);
  rep(i,n1) L[i] = S[l+i];
  rep(i,n2) R[i] = S[m+i];
  L[n1] = R[n2] = 1e9+1;
  i = j = 0;
  for(k = l; k < r; k++) {
    if(L[i] <= R[j]) {
      S[k] = L[i++];
      cnt += n2 - j;
    } else {
      S[k] = R[j++];
    }
  }
  return cnt;
}

ll count(int l, int r) {
  if(r - l <= 1) return 0;

  int m;
  ll v1, v2, v3;
  m = (l + r) / 2;
  v1 = count(l, m);
  v2 = count(m, r);
  v3 = merge(l, m, r);
  return v1 + v2 + v3;
}

int main () {
  cin >> N;
  a = vector<int>(N);
  S = vector<int>(N+1);
  rep(i,N) cin >> a[i];

  // [l, r)
  int l = 0, r = 1e9 + 1;
  ll t = (N*(N+1)/2 + 1)/2;
  while(r - l > 1) {
    int x = (l + r) / 2;
    S[0] = 0;
    rep(i,N) S[i+1] = S[i] + (a[i] >= x ? 1 : -1);
    if(count(0, N+1) >= t) {
      l = x;
    } else {
      r = x;
    }
  }

  cout << l << endl;

  return 0;
}


Measured memory_bytes: 1656
/* ITP1_2_A : Small Large or Equal */

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main(void){
	int a, b;

	scanf("%d %d", &a, &b);
	
	if(a > b){
		puts("a > b");
	}else if(a < b){
		puts("a < b");
	}else{
		puts("a == b");
	}

	return 0;
}


Measured memory_bytes: 1992
def main():
    n = int(input())
    h = list(map(int, input().split()))
    ans = h[0]
    for i in range(n-1):
        if h[i+1] > h[i]:
            ans += h[i + 1]-h[i]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#![allow(unused_imports)]
#![allow(dead_code)]
use datastructure::*;
use grapth::*;
use math::*;
use string_algorithm::*;
use util::*;
use input_scanner::*;

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

fn main() {
    let mut scan = Scanner::new();
    let a: f64 = scan.next();
    let b: f64 = scan.next();
    let h: usize = scan.next();
    let m: usize = scan.next();
    
    let argh: f64 = ((1 * (h*60 + m)) % 720) as f64;
    let argm: f64 = ((12 * (h*60 + m)) % 720) as f64;
    let pi2 = 2f64 * std::f64::consts::PI;

    let xh: f64 = (argh / 720f64 * pi2).sin() * a;
    let yh: f64 = (argh / 720f64 * pi2).cos() * a;
    let xm: f64 = (argm / 720f64 * pi2).sin() * b;
    let ym: f64 = (argm / 720f64 * pi2).cos() * b;
    let d = ((xh-xm)*(xh-xm) + (yh-ym)*(yh-ym)).sqrt();
    println!("{:.9}", d);
}

mod datastructure {}
mod grapth {}
mod math {}
mod string_algorithm {}
mod util {}
mod input_scanner {
    pub struct Scanner {
        bytes: Vec<u8>,
        begin: usize,
        end: usize,
    }
    
    impl Scanner {
        pub fn new() -> Self {
            use std::io::Read;
            let mut buffer: Vec<u8> = Vec::new();
            std::io::stdin().read_to_end(&mut buffer).unwrap();
            let end = (0..buffer.len())
                .find(|i| buffer[*i].is_ascii_whitespace())
                .unwrap_or(buffer.len());
            Scanner {
                bytes: buffer,
                begin: 0,
                end: end,
            }
        }
        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            let s: &str = unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
            let ret: T = s.parse::<T>().ok().expect("Parse error.");
            self.skip();
            ret
        }
        pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
        pub fn next_word(&mut self) -> Vec<u8> {
            let r = Vec::from(&self.bytes[self.begin..self.end]);
            self.skip();
            r
        }
        fn skip(&mut self) {
            self.begin = (self.end..self.bytes.len())
                .find(|i| !self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
            self.end = (self.begin..self.bytes.len())
                .find(|i| self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
        }
    }
}


Measured memory_bytes: 2956
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  vector<string> S(H);
  for(int i=0; i<H; i++) {
    cin >> S.at(i);
  }
  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++){
      if(S.at(i).at(j)=='.'){
        int sum=0;
        if(i!=0){
          if(S.at(i-1).at(j)=='#') sum++;
        }
        if(i!=H-1){
          if(S.at(i+1).at(j)=='#') sum++;
        }
        if(j!=0){
          if(S.at(i).at(j-1)=='#') sum++;
        }
        if(j!=W-1){
          if(S.at(i).at(j+1)=='#') sum++;
        }
        if(i!=0 && j!=0){
          if(S.at(i-1).at(j-1)=='#') sum++;
        }
        if(i!=0 && j!=W-1){
          if(S.at(i-1).at(j+1)=='#') sum++;
        }
        if(i!=H-1 && j!=0){
          if(S.at(i+1).at(j-1)=='#') sum++;
        }
        if(i!=H-1 && j!=W-1){
          if(S.at(i+1).at(j+1)=='#') sum++;
        }
        cout << sum;
      }else{
        cout << "#";
      }
    }
    cout << endl;
  }
}

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

using namespace std;
typedef long long ll;

ll comb(ll n, ll k){
    ll ret = 1;
    for(ll i = 0; i < k; ++i){
        ret *= (n - i);
        ret /= (i + 1);
    }
    return ret;
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    for(int i = 0; i < n; ++i){
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());

    ll total = 0;
    for(int i = 0; i < a; ++i){
        total += v.at(n - 1 - i);
    }
    printf("%.8f\n", (double)total / a);

    if(n == a){
        cout << 1 << endl;
        return 0;
    }

    const ll minv = v.at(n - a);
    const ll idx1 = lower_bound(v.begin(), v.end(), minv) - v.begin();
    const ll idx2 = upper_bound(v.begin(), v.end(), minv) - v.begin() - 1;
    if(v.back() > minv){
        const ll k = idx2 - (n - a) + 1;
        cout << comb(idx2 - idx1 + 1, k) << endl;
        return 0;
    }else{
        ll ans = 0;
        for(ll i = a; i <= min(b, idx2 - idx1 + 1LL); ++i){
            ans += comb(idx2 - idx1 + 1LL, i);
        }
        cout << ans << endl;
        return 0;
    }
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int d, n;
  cin >> d >> n;
  n += n / 100;
  int ans = pow(100, d) * n;
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

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

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  double x1, y1, x2, y2, x3, y3;
  cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
  vector<double> a(3);
  a[0] = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
  a[1] = sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
  a[2] = sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));

  sort(a.begin(), a.end());
  double s = (a[0]+a[1]+a[2])/2;
  double S = sqrt(s*(s-a[0])*(s-a[1])*(s-a[2]));

  double k = s + 2*S/a[2];
  double r = S/k;
  cout << setprecision(15) << r << endl;
}


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

const int k = 3000;


double moreHeadThanTail(double * p, int i,int &n,int head_count,double dp[][3000]){
    if(i == n){
        if(head_count <= 0){
            return 1;
        }
        
        return 0;
    }

    if(head_count <= 0){
        return 1;
    }
    if(dp[i][head_count] >= 0){
        return dp[i][head_count];
    }


    double x = p[i] *moreHeadThanTail(p,i+1,n,head_count - 1,dp) + (1 - p[i]) * moreHeadThanTail(p,i+1,n,head_count,dp);
    return dp[i][head_count] = x;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    double p[n];
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int head_count = (n / 2) + 1;
    double dp[n+1][3000];
    memset(dp,-1,sizeof(dp));
    cout<< fixed << setprecision(10) << moreHeadThanTail(p,0,n,head_count,dp)<<endl;
    return 0;
}

Measured memory_bytes: 74316
//sobskdrbhvk
//remember the flying, the bird dies ):(
#include <bits/stdc++.h>

using namespace std;

typedef long long int LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

#define PB push_back
#define MP make_pair
#define L first
#define R second
#define sz(x) ((int)(x).size())
#define smax(x, y) ((x) = max((x), (y)))
#define smin(x, y) ((x) = min((x), (y)))
#define all(x) x.begin(),x.end()

const int maxn = 1e5 + 85 - 69;
const LL Inf = 1e18;
LL mn[maxn],
	a[maxn],
	n, E, T;
LL dp[maxn];
deque<int> dq;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> E >> T;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	a[n + 1] = E;
	int ptr = 1;
	dq.push_front(0);
	for(int i = 1; i <= n; i++){
		while(2 * (a[i] - a[ptr]) > T) ptr++;
		while(sz(dq) and dq.back() + 1 < ptr) dq.pop_back();
		dp[i] = Inf;
		if(sz(dq))
			dp[i] = dp[dq.back()] + (a[i] - a[dq.back()]) + T;
		if(ptr >= 2)
			smin(dp[i], dp[mn[ptr - 2]] + 2 * (a[i] - a[mn[ptr - 2] + 1]) + a[i] - a[mn[ptr - 2]]);
		while(sz(dq) and dp[i] - a[i] <= dp[dq.front()] - a[dq.front()])
			dq.pop_front();
		dq.push_front(i);
		mn[i] = mn[i - 1];
		if(dp[i] - 2 * a[i + 1] - a[i] < dp[mn[i]] - 2 * a[mn[i] + 1] - a[mn[i]])
			mn[i] = i;
	}
	cout << dp[n] + E - a[n] << endl;
	return 0;
}

Measured memory_bytes: 2816
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--, B--, C--, D--;

    string s; cin >> s;

    if (C < D) {
        for (size_t i = A; i <= D - 1; ++i) {
            if (s[i] == '#' && s[i + 1] == '#') {
                return cout << "No" << "\n", 0;
            }
        }

        cout << "Yes" << "\n";
    }

    else {
        for (size_t i = A; i <= C - 1; ++i) {
            if (s[i] == '#' && s[i + 1] == '#') {
                return cout << "No" << "\n", 0;
            }
        }

        for (size_t i = A + 1; i <= D - 1; ++i) {
            if (s.substr(i, 3) == "...") {
                if (i + 2 == B && s[i + 3] == '#') continue;
                return cout << "Yes" << "\n", 0;
            }
        }

        cout << "No" << "\n";
    }

    return 0;
}


Measured memory_bytes: 592
import sys

N, A, B = map(int, input().split())
X = list(map(int, sys.stdin.readline().rsplit()))

res = 0
for i in range(1, N):
    cost = abs(X[i] - X[i - 1]) * A
    if cost < B:
        res += cost
    else:
        res += B

print(res)


Measured memory_bytes: 19912
package main

import "fmt"

func main() {
	var h, w int
	var c [10][10]int
	fmt.Scan(&h)
	fmt.Scan(&w)

	for i := 0; i <= 9; i++ {
		for j := 0; j <= 9; j++ {
			fmt.Scan(&c[i][j])
		}
	}

	for i := 0; i <= 9; i++ {
		for j := 0; j <= 9; j++ {
			for k := 0; k <= 9; k++ {
				if c[j][i]+c[i][k] < c[j][k] {
					c[j][k] = c[j][i] + c[i][k]
				}
			}
		}
	}

	answer := 0
	for i := 0; i < h*w; i++ {
		var a int
		fmt.Scan(&a)

		if a >= 0 {
			answer += c[a][1]
		}
	}
	fmt.Println(answer)
}


Measured memory_bytes: 3200
// 2011/04/02 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	while(!cin.eof()){
		string str;
		getline(cin, str);
		if(str.empty())
			continue;

		for(int i=0; i<str.size(); i++)
			if(str[i]==',')
				str[i] = ' ';

		istringstream ist(str);
		int n;
		double w, h;
		ist >> n >> w >> h;

		double bmi = w/(h*h);
		if(bmi>=25.0)
			cout << n << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>

typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

int main(void) {
    string input;
    cin >> input;
    int a, b, c, d;
    a = input[0] - '0';
    b = input[1] - '0';
    c = input[2] - '0';
    d = input[3] - '0';

    int ans_i;
    int ans_j;
    int ans_k;
    REP(i, 2) {
        if (i == 0) {
            ans_i = a + b;
        }
        else {
            ans_i = a - b;
        }
        REP(j, 2) {
            if (j == 0) {
                ans_j = ans_i + c;
            }
            else {
                ans_j = ans_i - c;
            }
            REP(k, 2) {
                if (k == 0) {
                    ans_k = ans_j + d;
                }
                else {
                    ans_k = ans_j - d;
                }
                if (ans_k == 7) {
                    cout << a;
                    if (i == 0) cout << "+";
                    else cout << "-";
                    cout << b;
                    if (j == 0) cout << "+";
                    else cout << "-";
                    cout << c;
                    if (k == 0) cout << "+";
                    else cout << "-";
                    cout << d << "=7"<< endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  int n, k;
  vector<int> a;
  Solver2(LL n, LL k) : n(n), k(k), a(n){};

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    if (accumulate(a.begin(), a.end(), 0) < n + (n - 1) * (k)) {
      cout << -1 << endl;
    } else {
      priority_queue<pair<int, int>> pq;
      pair<int, int> prev = {-1, -1};
      for (int i = 0; i < n; ++i) {
        pq.push({k + 1 - a[i], i});
      }
      {
        //check
        auto p1 = pq.top();
        pq.pop();
        auto p2 = pq.top();
        DBG(p1, p2)
        if (p1.first > (k + 1) / 2 || p2.first > k / 2) {
          cout << -1 << endl;
          return;
        }
        pq.push(p1);
      }
      vector<int> ex;
      while (ex.size() < k) {
        auto tmp1 = pq.top();
        pq.pop();
        if (tmp1.second != prev.second) {
          ex.push_back(tmp1.second);
          pq.push({tmp1.first - 1, tmp1.second});
          prev = tmp1;
        } else {
          auto tmp2 = pq.top();
          pq.pop();
          ex.push_back(tmp2.second);
          pq.push({tmp1.first, tmp1.second});
          pq.push({tmp2.first - 1, tmp2.second});
          prev = tmp2;
        }
      }
      cout << n + (n - 1) * (k) << endl;
      for (int i = 0; i < k + 1; ++i) {
        deque<int> ans;
        for (int j = 0; j < n; ++j) {
          if (i > 0 && j == ex[i - 1]) continue;
          if (i < k && j == ex[i]) {
            ans.push_back(j);
          } else {
            ans.push_front(j);
          }
        }
        for (int j = 0; j < ans.size(); ++j) {
          cout << ans[j] + 1 << ' ';
        }
      }
    }
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, m;
  std::cin >> n >> m;

  Problem::Solver2 sol(n, m);
  sol.solve();
  return 0;
}


Measured memory_bytes: 256
import * as fs from 'fs';

//in
//
//out
//
const main = (inp: string) => {

    if (parseInt(inp) % 2 ===0) {
        console.log(parseInt(inp) / 2);
    } else {
        console.log(Math.floor(parseInt(inp) / 2)+1);
    }
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 7500
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []a = new int [n];
		int []b = new int [n];
		
		for(int i = 0; i<n ; i++) {
			a[i] = sc.nextInt();
			b[i] = a[i] ;
		}
		Arrays.sort(b);
		
		for(int i = 0; i < n ;i++) {
			if(a[i] == b[n-1]) {
				System.out.println(b[n-2]);
			}
			if(a[i] < b[n-1]) {
				System.out.println(b[n-1]);
			}
		}

	}
}



Measured memory_bytes: 94404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define deb(x) cout << #x << "=" << x << endl;
const int MOD = 2019;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    string s; cin >> s;
    map<int, int> cnt;
    cnt[0]=1;
    int n = s.size();
    ll num = 0;
    ll mult = 1;
    ll ans = 0;
    for (int i = n-1; i>= 0; i--) {
        num += mult*(s[i]-'0'); num %= MOD;
        ans += cnt[num];
        cnt[num]++;
        mult = mult*10 % MOD;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	int k;
	cin>>k>>s;
	if(s.size()>k)
	{
		rep(i,0,k) cout<<s[i];
		cout<<"...";
	}
	else cout<<s<<"\n";
	return 0;
}

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

using namespace std;

int main() {
	string s, a = "", b = "";
	int total = 0;
	cin >> s;
	
	if (s.size() % 2 == 1) {
		for (int i = 0; i < (s.size() / 2); i++) a += s[i];
		for (int i = s.size() - 1; i > s.size() / 2; i--) b += s[i];
	} 
	else {
		for (int i = 0; i < (s.size() / 2); i++) a += s[i];
		for (int i = s.size() - 1; i >= s.size() / 2; i--) b += s[i];
	}
	
	
	for (int i = 0; i < a.size(); i++) {
		if (a[i] != b[i]) total++;
	}
	
	cout << total;
	
	return 0;
}

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



int main(){
  int A,B,tmp=10;
  cin >> A >> B;
  while(tmp<=1010){
    if(int(tmp*0.08)==A && int(tmp*0.1)==B) break;
    ++tmp;
  }
  if(tmp==1011) cout << "-1" << endl;
  else cout << tmp << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int cnt=0;
	for(int i=0;i<=100;i++){
		if(i>=a && i+1<=b && i>=c && i+1<=d)cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

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

int main(){

  int H, W;
  char ans[50][50], S[50][50], dummy;
  

  scanf("%d%d", &H, &W);
  scanf("%c", &dummy);
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      scanf("%c", &S[i][j]);
    }
    scanf("%c", &dummy);
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      int cnt = 0;
      if(S[i][j] == '#'){
        ans[i][j] = '#';
      }else{
        if(i == 0){
          if(j == 0){
            if(S[0][1] == '#') cnt++;
            if(S[1][0] == '#') cnt++;
            if(S[1][1] == '#') cnt++;
          }else if(j == W-1){
            if(S[0][W-2] == '#') cnt++;
            if(S[1][W-1] == '#') cnt++;
            if(S[1][W-2] == '#') cnt++;
          }else{
            if(S[0][j-1] == '#') cnt++;
            if(S[0][j+1] == '#') cnt++;
            if(S[1][j] == '#') cnt++;
            if(S[1][j-1] == '#') cnt++;
            if(S[1][j+1] == '#') cnt++;
          }
        }else if(i == H-1){
          if(j == 0){
            if(S[H-1][1] == '#') cnt++;
            if(S[H-2][0] == '#') cnt++;
            if(S[H-2][1] == '#') cnt++;
          }else if(j == W-1){
            if(S[H-1][W-2] == '#') cnt++;
            if(S[H-2][W-1] == '#') cnt++;
            if(S[H-2][W-2] == '#') cnt++;
          }else{
            if(S[H-1][j-1] == '#') cnt++;
            if(S[H-1][j+1] == '#') cnt++;
            if(S[H-2][j] == '#') cnt++;
            if(S[H-2][j-1] == '#') cnt++;
            if(S[H-2][j+1] == '#') cnt++;
          }
        }else{
            if(j == 0){
                if(S[i-1][0] == '#') cnt++;
                if(S[i-1][1] == '#') cnt++;
                if(S[i][1] == '#') cnt++;
                if(S[i+1][0] == '#') cnt++;
                if(S[i+1][1] == '#') cnt++;
            }else if(j == W-1){
                if(S[i-1][W-1] == '#') cnt++;
                if(S[i-1][W-2] == '#') cnt++;
                if(S[i][W-2] == '#') cnt++;
                if(S[i+1][W-1] == '#') cnt++;
                if(S[i+1][W-2] == '#') cnt++;
            }else{
                if(S[i-1][j-1] == '#') cnt++;
                if(S[i-1][j] == '#') cnt++;
                if(S[i-1][j+1] == '#') cnt++;
                if(S[i][j-1] == '#') cnt++;
                if(S[i][j+1] == '#') cnt++;
                if(S[i+1][j-1] == '#') cnt++;
                if(S[i+1][j] == '#') cnt++;
                if(S[i+1][j+1] == '#') cnt++;
            }
          }
      ans[i][j] = '0' + cnt;      
      }
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      printf("%c",ans[i][j]);
    }
    printf("\n");
  }

  return 0;
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define int long long int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()

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

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
		
	int h, w, mod = 1e9 + 7;
	cin>>h>>w;
	char a[h+1][w+1];

	for(int i=1; i<=h; i++) {
		for(int j=1; j<=w; j++) {
			cin>>a[i][j];
		}
	}

	int dp[h+1][w+1];
	memset(dp, 0, sizeof(dp));

	for(int i=1; i<=h; i++) {
		for(int j=1; j<=w; j++) {
			dp[1][1] = 1;
			if(a[i][j]=='.') {
				dp[i][j] = (dp[i][j-1] + dp[i-1][j])%mod;
			}
		}
	}

	cout<<dp[h][w];

	return 0;
}

Measured memory_bytes: 9088
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args : Array<String>) {
    val scan = FastScanner(System.`in`)

    var s = scan.next()
    val q = scan.nextInt()

    var rvFlag = false
    val str = ArrayDeque<Char>(s.toList())

    repeat(q) {
        val q1 = scan.nextInt()

        if (q1 == 1) {
            rvFlag = !rvFlag
        } else {
            val q2 = scan.nextInt()
            val c = scan.next()[0]

            if (rvFlag) {
                if (q2 == 1) {
                    str.addLast(c)
                } else {
                    str.addFirst(c)
                }
            } else {
                if (q2 == 1) {
                    str.addFirst(c)
                } else {
                    str.addLast(c)
                }
            }
        }
    }

    if (rvFlag) {
        println(str.reversed().joinToString(separator = ""))
    } else {
        println(str.joinToString(separator = ""))
    }
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

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

const int N=100005;
const long long INF=0x3f3f3f3f3f3f3f3f;
int n,k,a[105],dp[N];

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[j]>i) continue;
			dp[i]|=!dp[i-a[j]];
		}
	}
	if(dp[k]) printf("First\n");
	else printf("Second\n");
}

Measured memory_bytes: 640
function main(input) {
  var nums = input.split('\n').map((n) => parseInt(n, 10));
  var ans=0;
  for(var i=0; i<5; i++){
    if(nums[i]%10==0){
      ans+=nums[i];
    }else{
      ans+=10*(1+Math.floor(nums[i]/10));
    }
  }
  var hitoketa=[];
  for(var i=0;i<5;i++){
    if(nums[i]%10!=0)hitoketa.push(nums[i]%10)
  }
  var a=Math.min.apply(null, hitoketa);
  if(hitoketa.length!=0 && a!=0){
    console.log(ans-10+a);
  }else{
    console.log(ans);
  }
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, M=2e6;
const int NB = 30;
typedef long long ll;
const ll mod = (1e9 + 7);
int n,a[N],b[N],cnt=1,g[M][2],fail[M],val[M],track[N][NB];
void newtrie() { cnt = 0; g[0][0] = g[0][1] = val[0] = -1; }
int newnode() { ++cnt; g[cnt][0] = g[cnt][1] = val[cnt] = -1; return cnt; }
void addstr(const string& s, int vval) {
	int cur = 0;
	for (char x : s) {
		int lnk = (x == '0' ? 0 : 1);
		if (g[cur][lnk] == -1)
			g[cur][lnk] = newnode();
		cur = g[cur][lnk];
	}
	val[cur] = vval;
}
void mklink() {
	queue<int> q;
	for (int i=0; i<2; ++i)
		if (g[0][i] != -1) {
			fail[g[0][i]] = 0;
			q.push(g[0][i]);
		}
	while (!q.empty()) {
		int s = q.front(); q.pop();
		for (int i=0; i<2; ++i)
			if (g[s][i] != -1) {
				int state = fail[s];
				while (state > 0 && g[state][i] == -1) state = fail[state];
				state = (g[state][i] == -1 ? state : g[state][i]);
				fail[g[s][i]] = state;
				q.push(g[s][i]);
			}
	}
}
void aho(string text, vector<int> &x0, vector<int> &x1) {
	x0.clear(); x1.clear();
	for (int i = 0; i < n - 1; ++i) text += text[i];
	int cur = 0, i=0;
	for (char x : text) {
		++i;
		int v = (x == '0' ? 0 : 1);
		while (cur > 0 && g[cur][v] == -1) cur = fail[cur];
		cur = (g[cur][v] == -1 ? cur : g[cur][v]);
		if (val[cur] == 0) x0.push_back(i - n);
		if (val[cur] == 1) x1.push_back(i - n);
	}
}
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) cin >> b[i];
	for (int i = 0; i < n; ++i) fill(track[i], track[i] + NB, -1);
	for (int k = 0; k < NB; ++k) {
		string A, B, nB;
		for (int i = 0; i < n; ++i) {
			A += ((a[i] & (1 << k)) ? '1' : '0');
			B += ((b[i] & (1 << k)) ? '1' : '0');
			nB += ((b[i] & (1 << k)) ? '0' : '1');
		}
		newtrie();
		addstr(B, 0); addstr(nB, 1);
		mklink();
		vector<int> x0, x1;
		aho(A, x0, x1);
		for (int x : x0)
			track[x][k] = 0;
		for (int x : x1)
			track[x][k] = 1;
	}
	for (int k = 0; k < n; ++k) {
		bool emotional = true;
		for (int j=0; j<NB; ++j) 
			if (track[k][j] == -1) {
				emotional = false;
				break;
			}
		if (emotional) {
			int x = 0;
			for (int j = 0; j < NB; ++j)
				if (track[k][j])
					x |= (1 << j);
			cout << k << " " << x << endl;
		}
	}
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll X;
    cin >> X;
    ll U = X / 100;
    ll H = X % 100;
    ll cnt[200];
    fillnum(cnt,LINF);
    cnt[0] = 0;
    for (int i = 0; i <= H; i++) {
        for (int j = 1; j < 6; j++) {
            cnt[i+j] = min(cnt[i+j],cnt[i]+1);
        }
    }
    SANKOU(cnt[H] <= U,1,0);
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e15)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)

const int mxn = 1*(1e5) + 5;
ll n;

int solve(){
	ll k;
	cin >> k >> n;
	if(n == 0) {
		cout<<k;
		return 0;
	}
	vector<ll>a(n, 0);
	set<ll>s;
	for(int i=0; i<n; i++) {
		cin >> a[i];
		s.insert(a[i]);
	}
	// sort(a.begin(), a.end());
	// ll v = lower_bound(a.begin(), a.end(), k) - a.begin();
	// cout<<min(abs(k - a[v-1]), abs(k - a[v]));
	ll x=INF, y=INF;
	for(int i=k; i<1000; i++) {
		if(!s.count(i)) {
			x = i;
			break;
		}
	}
	for(int i=k-1; i>=0; i--) {
		if(!s.count(i)) {
			y = i;
			break;
		}
	}
	if(x-k >= k-y) {
		cout<<y;
	}
	else{
		cout<<x;
	}
	return 0;

}
 
int main(){
	fast;
	// tt
		solve();
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
 int main()
{	
lli i,j,n,k;
cin >> n;
vector<lli>in(n);
vector<lli>dp(n,0);
for(i=0;i<n;i++){
	cin >> in[i];
}

dp[0]=0;
for(i=1;i<n;i++){
	if(i==1)dp[i]=abs(in[i]-in[i-1]);
	else dp[i]=min(dp[i-1]+abs(in[i]-in[i-1]),dp[i-2]+abs(in[i]-in[i-2]));
	
}
	cout << dp[n-1];
return 0;}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
#define int long long
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
using namespace std;
#define hash hush
typedef long long ll;
typedef long double ld;
int n, a[8];
signed  main() {
	ld a, b, c;
	cin >> a >> b;
	c = (1 / a) + (1 / b);
	printf("%.19LF\n", 1 / c);
	getchar(); getchar();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define ll long long int
using namespace std;
int main()
{
    ll a,b,c,n,x,y,z,cnt=0,sum=0;
    string str;
    cin>>str;
    cout<<str[0]<<str[1]<<str[2]<<endl;


}


Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
int main()
{
	char n[200001];
	long long int i,m=0,len;
	scanf("%s",n);
	len=strlen(n);
	for(i=0;i<len;i++){
		m+=(n[i]-'0');
	}
	if(m%9==0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1812