akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
 
//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;
 
//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;
 
//use std::cmp::*;
 
fn main() {
    input! {
        n: usize,
        s: Chars,
    }
 
    //let r = s.iter().filter(|&&x| x == 'r').count();
    //let g = s.iter().filter(|&&x| x == 'g').count();
    //let cb = s.iter().filter(|&&x| x == 'b').count();
    let mut r = vec![0u64; n];
    let mut g = vec![0u64; n];
    let mut b = vec![0u64; n];
 
    for i in 1..n {
        r[i] = r[i - 1];
        g[i] = g[i - 1];
        b[i] = b[i - 1];
        if s[i] == 'R' {
            r[i] += 1;
        }
        if s[i] == 'G' {
            g[i] += 1;
        }
        if s[i] == 'B' {
            b[i] += 1;
        }
    }
    //println!("{:?}", r);
    //println!("{:?}", g);
    //println!("{:?}", b);
    let mut ans = 0;
 
    for i in 0..n - 2 {
        let ca = s[i];
        for j in i + 1..n - 1 {
            let cb = s[j];
            if ca == cb {
                continue;
            }
            match (ca, cb) {
                ('R', 'G') | ('G', 'R') => {
                    ans += b[n - 1] - b[j];
                    if 2 * j - i > 0 && 2 * j - i < n {
                        if s[2 * j - i] == 'B' {
                            ans -= 1;
                        }
                    }
                }
                ('G', 'B') | ('B', 'G') => {
                    ans += r[n - 1] - r[j];
                    if 2 * j - i > 0 && 2 * j - i < n {
                        if s[2 * j - i] == 'R' {
                            ans -= 1;
                        }
                    }
                }
                ('B', 'R') | ('R', 'B') => {
                    ans += g[n - 1] - g[j];
                    if 2 * j - i > 0 && 2 * j - i < n {
                        if s[2 * j - i] == 'G' {
                            ans -= 1;
                        }
                    }
                }
                _ => unreachable!(),
            }
        }
    }
 
    println!("{}", ans);
}

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

//	vector
struct theSieveOfEratosThenes {
	vector<bool> prm;

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

	bool isPrime(int a) {
		return prm[a];
	}
};

