akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    int N;
    int K;
    cin >> N >> K;

    vector<vector<int>> counts(2 * K, vector<int>(2 * K));

    for (int i = 0; i < N; ++i) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'W') {
            x += K;
        }
        ++counts[y % (2 * K)][x % (2 * K)];
    }

    // cerr << "==== counts ====\n";
    // for (int y = 0; y < 2 * K; ++y) {
    //     for (int x = 0; x < 2 * K; ++x) {
    //         cerr << counts[y][x] << ' ';
    //     }
    //     cerr << '\n';
    // }

    vector<vector<int>> xsums(2 * K, vector<int>(2 * K));
    for (int y = 0; y < 2 * K; ++y) {
        int s = 0;
        for (int x = 0; x < K; ++x)
            s += counts[y][x];

        for (int x = 0; x < 2 * K; ++x) {
            xsums[y][x] = s;

            s -= counts[y][x];
            s += counts[y][(x + K) % (2 * K)];
        }
    }

    // cerr << "==== xsums ====\n";
    // for (int y = 0; y < 2 * K; ++y) {
    //     for (int x = 0; x < 2 * K; ++x) {
    //         cerr << xsums[y][x] << ' ';
    //     }
    //     cerr << '\n';
    // }

    vector<vector<int>> ysums(2 * K, vector<int>(2 * K));
    for (int x = 0; x < 2 * K; ++x) {
        int s = 0;
        for (int y = 0; y < K; ++y)
            s += counts[y][x];

        for (int y = 0; y < 2 * K; ++y) {
            ysums[y][x] = s;

            s -= counts[y][x];
            s += counts[(y + K) % (2 * K)][x];
        }
    }

    // cerr << "==== ysums ====\n";
    // for (int y = 0; y < 2 * K; ++y) {
    //     for (int x = 0; x < 2 * K; ++x) {
    //         cerr << ysums[y][x] << ' ';
    //     }
    //     cerr << '\n';
    // }

    int best = 0;

    int csum = 0;
    for (int y = 0; y < 2 * K; ++y) {
        for (int x = 0; x < 2 * K; ++x) {
            if ((x / K + y / K) % 2 == 1)
                continue;
            csum += counts[y][x];
        }
    }

    //cerr << "==== csum ====\n";
    for (int y = 0; y < 2 * K; ++y) {
        for (int x = 0; x < 2 * K; ++x) {
            // cerr << csum << '(';

            best = max(best, csum);

            csum -= ysums[y][x];
            csum += ysums[(y + K) % (2 * K)][x];
            csum += ysums[y][(x + K) % (2 * K)];
            csum -= ysums[(y + K) % (2 * K)][(x + K) % (2 * K)];

            // cerr << ysums[y][x] << '-'
            //      << ysums[(y + K) % (2 * K)][x] << '-'
            //      << ysums[y][(x + K) % (2 * K)] << '-'
            //      << ysums[(y + K) % (2 * K)][(x + K) % (2 * K)] << ") ";

        }

        // cerr << "(" << csum << ")\n";

        csum -= xsums[y][0];
        csum += xsums[(y + K) % (2 * K)][0];
        csum += xsums[y][K];
        csum -= xsums[(y + K) % (2 * K)][K];
    }

    cout << best << '\n';

    return 0;
}


Measured memory_bytes: 47360
N=int(input())
t=list(map(int, input().split()))
v=list(map(int, input().split()))
T=sum(t)
V=[0]*(T+2)
from collections import deque
q=[deque() for i in range(101)]
s=0
for i in range(N):
    temp=min(V[s],v[i])
    q[temp].append(s)
    for j in range(t[i]):
        V[s+j+1]=v[i]
    s+=t[i]
q[0].append(T)
vans=[-1]*(T+1)
for i in range(101):
    while(len(q[i])>0):
        s=q[i].popleft()
        if vans[s]==-1:
            vans[s]=i
        if s>0 and vans[s-1]==-1:
            if V[s]>i:
                q[i+1].append(s-1)
            else:
                q[i].append(s-1)
        if s<T and vans[s+1]==-1:
            if V[s+1]>i:
                q[i+1].append(s+1)
            else:
                q[i].append(s+1)
ans=0
for i in range(T):
    if vans[i+1]>vans[i]:
        ans+=vans[i]+0.5
    elif vans[i+1]<vans[i]:
        ans+=vans[i+1]+0.5
    elif V[i+1]>vans[i]:
        ans+=vans[i]+0.25
    else:
        ans+=vans[i]
