akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

const bool CanMove(const string &str, const int S, const int G)
{
    bool isStone = false;
    for (int i = S; i <= G; ++i)
    {
        // 今いるマスが岩のとき
        if (str[i - 1] == '#')
        {
            // １マス前が岩であり，このマスも岩ならば移動不可能
            if (isStone)
            {
                return false;
            }
            isStone = true;
        }
        else
        {
            isStone = false;
        }
    }

    return true;
}

const bool IsThereThreeSpace(const string &str, const int S, const int G)
{
    for (int i = max(S, 1); i <= G - 2; ++i)
    {
        if (str[i - 1] == '.' && str[i] == '.' && str[i + 1] == '.')
            return true;
    }
    return false;
}

int main()
{
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;

    // Bのゴールの方が手前のとき
    if (D < C)
    {
        // 先にBがゴールできなければダメ
        if (!CanMove(S, B, D))
        {
            cout << "No" << endl;
            return 0;
        }
        // BーD間に３マスあれば，そこにBを置いてAが追い越して移動可能
        if (IsThereThreeSpace(S, B, D))
        {
            // Bを途中に置いてAがDーC間を移動できるかチェック
            if (CanMove(S, D, C))
            {
                cout << "Yes" << endl;
                return 0;
            }
            else
            {
                cout << "No" << endl;
                return 0;
            }
        }
        // B-D間に３マスなければ，BをDに置き，Aがゴールできるかチェック
        else
        {
            S[D - 1] = '#';
            if (CanMove(S, A, C))
            {
                cout << "Yes" << endl;
                return 0;
            }
            else
            {
                // 先にAを動かしてゴールできるかチェック
                S[D - 1] = '.';
                S[B - 1] = '#'; // Bは岩扱い。B-D間に３マスないので動かしても無駄
                if (CanMove(S, A, C))
                {
                    cout << "Yes" << endl;
                    return 0;
                }
                else
                {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    // Aのゴールの方が手前のとき
    else
    {
        // 先にBがゴールできなければダメ
        if (!CanMove(S, B, D))
        {
            cout << "No" << endl;
            return 0;
        }
        // Bがゴールできてしまえば，後はAを動かすだけ
        // Bは奥側のゴールにいるので干渉しない
        if (CanMove(S, A, C))
        {
            cout << "Yes" << endl;
            return 0;
        }
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
typedef long long LL;

int counter[30];

int main() {
   int N;
   string S;
   cin >> N >> S;
   LL ans = 1;
   for (int r = 0; r < N; r++)
      counter[S[r] - 'a']++;
   for (int i = 0; i < 26; i++)
      ans = (ans * (counter[i] + 1)) % MOD;
   ans--;
   if (ans < 0)
      ans += MOD;
   printf("%d\n", ans);
   return 0;
}//main


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	int N,K,L;
	int MAX_N=200001;
	ArrayList<Integer> []rail=new ArrayList[MAX_N];
	ArrayList<Integer> []road=new ArrayList[MAX_N];
	boolean[] visited=new boolean[MAX_N];
	long id=1;
	long []ar=new long[MAX_N];
	long []br=new long[MAX_N];
	
	HashMap<Long,Long> dp=new HashMap<Long,Long>();
	
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		N=sc.nextInt();
		K=sc.nextInt();
		L=sc.nextInt();
		for(int i=0;i<MAX_N;i++)rail[i]=new ArrayList<Integer>();
		for(int i=0;i<MAX_N;i++)road[i]=new ArrayList<Integer>();
		
		for(int i=0;i<K;i++){
			int a=sc.nextInt();
			int b=sc.nextInt();
			road[a].add(b);
			road[b].add(a);
			
		}
		for(int i=1;i<=N;i++){
			if(!visited[i]){
				dfs(i);
			}
			++id;
		}
		
		for(int i=0;i<L;i++){
			int a=sc.nextInt();
			int b=sc.nextInt();
			rail[a].add(b);
			rail[b].add(a);
		}
		
		Arrays.fill(visited,false);
		id=1;
		
		for(int i=1;i<=N;i++){
			if(!visited[i]){
				dfs2(i);
			}
			++id;
		}
		
		for(int i=1;i<=N;i++){
			if(dp.containsKey(ar[i]*MAX_N+br[i])){
				dp.put(ar[i]*MAX_N+br[i], dp.get(ar[i]*MAX_N+br[i])+1);
			}else{
				dp.put(ar[i]*MAX_N+br[i],(long) 1);
			}
		}
		
		for(int i=1;i<=N;i++){
			System.out.println(dp.get(ar[i]*MAX_N+br[i]));
		}
		
	}
	void dfs(int v){
		visited[v]=true;
		ar[v]=id;
		for(int to :road[v]){
			if(!visited[to]){
				dfs(to);
			}
		}
	}
	void dfs2(int v){
		visited[v]=true;
		br[v]=id;
		
		for(int to :rail[v]){
			if(!visited[to]){
				dfs2(to);
			}
		}
	}
}

Measured memory_bytes: 197008
#include <bits/stdc++.h>
using Int = int64_t;

int main() {
   for(;;) {
      Int n, m;
      std::cin >> n >> m;
      if( n == 0 && m == 0 ) break;
      std::vector<Int> xs(n);
      for(Int i = 0; i < n; ++i) {
         std::cin >> xs[i];
      }
      Int res = 0;
      for(Int i = 0; i < n; ++i) {
         for(Int k = i + 1; k < n; ++k) {
            Int t = xs[i] + xs[k];
            if( t <= m && res < t ) {
               res = t;
            }
         }
      }
      if( res == 0 ) {
         std::cout << "NONE" << std::endl;
      }
      else {
         std::cout << res << std::endl;
      }
   }
}



Measured memory_bytes: 3084
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

const double pi = 3.141592653589793;
// -------------------------------------------------------
int N;
int A[201010];

int main() {
  cin >> N;
  int sum = 0;
  repe(i, 1, N) {
    cin >> A[i];
    sum += abs(A[i] - A[i - 1]);
  }
  sum += abs(0 - A[N]);

  repe(i, 1, N) {
    int ans = sum;
    ans -= abs(A[i] - A[i - 1]);
    ans -= abs(A[i + 1] - A[i]);
    ans += abs(A[i + 1] - A[i - 1]);
    cout << ans << endl;
  }
}

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

using namespace std;

int main()
{
    int i,sum=0,num=0,test,t,total;
    scanf("%d %d",&test,&total);
    vector <int> v;

   for(t=1;t<=test;t++)
   {
       scanf("%d",&num);
       v.push_back(num);
       sum = sum + num;


   }

   int remain = total-sum;

   if(remain<0)
   {
       printf("0\n");

   }

   else
   {
       int n;

       for(i=0;i<test;i++)
       {
           n = remain/v[i];
           v[i]=n;
            //printf("ad %d ",n);
       }

       sort(v.begin(),v.end());
       int c= v[test-1] + test;

       printf("%d\n",c);
   //    printf("r %d\n",remain);
 //      printf("%d\n",v[test-1]);

   }

   return 0;
}



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

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

  int n, a;
  cin >> n >> a;

  if (n % 500 <= a) cout << "Yes\n";
  else cout << "No\n";

  return (0);
}


Measured memory_bytes: 3612
s = list(map(str, input()))
t = len(s)

i = 0
l = []
for _ in range(t - 3):
    for _ in s:
        if i <= t - 3:
            x = (s[i]+s[i + 1]+s[i + 2])
            l.append(x)
        i += 1
tmp = []
for num in l:
    y = abs(int(num) - 753)
    tmp.append(y)
print(min(tmp))


Measured memory_bytes: 9112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Schema;

class IDONTKNOWCSHARP
{

    public static void Main()
    {
        int num = int.Parse(Console.ReadLine());

        (int, int)[] item = new (int, int)[num];

        int count = 0;

        for (int i = 0; i < num; i++)
        {
            var value = GetLines();
            item[i].Item1 = int.Parse(value[0]);
            item[i].Item2 = int.Parse(value[1]);


        }

        for (int i = 0; i < num; i++)
        {
            if (item[i].Item1 == item[i].Item2)
            {
                count++;

                if (count == 3)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            else
            {
                count = 0;
            }

        }

        Console.WriteLine("No");
    }

    static string[] GetLines()
    {
        return Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
    }


}

Measured memory_bytes: 27548
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<20;


int main(){
    int a,b,c,d;cin >> a >> b >> c >> d;
    cout << a*b-(c*b+d*a)+c*d << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
#define PI 3.14159265359;

class Hoge{
  public:
					long int i0;
	int i1,N0;
	int iX;
					string s0;
					int *iarray0,*iarray1;
					Hoge(int);
					void func0();
					void array0();
	void printarray0();
	void lostnumber();
	~Hoge();
  private:
	
	void inputarray(int*,int);
	void inputarray2(int*,int*,int);
	void printarray(int*,int);
					};


Hoge::Hoge(int itemp){
	
	i0=itemp;
	//cout<<"i0="<<i0<<endl;
	
									}

void Hoge::func0(){
	//cout<<"X"<<endl;
	//cin>>iX;
	//cout<<"N0?"<<endl;
	//cin>>N0;
	cin>>iX>>N0;
	iarray0=new int[N0];
	iarray1=new int[102];
	//int N1=3;int N2=2;
	//int* iarray1=new int[101];
	//int* iarray2=new int[(100-N0)];

	inputarray(iarray0,N0);
	//printarray(iarray0,N0);
	lostnumber();
	//inputarray2(iarray1,iarray2,N1);
	
	
	
	//delete [] iarray1;
	//delete [] iarray2;
	
								}


void Hoge::array0(){

	cout<<"N0?";
	cin>>N0;
	
	
	for (int i0=0;i0<N0;i0++){
		cout<<"i0="<<i0<<endl;
		cin>>iarray0[i0];
		
		
	}
}

void Hoge::lostnumber(){

	int imin=100;
	int itemp=0;
	int iminanswer=100;

	for (int i0=0;i0<102;i0++){
		iarray1[i0]=i0;
	}
	//iarray1[0]=10000;
	for (int i0=0;i0<N0;i0++){
	iarray1[iarray0[i0]]=10000;
	//	cout<<"iarray0[i0]"<<iarray0[i0]<<endl;
	}

	//printarray(iarray1,101);
	
	for (int i0=0;i0<102;i0++){
		itemp=abs(iarray1[i0]-iX);
		if(itemp<imin){
			imin=itemp;
			iminanswer=iarray1[i0];
		//	cout<<"iminanswer="<<iminanswer<<endl;
		}
	}
	cout<<iminanswer<<endl;
									}

void Hoge::inputarray(int* itemp,int itempn){
	
	int* iarray=itemp;
	int n0=itempn;
	for (int i0=0;i0<n0;i0++){
		//cout<<"i0="<<i0<<endl;
		cin>>iarray[i0];
	}
}
void Hoge::inputarray2(int* itemp,int* itemp2,int itempn){
	
	int* iarray=itemp;
	int* iarray2=itemp2;
	int n0=itempn;
	
	for (int i0=0;i0<n0;i0++){
		cout<<"i0="<<i0<<endl;
		cin>>iarray[i0];
		cin>>iarray2[i0];
	}
}

void Hoge::printarray(int* itemp,int itempn){
	
	int* iarray=itemp;
	int n0=itempn;
	for (int i0=0;i0<n0;i0++){
		cout<<"iarray["<<i0<<"]="<<iarray[i0]<<endl;
		
	}
	cout<<"----------------"<<endl;
}
	
	void Hoge::printarray0(){
							 
							 for (int i0=0;i0<N0;i0++){
			cout<<"iarray0["<<i0<<"]="<<iarray0[i0]<<endl;
			
							 
							 }
	
	
}
Hoge::~Hoge(){
	
	delete [] iarray0;
	delete [] iarray1;
							}
int main(){
				int N;
				//cin>>N;
	Hoge* hoge=new Hoge(N);
	hoge->func0();
	//hoge->array0();
	//hoge->printarray0();
	return 0;
	delete hoge;
}//end of main

Measured memory_bytes: 3512
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	static int intN =0;
	static int sosuCnt =0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = sc.nextLine();
		//String[] h1 = sc.nextLine().split(" ");
		String[] arrayS = s.split("");
		String[] arrayT = t.split("");


		HashMap taiouMap = new HashMap();
		//int cnt =0;
		String alph = "abcdefghijklmnopqrstuvwxyz";
		String result = "Yes";
		for (int i = 0; i < t.length(); i++) {
			String tempT = arrayT[i];

			if (!taiouMap.containsKey(tempT)) {
				taiouMap.put(tempT,arrayS[i]);

				if (alph.contains(arrayS[i])) {
					alph=alph.replace(arrayS[i], "");
				} else {
					result = "No";
					break;
				}

			} else {
				if (!(taiouMap.get(tempT)).equals(arrayS[i])) {
					result = "No";
					break;
				}
			}
		}

		System.out.println(result);
	}

}

Measured memory_bytes: 66112
w, h , n = map(int , input().split())

left = 0
right = w
lower = 0
upper = h

for i in range(n):
  x, y, a = map(int, input().split())
  
  if a == 1:
    left = max(left, x)
  elif a == 2:
    right = min(x, right)
  elif a == 3:
    lower = max(lower, y)
  elif a == 4:
    upper = min(y, upper)

if left > right or lower > upper:
    print(0)
else:
    print((right-left)*(upper-lower))

Measured memory_bytes: 9212
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n=II()
	D=LI()+[0]

	D.sort()
	#print(D)

	DD=[]

	for i,v in enumerate(D):
		if i%2==0:
			DD.append(v)
		else:
			DD.append(24-v)
	DD.sort()
	DD.append(24)

	#print(DD)

	ans=25

	for i,j in zip(DD[:-1],DD[1:]):
		ans=min(ans,j-i)
	print(ans)











if __name__ == "__main__":
	main()


Measured memory_bytes: 61992
#include <stdio.h>

#define LOGOUT  (0U)
#define LOGIN   (1U)

#define PRE    (0U) /* 計測開始前 */
#define RUN    (1U) /* 計測中     */
#define END    (2U) /* 計測終了後 */

#define MAX     (1000U)

int log[MAX][4];
int r;

int calc(int ts,int te,int m);

int main(){
    int N,M,q,ts,te,m;
    int i;
    while(scanf("%d %d",&N,&M)&&(N>0)){
        /* ログ格納 */
        scanf("%d",&r);
        for(i=0;i<r;i++){
            scanf("%d %d %d %d",&log[i][0],&log[i][1],&log[i][2],&log[i][3]);
        }
        /* 質問毎に回答を出力 */
        scanf("%d",&q);
        for(i=0;i<q;i++){
            scanf("%d %d %d",&ts,&te,&m);
            printf("%d\n",calc(ts,te,m));
        }
    }
    return 0;
}

int calc(int ts,int te,int m){
    int use_cnt         = 0;        /* 利用PC数 */
    int sum             = 0;        /* 利用時間合計*/
    int pre_t           = 0;        /* 前回ログ時間 */
    int measure_state   = PRE;      /* 計測状態 */
    int i,log_t,log_m,log_s;

    /* ログを順番に確認 */
    for(i=0;i<r;i++){
        log_t = log[i][0];
        log_m = log[i][2];
        log_s = log[i][3];

        /* 計測開始チェック */
        if( (measure_state == PRE) && (log_t >= ts) ){
            measure_state = RUN;
            pre_t = ts;
        }

        /* 計測終了チェック */
        if( (measure_state == RUN) && (log_t >= te) ){
            measure_state = END;
            if(use_cnt>0){
                sum += te - pre_t;
            }
        }

        if(log_m == m){
            if(log_s==LOGIN){
                /* ログイン */
                if(use_cnt==0){
                    pre_t = log_t;
                }
                use_cnt++;
            }else{
                /* ログアウト */
                use_cnt--;
                if( (measure_state == RUN) && (use_cnt==0) ){
                    sum += log_t - pre_t;
                }
            }
        }
    }
    return sum;
}


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

using namespace std;

int main(){
    long double X,now=100;
    cin >> X;
    for(int i=1;;i++){
        now *= 101;
        now /= 100;
        now = floor(now);
        if(X<=now){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3724
#import<atcoder/all>
int N,Q,i,a;main(){std::cin>>N>>Q;atcoder::fenwick_tree<long>b(N);for(;i++<N;b.add(i-1,a))std::cin>>a;for(;std::cin>>i>>a>>N;Q--){if(i)std::cout<<b.sum(a,N)<<'\n';else b.add(a,N);}}

Measured memory_bytes: 8216
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s, t;
  cin >> s >> t;
  int x = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == t[i]) {
      x++;
    }
  }
  cout << x;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <vector>
using namespace std;

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (a <= x&a + b >= x) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <iostream>
#include <fstream>

using namespace std;

const int DIV = 1000000007;

void execute(int test, istream &in) {
    string s;
    in >> s;
    for (int i = 0; i < s.size(); i++)
        if (s[i] == '?')
            s[i] = 'D';
    printf("%s", s.c_str());
}

int main(int argc, char* argv[])
{
#ifdef VLAD_LOCAL
    //FILE *f = fopen("in.txt", "r");
    ifstream f("in.txt");
#else
    //FILE *f = stdin;
    istream &f = cin;
#endif
    int tests = 1;
    //f >> tests;
    for (int test = 0; test < tests; test++) {
        execute(test, f);
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pi;

#define fi first
#define se second

int read() {
  int res = 0, w = 1; char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') c = getchar(), w = -1;
  while (isdigit(c)) res = (res << 1) + (res << 3) + c - '0', c = getchar();
  return res * w;
}

const int N = 2e5 + 10;

char s[N];
int f[N][2];

int main() {
  cin >> s;
  int n = strlen(s) - 1;
  f[0][0] = 1;
  f[0][1] = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i] != s[i-1]) f[i][0] = max(f[i-1][0], f[i-1][1])+1;
    else f[i][0] = f[i-1][1] + 1;
    if (i > 2 && s[i] == s[i-2] && s[i-1] == s[i-3]) f[i][1] = f[i-2][0] + 1;
    else f[i][1] = max(f[i-2][0], f[i-2][1]) + 1;
  }
  cout << max(f[n][1], f[n][0]) << endl;
  return 0;
}


Measured memory_bytes: 2048
import java.util.*;

public class Main {
   public static void main(String[] args) {
       
           Scanner sc = new Scanner(System.in);       
           String str = sc.next();

           int lastindex[] = new int[26];           
           Arrays.fill(lastindex,-100);           
           
           for(int i = 0;i < str.length();i++){
               char c = str.charAt(i);
               int  charIndex = c - 'a';
               int last = lastindex[charIndex];
               if(i - last <= 2){
                   System.out.printf("%d %d\n",last + 1,i+1);
                   return;
               }               
               lastindex[charIndex] = i;
           }
           System.out.println("-1 -1");                                            
           
   }    
}

Measured memory_bytes: 25328
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) for(int i=0;i<n;i++)
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
int f(pii a){return (a.first*a.first + a.second*a.second)*200 + a.first;}

int main(void){
    int n,m;
    while(cin>>n>>m,n|m){
        map<int,int> mp;
        rep(i,n){
            int a,b;
            cin>>a>>b;
            if(mp.find(b)==mp.end()){
                mp[b]=0;
            }
            mp[b]+=a;
        }
        int ans=0;
        auto itr=mp.rbegin();
        for(;itr!=mp.rend();itr++){
            int cost=(*itr).first;
            int count=(*itr).second;
            if(m>=count){
                m-=count;
            }else{
                ans+=(count-m)*cost;
                m=0;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3092
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    VEC(int) subs(N + 1, 0);
    FOR(i, 0, N - 1) {
        int a;
        cin >> a;
        subs[a]++;
    }

    FOR(i, 0, N)
        cout << subs[i + 1] << endl;
    return 0;
};


Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
    int N, a, b, ans;
    string s;
    a = 0;
    b = 0;
    cin >> N >> s;
    
    for(int i = 0; i < N; i++) if(s[i] == 'R') a++;
    ans = a;
    for(int i = 0; i < N; i++){
        int now;
        if(s[i] == 'R') a--;
        else b++;
        now = max(a, b);
        ans = min(ans, now);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3756
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int m = sc.nextInt();
		int d = sc.nextInt();
		int a = d / 10;
		int b = d % 10;
		int ans = 0;
		
		for(int i = 2; i <= a; i++) {
			if(i == a) {
				for(int j = 2; j <= b; j++) {
					if (i * j <= m) {
						ans++;
					}
				}
			}
			else {
				for(int j = 2; j < 10; j++) {
					if (i * j <= m) {
						ans++;
					}
				}
			}
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
import java.util.*;
public class Main {
    
  public static void main(String[] args){
      
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int x[] = new int[N];
    int y[] = new int[N];
    for(int i = 0; i < N; ++i){
        
      x[i] = sc.nextInt();
      y[i] = sc.nextInt();
      
    }
    double sum = 0;
    for(int i = 0 ; i < N; ++i){
        
      for(int j = i+1 ; j < N; ++j){
          
        int xx= x[i]-x[j];
        int yy= y[i]-y[j];
        int r= (int)Math.pow(xx, 2)+ (int)Math.pow(yy, 2);
        sum += Math.sqrt(r);
        
      }
      
    }
    System.out.println(sum * 2/N);
  }
}


Measured memory_bytes: 35984
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;

int main(){
	ll x;
	cin >> x;
	
	
	ll ans=0;
	for(ll i=1;i<=x;i++){
		ll y=x/i;
		ans += i*y*(y+1)/2;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  cout<<a[0]+a[1];
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define MAX_SIZE (1000)

using namespace std;

int main()
{
    int  a, b;
    int  size;
    char op;
    int* ans = new int[MAX_SIZE + 1];
    

    for (int i = 0; i < MAX_SIZE + 1; i++) {
        do {
            cin >> a >> op >> b;
        } while (((a < 0 || a > 20000) || (b < 0 || b > 20000)) || (op == '/' && b == 0));

        if (op == '+') {
            ans[i] = a + b;
        } else if (op == '-') {
            ans[i] = a - b;
        } else if (op == '*') {
            ans[i] = a * b;
        } else if (op == '/') {
            ans[i] = a / b;
        } else if (op == '?') {
            size = i;
            break;
        }       
    }
 
    for (int i = 0; i < size; i++) {
         cout << ans[i] << endl;
    }
     
    delete[] ans;

    return (0);
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define rep(i,s,n)	for(int i=s;i<n;i++)
#define ii pair<int, int >
#define ll long long int
#define vi vector<int >
#define vl vector<long long int >
#define vvi vector<vector<int > >
#define vvl vector<vector< long long int > >
#define mii map<int , int >
#define umii unordered_map<int, int>
#define mp make_pair
#define pb push_back
using namespace std;

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

    //write your code here
		int x;
		cin>>x;
		int ans = 2*(x/500)*500;
		x-=(x/500)*500;
		ans+=(x/5)*5;
		cout<<ans<<endl;
    return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables ***************/
int h, w;
vector<string> s;
/**********************************************/

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

    cin >> h >> w;
    s.resize(h);
    REP(i, h) cin >> s[i];

    REP(i, h)REP(j, w) if(s[i][j] == '#'){
        bool flag = false;
        if(i-1 >= 0) flag |= s[i-1][j] == '#';
        if(i+1 < h) flag |= s[i+1][j] == '#';
        if(j-1 >= 0) flag |= s[i][j-1] == '#';
        if(j+1 < w) flag |= s[i][j+1] == '#';

        if(!flag){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
// Date: 2020-03-14

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

LL dp[N][2];
VI g[N];
int n;

void dfs(int u, int fa) {
    dp[u][0] = dp[u][1] = 1;
    for(auto v : g[u]) if(v != fa) {
        dfs(v, u);
        dp[u][0] *= dp[v][1]; dp[u][0] %= mod;
        dp[u][1] *= (dp[v][0] + dp[v][1]); dp[u][1] %= mod;
    }
}

int main() {
    FIO;
    cin >> n;
    rep(i, 1, n-1) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v), g[v].pb(u);
    }
    dfs(1, -1);
    LL ans = (dp[1][0] + dp[1][1]) % mod;
    cout << ans;

    return 0;
}

Measured memory_bytes: 14208
#include <iostream>

using namespace std;

int main (){

    int s;
    cin >> s;

    bool found = false;

    while (s)
    {
        int d = s % 10;
        s /= 10;

        if (d == 9){
            found = true;
        }
    }


    

    if (found) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    totalL = abs(A[0])
    for i in range(1, N):
        totalL += abs(A[i] - A[i-1])
    totalL += abs(A[N-1])
    pre = 0
    A.append(0)
    Ans = [totalL] * N
    for i in range(N):
        if pre <= A[i] <= A[i+1]: pre = A[i]
        elif A[i+1] <= A[i] <= pre: pre = A[i]
        else:
            Ans[i] += abs(A[i+1] - pre) - abs(A[i] - pre) - abs(A[i+1] - A[i])
            pre = A[i]


    print("\n".join(map(str, Ans)))

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 18216
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    double a, b;
    cin >> a >> b;
    double arg;
    cin >> arg;
    double s, l, h;
    s = ((double)1 / 2) * sin((double)arg * M_PI / 180) * a * b;
    l = a + b + sqrt(a * a + b * b - ((double)2) * a * b * cos((double)arg * M_PI / 180));
    h = s * 2 / a;
    cout << std::fixed << std::setprecision(10) << s << endl;
    cout << std::fixed << std::setprecision(10) << l << endl;
    cout << std::fixed << std::setprecision(10) << h << endl;
    return 0;
}


Measured memory_bytes: 3464
use proconio::{input, fastout};
use proconio::marker::{Chars};
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        s: Chars,
        k: usize,
    }

    let mut ans = 0;
    let mut cnt = k;
    for i in 0..s.len() {
        if s[i]=='1' {
            ans = 1;
            cnt -= 1;
            if cnt==0 {
                break;
            }
        } else {
            ans = s[i].to_digit(10).unwrap();
            break;
        }
    }

    println!("{}", ans);

}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}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);
	cout<<fixed<<setprecision(10);

	ll N=in();
	auto A=vecin<ll>(N),B=vecin<ll>(N);
	auto SA=accumulate(ALL(A),0LL),SB=accumulate(ALL(B),0LL);

	if(SA>SB){
		out("No");
		return 0;
	}

	ll NA=0,NB=0;
	REP(i,N){
		if(A[i]<B[i]){
			ll D=(B[i]-A[i]);
			NA += ceil(D/2.0);
		}
	}
	
	out(NA<=SB-SA?"Yes":"No");
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long LL;
const int INF = 1 << 30;
const int MaxN = 1e5;

int n;
char s[5];
int main()
{
	while(scanf("%s", s) != EOF)
	{
		if(s[0] == s[2]) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
import scala.io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    val Array(x,y) = readLine.split(" ")
    println(f"${solve(x,y)}")
  }

def solve(a: String, b: String): String = {
  if (a < b) "<"
  else if(a>b) ">"
  else "="
}

}


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

int main () {
  int N;
  cin >> N;
  
  int count = 0;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    count += b - a + 1;
  }
  cout << count << endl;
}

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

const int inf = 1e9;
const ll linf = 1e18;

int main()
{
    double a, b, x; cin >> a >> b >> x;
    
    double ans;
    if (x <= a * a * b / 2.0) {
        ans = atan(a * b * b /(2.0 * x));
    } else {
        double rest = a * a * b - x;
        ans = atan(2.0 * rest / (a * a * a));
    }
    cout << setprecision(15) << ans * 180.0 / M_PI << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    priority_queue<int> Q;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        Q.push(a);
    }
    for(int i=0;i<m;i++){
        int x=Q.top();
        Q.pop();
        Q.push(x/2);
    }
    int res=0;
    while(!Q.empty()){
        int x=Q.top();
        Q.pop();
        res+=x;
    }
    cout<<res<<endl;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()
#define BETWEEN(a, x, b) (a) <= (x) && (x) <= (b) 

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;


void solve()
{
    string s; 
    cin >> s;
    REP(i, s.length()-1)
    {
        if(s[i] == s[i+1])
        {
            cout << i+1 << ' ' << i+2 << endl;
            return;
        }
    }
    REP(i, s.length()-2)
    {
        if(s[i] == s[i+2])
        {
            cout << i+1 << ' ' << i+3 << endl;
            return;
        }
    }
    cout << -1 << ' ' << -1 << endl;
}

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

    return 0;
}

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

using namespace std;

int n, k;
long long ans1 = 0, ans2 = 0;

int main() {
	cin >> n >> k;
	for (int a = 1; a <= n; ++a) if (2*a % k == 0) {
		long long num = (n-a)/k;
		ans1 += (num+1)*num*3;
		ans2++;
	}
	cout << ans1+ans2 << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

void solve_abc_b() {
	ll n, x; // , a, b;
	//ll ans = 0;
	float ans = 0;

	cin >> n;

	V a(n);
	float sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += (float)1 / a[i];
	}

	ans = (float)1 / sum;

	cout << ans << "\n";
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_b();

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int A,B,T;
  int i;
  int x=0;

  scanf("%d %d %d",&A,&B,&T);
  for(i=A;i<=T;i+=A){
    x+=B;
  }
  printf("%d",x);

  return 0;
}


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

using namespace std;



int main(void) {
	int X;
	cin >> X;
	int delta = 1;
	int A = 120;
	int B = A-delta;
	long long test;
	bool find = false;
	while (!find) {
		//AとBの更新
		A -= 1;
		B = A - delta;
		if (B < -119) {
			//差を更新
			delta += 1;
			A = 120;
			B = A - delta;
		}
		test = (A*A*A*A*A) - (B*B*B*B*B);
		if (test == X) find = true;
	}
	cout << A << " "<< B<<endl;
	return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int mo=1000000007;
int n,a[105];
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
pii F(int l,int r,int v){
	if (l==r)
		return pii(power(2,a[l]-v-1),0);
	int mnv=1<<30,las=l;
	pii vf;
	For(i,l,r) mnv=min(mnv,a[i]);
	For(i,l,r+1)
		if (a[i]==mnv||i==r+1){
			if (las!=i){
				pii vson=F(las,i-1,mnv);
				int v1=vf.fi,v2=vf.se;
				int v3=2ll*vson.fi%mo,v4=vson.se;
				if (las==l) vf=pii(v3,v4);
				else{
					vf.fi=1ll*v1*v3%mo;
					vf.se=(2ll*(v1+v2)*(v3+v4)+mo-vf.fi)%mo;
				}
			}
			if (i!=r+1){
				if (i==l) vf=pii(1,0);
				else vf.se=(2ll*vf.se+vf.fi)%mo;
			}
			las=i+1;
		}
	vf.fi=1ll*vf.fi*power(2,mnv-v-1)%mo;
	return vf;
}
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	pii ans=F(1,n,0);
	printf("%d",2ll*(ans.fi+ans.se)%mo);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    int n;
    cin >> n;
    vector<ll> data(n);
    int two_cnt = 0;
    int four_cnt = 0;
    int free = 0;
    rep(i,0,n){
        cin >> data[i];
        if(data[i]%4==0){
            four_cnt ++;
        }else if(data[i]%2==0){
            two_cnt ++;
        }else{
            free ++;
        }
    }
    if(free == 0){
        
        cout<<"Yes"<<endl;
        
        
    }else if(two_cnt==0){
        if(free>four_cnt+1){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }else{
        if(free>four_cnt){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }

  return 0;
}

Measured memory_bytes: 4056
n=int(input())
A=[0]+list(map(int,input().split()))+[0]

#print(A)
su=0
for i in range(n+1):
    su+=abs(A[i+1]-A[i])

#print(su)

for i in range(1,n+1):
    if A[i-1]<=A[i]<=A[i+1] :
        print(su)
    else :
        print(su-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))


Measured memory_bytes: 14048
#include <iostream>

using namespace std;

int H[105];

int main()
{
    int X, N, x;

    cin >> X >> N;

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

    int left, right;

    left = right = X;

    while(true)
    {
        if(left >= 0 && !H[left])
        {
            cout << left;
            break;
        }
        if(right <= 101 && !H[right])
        {
            cout << right;
            break;
        }
        left--;
        right++;
    }

    return 0;
}


Measured memory_bytes: 3616
a,b = map(int,input().split())

if a > 0:
    ans = 1
elif a <= 0 and b >= 0:
    ans = 0
else:
    if (b-a+1)%2 == 0:
        ans = 1
    else:
        ans = -1
if ans == 1:
    print("Positive")
elif ans == 0:
    print("Zero")
else:
    print("Negative")

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

int main() {
  int N; std::cin >> N;
  if (N == 1) std::cout << "Hello World" << std::endl;
  else {
    int A, B; std::cin >> A >> B;
    std::cout << A + B << std::endl;
  }
}


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

int main () {
  string s, t;
  cin >> s >> t;
  sort (s.begin(), s.end());
  sort (t.begin(), t.end());
  reverse (t.begin(), t.end());
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

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

int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll b1 = b;
    b1 -= b/c;
    b1 -= b/d;

    ll l = lcm(c, d);
    b1 += b/l;

    ll a1 = a-1;
    a1 -= (a-1)/c;
    a1 -= (a-1)/d;
    a1 += (a-1)/l;

    // cout << b1 << " " << a1 << endl;
    cout << b1-a1 << endl;

    return 0;
}

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

vector<ll> prime;

void primeEnumeration(ll n) {
  for (ll i = 2; i <= n; i++) {
    bool flag = true;
    for (ll j = 2; j*j <= i; j++) {
      if (i%j == 0) {
        flag = false;
        break;
      }
    }
    if (flag) prime.push_back(i);
  }
}

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

  ll N, P;
  cin >> N >> P;

  if (N == 1) {
    cout << P << endl;
    return 0;
  }

  primeEnumeration((int)sqrt(P)+100);

  ll ans = 1;
  ll i = 0;
  ll cnt = 0;
  ll tmp = P;
  while (prime[i] <= tmp) {
    if (prime[i] >= (int)sqrt(P)) break;
    if (tmp % prime[i] == 0) {
      tmp /= prime[i];
      cnt++;
    } else {
      ans *= pow(prime[i], cnt / N);
      i++;
      cnt = 0;
    }
  }
  ans *= pow(prime[i], (cnt / N));
  cout << ans << endl;
}


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

int main(void){
    int i = 0, cnt = 0, num = -1;
    int *ary = malloc(sizeof(int) * 10000);

    while (num != 0){
        scanf("%d", &num);
        ary[cnt] = num;
        cnt++;
    }

    for (i = 0; i < cnt-1; i++){
        printf("Case %d: %d\n", i+1, ary[i]);
    }
}


Measured memory_bytes: 1920
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] count = new int[10001];

        for (int x = 1; x <= 100; x++)
        {
            for (int y = 1; y <= 100; y++)
            {
                for (int z = 1; z <= 100; z++)
                {
                    int index = x * x + y * y + z * z + x * y + y * z + z * x;
                    if (index <= 10000)
                    {
                        count[index]++;
                    }
                }
            }
        }

        for (int i = 1; i <= n; i++)
        {
            Console.WriteLine(count[i]);
        }
    }
}


Measured memory_bytes: 27516
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
//#include<cstdio>
//#include<iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include<string>//"reverse(s's it,s's it)"
//#include<functional>//"greater<T>" "sort(a,a+n,greater<int>());""
//#include<cmath>//"abs" "sqrt"
//#include<numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include<algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
//#include<cassert>//"assert(cond);": error if cond doesn't hold.
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert//also use as v.is(v's it,w's it,w's it);
#define ps push//TMP//stack,(priority) queue,
#define fr front//TMP//queue//for priority, use top().
typedef long long ll;//not necessarily
typedef pair<int,int> pii;
//Add other types in the same way.
const ll M=1000000007;//can be changed
int mod(int a){	return (a+M)%M;	}//M can be a variable
void plmod(ll &a,ll b){	a=(a+b+M)%M;	return;	}
void mnmod(ll &a,ll b){	a=(a-b+M)%M;	return;	}
void mlmod(ll &a,ll b){	a=(a*b)%M;  	return;	}
//Caution! you may need sth larger than "+M"!
void chmax(int &a,int b){	a=max(a,b);	return;	}
void chmin(int &a,int b){	a=min(a,b);	return;	}
//These 2 could be better in long long

int main(){
	printf("1407 38\n");
	int k=38;
	for(int i=1;i<=k;++i) cout<<i<<" ";//can be WA cuz of this.
	cout<<endl;
	for(int l=1;l<k;++l){
		cout<<1<<" ";
		for(int i=2;i<=k;++i) cout<<i+(l*(k-1))<<" ";
		cout<<endl;
	}
	for(int j=0;j<k-1;++j){
		for(int l=1;l<k;++l){
			cout<<j+2<<" ";
			for(int i=2;i<=k;++i) cout<<((k-1)*k+l-1-j*(i-2))%(k-1)+2+((i-1)*(k-1))<<" ";
			cout<<endl;
		}
	}
}

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



int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,m;
    cin>>n>>m;
   string a="",b="";
   for(int i=0;i<n;i++)
   {
   	a+=m+'0';
   }
   for(int i=0;i<m;i++)
   {
   	b+=n+'0';
   }
   if(a<b)
   {
   	cout<<a<<endl;
   }
   else 
   {
   	cout<<b<<endl;
   }
	
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	reverse(a,a+n);
	long long l=2LL,r=3LL;
	for (int i = 0; i < n; ++i)
	{
		l=(l+a[i]-1LL)/a[i]*a[i];
		r=(r-1LL)/a[i]*a[i]+a[i];
		if (r<=l)
		{
			cout<<"-1\n";
			return 0;
		}
	}
	cout<<l<<" "<<r-1LL<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t t=0; t<v.size(); ++t){cout << " " << #v << "[" << t << "]=" << v[t];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    
    int a, b, c;
    cin >> a >> b >> c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << s.size() << endl;
    return 0;
}
    

Measured memory_bytes: 256
#include <stdio.h>

void sort(int data[], int length)
{
  int i, j;
  int tmp;

  for (i = length; i > 0; i--) {
    for (j = 0; j < i - 1; j++) {
      if (data[j] > data[j + 1]) {
        tmp = data[j];
        data[j] = data[j + 1];
        data[j + 1] = tmp;
      }
    }
  }
}

int main(void)
{
  int n;
  int data[3];
  int i;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &data[0], &data[1], &data[2]);
    sort(data, 3);
    if (data[2] * data[2] == (data[0] * data[0] + data[1] * data[1])) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }

  return 0;
}

Measured memory_bytes: 580