akhauriyash/Code-Regression huggingface dataset:
#include <atcoder/all>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <unordered_map>
#include <cstdio>
#include <climits>
using namespace std;
using namespace atcoder;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

ll n;
vector<pair<ll, int>> vec;
ll ans = LLONG_MAX;

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n;
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	ll p = n;
	for (ll i = 2; i <= sqrt(n); i++) {
		int cnt = 0;
		while (p%i == 0) {
			cnt++;
			p /= i;
		}
        if(cnt==0)continue;
		if (i == 2)vec.push_back(make_pair(i, cnt + 1));
		else vec.push_back(make_pair(i, cnt));
	}
	if (1 < p)vec.push_back(make_pair(p, 1));
	int k = (int)vec.size();
	for (int i = 0; i < (1 << k); i++) {
		ll x = 1, y = 1;
		for (int j = 0; j < k; j++) {
			if (i&(1 << j))x *= pow(vec[j].first, vec[j].second);
			else y *= pow(vec[j].first, vec[j].second);
		}
        if (LLONG_MAX / x * gcd(x, y) < y)continue;
		pair<ll, ll> s = crt(vector<ll>{ (ll)0, y - 1 }, vector<ll>{ x, y });
		if (s != make_pair((ll)0, (ll)0)) {
			if (s.first == 0)ans = min(ans, s.second);
			else ans = min(ans, s.first);
		}
		s = crt(vector<ll>{ (ll)0, x - 1 }, vector<ll>{ y, x });
		if (s != make_pair((ll)0, (ll)0)) {
			if (s.first == 0)ans = min(ans, s.second);
			else ans = min(ans, s.first);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4084
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define int long long
using namespace std;

signed main() {
	int a;
	cin >> a;
	int b, c, d; b = 10000000; c = -10000000; d = 0;
	for (int e = 0; e < a; e++) {
		int f;
		cin >> f;
		d += f;
		b = min(b, f);
		c = max(c, f);
	}
	cout << b <<" "<< c << " " << d << endl;
}

Measured memory_bytes: 3072
n = int(input())
li = []
for i in range(n):li.append(int(input()))
li.sort()
if sum(li) % 10 == 0:
    for k in range(n):
        if (sum(li)-li[k]) % 10 != 0:
            print(sum(li)-li[k])
            exit()
else:
    print(sum(li))
    exit()
print("0")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int mod=1e9+7;
const int INF =LONG_LONG_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int n,k;
   cin>>n>>k;
   int h[n];
   for(int i=0;i<n;i++)
    cin>>h[i];
   vector<int>dp(n,1e18);
   dp[0]=0;
   dp[1]=abs(h[1]-h[0]);
   for(int i=2;i<n;i++)
   {
       for(int j=1;j<=k;j++)
       {
           if(i-j<0)break;
           dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
       }
   }
   cout<<dp[n-1]<<endl;
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	
	long long arr[n];
	
	for(int i= 0; i < n; i++)
	{
		cin >> arr[i];
	}
	
	long long lcm = arr[0];
	long long temp;
	for(int i = 1; i <n; i ++){
		long long tgcd = __gcd(arr[i], lcm);
		lcm = max(lcm,arr[i])/tgcd * min(lcm,arr[i]);
//		cout << tgcd << endl << endl;
	}
	
	cout << lcm << endl;
	
	return 0;
}

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

int main() {
    int N;
    std::cin >> N;

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

    bool p[N] = {false};
    int cur = 0, cnt = 0;
    p[cur] = true;
    while (true) {
        if (cur == 1) {
            std::cout << cnt << std::endl;
            return 0;
        }

        cur = a[cur] - 1;
        if (p[cur]) {
            std::cout << -1 << std::endl;
            return 0;
        }

        p[cur] = true;
        ++cnt;
    }

    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#define N (300000+1000)
using namespace std;

struct Edge{int to,next;}edge[N<<1];
int head[N],num_edge,Maxdep[N],size[N],sum,n,u,v;
long long ans;
char s[N];

void add(int u,int v)
{
	edge[++num_edge].to=v;
	edge[num_edge].next=head[u];
	head[u]=num_edge;
}

void Dfs1(int x,int fa)
{
	size[x]=(s[x]=='1');
	for (int i=head[x]; i; i=edge[i].next)
		if (edge[i].to!=fa)
		{
			Dfs1(edge[i].to,x);
			size[x]+=size[edge[i].to];
			Maxdep[x]=max(Maxdep[x],Maxdep[edge[i].to]+1);
		}
}

void Dfs2(int x,int fa,int maxdis)
{
	int l=(s[x]=='1'?0:(1<<30)), r, max1=maxdis, max2=0;
	if (sum-size[x]) l=min(l,maxdis);
	for (int i=head[x]; i; i=edge[i].next)
		if (edge[i].to!=fa)
		{
			if (Maxdep[edge[i].to]+1>max2) max2=Maxdep[edge[i].to]+1;
			if (max2>max1) swap(max1,max2);
			if (size[edge[i].to]) l=min(l,Maxdep[edge[i].to]+1);
		}
	if (max1==max2) r=max2-1;
	else if (max1==max2+1) r=max2;
	else r=max2+1;
	if (l<=r) ans+=r-l+1;
	for (int i=head[x]; i; i=edge[i].next)
		if (edge[i].to!=fa)
		{
			if (Maxdep[edge[i].to]+1!=max1) Dfs2(edge[i].to,x,max1+1);
			else Dfs2(edge[i].to,x,max2+1);
		}
}

int main()
{
	scanf("%d",&n);
	for (int i=1; i<n; ++i)
	{
		scanf("%d%d",&u,&v);
		add(u,v); add(v,u);
	}
	scanf("%s",s+1);
	for (int i=1; i<=n; ++i)  sum+=(s[i]=='1');
	Dfs1(1,0); Dfs2(1,0,0);
	printf("%lld\n",ans+1);
}

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

int main(){
	string str;
	cin >> str;
	for(int i=0;i<str.size();++i){
		if(str[i] == 'B'){
			if(i != 0){
				str.erase(i-1, 2);
				i -= 2;
			}
			else{
				str.erase(i, 1);
				--i;
			}
		}
	}
	cout << str << endl;
	return 0;
}

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

typedef long long ll;

ll mod = pow(10, 9) + 7;
int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    ll ans = 0;
    for(int h = 0; h < 60; h++) {
        ll x = 0;
        for(int i = 0; i < N; i++) {
            if(A.at(i) >> h & 1) {
                x++;
            }
        }
        ll now = (x * (N - x)) % mod;
        for(int i = 0; i < h; i++) {
            now = (now * 2) % mod;
        }
        ans += now;
        ans = ans % mod;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll n, a, b;
  cin >> n >> a >> b;

  cout << (a * n > b ? b : n * a) << "\n";
}

Measured memory_bytes: 256
function main(arg){
  arg = arg.split(' ');
  var count = 0;
  var mon = arg[0];
  var sv = arg[1];
  while (mon > 0) {
  	mon = mon - sv;
    count++;;
  }
  console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	h := sc.nextInt()
	n := sc.nextInt()
	sum := 0
	for i := 0; i < n; i++ {
		sum += sc.nextInt()
	}
	if h <= sum {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}
}

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 1152
import sys
input = sys.stdin.readline


def main():
    A, B, C = map(int, input().split())
    if A == B and A != C:
        print("Yes")
    elif A == C and A != B:
        print("Yes")
    elif B == C and A != B:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  vector<int> road(N);
  for(int i = 0; i < M;i ++){
    int a,b;
    cin >>a >>b;
    road.at(a-1)++;
    road.at(b-1)++;
  }
  
  for(int i = 0; i < N; i++){
    cout << road.at(i) << endl;
  }
  
  return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define pb push_back
#define FR first
#define SC second
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vl >
#define vb vector<bool>
#define vbb vector< vb >
#define vpl vector<pll>
#define vpll vector< vpl >

void DFS(ll u, vll &adj, vb &vis, ll &c)
{
    c++;
    vis[u] = true;
    for(auto v : adj[u])
    {
        if(!vis[v])
            DFS(v, adj, vis, c);
    }
}
void solve()
{
    ll n, m;
    cin>>n>>m;
    vll adj(n);
    for(ll i = 0; i < m; i++)
    {
        ll x, y;
        cin>>x>>y;
        x--;y--;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    vb vis(n, false);
    ll res = 0;
    for(ll i = 0; i < n; i++)
    {
        if(!vis[i])
        {
            ll c = 0;
            DFS(i, adj, vis, c);
            res = max(res, c);
        }
    }
    cout<<res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 26620
a, b = map(int, input().split())

import fractions
g = fractions.gcd(a, b)

import math

def div(m):
    d = {}
    temp = int(math.sqrt(m))+1
    for i in range(2, temp):
        while m%i== 0:
            m //= i
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
    if d == {}:
        d[m] = 1
    else:
        if m in d:
            d[m] += 1
        elif m != 1:
            d[m] =1
    return d

d = div(g)
#print(d)
if 1 not in d:
    ans = len(d)+1
else:
    ans = 1
print(ans)


Measured memory_bytes: 64236
N = int(input())
A = list(map(int, input().split()))
countUp = 0
sumA = sum(A)
minA = 2020202020 * N
for x in range(N):
    countUp += A[x]
    sumA -= A[x]
    minA = min(minA, abs(countUp - sumA))
print(minA)


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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<vector<int>> dp(n+1, vector<int>(n+1,0));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (s[i] == s[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
    }
  }

  int res = 0;

  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (i >= j) continue;
      res = max(res, min(dp[i][j], j - i));
    }
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 98176
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

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

        //lの次にkをする
        int t[3] = {};
        for (int k = 0; k < 3; k++) {
            for (int l = 0; l < 3; l++) {
                if (k == l) continue;
                t[k] = max(t[k], s[l] + a[k]);
            }
        }
        for (int k = 0; k < 3; k++) {
            s[k] = t[k];
        }
    }

    cout << max(max(s[0], s[1]), s[2]) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

const int maxn = 100005;
int f[maxn];
LL d[maxn];
int N,M;

int finds(int x,LL &temp){
    if(f[x] != x){
        int root = finds(f[x],temp);
        temp += d[x];
        d[x] = temp;
        f[x] = root;
        return root;
    }
    else{
        temp = 0;
        return x;
    }
}


int main()
{
    cin >> N >> M;
    _for(i,0,maxn) {
        f[i] = i;
    }
    int ok = 1;

    //cout << f[1] << endl;

    _for(i,0,M){
        int l,r,dd;
        scanf("%d %d %d",&l,&r,&dd);
        LL ll = 0,rr = 0;
        int rootr = finds(r,rr);
        int rootl = finds(l,ll);
        //cout << rootl << " "<<rootr << endl;
        if(rootr == rootl){
            if(d[r] - d[l] != dd) {ok = 0;break;}
        }
        else{
            LL d1 = d[l];
            LL d2 = d[r];
            if(d1+dd < d2){
                d[rootl] = d2 - dd - d1;
                f[rootl] = rootr;
            }
            else{
                d[rootr] = dd + d1 -d2;
                f[rootr] = rootl;
            }
        }
    }


    //_for(i,0,4){
        //cout << f[i] << " "<<d[i] << endl;
    //}


    if(ok) cout <<"Yes" << endl;
    else cout <<"No"<<endl;
    return 0;
}

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

int main()
{
	int a, b, i;
	cin>>a>>b;
	string s;
	getline(cin, s);
	getline(cin, s);

	if(s.at(a)!='-'){
		cout << "No" << endl;
		return 0;
	}
	
	for(i=0;i<a+b-1;i++){
		if(i==a)continue;
		if(s.at(i)<'0' || s.at(i)>'9'){
			cout << "No" << endl;
			return 0;
		}
		//cout << "hello" << endl;
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

bool dp[53][1000][1000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, sum = 0;
    cin >> N;
    vector<int> T(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i];
        sum += T[i];
    }
    dp[0][0][0] = true;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 1000; j++) for (int k = 0; k < 1000; k++) {
            if (!dp[i][j][k]) continue;
            int nj = j+T[i], nk = k+T[i];
            if (nj < 1000) dp[i+1][nj][k] = true;
            if (nk < 1000) dp[i+1][j][nk] = true;
            dp[i+1][j][k] = true;
        }
    }
    int ans = 3000;
    for (int i = 0; i < 1000; i++) for (int j = 0; j < 1000; j++) {
        if (!dp[N][i][j]) continue;
        int maxi = max(i, j);
        maxi = max(maxi, sum-i-j);
        ans = min(ans, maxi);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35520
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
 
int main(){
    int N,M,A=0,b,c=0;
    cin >> N>>M ;
 M=M*2+1;
  if(M>=N){
   cout <<1; 
  }else if(N%M!=0){
    cout << N/M+1;
  }else{
    cout << N/M;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    long double x,y;
    cin>>x>>y;
    cout<<(ll)(log2(y)-log2(x)+1)<<endl;
    return 0;
}

Measured memory_bytes: 384
use std::io::{stdin, Read};
use std::str::FromStr;

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

fn main() {
    let s: String = read().unwrap();
    if s == String::from("ABC") {
        println!("ARC");
    } else {
        println!("ABC");
    }
}


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

using namespace std;

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

	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
	int n, prime[10000], cnt = 1;
	prime[0] = 2;
	for (int i = 3; cnt < 10000; i += 2){
		int k = 0;
		for (int j = 3; j <= sqrt(i); j++) {
			if (i % j == 0){
				k = 1;
				break;
			}
		}
		if (!k) {
			prime[cnt] = prime[cnt - 1] + i;
			cnt++;
		}
	}
	while (1){
		cin >> n;
		if (!n) break;
		cout << prime[n - 1] << endl;
	}
}

Measured memory_bytes: 1196
#include <iostream>

using lint = long long;

void solve() {
    int n;
    std::cin >> n;

    lint p = 0, sum = 0;
    while (n--) {
        lint x;
        std::cin >> x;

        lint d = std::max(0LL, p - x);
        sum += d;
        p = x + d;
    }

    std::cout << sum << "\n";
}

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

    solve();

    return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int count=0;
  for(int i=0;i<N-1;i++){
    for(int j=i;j<N-1;j++){
      count+=vec.at(i)*vec.at(j+1);
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3592
n, m = gets.chomp.split(' ').map(&:to_i)

bridges  = Array.new(m, nil)
uf       = Array.new(n+1){|index| index}
uf_sizes = Array.new(n+1, 1)
results  = Array.new

for i in 1..m do
  a, b = gets.chomp.split(' ').map(&:to_i)
  bridges[i-1] = [a,b]
end

bridges.reverse!

def root(array, pos)
  routes = []
  while array[pos] != pos do
    routes.push(pos) # 経路記録
    pos = array[pos]
  end
  for r in routes do
    array[r] = pos
  end
  pos
end

islands = n*(n-1)/2

for (l,r) in bridges do

  results.push(islands)

  # 左右の根を求める
  l = root(uf, l)
  r = root(uf, r)

  # 根が異なっていれば
  if l != r then

    # 「不便さ」減少
    islands -= (uf_sizes[l]*uf_sizes[r])

    # 左の根を右の根につなげる
    uf[l] = r
    uf_sizes[r] += uf_sizes[l] # 島群のサイズ
    uf_sizes[l] = 0
  end
end

for i in results.reverse do
  print "#{i}\n"
end


Measured memory_bytes: 16180
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <string>
#include <chrono>
#include <queue>
#include <random>
#include <cassert>
#include <numeric>

using namespace std;

#define sqr(x) x * x
#define all(x) x.begin(), x.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
typedef long long ll;

template<typename T>
void print(vector<T>& a) {
	for (T e : a)
		cout << e << " ";
}

template<typename T>
void print(vector<vector<T>>& a) {
	for (int i = 0; i < a.size(); ++i) {
		for (int j = 0; j < a[i].size(); ++j)
			cout << a[i][j] << " ";
		cout << endl;
	}
}

void solve() {
	int x, y;
	cin >> x >> y;
	if (x == y && x == 1) {
		cout << 1000000 << endl;
	}
	else {
		int cnt = 0;
		if (x == 1)
			cnt += 300000;
		else
			if (x == 2) {
				cnt += 200000;
			}
			else {
				if (x == 3) {
					cnt += 100000;
				}
			}
		if (y == 1)
			cnt += 300000;
		else
			if (y == 2) {
				cnt += 200000;
			}
			else {
				if (y == 3) {
					cnt += 100000;
				}
			}
		cout << cnt << endl;
	}
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int A, B, H;
	cin >> A >> B >> H;
	OUT((A + B)*H / 2);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int n;
    cin >> n;
    vector<int> ans;
    int cnt = 0;

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

    while(n != 0){

        if(abs(n) %2 == 1){
            ans.pb(1);
            if(cnt%2 == 0){
                n -= 1;
            }
            else{
                n -= (-1);
            }
        }
        else{
            ans.pb(0);
        }
        n /= 2;
        cnt++;
    }

    for(int i = ans.size() - 1;i >= 0;i--){
        cout << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin>>S;
    if(S[2]==S[3]&&S[4]==S[5]){
        cout<<"Yes"<<endl;        
    }
    else{
        cout<<"No"<<endl;
    }
}


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

int main(){
	int a[10] ,b[10], c[10];

	for(int i = 0; i < 7; i++){
		cin>>a[i]>>b[i];
		c[i] = a[i] - b[i];
		if(c[i] < 0) c[i] = c[i] * -1;
	}

	for(int i = 0; i < 7; i++){
		cout<<c[i]<<endl;
	}
	return 0;
}



Measured memory_bytes: 3108
#include <iostream>

using namespace std;

long gcd(long a, long b)
{
  long m, n;
  if (a > b) {
    m = a;
    n = b;
  } else {
    m = b;
    n = a;
  }

  long tmp;
  while (n != 0) {
    tmp = n;
    n = m % n;
    m = tmp;
  }

  return m;
}

long lcm(long a, long b, long _gcd = -1)
{
  if (_gcd == -1) {
    _gcd = gcd(a, b);
  }
  
  return a * (b / _gcd);
}

int main(int argc, char const* argv[])
{
  long a, b, _gcd, _lcd;
  while (cin >> a >> b) {
    _gcd = gcd(a, b);
    _lcd = lcm(a, b, _gcd);
    cout << _gcd << " " << _lcd << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int H,W,K;
    cin >> H >> W >> K;
    vector<string> S(H);
    rep(i,H) cin >> S[i];
    vector<string> Sd(H);
    ll ans = 0;
    for(int i=0;i<(1<<H);i++){
        for(int j=0;j<(1<<W);j++){
            ll cnt = 0;
            rep(x,H) Sd[x]=S[x];
            for(int bit=0;bit<H;bit++){
                if(((1<<bit)&i)){
                    rep(w,W) Sd[bit][w]='.';
                }
            }
            for(int bit=0;bit<W;bit++){
                if(((1<<bit)&j)){
                    rep(h,H) Sd[h][bit]='.';
                }
            }
            rep(y,H)rep(x,W){
                if(Sd[y][x]=='#') cnt++;
            }
            if(cnt==K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int search(vector<int> &a, int num, int i) {
    int next,nextnum;
	if (num == 0)return 1;
	if (i == (int)a.size())return 0;
	else {
	    next = i + 1;
	    nextnum = num - a[i];
		return max(search(a, nextnum,next), search(a, num, next));
	}
}

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

	int q;
	cin >> q;
	int t;
	for (int i = 0; i < q; i++) {
		cin >> t;
		if (search(a, t, 0)) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}

}


Measured memory_bytes: 3108
while(True):
	counter=0
	try:
		date=int(input())
	except:
		break
	
	for i in range(10):
		for j in range(10):
			for k in range(10):
				for l in range(10):
					if(date==(i+j+k+l)):
						counter+=1
	
	print(counter)

Measured memory_bytes: 6720
#include<iostream>
using namespace std;
int main(){
	long long n,a[10001],i,j,min,max,gou=0;
	cin>>n;
	min=1000000;
    max=-1000000;
	for(i=1;i<=n;i++){
		cin>>a[i];
        gou+=a[i];
		if(a[i]>max){
			max=a[i];
		}
		if(a[i]<min){
			min=a[i];
		}
	}
	cout<<min<<" "<<max<<" "<<gou<<endl;
	return 0;
}


Measured memory_bytes: 3192
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.*;

import static java.lang.Math.*;
//Area of Polygon
public class Main{
	static PrintWriter out = new PrintWriter(System.out);
	static double[][] ple = new double[20][2];
    static int count = 0;
    public static void main(String[] args) {       
        input();
        output();
        out.flush();
       
      
    }
    static void input(){
    	Scanner sc = new Scanner(System.in);
    	for(int i = 0;sc.hasNext();i++){
            String s[] = sc.next().split(",");
            ple[i][0]=Double.parseDouble(s[0]);
            ple[i][1]=Double.parseDouble(s[1]);
            
            count = i+1;
        }
    	
    }
    static void output(){
    	
    	 double a = 0;
         for(int i=0;i<count;i++){
             double x1 = ple[i][0];
             double y1 = ple[i][1];
             double x2 = ple[(i+1)%count][0];
             double y2 = ple[(i+1)%count][1];
             a += x1*y2;
             a -=x2*y1;
         }
         double temp = abs(abs(a/2));
         out.println(new DecimalFormat("#0.000000").format(temp));
    }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;
const ll MOD=1e9+7;

int main() {
    int h,w;
    cin>>h>>w;
    ll dp[h+1][w+1];
    memset(dp,0,sizeof(dp));
    char a[h+1][w+1];
    rep(i,h){
        rep(j,w){
            cin>>a[i+1][j+1];
        }
    }
    dp[1][1]=1;
    for (int i=1;i<h+1;i++){
        for (int j=1;j<w+1;j++){
            if (i==1 && j==1){
                continue;
            }
            else{
                if (a[i][j]=='#'){
                    dp[i][j]=0;
                }
                else{
                    dp[i][j]=dp[i-1][j]+dp[i][j-1];
                    dp[i][j]%=MOD;
                }
            }
        }
    }
    cout<<dp[h][w]<<endl;

    return 0;
}

Measured memory_bytes: 9088
#include<iostream>
using namespace std;
bool BinarySearch(int A[],int n,int key)
{
	int right=n,left=0,mid;
	while(right>left)
	{
		mid = (right+left)/2;
		if(A[mid]==key)
		{
			return true;
		}
		else if(A[mid]<key)
		{
			left = mid+1;	
		}
		else if(A[mid]>key)
		{
			right = mid;	
		}
	}
	return false; 
}
int main()
{
	int n,S[100005],m,s[50005],count =0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>S[i];
	}
	cin>>m;
	for(int i=0;i<m;i++)
	{
		cin>>s[i];
		if(BinarySearch(S,n,s[i]))
		{
			count++;
		}
	}
	cout<<count<<endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
   
#define PutChar(c) ; *p = (char)(c); ++p;
   
#define MAX_N (2000001)
#define MAX_Ai (10001)
#define STR_SIZE (10000010)
   
int getNum(void);
void putNum(int n);
void CountingSort(int A[], int B[], int k, int len);
   
int A[MAX_N];
int B[MAX_N];
char str[STR_SIZE];
char *p = str;
   
int main(void) {
    register int i;
    int n;
   
    fread(str, 1, STR_SIZE, stdin);
       
    n = getNum();
    for (i = 1; i <= n; ++i) {
        A[i] = getNum();
    }
       
    CountingSort(A, B, MAX_Ai, n);
       
    p = str;
    --n;
    for (i = 1; i <= n; ++i) {
        putNum(B[i]);
        PutChar(' ');
    }
    putNum(B[i]);
    PutChar('\0');
       
    puts(str);
       
    return 0;
}
   
int getNum(void) {
    int n = 0;
    while ((*p >= '0') && (*p <= '9')) {
        n = n * 10 + (int)(*p - '0');
        ++p;
    }
    ++p;
    return n;
}
   
void putNum(int n) {
    int d;
    if (n < 10) {
        PutChar('0' + n);
        return;
    }
    d = n / 10;
    if (d) putNum(d);
    PutChar('0' + (n - (d * 10)));
}
   
void CountingSort(int A[], int B[], int k, int len) {
    int C[MAX_Ai] = { 0 };
    int i, j;
    for (j = 1; j <= len; ++j) {
        ++C[A[j]];
    }
    for (i = 1; i <= k; ++i) {
        C[i] += C[i - 1];
    }
    for (j = len; j > 0; --j) {
        B[C[A[j]]] = A[j];
        --C[A[j]];
    }
}

Measured memory_bytes: 26752
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		scanner.nextLine();
		List<Integer> alList = new ArrayList<>();
		for (int i = 1; i <= M; i++) {
			alList.add(i);
		}

		while (scanner.hasNextLine()) {
			scanner.nextInt();
			String string = scanner.nextLine();
			String[] s = string.split(" ");
			List<String> kIntegers = new ArrayList<>();
			for (String k : s) {
				kIntegers.add(k);
			}
			List<Integer> nothing = new ArrayList<>();
			for (int i = 1; i <= M; i++) {
				if (!kIntegers.contains(String.valueOf(i))) {
					nothing.add(i);
				}
			}

			alList.removeAll(nothing);
		}

		System.out.println(alList.size());
	}
}

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

const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  vector<ll> sum(100);
  rep(i, 101) {
    rep(j, n) { sum[i] += (x[j] - i) * (x[j] - i); }
    //cout << sum[i] << endl;
  }
  ll mn = 1000000000;
  int id = 0;
  rep(i, 100) {
    if (mn > sum[i]) {
      mn = sum[i];
      id = i;
    }
  }
  cout << mn << 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()
{
    int n;
    cin >> n;
    vector<int> v(n+1, 0);
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= n; j += i) {
            v[j] += 1;
        }
    }

    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        ans += v[i] * i;
    }

    cout << ans << endl;
    return 0;
}


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

int main() {
	long long int n,m,g,l;cin>>n>>m;
  	string s,t;cin>>s>>t;
  	g=__gcd(n,m);
  	l=n*m/g;
  	for(long long int i=0;i<g;i++){
      if(s[i*n/g]!=t[i*m/g]){
        cout<<-1<<endl;
        	return 0;
      }
    }
  	cout<<l<<endl;
}
  

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

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

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

    vector<char> T(Q), D(Q);
    for (int i = 0; i < Q; i++) {
        cin >> T[i] >> D[i];
    }

    int Lidx = 0, Ridx = N - 1;
    for (int i = Q - 1; i >= 0; i--) {
        if (T[i] == S[Lidx] and D[i] == 'L') {
            Lidx += 1;
            if (Lidx == N) {
                cout << 0 << endl;
                return 0;
            }
        }

        if (T[i] == S[Lidx - 1] and D[i] == 'R') {
            Lidx = max(0, Lidx - 1);
        }

        if (T[i] == S[Ridx] and D[i] == 'R') {
            Ridx -= 1;
            if (Ridx == -1) {
                cout << 0 << endl;
                return 0;
            }
        }

        if (T[i] == S[Ridx + 1] and D[i] == 'L') {
            Ridx = min(N - 1, Ridx + 1);
        }
    }

    int ans;
    if (Lidx > Ridx) {
        ans = 0;
    } else {
        ans = Ridx - Lidx + 1;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			long a = in.nextLong(), b = in.nextLong();
			int k = in.nextInt();

			for (int i = 0; i < k; i++) {
				if (i % 2 == 0) {
					if (a % 2 == 1) {
						a--;
					}
					b += a/2;
					a /= 2;
				} else {
					if (b % 2 == 1) {
						b--;
					}
					a += b/2;
					b /= 2;
				}
			}

			out.printf("%d %d\n", a, b);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public int[] nextIntArray1Index(int n) {
			int[] res = new int[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public long[] nextLongArray1Index(int n) {
			long[] res = new long[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextLong();
			}
			return res;
		}

		public double[] nextDoubleArray(int n) {
			double[] res = new double[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextDouble();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int arr[n], l[n]{INT_MIN}, r[n]{INT_MIN};
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    for(int i = 1; i < n; i++) {
        l[i] = max(l[i-1], arr[i-1]);
    }
    for(int i = n-2; i >= 0; i--) {
        r[i] = max(r[i+1], arr[i+1]);
    }
    for(int i = 0; i < n; i++) {
        cout << max(l[i], r[i]) << endl;
    }
    return 0;
}


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

int main()
{
    int n;
    map<int,int>num;
    cin>>n;
    int i;
    for(i=1;;i++){
        num[n]++;
        if(num[n]==2) break;
        if(n%2==0) n/=2;
        else n=3*n+1;
    }
    cout<<i<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    int n;
    cin >> n;
    vector <int> a(n),b(n);
    for(int i=0;i<n;++i) {
        cin >> a[i];
        b[i]=a[i];
    }
    int cnt=0;
    sort(b.begin(),b.end());
    if(b[0]!=1) cout << -1 << endl;
    else {
        int j=1;
        for(int i=0;i<n;++i) {
            if(a[i]==j) {
                ++cnt;
                ++j;
            }
        }
        cout << n-cnt << endl;
    }
}




Measured memory_bytes: 1792
import sys
input = sys.stdin.readline


class BIT():
    """区間加算、一点取得クエリをそれぞれO(logN)で答える
    add: 区間[l, r)にvalを加える
    get_val: i番目の値を求める
    i, l, rは0-indexed
    """
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _add(self, i, val):
        while i > 0:
            self.bit[i] += val
            i -= i & -i

    def get_val(self, i):
        """i番目の値を求める"""
        i = i + 1
        s = 0
        while i <= self.n:
            s += self.bit[i]
            i += i & -i
        return s

    def add(self, l, r, val):
        """区間[l, r)にvalを加える"""
        self._add(r, val)
        self._add(l, -val)


n, q = map(int, input().split())
query = [list(map(int, input().split())) for i in range(q)]
bit = BIT(n)

ans = []
for i in range(q):
    if query[i][0] == 0:
        _, l, r, x = query[i]
        bit.add(l-1, r, x)
    else:
        _, i = query[i]
        print(bit.get_val(i-1))


Measured memory_bytes: 26724
#include<stdio.h>
int main()
{
    int N;
    scanf("%d",&N);
    int p[1000];
    int i,sum,s=0;
    for(i=0;i<N;i++){
        scanf("%d",&p[i]);
    }
    int max=0;
    for(i=0;i<N;i++){
        if(p[i]>max){
            max=p[i];
        }
    }
    sum=max/2;
    for(i=0;i<N;i++){
        s=s+p[i];
    }
    s=s-sum;
    printf("%d",s);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll a;
string b;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> a >> b; 
	ll z = 100 * (b[0] - '0') + 10 * (b[2] - '0') + (b[3] - '0');
	ll ans = a * z / 100;
	cout << ans << '\n';
}

// 1000000000000000
// 0123456789012345


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
vector <int> num;
vector <int> cmp;
vector <char> erg2;
int main () {
	num.push_back(0);
	for(int i=1;i<150;i++){
		num.push_back(num[i-1]+i-1);
	}
int odd ,even;
cin>>odd>>even;
cout<<num[odd]+num[even];
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b,c;
    cin >> a >> b >> c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])
  		cout << "YES" << endl; 
  	else
  		cout << "NO" << endl;
	return 0;
}

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

#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
const int M=305;

int n,m,f[M][M],d[M][M];

int read(){
	int x=0,y=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') y=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*y;
}

int main(){
	n=read(),m=read();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			d[i][j]=read();
		}
	}
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			for(int x=1;x<=n;x++){
				for(int y=1;y<=m;y++){
					f[i][j]=max(f[i][j],d[x][y]-i*x-j*y);
				}
			}
		}
	}
	for(int x=1;x<=n;x++){
		for(int y=1;y<=m;y++){
			int now=1e9+7;
			for(int i=0;i<=100;i++){
				for(int j=0;j<=100;j++){
					now=min(now,f[i][j]+i*x+j*y);
				}
			}
			if(now!=d[x][y]){
				printf("Impossible\n");
				return 0;
			}
		}
	}
	printf("Possible\n202 10401\n");
	for(int i=1;i<=100;i++) printf("%d %d X\n",i,i+1);
	for(int i=102;i<=201;i++) printf("%d %d Y\n",i,i+1);
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			printf("%d %d %d\n",i+1,202-j,f[i][j]);
		}
	}
	printf("1 202\n");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    int h,w,k;
    cin >> h >> w >> k;
    int hpush,wpush;
    bool ok=false;
    rep(i,h+1){
        rep(j,w+1){
            hpush = i;
            wpush = j;
            int masu = hpush*w + (wpush*(h-hpush) - wpush*hpush);
            if(masu == k){
                ok =true;
            }
        }
    }
    if(ok) cout << "Yes" <<endl;
    else cout << "No" << endl;
} 

Measured memory_bytes: 3492
//https://atcoder.jp/contests/abc179/tasks/abc179_d
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

const int MAXN=2e5+4;
long long ans[MAXN];//递推答案
long long sum[MAXN];//前缀和

const int MAXK=10+4;
pair<int, int> seg[MAXK];//区间

const int MO=998244353;

int main() {
    int n,k;
    cin>>n>>k;
    for (int i=1; i<=k; i++) {
        cin>>seg[i].first>>seg[i].second;
    }

    //初始化
    ans[1]=1;
    sum[1]=1;

    for (int i=2; i<=n; i++) {
        for (int j=1; j<=k; j++) {
            int l=seg[j].first;
            int r=seg[j].second;

            if (l>=i) {
                continue;
            }
            l=i-l;
            r=max(0, i-r-1);
            ans[i]=(ans[i]+sum[l]-sum[r]+MO)%MO;
        }
        sum[i]=(sum[i-1]+ans[i])%MO;
    }

    cout<<ans[n]<<"\n";

    return 0;
}

Measured memory_bytes: 6756
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
const int n_max = 100010;
const int m_max = 100010;
vector<int> hairu[m_max];
vector<int> deru[m_max];
int v[n_max];

int rec(int x)
{
    if (v[x]!=0) return v[x];
    else if (hairu[x].size()==0) return 0;

    for (auto iter=hairu[x].begin();iter!=hairu[x].end();iter++)
    {
        v[x] = max(v[x], rec(*iter)+1);
    }
    return v[x];
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;cin>>n>>m;

    rep(i,m)
    {
        int a,b;cin>>a >> b;
        a--;b--;
        hairu[b].push_back(a);
        deru[a].push_back(b);
    }
    rep(i,n) v[i] = 0;

    int ans = 0;
    rep(i,n)
    {
        ans = max(ans, rec(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 14592
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

int vs[100000+10];

int main(void) {
  int n, k;
  scanf("%d%d", &n, &k);
  REP(i, n) {
    cin >> vs[i];
  }
  sort(vs, vs + n);
  int res = 2e9;
  REP(i, n) {
    if(i >= k-1) {
      int mini = vs[i-(k-1)];
      int maxi = vs[i];
      res = min(res, maxi-mini);
    }
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 640
n, a, b = gets.chomp("\n").split(" ").map(&:to_i)

result = 0
(1..n).each do |num|
  # a以上b以下
  if num >= a && num <= b
    # 2桁以上だったら1桁ずつ取得して加算
    if num.to_s.length >= 2
      tmp = 0
      num.to_s.chars.each do |c|
        tmp += c.to_i
      end
      if tmp >= a && tmp <= b
        result += num
      end
      next
    else
      result += num
      next
    end
  end
  # bより大きくかつ2桁以上の値
  if num > b && num.to_s.length >= 2
    # 文字列に変換して1桁ずつ取得して加算
    tmp = 0
    num.to_s.chars.each do |c|
      tmp += c.to_i
    end
    if tmp >= a && tmp <= b
      result += num
    end
  end
end
puts result


Measured memory_bytes: 1788
#include <stdio.h>

void trace(int A[],int N);
void insertionSort(int A[],int N);

int main(void){
	int N, i;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	trace(A,N);
	insertionSort(A,N);
	return 0;
}

void trace(int A[],int N) {
	int i;
	for(i=0;i<N;i++) {
		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N) {
	int i,j,v;
	for(i=1;i<N;i++) {
		v=A[i];
		j=i-1;
		while(j>=0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1]=v;
		trace(A,N);
	}
}


Measured memory_bytes: 2100
#input
N, K = map(int, input().split())#0~K-1回目と考える。
s = input() #0~N-1人目と考える。


#output

first_pos = int(s[0:1]) #0人目が○なら1, ×なら0

nowpos = first_pos #今チェックしている立ち方
nowposcount = 0 #1にすると0人目を考えるときにバグる
Accum = [0] * (N+1) #累積和 取り出し方は[まとまり個数目] 要素数はまとまりの個数+1
nowRuisekiCount = 1 #何番目のまとまりを見ているか 0~まとまり個数-1
zeroRenzoku = 1

for i in range(len(s)): #0~N-1人目につき、全てをチェックして累積和のリストを作る
    if int(s[i:i+1]) == nowpos: #今チェックしている立ち方と同じ(左の人と同じ)なら
        nowposcount += 1 #左のまとまりの個数を1増やす
        Accum[nowRuisekiCount] = Accum[nowRuisekiCount-1] + nowposcount #まとまりの数字数を入れる
    else:
        nowpos = abs(nowpos - 1)
        nowposcount = 1 #nowposcountは1に戻る
        nowRuisekiCount += 1 #次のまとまりに移ったことになる
        Accum[nowRuisekiCount] = Accum[nowRuisekiCount-1] + nowposcount #まとまりの文字数を入れる(1を入れる)

matomariCount = nowRuisekiCount #まとまりの数

#累積和を出す
if (first_pos == 1) & (matomariCount <= (K*2+1)): #まとまり数がK*2+1以下なら、全部逆立ちさせられる
    print(len(s))
elif (first_pos == 0) & (matomariCount <= (K*2)): #最初が0だと同様にK*2以下なら
    print(len(s))
else:
    #一番最初の合計文字数
    if first_pos == 1:
        maxaccum = Accum[(K*2+1)]
    else: #最初のまとまりが0なら
        maxaccum = Accum[(K*2)]

    #2個目のまとまりからも同様に見ていく
    for i in range(2, matomariCount+1, 1):
        if abs((first_pos - ((i-1)%2))) == 0: #これが0なら左端が0なので右端を落とす
            if i+(K*2)-1 > matomariCount:
                maxaccum = max(maxaccum, Accum[matomariCount]-Accum[i-1])
            else:
                maxaccum = max(maxaccum, Accum[i+(K*2)-1]-Accum[i-1])
        else:
            if i+(K*2) > matomariCount:
                maxaccum = max(maxaccum, Accum[matomariCount]-Accum[i-1])
            else:
                maxaccum = max(maxaccum, Accum[i+(K*2)]-Accum[i-1])
    print(maxaccum)


Measured memory_bytes: 7156