int main() {
	int n;
	theSieveOfEratosThenes tsoet(104730);
	while (cin >> n, n != 0) {
		int sum = 0, ans = 0;
		for (int i = 0; n != sum; ++i) {
			if (tsoet.isPrime(i)) {
				++sum;
				ans += i;
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 2976
#include "bits/stdc++.h"
using namespace std;

const int MOD = 1000000007;
const int abmax = 2020;

long long Inv(long long a) {
        long long res = 1;
        long long n = MOD - 2;
        while (n > 0) {
                if (n & 1) res = res * a % MOD;
                a = a * a % MOD;
                n >>= 1;
        }
        return res;
}

const int N = 8080;
long long fact[N];
long long invfact[N];
void init() {
        fact[0] = 1;
        for (int i = 1; i < N; i ++) fact[i] = (fact[i - 1] * i) % MOD;
        invfact[N - 1] = Inv(fact[N - 1]);
        for (int i = N - 2; i >= 0; i --) invfact[i] = (invfact[i + 1] * (i + 1)) % MOD;
}
long long C(long long n, long long r) {
        if (n < 0 || r < 0 || n < r) return 0;
        return fact[n] * invfact[n - r] % MOD * invfact[r] % MOD;
}

long long dp[4040][4040];
long long num[4040][4040];

int main() {
        init();
        int n;
        scanf("%d", &n);
        vector<int> a(n), b(n);
        for (int i = 0; i < n; i ++) scanf("%d%d", &a[i], &b[i]);
        for (int i = 0; i < n; i ++) { 
                dp[abmax - a[i]][abmax - b[i]] ++;
                num[abmax + a[i]][abmax + b[i]] ++;
        }
        long long ans = 0;
        for (int i = 0; i < abmax * 2 - 1; i ++) {
                for (int j = 0; j < abmax * 2 - 1; j ++) {
                        if (num[i][j] > 0) (ans += num[i][j] * dp[i][j]) %= MOD;
                        (dp[i + 1][j] += dp[i][j]) %= MOD;
                        (dp[i][j + 1] += dp[i][j]) %= MOD;
                }
        }
        for (int i = 0; i < n; i ++) { 
                ans -= C(2 * (a[i] + b[i]), 2 * a[i]) % MOD;
                ans %= MOD;
                ans += MOD;
                ans %= MOD;
        }
        printf("%lld\n", (ans * Inv(2)) % MOD);
        return 0;
}



Measured memory_bytes: 193536
#include <bits/stdc++.h>
using namespace std;
const long long int mod=1e9+7;
long long int dp[100005][13];
int main(){
  string S;
  cin >> S;
  if(S[0]!='?')dp[0][(S[0]-'0')]++;
  else for(int k=0;k<10;k++)dp[0][k]++;
  for(int i=1;i<S.length();i++){
    for(int j=0;j<13;j++){
      if(S[i]!='?'){
        dp[i][((j*10)%13+(S[i]-'0')%13)%13]+=dp[i-1][j];
        dp[i][((j*10)%13+(S[i]-'0')%13)%13]%=mod;
      }
      else{
        for(int k=0;k<10;k++){
          dp[i][((j*10)%13+k%13)%13]+=dp[i-1][j];
          dp[i][((j*10)%13+k%13)%13]%=mod;
        }
      }
    }
  }
  cout << dp[S.length()-1][5] << endl;
}

Measured memory_bytes: 10624
#include <stdio.h>
void trace(int A[], int N){
    for (int i = 0; i < N; i++){
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

/* 選択ソート */
int selectionSort(int A[], int N){
    int i, j, min_index, temp, count;
    count = 0;
    for (i = 0; i < N; i++){
        min_index = i;
        for (j = i; j < N; j++){
            if (A[j] < A[min_index]){
                min_index = j;
            }
        }
        if (min_index != i){
            temp = A[i];
            A[i] = A[min_index];
            A[min_index] = temp;
            count += 1;
        }
    }
    return count;
}

int main() {
    int N, i, count;
    int A[100];
    
    scanf("%d", &N);
    for (i = 0; i < N; i++) scanf("%d", &A[i]);
    count = selectionSort(A, N);
    trace(A, N);
    printf("%d\n", count);

    return 0;
}



Measured memory_bytes: 2732
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  int a[N];
  int sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  cout << sum-N << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
D = 0
for A in L:
  if A % 2 == 0:
    if A % 3 == 0 or A % 5 == 0:
      continue
    else:
      print("DENIED")
      D = 1
      break
  else:
    continue
if D != 1:
  print("APPROVED")

Measured memory_bytes: 2940
s = input()
k1 = len(s) - 1
k2 = 0
for i in range(len(s)):
    if s[i] == 'C' and i < k1:
        k1 = i
    if s[i] == 'F':
        k2 = i
if k2 - k1 > 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3192
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
char s[5]; 
int main(){
	scanf("%s",s+1);
	if(s[1]==s[2]&&s[2]==s[3]){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
  ans += B[A[i]-1]
  if i < N - 1 and A[i] == A[i+1]-1:
    ans += C[A[i]-1]

print(ans)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0;char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
int n,sum[200001],s[200001],h[200001],cnt;
inline void add(int x,int y){
	while(x<=n)sum[x]+=y,x+=x&-x;
}
inline int query(int x){
	int res=0;
	while(x)res+=sum[x],x-=x&-x;
	return res;
}
int main(void){
	register int i,mid,l,r;
	n=read();
	for(i=1;i<=n;++i)s[i]=h[i]=read();
	sort(h+1,h+n+1),cnt=unique(h+1,h+n+1)-h-1;
	for(i=1;i<=n;++i)s[i]=lower_bound(h+1,h+cnt+1,s[i])-h,add(s[i],1);
	for(i=1;i<=n;++i){
		add(s[i],-1);
		l=1,r=cnt;
		while(l<=r){
			mid=l+r>>1;
			if(query(mid)<(n>>1))l=mid+1;
			else r=mid-1;
		}
		printf("%d\n",h[l]);
		add(s[i],1);
	}
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <assert.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <climits>
#include <stack>
#include <unordered_map>
using namespace std;

bool arm_sort(pair<int64_t, int64_t>& lhs, pair<int64_t, int64_t>& rhs) {
  if (lhs.first != rhs.first) return lhs.first < rhs.first;
  else return lhs.second > rhs.second;
}

int main(){
    int32_t N;
    std::cin >> N;
    if (N == 1) {
      cout << 1 << endl;
      return 0;
    }
    vector<pair<int64_t, int64_t>> arms;
    for (int i = 0; i < N; i++) {
      int64_t x, l;
      cin >> x >> l;
      arms.emplace_back(x - l, x);
      arms.emplace_back(x + l, x);
    }

    sort(arms.begin(), arms.end());
    int64_t num_robo = 0;
    stack<int64_t> left_robo;
    //vector<int> state(N, 0);
    unordered_map<int64_t, int> state;
    for (auto arm : arms) {
      int id = arm.second;
      if (state.count(id) == 0) {
        //new left
        state[id] = 1;
        left_robo.push(id);
      } else {
        //right
        if (state[id] == 2) {
          //invalidated
          ;
        } else {
          num_robo++;
          while (!left_robo.empty()) {
            int inv_id = left_robo.top();
            left_robo.pop();
            state[inv_id] = 2;
          }
        }
      }
    }
    cout << num_robo << endl;

                   
    return 0;
}


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

int main() {
	map<int, int> mp;
	for (int i = 0; i < 4; i++) {
		int n;
		cin >> n;
		mp[n]++;
	}
	cout << (mp[1] && mp[9] && mp[7] && mp[4] ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 3604
import math

N, A, B = map(int, raw_input().split())
h = [int(raw_input()) for _ in xrange(N)]


def judge(K):
    sums = 0
    for i in h:
        t = i-K*B
        if t > 0:
            sums += math.ceil(t*1.0/(A-B))
            if sums > K:
                return False;
    return True


high = int(1e9)
low = 0

while low < high:
    mid = int((high + low) / 2)
    if judge(mid):
        high = mid;
    else:
        low = mid+1;

print low

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

using namespace std;

int factor (int n) {
  int res = 0;
  int d = 2;
  while (d * d <= n) {
    if (n % d == 0)
    {
      if (d == 2) ++res;
      n /= d;
    }
    else break;
  }
  if (n == 2) ++res;
  return res;
}

int main()
{
  int n; cin >> n;
  vector <int> two(3, 0);
  for (int i = 0; i < n; ++i) {
    int k; cin >> k;
    if (factor(k) == 0) ++two[0];
    else if (factor(k) == 1) ++two[1];
    else if (factor(k) >= 2) ++two[2];
  }
  if (two[2] >= two[0] || (two[1] == 0 && two[2] >= two[0] - 1)) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
import math
a, b = map(int, input().split())

for i in range(1,10 ** 6):
    asub = math.floor(i * 0.08)
    bsub = math.floor(i * 0.1)
    if asub == a and bsub == b:
        print(i)
        exit()

print("-1")

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

int main(){
	string s; cin >> s;
	bool flag = true;
	for(int i = 0; i < s.size(); ++i){
		if(i % 2 == 0){
			if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D') flag = true;
			else{
				puts("No");
				return 0;
			}
		}
		else{
			if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D') flag = true;
			else {
				puts("No");
				return 0;
			}
		}
	}
	if(flag) puts("Yes");
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;

    set<int> s;
    s.insert(0);
    auto it = s.begin();
    while(it != s.end()) {
        int val1 = (*it) + a * 100;
        int val2 = (*it) + b * 100;
        if (val1 <= f) s.insert(val1);
        if (val2 <= f) s.insert(val2);
        it++;
    }
    
    ll ans = 0, ansa = 0, ansb = 0;
    for (auto w: s) {
        vector<int> dp(f + 1, -1);
        dp[w] = 0;
        for (int cw = w; cw <= f; cw++) {
            // cout << w << " " << cw - c << " " << dp[cw - c] << endl;
            if (cw - c >= 0 and dp[cw - c] >= 0) {
                dp[cw] = dp[cw - c] + c;
                // cout << cw << " " << dp[cw] << endl;
            }
            // cw += c;
        }
        for (int dw = w; dw <= f; dw++) {
            if (dw - d >= 0 and dp[dw - d] >= 0) {
                dp[dw] = dp[dw - d] + d;
                // cout << dw << " " << dp[dw] << endl;
            }
            // dw += d;
        }
        rep(i, f + 1) {
            // cout << i << " " << dp[i] << endl;
            double x = (double)dp[i] * 100.0 / (double)(i - dp[i]);
            // if (dp[i] >= 0) { 
            //     cout << i << " " << dp[i] << " " << x << " " << e << endl;
            // }
            if (x > ans and x <= e) {
                ans = x;
                ansa = i;
                ansb = dp[i];
            }
        }
    }

    if (ansa == 0) {
        cout << 100 * a << " " << 0 << endl;
    } else {
        cout << ansa << " " << ansb << endl;
    }

    return 0;
}


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

string str[1000000];

int main()
{
	int n;
	ll count=0;
	ll tmp=1;
	scanf("%d",&n);
	
	for(int i=0;i<n;i++)
	{
		cin >> str[i];
		sort(str[i].begin(),str[i].end());
	}
	sort(str,str+n);
/*	for(int i=0;i<n;i++)
	{
		cout << str[i];
		printf("\n");
	}*/
	
	for(int i=1;i<n;i++)
	{
		if(str[i]==str[i-1])
		{
		tmp++;
		}
		else
		{
			count+=tmp*(tmp-1)/2;
			
			tmp=1;
		}
	}
	if(tmp!=0)
	{
		//printf("test tmp=%d\n",tmp);
		count+=tmp*(tmp-1)/2;
	}
	
	printf("%lld",count);

	

}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
long long n,a,b,l,r,i,j,k,mod=round(1e9)+7,c[1001][1001],g[1001][1001],f[1001][1001];
long long lt(long long a,long long b)
{
    if(b==0) return 1;
    long long tg=lt(a,b/2);
    if(b%2==0) return tg*tg%mod;
    return tg*tg%mod*a%mod;
}
int main()
{
    //freopen("ntu.inp","r",stdin);
    //freopen("ntu.out","w",stdout);
    cin>>n>>a>>b>>l>>r;
    for(i=0;i<=n;i++)
        for(j=i;j<=n;j++)
            if(i==0) c[i][j]=1; else c[i][j]=(c[i][j-1]+c[i-1][j-1])%mod;
    for(j=1;j<=n;j++)
    {
        g[0][j]=1;
        for(i=1;i<=n/j;i++) g[i][j]=g[i-1][j]*c[j][i*j]%mod*lt(i,mod-2)%mod;
    }
    for(j=a-1;j<=b;j++) f[0][j]=1;
    for(i=1;i<=n;i++)
        for(j=a;j<=b;j++)
        {
            f[i][j]=f[i][j-1];
            for(k=l;k<=min(r,i/j);k++)
                if(i-j*k>=0) f[i][j]=(f[i][j]+f[i-j*k][j-1]*g[k][j]%mod*c[j*k][i])%mod;
            //cerr<<i<<" "<<j<<" "<<f[i][j]<<'\n';
        }
    cout<<f[n][b];
}


Measured memory_bytes: 23296
#include<stdio.h>

int main(){
  int n,x,count;
  int i,j,k;

  while(1){
    scanf("%d %d", &n, &x);
    count = 0;
    if(n==0 && x==0){
      break;
    }
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
        if(i+j>=x){
          break;
        }
        for(k=j+1;k<=n;k++){
          if(i+j+k==x){
            count++;
            break;
          }
        }
      }
    }
    printf("%d\n",count);
  }

  return 0;
}



Measured memory_bytes: 2100
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;
typedef pair<ll,int> P;

int calculate(int x){

}


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

  vector<int>oks(n+1,true);
  for(int i=0;i<m;i++){
    int temp;
    cin>>temp;
    oks[temp]=false;
  }

  vector<ll>dp(n+1);

  dp[0]=1;

  for(int now=0;now<n;now++){
    for(int next=now+1;next<=min(n,now+2);next++){
      if(oks[next]){
        dp[next]+=dp[now];
        dp[next]%=1000000007;
      }
    }
  }
  cout<<dp[n]<<endl;
}


Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll A; cin >> A;
    double B; cin >> B;
    B *= 100;
    ll b = B+0.1;
    cout << A*b/100 << ln;
}


Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		int[] ans=new int[2<<s[0]];
		
		int p=0;
		for(int i=1;i<=(1<<s[0])-1;i++) {
			if(i==s[1]){continue;}
			p^=i;
		}
		
		if(s[1]==0){
			for(int i = 0;i<(2<<s[0]);i+=2) {
				ans[i]=i>>1;
				ans[i+1]=i>>1;
			}
			Console.WriteLine(String.Join(" ",ans));
		}
		else if(s[1]==p){
			int i=0,j=0;
			for(;i<(1<<s[0])-1;i++,j++) {
				if(j==s[1]){j++;}
				ans[i]=j;
				
			}
			ans[i]=s[1];j--;i++;
			for(;i<(2<<s[0]);i++,j--) {
				if(j==s[1]){j--;}
				ans[i]=j;
			}
			ans[(2<<s[0])-1]=s[1];
			Console.WriteLine(String.Join(" ",ans));
		}
		else{Console.WriteLine("{0}",-1);}
	}
}

public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public string[] Sa2{get{return ("# "+Console.ReadLine()).Split();}}
}

Measured memory_bytes: 27224
#include <iostream>

using namespace std;


int main() {

        int A[100];

        int N, D, X;

        cin >> N >> D >> X;

        for ( int i = 0; i < N; ++i) cin >> A[i];


        int c = 0;

        for ( int i = 0; i < N; ++i) {

                c += (D - 1) / A[i];

                }

        cout << c + N + X << endl;

}

Measured memory_bytes: 256
S = str(input())
T = str(input())

lS = len(S)
lT = len(T)
q = 0

for i in range(0,lS-lT+1):
    p = 0
    for j in range(0, lT):
        if S[i+j] == T[j]:
            p += 1
    q = max(q, p)
ans = lT-q
print(ans)

Measured memory_bytes: 9068
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
ll Xor(ll a){
	if(a%4==0)return a;
	if(a%4==1)return 1;
	if(a%4==2)return a+1;
	else return 0;
}
int main() {
	int n;cin>>n;
	ll Xo;
	loop(n,i,0){
		int x;cin>>x;
		if(!i)Xo=x;
		else Xo^=x;
	}
	cout<<(!Xo?"Yes":"No");
}


Measured memory_bytes: 256
n = int(input())
k = int(input())
x = list(map(int, input().split()))
ans = 0
for i in range(n):
    tmp1 = 2 * x[i]
    tmp2 = int((((k-x[i])**2)**0.5)//1 * 2)
    if tmp1 < tmp2:
        ans += tmp1
    else:
        ans += tmp2
print(ans)


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

using namespace std;

int main() {
    int n; cin >> n;
    long long res = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) res += i;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 3632
<?php
//ワーシャルフロイド（全点対最短路問題）
//スタート地点１つに対してゴールが２つ。流れるものは水
//故に、単純に $cost[$s][$g1] + $cost[$s][$g2] とするとWA
//スタート〜ある点までは合流道。ある点〜それぞれのゴールまでは二股に分かれて進むイメージ
//また、有向グラフ（一方通行）なので注意。
//と言ってもむしろ$cost[$b][$a] = $cost[$a][$b]というコピーが不要になるので楽。


$file_handle = fopen('php://stdin', "r");
//$file_handle = fopen('aoj2005_in.txt', "r");


function warshall_floyd($cost) {
	global $n;

	for ($i = 1; $i <= $n; ++$i) {
	    for ($j = 1; $j <= $n; ++$j) {
	        for ($k = 1; $k <= $n; ++$k) {
	        	//INFだったらスルー。これで劇的に早くなる。
	        	if ($cost[$j][$i]===INF || $cost[$i][$k]===INF) continue;
	            // j -> kへ行くのにiを経由した方が良いかどうか(cost)
	            $via = $cost[$j][$i] + $cost[$i][$k];
	            if ($via < $cost[$j][$k]) {
	                $cost[$j][$k] = $via;
	            }
	        }
	    }
	}
	return $cost;
}


while(1){
	//ファイル読み込み
	$info = trim(fgets($file_handle));
	$explode = explode(' ', $info);
	$n = $explode[0]; $m = $explode[1]; $s = $explode[2]; $g1 = $explode[3]; $g2 = $explode[4];
	//終了条件
	if ($n==0) break;
	
	//初期化

	//ワーシャルフロイド準備。
	for ($i=1; $i<=$n; ++$i){
		for ($j=1; $j<=$n; ++$j){
			if ($i === $j){
				$cost[$i][$i] = 0;
			} else {
				$cost[$i][$j] = INF;
			}
		}
	}

	//辺の情報を格納
	for ($i=1; $i<=$m; ++$i){
		$info2 = trim(fgets($file_handle));
		$explode = explode(' ', $info2);
		$a = $explode[0]; $b = $explode[1]; $c = $explode[2];
		$cost[$a][$b] = $c;
	}

	//探索。先に全点対最短路を求めておく必要がある
	$cost = warshall_floyd($cost);
	
	//最小値計算
	$min = INF;
	for($i=1; $i<=$n; ++$i){
		//どこで分岐するのが最も総コストが低いか比較
		$via = $cost[$s][$i] + $cost[$i][$g1] + $cost[$i][$g2];
		$min = min($min, $via);
	}
	
	//出力
	echo $min.PHP_EOL;
}

fclose($file_handle);

Measured memory_bytes: 9896
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <cmath>


using namespace std;

//  ||
// \


int main() {
	int y = 0, x = 0;
	cin >> x >> y;
	int e = y / 2;
	cout << x + e << endl;	

	return 0;
}


Measured memory_bytes: 256
/*input
2
8 13
5 13
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

const int N = 51;
bool dp[N][N];
bool avail[N];
int a[N];
int b[N];
int n;

bool dodp(int ind){
    REP(i,N){
      REP(j,N){
        dp[i][j] = 0;
      }
    }
    dp[50][a[ind]] = 1;
    for(int i = 50;i > 1;i--){
      for(int j = 0;j <= 50;j++){
        //cout << i << " " << j << " " << dp[i][j] << endl;
        
        dp[i-1][j%(i-1)] |= (dp[i][j]&avail[i-1]);
        dp[i-1][j] |= dp[i][j];
        if(i == 8 and j == 10){
        //  cout << dp[i][j] << endl;
       //   cout << i-1 << " " << j%(i-1) << endl;
         // cout << dp[i-1][j%(i-1)] << endl;
        }
      }
    }
    return dp[1][b[ind]];
}


void solve(){
    cin >> n;
    RE(i,n){
      cin >> a[i];
    }
    RE(i,n){
      cin >> b[i];
      /*if(2*b[i] >= a[i]){
        cout << -1;
        return;
      }*/
    }
    int ans = 0;
    for(int i = 0;i < 50;i++)avail[i] = 1;
    for(int bit = 50;bit > 0;bit--){
      avail[bit] = 0;
      bool works = 1;
      RE(i,n){
        works &= dodp(i);
      }
      if(!works){
        ans += 1ll<<bit;
        avail[bit] = 1;
      }
    }
    if(avail[50]){
      cout << -1;
      return;
    }
    cout << ans;
}     

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 3592
while 1:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    else:
        print("#" * W)
        for i in range(H - 2):
            print("#" + "." * (W - 2) + "#")
        if H != 1:
            print("#" * W)
        print()

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

#define MAX 45

void Fibonacci(int);

int main(void){
  int n;

  scanf("%d", &n);
  Fibonacci(n);

  return 0;
}

void Fibonacci(int n){
  int i, fib[MAX];

  fib[0] = 1;
  fib[1] = 1;

  for(i=2; i<MAX; i++) fib[i] = fib[i-2] + fib[i-1];
  printf("%d\n", fib[n]);

  return;
}

Measured memory_bytes: 596
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
using ll=long long;
using Vec = vector<ll>;
using P = pair<ll, ll>;
using VecP = vector<P>;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

//static const ll MOD = 1000000007;
//static const ll INF = 1000000000000000000;
//#define PI 3.14159265358979323846
//
//int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
//
//int findSumDigits(int s) {
//    int num = 0;
//    int temp = 0;
//    while (s) {
//        temp = s % 10;
//        num += temp;
//        s = s / 10;
//    }
//    return num;
//}
//
//int countDivisorNum(int n) {
//    int count = 0;
//    for (int i = 1; i <= n; i++) {
//        if (n % i == 0) {
//            count++;
//        }
//    }
//    return count;
//}

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    ll temp = 0;

    rep(i, 100, 1) {
        if (1000 * i >= n) {
            temp = i;
            break;
        }
    }

    ans = 1000 * temp - n;


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	map<int, int> mp;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		mp[A[i]]++;
	}
	A.clear();
	for (auto m : mp) {
		A.push_back(m.second);
	}
	while (A.size() < N)A.push_back(0);
	sort(A.begin(), A.end());
	int cur = 0;
	int sum = 0;
	vector<int> res(N + 1, 0);
	for (int i = 1; i <= N; i++) {
		while (cur < N && A[cur] < i) {
			sum += A[cur];
			cur++;
		}
		int t = i * (N - cur) + sum;
		//cerr << i << " " << t / i << endl;
		res[t / i] = i;
	}
	for (int i = N - 1; i > 0; i--) {
		res[i] = max(res[i], res[i + 1]);
	}
	for (int i = 0; i < N; i++) {
		cout << res[i + 1] << endl;
	}
}

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

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

    int n;
    cin >> n;
    
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        mp[a] = i + 1;
    }

    for(auto x : mp){
        cout << x.second << ' ';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 5504
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/01 16:42:29 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
void	Main()
{
	string	o, k;
	cin >> o >> k;
	string	mins;
	rep(i, o.size())
		mins += 'z';
	bool	final;
	final = false;
	rep(i, o.size() - k.size() + 1)
	{
		string	s;
		s = o.substr(i, k.size());
		bool	flag;
		flag = true;
		rep(j, k.size())
		{
			if (s.at(j) != k.at(j) && s.at(j) != '?')
			{
				flag = false;
				break;
			}
		}
		if (flag == true)
		{
			final = true;
			string	t;
			t = o;
			rep(x, k.size())
				t.at(i + x) = k.at(x);
			rep(b, t.size())
			{
				if (t.at(b) == '?')
					t.at(b) = 'a';
			}
			// while (t.find("?") != string::npos)
			// 	t.at(t.find("?")) = 'a';
			if (t < mins)
				mins = t;
		}
	}
	if (final)
		cout << mins << endl;
	else
		cout << "UNRESTORABLE" << endl;
}
// END

int32_t	main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


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

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

// 何bitたっているか
int func2(ll x) {
    int hiku = 1;
    int cnt  = 0;
    while (x - hiku >= 0) {
        x -= hiku;
        cnt++;
        hiku++;
    }
    return cnt;
}

// 素因数分解
ll func(ll n) {
    ll x         = 2;
    ll cnt       = 0;
    ll sum       = 0;
    bool isPrime = false;
    while (n >= x) {
        if (n % x == 0) {
            n /= x;
            cnt++;
        } else {
            int val = func2(cnt);
            sum += val;
            cnt = 0;
            x++;
        }
    }
    if (cnt > 0) {
        int val = func2(cnt);
        sum += val;
    }
    return sum;
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;  // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

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

    if (n < 2) {
        cout << 0 << endl;
        return 0;
    }

    vector<pair<long long, long long> > vec = prime_factorize(n);

    ll sum = 0;
    for (pair<long long, long long> val : vec) {
        sum += func2(val.second);
    }
    // cout << func(n) << endl;
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3600
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int *primes = NULL;
int max = 30000;

inline int prime(int n)
{
    return primes[n];
}
void euclid(void)
{
    int i,j;
    int sqrt_max;
    int *list;
    list=(int*)malloc(sizeof(int)*max+1);
    primes=(int*)malloc(sizeof(int)*max+1);
    sqrt_max = (int)(sqrt((double)max)+1.0);
    for(i=1;i<=max;i++){
        list[i] = 1;
    }
    for(i=2;i<=sqrt_max;i++){
        if(list[i]){
            primes[i] = 1;
            for(j=1;i*j<=max;j++){
                list[i*j] = 0;
            }
        }
    }
    for(i=2;i<=max;i++){
        if(list[i])
            primes[i] = list[i];
    }
    free(list);
}
int main(void)
{
    int t,num_triangle;
    int i,j,k;

    euclid();
//    for(i=1;i<=max;i++)if(prime(i)) printf("%d\n",i);

    while(1){
        scanf("%d\n",&t);
        if(t==0) break;
        num_triangle = 0;
        i=1; j=1; k=t-(i+j);
        while(i<=j && j<=k){
            if(prime(i)){
                while(j<=k){
                    if(i+j>k){
                        if(prime(j)&&prime(k)){
                            num_triangle++;
                        }
                    }
                    j++; k--;
                }
            }
            i++; j=i; k=t-(i+j);
        }
        printf("%d\n", num_triangle);
    }
    return 0;
}

Measured memory_bytes: 832
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void)
{
	int i, n, max;
	double M, Y, S, T;
	int p[4] = {1, 2, 3, 4};
	int x[101], y[101];
	
	scanf("%d", &n);
	
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
	}
	for(i=0;i<n;i++){
		scanf("%d",&y[i]);
	}
	
	for(i=0;i<n;i++){
		M += abs(x[i]-y[i]);
	}
	for(i=0;i<n;i++){
		Y += abs(x[i]-y[i])*abs(x[i]-y[i]);
	}
	for(i=0;i<n;i++){
		S += abs(x[i]-y[i])*abs(x[i]-y[i])*abs(x[i]-y[i]);
	}
	for(i=0;i<n;i++){
		if(i==0){
			T = abs(x[i]-y[i]);
		}
		else{
			if(T<abs(x[i]-y[i]))
			T = abs(x[i]-y[i]);
		}
	}
	printf("%.8f\n",M);
	printf("%.8f\n",sqrt(Y));
	printf("%.8f\n",pow(S, 1.0/3.0));
	printf("%.8f\n",T);
	
	return 0;
}


Measured memory_bytes: 2056
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

ll N;
ll DF[110];
ll DS[110];

int main(void){

    cin >> N;
    for (int i = 1; i <= N;i++) cin >> DF[i] >> DS[i];

    bool exist = false;
    int sec = 0;
    for (int i = 1; i <= N;i++){
        if (DF[i] == DS[i]) sec++;
        else sec = 0;

        if (sec == 3){
            exist = true;
            break;
        }
    }

    if (exist) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {

    static final long mod = 1_000_000_007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] t = new int[n];
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int[] max = new int[n];
        Arrays.fill(max, Integer.MAX_VALUE);
        int[] d = new int[n];
        Arrays.fill(d, -1);
        d[0] = max[0] = t[0];
        for (int i = 1; i < n; i++) {
            if(t[i-1] < t[i]) d[i] = max[i] = t[i];
            else max[i] = t[i];
        }
        boolean able = true;
        for (int i = n-1; i >= 0; i--) {
            if(i == n-1 || a[i+1] < a[i]){
                if((d[i] != -1 && d[i] != a[i])
                        || (max[i] < a[i])){
                    able = false;
                    break;
                }
                d[i] = max[i] = a[i];
            }else{
                if(a[i] < max[i]) max[i] = a[i];
            }
        }
        long ans = 1L;
        if(able){
            for (int i = 0; i < n; i++) {
                if(d[i] < 0){
                    ans = (ans * max[i]) % mod;
                }
            }
        }else ans = 0;
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 81112
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("7");
            //3
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1729");
            //294867501
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int S = int.Parse(InputList[0]);

        const int Hou = 1000000000 + 7;

        //場合の数[和]なDP表
        int UB = S;
        int[] DPArr = new int[UB + 1];
        DPArr[0] = 1;
        for (int I = 0; I <= UB; I++) {
            if (DPArr[I] == 0) continue;
            for (int J = 3; J <= S; J++) {
                int NewInd = I + J;
                if (UB < NewInd) break;
                DPArr[NewInd] += DPArr[I];
                DPArr[NewInd] %= Hou;
            }
        }
        Console.WriteLine(DPArr[UB]);
    }
}