print(ans)

Measured memory_bytes: 3700
#include <bits/stdc++.h> 
using namespace std; 
const int MAX_CHAR = 26; 
  
// function to check if we can spilt 
// string or not 
bool checkCorrectOrNot(string s) 
{ 
    // Counter array inisialized with 0 
    int count1[MAX_CHAR] = {0}; 
    int count2[MAX_CHAR] = {0}; 
  
    // Length of the string 
    int n = s.length(); 
    if (n%2!=0) 
        return false; 
  else
  {
    // traverse till the middle element 
    // is reached 
    for (int i=0,j=n-1; i<j; i++,j--) 
    { 
        // First half 
        count1[s[i]-'a']++; 
  
        // Second half 
        count2[s[j]-'a']++; 
    } 
  
    // Checking if values are different 
    // set flag to 1 
    for (int i = 0; i<MAX_CHAR; i++) 
        if (count1[i] != count2[i]) 
            return false; 
  
    return true;
  }
} 
  
// Driver program to test above function 
int main() 
{ 
    int l;
    cin>>l;
    string s;
    cin>>s;
  
    if (checkCorrectOrNot(s)) 
        cout << "Yes\n"; 
    else
        cout << "No\n"; 
    return 0; 
} 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  int n;

  cin >> n;

  cout << n * n << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	char s[5];
	int flg=0,i;
	scanf("%s",s);
	for(i=0;i<4;i++){
		if(s[i]==s[i+1]){
			flg=1;
			break;
		}
	}
	if(flg==1) printf("Bad\n");
	else printf("Good\n");
	return 0;
}


Measured memory_bytes: 1628
def dfs(x,cnt):
    global ans
    if cnt != n:
        for i in range(x[-1],m+1):
            dfs(x+[i],cnt+1)
    else:
        cnt = 0
        for a,b,c,d in lis:
            if x[a-1] + c == x[b-1]:
                cnt += d
        ans = max(ans,cnt)
n,m,q = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(q)]
ans = 0
dfs([1],0)
print(ans)

Measured memory_bytes: 72204
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 3000000
ll MOD=1000003;
ll int inv[N],comb[N],prd[N],invprd[N];
void calc_inv(){
    inv[1]=1;
    rep2(i,2,N-1){
        inv[i]=((-(MOD/i)*inv[MOD%i])%MOD+MOD)%MOD;
    }
    return;
}
void calc_comb(ll int n){
    comb[0]=1;
    rep2(i,1,n){
        comb[i]=comb[i-1]*(n+1-i)*inv[i]%MOD;
    }
    return;
}
void calc_product(){
    prd[0]=prd[1]=1;
    invprd[0]=invprd[1]=1;
    rep2(i,2,N-1){
        prd[i]=i*prd[i-1]%MOD;
        invprd[i]=inv[i]*invprd[i-1]%MOD;
    }
    return ;
}
ll cmb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return prd[a]*invprd[b]%MOD*invprd[a-b]%MOD;
}
ll modpow(ll x,ll n){
    if(n==0) return 1;
    ll res=modpow(x*x%MOD,n/2);
    if(n&1) res=res*x%MOD;
    return res;
}
main(){
    calc_inv();
    calc_product();
    int qqq=in();
    rep(i,qqq){
        int x=in(),d=in(),n=in();
        if(d==0){cout<<modpow(x,n)<<endl;continue;}
        if(n>MOD){cout<<0<<endl;continue;}
        ll ans=modpow(d,n);
        ll s=x*inv[d]%MOD;
        if(s==0){cout<<0<<endl;continue;}
        ans=ans*((prd[s+n-1]*inv[prd[s-1]]%MOD)%MOD)%MOD;
        cout<<ans<<endl;
    }
}



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

#define ll long long
ll n,a[305][305];
int main()
{
    cin>>n;
    ll i,j;
    bool flag=false;
    for(i=1; i<=n; i++)
        for(j=1; j<=n; j++)
            scanf("%lld",&a[i][j]);
    ll ans=0;
for(i=1;i<=n;i++)
{
    for(j=1;j<=i;j++)
    {flag=false;
        for(int k=1;k<=n;k++)
        {
            if(a[i][j]>a[i][k]+a[k][j])
            {
                printf("-1\n");
                exit(0);
            }
            if(a[i][j]==a[i][k]+a[k][j]&&i!=k&&j!=k)
                {
                    flag=true;
                }
        }
        if(!flag)
                {ans+=a[i][j];
                }
    }
}
 cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <limits>

#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

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

    int R;
    cin >> R;
    cout << (R * 2 * M_PI) << endl;
    
    return 0;
}


