akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int n, m;
    cin >> n >> m;
    vector<int> x(n+1);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        x[a] = (x[a] + 1) % 2;
        x[b] = (x[b] + 1) % 2;
    }

    rep(i, n){
        if(x[i+1] == 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}


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

using namespace std;

int h, w, a, b;

int main() {
    scanf("%d %d %d %d", &h, &w, &a, &b);

    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if ( (i <= b) == (j <= a) ) cout << 0;
            else cout << 1;
        }
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 1280
import fractions

N,X=map(int,input().split())
xlist=list(map(int,input().split()))

xlist2=[]
for i in range(N):
  xlist2.append(abs(xlist[i]-X))
  
#print(xlist2)
answer=xlist2[0]
for i in range(1,N):
  answer=fractions.gcd(answer,xlist2[i])
  
print(answer)

Measured memory_bytes: 16284
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int H, W; 
	cin >> H >> W; 
	int C[12][12] = {}; 
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			cin >> C[i][j]; 
		}
    }
	for(int k = 0; k < 10; k++){
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				C[i][j] = min(C[i][j], C[i][k] + C[k][j]); 
			}
		}
	}
	int ans = 0; 
	for(int i = 0; i < H * W; i++){
		int a; 
		cin >> a; 
		if(a >= 0){ans += C[a][1];}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= N; ++j) {
            if ((Y - i * 10000 - j * 5000) % 1000 == 0) {
                if ((Y - i * 10000 - j * 5000) / 1000 >= 0 && i + j + (Y - i * 10000 - j * 5000) / 1000 == N) {
                    cout << i << " " << j << " " << (Y - i * 10000 - j * 5000) / 1000;
                    return 0;
                }
            }
        }
    }

    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	int N, K; cin >> N >> K;
	V<ll> h(N), dp(N,LINF); REP(i, N) cin >> h[i];
	dp[1] = abs(h[1] - h[0]);
	dp[0] = 0;
	
	FOR(i,1,N){
		for(int j = i; i - K <= j && 0 <= j; --j){
			dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
		}
	}
		
	cout << dp[N-1] << endl;
	return 0;
}


Measured memory_bytes: 1792
import math

a, b, h, m = map(int, input().split())
xa = a * math.cos((h + m / 60.0) * 3.14159265358979323 / 6)
ya = a * math.sin((h + m / 60.0) * 3.14159265358979323 / 6)
xb = b * math.cos(m * 3.14159265358979323 / 30)
yb = b * math.sin(m * 3.14159265358979323 / 30)
print(math.sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)))


Measured memory_bytes: 62340
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
a = LI()
b = [None for i in range(n-1)]
for i in range(n-1):
    a[i+1] += a[i]
for i in range(n-1):
    b[i] = abs(2*a[i]-a[n-1])
