akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int main(void){
  int i, count=0;
  char a[10];
  char f[1000];

  scanf("%s", a);
  for(i=0;i<10;i++){
    if(64 <a[i] && a[i] < 91) a[i] += 32;
  }
  scanf("%s", f);
  while(strcmp(f, "END_OF_TEXT")){
    for(i=0;i<1000;i++){
      if(f[i] == 0) break;
      if(64 <f[i] && f[i] < 91) f[i] += 32;
    }
    if(strcmp(f, a) == 0) count++;
//    printf("%s\n", f);
    scanf("%s", f);
  }
  printf("%d\n", count);
  return 0;
}



Measured memory_bytes: 2140
#include<iostream>
using namespace std;
int main()
{
	//input
	int a, b;
	cin >> a >> b;
	//odd?
	int a_2 = a % 2;
	int b_2 = b % 2;
	if (a_2 == 1)
	{
		if (b_2 == 1)
		{
			cout << "Yes";
		} else {
			cout << "No";
		}
	}
	else {
		cout << "No";
	}
}

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

using namespace std;

typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long double ld;

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

const int N = 1e5 + 5;

int n;
pii seg[N];

int main() {

#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;

    for (int x, l, i = 0; i < n; i++) {
        cin >> x >> l;
        seg[i] = {x + l, x - l};
    }

    sort(seg, seg + n);

    int res = 0;
    int last = -2 * inf - 10;

    for (int i = 0; i < n; i++) {
        if (seg[i].second >= last)
            res++, last = seg[i].first;
    }

    cout << res << "\n";

    return 0;
}


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

long long gcd(long long a, long long b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}

bool check(long long q, vector<long long> a) {
    int n = a.size();
    // divide x^q - x;
    for (int i = 0; i < n; i++) {
        a[i] = (a[i] % q + q) % q;
        int c = i + (int) q - 1;
        if (c < n - 1) {
            a[c] = (a[c] % q + q) % q;
            a[c] += a[i];
            a[c] %= q; a[i] = 0;
        }
        if (a[i]) return false;
    }
    return true;
}

vector<bool> Eratosthenes(int n){
	vector<bool> prime(n+1, true);
	if(n >= 0) prime[0] = false;
	if(n >= 1) prime[1] = false;
	for(int i = 2; i * i <= n; i++){
		if(prime[i]){
			for(int j = i + i; j <= n; j += i) prime[j] = false;
		}
	}
    return prime;
}

int main() {
    int n; cin >> n;
    vector<long long> a(n+1);
    vector<long long> ans;
    for (int i = 0; i <= n; i++) {
        cin >> a[i];
    }
    long long d = abs(a[0]);
    for (int i = 0; i <= n; i++) {
        if (a[i]) d = gcd(d, abs(a[i]));
    }
    //cout << " " << d << endl;
    vector<long long> u;
    if (d >= 2) {
        for (long long c = 2; c * c <= d; c++) {
            if (d % c == 0) {
                u.emplace_back(c);
                while (d % c == 0) d /= c;
            }
        }
        if (d != 1) u.emplace_back(d);
        if (!u.empty()) for (auto q: u) {
            ans.emplace_back(q);
        }
    }
    auto prime = Eratosthenes(n+10);
    for (int i = 2; i <= n; i++) {
        if (prime[i]) {
            if (check((long long) i, a)) ans.emplace_back((long long) i);
        }
    }
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    if (ans.empty()) return 0;
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
import sys
import math


# 二分ヒープ数のサイズ
H = int(input())
# 二分ヒープを表す配列
A = list(map(int, input().split()))
# parent, left, right
parent, left, right = [], [], []


for i in range(H):
    count = i+1
    if count == 1:
        parent.append(0)
    else:
        parent.append(A[math.floor(count/2)-1])

    if 2*count <= len(A):
        left.append(A[2*count-1])
    else:
        left.append(0)

    if 2*count+1 <= len(A):
        right.append(A[2*count])
    else:
        right.append(0)

for i in range(H):

    sys.stdout.write('node %d: key = %d, ' % (i+1, A[i]))

    if parent[i] != 0:
        sys.stdout.write('parent key = %d, ' % parent[i])

    if left[i] != 0:
        sys.stdout.write('left key = %d, ' % left[i])

    if right[i] != 0:
        sys.stdout.write('right key = %d, ' % right[i])
    print()
# print('H: ', H)
# print('A: ', A)
# print('parent: ', parent)
# print('left: ', left)
# print('right: ', right)



Measured memory_bytes: 5732
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=(1<<17)+1,mo=1e9+7;
int n,m,a[maxn],po[maxn],fac[maxn],ans,inv[maxn],f[18][maxn];
int qpow(int a,int b)
{
	int ans=1;
	for(;b;b>>=1,a=a*a%mo)
		if(b&1)ans=ans*a%mo;
	return ans;
}
inline void prep(int n)
{
	fac[0]=inv[0]=1;
	for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i%mo;
	inv[n]=qpow(fac[n],mo-2);
	for(int i=n-1;i;i--)inv[i]=inv[i+1]*(i+1)%mo;
}

int calc(int x,int y)
{
//	cout<<"cal "<<x<<" "<<y<<" "<<fac[x]<<" "<<inv[y]<<" "<<inv[x-y]%mo<<endl;
	if(x<y||y<0)return 0;
	return fac[x]*inv[y]%mo*inv[x-y]%mo;
}

bool cmp(int a,int b){return a>b;}
signed main() 
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)cin>>a[i];	
	prep(1<<n);
	int maxstate=(1<<n)-1;
	f[m+1][0]=1;
	for(int i=m;i>=1;i--)
	{	
		for(int j=0;j<=maxstate;j++)
		{
			f[i][j]+=f[i+1][j],f[i][j]%=mo;
	//		cout<<i<<" "<<j<<" "<<f[i][j]<<endl;
			for(int k=0;k<=n-1;k++)
			{
				if((j>>k)&1)continue;
				f[i][(1<<k)+j]+=f[i+1][j]*calc((1<<n)-j-a[i],(1<<k)-1)%mo*fac[1<<k]%mo;
				f[i][(1<<k)+j]%=mo;
			}
		}
	}
	for(int i=0;i<=maxstate;i++)
	{
	//	cout<<f[1][i]<<endl;
		int cnt=0;
		for(int j=i;j;j-=j&-j)++cnt;
		if(cnt&1)ans=(ans+mo-f[1][i]*fac[(1<<n)-i-1]%mo)%mo;
		else ans=(ans+f[1][i]*fac[(1<<n)-i-1]%mo)%mo;
	}
	cout<<ans*(1<<n)%mo;
	return 0;
}
/*

*/


