akhauriyash/Code-Regression huggingface dataset:
// Problem : D - Line++
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define y2 y1919810
typedef pair <int, int> PII;
#define all(x) (x.begin(),  x.end())
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t)  for (int i = s; i <= (int)t; i++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
long long qread() {
	char c = getchar();
	int neg = 1;
	long long val = 0;
	while (c != '-' && !isdigit(c)) c = getchar();
	if (c == '-') c = getchar(), neg = -1;
	while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
	return neg * val;
}
int n, x, y;
int ans[5000];
int main() {
	n = qread(); x = qread(); y = qread();
	repn(i, n) {
		range(j, i + 1, n) {
			int dist = -1;
			if (i <= x) {
				if (j <= x) dist = j - i;
				else if (j >= y) dist = x - i + j - y + 1;
				else dist = min(y - j + 1 + x - i, j - i);
			}
			else dist = min(j - i, i - x + 1 + abs(j - y));
			ans[dist]++;
		//	cerr << i << ' ' << j << ' ' << dist << endl;
		}
	}
	repn(i, n - 1) cout << ans[i] << endl;
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define esort(s) sort((s).begin(),(s).end())

typedef long long ll;
typedef pair<int,int> ipair;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000;
const double PI = acos(-1.0);
const double EPS = 1e-10;

void solve(){
    int N;
    cin>>N;
    int x[N],y[N];
    rep(i,N){
        cin>>x[i]>>y[i];
    }
    vector<int> V(N);
    rep(i,N){
        V[i]=i;
    }
    double sum=0.;
    double div=1.0;
    rep(i,N){
        div*=(i+1);
    }
    do{
        rep(i,N-1){
            sum+=sqrt((x[V[i+1]]-x[V[i]])*(x[V[i+1]]-x[V[i]])+(y[V[i+1]]-y[V[i]])*(y[V[i+1]]-y[V[i]]))/div;
            // cout<<"("<<x[V[i]]<<","<<y[V[i]]<<") ";
        }
        // cout<<"\n"<<sum<<"\n";
    } while(next_permutation(V.begin(),V.end()));
    printf("%.10lf\n",sum);
    return;
}

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

    solve();
    return 0;
}

Measured memory_bytes: 256
from string import ascii_lowercase as alfa

count = {}

for i in range(len(alfa)):
    count[alfa[i]] = 0
while True:
    try:
        S = list(input())

        for i in range(len(S)):
            if S[i].isupper():
                S[i] = S[i].lower()

        for i in range(len(alfa)):
            for k in range(len(S)):
                if alfa[i] == S[k]:
                    count[alfa[i]] += 1
    
    except EOFError:
        break       
        
    
for key, value in count.items():
    print('{} : {}'.format(key, str(value)))
    


Measured memory_bytes: 6676
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll A, B, sumA, sumB;

    cin >> A >> B;

    if(A==0){
        sumA = 0;
    }
    else{
        if((A-1)%4==1){
            sumA = 1;
        }
        if((A-1)%4==3){
            sumA = 0;
        }
        if((A-1)%4==0){
            sumA = A-1;
        }
        if((A-1)%4==2){
            sumA = A;
        }
    }

    if(B%4==1){
        sumB = 1;
    }
    if(B%4==3){
        sumB = 0;
    }
    if(B%4==0){
        sumB = B;
    }
    if(B%4==2){
        sumB = B+1;
    }

    cout << (sumA ^ sumB) << endl;

    return 0;
}

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

