akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void){
	
		 double a,b;
	
		scanf("%lf%lf",&a,&b);

	
	if(a>b)
		puts("GREATER");
	else if(a<b)
		puts("LESS");
	else
		puts("EQUAL");
		
	return 0;
}



Measured memory_bytes: 128
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    ll a, b;
    cin >> a >> b;
    ll x = a % b;
    cout << min(x, b-x);
    return 0;
}


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

int main(){
    string s, t;
    cin >> s >> t;

    for(int i=0; i<s.size()-1; i++){
        for(int j=0; j<s.size()-1-i; j++){
            if(s[j] > s[j+1]){
                char tmp = s[j];
                s[j] = s[j+1];
                s[j+1] = tmp;
            }
        }
    }
    for(int i=0; i<t.size()-1; i++){
        for(int j=0; j<t.size()-1-i; j++){
            if(t[j] < t[j+1]){
                char tmp = t[j];
                t[j] = t[j+1];
                t[j+1] = tmp;
            }
        }
    }
    s.push_back('A');
    t.push_back('A');
    
    int n = min(s.size(), t.size());
    bool f = false;
    for(int i=0; i<n; i++){
        if(s[i] < t[i]){
            f = true;
            break;
        }
        if(s[i] > t[i]){
            break;
        }
    }
    if(f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
  
    return 0;
}


Measured memory_bytes: 256
/* Author: shriamrut
 * Language: C++17
 * Made on:16.02.2020
 * */
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ll long long
#define ss second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(v) (v).begin(),(v).end()
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
using namespace std;
void ra(auto a[],int n) { for(int i=0;i<n;i++) cin>>a[i];}
void pa(auto a[],int n) { for(int i=0;i<n;i++) cout<<a[i]<<" ";}
void rv(vector<auto>&v,int n) {v.resize(n);for(int i=0;i<n;i++)	cin>>v[i]; }
void pv(vector<auto>&v) {for(size_t i=0;i<v.size();i++) cout<<v[i]<<" ";}
ll maxl(ll a,ll b) { if(a>b) return a; return b; }
ll minl(ll a,ll b) { if(a<b) return a; return b; }
int main() {
	//IOS;
	int n;
	cin>>n;
	vector<int>a(n);
	rv(a,n);
	//bool ok=false;
	for(auto x:a) {
		if(x%2==0) {
			if(x%3!=0 &&  x%5!=0) {
				cout<<"DENIED";
				return 0;
			}
		}
	}
	cout<<"APPROVED";
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    int N, M;  cin >> N >> M;
    vector<pair<ll, int>> v;
    rep(i, N) {
        int a, b;  cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    sort(v.begin(), v.end());

    int cnt = 0;
    ll ans = 0;
    while (M > 0) {
        int d = v[cnt].second;
        ans += min(M, d) * v[cnt].first;
        M -= min(M, d);
        cnt++;
    }
    print(ans);

}

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

using namespace std;

int main(){
	string s;
  	cin >> s;
  	int rainy = 0;
  	int maxrainy = 0;
  	for(int i=0;i<3;i++){
    	if(s[i] == 'R'){
        	rainy++;
        } else {
        	rainy = 0;
        }
      	if(rainy > maxrainy){
        	maxrainy = rainy;
        }
    }
  	cout << maxrainy << endl;
}

Measured memory_bytes: 3596
from collections import defaultdict

N,K=list(map(int,input().split()))
a_list=list(map(int,input().split()))
alr = defaultdict(int)
alr[1] = 1
counter = 2
next = a_list[0]
base_roop = 0
last_index = 1
while True:
    if alr[next] != 0:
        base_roop = counter-1
        break
    else:
        alr[next] = counter
        last_index = next
        next = a_list[next-1]
        counter += 1

# nextから何回でlastに帰ってくるか
alr_next = defaultdict(int)
next_roop = 0
while True:
    if a_list[next-1]==last_index:
        next_roop += 1
        alr_next[next] = next_roop
        break
    else:
        next_roop+=1
        alr_next[next] = next_roop
        next = a_list[next-1]
next_roop+=1

if K<base_roop:
    ans = K%base_roop+1
    for k,v in alr.items():
        if v==ans:
            print(k)
            exit()
else:
    K-=base_roop
    ans = K%next_roop+1
    for k,v in alr_next.items():
        if v==ans:
            print(k)
            exit()
    print(last_index)

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

int main(){
	int A,B;
	cin>>A>>B;
	string S;
	cin>>S;
	rep(i,S.size()){
		if(i==A){
			if(S.at(i)=='-'){

			}else{
				cout<<"No"<<endl;
				return 0;
			}
		}else{
			if(int('0')<=S.at(i)&&S.at(i)<=int('9')){

			}else{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

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

int main(){
    int N;
    cin >> N;
    int a;
    int ans=0;
    for(int i=0; i<N; i++){
        cin >> a;
        if(i%2==0 && a%2==1)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
s = input()
mid = len(s) // 2
pre = s[:mid]
if len(s) % 2 == 0:
    aft = s[mid:]
    aft = aft[::-1]
else:
    aft = s[mid+1:]
    aft = aft[::-1]

dif = 0
for i in range(len(pre)):
    if pre[i] != aft[i]:
        dif += 1

print(dif)

Measured memory_bytes: 3064
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int []c = new int[340];		
			
			for(int a = 1 ; a <= n ; ++a){
				int b = sc.nextInt();
				int f = sc.nextInt();
				int r = sc.nextInt();
				int v = sc.nextInt();
				
				if (b==1){
					c[10*f+(r-1)]=c[10*f+(r-1)]+v;
				}else if (b==2){
					c[100*(b-1)+10*f+(r-1)]=c[100*(b-1)+10*f+(r-1)]+v;
				}else if (b==3){
					c[100*(b-1)+10*f+(r-1)]=c[100*(b-1)+10*f+(r-1)]+v;
				}else if (b==4){
					c[100*(b-1)+10*f+(r-1)]=c[100*(b-1)+10*f+(r-1)]+v;
				}
				
			}
			for(int a = 0 ; a <= 3 ; ++a){
				for(int d = 1 ; d <= 3 ; ++d){
					for(int e = 0 ; e <= 9 ; ++e){
						System.out.print(" "+c[100*a+10*d+e]);
					}
					System.out.println();
				}
				if(a!=3){
					System.out.println("####################");
				}
			}
	}

}

Measured memory_bytes: 29656
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#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++)

int main(){
    char k;
    cin >> k;
    if(k - 'a' >= 0)cout << "a" << endl;
    else cout << "A" << endl;
}

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

int main() {
  int a[7];
  int n, t, b;
  while (1) {
    cin >> n;
    if (!n) break;
    for (int i=0; i<7; i++) {
      a[i] = 0;
    }
    for (int i=0; i<n; i++) {
      cin >> t;
      b = t / 10;
      if (b > 6) {
        b = 6;
      }
      ++a[b];
    }
    for (int i=0; i<7; i++) {
      cout << a[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int a = sc.nextInt();
      int b = sc.nextInt();

      int[] arr = new int[n];
      for(int i = 0; i < n; i++)
        arr[i] = sc.nextInt();

      long cost = 0;
      for(int i = 1; i < n; i++){
        int prevX = arr[i - 1];
        int curX = arr[i];
        cost += Math.min((long)(curX - prevX) * a, b);
      }
      System.out.println(cost);
  }
}

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

namespace abc081_b
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var a = Console.ReadLine().Split(' ').Select(s => int.Parse(s));
            Console.WriteLine(Shift(a));
        }

        static int Shift(IEnumerable<int> A)
        {
            if (A.Any(a => a % 2 == 1)) return 0;
            var count = 1;
            var x = A.Select(s => s / 2);
            count += Shift(x);
            return count;
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int k,a,b;
  cin>>k>>a>>b;
  cout<<(a<=b/k*k?"OK":"NG")<<newl;
  return 0;
}


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

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		short size, sum;
		while (true) {
			sum = 0;
			String input = in.readLine();
			if (input.equals("0")) {
				break;
			}
			size = (short) input.length();
			for (int i = 0; i < size; i += 1) {
				sum += Short.parseShort(Character.toString(input.charAt(i)));
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 17020
import java.util.Scanner;

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

		for (int i = 0; i < s.length(); i += 2) {
			System.out.print(s.charAt(i));
		}
		System.out.println();
	}

}


Measured memory_bytes: 28636
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,s;
int main(){
	cin >> n >> s;
	FOR(i,2,sqrt(n) + 1) {
		ll n2 = n;
		ll c = 0;
		while(n2 > 0) {
			c += (n2 % i);
			n2 /= i;
		}
		if(c == s) {
			cout << i << endl;
			return 0;
		}
	}

	bool f = false;ll mini = 1000000000000000;
	FOR(i,1,sqrt(n) ) {
		ll j = s - i;
		if(j < 0) {
			break;
		}
		if(n - j < 0) {
			continue;
		}

		if((n - j) % i == 0 && (n - j) / i > j) {
			mini = min(mini,(n - j) / i);
			f = true;
		}
	}
	if(f) {
		cout << mini << endl;
	}else if(n == s){
		cout << n + 1 << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())

a = list(map(int,input().split()))

b = list(map(int,input().split()))

ans = int(0)
for i in range(n):
  if a[i] > b[i]:
    ans += b[i]
  else:
    if a[i]+a[i+1] > b[i]:
      ans += b[i]
      a[i+1] = a[i]+a[i+1]-b[i]
    else:
      ans += a[i]+a[i+1]
      a[i+1] = 0
      
print(ans)


Measured memory_bytes: 18624
#include<stdio.h>
int main(void)
{
int a,b,c;
int count=0;
int i;

scanf("%d %d %d",&a,&b,&c);
for(i=a;i<=b;i++)
{
if(c%i==0) count++;
}

printf("%d\n",count);
return 0;

}

Measured memory_bytes: 596
N, M = map(int, input().split())
X = sorted([list(map(int,input().split())) for _ in range(N)])

m = 0
c = 0
for x in X:
    c += x[0]*min(M-m, x[1])
    m += min(M-m, x[1])
    if m == M:
        break
print(c)

Measured memory_bytes: 28652
#include "bits/stdc++.h"
#include <numeric>

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

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

void Main() {
  int k;
  cin >> k;
  ll ans = 0;
  REP(a, 1, k+1) REP(b, 1, k+1) REP(c, 1, k+1) {
    ans += __gcd(a, __gcd(b, c));
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-8;
const int MAX=5e5+10;
const ll mod=1e9+7;
int main()
{
	ll a,b;
	while(~scanf("%lld%lld",&a,&b))
	{
		a*b%2?puts("Odd"):puts("Even");
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();

    sc.close();
    
    if (A <= 5) {
      System.out.println(0);
    } else if (A <= 12) {
      System.out.println(B/2);
    } else {
      System.out.println(B);
    }

  }

}

Measured memory_bytes: 21972
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

ans = 1000000000
for i in range(1 << n):
     score = [0 for _ in range(m)]
     tmp = i
     t = 0
     for j in range(n):
         if tmp & 1:
             for k in range(m):
                 score[k] += ca[j][k + 1]
             t += ca[j][0]
         tmp >>= 1
     if x <= min(score):
         ans = min(ans, t)
if ans == 1000000000:
    ans = -1
print(ans)

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

int N, A[MAXN + 3], idxMini;
LL dp[MAXN + 3][2][2];

LL solve(int group, int pos, int skipCount) {
    if (group == 0) {
        return (skipCount > 0 ? -1e15 : 0);
    }

    if (dp[group][pos][skipCount] != -1)
        return dp[group][pos][skipCount];

    int idx = (group - 1) * 2;
    LL result = (skipCount > 0 ? max(solve(group - 1, 0, skipCount - 1), solve(group - 1, 1, skipCount - 1)) : -1e15);

    if (pos == 0) {
        result = max(result, solve(group - 1, 0, skipCount) + A[idx + 1]);
    } else {
        result = max(result, max(solve(group - 1, 0, skipCount), solve(group - 1, 1, skipCount)) + A[idx + 2]);
    }

    return dp[group][pos][skipCount] = result;
}

int main() {
    cin >> N;

    idxMini = 1;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        if (A[i] < A[idxMini])
            idxMini = i;
    }

    memset(dp, -1, sizeof(dp));

    if (N%2 == 0)
        cout << max(solve(N/2, 0, 0), solve(N/2, 1, 0)) << endl;
    else {
        LL first = max(solve(N/2, 0, 0), solve(N/2, 1, 0));
        LL second = A[N] + solve(N/2, 0, 1);

        cout << max(first, second) << endl;
    }
}


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

using namespace std;

bool dp[100050];
int a [150];

int main() {
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	dp[a[0]] = true;
	for (int i = a[0] + 1; i <= k; i++) {
		for (int j = 0; j < n; j++) {
			if(i - a[j] < 0)
				break;
			if (!dp[i - a[j]])
				dp[i] = true;
		}
	}
	if (dp[k])
		cout << "First" << '\n';
	else	
		cout << "Second" << '\n';
}


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

using namespace std;
int main(void)
{
    set<int> s;
    int x[5];
    for (int i = 0; i < 5; i++) {
        s.insert(i + 1);
        cin >> x[i];
    }
    for (int i = 0; i < 5; i++)
        s.erase(x[i]);
    for (int i : s)
        cout << i << '\n';
    return 0;
}


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

using namespace std;
const int MAXN=1e5+5;
int h[MAXN],dp[MAXN];
int n,k;
int main()
{
	cin>>n>>k;
	
	for(int i=1;i<=n;++i)
	{
		cin>>h[i];
	}
	
	for(int i=2;i<=n;++i)
	{
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		
		for(int j=2;j<=k;++j)
		{
			if(i-j>0&&dp[i-j]+abs(h[i]-h[i-j])<dp[i])
				dp[i]=dp[i-j]+abs(h[i]-h[i-j]);
		}
		
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
}
int main()
{
    vok();
    int n;
    IN n;
    int ans=0;
    loop(i,0,n)
    {
        int temp;
        IN temp;
        if(temp%2 && i%2==0)
        {
            ans++;
        }
    }
    OUT ans<<endl
    return 0;
}

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

#define x first
#define y second

#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cerr << #x << ": " << x << endl;
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

ll ct[50];
int n;

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

	cin >> n;
	for (int i=0;i<n;i++) cin >> ct[i];
	ll ans=0;

	bool did=0;
	for (int i=0;i<n;i++) {
		ll td=ct[i]/n;
		if (td) {
			did=1;
			ct[i]%=n;
			for (int j=0;j<n;j++) if (i!=j) ct[j]+=td;
			ans+=td;
		}
		if (i+1==n && did) i=-1,did=0;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
alplist = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
n = int(input())
s = input()
ans = ""
for i in range(len(s)):
  for j in range(len(alplist)):
    if s[i] == alplist[j]:
      if j + n <= len(alplist)-1:
        ans += alplist[j+n]
      else:
        ans += alplist[j+n-len(alplist)]
print(ans)
  

Measured memory_bytes: 43372
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,K;
  cin >> A >> B >> K;
  
  int count=0,ans,m;
  m=min(A,B);
  for (int i=m;i>0;i--) {
    if (A%i==0 && B%i==0) {
      count++;
    }
    if (count==K) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,m;
    cin>>n>>m;
    int a[n],b[n];
    rep(i,n)cin>>a[i]>>b[i];
    multiset<pair<int,int>> yet;
    rep(i,n)yet.insert({a[i],b[i]});
    ll ans = 0;
    priority_queue<int> pq;
    REP(i,1,m+1){
        auto itr = yet.begin();
        while(itr!=yet.end()&&itr->first<=i){
            pq.push(itr->second);
            itr = yet.erase(itr);
        }
        if(pq.size()){
            ans+=pq.top();
            pq.pop();
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6396
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int a, b, c, d;
   cin >> a >> b >> c >> d;
   if(a + b > c + d){
      cout << "Left" << endl;
   }
   else if(a + b < c + d){
      cout << "Right" << endl;
   }
   else{
      cout << "Balanced" << endl;
   }

   return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
def main():
	N = int(input())
	march_list = ["M", "A", "R", "C", "H"]
	march_dict = defaultdict(int)
	for _ in range(N):
		x = input()
		if x[0] in march_list:
			march_dict[x[0]] += 1

	ans = 0
	for i in range(5):
		for j in range(i+1, 5):
			for k in range(j+1, 5):
				ans += march_dict[march_list[i]]*march_dict[march_list[j]]*march_dict[march_list[k]]
	print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<stdio.h>
int main(){
    int x[10],i,j,a;
    for(i=0;i<10;i++){
        scanf("%d",&x[i]);
    }
    for(i=0;i<10;i++){
        for(j=i;j<10;j++){
            if(x[i]<x[j]){
                a=x[i];
                x[i]=x[j];
                x[j]=a;
            }
        }
    }
    for(i=0;i<3;i++){
        printf("%d\n",x[i]);
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int N, cnt, X[100], MIN_N = 0x3f3f3f3f;
int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> X[i];
	}
	for (int i = 1; i <= 100; i++)
	{
		cnt = 0;
		for (int j = 0; j < N; j++)
		{
			cnt += (X[j] - i) * (X[j] - i);
		}
		MIN_N = min(cnt, MIN_N);
	}
	cout << MIN_N << endl;
	return 0;
}

Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;
using System;
class Program
{
    static void Main()
    {
        string input1 = Console.ReadLine();
        string input2 = Console.ReadLine();

        bool isFinded = true;
        for (int i = 0; i < 3; i++){
            if(input1[i] != input2[2 - i]){
                isFinded = false;
                break;
            }
        }

        if (isFinded){
            Console.WriteLine("YES");
        }else{
            Console.WriteLine("NO");
        }

    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main() {
    vector<int> a(3, 0);
    vector<int> b(3, 0);

    vector<vector<int>> c(3, vector<int>(3));
    rep(i, 3) {
        rep(j, 3) {
            cin >> c[i][j];
        }
    }

    // a_1 = 0からb_1,b_2,b_3を出す。
    b[0] = c[0][0];
    b[1] = c[0][1];
    b[2] = c[0][2];
    // a_2,a_3を出す
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];

    rep(i, 3) {
        rep(j, 3) {
            if (c[i][j] != (a[i] + b[j])) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

N = int(input())
pairs = [[0]*10 for i in range(10)]
for i in range(1, N+1):
    s = str(i)
    pairs[int(s[0])][int(s[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += pairs[i][j] * pairs[j][i]
print(ans)

Measured memory_bytes: 41580
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int a,b,c,d;
    cin >> a>>b>>c>>d;
    if (abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d))
    {
        cout << "Yes"<<endl;
    }
    else
    {
        cout << "No" <<endl;
    }
    return 0;
}

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

int main()
{
    long long n, k;
    cin >> n >> k;
    long long mod = 1e9 + 7;
    long long ans = 0;
    for (long long i = k; i <= n+1; i++)
    {
        ans = (ans + (n*i - i*(i-1) + 1)) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <cmath>
#include<iomanip>
#include <unordered_map>
#include <map>
using namespace std;
static const long long MOD = 1000000007LL;
typedef long long ll;
unordered_map <string,int> ump;
 
 
int main()
{
    int n;
    cin>>n;
    vector<ll> h(n);
    for(int i=0;i<n;i++)
    {
    	cin>>h[i];
    }
    vector<int> cnt;
    int cc=0;
    int max=-1;
    for(int i=0;i<n-1;i++)
    {
    	if(h[i]>=h[i+1])
    		cc++;
    	else
    	{
    		if(max<cc)
    			max=cc;
    		cc=0;
    	}
    	if(i==n-2&&h[i]>=h[i+1])
    		{
    		if(max<cc)
    			max=cc;}

    }
    if(n==1)
    	max=0;
    //sort(cnt.begin(),cnt.end());
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 1024
#ABC-133-C
#2019が素数ではなく3 * 673だから、2019の倍数が含まれてなければL*(L+1)%2019が答え。というアプローチで失敗だった。
L, R = map(int, input().split())
ans = 10 ** 10

for i in range(L, R+1):
    if ans == 0:
        break
    for j in range(i+1, R+1):
        ans = min(ans, (i * j) % 2019)
        if ans == 0:
            break

print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int MAXN=1e5+10;
int p[MAXN],n,res;
struct Segtree
{
	int val[MAXN<<2];
#define root val[o]
#define lson val[o<<1]
#define rson val[o<<1|1]
	void bd(int o,int l,int r)
	{
		if(l==r)
			return (void)(root=p[l]);
		int mid=(l+r)>>1;
		bd(o<<1,l,mid);
		bd(o<<1|1,mid+1,r);
		root=max(lson,rson);
	}
	void query(int o,int l,int r,int L,int R)
	{
		if(L>R)
			return;
		if(L<=l && r<=R)
			return (void)(res=max(res,root));
		int mid=(l+r)>>1;
		if(L<=mid)
			query(o<<1,l,mid,L,R);
		if(R>mid)
			query(o<<1|1,mid+1,r,L,R);
	}
} T;
int FindPre(int LL,int RR,int v)
{
	int L=LL,R=RR,s=0;
	while(L<=R)
	{
		int mid=(L+R)>>1;
		res=0;
		T.query(1,1,n,mid,RR);
		if(res>v)
			s=mid,L=mid+1;
		else
			R=mid-1;
	}
	return s;
}
int FindSuf(int LL,int RR,int v)
{
	int L=LL,R=RR,s=n+1;
	while(L<=R)
	{
		int mid=(L+R)>>1;
		res=0;
		T.query(1,1,n,LL,mid);
		if(res>v)
			s=mid,R=mid-1;
		else
			L=mid+1;
	}
	return s;
}
int main()
{
	n=read();
	for(int i=1; i<=n; ++i)
		p[i]=read();
	T.bd(1,1,n);
	ll ans=0;
	for(int i=1; i<=n; ++i)
	{
		int	pre1,pre2,suf1,suf2;
		pre1=FindPre(1,i-1,p[i]);
		pre2=FindPre(1,pre1-1,p[i]);
		suf1=FindSuf(i+1,n,p[i]);
		suf2=FindSuf(suf1+1,n,p[i]);
		ll tmp=0;
		tmp+=1LL*(pre1-pre2)*(suf1-i);
		tmp+=1LL*(suf2-suf1)*(i-pre1);
		ans+=tmp*p[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

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

signed main(){
    int n;cin>>n;
    vector<int> yoso(n+1,0);
    rep1(i,n){
        int buf=i;int s=2;
        while(buf>1){
            if(buf%s!=0)s++;
            else{
                yoso[s]++;
                buf/=s;
            }
        }
    }
    int four=0;
    int two=0;
    int tf=0;
    int ft=0;
    int st=0;
    rep1(i,n){
        //cout<<"yoso["<<i<<"] = "<<yoso[i]<<endl;
        if(yoso[i]>=4)four++;
        if(yoso[i]>=2)two++;
        if(yoso[i]>=24)tf++;
        if(yoso[i]>=14)ft++;
        if(yoso[i]>=74)st++;
    }
    //printf("four = %lld, two = %lld\n",four,two);
    int res=(two-2)*four*(four-1);
    res/=2;
    int add=0;
    add=tf*(two-1);
    res+=add;
    res+=ft*(four-1);
    res+=st;
    cout<<res<<endl;
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

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(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll K;
  IN(K);
  ll S = 7;
  vll Count(1E7+7, 0);

  ll ans = 1;

  S = S%K;

  while(true){
    if(Count[S]>0){
      OUT(-1);
      return 0;
    }else{
      Count[S]++;
    }
    if(S==0){
      OUT(ans);
      return 0;
    }
    S *= 10;
    S += 7;
    S %= K;
    ans++;
  }

  return 0;
}

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

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = null;
		try {
			line = br.readLine();
			line = line.trim();

			String[] words = line.split(" ");
			String longest = "", most = null;

			int[] count = new int[words.length];
			int max = -1;

			for (int i = 0; i < words.length; i++) {
				if (longest.length() < words[i].length())
					longest = words[i];
				for (int j = i + 1; j < words.length; j++) {
					if (words[i].equals(words[j])) {
						count[i]++;
					}
				}
				if (count[i] > max) {
					most = words[i];
					max = count[i];
				}
			}
			System.out.println(most + " " + longest);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 16896
#include<stdio.h>
int main(){
  int s;
  scanf("%d",&s);
  long long t=0;
  for(int i=1;i<=s;i++){
    if(i%3==0 || i%5==0){
      t+=0;
    }else{
      t+=i;
    }
  }
  printf("%lld\n",t);
}

Measured memory_bytes: 1732
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define R register
#define LL long long
#define U unsigned
#define FOR(i,a,b) for(R int i = a;i <= b;++i)
#define RFOR(i,a,b) for(R int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

int N,P;
int p[2];

int main(){
    scanf("%d%d",&N,&P);
    FOR(i,1,N){
        int x;scanf("%d",&x);
        p[x%2]++;
    }
    LL num = 0;
    if(p[1]) num = (1ll<<(p[1]-1))*(1ll<<p[0]);
    if(P){
        printf("%lld\n",num);
    }
    else printf("%lld\n",(1ll<<N)-num);
    return 0;
}

Measured memory_bytes: 256
a=[]
b=[]
while True:
    x,y=map(int,input().split())
    if x==0 and y==0:
        break
    a.append(x)
    b.append(y)

for i in range(len(a)):
    for i2 in range(a[i]):
        if i2==0 or i2 == (a[i]-1):
            print('#'*b[i])
        else:
            c = b[i]-2
            print('{}{}{}'.format('#','.'*c,'#'))
    print('')


Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, k, a[200005];
set<int> s1, s2;
void init(){
    n = read(), k = read();
    for (int i = 0; i < n; ++i)
        a[i] = read();
}
void solve(){
    int ans = 1, cnt = 0;
    for (int i = 0; i < k; ++i)
        s1.insert(a[i]), s2.insert(-a[i]);
    for (int i = 1; i < k; ++i)
        if (a[i] > a[i - 1]) ++cnt;
    bool flag = false;
    for (int i = k; i < n; ++i){
        if (cnt == k - 1) flag = true;
        s2.insert(-a[i]), s2.erase(-a[i - k]);
        if (a[i - k + 1] > a[i - k]) --cnt;
        if (a[i] > a[i - 1]) ++cnt;
        if (a[i - k] != *s1.begin() || -a[i] != *s2.begin()){
            if (cnt != k - 1 || !flag) ++ans;
        }
        s1.insert(a[i]), s1.erase(a[i - k]);
    }
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 19712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<ll> a(N), cum(N,0);

    for(int i=0; i<N; i++){
        cin >> a[i];
        if(i == 0) cum[i] = a[i];
        else cum[i] = cum[i-1]+a[i];
    }

    ll ans = 1LL<<59;
    for(int i=0; i<N-1; i++){
        chmin(ans, abs(cum[i] - cum[N-1]+cum[i]));
    }

    cout << ans << endl;
}

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

//#define fin cin
//#define fout cout

#define leftSon (node << 1)
#define rightSon ((node << 1) | 1)

#define pii pair < int , int >
#define F first
#define S second

using namespace std;

typedef long long ll;

const int inf = 0x3f3f3f3f;
const long long infL = LLONG_MAX;

const int nmax = 10;

int n, m, i, j;
char a[nmax][nmax];

bool used[nmax][nmax];

void print_answer(int x) {
    if (!x) printf("Impossible\n");
    else printf("Possible\n");

    exit(0);
}

void go(int x, int y) {
    used[x][y] = 1;

    if (x < n && a[x+1][y] == '#') {
        go(x + 1, y);
        return;
    }

    if (y < m && a[x][y+1] == '#') {
        go(x, y + 1);
        return;
    }
}

int main()
{
 

    /*
    ifstream fin("input.in");
    ofstream fout("output.out");
    */

    scanf("%d %d\n", &n, &m);
    for (i = 1; i <= n; ++i, scanf("\n"))
        for (j = 1; j <= m; ++j)
            scanf("%c", &a[i][j]);

    if (a[1][1] == '.')
        print_answer(0);

    go(1, 1);

    for (i = 1; i <= n; ++i)
        for (j = 1; j <= m; ++j)
            if (!used[i][j] && a[i][j] == '#')
                print_answer(0);

    print_answer(1);

    return 0;
}


Measured memory_bytes: 256
// finish date: 2019/2/22

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N;
    cin >> N;
    vd p(N);
    rep(i, N) cin >> p[i];
    vvd dp(N, vd(N + 1, 0));
    dp[0][0] = 1 - p[0];
    dp[0][1] = p[0];
    FOR(i, 1, N) {
        rep(j, N) {
            dp[i][j] += dp[i - 1][j] * (1 - p[i]);
            dp[i][j + 1] += dp[i - 1][j] * p[i];
        }
    }
    double ans = 0;
    FOR(i, N / 2 + 1, N + 1) {
        ans += dp[N - 1][i];
    }
    printf("%.9lf", ans);

    return 0;
}

Measured memory_bytes: 70656
#include "iostream"
#include "string"
#include <stack>
#include <queue>
#include <sstream>
#include <cstring>
using namespace std;

void A()
{
	stack<int> stack;
	string str;
	while (cin >> str)
	{
		if (str == "+" || str == "-" || str == "*")
		{
			int b = stack.top();
			stack.pop();
			int a = stack.top();
			stack.pop();
			int c;
			if (str == "+")
			{
				c = a + b;
			}
			else if (str == "-")
			{
				c = a - b;
			}
			else
			{
				c = a * b;
			}

			stack.push(c);
		}
		else
		{
			int num = stoi(str);
			stack.push(num);
		}
	}

	cout << stack.top() << endl;
}

void B()
{
	queue<string> name;
	queue<int> time;
	int spendTime = 0;
	int N;
	int Q;
	cin >> N;
	cin >> Q;

	cin.ignore();
	string line;
	string s;
	for (int i = 0; i < N;i++)
	{
		getline(cin, line);
		stringstream ss(line);
		ss >> s;
		name.push(s);
		ss >> s;
		time.push(stoi(s));
	}

	while (!time.empty())
	{
		int left = time.front();
		time.pop();
		string n = name.front();
		name.pop();

		if (Q >= left)
		{
			spendTime += left;
			cout << n << " " << spendTime<<endl;
		}
		else
		{
			spendTime += Q;
			time.push(left - Q);
			name.push(n);
		}
	}

	/*while (!name.empty())
	{
		cout << name.front() << endl;
		name.pop();
		cout << time.front() << endl;
		time.pop();
	}*/
}

struct Cell
{
	int data;
	Cell *prev;
	Cell *next;
};

Cell *start;
void insert(int x)
{
	Cell *c = (Cell *)malloc(sizeof(Cell));
	c->data = x;
	c->prev = start;
	c->next = start->next;
	start->next->prev = c;
	start->next = c;
}
void delete_x(int x)
{
	Cell *c = start->next;
	while (c != start && c->data != x)
	{
		c = c->next;
	}

	if (c == start)return;

	c->prev->next = c->next;
	c->next->prev = c->prev;
	free(c);
}

void deleteFirst()
{
	Cell *c = start->next;
	if (c == start)return;

	c->prev->next = c->next;
	c->next->prev = c->prev;
	free(c);
}

void deleteLast()
{
	Cell *c = start->prev;
	if (c == start)return;

	c->prev->next = start;
	start->prev = c->prev;
	free(c);
}

void print()
{
	Cell *c = start->next;
	int i = 0;
	while (true)
	{
		if (c == start)break;
		if (i != 0)cout << " " << flush;
		cout << c->data << flush;
		i++;
		c = c->next;
	}

	cout << endl;
}

void C()
{
	int N;
	//string command;
	int x = 0;
	//cin >> N;
	scanf("%d",&N);
	start = (Cell *)malloc(sizeof(Cell));
	start->next = start;
	start->prev = start;
	char command[20];
	for (int i = 0; i < N;i++)
	{
		scanf("%s",command);

		//cin >>command;
		//string first;
		//first = command.substr(0,1);

		if (command[0] == 'i')
		{
			scanf("%d", &x);
			insert(x);
			//cout << "insert" << endl;
		}
		else if (strlen(command)> 6)
		{
			//string seventh;
			//seventh = command.substr(6, 1);

			if (command[6]== 'F')
			{
				//cout << "First" << endl;
				deleteFirst();

			}
			else if (command[6] == 'L')
			{
				//cout << "Last" << endl;
				deleteLast();
			}

		}
		else if (command[0] == 'd')
		{
			scanf("%d", &x);
			//cout << "delete" << endl;
			delete_x(x);
		}

		//print();
	}

	print();
}

void D()
{

}
int main()
{
	//A();
	//B();
	C();
	return 0;
}

Measured memory_bytes: 32368
import java.util.*;

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




Measured memory_bytes: 50728
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;

    long long Tako[N];

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

    long long ans = 0LL;

    for(int i=0;i<N;i++){
        for(int j=1;j<N-i;j++){
            //cout << Tako[i] << " " << Tako[i+j] << endl;
            ans += Tako[i]*Tako[i+j];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
function Main(input){
	input = input.split("\n");
	var n = Number(input[0]);
	var ans = 0;
	for(var i=Math.min(input[1].length,input[2].length);i!=0;i--){
		if(input[1].substr(-1*i)==input[2].substr(0,i)&&input[1].length+input[2].length-i>=n){
			ans = i;
			break;
		}
	}
	console.log((input[1].substr(0,input[1].length-ans)+input[2]).length);
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    ll N;
    cin>>N;
    ll odd=0;
    ll mul2=0;
    ll mul4=0;
    REP(i,N){
        ll a;
        cin>>a;
        if(a%2!=0)odd++;
        else if(a%4==0)mul4++;
        else if(a%2==0)mul2++;
    }
    if(odd+mul2%2-mul4>1)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
S = input().strip()
flag =0
if S[0] =='A':
    if S[2:len(S)-1].count('C') == 1:
        if {'B','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'} & set(S) ==set([]):
            flag =1
print('AC' if flag else 'WA')         

Measured memory_bytes: 3064
x  = input().split()
y = x[1]
x = x[0]
X = 0
Y = 0
if x == "A" :
    X = 10
if x == "B":
    X = 11
if x == "C":
    X = 12
if x == "D":
    X = 13
if x == "E":
    X =14
if x == "F":
    X = 15
if y == "A" :
    Y = 10
if y == "B":
    Y = 11
if y == "C":
    Y = 12
if y == "D":
    Y = 13
if y == "E":
    Y =14
if y == "F":
    Y = 15
if X>Y:
    print(">")
elif X<Y:
    print("<")
else:
    print("=")



Measured memory_bytes: 3188
#include<iostream>
#include<cmath>
using namespace std;
long long n,a,s;
int main()
{
	cin>>n;
	for(int i=sqrt(n);i>0;i--)
	{
		if(n%i==0)
		{
			a=n/i;
			break;
		}
	}
		while(a>0)
		{
			s++;
			a/=10;
		}
	cout<<s<<endl;;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(N)]

tmp = [S[0]]
flag = True
for i in range(1,N):
    if S[i-1][-1] != S[i][0]:
        flag = False
        break
    if S[i] in tmp:
        flag = False
        break
    tmp.append(S[i])

print("Yes" if flag else "No")

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = mutableListOf<IntArray>()
    A.add(readLine()!!.split(" ").map { it.toInt() }.toIntArray())
    A.add(readLine()!!.split(" ").map { it.toInt() }.toIntArray())


    (0 until 2).forEach {i ->
        (0 until N).forEach { j ->
            val candidates = mutableListOf<Int>(0)
            if (j - 1 >= 0) {
                candidates.add(A[i][j - 1])
            }
            if (i - 1 >= 0) {
                candidates.add(A[i-1][j])
            }
            A[i][j] += candidates.max()!!
        }
    }
    println(A[1][N-1])
}


Measured memory_bytes: 37904