akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vs>		vvs;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/



int main()
{
	int N, M;
	cin >> N >> M;
	vi A(M);
	cin >> A;
	vi num = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

	vs dp(N + 1, "0");
	dp[0] = "";
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < M; j++) {
			if (i - num[A[j]] < 0) continue;
			if (dp[i - num[A[j]]] == "0") continue;
			string n1, n2;
			n1 = dp[i - num[A[j]]] + to_string(A[j]);
			n2 = to_string(A[j]) + dp[i - num[A[j]]];
			if (dp[i].length() < n1.length())
				dp[i] = max(n1, n2);
			else if (dp[i].length() == n1.length())
				dp[i] = max({ n1, n2, dp[i] });
		}
	}


	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 32896
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;


int main()
{
    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll MOD=1e9+7;
#define endl '\n'
#define F first
#define S second
#define pb push_back
const double PI = 3.141592653589793238460;
  void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
    #endif
}
ll dp[100005];ll a[100005];ll n,k;
ll frog(int ind)
{
  if(ind==n)
    return 0;
  if(dp[ind]!=-1)
    return dp[ind];
  ll cost=INT_MAX;
  for(int j=ind+1;j<=min(n,ind+k);j++)
  {
    
       cost=min(cost,abs(a[j]-a[ind])+frog(j));
       
  

  }
  return dp[ind]=cost;



}
  
 

int  main()
{
  c_p_c();
 cin>>n>>k;
 memset(dp,-1,sizeof(dp));

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

  cout<<frog(1);

 

  return 0;

}

Measured memory_bytes: 11420
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<i64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let d: i64 = input();
    let c_vec = input_vec();
    let mut scores: Vec<Vec<i64>> = Vec::new();
    let mut total = 0;
    let mut last = vec![0; 26];
    for _ in 0..d {
        let score = input_vec();
        scores.push(score);
    }
    for day_idx in 0..d {
        let mut max = std::i64::MIN;
        let mut max_idx = 0;
        for contest_idx in 0..26 {
            let mut score = scores[day_idx as usize][contest_idx];
            for i in 0..26 {
                if i == contest_idx {
                    continue;
                }
                score -= c_vec[i] * (day_idx + 1 - last[i]);
            }
            if score > max {
                max = score;
                max_idx = contest_idx;
            }
        }
        total += max;
        last[max_idx] = day_idx + 1;
        println!("{}", max_idx + 1);
    }
    // println!("{}", total);
}


Measured memory_bytes: 2248
#include<stdio.h>

int main()
{
   int h,w,i,j;


for(;;)
{
       scanf("%d %d",&h,&w);
       if(h==0 && w==0)
        break;
   for(i=0;i<h;i++)
   {
       if(i==0||i==h-1)
       {
           for(j=0;j<w;j++)
       {
           printf("#");
       }
       }
      else

      {
          printf("#");
       for(j=0;j<w-2;j++)
       {
           printf(".");
       }
       printf("#");
      }
       printf("\n");
   }

   printf("\n");
}


}



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

