akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back


int MOD=1000000007;
int N,M,P;
double v[105];
int ans=0;



signed main(){
    scanf("%lld",&N);
    double ans=0;
    rep(i,N){
        scanf("%lf",&v[i]);
    }
    sort(v,v+N);
    rep(i,N){
        if(i==0)ans=v[i];
        else ans=(ans+v[i])/2;
    }
    printf("%lf\n",ans);
}


Measured memory_bytes: 128
/*
   *********************************************************
    Code_Blooded Human == @{{ samrat_12   [  0_0  ^_^  ] }}
   *********************************************************
*/
#include <bits/stdc++.h>
#include<algorithm>
#include<queue>
#include<list>
#include<map>
#include <math.h>
#include<numeric>
using namespace std;
//using i1=int;
#define E "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  ipfile    ifstream cin ("input.txt");std::cin.rdbuf(std::cin.rdbuf())
#define pb(x) push_back(x);
#define ll long long int
#define ull unsigned long long int
#define db long double
#define mod 1000000007
#define vll vector<ll>
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define All(a,n) a,a+n
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define REVVEC(v) reverse(v.begin(),v.end())
#define REVARR(a) reverse(a,a+n)
#define maxc(v) max_element(all(v))
#define maxa(a,n) max_element(All(a,n))
#define minc(v) min_element(all(v))
#define inputarr(a,n) for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define outputarr(a,n) for(int xxx=0;xxx<n;xxx++) cout<<a[xxx]<<" "
#define rep(i,m, n)    for(int i = m; i < (n); ++i)
#define sp setprecison(10)
int main() {
    FAST
    string s1,s2;
    int c=0;
    cin>>s1>>s2;
    for(int i=0;i<s1.length();i++)
    if(s1[i]==s2[i])
    c++;
    cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 256
'use strict'

function main(input) {
  input = input.split('\n');
  const NK = input[0].split(' ').map(n => Number(n));
  const N = NK[0],
        K = NK[1];
  const A = input[1].split(' ').map(n => Number(n));
  const countBucket = [...Array(N+1)].fill(0);

  for (const num of A) {
    countBucket[num] += 1;
  }
  console.log(countBucket.sort((a, b) => b - a).slice(K).reduce((a, b) => a + b));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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


int main(){
    int lane,est,sum,ans; sum = 0;
    vector<int> hen(10);
    cin >> lane;
    for(int i=0;i<lane;i++){
        cin >> hen[i];
        sum = sum + hen[i];
    }
    est = max(hen[0],hen[1]);
    for(int j=2;j<lane;j++){
        est = max(est,hen[j]);
    }
    ans = sum - est;
    if(est<ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main(){
    int n;
    cin >> n;
    char m;
    int r;
    vector<int> S(13), H(13), C(13), D(13);

    for (int i = 0; i < n; i++)
    {
        cin >> m >> r;
        if(m == 'S') S.at(r-1) = r;
        else if(m == 'H') H.at(r-1) = r;
        else if(m == 'C') C.at(r-1) = r;
        else if(m == 'D') D.at(r-1) = r;
    }
    
    for (int i = 0; i < 13; i++)
    {
        if(S.at(i) == 0) cout << "S " << i+1 << endl;
    }
    for (int i = 0; i < 13; i++)
    {
        if(H.at(i) == 0) cout << "H " << i+1 << endl;
    }
    for (int i = 0; i < 13; i++)
    {
        if(C.at(i) == 0) cout << "C " << i+1 << endl;
    }
    for (int i = 0; i < 13; i++)
    {
        if(D.at(i) == 0) cout << "D " << i+1 << endl;
    }

}


Measured memory_bytes: 3092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      int num;
      int result;
      List<Integer> prime = new ArrayList<>(); 
      while(true) {

        if( ((line = br.readLine()) == null) || line.isEmpty() ) break;

        num = Integer.parseInt(line);
        if( num == 0 || num == 1) {
          result = 0;
          System.out.println(result);
          continue;
        }
        
        result = 0;
        prime.clear();
        for ( Integer i = 2; i <= num; i++ ) {
          if( isPrime(i,prime) ) {
            prime.add(i);
            result += 1;
          }
        }
        System.out.println(result);
      }
    }
  }

  public static boolean isPrime(Integer num,List<Integer> prime) {
    Integer k = Double.valueOf( Math.sqrt(num) ).intValue();
    for(Integer i: prime) {
      if ( num % i == 0) return false;
      if ( i > k ) return true;
    }
    return true;
  }
}


Measured memory_bytes: 157428
#include <stdio.h>

void CSort(int *a, int n);

int main(){
    int N, K, pos, sum = 0;
    scanf("%d %d", &N, &K);

    int l[N];
    for(int i = 0; i < N; i++){
        scanf("%d", &l[i]);
    }

    CSort(l, N);
    pos = N - 1;
    for(int i = 0; i < K; i++){
        sum += l[pos--];
    }

    printf("%d\n", sum);
    return 0;
}

void CSort(int *a, int n){
    int keys[50], pos = 0;
    for(int i = 0; i < 50; i++){
        keys[i] = 0;
    }

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

    for(int i = 0; i < 50; i++){
        while(keys[i] > 0){
            a[pos] = i + 1;
            keys[i]--;
            pos++;
        }
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 
 


int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll a,b,c;
	cin>>a>>b>>c;
	
	if(a+b+c >= 22)
	{
		cout << "bust";
	}
	else
	cout<<"win";
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int r = 0;
	int c = 0;
	unsigned long long int excel[101][101] = { 0 };

	cin >> r >> c;

	for (int i = 0; i < r; i++) {

		for (int u = 0; u < c; u++) {

			cin >> excel[i][u];

		}

	}

	for (int i = 0; i < r + 1; i++) {

		for (int u = 0; u < c; u++) {

			if (i == r) {

				for (int y = 0; y < r; y++) {

					excel[r][u] += excel[y][u];

				}

			}

			cout << excel[i][u] << " ";

			excel[i][c] += excel[i][u];

		}

		cout << excel[i][c] << endl;

	}


	return 0;

}



Measured memory_bytes: 3180
#include <iostream>
#include <cstdio>

using namespace std;

int S[100000];

int main(void) {

    int n;
    scanf("%d", &n);
//    cin >> n;

    for (int i = 0; i < n; ++i) {
//        cin >> S[i];
        scanf("%d", S + i);
    }

    int q, total = 0;
//    cin >> q;
    scanf("%d", &q);
    for (int i = 0; i < q; ++i) {
        int t;
//        cin >> t;
        scanf("%d", &t);
        int left = 0, right = n - 1, mid = 0;
        while (left <= right) {     // '<' ?????¨?????¨??§?????????
            mid = (left + right) / 2;
            if (t > S[mid]) {
                left = mid + 1;
            }
            else if (t < S[mid]) {
                right = mid - 1;
            }
            else {
                ++total;
                break;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 1576
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <iomanip>
#include <queue>
#include <deque>
#include <sstream>
#include <stdio.h>
#include <string>
#include <cmath>
#include <map>
#include <utility>
using namespace std;

#define s(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define ss(n) scanf("%s",&n)
#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795

int main() {
	int a,b;
	cin >> a >> b;
	if(a+b > 9 ){
		cout << "error";
	} else {
		cout << a+b;
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,p,count=0;cin>>N;
  vector<int> a(9);
  for(int i=0;i<N;i++){
    cin>>p;
    if(p<=399)a.at(0)++;
    else if(p<=799)a.at(1)++;
    else if(p<=1199)a.at(2)++;
    else if(p<=1599)a.at(3)++;
    else if(p<=1999)a.at(4)++;
    else if(p<=2399)a.at(5)++;
    else if(p<=2799)a.at(6)++;
    else if(p<=3199)a.at(7)++;
    else a.at(8)++;
  }
  for(int i=0;i<8;i++)
    if(a.at(i)!=0)count++;
  if(count==0)cout<<1<<" "<<a.at(8)<<endl;
  else cout<<count<<" "<<count+a.at(8)<<endl;
}

Measured memory_bytes: 256
from math import floor
import unittest


class BiscuitGenerator:
    def __init__(self, product_count, interval_sec):
        self.product_count = product_count
        self.interval_sec = interval_sec

    def product(self, second):
        return self.product_count * floor(second / self.interval_sec)


def parse_argument(input):
    args = [int(arg) for arg in input.split(" ")]
    return args


def main(input):
    args = parse_argument(input)
    generator = BiscuitGenerator(interval_sec=args[0], product_count=args[1])
    print(generator.product(args[2]))


if __name__ == "__main__":
    main(input())

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> r;
    vector<int> g;
    vector<int> b;
    for (int i = 0; i < n; i++)
    {
        if(s[i]=='R')r.push_back(i);
        if(s[i]=='G')g.push_back(i);
        if(s[i]=='B')b.push_back(i);
    }
    ll ans = (ll)sz(r) * (ll)sz(g) * (ll)sz(b);
    ll sub = 0;
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j+2*i<= n-1; j++)
        {
            if (s[j] != s[j + i] && s[j + i] != s[j + 2 * i] && s[j] != s[j + 2 * i])
            {
                sub++;
            }
            
        }
        
    }
    cout << ans-sub << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  long long int total = 0;
  int minusNum = 0;
  int minAb = INT_MAX;
  for(int i=0;i<n;i++) {
    cin >> A[i];
    total += abs(A[i]);
    if(A[i] < 0) minusNum++;
    if(abs(A[i]) < minAb) minAb = abs(A[i]);
  }
  if(minusNum % 2 == 0) {
    cout << total << endl;
  } else {
    cout << total - minAb * 2 << endl;
  }
}

Measured memory_bytes: 640
# include <algorithm>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <string>
# include <vector>

typedef long long ll;
using namespace std;

const ll MOD = pow(10, 9) + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    reverse(s.begin(), s.end());
    vector<ll> r(13, 0);
    if (s[0] == '?') {
        for (int i = 0; i <= 9; i++) {
            r[i] = 1;
        }
    } else {
        r[s[0] - '0'] = 1;
    }
    int rOrder = 1;
    for (int i = 1; i < s.size(); i++) {
        rOrder *= 10;
        rOrder %= 13;
        for (auto& rr : r) rr %= MOD;
        if (s[i] == '?') {
            vector<ll> toChange(13, 0);
            for (int k = 0; k < 13; k++) {
                if (r[k] > 0) {
                    for (int l = 0; l <= 9; l++) {
                        int newr = l * rOrder % 13;
                        int ni = (k + newr) % 13;
                        toChange[ni] += r[k] % MOD;
                        toChange[ni] %= MOD;
                    }
                }
            }
            for (int l = 0; l < 13; l++) {
                r[l] = toChange[l] % MOD;
            }
        } else {
            int k = s[i] - '0';
            if (k == 0) continue;
            int newr = k * rOrder % 13;
            vector<ll> toChange(13, 0);
            for (int l = 0; l < 13; l++) {
                if (r[l] > 0) {
                    int ni = (l + newr) % 13;
                    toChange[ni] += r[l] % MOD;
                    toChange[ni] %= MOD;
                }
            }
            for (int l = 0; l < 13; l++) {
                r[l] = toChange[l] % MOD;
            }
        }
    }
    cout << r[5] % MOD << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
struct UnionFind
{
    vector<ll> par;
    vector<ll> rank;
    vector<ll> sz;
    UnionFind(ll n) : par(n), rank(n), sz(n)
    {
        for(ll i = 0; i < n; i++)
        {
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }
    ll root(ll x)
    {
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }
    void unite(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y])
        {
            par[x] = y;
            sz[y] += sz[x];
        }
        else
        {
            par[y] = x;
            sz[x] += sz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    bool same(ll x, ll y)
    {
        return root(x) == root(y);
    }
    ll size(ll x)
    {
        x = root(x);
        return sz[x];
    }
};
struct edge {ll u, v, cost;};
bool comp(const edge& e1, const edge& e2)
{
    return e1.cost < e2.cost;
}
int main()
{
    int n;
    cin >> n;
    vector<P> px(n);
    vector<P> py(n);
    for(int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        px[i] = P(x, i);
        py[i] = P(y, i);
    }
    sort(px.begin(), px.end());
    sort(py.begin(), py.end());
    // kruscal start
    vector<edge> es;

    // set es
    for(int i = 1; i < n; i++)
    {
       edge e;
       e.cost = px[i].first - px[i-1].first;
       e.u = px[i].second;
       e.v = px[i-1].second;
       es.push_back(e);
    }
    for(int i = 1; i < n; i++)
    {
       edge e;
       e.cost = py[i].first - py[i-1].first;
       e.u = py[i].second;
       e.v = py[i-1].second;
       es.push_back(e);
    }

    ll V = n;
    UnionFind tree(V);
    ll E = es.size();
    sort(es.begin(), es.end(), comp);
    ll res = 0;
    for(int i = 0; i < E; i++)
    {
        edge e = es[i];
        if(!tree.same(e.u, e.v))
        {
            tree.unite(e.u, e.v);
            res += e.cost;
        }
    }
    cout << res << endl;
    // kruscal end
}


Measured memory_bytes: 11756
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include <vector>
#include <map>
using namespace std;
long long Z(long long n) {
	if(n==0) return 0;
	return Z(n/5)+n/5;
}
long long Read() {
	long long x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
	return x*f;
}
int main() {
	int n,b;
	n=Read(),b=Read();
	if(n%2==1&&b%2==1) {
		cout<<"Odd";
	} else  cout<<"Even";
	return 0;
}

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

# print(S, T)
# # ない場合はTを分解し、それらの文字列が存在するかを確認
# for i in range(1, len(T)):
#   # 分解文字列
#   for j in range(i+1):
#     subTs= T[j:len(T)-i+j]
#     if subTs in S[j:len(T)-i+j]:
#       print(i)
#       exit()
#   print(subTs)
# # 全てない場合は全文字を書き換える
# print(len(T))

# ない場合は、文字列の類似数を算出する
def similar(str1, str2):
  # print(str1, str2)
  cnt = 0
  for i in range(len(str1)):
    if str1[i] == str2[i]:
      cnt += 1
  return cnt

max_value = 0
for i in range(0, len(S)-len(T)+1):
  t = similar(S[i:len(T)+i], T)
  # print('t', t)
  if t > max_value:
    max_value = t
print(len(T)-max_value)


Measured memory_bytes: 72572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int sum = 0, ans = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();

		for (int i = 1; i <= n; i++) {
			String s = String.valueOf(i);
			for (int j = 0; j < s.length(); j++) {
				sum += Character.getNumericValue(s.charAt(j));
			}
			if (sum >= a && sum <= b) {
				ans += i;
			}
			sum = 0;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

vector<vector<int>> edge(200001, vector<int>(0));
VI c(10000, 0);
VI ans(10000, 0);
int sj = 0;

void dfs(int v, int p) {
	ans[v] = c[sj];
	sj++;
	for (int i = 0; i < edge[v].size(); i++) {
		if (edge[v][i] != p) {
			dfs(edge[v][i], v);
		}
	}
}

int main() {
	int n;
	cin >> n;
	int a, b;
	REP(i, n - 1) {
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	int sum = 0;
	REP(i, n) {
		cin >> c[i];
		sum += c[i];
	}
	sort(ALL(c), greater<int>());
	sum -= c[0];
	dfs(1, 0);
	cout << sum << '\n';
	for (int i = 1; i <= n; i++)
		cout << ans[i] << ' ';
}

Measured memory_bytes: 5888
#include <stdio.h>

int f(int x){ return x*x; }

int integral(int d)
{
    int sum=0;
    int i;
    int n=600/d-1;
    for(i=1;i<=n;i++){
        sum+=f(i*d)*d;
    }
    return sum;
}

//#define DEBUG
int main(void)
{
    FILE *fp;
#ifdef DEBUG        
    fp=fopen("input.txt","r");
#else
    fp=stdin;
#endif
    
    while(feof(fp)==0){
        int d;
        fscanf(fp,"%d\n",&d);
        printf("%d\n",integral(d));
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9+5

int main()
{
    int n;               cin>>n;
    vector<int> a(n);    for(auto &i:a)   cin>>i;

    vector<int> dp(n,inf);
    dp[0] = 0;

    for(int i=0 ; i<n; i++)
    {
        for(int j : {i-1, i-2})
            {
                if(j>=0)
                    dp[i] = min(abs(a[i]-a[j]) + dp[j] , dp[i]);
            }
    }
//for(auto i:dp)    cout<<i<<" ";   cout<<endl;

cout<<dp[n-1];
}


Measured memory_bytes: 1024
H,W=[int(i) for i in input().split(" ")]
a=[]
for _ in range(H):
    a.append([int(i) for i in input().split(" ")])

sousa=[]
for i in range(H):
    for j in range(W-1):
        if a[i][j]%2==1:
            a[i][j]-=1
            a[i][j+1]+=1
            sousa.append([i+1,j+1,i+1,j+2])

for i in range(H-1):
    if a[i][-1]%2==1:
        a[i][-1]-=1
        a[i+1][-1]+=1
        sousa.append([i+1,W,i+2,W])

print(len(sousa))
for s in sousa:
    print(" ".join([str(i) for i in s]))


Measured memory_bytes: 29712
/*
      author : nishi5451
      created: 11.08.2020 21:26:28
*/

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


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans = b/a;
    if(ans>c) ans = c;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
using namespace std;
 int main()
{
    ll n,x,sum=0,q,y;  cin>>n;
    map<ll,ll> mp;
    rep(i,0,n) 
    {
        ll x;  cin>>x;
        sum+=x;
        mp[x]++;
    }
    cin>>q;
    while(q--)
    {
        cin>>x>>y;
        sum-=mp[x]*x;
        sum+=mp[x]*y;
        mp[y]+=mp[x];
        mp[x]=0;
        cout<<sum<<"\n";
    }
}

Measured memory_bytes: 9448
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}

// long long version
const int MAX_N = 300005;
ll bit[MAX_N+1];
int nn = MAX_N; //　1-index

void adds(int a, ll w){
    for(int x = a; x <= nn; x += x & -x) bit[x] += w;
}
ll sums(int a){ // bit[1,a]の和を返す.
    ll ret = 0;
    for(int x = a; x > 0; x -= x & -x) ret += bit[x];  
    return ret;
}

int main() {
    int n, q;
    cin >> n >> q;

    rep(loop, q){
        int c, x, y;
        cin >> c >> x >> y;
        if(c == 0){
            adds(x, y);
        }else{
            ll res = sums(y);
            if(x > 1)res -= sums(x - 1);
            cout << res << endl;
        }
    }
    
    return 0;
}
 
 



Measured memory_bytes: 3912
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <regex>
#include <set>
#include <cmath>
#include <sstream>
#include <numeric>
#include <set>
#include <unordered_map>

int main()
{
    long long a, v, b, w;
    long long t;
    std::cin >> a >> v;
    std::cin >> b >> w;
    std::cin >> t;
    bool ans = false;

    long long pos = std::abs(a - b);
    long long vel = std::abs(v - w);
 
     if(t * vel >= pos && v > w)
    {
        std::cout << "YES";
    }else {
        std::cout << "NO";
    }

    return EXIT_SUCCESS;
}


Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define mul(a,b) a=(a*b)%mod
#define N 500010
ll fac[N],inv[N],ivf[N];
ll C(ll n,ll k){
    return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}
ll po(ll x,ll y){
    ll res=1;
    for(;y;y>>=1){
	if(y&1)res=res*x%mod;
	x=x*x%mod;
    }
    return res;
}
ll n,a,b,c;
ll solve(ll x,ll y,ll kei){
    ll res=C(x+y,x)*kei%mod; //cout<<res<<endl;
    res=res*po(a*inv[a+b]%mod,x)%mod;
    res=res*po(b*inv[a+b]%mod,y)%mod;//cout<<res<<endl;
    res=res*(a+b+c)%mod;
    res=res*inv[a+b]%mod;
    res=res*(x+y+1)%mod; 
    return res%mod;
}
int main(){
    fac[0]=ivf[0]=inv[1]=1;
    for(int i=1;i<N;i++){
	if(i>1)inv[i]=(mod-mod/i*inv[mod%i]%mod)%mod;
	fac[i]=fac[i-1]*i%mod;
	ivf[i]=ivf[i-1]*inv[i]%mod;
    }
     cin>>n>>a>>b>>c;
    ll ans=0;
    for(int i=0;i<n;i++){
	mad(ans,solve(i,n-1,b*inv[a+b]%mod));
	mad(ans,solve(n-1,i,a*inv[a+b]%mod));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11904
<?php
  $str = trim(fgets(STDIN));
  $ac = true;
  if($str[0] != "A")$ac = false;
  $c = 0;
  for($i = 2; $i < strlen($str) - 1; $i++){
    if($str[$i] == "C")$c++;
  }
  if($c != 1)$ac = false;

  for($i = 0; $i < strlen($str); $i++){
    if($str[$i] == "A" ||$str[$i] == "C" || $str[$i] == strtolower( $str[$i])){
    }else{
      $ac = false;
    }
  }
echo $ac ? "AC" : "WA";



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

int main(){
	int a,b;
	scanf("%d",&a);
	for(int i=1;i<=9;++i){
		for(int j=1;j<=9;++j){
			if (i*j==a){printf("Yes");return 0;}
		}
	}printf("No");
	return 0;
}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];

int32_t  main(){
	IOS;
  string s;cin>>s;
  map<char,int>mm;
  for(auto it:s)mm[it]++;
  for(auto it:mm){
    if(it.second%2){
      cout<<"No\n";
      return 0;
    }
  }
  cout<<"Yes\n";

  return 0;
}



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

#define INF 1e18
#define PI 3.141592653589793238
typedef long long ll;
#define N 200010

int main() {
    int n;cin>>n;
    int a[N];
    for(int i=0; i<n; i++) a[i]=0;
    for(int i=1; i<n; i++){
        int x;cin>>x;
        a[x-1]++;
    }
    for(int i=0; i<n; i++) cout<<a[i]<<endl;


    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll n;
    cin >> n;
    VL a(n), b(n);
    rep(i, 0, n) cin >> a[i] >> b[i];
    sort(ALL(a));
    sort(ALL(b));
    ll up, bt;
    if(n % 2 == 0){
        bt = a[n/2-1] + a[n/2];
        up = b[n/2-1] + b[n/2];
    }else{
        bt = a[n/2];
        up = b[n/2];
    }
    cout << up - bt + 1 << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    int k;
    cin >> k;
    ll res=0;
    for(int a=1;a<=k;a++) for(int b=1;b<=k;b++) for(int c=1;c<=k;c++) res+=gcd(gcd(a,b),c);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <string> 
#include <cstring>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
//#include <boost/multiprecision/cpp_int.hpp>

#define BIT(a) (1 << (a))
#define EPS (1e-10)

using namespace std;
//using namespace boost::multiprecision;

const long long MOD = 1000000007;
const int COUNTER_CLOCKWISE = 1;
const int CLOCKWISE = -1;
const int ONLINE_BACK = 2;
const int ONLINE_FRONT = -2;
const int ON_SEGMENT = 0;

class Point{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}
    
    Point operator+(Point p){return Point(x + p.x, y + p.y);}
    Point operator-(Point p){return Point(x - p.x, y - p.y);}
    Point operator*(double a){return Point(a * x, a * y);}
    Point operator/(double a){return Point(x / a, y / a);}

    bool operator < (const Point &p) const {
        return y != p.y ? y < p.y : x < p.x;
    }

    double norm(){return x * x + y * y;}
};
typedef Point Vector;
typedef vector<Vector> Polygon;

double cross(Vector a, Vector b){
    return a.x*b.y - a.y*b.x;
}

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > EPS)return COUNTER_CLOCKWISE;
    if (cross(a, b) > -EPS)return CLOCKWISE;
    if (dot(a, b) < -EPS)return ONLINE_BACK;
    if (a.norm() < b.norm())return ONLINE_FRONT;

    return ON_SEGMENT;
}

Polygon andrewScan(Polygon s){
    Polygon u, l;
    if (s.size() < 3) return s;
    sort(s.begin(), s.end());
    u.push_back(s[0]);
    u.push_back(s[1]);
    l.push_back(s[s.size()-1]);
    l.push_back(s[s.size()-2]);
    
    for (size_t i = 2; i < s.size(); i++){
        for (size_t n = u.size(); n >= 2 && ccw(u[n-2], u[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            u.pop_back();
        }
        u.push_back(s[i]);
    }

    for (int i = (int)s.size() - 3; i >= 0; i--){
        for (size_t n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            l.pop_back();
        }
        l.push_back(s[i]);
    }

    reverse(l.begin(), l.end());
    for (size_t i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);

    return l;
}

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}


int main(void){
    int mountain[15];
    for (int i = 0; i < 10; i++){
        cin >> mountain[i];
    }
    sort(mountain, mountain+10);
    for (int i = 9; i > 9 - 3; i--){
        cout << mountain[i] << endl;
    }
    return 0;
}   




Measured memory_bytes: 3088
N, M = [int(nm) for nm in input().split()]
A = [int(a) for a in input().split()]
A.sort(reverse = True)

while M >= 1:
  A[0] //= 2
  M -= 1
  
  i = 1
  while True:
    if N >= i*2 + 1:
      A1, A2, A3 = A[i-1], A[i*2 - 1], A[i*2]
    elif N == i*2:
      A1, A2, A3 = A[i-1], A[i*2 - 1], 0
    else:
      A1, A2, A3 = A[i-1], 0, 0

    if A1 < A2 or A1 < A3:
      if A2 >= A3:
        A[i-1], A[i*2 - 1] = A2, A1
        i = i*2
      else:
        A[i-1], A[i*2] = A3, A1
        i = i*2 + 1
    else:
      break

ans = sum(A)
print(ans)

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

signed main() {
	int l, n;
	cin >> l >> n;
	vector<int> d(n);
	rep(i, n) {
		cin >> d[i];
	}
	vector<int> sum(n), rsum(n);
	int now = 0;
	int rnow = 0;
	rep(i, n) {
		sum[i] = now;
		rsum[n - 1 - i] = rnow;
		now += d[i];
		rnow += l - d[n - 1 - i];
	}
	int ans = 0;
	rep(i, n / 2) {
		now = (sum[i] + (rsum[i] - rsum[i * 2])) * 2;
		ans = max(ans, now + l - d[i]);
		now = (sum[i] + (rsum[i] - rsum[i * 2 + 1])) * 2;
		ans = max(ans, now + d[i]);
	}
	rep(i, n / 2) {
		now = (rsum[n - 1 - i] + (sum[n - 1 - i] - sum[n - 1 - (i * 2)])) * 2;
		ans = max(ans, now + d[n - 1 - i]);
		now = (rsum[n - 1 - i] + (sum[n - 1 - i] - sum[n - 1 - (i * 2 + 1)])) * 2;
		ans = max(ans, now + l - d[n - 1 - i]);
	}
	if(n % 2 == 1) {
		now = (sum[n / 2] + rsum[n / 2]) * 2;
		ans = max(ans, now + max(d[n / 2], l - d[n / 2]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
#include<cstdio>
#include<set>
#include<algorithm>
using namespace std;
const int maxn=5e5+2;
int n,k;
int a[maxn],id[maxn],l[maxn],r[maxn];
set<int> s;
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		id[a[i]]=i;
	}
	s.insert(n+1);
	id[n+1]=n+1;
	for (int i=1;i<=n;i++){
		s.insert(a[i]);
		if (i>k) s.erase(a[i-k]);
		int pos=id[*s.upper_bound(a[i])];
		l[i]=l[pos];
		r[l[pos]]=i;
		l[pos]=i;
		r[i]=pos;
	}
	int j=n;
	for (int i=l[n+1];i;i=l[i]) a[i]=j--;
	for (int i=1;i<=n;i++) printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 34816
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)
#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
#define popcountL __builtin_popcountll
#define popcount __builtin_popcount
typedef long long ll;
typedef long long int lln;
ll INF=1<<28;
//typedef long long lld;
const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
const long double EPS=1e-7;
//#define INF 10000
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}

bool cmp(int a, int b)
{
    return a<b;
}

int vis[200000];
struct compare
{
  bool operator()(const int& l, const int& r)
  {
      return vis[l]>vis[r];
  }
};
ll inf=1e18;
int mod=1e9+7;
const int sz=300005;
ll dp[1<<17];
int arr[20][20];
ll profit[1<<17];
int n;
void pre()
{
    ll sum=0;
    for(int i=1;i<=(1<<n);i++)
    {
        sum=0;
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j))
            {
                for(int k=j+1;k<n;k++)
                {
                    if(i&(1<<k))
                    {
                        sum+=arr[j][k];
                    }
                }
            }
        }
//        cout<<i<<" "<<sum<<endl;
        profit[i]=sum;
    }
}
ll fun(int mask)
{
//    cout<<mask<<endl;
    if(popcount(mask)==n)
    {
        return 0;
    }
    if(dp[mask]!=-1)
        return dp[mask];
    ll ans=0;
    int other=mask^((1<<n)-1);
    for(int j=other;j>0;j=other&(j-1))
    {
        ans=max(ans,profit[j]+fun(mask|j));
    }
//    for(int i=1;i<(1<<n);i++)
//    {
//        if((mask&i)==0)
//        {
//            ans=max(ans,profit[i]+fun(mask|i));
//        }
//    }
    return dp[mask]=ans;
}
int main()
{
//    READ;
//    cout<<(1<<4);
    sf(n);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
            sf(arr[i][j]);
    }
    mem(dp,-1);
    pre();
    cout<<fun(0)<<endl;
    return 0;
}


Measured memory_bytes: 1792
def main():
    N = int(input())
    A = list(map(int, input().split()))
    L, R = [0] * N, [0] * N
    s = [(-1, -1)]
    for i, a in enumerate(A):
        while s[-1][0] >= a:
            s.pop()
        L[i] = i - s[-1][1]
        s.append((a, i))
    s = [(-1, N)]
    for i in reversed(range(N)):
        a = A[i]
        while s[-1][0] >= a:
            s.pop()
        R[i] = s[-1][1] - i
        s.append((a, i))
    return sum(a * l * r for a, l, r in zip(A, L, R))

print(main())


Measured memory_bytes: 41124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
const int INF = 0x3f3f3f3f;

int main(){
	int n;
	scanf("%d",&n);
	if(n >= 400 && n < 600) printf("8\n");
	if(n >= 600 && n < 800) printf("7\n");
	if(n >= 800 && n < 1000) printf("6\n");
	if(n >= 1000 && n < 1200) printf("5\n");
	if(n >= 1200 && n < 1400) printf("4\n");
	if(n >= 1400 && n < 1600) printf("3\n");
	if(n >= 1600 && n < 1800) printf("2\n");
	if(n >= 1800 && n < 2000) printf("1\n");
	return 0;
}


Measured memory_bytes: 3760
# 素数探索（エラトステネスの篩）
# - 2の倍数を最初から除外してみた
# @param limit 探索する範囲（最大の整数）
# @return [Array] 素数配列
def eratosthenes(limit)
  # 探索リスト
  search_list = []
  3.upto limit do |i|
    search_list << i if i.odd?
  end
  # p search_list

  # 探索結果（素数配列）
  primes = [2]

  # 最後に見つかった素数がコレを越えたら探索終了（残りは全て素数）
  root_limit = Math.sqrt(limit)

  while (prime = search_list.shift) do
    # 探索リストの先頭は必ず素数
    primes << prime

    # primeが√limit を越えたら、残りは全て素数
    if root_limit < prime
      primes.concat(search_list)
      break
    end

    # primeの倍数を全て除去
    search_list.reject! { |i| i % prime == 0 }
  end

  primes
end


num = gets.chomp.to_i

# 『5で割って余り1』になる素数だけを集める
# ※55555までだと該当するのが1408個もある。該当数を55個見つければOKなので。
prime_numbers = eratosthenes(1500).select {|n| n % 5 == 1}
# puts "Len: #{prime_numbers.length}"
# puts prime_numbers

# 先頭から必要な数の部分配列を返す
ans_nums = prime_numbers[0, num]
puts ans_nums.join(" ")


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

int n,m;
string s1,s2,s3,s4;
int dp[3002][3002];

int go(int i,int j)
{   
	
	if(i>=n || j>=m)
	  { if(dp[i][j]==-1)
	      dp[i][j]=0;
	  }
	else
	  {
	     if(s1[i]==s2[j])
	       { if(dp[i][j]==-1) 
	       	  dp[i][j]=1+go(i+1,j+1);
	       }
	     else{if(dp[i][j]==-1)
	       dp[i][j]=max(go(i+1,j),go(i,j+1));
	    	}
	    	
	  }
	 return dp[i][j]; 
}

void path(int i,int j)
{
	if(i>=n)
	  return ;
	if(j>=m)
	  return ;
	int ans=dp[i][j];
	if(s1[i]==s2[j])
	  {
	  	  cout<<s1[i];
	  	  return path(i+1,j+1);
	  }
	else
	  {
	  	 if(ans==go(i+1, j))
			return path(i+1, j);
		return path(i, j+1);
	  }
}


int main() {
	//cin>>n>>m;
	cin>>s1>>s2;
	memset(dp,-1,sizeof(dp));
	n=s1.size();m=s2.size();
	int ans=go(0,0);
	//cout<<ans<<'\n';
    path(0,0);
	return 0;
}

Measured memory_bytes: 35840
/*
Original problem: https://atcoder.jp/contests/dp/tasks/dp_n
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

const ll inf = 1e18+5;

namespace SOLVE {
    void main() {
        // dp: find the cost of each subarray by choosing the min of possible splits
        int n;
        cin >> n;
        VLL A(n);
        REP(i,0,n){
            cin >> A[i];
        }
        vector<VLL> dp(n, VLL(n)); // dp[i][j] is the min cost to build i-j
        vector<VLL> S(n, VLL(n)); // S[i][j] is the sum of subarray i-j

        REP(length, 0, n) {
            REP(start, 0, n - length) {
                ll end = start + length;
                if (length == 0) {
                    S[start][start] = A[start];
                    dp[start][start] = 0;
                } else {
                    S[start][end] = S[start][end - 1] + A[end];
                    ll best = inf;
                    // dp[start][end] = min(dp[start][mid] + dp[mid + 1][end] + sum[start][end])
                    REP(mid, start, end) {
                        best = min(best, dp[start][mid] + dp[mid + 1][end] + S[start][end]);
                    }
                    dp[start][end] = best;
                }
            }
        }

        cout << dp[0][n-1] << endl;
    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {
  return (os << "(" << p.first << ", " << p.second << ")");
}
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  os << "[";
  for(int i = 0;i < v.size();i++) os << v[i] << ", ";
  return (os << "]");
}

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

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

int main() {
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  i64 N;
  cin >> N;
  vector<pair<i64, i64>> acnt(N);
  vector<pair<i64, i64>> bcnt(N);
  auto di = [](i64 a, i64 b) {
    i64 two = 0;
    while(a % b == 0) {
      a /= b;
      two++;
    }
    return two;
  };
  auto func = [di](i64 a) {
    return pair<i64, i64>(di(a, 2), di(a, 5));
  };

  rep(i,0,N) {
    string s;
    cin >> s;
    i64 a = 0;
    i64 b = 1;
    bool dot = false;
    for(auto c: s) {
      if(c == '.') {
        dot = true;
      }
      else {
        if(dot) {
          b *= 10;
        }
        i64 num = c - '0';
        a = 10 * a + num;
      }
    }
    i64 g = gcd(a, b);
    a /= g;
    b /= g;
    acnt[i] = func(a);
    bcnt[i] = func(b);
  }

  auto dp = ndvec(40, 40, 40, 40, 0ll);
  rep(i,0,N) {
    dp[acnt[i].first][acnt[i].second][bcnt[i].first][bcnt[i].second]++;
  }
  for(int i = 40; i --> 1;) rep(j,0,40) rep(k,0,40) rep(l,0,40) {
    dp[i - 1][j][k][l] += dp[i][j][k][l];
  }
  for(int i = 40; i --> 1;) rep(j,0,40) rep(k,0,40) rep(l,0,40) {
    dp[j][i - 1][k][l] += dp[j][i][k][l];
  }
  rep(i,0,40) rep(j,0,40) rep(k,0,39) rep(l,0,40) {
    dp[j][i][k + 1][l] += dp[j][i][k][l];
  }
  rep(i,0,40) rep(j,0,40) rep(k,0,40) rep(l,0,39) {
    dp[j][i][k][l + 1] += dp[j][i][k][l];
  }
  i64 ans = 0;
  rep(i,0,N) {
    ans += dp[bcnt[i].first][bcnt[i].second][acnt[i].first][acnt[i].second];
    if(bcnt[i].first == 0 && bcnt[i].second == 0) ans--;
  }
  cout << ans / 2 << endl;

}


Measured memory_bytes: 32492
import java.util.Scanner;

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

	public void solve(Scanner sc) {
		String n = sc.next();
		String answer = "";
		for(int i=0; i<n.length(); i++) {
			char a = n.charAt(i);
			if(a=='1') {
				answer += '9';
			} else {
				answer += '1';
			}
		}
		System.out.println(answer);
	}
}


Measured memory_bytes: 22228
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, k;
    scan(n, k);
    auto p = aryread();
    auto ave = new real[](n + 1);
    ave[0] = 0;
    foreach (i; iota(n))
        ave[i + 1] = (p[i] + 1).to!real / 2 + ave[i];

    // ave.writeln();
    real ans = 0;
    foreach (i; iota(n - k + 1))
    {
        // (ave[i + k] - ave[i]).writeln();
        ans = max(ans, ave[i + k] - ave[i]);
    }
    writefln("%.10s", ans);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 14872
#include <iostream>
#include <algorithm>
int main(){
  //NとMの値を初期化
  int N =0, M = 0;
  std::cin >> N >> M;


  int L = 0;
  int R = 0;
  int L_max = 0;
  int R_min = 100005;

  for(int i =0; i <  M; i++)
  {
    std::cin >> L >> R;
    L_max = std::max(L_max,L);
    R_min = std::min(R_min,R);
  }
  if( R_min >= L_max )
    std::cout << R_min - L_max + 1 << std::endl;
  else
    std::cout << 0 << std::endl;

  return 0;
}


Measured memory_bytes: 256
var n,len,ans,s,i,count,m:int64;
    a:array[1..3]of int64;
begin
read(n);
a[1]:=9;
a[2]:=909;
a[3]:=90909;
m:=n;
repeat
inc(count);
m:=m div 10;
until m<=0;
len:=count-1;
if len mod 2 = 1 then ans:=a[(len+1) div 2]
else begin 
s:=1;
for i := 1 to len do s:=s*10;
ans:=a[len div 2]+n-s+1
end;
write(ans);
end.

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

int main() {
    int a,b,c,d, water_a, water_b, sugar_c, sugar_d, sugar_env, beaker_full;
    cin >> water_a >> water_b >> sugar_c >> sugar_d >> sugar_env >> beaker_full;
    water_a *= 100;
    water_b *= 100;
    float max_sugar_rate=0, sugar_rate;
    int max_sugar_water=water_a, max_sugar=0;
    for(a=1; water_a*a<=beaker_full; a++){
        for(b=0; water_a*a+water_b*b<=beaker_full; b++) {
            for(c=0; water_a*a+water_b*b+sugar_c*c<=beaker_full; c++){
                for(d=0; water_a*a+water_b*b+sugar_c*c+sugar_d*d<=beaker_full; d++){
                    sugar_rate = float(sugar_c*c+sugar_d*d)/(water_a*a+water_b*b);
                    if(sugar_rate > float(sugar_env) / 100) break;
                    if(sugar_rate > max_sugar_rate) {
                        max_sugar_rate = sugar_rate;
                        max_sugar_water= water_a*a+water_b*b+sugar_c*c+sugar_d*d;
                        max_sugar = sugar_c*c+sugar_d*d;
                    }
                }
            }
        }
    }
    cout << max_sugar_water << " " << max_sugar << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define INF 1000000000000
#define MINF -1000000000000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int A, B, Q;
ll s[MAX_N + 2], t[MAX_N + 2], x[MAX_N + 2];
ll ANS[MAX_N];

void solve()
{
  REP(i, Q)
  {
    ll q = x[i + 1];
    int si = upper_bound(s, s + A, q) - s;
    int ti = upper_bound(t, t + B, q) - t;
    ll ans = INF;
    for (int i = -1; i <= 0; i++) {
      for (int j = -1; j <= 0; j++) {
        if (abs(s[si + i]) == INF || abs(t[ti + j]) == INF) continue;
        ans = min(ans, abs(q - s[si + i]) + abs(s[si + i] - t[ti + j]));
        ans = min(ans, abs(q - t[ti + j]) + abs(t[ti + j] - s[si + i]));
      }
    }
    ANS[i] = ans;
  }
  // REP(i, Q) { cout << ANS[i] << endl; }
  REP(i, Q) { cout << ANS[i] << SLN(i, Q); }
}

int main(void)
{
  cin >> A >> B >> Q;
  REP(i, A) cin >> s[i + 1];
  s[0] = MINF, s[A + 1] = INF;
  REP(i, B) cin >> t[i + 1];
  t[0] = MINF, t[B + 1] = INF;
  REP(i, Q) cin >> x[i + 1];
  x[0] = MINF, x[Q + 1] = INF;
  solve();
  return 0;
}


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

long long int mem[100006];


long long int frog_dp(long long int i,long long int n,long long int ht[],int k)
{
    int j;
    if(i>=n)return 0;
    if(mem[i]!=-1)return mem[i];
    if(k==1)
    mem[i]=frog_dp(i+1,n,ht,k)+abs(ht[i+1]-ht[i]);

    if(k!=1)
    mem[i]=min(frog_dp(i+1,n,ht,k)+abs(ht[i+1]-ht[i]),frog_dp(i+2,n,ht,k)+abs(ht[i+2]-ht[i]));

    for(j=3; j<=k; j++)
    {
        mem[i]=min(mem[i],frog_dp(i+j,n,ht,k)+abs(ht[i+j]-ht[i]));
    }

    return mem[i];
}

int main()
{
    long long int n,i,k;
    cin>>n>>k;
    long long int ht[n+k+3];
    for(i=1; i<=n; i++)
        cin>>ht[i];
        for(i=1; i<k; i++ )
        ht[n+i]=9999999999999;

        memset(mem,-1,sizeof(mem));
    cout<<frog_dp(1,n,ht,k)<<endl;


    return 0;
}




Measured memory_bytes: 9600
h, w = map(int, input().split())
a = [input() for i in range(h)]
b= [1] * (h + w)

for i in range(h):
    if not a[i].count('#'):
        b[i] = 0

for i in range(w):
    flag = True
    for j in range(h):
        if a[j][i] == '#':
            flag = False
    if flag:
        b[i + h] = 0

for i in range(h):
    for j in range(w):
        if b[i] and b[j + h]:
            print(a[i][j], end = '')
    if b[i]:
        print()


Measured memory_bytes: 4468
#include <iostream>
using namespace std;
int main(){
    string a;
    cin>>a;
    static int d[3],dem=0;
    for (int i = 0 ; i < a.size() ; i++){
        if (a[i]=='a')
            d[0]=1;
        if (a[i]=='b')
            d[1]=1;
        if (a[i]=='c')
            d[2]=1;
    }
    for (int i = 0 ; i < 3 ; i++)
        if (d[i]!=0)
            dem++;
    if (dem==3) cout<<"Yes";
    else    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

dp = [0] * n
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]))

print(dp[n - 1])

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

#define ll long long

using namespace std;

//memset(dp, 0, sizeof(dp));

void work(int T) {
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	cout << accumulate(v.begin(), v.begin() + k, 0) << endl;
	return;
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
	// int t;
	// for(cin >> t; t > 0; t--) {
		// work(t);
	// }
	work(0);
	return 0;
};

Measured memory_bytes: 3644