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

priority_queue< pair<long long,long long> > q;
long long x, y, a, b, c;
 
int main()
{
	cin >> x >> y >> a >> b >> c;
	while (a--)
	{
		long long w;
		cin >> w;
		q.push(make_pair(w, 1));
	}
	
	while (b--)
	{
		long long w;
		cin >> w;
		q.push(make_pair(w, 2));
	}
	
	while (c--)
	{
		long long w;
		cin >> w;
		q.push(make_pair(w, 3));
	}
	
	long long z = x + y;
	long long ans = 0;
	
	while (z)
	{
		pair<long long, long long> t = q.top();
		q.pop();
		if (t.second == 3)
		{
			ans += t.first;
			z--;
		}
		else if (t.second == 2 && y)
		{
			ans += t.first;
			z--;
			y--;
		}
		else if (t.second == 1 && x)
		{
			ans += t.first;
			z--;
			x--;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10476
import heapq
X,Y,Z,K = map(int,input().split())
As = sorted(list(map(int,input().split())),reverse=True)
Bs = sorted(list(map(int,input().split())),reverse=True)
Cs = sorted(list(map(int,input().split())),reverse=True)
q = []
heapq.heapify(q)
heapq.heappush(q,(-(As[0]+Bs[0]+Cs[0]),0,0,0))
list_ijk = [(0,0,0)]
for i in range(K):
    # valueのマイナス値の小さい順にpop(優先度付きqueue)
    v,i,j,k = heapq.heappop(q)
    if i < len(As)-1 and (i+1,j,k) not in list_ijk:
        heapq.heappush(q,(-(As[i+1]+Bs[j]+Cs[k]),i+1,j,k))
        list_ijk.append((i+1,j,k))
    if j < len(Bs)-1 and (i,j+1,k) not in list_ijk:
        heapq.heappush(q,(-(As[i]+Bs[j+1]+Cs[k]),i,j+1,k))
        list_ijk.append((i,j+1,k))
    if k < len(Cs)-1 and (i,j,k+1) not in list_ijk:
        heapq.heappush(q,(-(As[i]+Bs[j]+Cs[k+1]),i,j,k+1))
        list_ijk.append((i,j,k+1))
    print(-v)    


Measured memory_bytes: 4572
#include <stdio.h>

int main(void) {
    int i,n,max,min,s,s_ans,total;
    int count = 0;
    
    while(count<=20){
        total = 0;
        max = 0;
        min = 1000;
        
        scanf("%d",&n);
        if(n==0)
            break;
        
        for(i=0;i<n;i++){
            scanf("%d",&s);
            total+=s;
            if(s>max)
                max = s;
            if(s<min)
                min = s;
        }
        s_ans = (total-max-min) / (n-2);
        printf("%d\n",s_ans);
        count++;
    }
    return 0;
}

Measured memory_bytes: 600
n = int(input())
a = list(map(int,input().split()))
flag = 1
cnt = 0
while flag:
    flag = 0
    for j in range(n-1,0,-1):
        if a[j] < a[j-1]:
            cnt += 1
            a[j],a[j-1] = a[j-1],a[j]
            flag = 1
print(*a)
print(cnt)


Measured memory_bytes: 5608
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

n=int(input())
t=[]
for i in range(n):
    t.append(int(input()))

ans=t[0]
for i in range(1,n):
    ans=lcm(ans,t[i])
print(ans)


Measured memory_bytes: 9052
from collections import deque

N = int(input())

g = [[] for _ in range(N)]
color = [[] for _ in range(N)]
mi = [[] for _ in range(N)]
MA = [[] for _ in range(N)]
edge = {}
ans = [0]*(N-1)
M = 0

for i in range(N-1):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
    ans[i] = (a,b)

stack = deque([0])
not_visit = [True]*N
not_visit[0] = False
while stack:
    now = stack.popleft()
    for i in g[now]:
        if not_visit[i]:
            stack.append(i)
            if not mi[now]:
                mi[now] = 1
                MA[now] = 1
                mi[i] = 1
                MA[i] = 1
                M = 1
                color[now].append(mi[now])
                color[i].append(mi[now])
                edge[(now+1,i+1)] = mi[now]
                edge[(i+1,now+1)] = mi[now]
            else:
                if mi[now] != 1:
                    mi[now] -= 1
                    color[now].append(mi[now])
                    color[i].append(mi[now])
                    edge[(now+1,i+1)] = mi[now]
                    edge[(i+1,now+1)] = mi[now]
                    if mi[i]:
                        mi[i] = min(mi[i],mi[now])
                    else:
                        mi[i] = mi[now]
                        MA[i] = mi[now]
                else:
                    MA[now] += 1
                    color[now].append(MA[now])
                    color[i].append(MA[now])
                    edge[(now+1,i+1)] = MA[now]
                    edge[(i+1,now+1)] = MA[now]
                    M = max(M,MA[now])
                    if MA[i]:
                        MA[i] = max(MA[i],MA[now])
                    else:
                        MA[i] = MA[now]
                        mi[i] = MA[now]

            not_visit[i] = False

print(M)
for i in range(N-1):
    print(edge[ans[i]])

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	string s;
	cin >> s;
	for(int i=1;i<s.length()-1;i++){
		char stmp[s.length()];
		size_t length = s.copy(stmp,s.length()-i,0);
		stmp[length]='\0';
		REP(j,length/2+1){
			if(length%2!=0) break;
			if(stmp[j]!=stmp[j+length/2]) break;
			if(j==length/2-1){
				cout << length << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll n, k, ans=0;
  cin >> n >> k;
  if (k % 2 == 1) {
    int c0 = 0;
    REP(i, n) {
      if ((i + 1) % k == 0) c0++;
    }
    ans += (ll)pow(c0, 3);
  } else {
    int c1=0, c2=0;
    REP(i,n){
      if ((i+1) % k == 0) c1++;
      if ((i+1) % k == k / 2) c2++;
    }
    ans += (ll)pow(c1, 3);
    ans += (ll)pow(c2, 3);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
//const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
bool dp[12][100005];
int ans[100005];
V<int> g[100005];
void solve(int d,int cur,int c){
	 if(dp[d][cur])return;
	 dp[d][cur]=1;
	 if(ans[cur]==0)ans[cur]=c;
	 if(d==0)return;
	 if(!dp[d-1][cur]){
		solve(d-1,cur,c);
	 }
	 for(int v:g[cur]){
		 solve(d-1,v,c);
	 }
}
struct Data{
	int v,d,c;
};
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		g[--a].push_back(--b);
		g[b].push_back(a);
	}
	int q;
	cin>>q;
	V<Data> d(q);
	for(int i=0;i<q;i++){
		cin>>d[i].v>>d[i].d>>d[i].c;
	}
	reverse(all(d));
	for(int i=0;i<q;i++){
		solve(d[i].d,d[i].v-1,d[i].c);
	}
	for(int i=0;i<n;i++)cout<<ans[i]<<"\n";
}

Measured memory_bytes: 11728
/* author   : mpily :-()
title : Competing.cpp
time :Sun Oct 27 14:59:44 2019

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int A,B;
	cin>>A>>B;
	if(A > 9 || B > 9)cout<<-1<<"\n";
	else cout<<A*B<<"\n";
	return 0;
}


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



int main(){
    int n,T;
    cin>>n>>T;
    int c[105],t[105];
    for(int i=0;i<n;i++){
        cin>>c[i]>>t[i];
    }
    int ans=100000;
    for(int i=0;i<n;i++){
        if(t[i]<=T){
            if(c[i]<ans){
                ans=c[i];
            }
        }
    }
    if(ans==100000){
        cout<<"TLE"<<endl;
    }else{
    cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(true)
    {
        c-=b;
        if(c<=0)
        {
            cout<<"Yes";
            break;
        }
        a=a-d;
        if(a<=0)
        {
            cout<<"No";
            break;
        }
    }
}

Measured memory_bytes: 3588
N = gets.chomp.to_i
t = gets.chomp.split.map(&:to_i)

total_sum = 0
a = 0

while a < N do
    sum = 0
    b = a + 1
    
    while b < N do
        sum += t[a] * t[b]
        b += 1
    end
    total_sum += sum
    a += 1
end

puts total_sum

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <stack>
#include <cstdint>
typedef long long int llint;

int main(void){
  int a, b;
  std::cin >> a >> b;
  if(a != 1 && b!= 1) std::cout << 1 << std::endl;
  if(a != 2 && b!= 2) std::cout << 2 << std::endl;
  if(a != 3 && b!= 3) std::cout << 3 << std::endl;
  return 0;
}


Measured memory_bytes: 256
N, A, B = map(int,input().split())
S = input()
yosen = 0
yosen_b = 1
for i in range(N):
    if S[i] == "a" and yosen < (A + B):
            print("Yes")
            yosen += 1
    elif S[i] == "b" and yosen < (A + B) and yosen_b <= B:
            print("Yes")
            yosen += 1
            yosen_b += 1
    else:
        print("No")

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#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 total=0;
    int date=0;
    while(C>total){
        date++;
        total+=A;
        if(date%7==0) total+=B;
    }
    cout << date << endl;

    return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

void dfs(int pos ,vector< vector<int> > &G, vector<int> &color){
    // cout << "now at " << pos << endl;
    for(auto x : G[pos]){
        if(color[x] != -1) continue;
        // cout << "next is " << x.first << endl;
        color[x]=1;
        // rep(i,n) cout << color[i] << " ";cout << endl;
        dfs(x, G, color);
    }
    return;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector< vector<int> > G(n, vector<int>(0,0));
    vector<int> color(n,-1);
    rep(i,m){
        int u,v,w;
        cin >> u >> v >> w;

        G[u-1].push_back(v-1);
        G[v-1].push_back(u-1);
    }

    int cnt=0;
    for(int node =0; node<n; node++){
        if(color[node]==-1){
            cnt++;
            dfs(node,G,color);
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 10752
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;

    char p[100][100];

    REP(i, h){
        REP(j, w){
            cin >> p[i][j];
        }
    }

    for(int i = 0; i < h + 2; ++i){
        for(int j = 0; j < w + 2; ++j){
            if(i == 0 || j == 0 || i == h + 1 || j == w + 1) cout << '#';
            else cout << p[i - 1][j - 1];
        }
        cout << endl;
    }

    return 0;
}


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

using namespace std;

const int MAX = 410 ;
long long arr[MAX] , dp[MAX][MAX] ;

long long solve(int l , int r)
{
    if(l == r)
        return 0 ;
    if(l > r)
        return 1e16 ;
    if(r-l == 1)
        return (arr[l] + arr[r]) ;
    long long &ret = dp[l][r] ;
    if(ret != -1)
        return ret ;
    ret = 1e15 ;
    long long sum = 0 ;
    for(int i = l ; i < r ; ++i)
        ret = min(ret , solve(l , i) + solve(i+1 , r)) , sum += arr[i];
    sum += arr[r] ;
    ret = ret + sum ;
    return ret ;
}

int main()
{
    memset(dp , -1 , sizeof(dp));
    int n ;
    cin>>n ;
    for(int i = 0 ; i < n ; ++i)
        cin>>arr[i] ;
    return cout<<solve(0 , n-1)<<"\n" , 0 ;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

vector<int> neg, pos;
int z = 0;

ll calc(ll x){
    //<= x
    //assert(x >= 0);
    ll res = 0;
    if (x >= 0){
        res = z * ll(sz(neg) + sz(pos)) + 1ll * sz(neg) * sz(pos) + z * (z-1ll) / 2;
        //cout << res << endl;
        int r = sz(neg)-1;
        reverse(all(neg));
        for (int i = 0; i < r; i++){
            while (i < r && 1ll * neg[i] * neg[r] > x){
                r--;
            }
           // cout << 1ll * neg[i] * neg[r] << " "<< r << endl;
            res += r-i;
        }
        reverse(all(neg));
        r = sz(pos)-1;
        for (int i = 0; i < r; i++){
            while (i < r && 1ll * pos[i] * pos[r] > x){
                r--;
            }
            res += r-i;
        }
    }
    else{
        int r = 0;
        for (int i = 0; i < sz(neg); i++){
            while (r < sz(pos) && 1ll * neg[i] * pos[r] > x){
                r++;
            }
            res += sz(pos) - r;
        }
    }
    return res;
}

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, x;
    ll k;
    cin >> n >> k;
    while (n--){
        cin >> x;
        if (x == 0) z++;
        else if (x < 0){
            neg.pb(x);
        }
        else{
            pos.pb(x);
        }
    }
    sort(all(neg));
    sort(all(pos));
    //cout << sz(neg) << " " << z << " " << sz(pos) << endl;
    //cout << calc(448283280358331064) << endl;
    ll l = -INF-1, r = INF;
    while (r - l > 1){
        //cout << l << " " << r << endl
        ll mid = (l+r)/ 2;
        if (calc(mid) < k){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    cout << r;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

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

  vector< pair<int, int> > ct(n);
  for(int i = 0; i < n; i++) {
    int c, t;
    cin >> c >> t;
    ct[i] = make_pair(c, t);
  }

  int ans = 1001;
  for(int i = 0; i < n; i++) {
    if(ct[i].second <= T && ct[i].first < ans) ans = ct[i].first;
  }

  if(ans == 1001) cout << string("TLE") << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,d[100000];
deque<ll>que;
int main(void){
    cin>>n;
    d[1]=1;
    que.push_back(1);
    while(que.size()){
        ll p=que.front();
        que.pop_front();
        for(int i=0;i<2;i++){
            ll u=i?(p+1)%n:(p*10)%n;
            if(d[u]&&d[u]<=d[p]+i)continue;
            d[u]=d[p]+i;
            i?que.push_back(u):que.push_front(u);
        }
    }
    cout<<d[0]<<endl;
}


Measured memory_bytes: 1408
n = int(input())

verdicts = []
ac = 0
wa = 0
tle = 0
re = 0

for _ in range(n):
    t = input()
    verdicts.append(t.upper())
    
for verdict in verdicts:
    if verdict == 'AC':
        ac += 1
    elif verdict == 'WA':
        wa += 1
    elif verdict == 'TLE':
        tle += 1
    elif verdict == 'RE':
        re += 1
        
print(f'AC x {ac}\nWA x {wa}\nTLE x {tle}\nRE x {re}')

Measured memory_bytes: 79368
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, K := ReadInt(), ReadInt()
	as := ReadInts(N)
	dp := make([]bool, K+1)
	for i := 1; i < K+1; i++ {
		for _, a := range as {
			if i-a >= 0 {
				if dp[i-a] == false {
					dp[i] = true
					break
				}
			}
		}
	}
	if dp[K] {
		fmt.Println("First")
	} else {
		fmt.Println("Second")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1960
#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(), x.end()
using namespace std;

const int mxN = 1e5+1;
ll dp[mxN][101], val[101]; int w[101];

ll knapsack(int n, ll c, int ind) {
    if(ind <= 0 || ind > n || c <= 0)
        return dp[c][ind] = 0;
    ll prof1 = 0;
    if(w[ind] <= c) {
        if(dp[c][ind] != -1) {
            return dp[c][ind];
        }
        prof1 = val[ind] + knapsack(n, c-w[ind], ind+1);
    }
    ll prof2 = knapsack(n, c, ind+1);
    return dp[c][ind] = max(prof1, prof2);
 
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    // dp[i][j] == max value of bag with weight i and last item j
    int n, c;
    cin >> n >> c;
    for(int i = 1; i <= n; i++)
        cin >> w[i] >> val[i];

    memset(dp, -1, sizeof(dp));
    ll ans = knapsack(n, c, 1);
    cout << ans << '\n';
}


Measured memory_bytes: 82496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

const int MAX_N = 1e5;
bool ispn[MAX_N];
int dp[MAX_N];

void init_prime_number() {
    int n = sqrt(MAX_N);
    rep(i, MAX_N) ispn[i] = true;
    ispn[0] = false;
    ispn[1] = false;
    
    reps(i, 2, n + 1) {
        if (!ispn[i]) {
            continue;
        }
        
        for (int ii = 2 * i; ii < MAX_N; ii += i) {
            ispn[ii] = false;
        }
    }
}

void init_dp() {
    rep(i, MAX_N) {
        dp[i] = 0;
    }
    
    reps(i, 1, MAX_N) {
        int p = 0;
        
        if ((i != 2) && (ispn[i] && ispn[(i + 1) / 2])) {
            p = 1;
        }
        
        dp[i] = dp[i - 1] + p;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int q;
    cin >> q;
    init_prime_number();
    init_dp();
    
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;
    }
    
    return 0;
}


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


int main(){
    int A,B;
    cin >> A >> B;
    cout << max(A-2*B,0) << endl;
    return 0;
}

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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    lld A;
    long double B;
    cin >> A >> B;
    cout << (lld)((long double)A * B) << endl;
}

Measured memory_bytes: 3732
function main(input){
  input = input.split('\n');

  const ns = input[0].split('').map(Number);
  const sum = ns.reduce((sum, n)=> sum + n, 0)

  console.log((sum%9 == 0)? 'Yes': 'No');

}

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


Measured memory_bytes: 35284
def prime_factorize(num)
  res = 0

  while num % 2 == 0
    res += 1
    num /= 2
  end

  res
end

n = gets.to_i
as = gets.split.map(&:to_i)

puts as.inject(0) { |r, a| r + prime_factorize(a) }


Measured memory_bytes: 2300
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
ans = 0
ls = []
for i in range(n):
    if t[i] == "r":
        if len(ls) >= k:
            if ls[-k] != "r":
                ans += p
                ls.append("r")
            else:
                ls.append("x")
        else:
            ans += p
            ls.append("r")
    elif t[i] == "s":
        if len(ls) >= k:
            if ls[-k] != "s":
                ans += r
                ls.append("s")
            else:
                ls.append("x")
        else:
            ans += r
            ls.append("s")
    else:
        if len(ls) >= k:
            if ls[-k] != "p":
                ans += s
                ls.append("p")
            else:
                ls.append("x")
        else:
            ans += s
            ls.append("p")
print(ans)

Measured memory_bytes: 4212
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int s=0;
	
	for(int i=0; i<s1.size(); i++)
	{
		if(s1[i]!=s2[i])
			s++;
	}
	
	cout<<s<< endl;
	return 0;
}

Measured memory_bytes: 3852
from sys import stdin
l = list(stdin.readline().rstrip())
zero_count=l.count('0')
one_count=l.count('1')
if zero_count > one_count:
    print(one_count*2)
elif zero_count < one_count:
    print(zero_count*2)
elif zero_count == one_count:
    print(len(l))
elif len(l) == 1:
    print(0)

Measured memory_bytes: 3956
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

  vector<vector<bool>> g(n, vector<bool>(n, false));

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a][b] = true;
    g[b][a] = true;
  }

  vector<int> p(n);
  for (int i = 0; i < n; i++)
    p[i] = i;

  int ans = 0;
  do {
    if (p[0] != 0)
      continue;

    bool ok = true;
    for (int i = 0; i + 1 < n; i++) {
      int f = p[i], t = p[i + 1];
      if (!(g[f][t] || g[t][f])) {
        ok = false;
      }
    }

    if (ok) {
      ans++;
    }

  } while (next_permutation(p.begin(), p.end()));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, j, n) for (int i = j; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;


int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<pair<int,int>> p(n);
    rep(i,n){
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(),p.end());
    int ans = 0;
    int idx = 0;
    while(1){
        if(k<=0) break;
        k-=p[idx].second;
        idx++;
    }
    ans =p[idx-1].first;
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		sc.close();

		String aa = "";
		for (int i = 0; i < b; i++) {
			aa += String.valueOf(a);
		}

		String bb = "";
		for (int i = 0; i < a; i++) {
			bb += String.valueOf(b);
		}

		if (aa.compareTo(bb) < 0) {
			out.println(aa);
		} else {
			out.println(bb);
		}

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <tuple>
using namespace std;
vector<long long>D; long long n, p, w[100009], b[100009], E;
int main() {
	cin >> n >> p;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> b[i];
		E += (b[i] * p);
		D.push_back((w[i] * (100 - p)) + (b[i] * p));
	}
	sort(D.begin(), D.end(), greater<long long>());
	for (int i = 0; i < D.size(); i++) {
		E -= D[i]; if (E <= 0) { cout << i + 1 << endl; break; }
	}
	return 0;
}

Measured memory_bytes: 2676
#include <stdio.h>
int heapsize,A[500001];
void buildMapHeap();
void maxHeapify(int );
void print();


int main(void){
  int i=1;
  scanf("%d",&heapsize);
  for(;i<=heapsize;i++)
    scanf("%d",&A[i]);

  buildMapHeap();//create max-heap
  print();
  
  return 0;
}

void buildMapHeap(){
  int i;
  for(i=heapsize/2;i>=1;i--)
    maxHeapify(i);
}
void maxHeapify(int parent){
  int left,right,maxnode,temp;
  left=2*parent;
  right=left+1;

  if(left<=heapsize && A[left] > A[parent])
    maxnode=left;
  else
    maxnode=parent;
  if(right<=heapsize && A[right] > A[maxnode])
    maxnode=right;

  if(maxnode!=parent){
    //need to swap node
    temp=A[maxnode];
    A[maxnode]=A[parent];
    A[parent]=temp;

    if(maxnode*2<=heapsize)
      //there is child of maxnode
      maxHeapify(maxnode);
  }
}
void print(){
  int i=1;
  for(;i<=heapsize;i++)
    printf(" %d",A[i]);
  printf("\n");
}



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

int main() {
  //宣言
  int N,Ai;
  int ans = 100000;
  int Ri = 0;
  
  //入力
  cin >> N;
  
  //処理
  for(int i = 0; i<N ; i++){
    cin >> Ai;
    while(Ai%2 == 0){
      Ai /= 2;
      Ri++;
    }
    ans = min(Ri,ans);
    Ri = 0;
  }
  
  //出力
  cout << ans << endl;
}

Measured memory_bytes: 256
/**
*     => Md. Sajjat Hosen
*     => Department of Computer Science and Engineering
*     => Bangabandhu Sheikh Mujibur Rahman Science and Technology University
**/

/*..................! TRY ONCE MORE !..................*/

/*...Part - 01...*/

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

/*...Part - 02...*/

typedef long long               ll ;
typedef long double             ld ;
typedef unsigned long long      ull ;
typedef pair<int,int>           pii ;
typedef pair<ll,ll>             pll ;
typedef vector<int>             vi ;
typedef vector<ll>              vll ;
typedef vector<vector<int>>     vvi ;

int Int(){int x ; scanf("%d",&x) ; return x ;}
ll Long(){ll x ; scanf("%lld",&x) ; return x ;}
float Float(){float x ; scanf("%f",&x) ; return x ;}
double Double(){double x ; scanf("%lf",&x); return x;}

/*...Part - 03...*/
/*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/*...Part - 04...*/
/*...Needed to change according to problem requirements...*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;

/*..........................................................*/
/*...Part - 05...*/

#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

/*...Part - 06...*/
/*...... ! Code start from here ! ......*/



int main(){
    //freopen("input.txt","r",stdin);
    int test = 1 , tc = 0 ;
    while(test--){
        int flag = 0;
        int n;
        n = Int;
        int a[n];
        for(int i = 0; i < n; i++)
            a[i] = Int;
        for(int i = 0; i < n; i++){
            if(a[i] % 2 == 0){
                if(a[i] % 3 == 0 or a[i] % 5 == 0){

                }
                else{
                    flag = 1;
                    break;
                }
            }
        }
        if(flag)
            printf("DENIED\n");
        else
            printf("APPROVED\n");
    }
    return 0 ;
}

/*...Always look at the part - 04...*/
/*...............END................*/


Measured memory_bytes: 256
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  map<string, int> mp;
  mp["SAT"] = 1;
  mp["FRI"] = 2;
  mp["THU"] = 3;
  mp["WED"] = 4;
  mp["TUE"] = 5;
  mp["MON"] = 6;
  mp["SUN"] = 7;

  string s; cin >> s;
  cout << mp[s] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi = 3.141592654;
void solve()
{
   ll n;
   cin>>n;
   ll ans=0,temp=INT_MAX;
   for(int i=0;i<n;i++)
   {
       ll x;
       cin>>x;
       if(x<=temp)
       {
           ans++;
           temp=x;
           
       }
   }
   cout<<ans<<endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

vector<ll> all_divs(ll n){
    vector<ll> ret;
    for(ll i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long K;
    cin >> K;
    ll count=0;
    ll seven = 7;
    ll a[1000001];
    // 下一桁: 1 3 7 9
    // 鳩ノ巣原理：n, mを自然数とし、n > mとしたとき、
    // n 個のものを m 組にわけるとき少なくとも一つの組は２個以上のものを含む
    // ex.)5つの巣に72羽をいれるとき、15羽以上の鳩が入っている箱が少なくとも一つ存在する
    a[1]=7%K;
    for(size_t i=2;i<=K; i++)
    {
        a[i]=(a[i-1]*10+7)%K;
    }
    for(size_t i=1;i<=K; i++)
    {
        if(a[i]==0)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    /*
    while(true)
    {
        cerr << seven << endl;
        vector<ll> divs = all_divs(seven);
        for(auto i : divs) cerr << i << " ";
        cerr << endl;
        count++;
        seven = seven * 10 + 7;
        if(count==15) break;
    }
    */

#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 11372
#include <bitset>
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  bitset<30> B;
  B.set();
  for (int i = 0; i < N; ++i) {
    int K;
    cin >> K;
    bitset<30> _B;
    for (int j = 0; j < K; ++j) {
      int a;
      cin >> a;
      _B.set(a - 1, true);
    }
    B &= _B;
  }
  int cnt = 0;
  for (int i = 0; i < M; ++i) {
    if (B.test(i)) {
      ++cnt;
    }
  }
  printf("%d\n", cnt);
}

Measured memory_bytes: 3216
N=int(input())
a=list(map(int,input().split()))
a.sort()
k=max(a)
dp=[1]*(k+1)
ans=0
for i in range(N):
  if dp[a[i]]==1:
    ans+=1
    if i<N-1 and a[i+1]==a[i]:
      ans-=1
    for j in range(a[i],k+1,a[i]):
      dp[j]=0
print(ans)


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

int main() {
  int n, a[20], b, c[20], p = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b;
    p += b;
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < n - 1; i++) {
    if (a[i + 1] - a[i] == 1) {
      p += c[a[i] - 1];
    }
  }
  cout << p << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	if (c - b == b - a)cout << "YES\n";
	else cout << "NO\n";
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

// reference: https://betrue12.hateblo.jp/entry/2020/02/17/020628

ll dp[1001001][2];
signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  s='0'+s;
  ll n=s.size();
  vll a(n);
  rep(i,n){
    a[i]=s[i]-'0';
  }
  
  rep(i,n+1) rep(j,2) dp[i][j]=LINF;
  dp[0][0]=0;
  rep(i,n){
    chmin(dp[i+1][0],dp[i][0]+a[i]);
    chmin(dp[i+1][1],dp[i][0]+a[i]+1);
    chmin(dp[i+1][0],dp[i][1]+10-a[i]);
    chmin(dp[i+1][1],dp[i][1]+10-a[i]-1);
  }
  ll ans=dp[n][0];
  cout<<ans<<endl;
}

Measured memory_bytes: 24776
#include <stdio.h>
#include <math.h>

int main(void){
    double x,h,sum;
    for(;sum=0,scanf("%lf",&x),scanf("%lf",&h),h;){
        sum=sqrt(h*h+x*x/4)*2*x+x*x;
        printf("%f\n",sum);
    }
    return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll s, w;
    cin >> s >> w;
    if(w >= s)
        cout << "unsafe";
    else
        cout << "safe";
}


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

using namespace std;

#define MOD 998244353

int n, po[200005], x[200005], y[200005], za[800005], zb[800005], ans;
pair<int, int> pa[200005], pb[200005];

void add(int& a, int b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

void build(int l, int r, int i) {
	if (l + 1 == r) {
		zb[i] = 1;
		return;
	}
	int mi = (l + r) / 2;
	build(l, mi, i * 2);
	build(mi, r, i * 2 + 1);
	zb[i] = zb[i * 2] + zb[i * 2 + 1];
}

void f1(int a, int l, int r, int i) {
	za[i]++;
	if (a == l && a + 1 == r)
		return;
	int mi = (l + r) / 2;
	if (a < mi)
		f1(a, l, mi, i * 2);
	else
		f1(a, mi, r, i * 2 + 1);
}

void f2(int a, int l, int r, int i) {
	zb[i]--;
	if (a == l && a + 1 == r)
		return;
	int mi = (l + r) / 2;
	if (a < mi)
		f2(a, l, mi, i * 2);
	else
		f2(a, mi, r, i * 2 + 1);
}

int qa(int a, int b, int l, int r, int i) {
	if (a == l && b == r)
		return za[i];
	int mi = (l + r) / 2, re = 0;
	if (a < mi)
		re = qa(a, min(mi, b), l, mi, i * 2);
	if (mi < b)
		re += qa(max(mi, a), b, mi, r, i * 2 + 1);
	return re;
}

int qb(int a, int b, int l, int r, int i) {
	if (a == l && b == r)
		return zb[i];
	int mi = (l + r) / 2, re = 0;
	if (a < mi)
		re = qb(a, min(mi, b), l, mi, i * 2);
	if (mi < b)
		re += qb(max(mi, a), b, mi, r, i * 2 + 1);
	return re;
}

int main() {
	po[0] = 1;
	for (int i = 1; i < 200005; i++) {
		po[i] = po[i - 1];
		add(po[i], po[i]);
	}
	for (int i = 0; i < 200005; i++)
		po[i]--;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &pa[i].first, &pb[i].first);
		pa[i].second = pb[i].second = i;
	}
	sort(pa, pa + n);
	for (int i = 0; i < n; i++)
		x[pa[i].second] = i;
	sort(pb, pb + n);
	ans = (long long)po[n] * n % MOD;
	build(0, n, 1);
	// printf("%d\n", ans);
	for (int i = 0; i < n; i++) {
		int id = pb[i].second;
		f2(x[id], 0, n, 1);
		// printf("%d %d %d %d\n", i, n - i - 1, x[id], n - x[id] - 1);
		add(ans, MOD - po[i]);
		add(ans, MOD - po[n - i - 1]);
		add(ans, MOD - po[x[id]]);
		add(ans, MOD - po[n - x[id] - 1]);
		if (x[id]) {
			// printf("A %d %d\n", qa(0, x[id], 0, n, 1), qb(0, x[id], 0, n, 1));
			add(ans, po[qa(0, x[id], 0, n, 1)]);
			add(ans, po[qb(0, x[id], 0, n, 1)]);
		}
		if (x[id] + 1 != n) {
			// printf("B %d %d\n", qa(x[id] + 1, n, 0, n, 1), qb(x[id] + 1, n, 0, n, 1));
			add(ans, po[qa(x[id] + 1, n, 0, n, 1)]);
			add(ans, po[qb(x[id] + 1, n, 0, n, 1)]);
		}
		f1(x[id], 0, n, 1);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 11904
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define print(x) cout << #x << " = " << x << endl;

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = acos(-1);
const long double eps = 1e-7;


const int MAX = 100001;

int n, m;
int l, r, d;
int numUsedTerm;		// 使用した条件の数え上げ
vector<pii> terms[MAX];	// 条件（first: エッジの先のインデックス、second：距離）
bool bHasLeft[MAX];		// 左に人がいるかどうか
bool bSearched[MAX];	// 探索をすでにしているかどうか
int dis[MAX];			// 距離を保存
bool bWrong;			// 矛盾が発生しているかどうか

// 深さ優先探索
void dfs(int p) {
	bSearched[p] = 1;
	numUsedTerm++;

	// インデックスpのノードにおける条件すべてをループ
	for (pii term : terms[p]) {
		// どのノードを探索しているか
		//printf("%2d->%2d\n", p, term.first);

		if (!bSearched[term.first]) {	// エッジの先がまだ探索されていない場合
			dis[term.first] = dis[p] + term.second;	// 距離を保存
			dfs(term.first);	// 次のエッジを探索
		}
		else {	// エッジの先がすでに探索済みである場合
			if (dis[p] + term.second != dis[term.first]) {	// 既に探索した道のりと現在辿ってきた道のりが異なる場合
				bWrong = true;
				return;
			}
		}
	}
}

int main() {
	scanf("%d %d", &n, &m);

	for (int i = 0; i < m; i++) {
		scanf("%d %d %d", &l, &r, &d);

		terms[l].push_back(pii({ r, d }));
		bHasLeft[r] = true;
	}

	for (int i = 1; i <= n; i++) {
		// 左に人がいる時はスキップ
		if (bHasLeft[i]) continue;

		// 一番右になりえる要素から探索スタート
		dfs(i);
	}

	if (bWrong || numUsedTerm < n) printf("No\n");
	else printf("Yes\n");

	//system("pause");
	return 0;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int N = 1e4;

void solve() {
  int n; cin >> n;
  vector<int> d1(n), d2(n);
  for (int i = 0; i < n; i++) {
    cin >> d1[i] >> d2[i];
  }
  for (int i = 0; i + 3 - 1 < n; i++) {
    if (d1[i] == d2[i] && d1[i + 1] == d2[i + 1] && d1[i + 2] == d2[i + 2]) {
      cout << "Yes"; return;
    }
  }
  cout << "No";
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(2);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


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

using namespace std;
typedef long long ll;
ll n,m,r,a[222222],l=1e9,ans;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    cin>>n>>m;
    l=1;
    for(int i=1; i<=n; i++){
        cin>>a[i];
        r=max(a[i],r);
    }
    ans = r;
    while(l<=r){
        ll mid = l+r>>1,cnt = 0;
        for(int i=1; i<=n; i++) cnt += (a[i]-1)/mid;
        if(cnt > m) l = mid + 1;
        else{
            ans = mid;
            r = mid - 1;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 5148
N=input()
A=list(map(int,input().split()))
M=max(A)+1
B=[True]*M
S=set()
x=0
for i in A:
  if i not in S:
    S.add(i)
    for j in range(i*2,M,i):
      B[j]=False
  else:
    B[i]=False
for i in A:
  if B[i]==True:
    x+=1
print(x)

Measured memory_bytes: 39552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int ans[N+1];
    fill(ans, ans+N+1, 0);
    rep2(i, 1, 100){
        rep2(j, 1, 100){
            rep2(k, 1, 100){
                int x = i*i+j*j+k*k+i*j+j*k+k*i;
                if(x <= N) ans[x]++;
            }
        }
    }
    rep2(i, 1, N){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3440
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin>>a;
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)	
			if(a==i*j){
			cout<<"Yes\n";
			return 0;}
	cout<<"No\n";
	return 0;
 } 

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

using namespace std;

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

  string r, g, b;
  cin >> r >> g >> b;
  int a = stoi(r + g + b);
  if (a % 4 == 0) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N, M;
  cin >> N >> M;
  cout << (1900 * M + 100 * (N - M)) * power(2, M) << '\n';
}


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

using namespace std;

int main(){
	int n, m ,k;
	while(cin >> n >> m >> k, n){
		vector<double> cur(n*m+1, 0.0);
		cur[0] = 1.0;
		for(int i=0;i<n;i++){
			vector<double> next(n*m+1, 0.0);
			for(int j=0;j+m<=n*m;j++)
				for(int l=1;l<=m;l++)
					next[j+l] += cur[j]/m;
			cur = next;
		}
		double ans = 0.0;
		for(int i=1;i<=n*m;i++)
			ans += cur[i]*max(1,i-k);
		printf("%.8lf\n", ans);
	}
}

Measured memory_bytes: 0