akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define int long long
#define F first
#define S second
#define pb push_back
#define p2(n) (1<<(n))
#define lg2(n) __lg(n)
using namespace std;
using pii = pair<long long,long long>;
using ld = long double;
mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

string s;

void solve(){
    cin >> s;
    int ans = 0;
    rep(i,0,3){
        if(s[i]=='R')
            ans++;
    }
    if(s[1]=='S')
        cout << min(ans,1LL) << '\n';
    else  
        cout << ans << '\n';
}

signed main(){
    Rushia_mywife
    solve();
}

Measured memory_bytes: 3648
from collections import Counter
N=int(input())
A=[]

for i in range(1,150):
    for j in range(1,150):
        for k in range(1,150):
            ans=(i**2+j**2+k**2+i*j+j*k+k*i)
            if ans<=N:
                A.append(ans)
B=Counter(A)


for a in range(1,N+1):
   if a in B.keys():
       print(B[a])
   else:
       print(0)

Measured memory_bytes: 92476
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            long x = in.nextLong();
            long[] a = new long[N + 2];
            for (int i = 0; i < N; i++) {
                a[i] = in.nextLong();
            }
            long cnt = 0;
            for (int i = 1; i <= N; i++) {
                long temp = a[i - 1] + a[i] - x;
                if (temp > 0) {
                    if (a[i] >= temp) {
                        cnt += temp;
                        a[i] -= temp;
                    } else {
                        cnt += a[i];
                        a[i] = 0;
                        if (a[i - 1] > x) {
                            cnt += a[i - 1] - x;
                        }
                    }
                }
            }
            out.println(cnt);
        }

    }
}



Measured memory_bytes: 50524
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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 rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s;
  cin >> s;
  int N = sz(s);
  ll ans = 0;
  ll cnt = 0;
  rep(i,N) {
    if(s[i] == 'W') {
      ans += cnt;
    } else {
      cnt++;
    }
  }
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
const ll mod=1e9+7;
ll a[110][10]={0};
int b[10],m,road[10][3];
void dfs(int x)
{
	int i;
	if(x==m-1)
	{
		for(i=1;i<m-1;i++)
		{
			if(b[i]==1&&b[i-1]==1)
			{
				return;
			}
		}
		if(b[0]==0)
		{
			road[0][1]++;
		}
		else
		{
			road[0][2]++;
		}
		if(b[m-2]==0)
		{
			road[m-1][1]++;
		}
		else
		{
			road[m-1][0]++;
		}
		for(i=1;i<m-1;i++)
		{
			if(b[i]==1)
			{
				road[i][2]++;
			}
			else if(b[i-1]==1)
			{
				road[i][0]++;
			}
			else
			{
				road[i][1]++;
			}
		}
		return;
	}
	b[x]=0;
	dfs(x+1);
	b[x]=1;
	dfs(x+1);
}
int main()
{
	int i,j,k,n,x,y;
	scanf("%d%d%d",&n,&m,&k);
	a[0][0]=1ll;
	if(m==1)
	{
		printf("1");
		return 0;
	}
	dfs(0);
	for(i=1;i<=n;i++)
	{
		a[i][0]=a[i-1][0]*road[0][1]+a[i-1][1]*road[0][2];
		a[i][0]%=mod;
		a[i][m-1]=a[i-1][m-1]*road[m-1][1]+a[i-1][m-2]*road[m-1][0];
		a[i][m-1]%=mod;
		for(j=1;j<m-1;j++)
		{
			a[i][j]=a[i-1][j]*road[j][1]+a[i-1][j-1]*road[j][0]+a[i-1][j+1]*road[j][2];
			a[i][j]%=mod;
		}
	}
	printf("%lld ",a[n][k-1]);
	return 0;
}

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

int main(){
  ll n, m;
  cin >> n >> m;
  ll div = m / n;
    //nothing can be more simplar than this
  for(int i = div; i >= 0; --i){
    if(m % i == 0){
      cout << i << endl;
      return 0;
    }
  }
}

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

const int INF = INT_MAX/2;
int main(){
    int N, K; cin >> N >> K;
    vector<int> h;
    vector<int> dp(N+1, INF);
    for(int i=0; i<N; i++){
        int a; cin >> a;
        h.push_back(a);
    }

    dp[0] = 0;
    for(int i=1; i<N; i++){
        int m = INF;
        for(int j=max(i-K, 0); j<i; j++){
            m = min(m, abs(dp[j] + abs(h[i]-h[j])));
        }
        dp[i] = m;
    }
    cout << dp[N-1] << endl;
}


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

using namespace std;