Measured memory_bytes: 3244
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		long h = scanner.nextLong();
		long w = scanner.nextLong();

		long result = 0;
		result = h/2 * (w/2+ w/2 + w%2);
		if(h%2 == 1){
			result += w/2 + w%2;
		}

		if(h == 1 || w == 1) result = 1;
		System.out.println(result);
	}

}


Measured memory_bytes: 20684
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int[] t = new int[N];
		for(int i=0; i<N; i++){
			t[i] = sc.nextInt();
		}
		
		long sum = 0;
		for(int i=1; i<N; i++){
			if(t[i]-t[i-1]<T){
				sum += t[i] - t[i-1];
			}else{
				sum += T;
			}
		}
		sum += T;
		
		System.out.print(sum);
		
	}

}


Measured memory_bytes: 63928
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)


using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

void solve() {
    Bint n, k;
    cin >> n >> k;

    Bint old = n;

    do {
        old = n;
        n %= k;
    } while (old > n);

    Bint t = (n - k >= 0 ? n - k : k - n);

    n = n - t <= 0 ? n : t;

    cout << n << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);

    solve();
    return 0;
}


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

using namespace std;

const int maxn = 1e6+10;

const long long mod = 1e9+7;

int Fac[maxn],inv[maxn],invFac[maxn],f[maxn],s[maxn];
inline long long C(int n,int m)
{
    return 1LL*Fac[n]*invFac[m]%mod*invFac[n-m]%mod;
}

int main()
{
    int n;
    cin>>n;
    long long ans=0LL,li=(n+1LL)/2LL;
    Fac[0]=inv[0]=inv[1]=invFac[0]=invFac[1]=1LL;
    for(int i=1;i<=n;i++)Fac[i]=1LL*Fac[i-1]*i%mod;//阶乘表
    for(int i=2;i<=n;i++)inv[i]=(mod-1LL*(mod/i)*inv[mod%i]%mod)%mod;//逆元表
    for(int i=2;i<=n;i++)invFac[i]=1LL*inv[i]*invFac[i-1]%mod;//逆元阶乘表
    for(int i=li;i<n;i++)s[i]=1LL*C(i-1,n-1-i)*Fac[i]%mod*Fac[n-1-i]%mod;//s表
    for(int i=n-1;i>=li;i--)f[i]=(s[i]-s[i-1]+mod)%mod;//f表
    for(int i=n-1;i>=li;i--)ans=(ans+1LL*i*f[i])%mod;//计算结果
    cout<<ans<<endl;
    return 0;
}

/*
逆元表
阶乘表
组合数计算表
假设需要k次完成操作的情况有s【k】种，则ans = Σ s（k） * k，(n+1)/2 <= k <= n-1
然而，如果但求s（k）的话，选择的顺序将会是一个很麻烦的事情
那么不如求f（k），用来表示最多k次完成操作的情况
于是s（k） = f（k） - f（k-1）
先排除最右边，使n-2 machine对应n-2 square， 需要k-1次操作
相当于接下来的k-1次操作每次可以涂满一个或者两个square，总需要n-1个square
先假设都涂了一个square，则还需n-2-（k-1） = n-k-1，即在k-1次操作中选择n-k-1次涂两个
C（k-1，n-1-k)
对于涂的顺序随意，于是f（k） = C（k-1，n-1-k) * （k-1）！ * （n-1-k）！
接下来就都是表了
*/


Measured memory_bytes: 17792
#include <bits/stdc++.h>
#define lol long long
using namespace std;
int main(){
    int a,b,c;
    string s,t,q;
    cin>>a>>b>>c;
    if(a==b) cout<<c<<"\n";
    else if(a==c) cout<<b<<"\n";
    else cout<<a<<"\n";
    return(0);
}

Measured memory_bytes: 3596
a, b, c, x, y = gets.chomp.split(' ').map{|i| i.to_i}
z = 0
if a + b > 2 * c 
	d = (x < y) ? x : y
	x -= d
	y -= d
	z += 2 * d
end
if a > 2 * c
	d = x
	x -= d
	z += 2 * d
end
if b > 2 * c
	d = y
	y -= d
	z += 2 * d
end
sum = a * x + b * y + c * z
#puts "#{a} #{b} #{c} #{x} #{y} #{z}"
puts sum