print(min(b))
"""

#D
n = I()
v = [[] for i in range(n)]
for i in range(n-1):
    a,b = LI()
    a -= 1
    b -= 1
    v[a].append(b)
    v[b].append(a)
d_f = [-1 for i in range(n)]
q = deque()
q.append(0)
d_f[0] = 0
while q:
    x = q.pop()
    for y in v[x]:
        if d_f[y] == -1:
            d_f[y] = d_f[x] + 1
            q.append(y)
d_s = [-1 for i in range(n)]
q.append(n-1)
d_s[n-1] = 0
while q:
    x = q.pop()
    for y in v[x]:
        if d_s[y] == -1:
            d_s[y] = d_s[x] + 1
            q.append(y)
f = 0
s = 0
for i in range(n):
    if d_f[i] <= d_s[i]:
        f += 1
    else:
        s += 1
if f > s:
    print("Fennec")
else:
    print("Snuke")
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 36200
#include<iostream>
#include<iostream>
using namespace std;
int main(){
  string s;
  cin>>s;
  string ans;
  for(int i=0;i<s.size();i++){
    if(s[i]=='B'&&ans.size()==0)continue;
    
    else if(s[i]=='0'||s[i]=='1'){
      ans+=s[i];
    }
    else{
      ans.pop_back();
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0, h;
    for (int i = 0; i < n; ++i) {
        cin >> h;
        if (h >= k) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  int total_post_towns;
  int total_journey_days;
  while(~scanf("%d %d",
               &total_post_towns,
               &total_journey_days)){
    vector<int> path;

    int sum[100001];
    memset(sum,0,sizeof(sum));
    for(int i=0;i<total_post_towns-1;i++){
      int distance;
      scanf("%d",&distance);
      path.push_back(distance);
      sum[i+1] = distance + sum[i];
    }

    int sx = 0;
    int res = 0;
    for(int i=0;i<total_journey_days;i++){
      int dx;
      scanf("%d",&dx);
      if(dx < 0){
        res += sum[sx] - sum[sx+dx];
        res %= 100000;
        sx += dx;
      }
      else if(dx >= 0){
        res += sum[sx + dx] - sum[sx];
        res %= 100000;
        sx += dx;
      }
    }

    printf("%d\n",res % 100000);
  }
}

Measured memory_bytes: 2064
#include<iostream>
#include<deque>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int MAX_K = 1e5 + 1;

bool is_checked[MAX_K];

int main() {
    int K;
    cin >> K;
    deque<P> DQ;
    DQ.push_back(P(1, 1));
    while (!DQ.empty()) {
        P now = DQ.front();
        DQ.pop_front();
        int num = now.first, cost = now.second;
        if (is_checked[num]) continue;
        is_checked[num] = true;
        if (num == 0) {
            cout << cost << endl;
            return 0;
        }
        DQ.push_back(P(((num + 1) % K), cost + 1));
        DQ.push_front(P(((num * 10) % K), cost));
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
typedef long long ll;
typedef complex<int> P;
typedef pair<int, int> Pii;


struct st{
	string name;
	double a;

	st(){}
	st(string n, double a) : name(n), a(a) {}
	bool operator< (const st &s)const{
		return (this->a == s.a) ? this->name < s.name : this->a > s.a;
	}
};

bool solve(int n){
	vector<st> vst;
	for(int i=0;i<n;i++){
		string l;
		int p, a, b, c, d, e, f, s, m;
		cin>> l>> p>> a>> b>> c>> d>> e>> f>> s>> m;
		int t, money;
		t = a + b + c + (d + e) * m;
		money = m * f * s - p;
		st tmp(l, (double)money/t);
		vst.pb(tmp);
	}
	sort(vst.begin(),vst.end());
	for(int i=0;i<vst.size();i++){
		cout<< vst[i].name<<  endl;
	}
	cout<< "#"<< endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	int n;
	while(cin>>n, n){
		solve(n);
	}
	return 0;
}

 

Measured memory_bytes: 1220
import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn
object Main extends App {

  val n = StdIn.readLine().trim.toInt
  
  // RuntimeError !! (Hash値が悪さしている？)
  //val result = (0 until n).foldLeft(ListBuffer.empty[String], HashSet.empty[String]){
  val result = (0 until n).foldLeft(ArrayBuffer.empty[String], Set.empty[String]){
      case ((acc, dict), _) =>
    val cmd = StdIn.readLine().split(' ')
    if(cmd(0) == "insert"){
      (acc, dict + cmd(1))
    } else {
      if(dict.contains(cmd(1))) {
        (acc += "yes", dict)
      } else {
        (acc += "no", dict)
      }
    }
  }
  println(result._1.mkString(f"%n"))

}


Measured memory_bytes: 477600
#include<stdio.h>
int main()
{
      int n;
      scanf("%d",&n);
      int a[n],i,b[100001]={ };
      long long int sum=0;
      for(i=0;i<n;i++){
            scanf("%d",&a[i]);
            b[a[i]]++;
            sum+=a[i];
      }
      int q;
      scanf("%d",&q);
      for(i=1;i<=q;i++){
            int c,d;
            scanf("%d%d",&c,&d);
            sum+=(long long int)((d*b[c])-(b[c]*c));
            b[d]+=b[c];
            b[c]=0;
            printf("%lld\n",sum);
      }

      return 0;
}



Measured memory_bytes: 2472
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll euclidean_gcd(ll a, ll b) {
    if(a < b) euclidean_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    int maxV = euclidean_gcd(A, B);
    vector<int> result;

    for (int i = maxV; i >= 1; i--) {
        if (maxV % i == 0) {
            result.pb(i);
        }
    }
    cout << result[K-1] << endl;
}

Measured memory_bytes: 256
import itertools


def get_discomfort(group_dic, color, D):
    s = 0
    for c, num in group_dic.items():
        s += D[c - 1][color - 1] * num
    return s


N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]


from collections import Counter


grids = [Counter() for _ in range(3)]

for i in range(N):
    c = list(map(int, input().split()))
    for j in range(N):
        grids[(i + j) % 3][c[j]] += 1


ans = float("inf")
for colors in itertools.permutations(list(range(C)), 3):
    colors = list(colors)
    s = 0
    for i, c in enumerate(colors):
        s += get_discomfort(grids[i], c, D)
    ans = min(ans, s)

print(ans)


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

using namespace std;

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

  string s;
  cin>>s;

  if(s=="ABC")
    cout<<"ARC"<<endl;
  else
    cout<<"ABC"<<endl;

  return 0;
}


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

using namespace std;

long long a[10][10];
int main() {
    
    int n;
    cin >> n;

    
    for (int i = 1; i <= n; ++i) {
        int last = i % 10;  
        int first = i;
        while(first / 10 > 0) first /= 10;
        a[first][last]++;
    }
    
    long long ans = 0;
    for (int i = 1; i <= 9; ++i) {
       for (int j = 1; j <= 9; ++j)
           ans += a[i][j] * a[j][i];
    }
    cout << ans << "\n";
    return 0;
}


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

int main(void){
    int H,W;
    cin >> H >> W;
    char s[H+2][W+2];
    for (int h = 0; h < H; h++)
    {
        for (int w = 0; w < W; w++)
        {
            cin >> s[h+1][w+1];
        }
    }
    for (int h = 0; h < H; h++)
    {
        s[h][0] = '.';
        s[h][W+1] = '.';
    }
    for (int w = 0; w < W; w++)
    {
        s[0][w] = '.';
        s[H+1][w] = '.';
    }
    
    for (int h = 0; h < H; h++)
    {
        for (int w = 0; w < W; w++)
        {
            if(s[h+1][w+1] == '#'){
                if(s[h][w+1] == '.' && s[h+2][w+1] == '.' && s[h+1][w] == '.' && s[h+1][w+2] == '.'){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
<?php
  while($n = fgets(STDIN)) {
    $count=0;
    for($i=0;$i<=9;$i++) {
      for($j=0;$j<=9;$j++) {
        for($k=0;$k<=9;$k++) {
          if(0 <= $n-$i-$j-$k && $n-$i-$j-$k <= 9) {
	    $count++;
	  }
	}
      }
    } 
    echo $count."\n";
  }

Measured memory_bytes: 15300
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: usize = read();
    let _: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    println!(
        "{}",
        if s[..a].iter().all(|&c| c.is_digit(10))
            && s[a] == '-'
            && s[a + 1..].iter().all(|&c| c.is_digit(10))
        {
            "Yes"
        } else {
            "No"
        }
    );
}

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


Measured memory_bytes: 4352
def main():
    import sys
    input = sys.stdin.readline
    
    def Warshall_Floyd(d):
        for k in range(n):
            for i in range(n):
                for j in range(n):
                    d[i][j] = min(d[i][j], d[i][k]+d[k][j])
        return d
      
    n, m, l = map(int, input().split())
    f_inf = float('inf')
    dist = [[f_inf]*n for _ in range(n)]
    for _ in range(m):
        a, b, c = map(int, input().split())
        dist[a-1][b-1] = c
        dist[b-1][a-1] = c

    Warshall_Floyd(dist)

    dist2 = [[f_inf]*n for _ in range(n)]
    for i in range(n):
        for j in range(n):
            if dist[i][j] <= l:
                dist2[i][j] = 1
    
    Warshall_Floyd(dist2)

    q = int(input())
    for _ in range(q):
        s, t = map(int, input().split())
        if dist2[s-1][t-1] == f_inf:
            print(-1)
        else:
          ans = dist2[s-1][t-1]
          print(ans-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 125148
#include <iostream>
#include <math.h>
#include <vector>
#include <cstdlib>

using namespace std;

int main(int argc, const char * argv[]) {
	int N;
	int max = 0;

	cin >> N;
	long int H[N];
	long int count[N];

	for(int i=0; i<N; i++){
		cin >> H[i];
		count[i] = 0;
	}


	for(int j=0; j<N-1; j++){
		if((count[j-1] != 0) && (j > 0)){
			count[j] = count[j-1] - 1;
		}else{
			for(int i=j; i<N-1; i++){
				if(H[i] < H[i+1]){break;}
				else{ count[j]++;}
			}
			if(max < count[j]){
				max = count[j];
			}
		}
	}

	cout << max << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	char ch[105];
	int k;
	cin>>k>>ch;
	int i,len;
	len=strlen(ch);
	for(i=0;i<k&&i<len;++i)
	{
		putchar(ch[i]);
	}
	if(i==k&&i<len)
	puts("...");
	else
	putchar('\n');
	return 0;
}

Measured memory_bytes: 3608
n = int(input())
a = list(map(int, input().split()))

ans = 1000
checkpoint = [a[0]]

for i in range(1, n):
    if a[i] >= a[i - 1]:
        checkpoint.append(a[i])
    else:
        kabu = ans // checkpoint[0]
        ans += kabu * (checkpoint[-1] - checkpoint[0])
        checkpoint = [a[i]]

if checkpoint[-1] >= checkpoint[0]:
    kabu = ans // checkpoint[0]
    ans += kabu * (checkpoint[-1] - checkpoint[0])
    
print(ans)


Measured memory_bytes: 9196
/**
 *    Author:  "Robin Singh" !!!
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     // 0 -> n-1 (i,0,n)
#define bk(i, j, k) for(int i = j-1; i >= k; i--)  // n-1 -> 0 (i,n,0)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0
#define rtn return 
#define nl "\n"      // avoid endl
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const ld eps = 1e-9;
const ll INF = (1LL<<61);
const int inf = (1<<30);
//-------------------------------------------------------------------------------------------------------------
#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }
//-------------------------------------------------------------------------------------------------------------

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, m = -2;
    cin >> n;
    if(! n){
        cout << 0; return 0;
    }
    string s;
    while(n){
        int x = n % m, y = n/m;
        if(x >= 0 && x <= 1){
            s += (x + '0');
            n = y;
        }
        else{
            y++;
            x = n - y*m;
            s += (x + '0');
            n = y;
        }
    }
    reverse(s.begin(), s.end());
    cout << s;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

int main() {
  long long N;
  long long a[200000];
  cin >> N;
  rep(i, N) {
    cin >> a[i];
  }
  sort(a, a+N);
  long long b[400001];
  for(int i = N-1; i >= 0; i--) {
    if(i == N-1) b[0] = a[N-1];
    else {
      b[(N-1-i)*2-1] = a[i];
      b[(N-1-i)*2] = a[i];
    }
  }
  long long sum = 0;
  rep(i, N-1) {
    sum += b[i];
  }
  cout << sum << endl;
  return 0;
}

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

using namespace std;

const int maxn = 100010;

int lowbit(int x) {
	return x & (-x);
}

int n, a[maxn][5], mn[maxn];
int s0[maxn], s1[maxn]; // 1 ~ n

void add(int *s, int p) {
	for (int i = p; i <= n; i += lowbit(i)) {
		s[i] ^= 1;
	}
}

int ask(int *s, int p) {
	if (!p) return 0;
	int ret = 0;
	for (int i = p; i; i -= lowbit(i)) {
		ret ^= s[i];
	}
	return ret;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) mn[i] = 3 * n;
	for (int i = 1; i <= 3; i++) {
		for (int j = 1; j <= n; j++) {
			scanf("%d", &a[j][i]);
			mn[j] = min(mn[j], a[j][i]);
		}
	}
	int ok = 1;
	for (int i = 1; i <= n; i++) {
		if ((i ^ mn[i]) & 1) {
			ok = 0;
		}
		if (a[i][2] != mn[i] + 1 || (a[i][3] != mn[i] + 2 && a[i][1] != mn[i] + 2)) {
			ok = 0;
		}
	}
	if (!ok) {
		puts("No");
		return 0;
	}
	int a0 = 0, a1 = 0, b0 = 0, b1 = 0;
	for (int i = 1; i <= n; i++) {
		if (mn[i] != a[i][1]) {
			if (i & 1) {
				a1 ^= 1;
			} else {
				a0 ^= 1;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		int t = (mn[i] + 2) / 3;
		if (i & 1) {
			b1 ^= ask(s1, n) ^ ask(s1, t);
			add(s1, t);
		} else {
			b0 ^= ask(s0, n) ^ ask(s0, t);
			add(s0, t);
		}
	}
	if ((a0 ^ b1) || (a1 ^ b0)) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
 
  using namespace std;
  long long MOD=1000000007;
  #define IOS() ios_base::sync_with_stdio(0); cin.tie(0);
  typedef long long ll;
  #define pb push_back
  typedef pair<ll,ll> pi;
  ll dp[401][401];
  ll sum[401][401];
  ll a[500];
  int n;

ll find (int l , int r )
{ 
    ll ans=LONG_LONG_MAX;
    // cout<<"ans is "<<ans<<endl;
    if(l==r)
      return dp[l][r]=0ll;

    else if(dp[l][r]!=-1)
      return dp[l][r];

    else
    {
      for(int i=l;i<r;i++)
      {
        ans=std::min(ans, sum[l][r] + find(l,i) + find(i+1,r));
      }
      return dp[l][r]=ans;
    }
}
void preprocess()
{
    for(int i=1;i<=n;i++)
    {
      sum[i][i]=a[i];

      for(int j=i+1;j<=n;j++)
      {
        sum[i][j]=sum[i][j-1]+a[j];
      }
    }
}

int main()
{
  IOS();
  cin>>n;
  
  memset(dp,-1ll ,sizeof dp);

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

  preprocess();

  ll ans=find(1,n);
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 6180
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
void func(int);
int main(void)
{
	int n,i,m,x[101],a;
	scanf("%d",&n);
	for(i=1;i<=n;i++)	scanf("%d",&x[i]);
	scanf("%d",&m);
	for(i=0;i<m;i++)	{
		scanf("%d",&a);
		if(x[a+1]!=x[a]+1 && x[a]!=2019)	x[a]++;
	}
	for(i=1;i<=n;i++)	printf("%d\n",x[i]);
	return 0;
}


Measured memory_bytes: 2712
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  cout << (n-1)*(m-1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
const int maxd = 1e5+10;
char s[maxd];
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    int n,k,ans=0,v;
    scanf("%d%d%s",&n,&k,s);
    for(int i=1;s[i];i++)
    {
        if(s[i]==s[i-1]) ans++;
    }
    printf("%d",min(ans+2*k,n-1));
    return 0;
}

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

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

  cout << max({A, B, C}) * 9 + A + B + C << endl;
  return 0;
}

Measured memory_bytes: 3548
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

bool Dfs(int v,
         const vector<vector<int>>& gr,
         vector<char>& used,
         vector<int>& way) {
  used[v] = true;
  way.push_back(v);

  bool found = false;
  for (int u : gr[v]) {
    if (!used[u]) {
      found = true;
      if (!Dfs(u, gr, used, way)) {
        found = false;
        break;
      }
    }
  }

  return found;
}

int main() {
//  freopen("../Console/1.txt", "rb", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int N, M;
  cin >> N >> M;

  vector<vector<int>> gr(N);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;

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

  vector<char> used(N, false);
  vector<int> way;
  Dfs(0, gr, used, way);
  reverse(way.begin(), way.end());

  for (int u : gr[0]) {
    if (!used[u]) {
      Dfs(u, gr, used, way);
      break;
    }
  }

  cout << way.size() << '\n';
  for (int v : way) {
    cout << v + 1 << ' ';
  }
  cout << '\n';

  return 0;
}


Measured memory_bytes: 12664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  ll s=0;
  for(int i= 1 ; i<=n ; ++i){
    if(!(i%3==0 || i%5==0)) s+=i;
  }
  cout << s;
  return 0;
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}

ll N;

struct Edge{
ll to;
  ll cost;
  Edge(ll to,ll cost):to(to),cost(cost){};
  
};

vector<Edge>G[101000];

ll ans[101000];

bool visited[101000];

void dfs(ll s,ll cost){
if(visited[s]){
  return;
}

  visited[s]=true;
  if(cost%2==0){
ans[s]=0;
  }
else{
ans[s]=1;
}

  for(auto p:G[s]){
    dfs(p.to,p.cost+cost);
  }
}


int main(){
  
  
  cin>>N;
  
  vector<ll>a(N);
  vector<ll>b(N);
  vector<ll>c(N);
  
  rep(i,N){
cin>>a[i]>>b[i]>>c[i];
    G[a[i]-1].push_back(Edge(b[i]-1,c[i]));
    G[b[i]-1].push_back(Edge(a[i]-1,c[i]));
    
  }
  
  dfs(0,0);
  
  rep(i,N){
cout<<ans[i]<<endl;
  }
}



Measured memory_bytes: 11648
// Getting Started - Gratest Common Divisor
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_B
using System;
using System.Linq;

namespace ALDS1_1_B {
	class Program {
		public Program() {}
		
		public static void Main() {
			new Program().Calc();
		}
		
		void Calc() {
			var A = Input				// Array : x, y
					.Split(' ')
					.Select(i => int.Parse(i))
					.ToArray();
			
			Output(gcd(A).ToString());
		}
		
		String Input {
			get {
				return Console.ReadLine();
			}
		}
		
		void Output(String str) {
			Console.WriteLine(str);
		}
		
		int gcd(int[] A) {
			return A[1] == 0 ? A[0] : gcd(new int[] {A[1], A[0] % A[1]});
		}
	}
}

Measured memory_bytes: 9528
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val A, B, C, X = sc.nextInt()
  val matched = for {
    a <- 0 to A
    b <- 0 to B
    c <- 0 to C
    if a * 500 + b * 100 + c * 50 == X
  } yield ()
  println(matched.length)
}


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

int main(void)
{
    int k; cin >> k;
    string s; cin >> s;
    if (s.length() > k) {
        for (int i = 0; i < k; i++)
        {
            cout << s[i];
        }
        cout << "..." << endl;
    }
    else cout << s << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n,k;cin>>n>>k;
  vector<ll>a(n);
  rep(i, n)cin>>a[i];

  // n==k
  if(n==k){
    ll result=1;
    for(auto c:a){
      c = (c+MOD)%MOD;
      result *= c;
      result %= MOD;
    }
    cout<<result<<endl;

    return 0;
  }

  vector<ll>ma, pa;
  for(auto c:a){
    if(c<0)ma.push_back(-c);
    else pa.push_back(c);
  }

  sort(pa.begin(), pa.end());
  sort(ma.begin(), ma.end());

  // -
  if(pa.size()==0 && k%2==1){
    ll result=1;
    rep(i, k){
      result = result*ma[i]%MOD;
    }
    result = (MOD-result)%MOD;
    cout<<result<<endl;

    return 0;
  }

  // else
  vector<ll> results;
  if(k%2==1){
    results.push_back(pa.back());
    pa.pop_back();
  }

  vector<ll>fa;
  while(ma.size()>=2){
    ll x = ma.back();
    ma.pop_back();
    x = x*ma.back();
    ma.pop_back();
    fa.push_back( x );
  }

  while(pa.size()>=2){
    ll x = pa.back();
    pa.pop_back();
    x = x*pa.back();
    pa.pop_back();
    fa.push_back( x );
  }

  sort(fa.begin(), fa.end());
  rep(i, k/2){
    results.push_back(fa.back());
    fa.pop_back();
  }

//  sort(results.begin(), results.end());
//  cout<<results.size()<<endl;
//  cout<<results[0]<<' '<<results[1]<<' '<<results[2]<<' '<<results[99994-3]<<' '<<results[99994-2]<<' '<<results.back()<<endl;

  ll result=1;
  for(auto c:results){
    ll x = c%MOD;
    result = (result*x)%MOD;
  }
  cout<<result<<endl;

  return 0;
}



Measured memory_bytes: 8964
package main

import (
	"fmt"
	"math"
)

func main() {
	var a,b,k float64
	fmt.Scan(&a,&b,&k)
	
	t := math.Min(a,k)
	a -= t
	k -= t
	
	t = math.Min(b,k)
	b -= t
	k -= t
	
	fmt.Printf("%d %d",int(a),int(b))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

int N;
int dp[105];
int h[105];

int main(){ 

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

cin>>N;

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

dp[0]=h[0];
for(int i=1; i<N; i++){
	if(h[i]>h[i-1]){
		dp[i]=dp[i-1]+h[i]-h[i-1];
	}else{
		dp[i]=dp[i-1];
	}
}

cout<<dp[N-1]<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

int arr[100007];
int main(){
	Lancer();
	ll k, n, res = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++){
		cin >> arr[i];
	}
	sort(arr, arr + n);
	int j = n - 1;
	while (k--)
	{
		res += arr[j--]; 
	}
	cout << res;
	cout << endl;
	return 0;
}


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

int main() {
  int X;
  cin >> X;
  if(X >= 30) {
    cout << "Yes" << endl;
  } else
  {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
using namespace std;
int main(){
  int k,s;
  cin >>k>>s;
  long long int ans=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
        if((s-i-j)<=k&&(s-i-j)>=0) ans++;
      }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

string sort(string str){
	int len, len2 = 0;
	char work; 

	len = str.length();

	// 両端から交換
	for(len = len - 1; len > len2; len--, len2++){
		work =  str[len];
		str[len] = str[len2];
		str[len2] = work;
	}
	return str;
}

int main(){
	string str;
	cin >> str;
	str = sort(str);
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main{
public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    scan.close();

    StringBuilder sb = new StringBuilder();
    for(int i=0;i<k;i++) {
        sb.append("ACL");
    }
    System.out.println(sb);
}
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef unsigned long long ull;

const int N = int(5e5) + 5;
const int inf = (int)1e9 + 7;

int n;
int f2[N], s[N], ans;
vector < int > g[N];

void dfs1(int v, int p){
  f2[v] = f2[p] + 1;
  for(int i : g[v]){
    if(i != p){
      dfs1(i, v);
    }
  }
}

void dfs2(int v, int p, int f1){
  s[v] = 1;
  for(int i : g[v]){
    if(i != p){
      dfs2(i, v, f1 + 1);
      s[v] += s[i];
    }
  }
  if(f2[v] < f1){
    ans = max(ans, s[v]);
  }
}


int main(){
  scanf("%d", &n);
  for(int i = 1; i < n; ++i){
    int x, y;
    scanf("%d %d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs1(n, 1);
  dfs2(1, 1, 1);
  if(ans >= n - ans){
    printf("Snuke");
  } else{
    printf("Fennec");
  }
  return 0;
}


Measured memory_bytes: 25472
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		String X=sc.next();
		String Y=sc.next();
		int x=X.compareTo(Y);
		if(x<0)System.out.println("<");
		else if(x==0)System.out.println("=");
		else System.out.println(">");
	}
}


Measured memory_bytes: 21844
#include<iostream>

using namespace std;

int main(){

	int a ,b ,c;

	cin >> a >> b >> c;

	//cout << /*出力をここに入力*/ << endl;

	if (a < b && b < c){

		cout << "Yes" << endl;

	}else{

		cout << "No" << endl;

}
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define pb push_back
#define mp make_pair
bool isPrime(ll n) 
{ 
    
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
   
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
int minthis(int a, int b){
if(a < b){
return a;
}
return b;
}
int maxthis(int a, int b){
if(a > b){
return a;
}
return b;
}
int gcd(int a, int b){
    if( a<0 ) a = -a;
    if( b<0 ) b = -b;
    while( b!=0 ){
        a %= b;
        if( a==0 ) return b;
        b %= a;
    }
    return a;
}
 
int findLargestDivisor(int n) 
{ 
	int max = 1;
    for (int i = 2; i < n; i++) {        
        if(n %(i) == 0) { 
            max = i;
        } 
    }
    return max;     
} 
 
 
ll power(ll x, ll y)  
{  
    ll temp;  
    if(y == 0)  
        return 1;  
    temp = power(x, y / 2);  
    if (y % 2 == 0)  
        return temp * temp;  
    else
    {  
        if(y > 0)  
            return x * temp * temp;  
        else
            return (temp * temp) / x;  
    }  
}  


void solve(){	
	
	int n;
	cin >> n;
	map<string,int> mp;
	mp["AC"] = 0;
	mp["WA"] = 0;
	mp["TLE"] = 0;
	mp["RE"] = 0;
	for(int i = 0; i < n ; i++){
		string a;
		cin >> a;
		mp[a]++;
	}
	map<string,int>:: iterator it;
	cout << "AC" << " x " <<  mp["AC"]<< "\n";
	cout << "WA" << " x " <<  mp["WA"]<< "\n";
	cout << "TLE" << " x " <<  mp["TLE"]<< "\n";
	cout << "RE" << " x " <<  mp["RE"]<< "\n";
}
  
int main(){ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;    
    //cin >> t;
    while(t--){
		solve();
	}
    return 0; 
}


Measured memory_bytes: 3664
#include <iostream>
#include <math.h>
using namespace std;
  
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数
  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする
  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(array[i], array[j]); }
  } while (i < j);
  swap(array[pivot], array[j]);   //pivotを更新
  return j;
}
/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;
  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}

int N;

int main(){
  scanf("%d", &N);
  int v[N];
  for(int i=0; i<N; i++){
    scanf("%d", &v[i]);
  }
  quick_sort(v, 0, N-1);
  
  double ans=v[0];
  for(int i=1; i<N; i++){
    //printf("%d ", v[i]);
    ans = (ans + v[i])/2;
  }
  printf("%lf", ans);
  return 0;
}
  

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC083_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int N = int.Parse(array[0]);
            int A = int.Parse(array[1]);
            int B = int.Parse(array[2]);

            int ans = 0;

            for (int i = 1; i<= N; i++)
            {
                int sum = 0;
                int num = i;
                while(0 < num)
                {
                    sum += num % 10;
                    num /= 10;
                }

                if (A <= sum && sum <= B)
                {
                    ans += i;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27188
sosu = [2]
A = 10 ** 9 + 7
N = int(input())
man = []
buriburi = 1
n = [0] * 1000

def prime(a):
    flag = 0
    m = a
    for i in range(2,m):
        if m % i == 0:
            flag = 1
            break
    if flag == 0:
        sosu.append(a)

for i in range(3,1001,2):
    prime(i)

for i in sosu:
    for j in range(N,1,-1):
        mod = j
        while mod % i == 0:
            n[i] += 1
            mod = mod // i

for i in n:
    if i != 0:
        buriburi *= i + 1

print(buriburi % A)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set; */
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define nl '\n'
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define debug(x) cerr << (#x) << " is " << (x) << endl;

#ifndef ONLINE_JUDGE
#define cerr if(true)cerr
#endif

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
	}
};
template<typename T>
struct Vec<1, T> : public vector<T> {
	Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
	}
};

ll power(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;  // Change x to x^2
    }
    return res;
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);}

ll modinv(ll a,ll p){return power(a,p-2,p);}


void solve(){
    ll a;
    long double b;
    cin>>a>>b;
    ll ans = floor(1.0*a*b);
    cout<<ans<<endl;
    return ;
}
int main()

{
    IO;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // #endif
    int T=1;
	// cin >> T;
	f(c,0,T){
		solve();
	}
    return 0;
}// make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first false erase double priority_queue


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

int main(){
    int n; cin >> n;
    vector<int> a(n); for (auto &&i : a) cin >> i;
    //
    //
    int right = 1;
    long long ans = 0;
    long long sum = 0;
    sum += a.at(0);
    for (int left = 0; left < n; left++)
    {
        while (right < n && sum + a.at(right) == (sum ^ a.at(right)) )
        {
            sum += a.at(right);
            right++;
        }
        ans += (right - left);
        if(left == right) right++;
        sum -= a.at(left);
    }
    std::cout << ans << endl;
}

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

int main(void){
    int64_t n,m,sum=0,count=0;
    cin>>n>>m;
    vector<pair<int,int>> ab(n);//値段,本数
    for (int i=0;i<n;i++) {
        cin >>ab.at(i).first>>ab.at(i).second;
    }
    sort(ab.begin(),ab.end());
    
    int i=0;
    while (count<m) {
        while  (count<m && ab.at(i).second!=0) {
            sum+=ab.at(i).first;
            ab.at(i).second--;
            count++;
        }
    i++;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    int p=0,w=0,g=0,y=0,ans;
    for (int i=0; i<n; i++){
        string s; cin >> s;
        if (s=="P") p=1;
        else if (s=="W") w=1;
        else if (s=="G") g=1;
        else y=1;
    }
    ans = p+w+g+y;
    cout << (ans==3 ? "Three" : "Four") << endl;
}

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

int main() {
  ll x, y;
  cin >> x >> y;
  int l = 0;
  while (x <= y) {
    ++l;
    x *= 2;
  }
  cout << l << endl;
  return 0;
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"

#define REP(i, n ,N) for(int i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= 0; i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
int inf = 1e9;

const int NODE_SIZE = 201;

int N;   //ノード数
int M;  // エッジ数

int graph[NODE_SIZE][NODE_SIZE];   //ノードの接続関係

int dist[NODE_SIZE];
//幅優先探索 (グラフ: vector)
int bfs_vec(int start){
    queue<int> q; //<コスト, ノード>
    bool visited[NODE_SIZE];
	bool used[NODE_SIZE][NODE_SIZE] = {};
    for(int i=0; i<N; i++) visited[i]=false;    //初期位置を設定
    for(int i=0; i<N; i++) dist[i] = inf;// 最後までinfなら到達不可能
    q.push(start);  //開始ノードを追加
    dist[start] = 1; // 初期状態のコスト
    while(!q.empty()){
        int curNode = q.front();
        int curStep = dist[curNode];
        q.pop();
        REP(nextNode,0,N){
			if(!graph[curNode][nextNode]) continue;
			if(used[curNode][nextNode]) continue;
//			p2(dist[nextNode], curStep);
			if(visited[nextNode] && dist[nextNode] < curStep + 1) {
//				p2(curNode, nextNode);
				return -1;
			}
			used[curNode][nextNode] = used[nextNode][curNode] = true;
            if(!visited[nextNode]){     //未到達のノードだけpush.
                q.push(nextNode);
                dist[nextNode] = curStep + 1;
				visited[nextNode] = true;
            }
        }
    }
//	REP(i,0,N){
//		cout << dist[i] << " ";
//	}
//	cout << endl;

	return *max_element(dist, dist+N);
}

string s;
int ans = -1;
int main(){
	cin >> N;
	REP(i,0,N){
		cin >> s;
		REP(j,0,N){
			graph[i][j] = (s[j] == '1');
		}
	}
	REP(i,0,N){
		ans = max(ans, bfs_vec(i));
	}

	p(ans);
	return 0;
}

Measured memory_bytes: 512
n,x,m=map(int,input().split())
ans=x
totol=n
was=[0]*m
was[x]=1
cs=x
cr=1
n-=1
seq=[x]
while n>0:
	cs=cs*cs%m
	seq.append(cs)
	cr+=1
	n-=1
	if was[cs]:
		if cs<=1:exit(print(ans+cs*(n+1)))
		res=sum(seq[:was[cs]-1])
		totol-=was[cs]-1
		loop=cr-was[cs]
		sumonloop=sum(seq[was[cs]:cr])
		res+=totol//loop*sumonloop
		for i in range(totol%loop):
			res+=cs
			cs=cs*cs%m
		exit(print(res))
	else:was[cs]=cr
	ans+=cs
print(ans)
'''
492443256176507
9 2 7

26

'''

Measured memory_bytes: 13636