int main() {
    int a, b, c, cnt;
    cin >> a >> b >> c;
    if ((1 < a < 10000) && (1 < b < 10000) && (1 < c < 10000)) {
        cnt = 0;
        for (int i = a; i <= b; i++) {
            if (c % i == 0) {
                cnt++;
            }
        }
        cout << cnt << endl;
    }
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
int tag[2000005];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>tag[i];
        if(i) cout<<' ';
        cout<<tag[i];
    }
    cout<<endl;

    for(int i=1;i<n;i++)
    {
        int key=tag[i];
        int j=i-1;
        while(key<tag[j]&&j>=0)
        {
            tag[j+1]=tag[j];
            j--;
        }
        tag[j+1]=key;
        for(int j=0;j<n;j++)
        {
            if(j)cout<<' ';
            cout<<tag[j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3064
#include<stdio.h>

main()
{
	char buf[2000], *p = buf;
	
	
	scanf("%[^\n]",buf);
	
	while(*p != '\0'){
		if('A' <= *p && *p <= 'Z'){
			printf("%c",*p + ('a'-'A'));
		} else if('a'<=*p && *p <= 'z'){
			printf("%c",*p-('a'-'A'));
		} else {
			printf("%c",*p);
		}
		p++;
	}
	printf("\n");
	return 0;
}
	

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

int main(){
    int a,b,c,k;
    int max = 0;
    cin >> a >> b >> c >> k;
    if(a > k) max = k;
    else if(a + b >= k) max = a;
    else max = 2 * a + b - k;
    cout << max << endl;
}

Measured memory_bytes: 3620
import collections


class Bit():
    def __init__(self, l):
        self.size = l
        self.bit = [0] * (self.size+1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += i & -i

    def __str__(self):
        return str(self.bit)


S = str(input())
N = len(S)
index = collections.defaultdict(list)

for i, c in enumerate(S):
    index[c].append(i)

ctr = N // 2
B = [0] * N
flag = 0
P = []

for c, k in index.items():
    cnt = len(k)
    if cnt % 2:
        if flag == 1:
            print(-1)
            exit()
        flag = 1
        B[k[cnt // 2]] = ctr + 1
    for i in range(cnt // 2):
        l, r = k[i], k[-(i+1)]
        P.append((l, r))

P.sort()

for i, (l, r) in enumerate(P):
    B[l], B[r] = i + 1, N - i

ans = 0
bit = Bit(N)
for i, b in enumerate(B):
    ans += i - bit.sum(b)
    bit.add(b, 1)

print(ans)


Measured memory_bytes: 30780
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    for(int i=0; i<N; i++)
    {
        cin >> A.at(i);
    }
    for(int i=0; i<N; i++)
    {
        B.at(i)=i+1;
    }
    int count=0;
    for(int i=0; i<N; i++)
    {
        if(!(A.at(i)==B.at(i)))
        {
            count++;
        }
    }
    if(count>2)
    {
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
    }   
}


Measured memory_bytes: 256
n = gets.to_i
as = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)

ans = 0
bs.each_with_index do |b, i|
  d = as[i] <= b ? as[i] : b
  as[i] = as[i] - d
  ans += d

  b -= d

  d = as[i + 1] <= b ? as[i + 1] : b
  as[i + 1] = as[i + 1] <= b ? 0 : as[i + 1] - b
  ans += d
end

puts ans


Measured memory_bytes: 15396
N = int(input())
D = list(map(int, input().split()))
d_map = {}
for d in D:
    if d not in d_map:
        d_map[d] = 1
    else:
        d_map[d] += 1
        
M = int(input())
T = list(map(int, input().split()))
possible = True
for i in range(M):
    if T[i] not in d_map or d_map[T[i]] == 0:
        possible = False
        break
    d_map[T[i]] -= 1
    
if possible:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 47700
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int y, m, d;
    char tmp;
    cin >> y >> tmp >> m >> tmp >> d;

    if(make_tuple(y, m, d) <= make_tuple(2019, 4, 30))
        cout << "Heisei" << endl;
    else
        cout << "TBD" << endl;

    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,ans=0;
int main() {
	cin>>a>>b>>c>>d;
	for(int i=0; i<=a; i++)
		for(int j=0; j<=b; j++)
			for(int k=0; k<=c; k++)
				if(i*500+j*100+k*50==d) {
					ans++;
//					cout<<i<<" "<<j<<" "<<k<<endl;
				}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

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

const int MOD = 100000;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

int extgcd(int a, int b, int& x, int&y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}

int inv(int a) {
    int x, y;
    extgcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    rep(i, n) {
        int a;
        cin >> a;
        pq.push(a);
    }

    rep(i, m) {
        int x = pq.top(); pq.pop();
        pq.push(x / 2);
    }

    ll ans = 0;
    rep(i, n) {
        ans += pq.top(); pq.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define tt this->
#define ll long long
using namespace std;
int main ()
{
int a,b,c;
cin>>a>>b>>c;
if (a==b&&b==c)
    cout<<"No";
else if (a==b||a==c||b==c)cout<<"Yes";
else
    cout<<"No";
    return 0;
}

/*
▀█████████▄     ▄████████    ▄████████    ▄████████
  ███    ███   ███    ███   ███    ███   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
 ▄███▄▄▄██▀    ███    ███  ▄███▄▄▄▄██▀   ███    ███
▀▀███▀▀▀██▄  ▀███████████ ▀▀███▀▀▀▀▀   ▀███████████
  ███    ██▄   ███    ███ ▀███████████   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
▄█████████▀    ███    █▀    ███    ███   ███    █▀
                            ███    ███

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,M;
string A[51],B[51];

bool check(int y, int x) {
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      if (A[y+i][x+j] != B[i][j]) return false;
    }
  }
  return true;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> M;
  REP(i,N) cin >> A[i];
  REP(i,M) cin >> B[i];
  for (int i = 0; i+M-1 < N; i++) {
    for (int j = 0; j+M-1 < N; j++) {
      if (check(i,j)) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a,b,c,d,e;
    scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
    if(a==0)printf("1");
    if(b==0)printf("2");
    if(c==0)printf("3");
    if(d==0)printf("4");
    if(e==0)printf("5");

    return 0;
}

Measured memory_bytes: 1620
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(){
	char num[3];
	int cont=0;
	scanf("%s", num);
	for(int i=0; i<3; ++i){
		if(num[i]=='7')
			cont=1;
	}
	if(cont==1)
		printf("Yes");
	else
		printf("No");
	printf("\n");

    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int read();

int n, m;
vector<int> e[2003];
void add(int u, int v) { e[u].push_back(v), e[v].push_back(u); }

int fa[2003][2003], f[2003][2003];

void dfs(int rt, int u) {
    for (int v : e[u])
        if (v != fa[rt][u]) fa[rt][v] = u, dfs(rt, v);
}

struct E {
    int u, v;
};

queue<E> q;
void link(int u, int v) {
    if (f[u][v] == v && f[v][u] == u) return;
    if (f[u][v] != u) return link(f[u][v], v);
    if (f[v][u] != v) return link(u, f[v][u]);

    f[u][v] = v, f[v][u] = u;
    queue<int> qu;
    qu.push(u);
    while (!qu.empty()) {
        int w = qu.front();
        qu.pop();
        for (int tw : e[w]) {
            if (tw == fa[v][w]) continue;
            (f[v][tw] == v) ? (f[v][tw] = u, qu.push(tw)) : q.push((E){u, tw});
        }
    }

    qu.push(v);
    while (!qu.empty()) {
        int w = qu.front();
        qu.pop();
        for (int tw : e[w]) {
            if (tw == fa[u][w]) continue;
            (f[u][tw] == u) ? (f[u][tw] = v, qu.push(tw)) : q.push((E){v, tw});
        }
    }
}

int res;
void solve(int rt, int u, int las) {
    if (u != rt && f[las][u] == u) ++res, las = u;
    for (int v : e[u])
        if (v != fa[rt][u]) solve(rt, v, las);
}

int main() {
    n = read(), m = read();
    for (int i = 1; i < n; ++i) add(read(), read());
    for (int i = 1; i <= n; dfs(i, i), ++i)
        for (int j = 1; j <= n; ++j) f[i][j] = i;

    for (int i = 1; i <= m; ++i) link(read(), read());
    while (!q.empty()) link(q.front().u, q.front().v), q.pop();

    for (int i = 1; i <= n; ++i) solve(i, i, i);
    printf("%d\n", res >> 1);
    return 0;
}

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') f = (c == '-') ? -1 : f, c = getchar();
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}


Measured memory_bytes: 32128
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
typedef long long ll;
ll gcd(ll a, ll b){
    return b == 0 ? a : gcd(b, a%b);
}
ll lcm(ll a, ll b){
    ll temp = gcd(a,b);
//    return (ll)a * b / temp;
    if(a < b) swap(a,b);
    return a / temp * b;
}
int main(){
  //  freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll t[105];
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> t[i];
/*    ll tg = t[1];
    for(int i = 2; i <= n; i++){
        tg = gcd(tg,t[i]);
    }
//    cout << tg;*/
    ll tl = t[1];
    for(int i = 2; i <= n; i++){
        tl = lcm(tl, t[i]);
//        cout << tl;
    }
    cout << tl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cstring>
#include<functional>

using namespace std;

int gcd(int a, int b)
{
	while (b != 0)
	{
		int temp;

		a %= b;

		temp = a;
		a = b;
		b = temp;
	}

	return a;
}

int main()
{
	//freopen("input.txt", "r", stdin);

	int n;

	scanf("%d", &n);

	int sol = 0;

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			int ab;

			ab = gcd(i, j);

			for (int k = 1; k <= n; k++)
			{
				sol += gcd(ab, k);
			}
		}
	}

	printf("%d\n", sol);

	return 0;
}

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

int gcd(int x,int y){
  int minnum = min(x,y);
  int maxnum = max(x,y);

  if(minnum == 0) return maxnum;
  
  int gcd_r = gcd(minnum,maxnum % minnum);

  return gcd_r;
}

int main(){
  int x,y;

  cin >> x >> y;

  cout << gcd(x,y) << endl;
  
}



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


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    if( c!=a){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  if(a==c){
    if( b!=a){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  if(b==c){
    if( a!=b){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                          
using namespace std;    
int n,v[100005],a[100005],b[100005],x,y,c,d;
bool cmp(int x,int y){
	return x>y;
}
int main(){	
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>v[i];
		if(i%2!=0) a[v[i]]++;
		else b[v[i]]++;
	}
	for(int i=1;i<=100000;i++)
	{
		if(a[i]>x) x=a[i],y=i;
		if(b[i]>c) c=b[i],d=i;
	}
	sort(a+1,a+1+100000,cmp);
	sort(b+1,b+1+100000,cmp);
	if(d==y)
	{
		if(x+b[2]>c+a[2]) cout<<n-x-b[2];
		else cout<<n-c-a[2];
	}
	else cout<<n-c-x;
	return 0;
}

Measured memory_bytes: 1408
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

template<typename Monoid>
struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
        sz = 1;
        while(sz < n) sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x) {
        seg[k + sz] = x;
    }

    void build() {
        for(int k = sz - 1; k > 0; k--) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    void update(int k, const Monoid &x) {
        k += sz;
        seg[k] = x;
        while(k >>= 1) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    Monoid query(int a, int b) {
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1) L = f(L, seg[a++]);
            if(b & 1) R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const {
        return seg[k + sz];
    }
};

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    vector<int> v[26];
    int l[26]{0};
    int r[200002];
    for(int i = 0; i < n; i++){
        v[s[i] - 'a'].push_back(i);
        r[i] = l[s[i] - 'a'];
        l[s[i] - 'a']++;
    }
    int f = 0;
    for(int i = 0; i < 26; i++) f += l[i] % 2;
    if(f >= 2){
        cout << -1 << endl;
        return 0;
    }
    SegmentTree<ll> seg(n, [](ll a, ll b){return a + b;}, 0ll);
    int k = 0;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(r[i] * 2 == l[s[i] - 'a'] - 1) ans += n / 2 - k;
        else if(r[i] * 2 < l[s[i] - 'a']){
            ans += n - k - 1 - v[s[i] - 'a'][l[s[i] - 'a'] - r[i] - 1] +
                seg.query(0, v[s[i] - 'a'][l[s[i] - 'a'] - r[i] - 1]);
            seg.update(v[s[i] - 'a'][l[s[i] - 'a'] - r[i] - 1], 1);
            k++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6396
N, T = map(int, input().split())
t = list(map(int, input().split()))
t.append(t[-1])
ans = 0
for i in range(1, N+1):
  if t[i] - t[i-1] > T:
    ans += T
  elif t[i] == t[i-1]:
    ans += T
  elif t[i] - t[i-1] <= T:
    ans += t[i] - t[i-1]
  
print(ans)

Measured memory_bytes: 26708
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long N = sc.nextLong();
		long ans = 0;
		for( long i=1; i<=N; i++ ){
			if( i%3!=0 && i%5!=0 ){
				ans += i;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35812
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl();
        ll A = 0, C = 1, G = 2, T = 3;

        ll dp[n + 1][4][4][4];
        rep(i, n + 1) rep(j, 4) rep(k, 4) rep(l, 4) dp[i][j][k][l] = 0;
        // dp[i][j][k][l]: i文字目までで, i文字目がj, i+1文字目がk, i+2文字目がl, i+3文字目がm
        /*
         * ダメな列
         * AGC, ACG, GAC
         * AxGC, AGxC
         */
        rep(i, n) {
            rep(j, 4) {
                rep(k, 4) {
                    rep(l, 4) {
                        if (j == C && k == G && l == A) continue;
                        if (j == C && k == A && l == G) continue;
                        if (j == G && k == C && l == A) continue;

                        if (i < 3) {
                            dp[i + 1][j][k][l] = 1;
                        } else {
                            rep(m, 4) {
                                if (j == C && k == G && m == A) continue;
                                if (j == C && l == G && m == A) continue;

                                dp[i + 1][j][k][l] += dp[i][k][l][m];
                                dp[i + 1][j][k][l] %= mod;
                            }
                        }
                    }
                }
            }
        }
        ll ans = 0;
        rep(i, 4) rep(j, 4) rep(k, 4) ans += dp[n][i][j][k], ans %= mod;
        cout << ans << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

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


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll a, b ,c; cin >> a >> b >> c;

    ll dif = c-b-a;
    if(dif <= 0){
        cout << "No" << endl;
        return 0;
    } 

    if(dif * dif > 4 * a * b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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


using namespace std;

int main() {

	int n, m, x, y;
	cin >> n >> m >> x >> y;

	vector<int> xx(n);
	vector<int> yy(m);

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

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

	sort(xx.begin(), xx.end());
	sort(yy.begin(), yy.end());


	bool hh = false;

	for (int z = x + 1; z <= y; z++) {
		if (xx[n - 1] < z && z <= yy[0]) {
			hh = true;
		}
	}

	if (hh) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
double a,b,c,d;
double cos_u;
double rate;
double ux=0.0,uy=0.0,uz=0.0;
double uv,vw,uw;
double vx,vy,vz,vx2,vy2,vz2,vx3,vy3,vz3;
double wx,wy,wz,wx2,wy2,wz2,wx3,wy3,wz3;
int main(){
  while(cin>>a>>b>>c>>d){

    if(a==-1.0&&b==-1.0&&c==-1&&d==-1.0)break;
    a=a*M_PI/180.0;
    b=b*M_PI/180.0;
    c=c*M_PI/180.0;
    d=d*M_PI/180.0;
    uv=uw=6378.1;
    
    vx=6378.1;
    vy=0;
    vz=0;

    vx2=vx*cos(a)+vz*sin(a);
    vy2=vy;
    vz2=-vx*sin(a)+vz*cos(a);

    vx=vx2*cos(b)-vy2*sin(b);
    vy=vx2*sin(b)+vy2*cos(b);
    vz=vz2;

    wx=6378.1;
    wy=0;
    wz=0;

    wx2= wx*cos(c)+wz*sin(c);
    wy2= wy;
    wz2=-wx*sin(c)+wz*cos(c);

    wx=wx2*cos(d)-wy2*sin(d);
    wy=wx2*sin(d)+wy2*cos(d);
    wz=wz2;


    uv=sqrt(vx*vx + vy*vy + vz*vz);    uw=sqrt(wx*wx + wy*wy + wz*wz);
    //cout<<uv<<' '<<uw<<endl;

    vw=sqrt((vx-wx)*(vx-wx) + (vy-wy)*(vy-wy) + (vz-wz)*(vz-wz));
    
    cos_u=(vx*wx + vy*wy + vz*wz)/(uv*uw);
    
    cos_u=acos(cos_u);
    
    rate=cos_u/(2.0*M_PI);

    printf("%.0f\n",6378.1*2.0*M_PI*rate);
  }
  return 0;
}

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

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

  if (S[0]==S[1] || S[1]==S[2] || S[2]==S[3]){
    cout << "Bad" << endl;
  }else
  {
        cout << "Good" << endl;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a % 2 == 1 && i % 2 == 0) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int qn = in.nextInt();
		for (int q = 0; q < qn; q++) {
			int x = in.nextInt();
			int y = in.nextInt();
			int x2 = x + in.nextInt();
			int y2 = y + in.nextInt();
			int cats = in.nextInt();
			int catCounter = 0;
			for (int cat = 0; cat < cats; cat++) {
				int cx = in.nextInt(), cy = in.nextInt();
				if ((x <= cx && cx <= x2) && (y <= cy && cy <= y2)) {
					catCounter++;
				}
			}
			System.out.println(catCounter);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <string>
#include <bits/stdc++.h>

using namespace std;

int main(){
  int N, i, j, X, sum=0, a, b;
  bool can = false;
  cin >> N;
  int n=25;
  for (i = 0; i < n; i++){
    for (j = 0; j < n; j++){
      sum = 4*i + 7*j;
      if (sum == N){
        can = true;
        break;
      }
    }
  }
  if (can)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, n) for(long i = x; i < n; i++)
#define erep(i, x, n) for(long i = x; i <= n; i++)
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;
const long MOD = 1000000007;

long N, M;
long cnt = 0;
vector<bool> vis(9, false);
vector<vector<long>> s(9);
bool check(){
  erep(i, 1, N){
    if(vis[i] == false){
      return false;
    }
  }
  return true;
}

void dfs(long x){
  vis[x] = true;
  if(check() == true){
    cnt++;
    vis[x] = false;
    return;
  }
  rep(i, 0, s[x].size()){
    if(vis[s[x][i]] == false) dfs(s[x][i]);
  }
  vis[x] = false;
  return;
}

int main(){
cin >> N >> M;
erep(i, 1, M){
  long a1, b1;
  cin >> a1 >> b1;
  s[a1].push_back(b1);
  s[b1].push_back(a1);
}
dfs(1);
show(cnt);

return 0;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    string s;
    cin >> s;
    string t = "keyence";
    ll n = s.size();
    ll m = t.size();
    REP(i, n) {
        if(i > m)
            break;
        string tt = s.substr(0, i) + s.substr(n - (m - i), m - i);
        if(tt == t) {
            cout << "YES" << en;
            return;
        }
    }
    cout << "NO" << en;
}

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

    solve();
    /*
    ll t;
    cin >> t;
    REP(i, t)
    solve();
    */

    return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
ll dp[101][4][4][4];

bool ng(int a, int b, int c) {
  return (a == 1 && b == 2 && c == 3) ? true : false;
}

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

  cin >> n;

  dp[0][0][0][0] = 1;
  REP(i, n) REP(a, 4) REP(b, 4) REP(c, 4) REP(d, 4) {
    if(ng(b, c, d) || ng(c, b, d) || ng(b, d, c)) continue;
    if(ng(a, c, d) || ng(a, b, d)) continue;
    dp[i + 1][b][c][d] = (dp[i + 1][b][c][d] + dp[i][a][b][c]) % mod;
  }

  ll ans = 0;
  REP(a, 4) REP(b, 4) REP(c, 4) {
    ans = (ans + dp[n][a][b][c]) % mod;
  }

  cout << ans << endl;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;

ll dp[110][5][5][5];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    dp[0][0][0][0] = 1;
    // A = 1, G = 2, C = 3, T = 4
    rep(n, N) {
        rep(i, 5) {
            rep(j, 5) {
                rep(k, 5) {
                    REP(t, 1, 5) {
                        // AGC
                        if (i == 2 && j == 1 && t == 3) continue;
                        // ACG
                        if (t == 2 && j == 1 && i == 3) continue;
                        // GAC
                        if (t == 3 && i == 1 && j == 2) continue;
                        // A?GC
                        if (t == 3 && i == 2 && k == 1) continue;
                        // AG?C
                        if (t == 3 && j == 2 && k == 1) continue;
                        dp[n+1][t][i][j] += dp[n][i][j][k];
                        dp[n+1][t][i][j] %= mod;
                    }
                }
            }
        }
    }
    ll sums = 0;
    REP(i, 1, 5) {
        REP(j, 1, 5) {
            REP(k, 1, 5) {
                sums += dp[N][i][j][k];
                sums %= mod;
            }
        }
    }
    cout << sums << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>  //setprecision(桁)
using namespace std;
#define pb push_back
#define rep(i,n) for(int i = 0;i < n;i++)
#define INF 1e+9

struct edge {
    int to;
    double cost;
};

// <最短距離, 頂点の番号>
using P = pair<double, int>;

int V;
const int ci = 2e5+ 5;
vector<edge> G[ci];
double d[ci];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) { //cout << "On" << endl;
        P p = que.top();
        que.pop();
        int v = p.second; //cout << "v=" << v << endl;
        if (d[v] < p.first) continue;
        for (int i=0; i<G[v].size(); i++) {
            edge e = G[v][i]; //cout << "koo" << endl;
            if (d[e.to] > d[v] + e.cost) { //cout << e.cost << endl;
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
    long double a,b; cin >> a >> b;
    long long int ans = a * b;
    cout << ans << endl;
}

Measured memory_bytes: 8448
x,y,a,b,c=map(int,input().split())
taste=[sorted(list(map(int,input().split())),reverse=True) for i in range(3)]
red=taste[0][:x]
green=taste[1][:y]
noclo=taste[2]
print(sum(sorted(red+green+noclo)[-(x+y):]))

Measured memory_bytes: 23712
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(a,b,x):
  def countDivisible(k,d):
    return k // d
  return countDivisible(b,x) - countDivisible(a-1,x)



def main():
  a,b,x = map(int,input().split())
  # a = list(map(int,input().split()))
  print(solve(a,b,x))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 9160
S=str(input())
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2] : print("Yes")
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1] : print("Yes")
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1] : print("Yes")
else : print("No")

Measured memory_bytes: 3064
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = scan.nextLong();
    long c = a*500;

    if (c >= b){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35652
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
ll read()
{
	ll tmp=0; char f=1,c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1; c=getchar();}
	while('0'<=c&&c<='9'){tmp=tmp*10+c-'0'; c=getchar();}
	return tmp*f;
}
using namespace std;
ll a[100010],b[100010];
int n,h;
int main()
{
	n=read(); h=read();
	for(int i=1;i<=n;i++)a[i]=read(),b[i]=read();
	ll mxa=0;
	for(int i=1;i<=n;i++)mxa=max(mxa,a[i]);
	sort(b+1,b+n+1);
	ll ans=0;
	for(int i=n;i;i--){
		if(b[i]>mxa)++ans,h-=b[i];
		if(h<=0){
			printf("%lld\n",ans); return 0;
		}
	}
	ans+=h/mxa;
	if(h%mxa)++ans;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionC(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		pw.println(nextInt()*nextInt());
	}
	public static void solutionB(String[] args) throws Exception{
		int N = nextInt();
		long[] a = nextLongs();
		Arrays.sort(a);
		long ans = a[0];
		for(int i=1;i<N;i++) {
			long x = 0;
			try{
				x= Math.multiplyExact(ans, a[i]);
			}catch(Exception e) {
				pw.println(-1);
				return;
			}
			if(x>=1000000000000000001L) {
				pw.println(-1);
				return;
			}
			ans=x;
		}
		pw.println(ans);
	}
	public static void solutionC(String[] args) throws Exception{
		String A = nextString();
		String B = nextString();
		BigDecimal bA = new BigDecimal(A);
		BigDecimal bB = new BigDecimal(B);



		pw.println(bA.multiply(bB).longValue());
	}
	public static void solutionD(String[] args) throws Exception{

	}



	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 25720
#include <algorithm>
#include <cmath>
#include <ctype.h>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define ENDL '\n'
#define FOR(i, n) for (int i = 0; i < n; ++i)
#define FOR_EACH(i, v) for (auto&& i : v)

class Edge {
public:
	int to;
	int a;
	int b;

	Edge(int to_, int a_, int b_)
	{
		to = to_;
		a = a_;
		b = b_;
	}
};

void dijkstra(int vertexNum, vector<list<Edge>>& edge, int start, vector<long long>& distance, bool type)
{
	priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pQueue;
	FOR(i, vertexNum) {
		distance[i] = -1LL;
	}
	distance[start] = 0LL;

	pQueue.push(make_pair(0LL, start));
	while (!pQueue.empty()) {
		pair<long long, int> p = pQueue.top();
		pQueue.pop();
		if (distance[p.second] != -1LL && distance[p.second] < p.first) {
			continue;
		}

		for (list<Edge>::iterator it = edge[p.second].begin(); it != edge[p.second].end(); it++) {
			int cost = type ? it->a : it->b;

			if (distance[it->to] == -1LL || distance[it->to] > distance[p.second] + cost) {
				distance[it->to] = distance[p.second] + cost;
				pQueue.push(make_pair(distance[it->to], it->to));
			}
		}
	}
}

const long long INITIAL_YEN = 1000000000000000LL;
int n;
int m;
int s;
int t;

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

	cin >> n >> m >> s >> t;
	vector<list<Edge>> edge(n);
	vector<long long> distanceA(n);
	vector<long long> distanceB(n);
	FOR(i, m) {
		int u;
		int v;
		int a;
		int b;
		cin >> u >> v >> a >> b;
		edge[u - 1].push_back(Edge(v - 1, a, b));
		edge[v - 1].push_back(Edge(u - 1, a, b));
	}

	dijkstra(n, edge, s - 1, distanceA, true);
	dijkstra(n, edge, t - 1, distanceB, false);

	list<long long> ans;
	ans.push_back(distanceA[n - 1] + distanceB[n - 1]);
	FOR(i, n - 1) {
		ans.push_back(min(ans.back(), distanceA[n - i - 2] + distanceB[n - i - 2]));
	}

	for (list<long long>::reverse_iterator it = ans.rbegin(); it != ans.rend(); it++) {
		cout << INITIAL_YEN - *it << ENDL;
	}

	return 0;
}


Measured memory_bytes: 19536
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string date;
  cin >> date;
  
  if(date[0] == '2'){
    if(date[1] == '0'){
      if(date[2] == '1'){
        if(date[3] == '9'){
          if(date[5] == '0'){
            if(date[6] == '4'){
              cout << "Heisei" << endl;
              return 0;
            }
            if(date[6] < '4'){
                cout << "Heisei" << endl;
                return 0;
            }
          }
        }
        else if(date[3] < '9'){
            cout << "Heisei" << endl;
            return 0;
        }
      }
      else if(date[2] < '1'){
          cout << "Heisei" << endl;
          return 0;
      }
    }
  }
  else if(date[0]<'2'){
      cout << "Heisei" << endl;
      return 0;
  }
  
  cout << "TBD\n";
  
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

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

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

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

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

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    string s = inp1;

    int ans = 0;
    Rep(i, 1, s.length()) {
        if (s[i - 1] != s[i]) ++ans;
    }

    Cout(ans);

    return 0;
}


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

int main(){
  int N,A,B;
  cin>>N;
  cin>>A>>B;
  int P[N];
  int p1=0,p2=0,p3=0;
  for(int i=0;i<N;i++){
    cin>>P[i];
    if(P[i]<=A){
      p1++;
    }
    else if(P[i]<=B){
      p2++;
    }
    else p3++;
  }
  cout<<min(min(p1,p2),p3)<<endl;
  return 0;
}

  
  

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

#define int long long
#define X first
#define Y second
#define pb push_back
#define sz(v) (int) v.size()

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 5;
const int MOD = 998244353;

int n, d[N], dp[N], cnt[N];

int mul(int x, int y) {
    return 1ll * x * y % MOD;
}

main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> d[i];
    if (d[1]) return cout << "0\n", 0;
    sort(d + 1, d + n + 1, [&](int i, int j) { return i < j;});
    dp[1] = 1;
    cnt[0] = 1;
    for (int v = 2; v <= n; ++v) {
        if (!d[v]) return cout << "0\n", 0;
        dp[v] = mul(dp[v - 1], cnt[d[v] - 1]);
        cnt[d[v]]++;
    }
    cout << dp[n] << "\n";

    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>

#define MAX_N 101000

int isPrime[ MAX_N + 1 ] = { 0, 0, 1 };

int compare( const void *, const void * );

int main( void ) {
	int i, j, N, P, cnt, p[ 22 ], sum[ 253 ];

	for ( i = 3; i <= MAX_N; i += 2 )
		isPrime[ i ] = 1;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	for ( ; scanf( "%d %d", &N, &P ), N != -1; printf( "%d\n", sum[ P - 1 ] ) ) {
		cnt = 0;
		for ( i = N + 1; cnt < 22; i++ )
			if ( isPrime[ i ] )
				p[ cnt++ ] = i;

		cnt = 0;
		for ( i = 0; i < 22; i++ )
			for ( j = i; j < 22; j++ )
				sum[ cnt++ ] = p[ i ] + p[ j ];

		qsort( sum, 253, sizeof(int), &compare );
	}

	return 0;
}

int compare( const void *a, const void *b ) {
	return *(int *)a - *(int *)b;
}

Measured memory_bytes: 992
import java.io.BufferedInputStream;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    static final int MAX = 1_000_000_000;
    public static void main(String[] args) {
        //System.setIn(Main.class.getResourceAsStream("input"));
        Scanner sc = new Scanner(new BufferedInputStream(System.in));
        long  a = sc.nextInt();
        long b = sc.nextInt();
        System.out.println(a*b/pgcd(a, b));
    }

    static long pgcd(long a, long b) {
        if(b == 0) return a;
        return pgcd(b, a%b);
    }
    private static int nextInt(Scanner sc) {
        return Integer.valueOf(sc.nextLine());
    }
    private static int[] toArray(String text) {
        return Arrays.stream(text.split("")).mapToInt(Integer::valueOf).toArray();
    }

}

Measured memory_bytes: 22612