Measured memory_bytes: 12908
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int count=0;
		for(int i=1; i<=n; i++){
			int x=sc.nextInt();
			if(isprime(x)){
				count++;
			}
		}
		System.out.println(count);



	}
	public static boolean isprime(int x){
		if(x==2){
			return true;
		}
		if(x%2==0 || x<2){
			return false;
		}
		int i=3;
		while(i<=Math.sqrt(x)){
			if(x%i==0){
				return false;
			}
			i+=2;
		}
		return true;
	}

	}


Measured memory_bytes: 41040
#include<iostream>
#include<string>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	stack<int> S1;
	stack<pair<int,int> > S2;
	char ch;
	int sum=0;
	for (int i=0;cin>>ch;i++){
		if(ch=='\\'){
			S1.push(i);
		}else if(ch=='/' && S1.size()>0){
			int j=S1.top();S1.pop();
			int a=i-j;
			sum+=a;
			while(S2.size()>0 && S2.top().first>j){
				a+=S2.top().second; S2.pop();
			}
			S2.push(make_pair(j,a));
		}
	}
	
	vector<int> ans;
	while(S2.size()>0) {
		ans.push_back(S2.top().second);
		S2.pop();
	}
	reverse(ans.begin(),ans.end());
	cout << sum << endl;
	cout << ans.size();
	for(int i=0;i<ans.size();i++){
		cout << " " << ans[i];
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
char a[10005];
int main()
{
	int n;
	cin >> n;
	cin >> a;
	for(int i=0;i<strlen(a);i++){
		printf("%c",(((a[i]-65)+n)%26)+65);
	}
	cout << endl;
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
	double r, p, m;

	cin >> r;

	p = r * r * 3.141592653589;

	m = r * 2 * 3.141592653589;

	printf("%f" , p);
	printf(" ");
	printf("%f" , m);

}

Measured memory_bytes: 1236
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_20181006
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());
            if(x == 1)
            {
                Console.WriteLine("Hello World");
            }
            else
            {
                var a = int.Parse(Console.ReadLine());
                var b = int.Parse(Console.ReadLine());
                Console.WriteLine(a + b);
            }
        }
    }
}


Measured memory_bytes: 13140
"use strict"

const main = arg => {
  arg = arg.trim().split("\n");
  const N = parseInt(arg[0]);
  const L = arg[1].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
  
  let answer = 0;
  
  for(let i=0; i<N*2; i+=2) {
    answer += L[i];
  }
  
  console.log(answer);
}

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


Measured memory_bytes: 7500
#include<stdio.h>

#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int prim();

int n,M[MAX][MAX];

int main(){
  int i,j,e;
  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      scanf("%d",&e);
      M[i][j] = (e == -1) ? INFTY : e; 
    }
  }

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

  return 0;
}