Measured memory_bytes: 27816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
double a[55];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for (ll i = 0; i < n; i++){
		cin >> a[i];		
		}
	sort(a, a+n);
	double ans = (a[0] + a[1])/2;
	for (ll i = 2; i < n; i++){
		ans = (ans + a[i])/2;
		
		
		}
		cout << ans;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
    long long N,A,B;
    cin>> N >> A >> B;
    long long total,residence;
    total = N/(A+B);
    residence = N % (A+B);
    if(residence>=A){
        residence = A;
    }
    else{
        residence = residence;
    }
    cout << total*A+residence << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;

ll MOD=int(1e9+7);

ll modinv(ll num){
  ll res=1LL;
  ll power=MOD-2LL;
  while(power>0LL){
  	if(power&1)res=res*num%MOD;
    num=num*num%MOD;
    power>>=1;
  }
  return res;
}

ll comb(ll s, ll t){
  ll ret=1LL;
  for(ll i=1LL;i<=s-t;i++){
  	ret=(ret*(t+i)%MOD)*modinv(i)%MOD;
  }
  // cout<<s<<"C"<<t<<": "<<ret<<endl;
  return ret;
}

int main(){
  ll n, m;cin>>n>>m;
  vector<ll> factor;
  for(ll div=2LL;div<=m;div++){
    int cnt=0;
    while(m%div==0LL){m/=div;cnt++;}
    if(cnt!=0)factor.push_back(ll(cnt));
  }
  ll ans=1LL;
  for(auto& e: factor){
  	ans=(ans*comb(n+e-1, e))%MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

bool chmax2(string &a, string b)
{
  if (a == "0") {a = b; return true;}
  if (a.size() < b.size()) {a = b; return true;}
  if (a.size() == b.size() && a < b) {a = b; return true;}
  return false;
}

signed main()
{
  vector<int> C = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (int i = 0; i < M; i++)
  {
    cin >> A.at(i);
  }
  
  vector<string> dp(N + 10, "0");
  dp.at(0) = "";
  for (int i = 0; i <= N; i++)
  {
    if (dp.at(i) == "0") continue;
    for (int j = 0; j < M; j++)
    {
      chmax2(dp.at(i + C.at(A.at(j))), dp.at(i) + myitoc(A.at(j)));
    }
  }
  
  string ans = dp.at(N);
  cout << ans << endl;
}

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

int main() {
  string N;
  cin >> N;
  if (N[0] == N[1] && N[1] == N[2]){
    cout << "Yes" << endl;
  }
  else if (N[1] == N[2] && N[2] == N[3]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}








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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int a[N],b[N];
    a[0] = 0;
    b[0] = 0;
    for(int i=0;i<N;i++){
        if(S[i] == 'E'){
            a[i+1] = a[i] + 1;
            b[i+1] = b[i];
//            cout << a[i+1] << ":" << b[i+1] << "|" << endl;
        }else if(S[i] == 'W'){
            a[i+1] = a[i];
            b[i+1] = b[i] + 1;
 //           cout << a[i+1] << ":" << b[i+1] << "|" << endl;
        }
    }

    int score ,result;
    for(int i=0;i<N;i++){
        score = b[i] + (a[N]-a[i+1]);
        if(i==0){
            result = score;
            continue;
        }
        if(score < result) result = score;
 //       cout << b[i]<< "+" << a[N] << "-" << a[i+1] << ":" << score << endl;
    }
    cout << result << endl;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define ll long long
#define uint unsigned int
#define inf 0x3f3f3f3f
#define db double
using namespace std;
const int maxn=1e6+10;
int d[2][6], cnt1=0,cnt2=0;

int main() {
	ll a;
	cin>>a;
	a=a*a*a+a*a+a;
	cout<<a<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <functional>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
#define fi first
#define se second
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

  ll N,K; cin>>N>>K;

  ll res = 0;
  for(ll i=K; i<=N+1; ++i) {
    ll L = i*(i-1)/2;
    ll R = N*(N+1)/2 - (N-i)*(N-i+1)/2;
    res+=R-L+1;
    res%=MOD;
  }

  cout<<res<<endl;

  return 0;
}

Measured memory_bytes: 3660
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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 main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  vector<lint> A(N);
  lint sum = 0;
  rep(i, N) {
    cin >> A[i];
    sum += A[i];
  }

  lint l = 0, r = 0;
  rep(i, N) {
    l += A[i];
    if (sum / 2 <= l) {
      r = sum - l;
      lint l2 = l - A[i];
      lint r2 = sum - l2;
      lint ans1 = abs(r - l);
      lint ans2 = abs(r2 - l2);
      cout << min(ans1, ans2) << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 1792