akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
struct Node{
    long long int data;
    struct Node* next;
    struct Node* prev;
};
struct Node* list;
struct Node* end;
void insertTop(long long int data){
    struct Node* newN = (struct Node*)malloc(sizeof(struct Node));
    newN->data = data;
    newN->prev = NULL;
    newN->next = NULL;
    if(list == NULL){
        list = newN;
        end = newN;
        return;
    }
    list->prev = newN;
    newN->next = list;
    list = newN;
}
void insertBottom(long long int data){
    struct Node* newN = (struct Node*)malloc(sizeof(struct Node));
    newN->data = data;
    newN->prev = NULL;
    newN->next = NULL;
    if(end == NULL){
        list = newN;
        end = newN;
        return;
    }
    end->next = newN;
    newN->prev = end;
    end = newN;
}
void deleteX(long long int x){
    struct Node* temp = list;
    struct Node* p;
    struct Node* n;
    while(temp != NULL){
        if(temp->data == x){
            //printf("found %lld\n", x);
            //printf("next %lld\n",temp->next->data);
            p = temp->prev;
            n = temp->next;
            if(p == NULL && n == NULL) {
                list = NULL; end=NULL;break;
            }
            if(p == NULL){
                list = temp->next;
                list->prev = NULL;
            }else p->next = n;
            if(n==NULL){
                end = end->prev;
                end->next = NULL;
            }else n->prev = p;
            break;
        }
        temp = temp->next;
    }
}
void deleteTop(){
    list = list->next;
    if(list == NULL){
        end = NULL;
    }else list->prev = NULL;
}
void deleteBottom(){
    end = end->prev;
    if(end == NULL){
        list = NULL;
    }else end->next = NULL;
}
void print(){
    struct Node* temp = list;
    while(temp != NULL){
        printf("%d", temp->data);
        temp = temp->next;
        if(temp == NULL)printf("\n");
        else printf(" ");
    }
}
void tnirp(){
    struct Node* temp = end;
    if(temp == NULL)return;
    while(temp!=NULL){
        printf("%d<-", temp->data);
        temp = temp->prev;
    }
    printf("\n");
}
int main(){
    list = NULL;
    struct Node* temp;
    char cmd[13];
    long long int n, x;
    scanf("%lld", &n);
    while(n--){
        scanf("%s", &cmd);
        if(strcmp(cmd, "deleteFirst")== 0){
            deleteTop();
        }else if(strcmp(cmd, "deleteLast") == 0){
            deleteBottom();
        }else if(strcmp(cmd, "insert") == 0){
            scanf("%lld", &x);
            insertTop(x);
        }else if(strcmp(cmd, "delete") == 0){
            scanf("%lld", &x);
            deleteX(x);
        }
    }
    print();

    return 0;
}



Measured memory_bytes: 36164
#include <stdio.h>

int main(void)
{
	int m,f,r;
	int cnt=0,i;
	int sum;
	char rank[100];
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		
		if(m==-1&&f==-1&&r==-1)break;
		
		sum=m+f;
		if(sum>=80)rank[cnt]='A';
		else if(sum>=65&&80>sum)rank[cnt]='B';
		else if(sum>=50&&65>sum)rank[cnt]='C';
		else if(sum>=30&&50>sum){
			rank[cnt]='D';
			if(r>=50)rank[cnt]='C';
		}
		if(sum<30||m==-1||f==-1)rank[cnt]='F';
		cnt++;
	}
	for(i=0;i<cnt;i++){
		printf("%c\n",rank[i]);
	}
	return 0;
}

/*
50?????????
80?????§A 65??\???B 50??\???C 30??\???D 30??????F
D???????????§50??\?????????C
???????¬??????§F

?¬????????????°???-1

m,f,r?????¨???-1??§??????
		if(m==-1;f==-1;r==-1) break;

*/

Measured memory_bytes: 600
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = sorted(LI(), reverse=True)
    b = 0
    c = 0
    for i in range(n):
        if i % 2 == 0:
            b += a[i]
        else:
            c += a[i]

    return b - c


print(main())




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