int prim(){
  int u,minv,i,v;
  int d[MAX],p[MAX],color[MAX];

  for( i = 0 ; i < n ; i++ ){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for( i = 0 ; i < n ; i++ ){
      if( minv > d[i] && color[i] != BLACK ){
	u = i;
	minv = d[i];
      }
    }

    if( u == -1 ) break;

    color[u] = BLACK;

    for( v = 0 ; v < n ; v++ ){
      if(color[v] != BLACK && M[u][v] != INFTY ){
	if( d[v] > M[u][v] ){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }

  int sum = 0;

  for( i = 0 ; i < n ; i++ ){
    if( p[i] != -1 ) sum += M[i][p[i]];
  }

  return sum;
} 

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define ll long long
#define int long long
#define ld long double
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 1e5 + 100 , N = 1e5 + 5 , SQ = 600 , base = 1999 , mod = 1e9 + 7 , INF = 1e18 , lg = 17;

int n , p2[maxn] , p1[maxn][5] , suma[maxn] , sumb[maxn] , sumc[maxn] , sumq[maxn] , ans;
string s;

// 0 -> B C , 1 -> ? C , 2 -> ? ? , 3 -> B ?;

inline void pre() {
    p2[0] = 1;
    for (int i = 1; i < maxn; ++i) {
        p2[i] = (p2[i - 1] * 3) % mod;
    }
    for (int j = n; j >= 1; --j) {
        suma[j] = suma[j + 1] + (s[j - 1] == 'A');
    }
    for (int j = n; j >= 1; --j) {
        sumb[j] = sumb[j + 1] + (s[j - 1] == 'B');
    }
    for (int j = n; j >= 1; --j) {
        sumc[j] = sumc[j + 1] + (s[j - 1] == 'C');
    }
    for (int j = n; j >= 1; --j) {
        sumq[j] = sumq[j + 1] + (s[j - 1] == '?');
    }

    for (int j = n; j >= 1; --j) {
        p1[j][0] = p1[j + 1][0];
        (p1[j][0] += (s[j - 1] == 'B' ? sumc[j + 1] : 0)) %= mod;
    }
    for (int j = n; j >= 1; --j) {
        p1[j][1] = p1[j + 1][1];
        (p1[j][1] += (s[j - 1] == '?' ? sumc[j + 1] : 0)) %= mod;
    }
    for (int j = n; j >= 1; --j) {
        p1[j][2] = p1[j + 1][2];
        (p1[j][2] += (s[j - 1] == '?' ? sumq[j + 1] : 0)) %= mod;
    }
    for (int j = n; j >= 1; --j) {
        p1[j][3] = p1[j + 1][3];
        (p1[j][3] += (s[j - 1] == 'B' ? sumq[j + 1] : 0)) % mod;
    }
}

int32_t main() {
    FAST
    cin >> s;
    n = s.size();
    pre();

    for (int i = n; i >= 1; --i) {
        if(s[i - 1] == 'A') {
            ans = (ans + (p1[i + 1][0] * p2[sumq[1]]) % mod) % mod;
            // cout << p1[i + 1][0] * p2[sumq[1]] << endl;
            ans = (ans + (p1[i + 1][1] * p2[sumq[1] - 1]) % mod) % mod;
            // cout << p1[i + 1][1] * p2[sumq[1] - 1] << endl;
            ans = (ans + (p1[i + 1][2] * p2[sumq[1] - 2]) % mod) % mod;
            // cout << p1[i + 1][2] * p2[sumq[1] - 2] << endl;
            ans = (ans + (p1[i + 1][3] * p2[sumq[1] - 1]) % mod) % mod;
            // cout << p1[i + 1][3] * p2[sumq[1] - 1] << endl;
            // cout << ans << endl;
        }
        else if(s[i - 1] == '?') {
            ans = (ans + (p1[i + 1][0] * p2[sumq[1] - 1]) % mod) % mod;
            ans = (ans + (p1[i + 1][1] * p2[sumq[1] - 2]) % mod) % mod;
            // cout << i << ' ' << p1[i + 1][1] << endl;
            ans = (ans + (p1[i + 1][2] * p2[sumq[1] - 3]) % mod) % mod;
            ans = (ans + (p1[i + 1][3] * p2[sumq[1] - 2]) % mod) % mod;
        }
        // cout <<  "hey" << ans << '\n';
    }

    cout << ans << '\n';
 }


Measured memory_bytes: 11616
#include<unordered_set>
#include<cstdio>
int main(){
    int n,tmp;
    std::unordered_set<int> s;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&tmp);
        if(s.count(tmp)==0)s.emplace(tmp);
        else s.erase(tmp);
    }
    printf("%d",s.size());
    return 0;
}

Measured memory_bytes: 4388
// A. 

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	int N, C, K;
	cin >> N >> C >> K;
	int ans = 0, r = 0, bt, t[100000];
	for (int i = 0; i < N; ++i) {
		cin >> t[i];
	}
	sort(t, t + N);
	for (int i = 0; i < N; ++i) {
		if (r > 0 && t[i] <= bt) {
			--r;
		} else {
			++ans;
			r = C - 1;
			bt = t[i] + K;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>

int main(void){
  while(1){
int stonNum[51] = {0};
    int p, n;
    std::cin >> n >> p;
    int first = p;
    if(n == 0 && p == 0)  return 0;
    int i=0;
    while(1){
      bool flag = true;
      if(p > 0){
        stonNum[i]++;
        p--;
        if(stonNum[i] == first){
        std::cout << i << std::endl;
        break;
        }
      }else{
        p += stonNum[i];
        stonNum[i] = 0;
      }
      if(i == n-1)  i = 0;
      else i++;
    }
  }
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
#include<time.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define fe(x) for(int ii=be[x];ii;ii=e[ii].ne)
using namespace std;
int r,c,n,m,xx,yy,zz,ww,t1,t2,st,s[210000];
/*int random(){
	return rand()*32768+rand();
}*/
int bor(int a,int b){//a=0..r b=0..c
	if (b==0) return a+1;
	if (a==r) return b+r+1;
	if (b==c) return r+c+1+r-a;
	if (a==0) return r+c+1+r+c-b;
	return 0;
}
struct nod{
	int x,na;
	bool operator <(const nod &a)const{
		return x<a.x;
	}
};
nod a[210000];
int main(){
	scanf("%d%d%d",&r,&c,&n);
	/*fo(i,0,r) printf("%d ",bor(i,0));
	fo(i,1,c) printf("%d ",bor(r,i));
	fd(i,r-1,0) printf("%d ",bor(i,c));
	fd(i,c-1,1) printf("%d ",bor(0,i));*/
	fo(i,1,n){
		scanf("%d%d%d%d",&xx,&yy,&zz,&ww);
		t1=bor(xx,yy);t2=bor(zz,ww);
		if (t1==0||t2==0) continue;
		if (t1>t2) swap(t1,t2);
		a[++m].x=t1;a[m].na=i;
		a[++m].x=t2;a[m].na=-i;
	}
	sort(a+1,a+m+1);
	fo(i,1,m){
		if (a[i].na>0){
			s[++st]=a[i].na;
			continue;
		}
		if (a[i].na+s[st]!=0){
			printf("NO\n");
			return 0;
		}
		st--;
	}

	printf("YES\n");
	return 0;
}



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

constexpr int lim = 1e6;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  vector<bool> b(lim + 1, true);
  b[0] = b[1] = false;
  for (int p = 2; p * p <= lim; ++p) {
    if (b[p]) {
      for (int i = 2 * p; i <= lim; i += p) {
        b[i] = false;
      }
    }
  }
  int a, d, n;
  while (cin >> a >> d >> n, a) {
    for (int i = a; ; i += d) {
      n -= b[i];
      if (n == 0) {
        cout << i << '\n';
        break;
      }
    }
  }
}



Measured memory_bytes: 3216
INF = 10**8

N, M = map(int, input().split())
n = 2 ** N
dp = [0] + [INF]*(n - 1)

for _ in range(M):
  a, b = map(int, input().split())
  c = sum(map(lambda x:2**(x-1), list(map(int, input().split()))))
  for i in range(n):
    dp[i | c] = min(dp[i] + a, dp[i | c])
  
if dp[-1] == INF:
  print(-1)
else:
  print(dp[-1])


Measured memory_bytes: 48344
#include<iostream>
#include<cstdio> 
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;

int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}

int main(){
	LL ans=0,a,b;
	cin>>a>>b;
	if(a%b==0)
		cout<<"-1"<<endl;
	else{
		ans=a;
		bool flag=false;
		while(ans<=1e18){
			if(gcd(ans,b)!=b){
				flag=true;
				break;
			}
		}
		if(flag)
			cout<<ans<<endl;
		else
			cout<<"-1"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	int cnt = 0;
	rep(i,n-1) {
		if (s[i] != s[i+1]) cnt++;
	}
	int ans = n-1 - max(0,cnt-2*k);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3764
import sys
from collections import deque

sys.setrecursionlimit(10000)
INF = float('inf')

assert 2 ** 18 == 262144

# def cumxor(li):
#     return list(itertools.accumulate(li, operator.xor))
#
#
# def xors(li):
#     """
#     :param list of int li:
#     :return:
#     """
#     cumxors = cumxor(li)
#     n = len(li) // 2
#     xors = []
#     for i in range(n):
#         st = li.index(i)
#         en = li.index(i, st + 1)
#         xors.append(cumxors[en - 1] ^ cumxors[st])
#     return xors


M, K = list(map(int, input().split()))

if K == 0:
    ans = []
    for i in range(2 ** M):
        ans.append(i)
        ans.append(i)
    print(*ans)
    exit()

if M == 1:
    if K == 0:
        print(0, 0, 1, 1)
    else:
        print(-1)
    exit()

if K >= 2 ** M:
    print(-1)
    exit()

ans = deque()
ans.append(K)
for i in range(2 ** M):
    if i == K:
        continue
    ans.append(i)
    ans.appendleft(i)
ans.append(K)
print(*ans)


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

int main(){
  int x[5];
  int ans = 0;
  for (int i = 0; i < 5; i++){
    cin >> x[i];
    if(x[i] == 0) ans = i + 1;
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 3584
#!/usr/bin/env python3

# N = int(input())
# S = input()
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

def main():
    cnt_1 = 0
    for i in range(1, 1000):
        if X + i in A:
            cnt_1 += 1
        if X + i == N:
            break
    cnt_2 = 0
    for i in range(1, 1000):
        if X - i in A:
            cnt_2 += 1
        if X - i == 0:
            break
    print(min(cnt_1, cnt_2))

if __name__ == "__main__":
    main()


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

double dp[3333][3333];

int main(){
	
	int n;cin >> n;
	vector<double> v(n);
	REP(i,n)cin >> v[i];
	dp[0][0] = 1;
	
	REP(i,n){
		REP(j,n)if(dp[i][j] > 0){
			dp[i+1][j+1] += dp[i][j] * v[i];
			dp[i+1][j] += dp[i][j] * (1 - v[i]);
		}
	}
		
	double ans = 0;
	REP(i,n+1)if(2 * i > n)ans += dp[n][i];
	cout << Decimal << ans << endl;
	
	
	return 0;
}


Measured memory_bytes: 78464
/*
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
using ll = long long;

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

    int n;
    cin >> n;
    int arr[n + 1];
    memset(arr, 0, sizeof arr);
    for(int i = 2;i <= n;i++)
    {
        int a;
        cin >> a;
        arr[a]++;
    }
    for(int i= 1;i <= n;i++)
    {
        cout << arr[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4432
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto a=scanElem;
  auto b=scanElem;
  writeln((a+b)%24);
}


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

int main()
{
  int N;
  int h[110000];
  int res=0;
  cin >> N;

  rep(i,N) cin >> h[i];

  int dp[110000];

  memset(dp, 0, sizeof(dp));
  dp[1] = abs(h[1]-h[0]);

  FOR(i, 2, N-1) {
    int cost1 = abs(h[i] - h[i-1]);
    int cost2 = abs(h[i] - h[i-2]);
    dp[i] = min(dp[i-1] + cost1, dp[i-2] + cost2);
  }

  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

int N;
int A[105];
int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N;
	FOR(n,N) {
		cin >> A[n];
	}
	double sum = 0;
	FOR(n,N) {
		sum+=1.0/(double)A[n];
	}
	cout << std::setprecision(10);
	cout << (double)1.0/sum << endl;

	return 0;
}




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

int main() {
    int N;
    int L[11];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> L[i];
    int sum = 0;
	int max = -1;
	for(int i = 0; i < N; ++i){
		sum += L[i];
		if(max <= L[i]) max = L[i];
	}
	if(max < sum - max){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;

typedef pair<int,int> P;

int main(){
  int c,n,m,s,g,a,b,f;
  int cost[101][101];
  int d[11][101];

  while(1){
    scanf("%d %d %d %d %d",&c,&n,&m,&s,&g);
    if(!c && !n && !m && !s && !g)break;

    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){
	if(i-j)cost[i][j] = 1<<29;
	else cost[i][j] = 0;
      }
    }

    for(int i=0;i<m;i++){
      scanf("%d %d %d",&a,&b,&f);
      cost[a][b] = f;
      cost[b][a] = f;
    }

    priority_queue<P,vector<P>,greater<P> > q;
    fill(d[0],d[0]+n+1,1<<29);
    d[0][s] = 0;
    q.push(P(0,s));

    while(q.size()){
      P p=q.top();
      q.pop();
      int v = p.second;
      if(d[0][v] < p.first)continue;
      for(int i=1;i<=n;i++){
	if(d[0][i] > d[0][v] + cost[v][i]){
	  d[0][i] = d[0][v] + cost[v][i];
	  q.push(P(d[0][i],i));
	}
      }
    }

    for(int i=1;i<=c;i++){
      fill(d[i],d[i]+n+1,1<<29);
      d[i][s] = 0;
      q.push(P(0,s));

      while(q.size()){
	P p=q.top();
	q.pop();
	int v = p.second;
	if(d[i][v] < p.first)continue;
	for(int j=1;j<=n;j++){
	  int tmp = min(d[i][v] + cost[v][j],d[i-1][v] + cost[v][j]/2);
	  if(d[i][j] > tmp){
	    d[i][j] = tmp;
	    q.push(P(d[i][j],j));
	  }
	}
      }
    }

    printf("%d\n",d[c][g]);
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
long long n,T,ans,now,cnt1,cnt2,f[100],sum[200010];
struct wang
{
	long long a,b;
}x,a[200010];
bool mycmp(wang x,wang y)
{
    return x.a*(y.b+1)>y.a*(x.b+1);
}
int main()
{
    scanf("%lld%lld",&n,&T);
    for (int i=1;i<=n;i++) {
        scanf("%lld%lld",&x.a,&x.b);
        if (x.a!=0) a[++cnt1]=x;
        else sum[++cnt2]=x.b+1;
    }
    sort(a+1,a+cnt1+1,mycmp);
    sort(sum+1,sum+cnt2+1);
    for (int i=1;i<=35;i++)
		f[i]=T+1;
    for (int i=1;i<=cnt2;i++)
		sum[i]+=sum[i-1];
    for (int i=1;i<=cnt1;i++)
        for (int j=35;j>=1;j--)
            if (f[j-1]<=T) f[j]=min(f[j],(a[i].a+1)*(f[j-1]+1)+a[i].b);
    for (int i=0;i<=35;i++) {
        if (f[i]>T) continue;
        now=upper_bound(sum+1,sum+cnt2+1,T-f[i])-sum-1;
        ans=max(ans,i+now);
    }
    printf("%lld",ans);
}

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

int count(int N, vector<int> &A, int k){
	int i, ans = 0;
	for(i = 0; i < N; i++){
		ans += A.end() - lower_bound(A.begin(), A.end(), k - A[i]);
	}
	return ans;
}

int sum(int N, vector<int> &A, int k){
	int i, ans = 0;
	vector<int> s(N + 1, 0);
	for(i = 1; i <= N; i++){
		s[i] = s[i - 1] + A[i - 1];
	}
	for(i = 0; i < N; i++){
		ans += A[i] * (A.end() - lower_bound(A.begin(), A.end(), k - A[i])) + (s[N] - s[lower_bound(A.begin(), A.end(), k - A[i]) - A.begin()]);
	}
	return ans;
}

signed main(){
	int N, M, i;
	scanf("%lld%lld", &N, &M);
	vector<int> A(N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
	}
	sort(A.begin(), A.end());
	int l = 0, h, r = 2 * A[N - 1] + 1;
	while(r - l > 1){
		h = (l + r) / 2;
		if(count(N, A, h) >= M){
			l = h;
		}
		else{
			r = h;
		}
	}
//	printf("l = %lld\n", l);
//	printf("sum(N, A, l) = %lld\n", sum(N, A, l));
	printf("%lld\n", sum(N, A, l) - l * (count(N, A, l) - M));
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int W = scn.nextInt();
		int H = scn.nextInt();
		int x = scn.nextInt();
		int y = scn.nextInt();
		int r = scn.nextInt();
		scn.close();
		
		System.out.println((x + r <= W && x - r >= 0 && y + r <= H && y - r >= 0)?"Yes":"No");


	}

}


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

char chess(int h,int w){
    if((h+w)%2==0){
        return '#';
    }
    return '.';
}

int main(void){
    int H,W;
    while(true){
        cin>>H>>W;
        if(H==0 && W==0){
        break;
        }
    
     for(int j=0; j<H; j++){
         for(int i=0; i<W; i++){
            cout<<chess(i,j);
         }
         cout<<endl;
     }
     cout<<endl;
    } 
}



Measured memory_bytes: 3068
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;

  int l = 1, r = N;
  long long c = (1+N)/2LL;
  while(l < r){
         if(c*(c+1) == 2*N) break;
    else if(c*(c+1) <  2*N) l=c;
    else /* c*(c+1) > 2*N */r=c;
    if (c == (l+r)/2LL) break;
    else c = (l+r)/2LL;
  }
  if(c*(c+1) <  2*N) c++; // こころぴょんぴょん
  for (int i=1; i<=c; i++){
    if(c*(c+1)/2LL == N+i) continue;
    cout << i << "\n";
  }
  return 0;
}
  
  
  

Measured memory_bytes: 3628
a, b, c = map(int, input().split())
if a == 1 and b == 1 and c == 1:
    print(0)
    exit()
if a == b and b == c:
    print(-1)
    exit()
cnt = 0
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    a, b, c = b//2+c//2, c//2+a//2, a//2+b//2
    cnt += 1
print(cnt)


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2000;

int N;
pii A[MAXN+10];
ll dp[MAXN+10][MAXN+10];

ll solve(int l, int r)
{
	ll &ret=dp[l][r];
	if(ret!=-1) return ret;
	ret=0;

	int t=l+N+1-r+1;
	if(t==N+1) return ret=0;

	ret=max(ret, solve(l+1, r)+(ll)abs(A[t].second-(l+1))*A[t].first);
	ret=max(ret, solve(l, r-1)+(ll)abs(A[t].second-(r-1))*A[t].first);
	return ret;
}

int main()
{
	int i, j;

	scanf("%d", &N);
	for(i=1; i<=N; i++) scanf("%d", &A[i].first), A[i].second=i;
	sort(A+1, A+N+1, greater<pii>());

	memset(dp, -1, sizeof(dp));
	printf("%lld\n", solve(0, N+1));
}

Measured memory_bytes: 35548
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Thu Dec 27 17:44:52 2018
//
package main

import (
  "fmt"
)

func main(){
	var s string
	fmt.Scan(&s)

	ans := 700
	for i := range s{
		if s[i] == 'o'{
			ans += 100
		}
	}
	fmt.Println(ans)
}


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

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

// 
ll f(vector<p>& pp){
    // 独立に行っているのに、番号n-1(0-origin)より上は意味がないので矯正
    for(auto& elm : pp){
        elm.first = min(elm.first, (ll)(pp.size()));
    }

    vector<vector<ll> > s(pp.size()+1);
    for(auto& elm : pp){
        s[elm.first].push_back(elm.second);
    }
    ll res = 0;
    priority_queue<ll> q;
    for(int i = pp.size(); i >= 1; i--){
        for(ll x : s[i]) q.push(x);
        if(!q.empty()){
            res += q.top();
            q.pop();
        }
    }
    return res;
}

void solve(){
    int N;
    cin >> N;
    cin.ignore();
    ll ans = 0;
    vector<p> lp, rp;
    for(int i = 0; i < N; i++){
        ll k, l, r;
        cin >> k >> l >> r;
        cin.ignore();
        ll m = min(l, r);
        ans += m;
        l -= m; r -= m;
        if(l > 0){
            lp.emplace_back(k, l);
        } else {
            rp.emplace_back(N - k, r);
        }
    }
    ans += f(lp);
    ans += f(rp);
    cout << ans << endl;
    return;
}

int main(){

    int T;
    cin >> T;
    cin.ignore();

    for(int i = 0; i < T; i++){
        solve();
    }

    return 0;
}

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

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

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(ll N, vector<ll> A) {
    vector<ll> B;
    for (int i = 0; i < N; i++) {
        B.push_back(abs(i - (N - 1 - i)));
    }
    sort(B.begin(), B.end());
    sort(A.begin(), A.end());
    if (A == B) {
        ll ans = 1;
        for (int i = 0; i < N / 2; i++) {
            ans *= 2;
            ans %= 1000000007;
        }
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }
}


void main_(istream &cin) {
    ll N;
    cin >> N;
    vector<ll> A(N - 1 + 1);
    for (int i = 0; i <= N - 1; i++) {
        cin >> A[i];
    }
    solve(N, A);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 2936
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
ll sum(ll l, ll r) {
  return (l+r)*(r-l+1)/2;
}

int main() {
  int n, k;
  cin >> n >> k;
  mint ans;
  for (int i = k; i <= n+1; i++) {
    ll l = sum(0,i-1), r = sum(n-i+1,n);
    ans += r-l+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
n = int(input())
p = [int(i) for i in input().split()]
cnt = 0
for i in range(1,n-1):
    tmp= [p[i-1],p[i],p[i+1]]
    if tmp[1]>=tmp[0] and tmp[1]<=tmp[2]:
        cnt += 1
    elif tmp[1]>tmp[2] and tmp[1]<=tmp[0]:
        cnt += 1
   
print(cnt)

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

using namespace std;

vector<int> a;

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

    int tmp;
    for(int i = 0; i < n; i++) {
        cin >> tmp;
        a.push_back(tmp);
    }

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

    int left = 0, right = a[a.size()-1]+1;
    int mid, count;
    while(abs(right-left) > 1) {
        mid = (left + right) / 2;
        count = 0;
        for(int i = 0; i < n; i++) {
            count += (a[i] + mid - 1) / mid - 1;
        }

        if(count > k) left = mid;
        else right = mid;
    }

    cout << right << endl;

}

Measured memory_bytes: 4216
#include <stdio.h>
#include<string.h>
char a[7][5]={ "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int b[7]={7,6,5,4,3,2,1};
char d[4];
int main()
{
	gets(d);

	for(int i=0;i<7;i++)
	if(strcmp(d,a[i])==0)
	{
	printf("%d\n",b[i]);
		return 0;
	}
	
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int x, a;
    cin >> x >> a;
    if(x >= a) {
        cout << 10 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
  //static double pi=3.14285714;
    public static void process()throws IOException
    {
      long n=nl();
      long sum=0;
      for(long i=1;i<=n;i++)
      {
          if(i%3!=0 && i%5!=0 && i%15!=0)
          sum+=i;
      }
      pn(sum);
    }

 static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

    //  oj = System.getProperty("ONLINE_JUDGE") != null;
        if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
        
         //int t=ni();
         //while(t-->0)
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static String nn()throws IOException{return sc.next();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;

/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
    
    
    

    


Measured memory_bytes: 32976
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

template <typename T>
inline T Gcd(T a, T b) {
    T c;
    while (b) {
        c = b;
        b = a % b;
        a = c;
    }
    return a;
}

Int Lcm(Int a, Int b) {
    if (a < b) {
        swap(a, b);
    }

    return a / Gcd(a, b) * b;
}

Int func(Int n, Int a, Int b) {
    Int ret = 0;

    Int G = Gcd(a, b);
    if (G == a || G == b) {
        ret = n - (n / G);
    } else {
        ret = n - ((n / a) + (n / b) - (n / Lcm(a, b)));
    }

    return ret;
}

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

    Int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << func(b, c, d) - func(a - 1, c, d) << endl;

    return 0;
}

Measured memory_bytes: 3536
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

using ll = long long;
//constexpr ll N = 2e5;
//ll a[N];

//constexpr int max = 2147483647;



int main()
{
	int n;
	map<string, int> s;
	string tmp;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> tmp;
		if (s.count(tmp))
			continue;
		else
			s[tmp] = 1;

	}
	
	cout << s.size();

	
	return 0;
}

Measured memory_bytes: 19228
#include<bits/stdc++.h>
 using namespace std;
 
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second 
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 1000000007
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define mp make_pair
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200015
 
int main()
{

 
ll n,i,j=0;
string s1;
map<string,ll>mp1;
cin>>n;
for(i=0;i<n;i++)
{
	cin>>s1;
	mp1[s1]++;
}
cout<<mp1.size()<<endl;
}

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

#define ll long long
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define MAX 1000000

vector<bool>prime(MAX, true);
vector<ll>fact(MAX);
vector<ll>factinv(MAX);

ll  fastpower(ll a, ll n)
{
	ll res = 1;
	while(n > 0)
	{
		if(n % 2 != 0)
		{
			res = (res * a) % MOD;
		}
		n /= 2;
		a=(a * a) % MOD;
	}
	return res;
}

void getprime()
{
	for(ll i = 2;i < MAX; i++)
	{
		if(prime[i-1])
		{
			for(ll j = i*i; j < MAX; j += i)
				prime[j-1] = false;
		}
	}
}

void getfact()
{
	fact[0] = 1;
	factinv[0] = 1;
	
	for(ll i = 1; i < MAX; i++)
		fact[i] = (fact[i-1] * i)%MOD;
	
	for(ll i = 1; i < MAX; i++)
		factinv[i] = (factinv[i-1] * fastpower(i, MOD -2) )%MOD;

}

int main()
{
  ll n;
  cin>>n;
  ll sum=0;
  for(ll i=1;i<=n;i++)
  {
    for(ll j=1;j<=n;j++)
    {
      ll g=__gcd(i,j);
      for(ll k=1;k<=n;k++)
      {
        ll g1=__gcd(g,k);
        sum+=g1;
      }
    }
   	
  }
  cout<<sum;
  
  return 0;
}

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

int main()
{
	int x,y,z,Y,N;
	cin>>N>>Y;
	
	for(x=0;x<=Y/10000;x++)
	   for(y=0;y<=Y/5000;y++)
	   {
	   	   z=N-x-y;
		   if(z>=0 && x*10000+y*5000+z*1000==Y)
		   {
		   	   cout<<x<<" "<<y<<" "<<z;
		   	   return 0;
		   }
	   }
	   
	cout<<"-1 -1 -1";
	return 0;
}

Measured memory_bytes: 256
import collections
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


def factorize_all(n):
    factorizations = [None] * (n + 1)
    factorizations[0] = dict()
    factorizations[1] = dict()
    for p in range(2, n + 1):
        if factorizations[p] is None:
            for k in range(1, n // p + 1):
                if factorizations[k] is None:
                    continue
                fs = factorizations[k].copy()
                if p in fs:
                    fs[p] += 1
                else:
                    fs[p] = 1
                factorizations[k * p] = fs
    return factorizations


MOD = 10**9 + 7

n = ri()
ls = ril()
if n == 1:
    print(1)
    exit()

factorizations = factorize_all(max(ls))

lcm = collections.Counter()
for x in ls:
    counter = factorizations[x]
    for p, k in counter.items():
        lcm[p] = max(lcm[p], k)
lcm_val = 1
for p, k in lcm.items():
    lcm_val *= pow(p, k, MOD)
    lcm_val %= MOD

res = 0
for x in ls:
    res += lcm_val * pow(x, MOD - 2, MOD)
    res %= MOD
print(res)

Measured memory_bytes: 302856
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

all_combination = permutations(range(1, N + 1), N)
dict_order = {}
for i, c in enumerate(all_combination):
    dict_order[c] = i
print(abs(dict_order[P] - dict_order[Q]))

Measured memory_bytes: 10472
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use std::cmp::min;


#[fastout]
fn main() {
    input! {
    n: usize,
    b: [usize; n - 1]
    }
    let mut ans = 0;
    for i in 0..n {
        if i == 0 {
            ans += b[0]
        } else if i == n - 1 {
            ans += b[n - 2]
        } else {
            ans += min(b[i], b[i - 1])
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2204
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
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; }

int N;
int ans[100005];
int u[100005],v[100005],w[100005];
vector<pair<int,int>> P[100005];

void dfs(int cur,int fa){
    for (auto i:P[cur]) if (i.first != fa) {
        if (i.second%2 == 1) ans[i.first] = 3-ans[cur];
        else ans[i.first] = ans[cur];
        dfs(i.first, cur);
    }
}


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

    REPP(i,1,N+1) cin >> u[i] >> v[i] >> w[i];
    REPP(i,1,N+1) P[i].clear();//push_backしたいから
    REPP(i,1,N+1){
        P[u[i]].push_back({v[i],w[i]});
        P[v[i]].push_back({u[i],w[i]});
    }


    ans[1] = 1;
    dfs(1,-1);
    REPP(i,1,N+1) cout << ans[i]-1 << endl;
}

Measured memory_bytes: 10240
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  string s;
  cin >> s;
  string ans;
  if(s == "ABC") {
    ans = "ARC";
  }
  else {
    ans = "ABC";
  }
  cout << ans << endl;
  return 0;
}


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

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

int main() {
    int a, b;
    cin >> a >> b;

    string A = to_string(a);
    string B = to_string(b);
    rep(i, a - 1) B += to_string(b);
    rep(i, b - 1) A += to_string(a);

    cout << (A > B ? B : A) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_b(pair<int, long long> a, pair<int, long long> b) {
    if(a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

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

    cout << N * (N - 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n-1), b(n-1), c(n-1);
  vector<vector<int>> to(n), co(n);
  rep(i, n-1) {
    cin >> a[i] >> b[i];
    --a[i], --b[i];
    to[a[i]].push_back(b[i]);
    to[b[i]].push_back(a[i]);
    co[a[i]].push_back(i);
    co[b[i]].push_back(i);
  }
  queue<pair<int, int>> que;
  que.push({0, 0});
  while (!que.empty()) {
    int now, precol;
    tie(now, precol) = que.front();
    que.pop();
    int cnt = 1;
    if (cnt == precol)
      cnt++;
    rep(i, to[now].size()) {
      int next = to[now][i];
      if (!c[co[now][i]]) {
        c[co[now][i]] = cnt;
        que.push({next, cnt});
        cnt++;
        if (cnt == precol)
          cnt++;
      }
    }
  }
  int mx = 0;
  rep(i, n)
    chmax(mx, (int)to[i].size());
  cout << mx << endl;
  rep(i, n-1)
    cout << c[i] << endl;
  return 0;
}

Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    double pi = 3.141592653;
    ll r; cin >> r;
    cout << setprecision(10) << 2*r*pi << endl;
    return 0;
}

Measured memory_bytes: 3780