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

public class Main {
    public static void main(String[] args) {
        Main main = new Main();main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        for (int i = 0; i <= 100;) {
            int N2 = N -i;
            if (N2 < 0) {
                i += 4;
                continue;
            }
            if (N2 % 7 == 0) {
                System.out.println("Yes");
                return;
            }
            i += 4;
        }
        System.out.println("No");
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () { s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in)); }
        public String next() {
            try {
                if (i < s.length) return s[i++]; String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0); i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF -1
using namespace std;

typedef long long int ll;
typedef pair<int, int> P;

int main() {

	char a[4][4];

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

	cout << a[0][0] << a[1][1] << a[2][2] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

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 (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

vector<vector<vector<int>>> dp;
int n, ma, mb;
int INF = 5000;
int MAX = 401;

void init()
{
	cin >> n >> ma >> mb;
	dp.resize(41, vector<vector<int>>(MAX, vector<int>(MAX, INF)));
	dp[0][0][0] = 0;
}

int main()
{
	init();

	REP(i, n)
	{
		int a, b, c;
		cin >> a >> b >> c;

		REP(j, MAX)
			REP(k, MAX)
		{
			if (dp[i][j][k] < INF)
			{
				chmin(dp[i + 1][j][k], dp[i][j][k]);
				chmin(dp[i + 1][j + a][k + b], dp[i][j][k] + c);
			}
		}
	}

	int ans = INF;

	REP1O(i, 41)
	REP1O(j, MAX)
		REP1O(k, MAX)
	{
		if (j * mb == k * ma)
			chmin(ans, dp[i][j][k]);
	}

	if (ans == INF)
		cout << -1 << endl;
	else
		cout << ans << endl;

}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M ; i ++) cin >> A.at(i);

    for (int i = 0; i < M ; i++) {
        N -= A.at(i);
    }

    if (N < 0) N = -1;
    
    cout << N << endl;
    
}

Measured memory_bytes: 3616
def new_list(s_list):
    s_list_new = [s_list[0]]
    for i, s in enumerate(s_list):
        if i >= 1:
            if s != s_list[i - 1]:
                s_list_new.append(s)
    return s_list_new

if __name__ == "__main__":

    count = 0
    n, k = map(int, input().split())
    stext = str(input())
    s_list = [s for s in stext]
    s_list = new_list(s_list)
    cnt_l = s_list.count('L')
    cnt_r = s_list.count('R')
    if cnt_l == cnt_r:
        if k >= cnt_l:
            count = 1
        else:
            count = 2 * (cnt_l - k)
    else:
        cnt_lr = min(cnt_l, cnt_r)
        if k >= cnt_lr:
            count = 1
        else:
            count = 2 * (cnt_lr - k) + 1
                
    print('{0}'.format(n - count))    

Measured memory_bytes: 4860
#include <stdio.h>
int main(void){

int n,x,i,j,k,count;

while(1){
scanf("%d %d",&n,&x);
if (n == 0 && x == 0)break;
count = 0;
for (i = 1;i<n;i++){
    for (j = 2;j<n;j++){
        if (i == j || j<i)continue;
        for (k = 3;k<=n;k++){
            if (i == k || j == k || k<j)continue;
            if (i+j+k == x){
                count++;
            }
        }
    }
}
printf("%d\n",count);
}

return 0;    
}


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

vector<long long> rbd(vector<long long> mat) {
    int n = mat.size();
    int rk = 0;
    for (int i = 60; i >= 0; i--) {
        bool exist = false;
        for (int j = rk; j < n; j++) {
            if (mat[j] >> i & 1) {
                exist = true;
                swap(mat[rk], mat[j]);
                break;
            }
        }
        if (exist) {
            for (int j = 0; j < n; j++) {
                if (j != rk && mat[j] >> i & 1) {
                    mat[j] ^= mat[rk];
                }
            }
            rk++;
        }
    }
    return mat;
}

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

    int n;
    cin >> n;
    long long all = 0;
    vector<long long> as(n);
    for (int i = 0; i < n; i++) cin >> as[i];

    vector<int> cnt(60);
    for (int i = 0; i < n; i++) {
        all ^= as[i];
        for (int j = 0; j < 60; j++) {
            if (as[i] >> j & 1) cnt[j]++;
        }
    }
    long long ans = 0;
    for (int i = 0; i < 60; i++) {
        if (cnt[i] & 1) {
            ans += 1LL << i;
            for (int j = 0; j < n; j++) {
                if (as[j] >> i & 1) {
                    as[j] ^= 1LL << i;
                }
            }
        }
    }
    long long a = 0;
    auto bs = rbd(as);
    for (auto &b : bs) {
        a ^= b;
    }
    cout << a + (all ^ a) << endl;
}


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