//typedef
//------------------------------------------
typedef int64_t LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define EACH(i,c) for(decltype((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) whole(sort, c)
#define RSORT(c) rwhole(sort, c)

//constant
//--------------------------------------------
constexpr double EPS = 1e-10;
constexpr double PI  = M_PI;
constexpr int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}
template<class T,class U> void chmin(T&a,U b){if(b<a)a=b;}
LL gcd(LL a, LL b) { return b?gcd(b,a%b):a;}
LL lcm(LL a, LL b) { return a/gcd(a,b)*b;}

//main code

int main(int argc, char *argv[])
{
	string s;
	cin >> s;
	map<char, int> mp;
	for (auto c : s) {
		mp[c]++;
	}
	for (auto m : mp) {
		if (m.second&1) {cout << "No" << endl;
		return 0;}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
//#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(s, v, it) for (s::iterator it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(#x".in", "r", stdin),freopen(#x".out", "w", stdout)
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 200010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
const double eps = 1e-7 ;
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }
template <class T> void print(T a) { cout << a << endl ; exit(0) ; }
template <class T> void chmin(T &a, T b) { if (a > b) a = b ; }
template <class T> void chmax(T &a, T b) { if (a < b) a = b ; }
template <class T> void upd(T &a, T b) { (a += b) %= MOD ; }
template <class T> void mul(T &a, T b) { a = (ll) a * b % MOD ; }

ll dp[210][N] ;
int s[N] ;
int n, x ;

signed main() {
	scanf("%d%d", &n, &x) ;
	rep(i, 0, n - 1) scanf("%d", &s[i]) ;
	sort(s, s + n) ;
	rep(i, 0, x) dp[0][i] = i ;
	rep(i, 0, n - 1)
	rep(j, 0, x)
	dp[i + 1][j] = (dp[i][j % s[i]] + i * dp[i][j]) % MOD ;
	printf("%lld\n", dp[n][x]) ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/




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

using namespace std;

#define int long long

const int INF = 1e18;

struct Cake {
    int a, b, c;
};

int f(Cake c, int mask) {
    int sum = 0;
    sum -= c.a + c.b + c.c;
    if ((mask >> 0) & 1) {
        sum += 2 * c.a;
    }
    if ((mask >> 1) & 1) {
        sum += 2 * c.b;
    }
    if ((mask >> 2) & 1) {
        sum += 2 * c.c;
    }
    return sum;
}

int get_res(vector <Cake>& cakes, int m) {
    int suma = 0, sumb = 0, sumc = 0;
    for (int i = 0; i < m; ++i) {
        suma += cakes[i].a;
        sumb += cakes[i].b;
        sumc += cakes[i].c;
    }
    return abs(suma) + abs(sumb) + abs(sumc);
}

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

    int n, m;
    cin >> n >> m;
    vector <Cake> cakes(n);
    for (auto& it : cakes) {
        cin >> it.a >> it.b >> it.c;
    }
    int ans = -1;
    for (int mask = 0; mask < (1 << 3); ++mask) {
        sort(cakes.rbegin(), cakes.rend(), [mask](Cake c1, Cake c2) {
            return f(c1, mask) < f(c2, mask); 
        });
        ans = max(ans, get_res(cakes, m));
    } 
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 16
#define mod 1000000007
using namespace std;
inline int read()
{
    int x=0,f=1;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();}
    return x*f;
}
int n,m,a[MN+5],f[1<<MN],p[1<<MN],inv[1<<MN],num[1<<MN];
inline int C(int n,int m){return 1LL*p[n]*inv[m]%mod*inv[n-m]%mod;}
inline void R(int&x,int y){x+=y;x>=mod?x-=mod:0;}
int main()
{
    n=read();m=read();
    p[0]=p[1]=inv[0]=inv[1]=f[0]=1;
    for(int i=2;i<1<<n;++i) p[i]=1LL*p[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
    for(int i=2;i<1<<n;++i) inv[i]=1LL*inv[i-1]*inv[i]%mod;
    for(int i=m;i;--i) a[i]=read();
    for(int i=1;i<=m;++i)
        for(int j=1<<n;j--;) if(f[j])
            for(int k=0;k<n;++k) if(!(j&(1<<k)))
            {
                int left=(1<<n)-a[i]-j;
                if(left+1>=(1<<k)) R(f[j|(1<<k)],1LL*f[j]*C(left,(1<<k)-1)%mod*p[1<<k]%mod);
            }
    for(int i=0;i<1<<n;++i) num[i]=num[i>>1]+(i&1),f[i]=1LL*f[i]*p[(1<<n)-1-i]%mod*((num[i]&1)?mod-1:1)%mod;
    for(int i=0;i<n;++i) for(int j=0;j<1<<n;++j) if(j&(1<<i)) R(f[j^(1<<i)],f[j]);
    printf("%d\n",(1LL<<n)*f[0]%mod);
    return 0;
}


Measured memory_bytes: 1280
from collections import deque
deq = deque()
for _ in range(int(input())):
    e = input()
    if e[0] == 'i':
        deq.appendleft(e[7:])
    elif e[6] == ' ':
        try:
            deq.remove(e[7:])
        except:
            pass
    elif e[6] == 'F':
        deq.popleft()
    else:
        deq.pop()
print(*deq)



Measured memory_bytes: 69736
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int H,W;
string S[410];
int color[410][410];
int now=1;
ll dis[161000];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

void dfs(int y,int x){
    //cout<<now<<" "<<y<<" "<<x<<endl;
  for(int i=0;i<4;i++){
    int nx=x+dx[i],ny=y+dy[i];

    if(nx>=0 && nx<W && ny>=0 && ny<H && color[ny][nx]==-1 && S[y][x]!=S[ny][nx]){
        if(S[ny][nx]=='#'){
            dis[now]++;
            color[ny][nx]=0;
            dfs(ny,nx);
        }else{
            color[ny][nx]=now;
            dfs(ny,nx);
        }
    }
  }
}

int main(){
  for(int i=0;i<410;i++){
      for(int j=0;j<410;j++) color[i][j]=-1;
  }  

  ll ans=0;  
  cin>>H>>W;

  for(int i=0;i<H;i++){
    cin>>S[i];
  }
  for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
          if(S[i][j]=='#' && color[i][j]==-1){
              color[i][j]=0;
              dis[now]++;
              dfs(i,j);
              now++;
          } 
      }
  }

  for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
          //cout<<color[i][j]<<endl;
          ans+=dis[color[i][j]];
      }
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 18560
#include<bits/stdc++.h>
#define maxn 1e9+5
#define ll long long int
using namespace std;
int main(){
ll n;
cin>>n;
vector<ll>h(n),dp(n+1,maxn);
for(int i=0;i<n;i++) cin>>h[i];
dp[0]=0;
for(int i=1;i<n;i++){
    for(auto j:{i-1,i-2}){

        if(j>=0){

            dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));   //this means we take min of current position and (position from past+distance/height to reach current position) and then check for different moves for min value
        }
    }

}
cout<<dp[n-1]<<"\n";