Measured memory_bytes: 1788
using System;
class Program
{
    static void Main(string[] args)
    {
        string a = Console.ReadLine();
        string b = Console.ReadLine();
        string c = Console.ReadLine();

        char card = a[0];
        a = a.Remove(0, 1);

        string winner = "";
        while (winner == "")
        {
            switch (card)
            {

                case 'a':
                    try
                    {
                        card = a[0];
                        a = a.Remove(0, 1);
                    }
                    catch { winner = "A"; }
                    break;
                case 'b':
                    try
                    {
                        card = b[0];
                        b = b.Remove(0, 1);
                    }
                    catch { winner = "B"; }
                    break;
                default:
                    try
                    {
                        card = c[0];
                        c = c.Remove(0, 1);
                    }
                    catch { winner = "C"; }
                    break;
            }           
        }
        Console.WriteLine(winner);
    }
}

Measured memory_bytes: 2648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  string s; cin >> s;

  if (s == "keyence") {
    YES();
    return;
  }

  for (int si = 0; si < s.size(); si++) {
    for (int li = 1; li <= s.size() - si; li++) {
      string t = s;
      t.replace(si, li, "");
      // debug3(si, li, t);
      if (t == "keyence") {
        YES();
        return;
      }
    }
  }
  NO();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main()
{
int n,res=0;
cin>>n;
vector<int> v(n-1),a(n);
for(int i=0;i<n-1;i++)
cin>>v[i];
a[n-1]=v[n-2];
a[0]=v[0];
for(int i=1;i<=n-2;i++)
a[i]=min(v[i],v[i-1]);
for(int i=0;i<n;i++)
res+=a[i];
cout<<res<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;

  string ans(2 * N, '.');
  rep(i, N) {
    ans[i * 2] = S[i];
    ans[i * 2 + 1] = T[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
H,W = map(int, input().split())

M = [[0] * W for _ in range(H)]
colors = [[''] * W for _ in range(H)]
for i in range(H):
    colors[i] = list(input())
    for j in range(W):
        if i == 0:
            if j == 0:
                M[i][j] = 0 if colors[i][j] == '.' else 1
            else:
                M[i][j] = M[i][j-1] if colors[i][j] == '.' or colors[i][j-1] == '#' else M[i][j-1] + 1
        else:
            if j == 0:
                M[i][j] = M[i-1][j] if colors[i][j] == '.' or colors[i-1][j] == '#' else M[i-1][j] + 1
            else:
                if colors[i][j] == '.':
                    M[i][j] = min([M[i-1][j], M[i][j-1]])
                else:
                    top = M[i-1][j] if colors[i-1][j] == '#' else M[i-1][j] + 1
                    left = M[i][j-1] if colors[i][j-1] == '#' else M[i][j-1] + 1
                    M[i][j] = min(top, left)

print(M[H-1][W-1])


Measured memory_bytes: 3316
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException{
		Scanner scan = new Scanner(System.in);
		String[] wab = scan.nextLine().split(" ");
		int distance = 0;
		if(Integer.parseInt(wab[1]) < Integer.parseInt(wab[2])){
			distance = Integer.parseInt(wab[2]) - (Integer.parseInt(wab[1]) + Integer.parseInt(wab[0]));
		}else if(Integer.parseInt(wab[1]) > Integer.parseInt(wab[2])){
			distance = Integer.parseInt(wab[1]) - (Integer.parseInt(wab[2]) + Integer.parseInt(wab[0]));
		}
		if(distance < 0){
			System.out.println(0);
		}else{
			System.out.println(distance);
		}
	}
}


Measured memory_bytes: 21076
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


void solve(std::vector<long long> A){
	LL s=0;
	for(auto a:A){
		s+=a;
	}
	if(s>21){
		cout << "bust" << endl;
	}
	else{
		cout << "win" << endl;
	}

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<long long> A(3);
    for(int i = 0 ; i < 3 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 105
using namespace std;
typedef long long ll;
ll dp[N][N],n,h,a1,a2,ans;
ll find(ll x){
    while(x){
        if(x/10==0)return x;
        x/=10;
    }
}
int main(){
    cin>>n;
    for(ll i=1;i<=n;i++){
        h=i,a1=h%10,a2=find(h);
        dp[a2][a1]++;
    }
    for(ll i=1;i<=9;i++)
        for(ll j=1;j<=9;j++)
            ans+=dp[i][j]*dp[j][i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3576
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
 
//FizzBuzz
public class Main{
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            int n = sc.nextInt();
            if((m|n)==0)break;
            List<Integer> p = new ArrayList<Integer>();
            for(int i=1;i<=m;i++)p.add(i);
            int k = 1;
            int pos = 0;
            while(n--!=0){
                String s = sc.next();
                if(p.size()==1)continue;
                String c = k+"";
                if(k%15==0)c="FizzBuzz";
                else if(k%5==0)c="Buzz";
                else if(k%3==0)c="Fizz";
                if(c.equals(s))pos=(pos+1)%p.size();
                else {
                    p.remove(pos);
                    pos %= p.size();
                }
                k++;
            }
            for (int i = 0; i < p.size(); i++) {
                System.out.print(p.get(i) + (i < p.size() - 1 ? " " : "\n"));
            }
        }
    }
}


Measured memory_bytes: 70996
fun main() {
    val k = readLine()!!.split(' ')[1].toInt()
    var sum = 0
    val p = readLine()!!.split(' ').map { it.toInt() }.sorted()
    for(i in p.indices) {
        if(i < k) sum += p[i]
        else break
    }
    println(sum)
}

Measured memory_bytes: 40372
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <fstream>
#define ni(n) scanf("%d", &n)
#define nl(n) scanf("%I64d", &n)
#define nai(a,n) for (int i = 0; i < (n); i++) ni((a)[i])
#define nal(a,n) for (int i = 0; i < (n); i++) nl((a)[i])
#define case(t) printf("Case #%d: ", (t))
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define f first
#define s second
typedef long long ll;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e5 + 5;
const double eps = 1e-9;
using namespace std;

int main()
{
    int n, a, b;
    ni(n), ni(a), ni(b);
    if (abs(a - b) & 1) printf("Borys\n");
    else printf("Alice\n");
    return 0;
}


Measured memory_bytes: 256
loop do
	n = STDIN.gets.to_i
	break if n.zero?

	a_score = 0
	b_score = 0
	n.times do
		a, b = STDIN.gets.split.map(&:to_i)
		case a <=> b
		when 1;
			a_score += a + b
		when 0;
			a_score += a
			b_score += a
		else;
			b_score += a + b
		end
	end

	puts "#{a_score} #{b_score}"
end

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

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

int main(){
  int N;
  long long int A[200002]={};
  long long int ans=0LL;
  long long int T;
  scanf("%d\n",&N);
  for(int i=0;i<N;i++)
    scanf("%lld",A+i);
  
  qsort(A,N,sizeof(long long int),f);
  for(int i=1;i<N;i++){
    ans+=A[i/2];
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 4664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+10;
const ll INF = 1e18;
int n,f;
ll a[N],l[N],r[N],ans;
int main(){
    scanf("%d",&n); n++;
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    ll o=1;
    for(int i=1;i<=n;++i){
        l[i]=o-a[i]; o=l[i]*2>INF?INF:l[i]*2;
        //printf("%lld %lld\n",o,l[i]);
        if(l[i]<0){
            f=1; break;
        }
    }
    if(f){
        printf("-1\n");
        return 0;
    }
    for(int i=n;i>=1;--i)
        l[i]=min(l[i],l[i+1]+a[i+1]);
    for(int i=1;i<=n;++i){
        ans+=l[i]+a[i];
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 5284
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    string s; cin >> s;
    map<char, ll> m;
    ll ans = 1;
    ll mod = 1000000007;
    rep(i,n){
        m[s[i]]++;
    }
    for(auto val : m){
        ans = ans*(val.second+1)%mod;
    }
    cout << ans - 1 << endl;


    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include <string>
#include<vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> V(N);
  for(int i=0;i<N;i++){
    cin >> V.at(i);
  }
  vector<int> C(N);
  for(int i=0;i<N;i++){
    cin >> C.at(i);
  }
  vector<int> S(N);
  for(int i=0;i<N;i++){
    S.at(i) = V.at(i) - C.at(i);
  }
  int max = 0;
  for(int i = 0;i<N;i++){
    if(S.at(i) <= 0){
      continue;
    }
    max += S.at(i);
  }
  cout << max << endl;


  return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline

n = int(input())

edges = [[] for _ in range(n)]
l = {}
for i in range(n-1):
    a,b = map(int,input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
    l[(a-1,b-1)]=i
    l[(b-1,a-1)]=i


ans = [0]*(n-1)
visited = [False]*n

q = deque([(0,0)])
visited[0] = True

mx = 0
while q:
    key,v = q.popleft()
    i = 1
    for x in edges[v]:
        if not visited[x]:
            if key != i:
                visited[x] = True
                ans[l[(v,x)]]=i
                q.append((i,x))
                mx = max(mx,i)
                i += 1
            else:
                visited[x] = True
                i += 1
                ans[l[(v,x)]]=i
                q.append((i,x))
                mx = max(mx,i)
                i += 1

print(mx)
for i in range(n-1):
    print(ans[i])



Measured memory_bytes: 95136
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef pair<int,int> P;
typedef pair<int,P>Q;
#define fi first
typedef long long ll;
#define sc second

int x[10][10],f[10][10],n,m,c;

int main(){
	while(1){
		cin>>n>>m>>c;
		if(n==0)return 0;
		rep(i,n)rep(j,m) cin>>x[i][j];
		int ans = 0; c--;
		for(int mask=0;mask<6*6*6*6;mask++)
		{
			vector<int>vec;
			int M = mask;
			rep(q,4) {vec.push_back(M%6); M/=6;} vec.push_back(c);
			rep(i,n) rep(j,m) f[i][j] = x[i][j]-1;
			for(int i=0;i<=vec.size();i++){
				bool used[10][10] ={};
				queue<P>que; que.push(P(0,0));
				int dx[4]={0,0,1,-1};
				int dy[4]={1,-1,0,0};
				while(!que.empty()){
					P p = que.front(); que.pop();
					if(used[p.fi][p.sc] ) continue;
					used[p.fi][p.sc] = 1;
					rep(k,4){
						int nx = p.fi+dx[k];
						int ny = p.sc+dy[k];
						if(0<=nx&&nx<n&&0<=ny&&ny<m&&f[nx][ny] == f[0][0]){
							que.push(P(nx,ny));
						}
					}
				}
				if(i == vec.size()){
					int C =0;
					rep(i,n) rep(j,m) if(used[i][j])C++;
					ans=max(ans,C); break;
				}
				rep(ii,n) rep(j,m){
					if(used[ii][j]) f[ii][j] = vec[i];
				}
			}
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, a, b, c, x, y);

	int mn = min(x, y);
	int ans = x * a + b * y;
	if (x == y) ans = min(ans, 2 * c * max(x, y));
	if (x > y) ans = min(ans, (x - y) * min(a, 2 * c) + mn * min(a + b, 2 * c));
	else       ans = min(ans, (y - x) * min(b, 2 * c) + mn * min(a + b, 2 * c));

	OUT(ans)BR;
	
  return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int C1,C2,C3;
	while(cin>>C1){
		cin>>C2>>C3;
		int S=C1+C2;
		int num=0;
		REP(i,10){
			if(i+1!=C1 && i+1!=C2 && i+1!=C3 && S+i+1<=20) num++;
		}

		if(num>3){
			out("YES");
		}
		else{
			out("NO");
		}
	}

	return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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 (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N, K; cin >> N >> K;
    if (K == 1) {
        cout << 0 << endl;
        return 0;
    }
    cout << (N - K) << endl;

    return 0;
}


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int main(){
	ios::sync_with_stdio(false);
	int n,a[3333];
	cin>>n;
	int ans=0,pre;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		if(i==1)ans++,pre=a[1];
		else if(a[i]>=pre)ans++,pre=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <utility>

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

int main(){
	ios_base::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	n *= 2;
	vector<int> a(n), b(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	for(int i = 0; i < n; ++i){ cin >> b[i]; }
	set<pii> eq, ne;
	ll base = 0, sum = 0;
	for(int i = 0; i < n; ++i){
		const int d = a[i] - b[i];
		base += b[i];
		if(i == 0 || i + 1 == n){
			sum += d;
		}else if(d > 0){
			eq.emplace(d, i);
			sum += d;
		}else{
			ne.emplace(d, i);
		}
	}
	while(q--){
		int p, x, y;
		cin >> p >> x >> y;
		--p;
		if(p == 0 || p + 1 == n){
			const int before_d = a[p] - b[p];
			const int after_d = x - y;
			base -= b[p];
			base += y;
			a[p] = x; b[p] = y;
			sum -= before_d;
			sum += after_d;
		}else{
			const int before_d = a[p] - b[p];
			const int after_d = x - y;
			const auto eq_it = eq.find(pii(before_d, p));
			const auto ne_it = ne.find(pii(before_d, p));
			if(eq_it != eq.end()){
				sum -= before_d;
				eq.erase(eq_it);
			}else{
				ne.erase(ne_it);
			}
			base -= b[p];
			base += y;
			a[p] = x; b[p] = y;
			if(after_d > 0){
				sum += after_d;
				eq.emplace(after_d, p);
			}else{
				ne.emplace(after_d, p);
			}
		}	
		if(eq.size() % 2 != 0){
			const auto x = *(eq.begin());
			const auto y = *(ne.rbegin());
			if(x.first >= -y.first){
				ne.erase(y);
				eq.insert(y);
				sum += y.first;
			}else{
				eq.erase(x);
				ne.insert(x);
				sum -= x.first;
			}
		}
		cout << base + sum << endl;
	}
	return 0;
}



Measured memory_bytes: 15744
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    
    cin>>n;
    int s=0;
    vector<int> a(n);
    vector<int> b(n);
    while(s<=n-1){
    cin>>a[s]>>b[s];
        s++;
        }
    s=0;
    while(s<=n-1){
        if(a[s]%b[s]==0){
        cout<<b[s]<<endl;
            s++;
        }else{
    cout<<a[s]%b[s]<<endl;
        s++;
    }
    }
    return 0;
}

Measured memory_bytes: 1196
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();

        int count = 0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int k = 0; k <= c; k++) {
                    if (500 * i + 100 * j + 50 * k == x) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}


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

using namespace std;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
   // if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  map< int, vector< tuple< int, int, int > > > mp;

  for(int i = 0; i < M; i++) {
    int d, a, b;
    cin >> d >> a >> b;
    mp[d].emplace_back(1333333, a, b);
  }
  for(int i = 0; i < Q; i++) {
    int e, s, t;
    cin >> e >> s >> t;
    mp[e].emplace_back(i, s, t);
  }
  set< int > st;
  for(int i = 1; i <= N; i++) {
    st.emplace(i);
  }
  UnionFind uf(N + 1);
  vector< int > ans(Q);
  for(auto &v : mp) {
    sort(begin(v.second), end(v.second));
    for(auto &x : v.second) {
      int a, b, c;
      tie(c, a, b) = x;
      if(c == 1333333) {
        auto l = st.lower_bound(uf.find(a));
        while(uf.find(a) != uf.find(b)) {
          uf.unite(uf.find(a), *l);
          l = st.erase(l);
        }
        st.emplace(uf.find(a));
      } else {
        ans[c] = a > b || uf.find(a) == uf.find(b);
      }
    }
  }
  for(auto& x : ans) puts(x ? "Yes" : "No");
}


Measured memory_bytes: 30308
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    rep(i, 0, M) cin >> X[i];
    if(N >= M) {
        cout << 0 << endl;
        return 0;
    }
    vsort(X);

    vector<int> a(M - 1);
    rep(i, 0, M - 1) {
        a[i] = abs(X[i + 1] - X[i]);
    }
    vsort(a);
    int rsl = 0;
    rep(i, 0, M - N) rsl += a[i];
    cout << rsl << endl;
}


Measured memory_bytes: 1024
#include<iostream>
int main() {
	int n[10];
	for (int i = 0;i < 10;++i){
		std::cin>>n[i];
	}
	for (int i = 0;i < 10;++i) {
		for (int j = 0;j < 10;++j) {
			if (i < j) {
				if (n[i]>n[j]) {
					int a = n[i];
					n[i] = n[j];
					n[j] = a;
				}
			}
		}
	}
	std::cout << n[9] << std::endl;
	std::cout << n[8] << std::endl;
	std::cout << n[7] << std::endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define PI acos(-1l)
const int M = 1000000007;
const int N=3e6+5;
const long long INF = 1e18+5;

//#define rohit
#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif

void solve() {
    int a ;
    string b;
    cin >> a >> b;
    int bdec = 0 ,f = 0;

    int pos = 0;
    for(int i=0 ; i<b.length() ; i++){
        if(b[i]=='.'){
            pos = i;
            continue;
        }
        bdec = bdec*10 + b[i] - '0';
    }
//    for(int i=pos+1; i<b.length() ; i++){
//        f = f*10 + b[i] - '0';
//    }
    int ans = (a*bdec)/100;
    cout << ans ;
}

signed main(){
    FAST;
    //TODO:  check test cases.
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++){
        solve();
    }
}

/*Extra Cares
 * 1)In graphs or dp problems sometimes long long creates MLE.
 * 2)Check whether int to long long typecasting is commented or not?
 * 3)Check overflows.
*/

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

int main() {
    string s; cin >> s;
    string t[] = {"Sunny", "Cloudy", "Rainy", "Sunny"};
    if (s == t[0]) return !(cout << t[1] << endl);
    if (s == t[1]) return !(cout << t[2] << endl);
    if (s == t[2]) return !(cout << t[3] << endl);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main()
{
    
    int N,A,B;
    int x,y;
    int ans;
    
    cin >> N >> A >> B;
    
    x = A*N;
    y = B;
    
    if(x>=y) ans = y;
    else ans = x;
    

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

    


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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define rep(i,j,n) for(int i=j; i<n; i++)
#define INF 1000000000000000000 // If you use it, make sure not to put in "int" type variable ;(, use long long int
void optimizeIO() { ios_base::sync_with_stdio(false); cin.tie(NULL); }
const ll mod=1000000007;

vector<int>adj[200010];
vector<bool>vis(200010,false);
vector<ll>tot(200010);
vector<ll>val(200010,0);

void dfs(int s, int &cnt)
{
	if(vis[s]) return;
	vis[s]=true;
	cnt+=val[s];
	tot[s]=cnt;
	for(auto u:adj[s]) dfs(u,cnt);
	cnt-=val[s];
}

int main()
{
    optimizeIO();
    int nT; nT=1;
	while(nT--)
	{
		int n,q; cin>>n>>q;
		rep(i,0,n-1)
		{
			int x,y; cin>>x>>y;
			adj[x].pb(y);
			adj[y].pb(x);
		}
		while(q--)
		{
			int p,x; cin>>p>>x;
			val[p]+=x;
		}
		int now=0; dfs(1,now);
		rep(i,1,n+1) cout<<tot[i]<<' '; cout<<'\n';
	}
	return 0;
}


Measured memory_bytes: 25856
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

int main()
{
    ll n,l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i,n){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    rep(i,n){
        cout << s[i];
    }
    cout << endl;
    return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin >> S >> T;
  int cnt = 0;
  for(int i=0; i<3; i++){
    if(S.at(i) == T.at(i)){
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

int main() {
  int n; cin >> n;
  for (int i = 1; i <= n; i++) {
    double d; string s;
    cin >> d >> s;
    if (s == "BTC") v += d * 380000; else v += d;
  }
  cout << fixed << setprecision(20) << v << endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }


int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, M;
	priority_queue<double> A;
	cin >> N >> M;

	int a;
	for (size_t i = 0; i < N; i++)
	{
		cin >> a;
		A.push(a);
	}

	double price;
	for (size_t i = 0; i < M; i++)
	{
		price = A.top() / 2;
		A.pop();
		A.push(price);
	}

	ll total = 0;
	for (size_t i = 0; i < N; i++)
	{
		total += static_cast<ll>(A.top());
		A.pop();
	}

	cout << total << endl;

	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <math.h>

int main(void){
  using namespace std;
  int n,x,t;
  cin >> n >> x >> t;
  //cout << ceil((double)20/(double)12) <<endl;
  int ans = (int)(ceil((double)n/(double)x)*t);
  cout << ans << endl;
}
  

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    int a[4];
    cin>>a[0]>>a[1]>>a[2]>>a[3];
    sort(a,a+4);
    cout<<(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9?"YES":"NO")<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  cout << pow(n, 3) << endl;
  return 0;
}

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

const int64_t MOD = 1000000007;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;


// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
      v[k][j] %= MOD;
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;


signed main() {
  ll a, b, c ,d;
  cin >> a >> b >> c >> d;
  
  // a --- b
  
  // ( a + (c-(a%c))%c )/c .... b/c
  // b/c - ( a + (c-(a%c))%c )/c + 1
  
  ll cCount = b/c - ( a + c - 1 )/c + 1;
  ll dCount = b/d - ( a + d - 1 )/d + 1;
  ll cd = lcm(c,d);
  ll cdCount = b/cd - ( a + cd - 1 )/cd + 1;

  //cout << cCount << endl;
  //cout << dCount << endl;
  //cout << cdCount << endl;
  
  cout <<  b - a + 1 -  (cCount + dCount - cdCount) << endl;  
  
  
  return 0;
}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int r_cnt=0;
	rep(i,s.size()){
		if(s[i]=='R')
			r_cnt++;
	}
	int b_cnt = n-r_cnt;
	if(r_cnt>b_cnt)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256