typedef long long int ll;
typedef struct point{
	double x, y;
}Point;

double dist(Point p1, Point p2){
	return sqrt(pow(p1.x-p2.x,2)+pow(p1.y-p2.y,2));
}

int main(){
	int N; scanf("%d",&N);
	Point tab[N];
	for (int i=0;i<N;i++){
		scanf("%lf %lf",&tab[i].x, &tab[i].y);
	}
	
	int p[N];
	for(int i=0;i<N;i++) p[i]=i;
	
	int cnt=0;
	double sum=0;
	do{
		double tmp=0;
		for(int i=0;i<N-1;i++){
			tmp+=dist(tab[p[i]], tab[p[i+1]]);
		}
		sum+=tmp;
		cnt++;
	}while(next_permutation(p,p+N));
	
	printf("%.10lf",sum/(double)cnt);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i, n) for(int i=0;i<n;++i)
#define REPR(i, n) for(int i = n-1;i>=0;--i)
#define REPI(itr, v) for(auto itr=v.begin();itr!=v.end();+itr)
#define SORT(v, n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define llong long long
#define INF 999999999
#define pb(a) push_back(a)

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

using namespace std;

int main(){

  cin.tie(0);
  ios::sync_with_stdio(false);

  string s;

  cin >> s;

  int n = (int)s.length();
  REP(i, n){
    int len = n - i + 1;
    if(s[i] == 'd'){
      if(len >= 11 && s.substr(i, 11) == "dreameraser"){
        i += 10;
      }else if(len >= 10 && s.substr(i, 10) == "dreamerase"){
        i += 9;
      }else if(len >= 7 && s.substr(i, 7) == "dreamer"){
        i += 6;
      }else if(len >= 5 && s.substr(i, 5) == "dream"){
        i += 4;
      }else{
        cout << "NO\n";
        return 0;
      }
    }else if(s[i] == 'e'){
      if(len >= 6 && s.substr(i, 6) == "eraser"){
        i += 5;
      }else if(len >= 5 && s.substr(i, 5) == "erase"){
        i += 4;
      }else{
        cout << "NO\n";
        return 0;
      }
    }else{
      cout << "NO\n";
      return 0;
    }
  }

  cout << "YES\n";

  return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const int MAX = 100000;

int n;

    
int main()
{
    vector<int> ve;
    int t, n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    {
        scanf("%d", &t);
        ve.push_back(t);
    }
    make_heap(ve.begin(),ve.end());
    for (vector<int>::iterator it = ve.begin() ; it != ve.end(); ++it)
        printf(" %d",*it);
   printf("\n");
    return 0;
}

Measured memory_bytes: 4920
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	string s;
	int cnt = 0;
	cin >> s;

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

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

int main(){
    long long l,r;
    cin >> l >> r;
    if(r / 2019 - l / 2019 > 0){
        cout << 0 << endl;
        return 0;
    }
    l = l % 2019;
    r = r % 2019;
    long long min = 100000000;
    for(int i = l; i < r; i++){
        for(int j = i+1; j < r+1; j++){
            if((i * j) % 2019 < min){
                min = (i * j) % 2019;
            }
        }
        
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int ans = 0;
	for(int i = 1; i < n-1; i++){
		if(a[i-1] < a[i] && a[i] < a[i+1]) ans++;
		else if(a[i+1] < a[i] && a[i] < a[i-1]) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n,a,b;
  cin >> n;
  a = n%100;
  b = n/100;
  if( 0<= a && a <= b*5) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int t[110];
  int sum = 0;
  rep(i,n) {
    cin >> t[i];
    sum += t[i];
  }
  int m;
  cin >> m;
  rep(i,m) {
    int p, x;
    cin >> p >> x;
    cout << sum - t[p - 1] + x << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define watch(x) cout<<#x<<" : "<<x<<endl;
typedef long long ll;
using namespace std;

int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(NULL),cout.tie(NULL);

    string s,t;
    cin>>s>>t;
    ll n=s.size(),ans=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3912
<?php
$words = ["dream", "dreamer", "erase", "eraser"];

fscanf(STDIN, "%s", $S);

while($S) {
    $flg = false;
    
    foreach ($words as $word) {
        $len = strlen($word);
        $exam = substr($S, -$len);
        if ($exam === $word) {
            $S = substr($S, 0, strlen($S) - $len);
            $flg = true;
            break;
        }
    }
    
    if ($flg === false) break;
}

echo $S === "" ? "YES\n" : "NO\n";


Measured memory_bytes: 4604
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 }; 
//const long double PI = acos(-1.0);
//#define int long long
signed main(){
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') {
			s[i] ='9';
			continue;
		}
		else if(s[i]=='9') {
			s[i] = '1';
			continue;
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
# DP(配るDP)
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('inf')] * N
dp[0] = 0
for i in range(N - 1):
  for j in range(1, K + 1):
    if i + j > N - 1:
      break
    dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print(dp[N -1])


Measured memory_bytes: 55008
//y14-2
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){
    int tmp;
    int sum = 0;
    cin >> tmp;
    sum += tmp;
    cin >> tmp;
    sum += tmp * 5;
    cin >> tmp;
    sum += tmp * 10;
    cin >> tmp;
    sum += tmp * 50;
    cin >> tmp;
    sum += tmp * 100;
    cin >> tmp;
    sum += tmp * 500;
    if(sum >= 1000) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)

int solve() {
  string S; cin >> S;
  int left = 0, right = S.size() - 1;
  int ans = 0;
  while(left < right) {
    if(S[left] == S[right]) {
      left++, right--;
    } else {
      if(S[left] == 'x') {
        left++, ans++;
      } else if(S[right] == 'x') {
        right--, ans++;
      } else {
        return -1;
      }
    }
  }
  return ans;
}

int main() {
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 512
n = STDIN.gets.to_i
matrix = (0...n).inject([]) do |result|
	result << STDIN.gets.split[0...n].map { |v| v == "-1" ? nil : v.to_i}
end

# プリムのアルゴリズム
MAX_WEIGHT = 2001
parent = Array.new(n)
visited = Array.new(n, false)
min_weight_adj = Array.new(n, MAX_WEIGHT)

loop do
	vertex = matrix.each_index.
		select { |i| !visited[i] }.
		min_by { |i| min_weight_adj[i] }

	break if vertex.nil?
	visited[vertex] = true

	matrix.each_index do |i|
		next if visited[i] || matrix[vertex][i].nil?

		if matrix[vertex][i] < min_weight_adj[i]
			min_weight_adj[i] = matrix[vertex][i]
			parent[i] = vertex
		end
	end

end

puts matrix.each_index.
	select { |i| !parent[i].nil? }.
	inject(0) { |r, i| r += matrix[i][parent[i]] }

Measured memory_bytes: 6124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c,n) for(int i=c;i<n;i++)

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

  if(s=="ABC"){cout<<"ARC"<<endl;}
  else{cout<<"ABC"<<endl;}
  
  return 0;
}


Measured memory_bytes: 3628
using System;
using System.Linq;
using System.Text;

namespace ITP1_5_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var sb = new StringBuilder();

            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                if (input.All(s => s == "0"))
                    break;
                var H = int.Parse(input[0]);
                var W = int.Parse(input[1]);
                for(int i = 0; i < H; i++)
                {
                    sb.AppendLine(new string('#', W));
                }
                sb.AppendLine();
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9368
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main()
{
    int n; cin>>n;
    ll a[100010], b[100010], a2[100010];
    for(int i=0; i<n+1; i++) cin>>a[i], a2[i]=a[i];
    for(int i=0; i<n; i++) cin>>b[i];
    ll s1=0, s2=0;
    for(int i=0; i<n; i++){
        ll x=min(b[i], a[i]);
        a[i]-=x;
        s1+=x;
        ll y=min(b[i]-x, a[i+1]);
        a[i+1]-=y;
        s1+=y;
    }
    reverse(a2, a2+n+1);
    reverse(b, b+n);
    for(int i=0; i<n; i++){
        ll x=min(b[i], a2[i]);
        a2[i]-=x;
        s2+=x;
        ll y=min(b[i]-x, a2[i+1]);
        a2[i+1]-=y;
        s2+=y;
    }
    cout<<max(s1, s2)<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <tuple>
using namespace std;
template<class T>
bool equal(T x, T y) { return x==y;}

template<>
bool equal(const char* x, const char* y) {return std::strcmp(x, y);}

template<class Iterator, class Compare>
void selection_sort(Iterator first, Iterator last, Compare comp)
{
    for(Iterator p = first; p != last; ++p)
    {
        Iterator min_position = p;
        for(Iterator q = p; q != last; ++q)
        {
            if(comp(*q, *min_position))
                min_position = q;
        }
        auto tmp = *min_position;
        *min_position = *p;
        *p = tmp;
    }
}

int main()
{
    long A, B, C; cin >> A >> B >> C;
    cout << min({((A+1)/2)*B*C - A/2*B*C, A*((B+1)/2)*C- A*(B/2)*C, A*B*((C+1)/2) - A*B*(C/2)}) << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
main(){
  int a,b,d=0,r=0;
  double f=0;
  scanf("%d %d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/(double)b;
  printf("%d %d %lf\n",d,r,f);
  return 0;
}

Measured memory_bytes: 636
import sys
input = sys.stdin.readline
INF = 10**10
MOD = 10**9 + 7
sys.setrecursionlimit(100000000)
from functools import lru_cache
from itertools import permutations

def main():
    n,m = map(int,input().split())
    food = [0] * m
    for i in range(n):
        a = list(map(int,input().split()))
        for i in range(1,len(a)):
            food[a[i] - 1] += 1
    
    cnt = 0
    for i in range(m):
        if food[i] == n:
            cnt += 1
    
    print(cnt)


if __name__=='__main__':
    main() 

Measured memory_bytes: 3572
object Main extends App {
//  val coin = Array(500,100,50)
  val Array(a, b, c, x) = Iterator.continually(io.StdIn.readLine.toInt)
    .take(4).toArray

  val ans = {
      for {
        i <- 0 to a
        if 500*i <= x
        j <- 0 to b
        if 500*i + 100*j <= x
        k <- 0 to c
        if 500*i + 100*j + 50*k == x
      } yield  true
    }.size

  println(ans)
}

Measured memory_bytes: 27208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> sot;
    vector<int> nsot;
    rep(i,n){
        int num; cin >> num;
        sot.push_back(num);
        nsot.push_back(num);
    }
    sort(ALL(sot));
    int count = 0;
    vector<int> v;
    rep(i,n){
        if(sot[i]!=nsot[i]){
            v.push_back(i);
            count += 1;
        }
    }
    if(count==0){
        cout << "YES" << endl;
    }else if(count==2){
        if(sot[v[1]]==nsot[v[0]] && sot[v[0]] == nsot[v[1]]){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }else{
        cout << "NO" << endl;
    }

    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
const int mod=1e6+3;
typedef long long ll;
#define inf 0x3f3f3f3f
#define mem(a,b) memset(a,b,sizeof(a))
#define per(i,a,b) for(int i=(a);i<b;i++)
#define rep(i,a,b) for(int i=(a);i<=b;i++)
#define pi acos(-1.0)
#define mid ((l+r)>>1)
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
void read(int &x)
{
	int f=1;x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=f;
}
int a[maxn];
int main()
{
	int n;
	read(n);
	per(i,0,n)read(a[i]);
	int ans=0;
	rep(i,1,n-2)
	{
		if(a[i]>a[i-1]&&a[i]>a[i+1]||a[i]<a[i-1]&&a[i]<a[i+1]||a[i]==a[i+1]&&a[i]==a[i-1])continue;
		ans++;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <iostream>

 

 

 

using namespace std;

 

 

 

int main() 
{
    int i, x;
    for(i=1; i<=10000; i++)
    {
        cin >> x;
        if(x==0)
          break;
        cout << "Case" << " " <<  i  << ":" << " " << x << endl;
    }
}


Measured memory_bytes: 3092
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-27 15:37:08
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  string s; cin >> s;
  stack<char> st;

  int n = s.size();

  for (int i = 0; i < n; ++i) {
    char c = s[i];
    if (st.empty()) {
      st.push(c);
    } else {
      if (st.top() == 'S' && c == 'T') {
        st.pop();
      } else {
        st.push(c);
      }
    }
  }

  cout << st.size() << endl;

  return 0;
}

Measured memory_bytes: 720
using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] dlm = " ".ToCharArray();
            string[] data = Console.ReadLine().Split(dlm);

            int a = int.Parse(data[0]);
            int b = int.Parse(data[1]);

            int d = a / b;
            int r = a - d * b;
            double f = (double) a / b;

            Console.WriteLine("{0} {1} {2}", d, r, f.ToString("f5"));
        }
    }
}


Measured memory_bytes: 17976
object Main extends App {
  val s = io.StdIn.readLine
  val t = io.StdIn.readLine
  val n = t.length
  var mn = n
  for (idx <- 0 to s.length - n) {
    var tmp = 0
    for ((c1, c2) <- t.zip(s.substring(idx))) {
      if (c1 != c2) tmp += 1
    }
    mn = Math.min(mn, tmp)
  }
  println(mn)
}


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

namespace CSharpSample01
{
    
    class Program
    {

        
        static void Main(string[] args) 
        {
            int N = int.Parse(Console.ReadLine());
            int[] h = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();          

            int r = 0;
            int l = 0;
            long cnt = 0;
            while (true)
            {
                //l見つける
                for(int i = 0; i < h.Length; i++)
                {                   
                    if(h[i] != 0)
                    {
                        l = i;
                        break;
                    }
                    
                    if(i == h.Length - 1)
                    {
                        Console.WriteLine(cnt);
                        return;
                    }                    
                }

                //r見つける
                for(int i = l; i < h.Length; i++)
                {                    

                    if (h[i] == 0)
                    {
                        r = i - 1;
                        break;
                    }

                    if (i >= h.Length - 1)
                    {
                        r = i;
                        break;
                    }

                }

                //位置ずつ消す
                for(int i = l; i <= r; i++)
                {
                    h[i]--;
                }

                cnt++;

                /*
                Console.WriteLine($"l = {l} r = {r}");

                Console.WriteLine(string.Join(" ", h));
                Console.ReadLine();
                */

            }

        }
    }
}


Measured memory_bytes: 13396
h, w = gets.to_s.split.map{|t|t.to_i}

c = Array.new(10){ gets.to_s.split.map{|t|t.to_i} } << ( [0] * 10 )
a = Array.new(h){ gets.to_s.split.map{|t|t.to_i} }.flatten

10.times do |k|
  10.times do |i|
    10.times do |j|
      c[i][j] = c[i][k] + c[k][j] if c[i][j] > c[i][k] + c[k][j]
    end
  end
end

ans = 0
a.each{|k| ans += c[k][1] }

puts ans

Measured memory_bytes: 5040
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX_N 1000
#define MAX_W 1000


int main()
{	
	int cnt = 0;
	int W, N;
	while( cin>>W && W && cin>>N){
		cnt++;
		int dp[MAX_N+1][MAX_W+1];
		for(int i=0;i<N;i++){
			int v,w;
			scanf("%d,%d",&v,&w);
			for(int j=0;j<W+1;j++){
				if(j-w>=0){
					dp[i+1][j] = max( dp[i][j], dp[i][j-w] + v);
				}else{
					dp[i+1][j] = dp[i][j];
				}
			}
		}
		cout<<"Case"<<' '<<cnt<<":"<<endl;
		for(int j=0;j<W+1;j++){
			if( dp[N][j] == dp[N][W] ){
				cout<< dp[N][j] << endl << j << endl;
				// そこからは全て一致するのでbreak
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 5156
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextLine

  val z = N.last match {
    case '2' | '4' | '5' | '7' | '9' => "hon"
    case '0' | '1' | '6' | '8' => "pon"
    case '3' => "bon"
  }
  println(z)
}


Measured memory_bytes: 55332
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  srand((unsigned)time(NULL));
  ll n,cnt=0;
  string v;
  set<int> r;
  set<int> w;
  cin >> n >> v;
  rep(i,n){
    if(v[i]=='R'){r.insert(i);}
    else if(v[i]=='W'){w.insert(i);}
  }
  if(r.size()==0 || w.size()==0){
    cout << 0 << endl; return 0;
  }
  rep(i,n){
    if(i == *begin(r)){
      r.erase(i);
    }else{break;}
  }
  while(r.size()!=0 && w.size()!=0 &&*rbegin(r)>=*begin(w)){
    r.erase(*rbegin(r));
    w.erase(*begin(w));
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 12956
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld double
#define ff first
#define ss second
ll mod = 1000000007;
void fun(){
	int n,t;
	cin>>n>>t;
	int mn=INT_MAX;
	map<int,int> mp;
	for(int i=0;i<n;++i){
		int x; cin>>x;
		mn=min(mn,x);
		mp[x-mn]++;
	}
	auto it=mp.rbegin();
	cout<<it->second<<"\n";
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll t=1; //cin>>t;
	while(t--){
		fun();
	}
	return 0;
}



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

class Progaram
{
    static void Main(String[] args)
    {
        var l = Console.ReadLine().Split(' ')
            .Select(x => int.Parse(x)).ToArray();
        var a = l[0]; var b = l[1];

        if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
        {
            Console.WriteLine("Possible");
        }
        else
        {
            Console.WriteLine("Impossible");
        }
    }
}

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

int N;

void dfs(string s,char n){
    if(s.size()==N){
        cout<<s<<endl;
        return;
    }else{
        for(char a='a';a<=n;a++){
            string t=s;
            t+=a;
            dfs(t,max((int)n,a+1));
        }
    }
}

int main(){
    cin>>N;

    dfs("",'a');
}

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

using namespace std;

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

  string s, t;
  cin >> s >> t;
  reverse(s.begin(), s.end());
  if (s == t) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
      using namespace std;
      #define ll long long
      #define pb push_back
      #define pll  pair <long long,long long>
      #define mp make_pair
      #define ss second
      #define ff first
      #define maa 1000000007
      #define endl '\n'
      #define ld long double
      #define all(x) x.begin(),x.end()
      ll  power(ll  i,ll  j)
      {
        if(j==0)
        return 1 ;
        ll t=power(i,j/2)%maa ;
        if(j%2==0)
        return (t%maa*t%maa)%maa ;
        else
        return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
      }
      bool is(ll  i)
      {
        if(i==1)
            return 0 ;
        ll  f=0 ;
        for(ll  j=2;j<=sqrt(i);j++)
        {
            if(i%j==0)
            {
                f=1 ;
                break ;
            }
        }
        return !f ;
      }
      ll n ;
      double p[3001] ;
      double dp[3001] ;
      int main()
      {

        /// 50-4
        /// freopen("input.txt","r",stdin);
        /// freopen("output.txt","w",stdout);
        cout<<fixed<<setprecision(10) ;
        cin>>n ;
        for(ll i=1;i<=n;i++)
        cin>>p[i] ;
        for(ll i=0;i<3001;i++)
        {
            
            dp[i]=0.0 ;
        }
        dp[1]=p[1] ;
        dp[0]=(1.0-p[1]) ;
        for(ll i=2;i<=n;i++)
        {
            for(ll j=i;j>=0;j--)
            {
                dp[j]=dp[j]*(1.0-p[i]) ;
                if(j-1>=0)
                dp[j]+=dp[j-1]*p[i] ;
            }
        }
        ld ans=0.0 ;
        for(ll j=(n+1)/2;j<=n;j++)
        {
            ans+=dp[j] ;
           // cout<<dp[n][j]<<endl ;
        }
       /* for(ll i=1;i<=n;i++)
        {
            for(ll j=0;j<=i;j++)
            {
                cout<<dp[i][j]<<" " ;
            }
            cout<<endl ;
        }*/
        cout<<ans ;
        
        
       
        
        

      }








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

using namespace std;

const int INF = 0x0fffffff;

int N;
int K;

typedef pair<int, int> ii;

vector< vector<int> > M;
vector<bool> V; // visited

vector<ii> R; // range

const ii inf = make_pair(-INF, INF);
const ii fail = make_pair(INF, -INF);

ii dfs(int i) {
    if (V[i]) {
        return inf;
    }

    V[i] = true;

    for (size_t j = 0; j < M[i].size(); ++j) {
        int ni = M[i][j]; // next i

        ii rv = dfs(ni);

        //if (rv == make_pair(-INF-1, INF+1)) {
        //    rv = inf;
        //}

        if (rv == fail) {
            return fail;
        } else if (R[i] == inf){
            R[i] = rv;
        } else if (rv == inf) {
            continue;
        } else if (R[i].first % 2 != rv.first % 2) {
            return fail;
        //} else if (R[i].second < rv.first) {
        //    return fail;
        //} else if (rv.second < R[i].first) {
        //    return fail;
        } else {
            R[i].second = min(R[i].second, rv.second);
            R[i].first  = max(R[i].first, rv.first);
        }
    }

    if (R[i].second < R[i].first) {
        return fail;
    }

    if (R[i] == inf) {
        return inf;
    } else {
        return make_pair(R[i].first-1, R[i].second+1);
    }
}

void dfs2(int i) {
    if (V[i]) {
        return;
    } 

    V[i] = true;

    R[i] = make_pair(R[i].first, R[i].first);
    
    for (size_t j = 0; j < M[i].size(); ++j) {
        int ni = M[i][j]; // next i
        
        if (V[ni]) {
            continue;
        }

        R[ni] = make_pair(max(R[ni].first, R[i].first-1), min(R[ni].second, R[i].second+1));

        dfs2(ni);
    }
}

int main(int argc, char* argv[]) {
    // for cin
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;

    M.resize(N);

    for (int i = 0; i < N; ++i) {
        M[i].clear();
    }

    for (int i = 0; i < N-1; ++i) {
        int a;
        int b;

        cin >> a >> b;
        a--;
        b--;

        M[a].push_back(b);
        M[b].push_back(a);
    }

    V.resize(N);
    fill(V.begin(), V.end(), false);

    R.resize(N);
    fill(R.begin(), R.end(), inf);

    cin >> K;

    for (int i = 0; i < K; ++i) {
        int v;
        int p;

        cin >> v >> p;
        v--;

        R[v] = make_pair(p, p);
    }

    ii rv = dfs(0);

    if (rv == fail) {
        printf("No\n");
        return 0;
    }

    printf("Yes\n");
    fill(V.begin(), V.end(), false);

    dfs2(0);

    for (int i = 0; i < N; ++i) {
        printf("%d\n", R[i].first);
    }

    return 0;
}


Measured memory_bytes: 11904
#include <cstdio>

int main() {
    while (true) {
        int a,b;
        std::scanf("%d%d",&a,&b);
        if (a == 0 && b == 0) {
            return 0;
        } else if (a <= b) {
            std::printf("%d %d\n",a,b);
        } else {
            std::printf("%d %d\n",b,a);
        }
    }
  
}


Measured memory_bytes: 2568
#include <cstdio>
using namespace std;
const int N=300010;
const int INF=1e9;
int n;
char str[N];
int left[N],right[N]; 
inline int min(int x,int y){
	return x<y?x:y;
}
void readData(){
	scanf("%d",&n);
	scanf("%s",str+1);
}
void init(){
	for(int i=1;i<=n;i++)
		left[i]=left[i-1]+(str[i]=='W');
	for(int i=n;i>=1;i--)
		right[i]=right[i+1]+(str[i]=='E');
}
void solve(){
	int ans=INF;
	for(int i=1;i<=n;i++)
		ans=min(ans,left[i-1]+right[i+1]);
	printf("%d\n",ans);
}
int main(){
	readData();
	init();
	solve();
	return 0;
}


Measured memory_bytes: 2816
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N, K;
    cin >> K >> N;
    vector<int> A(N+1);
    for (int i = 0; i < N; i++) cin >> A[i];
    int mx = 0;
    for (int i= 0; i < N-1; i++) {
        mx = max(mx, abs(A[i] - A[i+1]));
    }
    mx = max(mx, abs(K-A[N-1] + A[0]));

    cout << K - mx << endl;
    return 0;
}

Measured memory_bytes: 1792
/**
 *    author:  RM07
 *    created: August 22, 2020 9:14 PM
 *    motto: Knowledge is Power, Strive for Excellence
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long 
signed main(){
    string str;
    cin >> str;
    int ans = 0;
    for(int i = 0; i < str.size(); i++){
        ans += (str[i] - '0');
    }
    if(ans % 9) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  ll score = 0;
  vector<char> te;
  rep(i, T.size()) {
    char c = T[i];
    char t = 'x';
    if(i>=K) t = te[i-K];
    if(c=='s' && t!='r') {
      score += R;
      te.push_back('r');
    } else if(c == 'p' && t!='s') {
      score += S;
      te.push_back('s');
    } else if(c == 'r' && t!='p') {
      score += P;
      te.push_back('p');
    } else {
      te.push_back('x');
    }
  }
  cout << score << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
 #define PI 3.141592653
using namespace std;

ll A[100001];

void solve(){
	int n,m; cin>>n>>m;
	ll ans=0;
	priority_queue<pair<ll,ll> > pq;
	for(int i=0; i<n; i++){
		cin>>A[i];
		ans += A[i];
		pq.push({A[i] - A[i]/2,A[i]/2});
	}
	for(int i=0; i<m; i++){
		pair<ll,ll> pp = pq.top();
		pq.pop();
		ans -= pp.f;
		pq.push({pp.s - pp.s/2,pp.s/2});
	}
	cout<<ans;
}


int main()
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(12);
	int t =1; //cin>>t;
	for(int i=1; i<=t; i++){
		solve();
		cout<<"\n";
	}
	return 0;

}

Measured memory_bytes: 2932
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s
}

fn main () {
	let s = read_line().split_whitespace().map(|e|e.parse().unwrap())
	.collect::<Vec<i32>>();

	let x = s[0];
	let a = s[1];
	let b = s[2];

	let r = b - a;

	if r <= 0 {
		println!("delicious");
	}else if r <= x {
		println!("safe");
	}else{
		println!("dangerous");
	}
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int abs(int a){
	if(a>=0)return a;
	else return -a;
}

int max(int a,int b){
	return a>=b ? a:b;
}
int min(int a,int b){
	return a<=b ? a:b;
}

int main(){

	int w,a,b;

	cin>>w>>a>>b;

	int ans = abs(a-b);

	if(ans>=w){
		ans-=w;
		cout<<ans<<endl;
	}else{
		cout<<0<<endl;
	}

	return 0;
}

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

string s;
signed main(){
  long long ans=0,ket;
  cin>>s;
  s='0'+s;
  for(int i=s.size()-1;i>=0;i--){
    ket=s[i]-'0';
    if(ket<5){
      ans+=ket;
    }
    else {
      if(ket == 5 && s[i-1]<'5'){
        ans+=ket;
      } else {
        ans+=10-ket;
        s[i-1]++;
      }
    }
  }
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 2308
A,B=input().split(' ')
A = int(A)
if '.' in B:
    B_int,B_float = B.split('.')
    if len(B_float) == 1:
        print(A*int(B_int)+(A*int(B_float))//10)
        print(B_int,B_float)
    else:
        print(A*int(B_int)+(A*int(B_float)//100))

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

using namespace std;

using ll = long long;

int n;

void perm(vector<int>& tar, vector<int>& c) {
	vector<int> tmp(tar);
	for (int i = 0; i < n - 1; i++) {
		tar[i] = tmp[c[i]];
	}
}

void solve(vector<int>& c, ll k, vector<int>& res) {
	while (k > 0) {
		if (k & 1) perm(res, c);
		vector<int> tmp(c);
		perm(c, tmp);
		k >>= 1;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	vector<ll> x(n), dx(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < n - 1; i++) {
		dx[i] = x[i + 1] - x[i];
	}
	int m;
	ll k;
	cin >> m >> k;
	vector<int> c(n - 1), res(n - 1);
	for (int i = 0; i < n - 1; i++) {
		c[i] = i;
		res[i] = i;
	}
	for (int i = 0; i < m; i++) {
		int a;
		cin >> a;
		a--;
		swap(c[a - 1], c[a]);
	}
	solve(c, k, res);
	vector<ll> ans(n);
	ans[0] = x[0];
	for (int i = 1; i < n; i++) {
		ans[i] = ans[i - 1] + dx[res[i - 1]];
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4544
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>
#include <numeric>
#include <string>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )
#define llrep(i, a, b) for(ll i = (a); i < (b); ++i )
#define llrrep(i, a, b) for(ll i = (a); i > (b); --i )
#define llREP(i, a, b) for(ll i = (a); i <= (b); ++i )
#define llRREP(i, a, b) for(ll i = (a); i >= (b); --i )
#define ullrep(i, a, b) for(ull i = (a); i < (b); ++i )
#define ullrrep(i, a, b) for(ull i = (a); i > (b); --i )
#define ullREP(i, a, b) for(ull i = (a); i <= (b); ++i )
#define ullRREP(i, a, b) for(ull i = (a); i >= (b); --i )



int N, M;
ll X[2][1010], Y[2][1010], Z[2][1010];
ll A[8][1010];
int P[8][3] = {
        {1, 0, 0},
        {0, 1, 0},
        {0, 0, 1},
        {1, 0, 1},
        {1, 1, 0},
        {0, 1, 1},
        {0, 0, 0},
        {1, 1, 1},
};

int main() {
    cin >> N >> M;
    rep(i, 0, N) {
        cin >> X[0][i] >> Y[0][i] >> Z[0][i];
        X[1][i] = -X[0][i];
        Y[1][i] = -Y[0][i];
        Z[1][i] = -Z[0][i];
    }
    rep(i, 0, 8) {
        rep(n, 0, N) {
            A[i][n] += X[P[i][0]][n];
            A[i][n] += Y[P[i][1]][n];
            A[i][n] += Z[P[i][2]][n];
        }
        sort(A[i], A[i]+N, std::greater<>());
    }
    ll ans = 0;
    rep(i, 0, 8) {
        ans = max(ans, accumulate(A[i], A[i]+M, 0LL));
    }
    cout << ans << endl;

}



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

int main() {
    using namespace std;

    cin.tie(0);
   	ios::sync_with_stdio(false);

    int x, a;

    cin >> x >> a;

    if (x < a) {
        cout << "0" << endl;
    } else {
        cout << "10" << endl;
    }

    
}

Measured memory_bytes: 256
h, w = list(map(int, input().split()))
g = []

for i in range(h):
    g.append(list(map(lambda x: 0 if x == '.' else 1, list(input()))))

changed = True
while changed:
    changed = False
    for row in g:
        if sum(row) == 0:
            g.remove(row)
            changed = True

    t = list(zip(*g))
    for column in t:
        if sum(column) == 0:
            t.remove(column)
            changed = True

    g = list(zip(*t))

result = ["".join(list(map(lambda x: "#" if x else ".", row))) for row in g]

for row in result:
    print(row)

Measured memory_bytes: 9380
n = int(input())
v = input().split()
for i in range(n):
	v[i] = int(v[i])
while(len(v) > 1):
	min1 = min(v)
	v.remove(min1)
	min2 = min(v)
	v.remove(min2)
	v.append((min1 + min2) / 2)
print(v[0])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}

}

int main() {

	int n;
	std::cin >> n;
	std::vector<int> a(n);
	std::vector<std::vector<int>> x(n, std::vector<int>());
	std::vector<std::vector<int>> y(n, std::vector<int>());
	rep(i, n) {
		std::cin >> a[i];
		rep(j, a[i]) {
			int x_, y_;
			std::cin >> x_ >> y_;
			x[i].push_back(x_);
			y[i].push_back(y_);
		}
	}

	// O(2^15 * 10)

	// 全ての人が正直者かそうでないかで分けてみる
	// その時の最大値
	// bit

	int ans = 0;

	for (int bit = 0; bit < (1 << n); ++bit) {
		int tmp_ans = 0;

		// 1なら正直，0なら嘘つき
		std::vector<int> humans(n);
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) {
				humans[i] = 1;
				++tmp_ans;
			}
			else {
				humans[i] = 0;
			}
		}
		bool out = false;
		rep(i, n) {
			if (humans[i] == 0) continue; // 信用ならない
			rep(j, a[i]) {
				if (y[i][j] != humans[x[i][j] - 1]) {
					out = true;
					break;
				}
			}
			if (out) break;
		}

		if (!out) ans = std::max(ans, tmp_ans);
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256