return 0;}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9;
const long long LLINF = 1e18;

int a, b, k;
vector<int> v;
int main() {
    cin>>a>>b>>k;

    REP(i, a, a+k){
        if(CK(i, a, b+1)) v.push_back(i);
    }
    REP(i, b-k+1, b+1){
        if(CK(i, a, b+1)) v.push_back(i);
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    REP(i, 0, v.size()) cout<<v[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll Q,H,S,D,N;
	cin >>Q>>H>>S>>D>>N;
	
	// 解法
	ll N1 = (N/2)*2;
	ll N2 = N%2;
	
	ll ans;
	ans = min(N1*Q*4, min(N1*H*2, min(N1*S, N1*D/2)));
	ans += min(N2*Q*4, min(N2*H*2, N2*S));
	
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    while(true){
        ll n,cnt=0;
        pll M;
        char s[110];
        map<ll,ll> mp,mp1;
        cin>>n;
        if(n==0) break;
        rep(i,n){
            cin>>s[i];
            mp[s[i]-'A']++;
        }
        for(auto i:mp){
            if(M.first<=i.second){
                M=pll(i.second,i.first);
            }
        }
        for(auto i:mp){
            if(M.first==i.second) cnt++;
        }
        if(cnt>1){
            cout<<"TIE"<<endl;
            continue;
        }
        cout<<(char)(M.second+'A')<<" ";
        ll top=0,sec=0;
        rep(i,n){
            if(s[i]==(char)(M.second+'A')) top++;
            else{
                mp1[s[i]-'A']++;
                sec=max(sec,mp1[s[i]-'A']);
            }
            if(top>sec+(n-1-i)){
                cout<<i+1<<endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3120
#pragma GCC optimize ("O3")
    #pragma GCC optimize ("unroll-loops")

    #include "bits/stdc++.h"
    using namespace std;

    #define pb push_back
    #define F first
    #define S second
    #define f(i,a,b)  for(int i = a; i < b; i++)
    #define endl '\n'

    using ll = long long;
    using db = long double;
    using ii = pair<int, int>;

    const int N = 1e5 + 5, LG = 19, MOD = 1e9 + 7;
    const int SQ =225;
    const long double EPS = 1e-7;

    int32_t main(){
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(0);
        cin.tie(0);
    #endif

        int n, k;
        cin >> n >> k;  k= min(k,n);
        vector<int>a(n);
        for(auto & x : a)cin >> x;
        sort(a.begin(),a.end());
        a.resize(n-k);
        if(a.size())
        cout << accumulate(a.begin(),a.end(),0ll) << '\n';
        else
          cout<<0<<'\n';

      return 0;
    }


Measured memory_bytes: 1024
S = input()
T = input()

max = 0
max_i = 0
ans = len(T)
for i in range(len(S) - len(T) + 1):
    cnt = 0
    for j in range(len(T)):
        if S[i + j] == T[j]:
            cnt += 1
    if cnt > max:
        max = cnt
        max_i = i
        ans = len(T) - max

print(ans)


Measured memory_bytes: 8952
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1234567;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
    int N,M;
    cin >> N >> M;
    if(M % 2 == 0) {
        int cnt1 = 1;
        int cnt2 = 1 + M;
        int cnt3 = 2 + M;
        int cnt4 = cnt3 + (M - 1);
        for(int i = 0;i < M;i++) {
            if(i % 2 == 0) {
                cout << cnt1 << " " << cnt2 << endl;
                cnt1++;
                cnt2--;
            }
            else {
                cout << cnt3 << " " << cnt4 << endl;
                cnt3++;
                cnt4--;
            }
        }
    }
    else {
        int cnt1 = 1;
        int cnt2 = 1 + M;
        int cnt3 = 2 + M;
        int cnt4 = cnt3 + (M - 1);
        for(int i = 0;i < M;i++) {
            if(i % 2 == 0) {
                cout << cnt1 << " " << cnt2 << endl;
                cnt1++;
                cnt2--;
            }
            else {
                cout << cnt3 << " " << cnt4 << endl;
                cnt3++;
                cnt4--;
            }
        }
    }
}

Measured memory_bytes: 3636
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.Map                      as M
import           Data.List
import qualified Data.Set                      as S
import           Data.Maybe
import           Data.Ord
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n $ BS.unpack <$> BS.getLine
toPair [x, y] = (x, y)

main = do
  n <- read <$> getLine
  a <- map read . words <$> getLine
  putStrLn $ solve a n

solve :: [Int] -> Int -> String
solve a n | all f a'  = "APPROVED"
          | otherwise = "DENIED"
 where
  a' = filter even a
  f x = or [x `mod` 3 == 0, x `mod` 5 == 0]


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
int n, x;
int a[maxn], b[maxn], d[maxn];
int main()
{
	scanf("%d%d", &n, &x);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &d[i]);
	a[0] = x;
	for(int i = 1; i <= n; ++i)
	{
		if(a[i - 1] >= d[i])
			a[i] = a[i - 1] - d[i];
		else if(d[i] - a[i - 1] <= a[i - 1])
			a[i] = d[i] - a[i - 1];
		else
			a[i] = a[i - 1];
	}
	b[n] = 1;
	for(int i = n - 1; i; --i)
	{
		if(b[i + 1] <= d[i + 1] / 2)
			b[i] = b[i + 1];
		else
			b[i] = b[i + 1] + d[i + 1];
	}
	int q;
	scanf("%d", &q);
	for(int i = 1; i <= q; ++i)
	{
		int p;
		scanf("%d", &p);
		if(b[p] <= a[p - 1])
			puts("YES");
		else
			puts("NO");
	}
	return 0;
}
	

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

#define int long long int


signed main(){

  int h,w,m;
  cin>>h>>w>>m;
  int ans=0;
  vector <pair <int,int> > vh(h+1),vw(w+1);
  map <pair <int,int>,int > m1;
  pair <int,int> p;
  for(int i=0;i<=h;i++){
    vh[i]=make_pair(0,0);
  }
  for(int i=0;i<=w;i++){
    vw[i]=make_pair(0,0);
  }
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    vh[x].first++;
    vh[x].second=x;
    vw[y].first++;
    vw[y].second=y;
    p=make_pair(x,y);
    m1[p]++;
  }
  sort(vh.rbegin(),vh.rend());
  sort(vw.rbegin(),vw.rend());
  // for(int i=0;i<h+1;i++){
  //   cout<<vh[i].first<<" "<<vh[i].second<<endl;
  // }
  // for(int i=0;i<w+1;i++){
  //   cout<<vw[i].first<<" "<<vw[i].second<<endl;
  // }
  int ans1=0,c1=vh[0].second;
  ans1+=vh[0].first;
  ans1+=vw[0].first;
  int c2=vw[0].second;
  ans1-=m1[make_pair(vh[0].second,vw[0].second)];
  for(int i=1;i<w;i++){
    if(vw[i].first==vw[i-1].first){
        p=make_pair(vh[0].second,vw[i].second);
        int temp=vw[i].first+vh[0].first;
        ans1=max(temp-m1[p],ans1);
    }
  }
  int ans2=vw[0].first;
  c1=vw[0].second;
  c2=vh[0].second;
  ans2+=vh[0].first;
  ans2-=m1[make_pair(vh[0].second,vw[0].second)];
  for(int i=1;i<h;i++){
    if(vh[i].first==vh[i-1].first){
        p=make_pair(vh[i].second,vw[0].second);
        int temp=vh[i].first+vw[0].first;
        ans2=max(ans2,temp-m1[p]);
    }
  }
  cout<<max(ans1,ans2)<<endl;
  return 0;
}


Measured memory_bytes: 68972
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    #ss=readline().rstrip()
    #yn(1)
    x=n%1000
    if x>0:
        print(1000-x)
    else:
        print(0)
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16180
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <bitset>
#include <functional>
#include <tuple>
#include <complex>
#include <chrono>
#include <climits>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

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

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
// default_random_engine generator;
// mt19937 rnd(1);


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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    --a; --b; --c; --d;

    string s;
    cin >> s;

    for (int i = a; i < c; ++i) {
        if (s[i] == '#' && s[i + 1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i = b; i < d; ++i) {
        if (s[i] == '#' && s[i + 1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }

    if (c < d) {
        cout << "Yes" << endl;
        return 0;
    }

    for (int i = b; i <= d; ++i) {
        if (s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.') {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}   




Measured memory_bytes: 592
import math

A,B,H,M = map(int,input().split())

co_hour = [math.cos(((H*60 + M)/360 - 1/2) * math.pi) * A , math.sin(((H*60 + M)/360 - 1/2) * math.pi) * A]
co_min = [math.cos(((M/30 - 1/2) * math.pi)) * B, math.sin(((M/30 - 1/2) * math.pi)) * B]

x = co_hour[0] - co_min[0]
y = co_hour[1] - co_min[1]

Answer = math.sqrt(x * x + y * y)

print(Answer)


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


int main(){
int minj,cnt=0,N,A[100];
cin >> N ;

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

for(int i=0;i<N;i++){
     minj = i;
     for(int j=i;j<N;j++){
     	if (A[j] < A[minj]) minj = j;
    }
     if(minj!=i){
      swap(A[minj],A[i]);cnt++;
     }
}
for(int i=0;i<N;i++){cout << A[i] ; if(i!=N-1)cout << " ";}
 cout << endl << cnt << endl;

}

Measured memory_bytes: 3104
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	string s;
	for (; cin >> s;)
	{
		vector<int> a(14);

		stringstream ss;
		ss << s;

		for (int i = 0; i < 5; i++)
		{
			int x;
			ss >> x;

			a.at(x - 1)++;
			if (x == 1)
			{
				a.at(13)++;
			}

			ss.ignore();
		}

		int maxn = 0;
		int cnt = 0;
		int len = 0;
		bool str = false;
		for (int i = 0; i < 14; i++)
		{
			if (a.at(i) > 0)
			{
				maxn = max(maxn, a.at(i));
				if (i < 13)
				{
					cnt++;
				}
				len++;
				if (len >= 5)
				{
					str = true;
				}
			}
			else
			{
				len = 0;
			}
			
		}

		if (maxn == 4)
		{
			cout << "four card" << endl;
		}
		else if (maxn == 3)
		{
			if (cnt == 2)
			{
				cout << "full house" << endl;
			}
			else
			{
				cout << "three card" << endl;
			}
		}
		else if (maxn == 2)
		{
			if (cnt == 3)
			{
				cout << "two pair" << endl;
			}
			else
			{
				cout << "one pair" << endl;
			}
		}
		else
		{
			if (str)
			{
				cout << "straight" << endl;
			}
			else
			{
				cout << "null" << endl;
			}
		}
	}
}



Measured memory_bytes: 3116
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()
def gcd(a,b):
    while b % a:
        a,b = b, a % b
    return a

N,M = IL()
s = S()
t = S()

agcd = gcd(N,M)
bgcd = N//agcd
lcm = N*M//agcd

for i in range(agcd):
    if s[i*lcm//M] == t[i*lcm//N]:
        continue
    else:
        print(-1)
        break
else:
    print(N*M//agcd)

Measured memory_bytes: 12668
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {
	void Solve() {
		UL A, B; cin >> A >> B;
		UL ans = -1;
		for(UL i = 1; i <= 1000; i++) {
			if (i * 8 / 100 == A)
				if (i * 10 / 100 == B) {
					ans = i; break;
				}
		}
		if (ans == -1) cout << -1 << endl;
		else cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <map>
#include <algorithm>  
#include <cmath>
#include <iomanip>
#define ll long long
using namespace std;
ll gcd(ll a,ll b)
{
    if(a<b)
    {
        return gcd(b,a);
    }
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;++i)
    {
        for(ll j=1;j<=n;++j)
        {
            for(ll k=1;k<=n;++k)
            {
                ll a=gcd(j,k);
                a=gcd(a,i);
                sum+=a;
            }
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3632
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<String> set = new HashSet<>();

		for(int i = 0; i < n; i++) {
			set.add(sc.next());
		}

		System.out.println(set.size());

		sc.close();
	}
}


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

int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    rep(i, n){
        int a;
        cin >> a;
        q.push(a);
    }
    rep(i, m){
        int a = q.top();
        q.pop();
        a/=2;
        q.push(a);
    }
    ll ans = 0;
    rep(i,n){
        int a = q.top();
        q.pop();
        ans += a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}

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

    ll N, A, B;
    scan(N, A, B);
    ll ans = (N / (A + B)) * A + min(N % (A + B), A);
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
#define NUM 1000000007
typedef long long int lli;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout <<(min(a, b) + min(c, d)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

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

#define MAX 10000

set<ll> dp1, dp2;

void dp(ll value, set<ll> &sta, set<ll> &stb) {
  for (auto it : sta) {
	stb.insert(it + value);
	stb.insert(it - value);
  }
}

int main(void) {
  ll x, y, ans1, ans2;
  vll vx, vy;
  cin >> s;
  cin >> x >> y;

  while (temp < s.size()) {
	if (s[temp] == 'T') break;
	temp++;
  }
  dp1.insert(temp);

  flag = false;
  FOR(i, temp+1, s.length()) {
	if (s[i] == 'F') {
	  cnt++;
	}
	else {
	  if (cnt == 0) {
		flag = !flag;
		continue;
	  }
	  flag ? vx.push_back(cnt) : vy.push_back(cnt);
	  flag = !flag;
	  cnt = 0;
	}
  }
  flag ? vx.push_back(cnt) : vy.push_back(cnt);

  flag = true;
  FOR(i, 0, vx.size()) {
	flag ? dp2.clear() : dp1.clear();
	flag ? dp(vx[i], dp1, dp2) : dp(vx[i], dp2, dp1);
	flag = !flag;
  }
  if (flag) {
	ans1 = dp1.count(x);
  }
  else {
	ans1 = dp2.count(x);
  }

  dp1.clear();
  dp2.clear();
  dp1.insert(0);

  flag = true;
  FOR(i, 0, vy.size()) {
	flag ? dp2.clear() : dp1.clear();
	flag ? dp(vy[i], dp1, dp2) : dp(vy[i], dp2, dp1);
	flag = !flag;
  }
  if (flag) {
	ans2 = dp1.count(y);
  }
  else {
	ans2 = dp2.count(y);
  }

  if (ans1 > 0 && ans2 > 0) {
	cout << "Yes" << endl;
  }
  else {
	cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 768
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
													 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 998244353;
const ll maxn = 1000005;
const ll mm = 1e+18;
void solve()
{
	int a;
	long double b;
	cin>>a>>b;
	long double ans=(long double)(a)*b;
	long long f=floor(ans);
	pr(f);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}


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

N = int(input())

values = [0]*N
max_value_count = 0
max_value = 0
next_max_value = max_value

for i in range(N):
    in_value = int(input())
    values[i] = in_value

    if in_value == max_value:
        max_value_count = max_value_count + 1
    elif in_value > max_value:
        next_max_value = max_value
        max_value = in_value
        max_value_count = 1
    elif in_value > next_max_value:
        next_max_value = in_value

for row in range(N):
    if values[row] == max_value and max_value_count == 1:
        print(next_max_value)
    else:
        print(max_value)


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  long long money = 1000;
  for(int i = 0; i < N-1; i++) {
    long long stock = 0;
    if(A.at(i) < A.at(i+1)) {
      stock = money / A.at(i);
    }
    money += (A.at(i+1)-A.at(i))*stock;
  }
  cout << money << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
const ll mod = 1e9+7;
const ll mod1 = 998244353;
#define rep(i,a,b) for(ll i=a;i<b;i++)

void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

 ll pow(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}



int main(){
 
  ios_base :: sync_with_stdio(0);
   cin.tie(0);
   ll n,m;
   cin>>n>>m;
   ll a[n];
   ll sum = 0;
   rep(i ,0 ,n){
    cin>>a[i];
    sum += a[i];

   }
   ll ans = 0;
   rep(i ,0 ,n){
    ll t= a[i]*4*m;
    if(t >= sum){
        ans++;
    }
   }
   if(ans >= m)cout<<"Yes";
   else
    cout<<"No";




}


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

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

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

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

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

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll w,h;
	vpll v;
	while(1){
		cin >> h >> w;
		if(h==0 && w==0) break;
		v.pb(m_p(h,w));
	}
	rep(i,SIZE(v)){
		rep(j,v[i].first){
			rep(k,v[i].second){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M, Q = MAP()
abcd = [LIST() for _ in range(Q)]
ans = 0

def DFS(l):
 	global ans 
 	#print(l)
 	if len(l) == N:
 		tmp = 0
 		for a, b, c, d in abcd:
 			a -= 1
 			b -= 1
 			if l[b] - l[a] == c:
 				tmp += d
 		ans = max(ans, tmp)
 	else:
 		for i in range(l[-1], M+1):
 			DFS(l+(i,))

for i in range(1, M+1):
 	DFS((i,))

print(ans)


Measured memory_bytes: 10620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 0x3F3F3F3F;
const int maxn = 1e7 + 555;
const int MOD = 1e9 + 7;
int cnt[maxn];
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (ll j = 1; i * j <= n; j++) {
            cnt[i * j]++;
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += 1ll * i * cnt[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 42688
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

input=sys.stdin.readline
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ab=[0]*(x*y)
c.sort(reverse=True)
for i in range(x):
    for j in range(y):
        ab[y*i+j]=a[i]+b[j]
ab.sort(reverse=True)
d=ab[:k]
ans=[0]*(k*z)
for i in range(len(d)):
    for j in range(z):
        ans[z*i+j]=d[i]+c[j]
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

Measured memory_bytes: 120372
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll INF = 1e9 + 7;
int n, k;
vector<vi> adj;
ll ans;
void dfs(int u, int p, bool q){
    int c;
    if(q){
        q = false;
        c = k-1;
    } 
    else c = k-2;
    for(auto v : adj[u]){
        if(v == p) continue;
        ans *= (ll)c;
        ans %= INF;
        c--;
        dfs(v, u, q);
    }
}
int main(){
    cin >> n >> k;
    ans = k;
    adj.resize(n+1, vi());
    for(int i = 1; i < n; i++){
        int x, y;
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    dfs(1, -1, true);
    cout << ans;
}


Measured memory_bytes: 10368