int main(){
    int N,c=0,ans=0;
    cin >>N;
    int A[110];
    for(int i=0;i<N;i++) cin >>A[i];

    for(int i=0;i<N;i++){
        for(int k=0;k<N;k++){
            if((A[i]-A[k])>0) c=A[i]-A[k];
            else c=-A[i]+A[k];
            if(ans<c)ans=c;
        }
    }  

    cout << ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc013.contest.atcoder.jp/tasks/agc013_b>
問題文============================================================
 N 頂点 M 辺の、連結な単純無向グラフが与えられます。
 頂点には 1 から N までの番号がついており、辺には 1 から M までの番号がついています。
 辺 i は、頂点 Ai と頂点 Bi を結んでいます。 次の条件を満たすパスを 1 つ見つけて、出力してください。
 
 2 個以上の頂点を通る
 同じ頂点を 2 度以上通らない
 パスの少なくとも一方の端点と直接辺で結ばれている頂点は、必ずパスに含まれる
 
 ただし、この問題の制約の下で、このようなパスが必ず存在することが証明できます。
 また、あり得る答えのうちどれを出力しても構いません。
 
=================================================================

解説=============================================================

 とりあえず、適当に一本のパスを見て
 その端点につながる頂点であって全体のパスに含まれるかどうかを判定する。
 もし、含まれない頂点があれば、それを新たな端点として再度判定を繰り返す
 
 そうすればいずれ、次頂点にいけなくなる => 次頂点がない or すでに次頂点がパス内部に含まれている
 
 ということになるため、ひたすら判定を繰り返せばいい
 
================================================================
*/

void solve(){
    ll N,M; cin >> N >> M;
    vector<ll> A(M),B(M);
    for(int i = 0; i < M;i++){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }
    vector<vector<ll>> G(N);
    for(int i = 0; i < M;i++){
        G[A[i]].push_back(B[i]); G[B[i]].push_back(A[i]);
    }
    vector<int> used(N,0);
    ll l = 0, r = G[0][0];
    used[l] = used[r] = 1;
    deque<ll> deq; deq.push_front(l); deq.push_back(r);
    while(true){
        bool f = true;
        for(auto v:G[l]){
            if(used[v]) continue;
            f = false; used[v] = 1;
            deq.push_front(v); l = v; break;
        }
        if(!f)continue;
        for(auto v:G[r]){
            if(used[v])continue;
            f = false; used[v] = 1;
            deq.push_back(v); r = v; break;
        }
        if(f) break;
    }
    vector<ll> ans(deq.begin(),deq.end());
    cout << ans.size() << endl;
    for(int i = 0; i < (int)ans.size();i++){
        cout << ans[i]+1 << " \n"[i == ans.size()-1];
    }
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve();
	return 0;
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
  	cin >> N;
  	int d[N];
  	int max=0;
  	for(int i=0;i<N;i++){
      cin >> d[i];
    }
  	int temp;
  	for(int i=0;i<N-1;i++){
      for(int j=0;j<N;j++){
        if(j==N-1) continue;
        if(d[j]<d[j+1]){
          temp = d[j];
          d[j] = d[j+1];
          d[j+1] = temp;
        }
      }
    }
/*  for(int i=0;i<N;i++){
    cout << d[i] << endl;
  }
  */
  	int under_mochi = d[0],count=1;
  	for(int i=1;i<N;i++){
      if(d[i] < under_mochi){
        count++;
        under_mochi = d[i];
      }
    }
  cout << count << endl;
  
}
  

Measured memory_bytes: 256
#include <cstdio>
#pragma warning(disable : 4996)
int H, W, T, a[1009][1009], dp[1009][1009];
int main() {
	while (scanf("%d%d%d", &H, &W, &T), H) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				scanf("%d", &a[i][j]);
			}
		}
		for (int i = 0; i <= H; i++) {
			for (int j = 0; j <= W; j++) {
				dp[i][j] = 0;
			}
		}
		dp[0][0] = T - 1;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				dp[i + 1][j] += (dp[i][j] - a[i][j] + 1) >> 1;
				dp[i][j + 1] += (dp[i][j] + a[i][j]) >> 1;
			}
		}
		int cx = 0, cy = 0;
		while (cx < H && cy < W) {
			if ((dp[cx][cy] ^ a[cx][cy]) & 1) cy++;
			else cx++;
			T >>= 1;
		}
		printf("%d %d\n", cx + 1, cy + 1);
	}
	return 0;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll h,w,n; cin>>h>>w>>n;
    cout << min((n+h-1)/h, (n+w-1)/w) << endl;
    return 0;
}

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

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s[8];
  for (int i = 0; i < 8; i++) {
    cin >> s[i];
  }
  cout << "90" << endl;
  for (int j = 0; j < 8; j++) {
    for (int i = 0; i < 8; i++) {
      cout << s[7 - i][j];
    }
    cout << endl;
  }
  cout << "180" << endl;
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      cout << s[7 - i][7 - j];
    }
    cout << endl;
  }
  cout << "270" << endl;
  for (int j = 0; j < 8; j++) {
    for (int i = 0; i < 8; i++) {
      cout << s[i][7 - j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3216
import math
import numpy as np
from collections import deque
def main():
    z = [int(t)for t in input().split()]
    n,m = z[0],z[1]

    if m==0:
        if n==1:
            print(0)
        else:
            print(10**(n-1))

        return

    sc = [[int(t)for t in input().split()] for _ in range(m)]
    sc = [(t[0]-1,t[1]) for t in sc]

    cond = set(sc)

    num = [-1]*n

    for s,c in cond:
        if num[s] == -1:
            num[s] = c
        else:
            print(-1)
            return
    
    if num[0] == 0 and n != 1:
        print(-1)
        return

    if num[0] == -1:
        num[0] = 1
    
    num = num[::-1]

    result = 0
    for i in range(n):
        result += 0 if num[i]==-1 else num[i]*10**i

    print(result)

if __name__ == "__main__":
    main()

Measured memory_bytes: 12492
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<iostream>

using namespace std;

int main(){
	int a, b;
	while(~scanf("%d %d", &a, &b)){
		cout << (a + b) % 24 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math
n=int(input())
xy=[]

for i in range(n):
  xy.append(list(map(int,input().split())))

sum=0
count=0
for i in range(len(xy)):
  for j in range(len(xy)):
    if i==j:
      continue
    sum+=math.sqrt((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)
  count+=1
print(sum/count)

Measured memory_bytes: 3064
N = int(input())
ans = 0

def AAA(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


B = len(AAA(N-1))-1


C = AAA(N)
for i in range(len(C)):
    nN = N
    if C[i] != 1:
        while nN % C[i] == 0:
            nN = nN / C[i]
        if nN % C[i] == 1:
            ans = ans + 1
            
print(B+ans)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<string> S(N);
    vector<long long> C(N);
    for (int i=0; i<N; i++)
        cin>>S[i]>>C[i];

    function<long long (int, int)> fL, fR;

    long long oo = 1000000000000000000LL;

    vector<vector<long long>> ML(N, vector<long long>(21, -1));
    fL = [&](int si, int l) -> long long
    {
        if (ML[si][l]>=0)
            return ML[si][l];
        if (ML[si][l]==-2)
            return oo;
        ML[si][l] = -2;

        bool ok = true;
        for (int i=0; i<l && ok; i++)
            if (S[si][S[si].size()-l+i]!=S[si][S[si].size()-i-1])
                ok = false;
        if (ok)
            return ML[si][l]=0;

        long long ans = oo;
        for (int i=0; i<N; i++)
        {
            bool ok = true;
            int t = min(l, (int)S[i].size());
            for (int j=0; j<t && ok; j++)
                if (S[si][S[si].size()-l+j]!=S[i][S[i].size()-j-1])
                    ok = false;
            if (ok)
            {
                long long a = 0;
                if (l<(int)S[i].size())
                    a = fR(i, S[i].size()-l);
                else
                    a = fL(si, l-S[i].size());
                ans = min(ans, a+C[i]);
            }
        }
        return ML[si][l] = ans;
    };

    vector<vector<long long>> MR(N, vector<long long>(21, -1));
    fR = [&](int si, int l) -> long long
    {
        if (MR[si][l]>=0)
            return MR[si][l];
        if (MR[si][l]==-2)
            return oo;
        MR[si][l] = -2;

        bool ok = true;
        for (int i=0; i<l && ok; i++)
            if (S[si][i]!=S[si][l-i-1])
                ok = false;
        if (ok)
            return MR[si][l]=0;

        long long ans = oo;
        for (int i=0; i<N; i++)
        {
            bool ok = true;
            int t = min((int)S[i].size(), l);
            for (int j=0; j<t && ok; j++)
                if (S[i][j]!=S[si][l-j-1])
                    ok = false;
            if (ok)
            {
                long long a = 0;
                if (l<(int)S[i].size())
                    a = fL(i, S[i].size()-l);
                else
                    a = fR(si, l-S[i].size());
                ans = min(ans, a+C[i]);
            }
        }
        return MR[si][l] = ans;
    };

    long long ans = oo;
    for (int i=0; i<N; i++)
        ans = min(ans, fL(i, (int)S[i].size())+C[i]);
    cout<<(ans<oo ? ans : -1)<<endl;
}


Measured memory_bytes: 3200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

	public static void main(String[] args) throws IOException
	{
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int a = Integer.parseInt(str.substring(0, str.indexOf(" ")));
		int b = Integer.parseInt(str.substring(str.indexOf(" ") + 1));
		String ab = "";
		if(a == b) ab = "==";
		else if(a > b) ab = ">";
		else ab = "<";
		System.out.println("a " + ab + " b");
	}

}



Measured memory_bytes: 24308
#include <iostream>
#include <cstdlib>
using namespace std;
 
#define MAX 100005
#define NIL -1
 
struct Node {
  int parent;
  int left;
  int right;
};
 
Node T[MAX];
int n, D[MAX];
 
void print(int u) {
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].parent << ", ";
  cout << "depth = " << D[u] << ", ";
 
  if ( T[u].parent == NIL ) cout << "root, ";
  else if ( T[u].left == NIL ) cout << "leaf, ";
  else cout << "internal node, ";
 
  cout << "[";
  for ( int i = 0, c = T[u].left; c != NIL; i++, c = T[c].right ) {
    if ( i ) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}
 
int rec(int u, int p) {
  D[u] = p;
  if ( T[u].right != NIL ) rec(T[u].right, p);
  if ( T[u].left != NIL ) rec(T[u].left, p + 1);
}
 
int main() {
  int d, v, c, l, r;
  cin >> n;
  for ( int i = 0; i < n; i++ ) T[i].parent = T[i].left = T[i].right = NIL;
 
  for ( int i = 0; i < n; i++ ) {
    cin >> v >> d;
    for ( int j = 0; j < d; j++ ) {
      cin >> c;
      if ( j == 0 ) T[v].left = c;
      else T[l].right = c;
      l = c;
      T[c].parent = v;
    }
}
    for ( int i = 0; i < n; i++ ) {
      if ( T[i].parent == NIL ) r = i;
  }
 
  rec(r, 0);
 
  for ( int i = 0; i < n; i++ ) print(i);
 
  return 0;
}

Measured memory_bytes: 7772
K,N = list(map(int , input().split()))
A = list(map(int , input().split()))
A.sort()
Q = []
for i in range(N-1):
    q = A[i+1]-A[i]
    Q.append(q)
p = K + A[0]- A[N-1]
Q.append(p)
Ans = K - max(Q)
print(Ans)


Measured memory_bytes: 26420
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int[] Aa = new int[3];
		for (int i = 0; i < 3; i++) {
			Aa[i] = scn.nextInt();
		}
		Arrays.sort(Aa);
		int A = Aa[0], B = Aa[1], C = Aa[2];
		int ans = 0;
		ans += (C - A) / 2;
		A += ((C - A) / 2) * 2;
		ans += (C - B) / 2;
		B += ((C - B) / 2) * 2;
		Aa[0] = A;
		Aa[1] = B;
		Aa[2] = C;
		Arrays.sort(Aa);
		for(int i = 2;i >= 0;i--) {
			Aa[i] -= Aa[0];
		}
		
		if(Aa[0] == Aa[1]) {
			if(Aa[2] != 0)ans++;
		}else {
			ans +=2;
		}
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 23124
#include <iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<stack>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
ll b[100010];
ll a[100010];
vector<ll>v[100010];
int main()
{
      ll n,m;
      cin>>n>>m;
       for(ll i=0;i<m;i++)
       {
           cin>>a[i]>>b[i];
           v[a[i]].push_back(b[i]);
       }
       for(ll i=1;i<=n;i++)
        sort(v[i].begin(),v[i].end());



    for(ll i=0;i<m;i++)
    {
        ll ans = lower_bound(v[a[i]].begin(),v[a[i]].end(),b[i]) - v[a[i]].begin();
        printf("%06lld%06lld\n",a[i],ans+1);
    }




    return 0;
}


Measured memory_bytes: 8576
#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
#include<cstdlib>
using namespace std;

bool isso(long long int a) {
	if (a == 1||a==0)return false;
	for (long long int i = 2; i*i <= a; ++i) {
		if ((a%i)) {
		}
		else {
			return false;
		}
	}
	return true;
}



long long int powint(long long int a, long long int b) {
	assert(b >= 0);
	if (b == 0)return 1;
	if (b == 1)return a;
	long long int ans = 1;
	long long int aa = powint(a, b / 2);
	ans *= aa*aa;
	if (b % 2)ans *= a;
	return ans;
}

struct edge {
	int from;
	int to;
	int cost;
};

struct aa {
	int now;
	int fuel;
	int cost;
};

class Compare {
public:
	//keiroが昇順に並ぶ
	bool operator()(const aa&l, const aa&r) {
		return l.cost> r.cost;
	}
};

vector<vector<int>>involve;


vector<int> dfs2(const int now, vector<bool>&used) {
	if (used[now])return vector<int>(0);
	else {
		used[now] = true;
	}
	vector<int>ans;
	for (auto i : involve[now]) {
		if (involve[i].size()) {
			vector<int>a(dfs2(i,used));
			ans.insert(ans.end(), a.begin(), a.end());
		}
		else {
			ans.push_back(i);
		}
	}
	return ans;
}


int main() {
	while (1) {
		int num = 0;
		map<string,int>mp;
		set<int>ed;
		int N; cin >> N;
		if (!N)break;
		involve.clear();
		involve.resize(1100);
		for (int i = 0; i < N; ++i) {
			string st; cin >> st;
			string groupname;
			vector<string> membername;
			int pre;
			for (int j = 0; j < st.size(); ++j) {
				if (st[j] == ':') {
					groupname = st.substr(0, j);
					pre = j;
				}
				else if (st[j] == ','||st[j]=='.') {
					membername.push_back(st.substr(pre + 1, j - pre - 1));
					pre = j;
				}
			}
			if (!mp.count(groupname)) {
				mp[groupname] = num++;
			}
			for (int i = 0; i < membername.size(); ++i) {
				if (!(mp.count(membername[i]))) {
					mp[membername[i]] = num++;
				}
			}
			for (int i = 0; i < membername.size(); ++i) {
				involve[mp[groupname]].push_back(mp[membername[i]]);
				ed.emplace(mp[membername[i]]);
			}
		}
		vector<bool>used(1100, false);
		vector<int>allnames(dfs2(0,used));
		sort(allnames.begin(), allnames.end());
		const int ans(unique(allnames.begin(), allnames.end()) - allnames.begin());
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 3284
mod = 10**9 + 7
n = int(input())
prime = {}

for x in range(1,n+1):
    m = x
    i = 2
    while i*i <= m:
        if m%i == 0:
            if i not in prime.keys():prime[i] = 0
            while m%i == 0:
                m = m//i
                prime[i] += 1
        i += 1
    if m != 1:
        if m not in prime.keys():prime[m] = 0
        prime[m] += 1
ans = 1
for q in prime.values():
    ans *= q + 1
    ans %= mod
print(ans)


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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    ll ans = 0;

    REP(i, 1, N+1)
    {
        if( i%3 != 0 && i%5 != 0 ) ans += i;
    }
    cout << ans << endl;

}


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

int main(){
    char x, y;
    cin >> x >> y;
    if(x > y) cout << '>' << endl;
    else if(x < y) cout << '<' << endl;
    else cout << '=' << endl;
    return 0;
}


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

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(auto &i:A)cin >> i;
	sort(A.begin(),A.end());
	for(int i=0;i+1<N;i++){
		if(A[i]==A[i+1]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

//Card Game
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int p1 = 0;
			int p2 = 0;
			while(n--!=0){
				int a = sc.nextInt();
				int b = sc.nextInt();
				if(a>b)p1+=a+b;
				else if(a<b)p2+=a+b;
				else {
					p1+=a;
					p2+=b;
				}
			}
			System.out.println(p1 + " " + p2);
		}
	}
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) (a).begin(),(a).end()

template<typename T1, typename T2> inline void chkmin(T1 & x, const T2 & y) {if (y < x) x = y;}
template<typename T1, typename T2> inline void chkmax(T1 & x, const T2 & y) {if (x < y) x = y;}

#define int ll

int getMod(string n, int mod) {
	if (mod <= 0) return -1;
	int ans = 0;
	int pow = 1;
	reverse(all(n));
	for (auto i : n) {
		ans += pow * (i - '0') % mod;
		ans %= mod;
		pow *= 2;
		pow %= mod;
	}
	return ans;
}

int binpow(int a, int n, int mod) {
	int ans = 1;
	while (n) {
		if (n & 1) {
			ans = ans * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}

int getCnt(string n) {
	int ans = 0;
	for (auto i : n) {
		ans += i == '1';
	}
	return ans;
}

int n;
string x;

void read() {
	cin >> n >> x;
}

int getAns(int have) {
	int ans = 0;
	while (have) {
		have %= __builtin_popcount(have);
		ans++;
	}
	return ans;
}

vector<int> ans;

void run() {
	int cnt = getCnt(x);
	//cout << "cnt = " << cnt << endl;
	int valAdd = getMod(x, cnt + 1);
	int valDel = getMod(x, cnt - 1);
	//cout << "valAdd = " << valAdd << endl;
	//cout << "valDel = " << valDel << endl; 
	for (int i = 0; i < n; i++) {
		if (x[i] == '0') {
			if (cnt == 0) {
				ans.push_back(1);
			} else {
				int fans = 1;
				//cout << "n - 1 - i = " << n - 1 - i << endl;
				//int val = binpow(2, n - 1 - i, cnt + 1);
				//cout << "val = " << val << endl;
				fans += getAns((valAdd + binpow(2, n - 1 - i, cnt + 1)) % (cnt + 1));
				ans.push_back(fans);
			}
		} else if (x[i] == '1') {
			if (cnt == 1) {
				ans.push_back(0);
			} else {
				int fans = 1;
				int val = (valDel - binpow(2, n - 1 - i, cnt - 1));
				val %= cnt - 1;
				val += cnt - 1;
				val %= cnt - 1;
				fans += getAns(val);
				ans.push_back(fans);
			}
		}
	}
}

void write() {
	for (auto i : ans) {
		cout << i << "\n";
	}
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 5648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s = "";
    bool ok = true;
    cin >> s;
    for(int i = 0; i < (int)s.size(); i++)
    {
        if(i%2 == 1 && s[i] == 'R') ok = false;
        if(i%2 == 0 && s[i] == 'L') ok = false;
    }
    cout << (ok?"Yes":"No") << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            String s = in.nextString();

            int cnt1 = count(n, s, ')');
            int cnt2 = count(n, new StringBuilder(s).reverse().toString(), '(');

            for (int i = 0; i < cnt1; i++) {
                s = "(" + s;
            }
            for (int i = 0; i < cnt2; i++) {
                s += ")";
            }

            out.println(s);
        }

        private int count(int n, String s, char c) {
            int cnt = 0;
            int sum = 0;
            for (int i = 0; i < n; i++) {
                if (s.charAt(i) == c) {
                    if (sum > 0) {
                        sum--;
                    } else {
                        cnt++;
                    }
                } else {
                    sum++;
                }
            }

            return cnt;
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 23380
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
struct C{P p;D r;};
C c[100];
D eps=1e-9,PI=acos(-1.0);
D cro(P a,P b){return imag(conj(a)*b);}
D verlen(L l,P p){return abs(cro(l.fs-l.sc,p-l.sc)/abs(l.fs-l.sc));}
int large(D a,D b){
	if(abs(a-b)<eps) return 0;
	if(a>b) return 1;
	return -1;
}
vector<L> tanCP(C c,P p){
	int x=large(c.r,abs(p-c.p));
	vector<L> ret;
	if(x==1) return ret;
	if(x==0){
		ret.pb(L(p,p+(c.p-p)*P(0,1)));
		return ret;
	}
	D theta=acos(c.r/abs(p-c.p));
	ret.pb(L(p,c.p+(p-c.p)/abs(p-c.p)*polar(c.r,theta)));
	ret.pb(L(p,c.p+(p-c.p)/abs(p-c.p)*polar(c.r,-theta)));
	return ret;
}
vector<L> intan(C a,C b){
	P p=(a.r*b.p+b.r*a.p)/(a.r+b.r);
	return tanCP(a,p);
}
vector<L> outtan(C a,C b){
	if(abs(a.r-b.r)<eps){
		vector<L> ret;
		P p=(a.p-b.p)/abs(a.p-b.p)*polar(a.r,PI/2);
		ret.pb(L(a.p+p,b.p+p));
		ret.pb(L(a.p-p,b.p-p));
		return ret;
	}
	P p=(a.r*b.p-b.r*a.p)/(a.r-b.r);
	return tanCP(a,p);
}
vector<L> tans(C a,C b){
	vector<L> ret=intan(a,b),tmp=outtan(a,b);
	for(L l:tmp) ret.pb(l);
	return ret;
}
int main(){
	while(true){
		int N;
		cin>>N;
		if(N==0) break;
		rep(i,N){
			int x,y,r,m;
			cin>>x>>y>>r>>m;
			c[i].p=P(x,y);
			c[i].r=r;
			c[N+i].p=P(x,y);
			c[N+i].r=r+m;
		}
		int ans=1;
		rep(i,2*N) rep(j,i){
			vector<L> ls=tans(c[i],c[j]);
			for(L l:ls){
				int cnt=0;
				rep(k,N){
					D d=verlen(l,c[k].p);
					if(c[k].r<d+eps&&d<c[N+k].r+eps) cnt++;
				}
				ans=max(ans,cnt);
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1276
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.nextLine();
		int k = sc.nextInt();
		
		boolean canDo = false;
		for (int i = 0; i < k; i++) {
			if (a >= b) {
				b = b*2;
				if (a < b && b < c) {
					canDo = true;
					break;
				}
			} else if (b >= c) {
				c = c*2;
				if (a < b && b < c) {
					canDo = true;
					break;
				}
			} else {
				canDo = true;
				break;
			}
		}
		String ans = canDo ? "Yes" : "No";
		System.out.println(ans);
	}
}


Measured memory_bytes: 35904
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;

int sum[510][510];
int N, M, Q;

int main() {
	cin >> N >> M >> Q;

	rep(i, 0, M) {
		int l, r;
		cin >> l >> r;
		sum[l][r]++;
	}

	rep(i, 1, 510) {
		rep(j, 1, 510) {
			sum[i][j] += sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1];
		}
	}


	rep(i, 0, Q) {
		int p, q;
		cin >> p >> q;
		cout << sum[q][q] - sum[p-1][q]-sum[q][p-1]+sum[p-1][p-1] << endl;
	}



	return 0;
}

Measured memory_bytes: 1920
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int  num = scanner.nextInt();//要素数
		int array[] = new int[num];
		
		for(int i = 0; i < num; i ++ ){
			array[i] = scanner.nextInt();
		}
		
		insertionSort(array, num);
		
		scanner.close();
	}

	public static int[] insertionSort( int[] array, int num){ // N個の要素を含む0-オリジンの配列A
		int sub;
		int comp = 0;
		int i;
		
		for(int cou = 0; cou < num; cou ++ ){
			System.out.print(array[cou]);
			if( cou == num - 1) {
			System.out.print("\n");
			}else {
				System.out.print(" ");
			}
		}
		
		for( i = 1; i <=  num - 1; i ++ ){
			sub = array[i];
			comp = i - 1;
			while( comp >= 0 && array[comp] > sub ){
				array[comp + 1] = array[comp];
				comp --;
			}
			array[comp + 1] = sub;
			
			for(int cou = 0; cou < num; cou ++ ){
				System.out.print(array[cou]);
				if( cou == num - 1) {
				System.out.print("\n");
				}else {
					System.out.print(" ");
				}
			}
		}
		return array;
	}
}


Measured memory_bytes: 33792
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=5e3+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
}
int n;
const int mo=1e9+7;
vector<int>E[N];
#define pb push_back
void input()
{
	int x,y;
	n=read<int>();
	For(i,2,n)
	{
		x=read<int>(),y=read<int>();
		E[x].pb(y),E[y].pb(x);
	}
}
int mc[N],dp[N][N],size[N],tmp[N];
void add(int &x,int y)
{
	x+=y;x-=(x>=mo?mo:0);
}
void DP(int u,int pre)
{
	size[u]=1;
	dp[u][1]=1;
	for(int v:E[u])if(v^pre)
	{
		DP(v,u);
		For(i,0,size[u]+size[v])tmp[i]=0;
		For(i,0,size[u])For(j,0,size[v])add(tmp[i+j],1ll*dp[u][i]*dp[v][j]%mo);
		For(i,0,size[u]+size[v])dp[u][i]=tmp[i];
		size[u]+=size[v];
	}
	For(i,1,size[u])add(dp[u][0],mo-1ll*dp[u][i]*mc[i]%mo);
}
void work()
{
	mc[0]=1;
	For(i,1,n)if(mc[i]%2==0)mc[i]=1ll*mc[i-2]*(i-1)%mo;
	DP(1,0);
	//cerr<<dp[1][0]<<endl;
	write((mo-dp[1][0])%mo,'\n');
}
int main()
{
//	file();
	input();
	work();
	return 0;
}


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

struct Card {char mark, value;};

void bubble(struct Card A[], int n){
    for (int i = 0; i < n; i++){
        for (int j = n-1; j > i; j--){
            if (A[j].value < A[j-1].value){
                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[], int n){
    for (int i = 0; i < n; i++){
        int minj = i;
        for (int j = i; j < n; j++){
            if (A[j].value < A[minj].value){
                minj = j;
            }
        }
        Card r = A[i]; A[i] = A[minj]; A[minj] = r;
    }
}

bool isStable(struct Card A[],struct Card B[], int n){
    for (int i = 0; i < n; i++){
        if (A[i].mark != B[i].mark) return false;
    }
    return true;
}

int main(){
    Card A[36], B[36];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> A[i].mark >> A[i].value;
        B[i] = A[i];
    }
    bubble(A,n);
    selection(B,n);
    for (int i = 0; i < n; i++){
        if (i == n-1) cout << A[i].mark << A[i].value << endl;
        else cout << A[i].mark << A[i].value << ' ';
    }
    cout << "Stable" << endl;
    for (int i = 0; i < n; i++){
        if (i == n-1) cout << B[i].mark << B[i].value << endl;
        else cout << B[i].mark << B[i].value << ' ';
    }
    if (isStable(A,B,n)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>

using namespace std;

int main() {
	int in = 0;
	int hour = 0;
	int minute = 0;
	int second = 0;

	cin >> in;

	hour = in / (60 * 60);
	minute = (in - hour*(60 * 60)) / 60;
	second = in - hour*(60 * 60) - minute * 60;

	cout << hour << ":" << minute << ":" << second << endl;

	return 0;
}


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

int main() {
  long long n;
  cin >> n;
  long long a[n];
  long long sum = 0, sum2 = 0;
  for ( long long i = 0; i < n; i++ ) {
    cin >> a[i];
    sum += a[i];
    a[i] *= 2;
    if ( i%2 == 1 ) { sum2 += a[i];  }
  }

  long long m[n];
  m[0] = sum - sum2;
  for ( long long i = 1; i < n; i++ ) { m[i] = a[i-1] - m[i-1]; }

  for ( long long i = 0; i < n-1; i++ ) {
    cout << m[i] << ' ';
  }
  cout << m[n-1] << endl;
  return 0;
}


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

ll inf =1e9+7;

#define pi 3.14159265358979323846L
bool isprime(ll a)
{
	
	ll cnt=0;	
	for(ll i=1;i*i<a;i++)
	{
		
	 	if(a%i==0)
	 	{
	 		cnt+=2;
		 }
		
		
	}
	
		if(cnt==2)
		return true;
		else
		return false;
		
}
ll mod(ll a)
{
	if(a<inf)return a;
	else
	return a%inf;
}
void solve()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	
	long double x,y;
	x=ceil(c/b);
	if(c%b!=0)
	x++;
	y=ceil(a/d);
	if(a%d!=0)
	y++;
//	cout<<x<<" "<<y<<" ";
	if(x<=y)
	{
		cout<<"Yes";
	}
	else
	cout<<"No";
}
int main()
{


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

		solve();
	
return 0;

		
	}
	
	
	


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

int main(void) {
    int n, a[100];
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    // bubble sort
    int end_flag = 0, swap_num = 0;
    for(int j=0;!end_flag;j++){
        end_flag = 1;
        for(int i=n-1;i>j;i--){
            end_flag = 0;
            if(a[i] < a[i - 1]){
                swap(a[i], a[i - 1]);
                swap_num++;
            }
        }
    }
    // disp result
    for(int i = 0; i < n; i++){
        if(i) cout << ' ';
        cout << a[i];
    }
    cout << endl;
    cout << swap_num << endl;
    return 0;
}



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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll N,M;
ll dp[2][3001][2];

int main(){
  cin>>N>>M;
  N--;M--;
  ll crt=0,nxt=1;
  rep(i,N+1){
    if(i==0)dp[crt][i][1]=1;
    else dp[crt][i][0]=1;
  }
  rep(i,M){
    memset(dp[nxt],0,sizeof(dp[nxt]));
    rep(j,N+1)rep(k,2){
      (dp[nxt][j][k]+=dp[crt][j][k]*2%mod)%=mod;
      if(j+1<=N)(dp[nxt][j+1][k]+=dp[crt][j][k])%=mod;
      if(j>0)(dp[nxt][j-1][(k==1)||(j-1==0)]+=dp[crt][j][k])%=mod;
    }
    swap(crt,nxt);
  }
  ll res=0;
  rep(i,N+1)(res+=dp[crt][i][1])%=mod;
  cout<<res*4%mod<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

char X[222222];

int main(void) {
	int i;
	int mareitaso = 0, kugyu = 0;
	if (scanf("%222221s", X) != 1) return 1;
	for (i = 0; X[i] != '\0'; i++) {
		if (X[i] == 'T') {
			if (kugyu > 0) kugyu--; else mareitaso++;
		} else {
			kugyu++;
		}
	}
	printf("%d\n", mareitaso + kugyu);
	return 0;
}


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

int main(){

	long long n;
	cin >> n;
	vector<pair<long long, long long>>p;
	for (int i = 1; i <= sqrt(n); i++)
		if (n%i == 0)
			p.push_back(make_pair(i, n / i));

	long long ans = 1000000000000;
	for (int i = 0; i < p.size(); i++){
		ans = min(ans, p[i].first + p[i].second - 2);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
//******* It's LEVI_17 ***************

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

#define ff first
#define ss second
#define MP make_pair
#define mset(x,a) memset(x,a,sizeof(x))
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define sqr(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define f1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define vvll vector<vector<ll>>  
#define vll vector<ll> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define cases ll t;cin >> t;while(t--)
#define rr return 0
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define deb(a)			std::cerr<<#a<<"="<<(a)<<"\n"
#define deb2(a,b)		std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define deb3(a,b,c)		std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
const int MOD = 1000 * 1000 * 1000 + 7;

//syntax for priority queue
// max queue -> priority_queue<ll>
// min queue -> priority_queue<ll,vector<ll>,greater<ll>>

//##############################################################################################

double getRes(double arr[],ll n)
{
    double dp[n + 1][n + 1];
    memset(dp, 0, sizeof(dp));
    // dp[i][j] represents probability of getting [j] heads on i coins toses.

    dp[0][0] = 1;
    for (ll i = 1; i <= n; i++)
        dp[0][i] = 0;
    for (ll i = 1; i <= n; i++)
        dp[i][0] = (1.0 - arr[i - 1]) * dp[i - 1][0];

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= n; j++)
        {
            dp[i][j] = arr[i-1] * dp[i - 1][j - 1] + (1.0 - arr[i-1]) * dp[i - 1][j];
        }
    }
    double sum = 0;
    for (ll i = n/2+1; i <= n; i++)
    {
        sum += dp[n][i];
    }

    return sum;
}

void solve()
{
    ll n;
    cin >> n;
    double arr[n];
    f(i, n)
        cin >> arr[i];

    double res = getRes(arr, n);

    printf("%0.10lf\n", res);
}

//###############################################################################################

int main()
{
    fast;
    ll t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    rr;
}


//Watashi wa tsuyoku modotte kimasu

Measured memory_bytes: 74136
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;



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

    Int n, a, b;
    vector<pair<Int, Int>> pair;
    cin >> n;
    for(Int i=0; i<n; i++){
        cin >> a >> b;
        pair.push_back(make_pair(b, a));
    }
    sort(pair.begin(), pair.end());
    Int time = 0;
    for(auto p : pair){
        time += p.second;
        if(time > p.first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 6000
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
//map<key,value>

int main(){
  int a,b,c;;
  cin >> a >> b >> c;
  if(a==b && b==c && c== a)cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
#include <stdio.h> 

int main(void){
    int n,i,max=-1000000,min=1000000;
	long long sum=0;
	int a[10000];
	scanf("%d\n",&n);
	a[n-1]=0;
	
	for(i=0;i<n;i++){
	scanf("%d",&a[i]);
		if(max<a[i]){
		max=a[i];
		}
		if(min>a[i]){
		min=a[i];
		}
		sum+=a[i];	
	}
	
	printf("%d %d %lld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2112
#include <stdio.h>
#include <math.h>
 
#define PI 3.141592653589793238462643383279
 
#define EARTH_HANKEI 6378.1
 
int main(void) {
    double a,b,c,d;
    double ax1,ay1,ax2,ay2;
    double x1,y1,z1,x2,y2,z2;
    double cosine;
    double result;
    while(1) {
        scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
        if(a==-1 && b==-1 && c==-1 && d==-1)break;
        ax1=b*PI/180;
		ay1=a*PI/180;
        ax2=d*PI/180;
		ay2=c*PI/180;
        y1=cos(ay1);
		z1=sin(ay1);
        x1=y1*sin(ax1);
		y1=y1*cos(ax1);
        y2=cos(ay2);
		z2=sin(ay2);
        x2=y2*sin(ax2);
		y2=y2*cos(ax2);
        cosine=x1*x2+y1*y2+z1*z2;
        result=EARTH_HANKEI*acos(cosine);
        printf("%d\n",(int)floor(result+0.5));
    }
    return 0;
}

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

ll b[500][500];
char s[510][510];
ll sum[510][510];
int r[500][500];

ll S(int x1, int y1, int x2, int y2) {
	return sum[y2 + 1][x2 + 1] - sum[y2 + 1][x1] - sum[y1][x2 + 1] + sum[y1][x1];
}

int main() {
	int H, W;
	while(scanf("%d%d", &H, &W), H + W) {
		for(int i = 0; i < H; i++) {
			scanf("%s", s[i]);
			for(int j = 0; j < W; j++) {
				if(s[i][j] == '*') b[i][j] = 1;
				else b[i][j] = 0;
			}
		}
		memset(sum, 0, sizeof sum);
		memset(r, 0, sizeof r);
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				sum[i + 1][j + 1] = sum[i + 1][j] + b[i][j];
			}
		}
		for(int i = 1; i <= H; i++) {
			for(int j = 1; j <= W; j++) {
				sum[i + 1][j] += sum[i][j];
			}
		}
		for(int i = 0; i < H; i++) {
			for(int j = W - 1; j >= 0; j--) {
				r[i][j] = r[i][j + 1];
				if(s[i][j] == '*') r[i][j] = 0;
				else r[i][j]++;
			}
		}

		int ans = 0;
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				int w = r[i][j];
				for(int k = i; k < H; k++) {
					w = min(w, r[k][j]);
					ans = max(ans, (k - i + 1) * w);
				}
			}
		}
		printf("%d\n", ans);
	}
}

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

using namespace std;

int main()
{
	string S;
	cin >> S;
	if (S == "Sunny")
	{
		cout << "Cloudy" << endl;
	}
	else if (S == "Cloudy")
	{
		cout << "Rainy" << endl;
	}
	else
	{
		cout << "Sunny" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int A,B;
  cin>>A>>B;
  if(A==B) cout<<A+B;
  else cout<<2*max(A,B)-1;
return 0;}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
int inf=100000000;
const double PI = 3.14159265358979323846;
int main(){
  int m;
  cin >> m;
  int n;
  cin >> n;
  int k=2;
  rep(i,m)k*=2;
  int ans[k];
  if(n>k/2-1||(m==1&&n==1)){
    cout << -1 << endl;
    return 0;
  }
  if(m==1&&n==0){
    cout << 0 << " " << 0  << " " << 1 << " " << 1 << endl;
    return 0;
  }
  rep(i,k){
    if(i<k/2){
      if(i==n)ans[k/2-1]=n;
      else{
      if(i<n)ans[i]=i;
      else ans[i-1]=i;
      }
    }
    else{
      if(i-k/2==n)ans[k-1]=i-k/2;
      else{
        if(i-k/2>n)ans[k-1-(i-k/2)]=i-k/2;
        else ans[k-2-(i-k/2)]=i-k/2;
      }
    }
  }
  rep(i,k-1)cout << ans[i] << " ";
  cout << ans[k-1] << endl;
}  


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	int ans=0;
	cin >>s;
	bool could=true;
	int atb=0;
	int ate=s.size()-1;
	int c=0;
	for(;atb <ate;){

		if(s[atb]==s[ate]){
			atb++;
			ate--;
		}else{
			if(s[atb]=='x' or s[ate]=='x'){
				if (s[atb] == 'x' and atb < s.size() - 1)
				{
					atb++;
					c++;
				}
				if (s[ate] == 'x' and ate > 0)
				{
					ate--;
					c++;
				}
			}else{
			could=false;
			atb=ate;
		}}
	}
//	cout<<c<<endl;
	if(could){
		ans=c;
		cout<<ans<<endl;
	}else{
		cout << "-1"<< endl;
	}

}

Measured memory_bytes: 512