int main()
{
	int k, a, b;

	scanf("%d %d %d", &k, &a, &b);

	int ka, kb;

	ka = a / k;
	kb = b / k;

	if (ka == kb && a%k)
	{
		printf("NG\n");
	}

	else
	{
		printf("OK\n");
	}

	return 0;
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PGC
{
	class Program
	{
		static int count = 0;
		static void Main(string[] args)
		{
			var N = int.Parse(Console.ReadLine());
			var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

			MergeSort(A, 0, N);
			System.Console.WriteLine(string.Join(" ", A));
			System.Console.WriteLine(count);
		}

		static void MergeSort(int[] A, int left, int right)
		{
			if (left + 1 < right)
			{
				var mid = (left + right) / 2;
				MergeSort(A, left, mid);
				MergeSort(A, mid, right);
				Merge(A, left, mid, right);
			}
		}

		static void Merge(int[] A, int left, int mid, int right)
		{
			var n1 = mid - left;
			var n2 = right - mid;
			var L = new int[n1 + 1];
			var R = new int[n2 + 1];
			for (int ii = 0; ii < n1; ii++)
			{
				L[ii] = A[left + ii];
			}
			for (int ii = 0; ii < n2; ii++)
			{
				R[ii] = A[mid + ii];
			}
			L[n1] = int.MaxValue;
			R[n2] = int.MaxValue;
			var i = 0;
			var j = 0;
			for (int k = left; k < right; k++)
			{
				count++;
				if (L[i] <= R[j])
				{
					A[k] = L[i];
					i++;
				}
				else
				{
					A[k] = R[j];
					j++;
				}
			}
		}
	}
}



Measured memory_bytes: 86752
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=2e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
ll prim[MAXN];
void init()
{
    memset(prim,0,sizeof(prim));
    prim[0]=prim[1]=1;
    for(int i=2;i<MAXN;i++)
    {
        for(int j=i+i;j<MAXN;j+=i)
        {
            prim[j]=1;
        }
    }
}
int main()
{
    init();
    int x;
    while(cin>>x)
    {
        for(int i=1;i<MAXN;i++)
        {
            if(prim[i]==0&&i>=x)
            {
                cout<<i<<endl;break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 1792
//BoxesandCandies.cpp (C)
#include <iostream>
using namespace std;

int main(){
  long long N,x,Acnt,Bcnt;
  cin >> N >> x;
  long long a[N],b[N];
  for(int i = 0; i < N; i++) cin >> a[i], b[i] = a[i];
  Acnt = 0;
  if(a[1]+a[0]>x){
    Acnt += a[1] + a[0] - x;
    if(a[0]-x >= 0) a[0] = x , a[1] = 0;
    else a[1] = x - a[0];
  }
  for(int i = 1; i < N-1; i++){
    if(a[i+1] + a[i] > x) Acnt += a[i+1] + a[i] - x, a[i+1] = x - a[i];
  }
  Bcnt = 0;
  if(b[N-1]+b[N-2]>x){
    Bcnt += b[N-1] + b[N-2] - x;
    if(b[N-1]-x >= 0) b[N-1] = x , b[N-2] = 0;
    else b[N-2] = x - b[N-1];
  }
  for(int i = N-2; i > 0; i--){
    if(b[i] + b[i-1] > x) Bcnt += b[i] + b[i-1] - x, b[i-1] = x - b[i];
  }
  printf("%lld\n",min(Acnt,Bcnt));
  return 0;
}


Measured memory_bytes: 1792
def get_num(n, x):
    ans = 0
    for n3 in xrange(min(n, x - 3), (x + 2) / 3, -1):
        for n2 in xrange(min(n3 - 1, x - n3 - 1), (x - n3) / 2, -1):
            if n3 + min(n2 - 1, x - n3 - n2):
                ans += 1
            # for n1 in xrange(min(n2 - 1, x - n3 - n2), x - n3 - n2 - 1, -1):
            #     if n3 == x - n1 - n2:
            #         ans += 1
            #         break
    return ans


data = []
while True:
    [n, x] = [int(m) for m in raw_input().split()]
    if [n, x] == [0, 0]:
        break
    if x < 3:
        print(0)
    else:
        print(get_num(n, x))

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

int main(){

  long n,ans=0;
  cin >> n;
  long d[n];
  For(i, n) cin >> d[i];
  sort(d,d+n);
  for(int i=0; i<=d[n-1]; i++){
    if(d[n/2-1]<i&&d[n/2]>=i) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())

total = 0
mod = 10**9+7
s = [0]
for i in range(0, N+1):
    s.append(s[-1] + i)

for i in range(K, N+2):
    total = (total + ((s[-1]-s[-(i+1)]) - s[i] + 1)) % mod
print(total)

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

int gcd(int a,int b,int c){
    int ans;
    for(int i=1;i<=min({a,b,c});i++){
        if(a%i==0&&b%i==0&&c%i==0){
            ans=i;
        }
    }
    return ans;
}

int main(){
    int k; cin>>k;
    int ans=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                ans+=gcd(i,j,l);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
char s[10];
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(int x){print(x);puts("");}
void query(ll  x){printf("? %lld\n",x);fflush(stdout);scanf("%s",s);}
int main(){
    int x=1e9;query(x);
    if(s[0]=='Y'){
        for(int i=9;i;i--){
            query(x-1);
            if(s[0]=='N')break;
            x/=10;
        }printf("! %d\n",x);
        return 0;
    }//特判类似10000这种情况
    for(int i=9;i;i--){
        x/=10;query(x);
        if (s[0]=='Y')break;
    }int l=x+1,r=x*10-1,ans;
    while(l<=r){
        ll mid=(l+r)>>1;query(mid*10);
        if(s[0]=='Y')r=mid-1,ans=mid;
        else l=mid+1;
    }printf("! %d\n",ans);
    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define MOD 1000000007

using namespace std;
typedef long long int ll;

int main(void){
	// #ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// #endif
	fast;
	ll a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	ll ans = 1e9;
	do{
		ll cur = 0 + abs(a[1]-a[0]) + abs(a[2]-a[1]);
		ans = min(cur, ans);
	}while(next_permutation(a, a+3));
	cout << ans << '\n';
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (n, k) = readLine()!!.trim().split(' ').map { it.toLong() }
    val dic = Array (100005) { 0L }
    for (i in 0 until n) {
        val (a, b) = readLine()!!.trim().split(' ').map { it.toLong() }
        dic[a.toInt()] += b
    }
    for (i in 1 until 100005) {
        if (dic[i] < k) {
            k -= dic[i]
        } else {
            println(i)
            break
        }
    }
}


Measured memory_bytes: 57920
#include <iostream>
#include <queue>
#include <string>
using namespace std;
#define rep(i, n) for(int (i) = 0; (i) < (n); i++)
typedef long long ll;

queue<string> Q;

int main(void){
    int n, q; //プロセス数とクオンタム
    string str[100100]; // プロセス名
    int t[100100]; //各プロセスの処理時間

    cin >> n >> q;
    //キューにプロセスを入れる（初期段階）
    ll C = 0; //すべてのプロセスが終了するのにかかる時間
    rep(i, n){
        cin >> str[i];
        Q.push(str[i]);
        cin >> t[i];
        C += t[i];
    }

    int T = 0; //処理が終わるまでにかかった時間
    while(true){
        rep(i, n){
            if(t[i] > 0){
                if(t[i] <= q){
                    T += t[i];
                    t[i] = 0;
                    Q.pop();
                    cout << str[i] << " " << T << endl;
                }
                else{
                    T += q;
                    t[i] -= q;
                    Q.pop();
                    Q.push(str[i]);
                }
            }
        }
        if(T == C) break;
    }
}



Measured memory_bytes: 6952
using namespace std;

#include <cstdio>
#include <cstdint>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

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

    const double PI = 3.141592653589;
    double R;
    cin >> R;

    double ans;
    ans = 2.0 * PI * R;

    printf("%.4lf\n", ans);
    //cout << ans << "\n";
    return 0;
    
}

Measured memory_bytes: 3804
package main

import "fmt"

func main(){
	var n,ans int
	fmt.Scan(&n)
	if n <= 599 {
		ans = 8
	} else if n <= 799 {
		ans = 7
	} else if n <= 999 {
		ans = 6
	} else if n <= 1199 {
		ans = 5
	} else if n <= 1399 {
		ans = 4
	} else if n <= 1599 {
		ans = 3
	} else if n<= 1799 {
		ans = 2
	} else {
		ans = 1
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  std::vector<int> num(3);
  for (int i = 0; i < 3; ++i) {
    std::cin >> num[i];
  }
  std::sort(num.begin(), num.end());
  std::vector<int> ans(2, 0);
  for (int i = 0; i < 2; ++i) {
    int a, b, c;
    if (num[2] % 2 == i) {
      ans[i] += 1;
      c = num[2] - 1;
    } else {
      c = num[2];
    }
    if (num[1] % 2 == i) {
      if (c > num[1]) {
        ans[i] += 2;
        b = num[1] + 1;
      } else {
        ans[i] += 1;
        b = num[1] - 1;
      }
    } else {
      b = num[1];
    }
    ans[i] += (c - b) / 2;
    if (num[0] % 2 == i) {
      if (c > num[0]) {
        ans[i] += 2;
        a = num[0] + 1;
      } else {
        ans[i] += 1;
        a = num[0] - 1;
      }
    } else {
      a = num[0];
    }
    ans[i] += (c - a) / 2;
  }
  std::cout <<  std::min(ans[0], ans[1]) << std::endl;
  return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;

int R, G, B, N;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> R >> G >> B >> N;
    ll ret = 0;
    vector<ll> vec;
    
    for(int r = 0; r <= N; r++)
    {
        for(int g = 0; g <= N; g++)
        {
            ll temp = r * R + g * G;
            if(temp > N) break;
            ll left_b = N - temp;
            if(left_b % B == 0)
                ret += 1;
        }
    }
    
    
    
    
    
    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 256
while 1:
    ans=0
    n,x=map(int,raw_input().split())
    if n:
        for i in range(1,n-1):
            for j in range(i+1,n):
                for k in range(j+1,n+1):
                    if i+j+k==x:ans+=1
    else:break
    print ans

Measured memory_bytes: 4208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}
ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
bool isPrime(int x){
    if(x==1) return false;
    else if(x==2) return true;
    else if(x%2==0) return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0){
            return false;
        }
    }
    return true;
}

int main(){
    fast_io
    
    int a,b;
    cin>>a>>b;
    int n=10000;
    for(int i=1;i<=n;i++){
        if((int)(i*0.08)==a &&(int)(i*0.1)==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <memory>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
int main(){
	int n; cin >>n;
	vector<int> a(n);
	cinf(n,a);
	map<int,int>mp;
	for(int i=0;i<n;i++){
		mp[a[i]]++;
	}
	ll x=0; ll y=0;
	for(auto p:mp){
		if(p.second>1){
			y=x;
			x=p.first;
		}
		if(p.second>3)
			y=x;
	}
	ll ans=x*y;
	cout << x*y << endl;
}

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

int h, w, k;
int ans = 0;

int main() {
  cin >> h >> w >> k;
  vector<vector<char>> c(h,vector<char>(w));
  rep (i, h) {
    rep (j, w) {
      cin >> c[i][j];
    }
  }
  rep (bit, 1<<(h+w)) {
    vector<vector<bool>> mask(h, vector<bool>(w, true));
    rep (i, h+w) {
      if (bit & (1<<i)) {
        if (i < h) {
          rep (j, w) {
            mask[i][j] = false;
          }
        } else {
          rep (j, h) {
            mask[j][i-h] = false;
          }
        }
      }
    }
    int bl = 0;
    rep (i, h) {
      rep (j, w) {
        if (mask[i][j] && c[i][j] == '#') {
          bl++;
        }
      }
    }
    if (bl == k) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
	int i,j,k,l,m,n; 
	while(scanf("%d", &n)!= EOF)
	{
		m = 0;	
		for(i=0;i<10;i++)
		{
			for(j=0;j<10;j++)
			{
				for(k=0;k<10;k++)
				{			
					for(l=0;l<10;l++)
					{
						if(i+j+k+l==n)	
						{
							m++;
						}
					}
				}
			}
		}
		printf("%d\n",m);
	}	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
//#define s second

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*********************************************START**************************************************************************/


int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int T  = 1;
	//int T;
	//cin >> T;
	// cin.ignore(); //must be there when using getline(cin, s)
	while (T--)
	{
		string s; cin >> s; 
		int n = s.length();
		ll ans = 0 ;
		for(int i=0; i<n; i++){
			ans += s[i]-'0';
		}
		if(ans % 9){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}
					
	}

	return 0;
}
 


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll n, d;
    cin >> n >> d;
    vector<ll> x(n), y(n);
    rep(i, n)
    {
        cin >> x[i] >> y[i];
    }
    ll ans = 0;
    rep(i, n)
    {
        if (x[i] * x[i] + y[i] * y[i] <= d * d)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int N;
    cin>>N;
    vector<pair<int,int> > a(N);
    rep(i,N){
        int b,c;
        cin>>b>>c;
        a[i] = make_pair(c,b);
    }
    sort(a.begin(),a.end());
 
    ll sum = 0;
    bool flag = true;
    for(int i=0;i<N;i++){
        sum += a[i].second;
            if(sum>a[i].first){
                flag = false;
      			cout<<"No";
      			return 0;
            }
    }
    if(flag==true){
        cout<<"Yes";
    }
    
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> a(M);
  vector<long> f(N,-1);
  for(int i=0; i<M; i++){
    cin >> a.at(i);
    f.at(a.at(i)-1)=0;
  }
  
  if(f.at(0)==-1){
    f.at(0)=1;
  }
  if(N>1&&f.at(1)==-1){
    f.at(1)=1+f.at(0);
  }
  
  for(int i=2; i<N; i++){
    if(f.at(i)==-1){
      f.at(i)=(f.at(i-1)+f.at(i-2))%1000000007;
    }
    else{
      f.at(i)=0;
    }
  }
  cout << f.at(N-1) << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int ans = 1;
    x -= y + 2 * z;
    ans += x / (y + z);
    cout << ans << endl;
    
}

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

using namespace std;

int main(){
  string s;
  int num = 0;

  cin >> s;

  for(int i = 0; i < 4; i++){
    if(s.at(i) == '+'){
      num++;
    }else{
      num--;
    }
  }

  cout << num << endl;

  return 0;
}


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

typedef pair<int,int> P;
int main ()
{
    const int INF = 1 << 28;
    const int MAX = 1000000;
    const int dx[] = { 1, 0,-1, 0};
    const int dy[] = { 0,-1, 0, 1};
    const int dm[] = {-1, 0, 1};
    int n, m;
    map<P, int> M;
    vector<P> d(MAX+1, P(INF,INF));

    M[P(0,0)] = 1;
    d[1] = P(0,0);
    int x = 1, y = 0;
    int c = 1;
    for (int i = 2; i <= MAX; i++) {
        c %= 4;
        int cdir = 4 + c - 1;
        cdir %= 4;
        int sy = y - dy[cdir], sx = x - dx[cdir];
        M[P(y,x)] = i;
        d[i] = P(y,x);
         if (M.find(P(sy,sx)) != M.end()) {
            x += dx[c];
            y += dy[c];
         } else {
             x = sx;
             y = sy;
             c++;
         }
    }

    vector<bool> prim(MAX+1, true);
    prim[0] = prim[1] = false;
    for (int i = 2; i <= MAX / 2; i++) {
        for (int j = 2; prim[i] && j * i <= MAX; j++) {
            prim[i * j] = false;
        }
    }

    while (cin >> n >> m , n + m) {
        int res = 0;
        int res_n = 0;
        queue<pair<int,P> > q;

        vector<int> count(MAX+1, 0);
        if (prim[m]) {
            count[m] = 1;
            q.push(pair<int,P>(1, d[m]));
            res = 1;
            res_n = m;
        } else {
            count[m] = 0;
            q.push(pair<int,P>(0, d[m]));
        }

        vector<bool> used(MAX + 1, false);

        while (q.size()) {
            pair<int,P> pp = q.front(); q.pop();
            P p = pp.second;
            int num = M[p];
            int ret = pp.first;

            if (count[num] > ret) continue;
            used[num] = true;
            y = p.first, x = p.second;
            for (int i = 0; i < 3; i++) {
                int ny = y + 1, nx = x + dm[i];
                if (M.find(P(ny, nx)) != M.end() && M[P(ny,nx)] <= n) {
                    int t_n = M[P(ny,nx)];
                    if (count[t_n] == 0 || count[t_n] < count[num] + (prim[t_n] ? 1 : 0)) {

                        if (!used[t_n] || count[t_n] < count[num] + (prim[t_n] ? 1 : 0)) {
                            count[t_n] = count[num] + (prim[t_n] ? 1 : 0);
                            q.push(pair<int,P>(count[t_n], P(ny,nx)));
                            used[t_n] = true;
                        }
                        if (res <= count[t_n] && prim[t_n]) {
                            if (res < count[t_n]) {
                                res = count[t_n];
                                res_n =  t_n;
                            } else {
                                res_n = max(t_n, res_n);
                            }
                        }
                    }
                }
            }
        }

        if (res == 0)
            cout << 0 << " " << 0 << endl;
        else
            cout << res << " " << res_n << endl;
    }

    return 0;
}

Measured memory_bytes: 75660
import java.util.Scanner;

public class Main {
	
		public static void main(String[] args) {
			
			Scanner sc =new Scanner(System.in);
			
			
			int a,b;
			a=sc.nextInt();
			b=sc.nextInt();
			
			if(a>9||b>9) {
				System.out.println(-1);
				
			}
			else {
				System.out.println(a*b);
			}
			sc.close();
			
				
		}

}


Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	ll x;
	cin >> x;
	ll ans = 0;
	ll a,b,c;
	a = x / 500;
	b = x % 500;
	c = b /5;
	ans = ans + a * 1000;
	ans = ans + (c * 5);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

N, T= map(int, input().split())
t_list = list(map(int, input().split()))

ans = T
for i in range(N-1):
    if t_list[i+1] - t_list[i] > T:
        ans += T
    else:
        ans += T - (T - (t_list[i+1] - t_list[i]))
print(ans)

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

int main(){
    string A,B;
    int a,b;
    cin >> A >> B >> a >> b;
    string X; cin >> X;
    if(X==A){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }
}


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

using namespace std;

int main(){
	long long s,h,m,t;
	
	cin>>t;
	
	s=t%60;
	t=t/60;
	m=t%60;
	h=t/60;
	
	cout<<h<<":"<<m<<":"<<s<<endl;
}


Measured memory_bytes: 3104
program ABC060C
    implicit none
    integer::n,t,i,ans
    integer,allocatable::a(:)
    read*,n,t
    ans = t
    allocate(a(n))
    read*,a
    do i = 1,n-1
        if (a(i+1)-a(i) < t) then
            ans = ans + a(i+1)-a(i)
        else
            ans = ans + t
        end if 
    end do
    print*,ans
end program ABC060C

Measured memory_bytes: 1536
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

int X,A;

int main() {

	scanf("%d%d", &X,&A);

	if (X < A) printf("0\n");
	else 

	printf("10\n");

	return 0;
}


Measured memory_bytes: 256
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed;
    cout.precision(2);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    int n;
    cin >> n;
    set<int> st;
    for(int i = 0;i < n;i++)
    {
        int a;cin >> a;
        st.insert(a);
    }
    cout << ((st.size() == n)?"YES":"NO");
    return 0;
}

Measured memory_bytes: 9600
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
    auto N = readln.split[0].to!ulong;
    auto A = readln.split.to!(ulong[]);
    N = A.length;
    auto grps = sort(A.dup).group;
    size_t[ulong] nums;
    
    //grps.array.writeln;
    
    foreach (tup; grps) {
        nums[tup[0]] = tup[1];
    }
    //nums.writeln; 
    
    ulong all_num = grps.map!(a => a[1] * (a[1]-1)).sum / 2;
    ulong all_num_true = nums.values.dup.map!(a => a*(a-1)).sum / 2;
    
    int[] re; re.length = N;
    if (
        equal( sort(grps.map!(a => a[1]).array), sort(nums.values) ) &&
        !equal( sort(grps.map!(a => a[1] * (a[1]-1)).array), sort(nums.values.map!(a => a * (a-1)).array) )
    ) {
        if (all_num_true > all_num) re[N+1] = 1;  // RE
        else if (all_num_true < all_num) writeln("aaa");   // WA
        else while (true) { N++; }    // TLE
    }
    
    foreach (k; 0 .. N) {
        writeln( all_num_true - (nums[A[k]] - 1) );
    }
}



Measured memory_bytes: 26768
/**
*    author:  boutarou
*    created: 02.08.2020 21:01:49
**/

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

int main() {
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)

amax = a.max
amid = amax / 2.0

r = a.sort{|a, b| (a - amid).abs <=> (b - amid).abs}[0]

if n == 2
  puts "#{a.max} #{a.min}"
else
  puts "#{amax} #{r}"
end

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

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

struct Bridge {
    int from;
    int to;
    Bridge(){}
    Bridge(int from, int to) : from(from), to(to){}
};

struct UnionFind {
    vector<int> par;
    vector<int> treeSize;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
        for(int i = 0; i < N; i++) treeSize.push_back(1);
    }
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    int size(int x) {
        int rx = root(x);
        return treeSize[rx];
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
        treeSize[ry] += treeSize[rx];
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    ll n, m; cin >> n >> m;
    vector<Bridge> bridges(m);
    int from,to;
    rep(i, m) {
        cin >> from >> to;
        bridges[i] = Bridge(from-1, to-1);
    }
    ll max = n*(n-1)/2;
    vector<ll> fubens(m,max);
    UnionFind u(n);
    for(int i = m-2; i >=0; i--) {
        int a = bridges[i+1].from;
        int b = bridges[i+1].to;
        if(u.same(a,b)) {
            fubens[i] = fubens[i+1];
            continue;
        }
        ll fromSize = u.size(a);
        ll toSize = u.size(b);
        u.unite(a, b);
        fubens[i] = fubens[i+1] - fromSize*toSize;
    }
    for(int i = 0; i < m; i++) {
        cout << fubens[i] << endl;
    }
}



Measured memory_bytes: 3832
import math

n = int(input())
s = input()

eS = [0] * n
wS = [0] * n

ec = 0
for i in range(n):
    eS[i] = ec
    if s[i] == "W":
        ec += 1

wc = 0
for i in reversed(range(n)):
    wS[i] = wc
    if s[i] == "E":
        wc += 1

ans = 10000000

for i in range(n):
    ans = min(ans, eS[i] + wS[i])

print(ans)


Measured memory_bytes: 23324
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,m,i;
  cin>>n>>m;
  vector<int> a(m),b(m),f(n+1),ans(n+1);
  vector<vector<int>> g(n+1,vector<int>(0));
  queue<int> q;
  for(i=0;i<m;i++){
    cin>>a.at(i)>>b.at(i);
    g.at(a.at(i)).push_back(b.at(i));
    g.at(b.at(i)).push_back(a.at(i));
  }
  f.at(1)=1;
  q.push(1);
  while(!q.empty()){
    int j=q.front();
    q.pop();
    for(int k:g.at(j)){
      if(f.at(k)==0){
        ans.at(k)=j;
        f.at(k)=1;
        q.push(k);
      }
    }
  }
  for(i=2;i<=n;i++) if(f.at(i)==0) break;
  if(i<=n) cout<<"No"<<endl;
  else{
    cout<<"Yes"<<endl;
    for(i=2;i<=n;i++) cout<<ans.at(i)<<endl;
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  int w=0, h=0;
  int ok = true;
  for(int i = n-1; i > 0; i--) {
    if(a[i]==a[i-1]) {
      if(ok) {
        w=a[i];
        ok=false;
        i--;
      }
      else {
        h= a[i];
        break;
      }
    }
  }
  cout << (ll)w*h << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N, L;
	cin >> N >> L;

	vector<string> slist(N, "");

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

	sort(slist.begin(), slist.end());

	for (string e : slist)
	{
		cout << e;
	}
	
	return 0;
}

Measured memory_bytes: 256
import sys

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])


def main():
    N = I()
    S = sorted(LI(),reverse=True)

    flag = [True]*len(S)

    cur = []
    nxt = []
    cur.append(S[0])
    nxt.append(S[0])
    
    flag[0] = False

    for i in range(N):
        j = 0
        for k in range(len(S)):
            if j >= len(cur):
                break
            elif flag[k] and S[k]<cur[j]:
                nxt.append(S[k])
                j+=1
                flag[k] = False
        if len(cur) != j:
            return("No")
        nxt.sort(reverse=True)
        cur = [x for x in nxt]
    return("Yes")

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


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

long r,c,n;
string ans="YES";
vector<long> xa(100000);
vector<long> ya(100000);
vector<long> xb(100000);
vector<long> yb(100000);
vector<long> v;
map<long,long> t;

long check(long x,long y) {
  if(x==0) return y;
  else if(y==c) return c+x;
  else if(x==r) return r+c*2-y;
  else if(y==0) return r*2+c*2-x;
  else return -1;
}

int main() {
  cin >> r >> c >> n;
  for(long i=0;i<n;i++) {
    cin >> xa[i] >> ya[i] >> xb[i] >> yb[i];
    long a=check(xa[i],ya[i]);
    long b=check(xb[i],yb[i]);
    if(a!=-1&&b!=-1) {
      if(a>b) swap(a,b);
      t[a]=i;
      t[b]=i+1000000;
    }
  }
  for(auto itr=t.begin();itr!=t.end();itr++) {
    if((*itr).second>=1000000) {
      if(v.back()+1000000!=(*itr).second) {
        ans="NO";
        break;
      }
      auto itr2=v.end();
      itr2--;
      v.erase(itr2);
    } else {
      v.push_back((*itr).second);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 19472
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
const ll mod = 1e9+7;

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}
template<typename T> inline bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template<typename T> inline bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int N;
int A[100010][3];
int dp[100010][3];

int main() {
  cin >> N;
  rep(i, 0, N) rep(j, 0, 3) cin >> A[i][j];

  rep(i, 0, 3) dp[0][i] = A[0][i];
  rep(i, 1, N) rep(lst, 0, 3) {
    rep(nxt, 0, 3) if (lst != nxt) chmax(dp[i][nxt], dp[i-1][lst] + A[i][nxt]);
  }

  int ans = 0;
  rep(i, 0, 3) chmax(ans, dp[N-1][i]);
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
  int n; cin >> n;
  int a[n];
  for(int i=0 ; i<n ; i++){
    cin >> a[i];
  }
  
  sort(a,a+n);
  int m = n/2;
  
  cout << a[m] - a[m-1] << endl;
}


Measured memory_bytes: 640
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different 
Yours Faithfully
Shobhit Yadav */

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

ll K,N,T;
/*ll freq[200005];*/
void solve(){
	 /*memset(freq,0,sizeof(freq));*/
     cin>>N>>K;
    ll a[N];
    ll sum = 0;

  for(ll i = 0 ; i<N ; i++)
  	cin>>a[i];


  sort(a , a+N);

  for(ll i = 0 ; i<K ; i++)
  	sum += a[i];


  cout<<sum<<'\n';

}



int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
  solve();
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));} /* 最大公約数*/
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >>d;
    a--;
    ll e = (b-a);
    ll l = lcm(c,d);
    ll ans = e - b/c - b/d + b/l;
    ans += a/c + a/d - a/l;
    cout << ans << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
 

int main(){
	VL A(3);
    cin>>A[0]>>A[1]>>A[2];
    sort(A.begin(),A.end());
    if(A[0]==A[1]&&A[1]==A[2])cout<<1;
    else if((A[0]!=A[1]&&A[1]==A[2])||(A[1]!=A[2]&&A[0]==A[1]))cout<<2;
    else cout<<3;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::pair;using std::set;using std::string;using std::vector;
using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;
#define ff first
#define ss second
#define pb emplace_back
template<typename T>void _dbg(const char*_s,T _h){cerr<<_s<<" = "<<_h<<"\n";}
template<typename T,typename...Ts>void _dbg(const char*_s,T _h,Ts..._t){int _b=0;while(((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',')cerr<<*_s++;cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);}
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...) 
#endif
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#endif
}}init;

const int MAXN = 2e5 + 1, B = 21;
int a[MAXN];
int last[MAXN][B];

int32_t main() {
    
    int n;
    cin >> n;

    ll ans = 0;


    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        int mx = 0;
        for (int j = 0; j < B; ++j) {
            last[i][j] = last[i - 1][j];
            if (a[i] >> j & 1) {
                mx = max(mx, last[i][j]);
                last[i][j] = i;
            } else {
                if (last[i][j])
                    mx = max(mx, last[last[i][j] - 1][j]);
            }
        }
        ans += i - mx;
    }

    cout << ans << '\n';

    

    return 0;
}


Measured memory_bytes: 17408
#include <cstdio>

int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    bool A[101],B[101];
    for(int i = 0; i < 101; i++){
        A[i] = false;
        B[i] = false;
        if(a <= i && i <= b){
            A[i] = true;
        }
        if(c <= i && i <= d){
            B[i] = true;
        }
    }

    int count = 0;
    for(int i = 0; i < 101; i++){
        if(A[i] == true && B[i] == true){
            count++;
        }
    }
    if(count > 0){
        count--;
    }
    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
#define MAX 10000
main(){
  int i,j,n,q,t[MAX],s[MAX];

  int count=0;
  
   scanf("%d",&n);
  
 for(i=0;i<n;i++)
    
   scanf("%d",&t[i]);
  
   scanf("%d",&q);
  
 for(i=0;i<q;i++)
    
   scanf("%d",&s[i]);
 
 for(i=0;i<q;i++)
    
    for(j=0;j<n;j++)
      
    if(t[j]==s[i]){
    
      count++;
   
       break;
      
  }
  
   printf("%d\n",count);
  
   return 0;

}

Measured memory_bytes: 1784
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,a,b=I()
print(min(n*a,b))


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5;

int main() {
	ios_base::sync_with_stdio(0);
	int a,b,n,T,cas=0;
	string s1, s2;
	cin>>a>>b;
	for(int i=0;i<b;++i) s1+=a+'0';
	for(int i=0;i<a;++i) s2+=b+'0';
		// cout<<s1<<" "<<s2;
	if(s1<=s2) cout<<s1;
	else cout<<s2;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

long long n;

void func(long long cur, int use, int &counter) {//カウンターはアドレスとすることで再帰しても干渉可能
    if (cur > n) return;//nを超えていたら終わり
    if (use == 0b111) counter++;//全ての要素を使っていたらカウンタに+1

    func(cur * 10 + 7, use | 0b001, counter);//2進数のandをとって7を使ったことを示す

    func(cur * 10 + 5, use | 0b010, counter);

    func(cur * 10 + 3, use | 0b100, counter);
}


int main() {
    cin >> n;

    int ans = 0;
    func(0, 0, ans);
    cout << ans << endl;
    //アドレスを参照しているのでvoid関数の結果を反映している
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const int inf = 1e9;
const lli mod = 1e9 +7;

lli ExGCD(lli a, lli b, lli &x, lli &y){
    lli d=a;
    x=1; y=0;
    if(b!=0){ d=ExGCD(b, a%b, y, x); y-=a/b*x; }
    return d;
}
lli inverse(lli a){
    lli x,y;
    ExGCD(a, mod, x, y);
    return x>0? x: mod+x;
}

lli fact[300001];
lli inv[300001];
void maketable(){
    fact[0] = 1;
    for(int i=0; i<300000; i++){
        fact[i+1] = fact[i]*(i+1) %mod;
    }
    lli y;
    for(int i=0; i<300000; i++){
        ExGCD(fact[i], mod, inv[i], y);
        while(inv[i]<0) inv[i]+=mod;
    }
}

lli nCr(lli n, lli r){
    return fact[n] *inv[n-r] %mod *inv[r] %mod;
}

lli modpow(lli a, lli p){
    lli ret = 1;
    for(int i=63; i>=0; i--){
        ret *= ret;
        ret %= mod;
        if((1LL<<i & p) != 0){
            ret *= a;
            ret %= mod;
        }
    }
    return ret;
}

int main(){
    maketable();
    int n,k;
    cin >> n >> k;
    vector<lli> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    lli nck = nCr(n, k);
    lli ans = 0;
    for(int i=0; i<n-1; i++){
        lli num = nck;
        if(i+1 >= k) num += -nCr(i+1, k) +mod;
        if(n-i-1 >= k) num += -nCr(n-i-1, k) +mod;
        num %= mod;
        ans += num *(a[i+1] -a[i]) %mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
//q016.cpp
//Sun Aug  9 13:22:38 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

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

	int a[n];
	rep(i,n) a[i]=i+1;

	int p[n],q[n];
	rep(i,n){
		cin >> p[i];
	}
	rep(i,n){
		cin >> q[i];
	}

	int count = 0;
	int pp=0;
	int qq=0;
	do {
		if (pp==0){
			int flag = 1;
			rep(i,n){
				if (a[i]!=p[i]){
					flag = 0;
					break;
				}
			}
			if(flag){
				pp=count;
			}
		}
		if (qq==0){
			int flag = 1;
			rep(i,n){
				if (a[i]!=q[i]){
					flag = 0;
					break;
				}
			}
			if(flag){
				qq=count;
			}
		}
		count++;
	} while (next_permutation(a,a+n)); //必ずaを事前にソート


	cout << abs(pp-qq) << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3604
s = input()

if s == "SUN":
    print("7")
elif s == "MON":
    print("6")
elif s == "TUE":
    print("5")
elif s == "WED":
    print("4")
elif s == "THU":
    print("3")
elif s == "FRI":
    print("2")
elif s == "SAT":
    print("1")
            
    



        


        


    







        



Measured memory_bytes: 2940