akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

    long Q,H,S,D,N;

    public void solve() {
        Q = nextLong();
        H = nextLong();
        S = nextLong();
        D = nextLong();
        N = nextLong();

        long ans = 0;

        long min = D;
        min = Math.min(min,Math.min(S * 2,H * 4));
        min = Math.min(min,Q * 8);

        ans += N / 2 * min;

        if(N % 2 == 1){
            min = Math.min(S,H * 2);
            min = Math.min(min,Q * 4);
            ans += min;
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

int main()
{
  string s;
  cin >> s;
  
  for (int i = 0; i < s.size(); i ++)
  {
    if (i == 3) cout << "8";
    else cout << s.at(i);
  }

  return 0;
}


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

bool isEvenArray(string &S, int ind) {
	for (int i = 0; i < ind / 2; i++) {
		if (S[i] != S[i + ind / 2]) return false;
	}
	return true;
}


int main()
{
	string S;
	cin >> S;
	int index = S.size();
	while (1) {
		index -= 2;
		if (isEvenArray(S, index)) break;
	}
	cout << index << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int a, b;
    cin >> a >> b;
    if ((a * b) % 2 == 0)
        cout << "Even" << endl;
    else
        cout << "Odd" << endl;
    // end

    return 0;
}


Measured memory_bytes: 384
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(s, w);
    cout << (s <= w ? "unsafe" : "safe") << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3640
N = int(input())
s = [0]*N
for i in range(N):
    s[i] = int(input())

dp = [False]*(10**4+1)

dp[0] = [True]
for j in range(N):
    for i in range(10**4-1, -1, -1):
        if i+s[j] < 10**4+1:
            dp[i+s[j]] = dp[i] or dp[i+s[j]]

for i in range(10**4+1):
    if (10**4-i) % 10 != 0:
        if dp[10**4-i]:
            print(10**4-i)
            exit()

print(0)

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

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

    int n;
    cin >> n;
    vector<long long> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

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

    long long ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            int k = lower_bound(A.begin(), A.end(), A[i] + A[j]) - A.begin();
            ans += max(0, k - j - 1);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math

def solve(N: int, K: int, A: "List[int]"):
    ix = A.index(1)

    # if(K == N):
    #     print(1)
    #     exit()

    # ans = min(math.ceil(len(A[:max(0,ix-1)])/(K-1))+math.ceil(len(A[min(ix+2,len(A)):])/(K-1))+1,
    #         math.ceil(len(A[:ix])/(K-1))+math.ceil(len(A[ix+1:])/(K-1)))
    # print(ans)

    ans = math.ceil((N-1)/(K-1))
    print(ans)


    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14452
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, a, b := scanInt(), scanInt(), scanInt()
	q := n / (a + b)
	r := n % (a + b)

	ans := q * a
	if r > a {
		ans += a
	} else {
		ans += r
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
main :: IO()
main = do
    str <- getLine
    print $ getsolve (init str)
    
    
    
getsolve :: String -> Int
getsolve str
	| len == 0								= 0
    | mod len 2 == 1						= getsolve (init str)
    | (take hlen str) == (drop hlen str)	= len
    | otherwise								= getsolve (init str)
    where len = length str
          hlen = div len 2


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

using namespace std;


#define PI 3.14159265
#define int long long



main(){


	int s; cin >> s;

	

	set <int> m;

	m.insert(s);

	int step = 1;
	while(true){
		step++;
		if(s & 1){
			s = s * 3 + 1;
		}else{
			s /= 2;
		}
		

		if(m.find(s) != m.end()){
			cout << step << endl;
			return 0;
		}else{
			m.insert(s);
		}
	}

	// cout << m[s] << endl;



	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 n, c;
    cin >> n >> c;
    vector<int64> x(n);
    vector<int64> v(n);
    REP(i,n)cin >> x[i] >> v[i];
    vector<int64> sum1(n+1);
    vector<int64> sum2(n+1);
    vector<int64> sum3(n+1);
    vector<int64> sum4(n+1);
    sum1[0] = 0;
    REP(i,n){
        sum1[i+1] = sum1[i] + v[i];
    }
    REP(i,n){
        sum1[i+1] -= x[i];
    }
    REP(i,n){
        sum1[i+1] = max(sum1[i+1], sum1[i]);
    }

    sum3[0] = 0;
    REP(i,n){
        sum3[i+1] = sum3[i] + v[i];
    }
    REP(i,n){
        sum3[i+1] -= 2 * x[i];
    }
    REP(i,n){
        sum3[i+1] = max(sum3[i+1], sum3[i]);
    }

    sum2[n] = 0;
    FORR(i,n-1,0){
        sum2[i] = sum2[i+1] + v[i];
    }
    FORR(i,n-1,0){
        sum2[i] -= (c - x[i]);
    }
    FORR(i,n-1,0){
        sum2[i] = max(sum2[i+1], sum2[i]);
    }

    sum4[n] = 0;
    FORR(i,n-1,0){
        sum4[i] = sum4[i+1] + v[i];
    }
    FORR(i,n-1,0){
        sum4[i] -= 2 * (c - x[i]);
    }
    FORR(i,n-1,0){
        sum4[i] = max(sum4[i+1], sum4[i]);
    }

    int64 ans = 0;
    REP(i,n+1){
        ans = max(ans, sum1[i] + sum4[i]);
    }
    REP(i,n+1){
        ans = max(ans, sum3[i] + sum2[i]);
    }
    ANS(ans);
    return 0;
}

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

using namespace std;

int main() {
  int c = 1;
  string n;
  cin >> n;
  for (int i = 0; i < (int)n.size(); ++i) {
    c = n[i] == n[i+1] ? c + 1 : 1;
    if (c == 3) break;
  }
  cout << (c == 3 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(input())

def main():
    N, K = geta(int)
    h = geta(int)

    INF = 1 << 60
    dp = [INF]*N
    dp[0], dp[1] = 0, abs(h[0] - h[1])

    for i in range(2, N):
        lb = max(0, i-K)
        for j in range(lb, i):
            dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]))

    print(dp[N - 1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 52448
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007
//#define MOD 7

using namespace std;

int main(void){
    // Your code here!
    long long n, a, b;
    
    cin >> n >> a >> b;
    
    cout << min(a * n, b) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------

  //if(b > a*x) ans = a*x;
  //else ans = b;

  cout << a*a*3 << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>

using namespace std;

int main(void)
{
	int x, n;
	int p;
	int ans[102];
	int i;
	for ( i = 0; i <= 101; i++)
		ans[i] = i;

	cin >> x >> n;

	if (n != 0)
	{
		for ( i = 0; i < n; i++)
		{
			cin >> p;
			ans[p] = -999;
		}
		
		int left_right = 0;
		while (1)
		{
			if (x - left_right >= 0)
			{
				if (ans[x - left_right] != -999)
				{
					cout << ans[x - left_right];
					break;
				}
			}

			if (x + left_right <= 101)
			{
				if (ans[x  + left_right] != -999)
				{
					cout << ans[x  + left_right];
					break;
				}
			}
			left_right++;
		}
		
	}
	else
	{
		cout << x;
	}


	return 0;
}

Measured memory_bytes: 3620
using System;
class SS
{
 static void Main()
 {
   int n=int.Parse(Console.ReadLine());
   int[] m=new int[n];
   var lines=Console.ReadLine().Split(" ");
   foreach(var line in lines)
   {
     int num=int.Parse(line);
     if(1<=num)
       m[num-1]++;
       
   }
   foreach(var menber in m)
   {
     Console.WriteLine(menber);
   }
 }
}


Measured memory_bytes: 42308
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>


#include<bits/stdc++.h>

#define ll long long
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define len(a) (int)a.size()
#define all(a) (a).begin(), (a).end()
#define pqueue priority_queue

using namespace std ;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr<<"LINE ("<< __LINE__ << ") : [" << #__VA_ARGS__ << "] -> ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

class BDigitSums {
public:
    int S(int N){
        int sum = 0 ;
        while(N!=0){
            sum += N % 10 ;
            N/=10 ;
        }
        return sum ;
    }
    void solveOne(std::istream& in, std::ostream& out){
        int N ;
        in >> N ;
        if( N % S(N) == 0) out << "Yes" ;
        else out << "No" ;
    }
	void solve(std::istream& in, std::ostream& out) {
	    int T = 1 ;
	    for(int id = 1 ; id <=  T ; ++id){
	        solveOne(in, out) ;
	    }
	}
};


int main() {
    ios::sync_with_stdio(false) ;
    cin.tie(0) ;
	BDigitSums solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vei vector<int>
#define vep vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++){cout<<a[i]<<" ";cout<<endl;}}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1LL; while (b > 0) {if (b & 1LL) {c = a * c%mod;}a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

int dp[100005];
bool ok[100005];

bool solve() {
	int n,m; cin >> n >> m;
	REP (i,n+1) ok[i] = true;
	REP (i,m) {
		int x; cin >> x;
		ok[x] = false;
	}
	dp[0] = 1;
	FOR (i,1,n+1) {
		if (!ok[i]) continue;
		if (ok[i-1]) {
			dp[i] += dp[i-1];
			dp[i] %= mod;
		}
		if (i >= 2) {
			if (ok[i-2]) {
				dp[i] += dp[i-2];
				dp[i] %= mod;
			}
		}
	}
	cout << dp[n] << endl;
}

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

	solve();
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int a[3],k;
    cin >> a[0] >> a[1] >> a[2] >> k;
    for(int i = 0;i < k;i++)
    {
        sort(a,a + 3);
        a[2] *= 2;
    }
    cout << a[0] + a[1] + a[2];

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    set_s = set(c for c in S)
    for e_s in set_s:
        if S.count(e_s) != 2:
            print(NO)
            return
    print(YES)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <cstdio>
#include <cstring>

#define MOD (10000)

using namespace std;

int memo[101][4][3];
int ready[101];

int n, k;

int countWay(int day, int pasta, int how)
{
	if (how > 2) return (0);
	if (~pasta && memo[day][pasta][how] >= 0) return (memo[day][pasta][how]);
	
	if (day == n){
		return (1);
	}
	
	int ret;
	
	ret = 0;
	if (ready[day + 1]){
		ret = countWay(day + 1, ready[day + 1], pasta == ready[day + 1] ? how + 1 : 1) % MOD;
	}
	else {
		for (int i = 1; i <= 3; i++){
			ret = (ret + countWay(day + 1, i, pasta == i ? how + 1 : 1)) % MOD;
		}
	}
	if (~pasta) return (memo[day][pasta][how] = ret);
	return (ret);
}

int main()
{
	scanf("%d %d", &n, &k);
	
	for (int i = 0; i < k; i++){
		int when, what;
		scanf("%d %d", &when, &what);
		ready[when] = what;
	}
	
	memset(memo, -1, sizeof(memo));
	
	printf("%d\n", ready[1] ? countWay(1, ready[1], 1) : (countWay(1, 1, 1) + countWay(1, 2, 1) + countWay(1, 3, 1)) % MOD);
	
	return (0);
}

Measured memory_bytes: 1032
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
#include<sstream>

using namespace std;

vector<int> getInput(int input);

int main()
{
	int N; cin >> N;
	vector<int> A = getInput(N);
	map<int, int> mp;
	for (int i = 0; i < N; i++) {
		mp[A[i]] = i + 1;
	}
	for (auto x : mp) {
		cout << x.second << endl;
	}
}

vector<int> getInput(int input) {
	vector<int> vec(input);
	for (auto& v : vec) {
		cin >> v;
	}
	return vec;
}

Measured memory_bytes: 5888
#include <iostream>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    long long A[N + 1];
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
    }

    if (A[1] != 0) { // X1は0以外にならない
        cout << -1 << endl;
        return 0;
    }

    long long total = 0;
//    long long cnt = 1;
    for (int i = 1; i < N; ++i) {
        if (A[i + 1] - A[i] >= 2) {
            cout << -1 << endl;
            return 0;
        }
        if (A[i] >= A[i + 1]) {
            total += A[i];
        }
//        if(A[i]+1==A[i+1]){
//
//        }
        if (i == N - 1) {
            total += A[N];
        }
    }

    cout << total << endl;
    return 0;
}

Measured memory_bytes: 1792
// AtCoder ABC131: A - Security
// 2019.9.3 bal4u

#include <stdio.h>

int main()
{
	char i, s[10];
	
	scanf("%s", s);
	for (i = 1; s[i]; i++) {
		if (s[i] == s[i-1]) { puts("Bad"); return 0; }
	}
	puts("Good");
	return 0;
}


Measured memory_bytes: 128
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        a: usize,
    }
    println!("{}", a + a * a + a * a * a);
}


Measured memory_bytes: 2124
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef pair<int, int> p;

void solve()
{
	int n;
	cin >> n;
	vector<p> list(n);
	for(int i = 0; i < n; ++i)
	{
		cin >> list[i].second >> list[i].first;
	}
	sort(list.begin(), list.end());
	int max_point = list[n - 1].first;
	int min_num = 99999;
	for(int i = 0; i < n; ++i)
	{
		if(max_point == list[i].first)
		{
			if(min_num > list[i].second)
			{
				min_num = list[i].second;
			}
		}
	}
	cout << min_num << " " << max_point << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1200
#include "stdio.h"

int main(void)
{
    int N;
    scanf("%d",&N);
    int i,j;
    int a[N];

    a[0]=0;
    for(i=1;i<N;i++)
    {
        scanf("%d",&a[i]); 
    }

    int kazu[N+1];
    for(i=0;i<=N;i++)
    {
        kazu[i]=0;
    }

    for(i=1;i<N;i++)
    {
        kazu[a[i]]++;
    }

    for(i=1;i<=N;i++)
    {
        printf("%d\n",kazu[i]);
    }
    return 0;
}

Measured memory_bytes: 3292
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {

	ll N, A;
	cin >> N >> A;
	cout << N * N - A;

	system("PAUSE");

	

}


Measured memory_bytes: 504
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    S = input()

    arr = []
    S = S.replace('><', '>,<')
    S = S.replace('<>', '<,>')
    S = S.split(',')
    for s in S:
        a = []
        if s[0] == '<':
            for i in range(len(s) + 1):
                a.append(i)
        else:
            for i in range(len(s), -1, -1):
                a.append(i)
        arr.append(a)
    ans, prev = 0, 0
    for i, a in enumerate(arr):
        ans += sum(a[1:])
        if arr[i][0] > prev:
            ans += arr[i][0] - prev
        prev = arr[i][-1]
    print(ans)


main()


Measured memory_bytes: 42476
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
using namespace std;

int A[100], top = 0;

int pop(){
  top--;
  return A[top+1];
}

void push(int x){
  top++;
  A[top] = x;
}

int main(){
  char v[10];
  int a, b;
  while ( scanf("%s", v) != EOF){
    if (v[0] == '+'){
      a = pop();
      b = pop();
      push( a + b );
    } else if (v[0] == '-'){
      b = pop();
      a = pop();
      push( a - b );
    } else if (v[0] == '*'){
      a = pop();
      b = pop();
      push( a * b );
    } else {
      push(atoi(v));
    }
  }

  cout << A[1] << endl;

  return 0;
}



Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define nt _int128
#define mod 1000000007
ll n;
ll arr[405];
ll dp[405][405];
ll func(ll i,ll j)
{
    if(j-i==0)
    {
        dp[i][j]=0;
        return 0;
    }
    else if(dp[i][j]!=-1)
        return dp[i][j];
    ll mn=1e18,mn2=1e18;
    for(ll h=i;h<j;h++)
    {
        ll y=arr[j]-arr[i-1];
        ll z=func(i,h);
        z+=func(h+1,j);
        mn=min(mn,z+y);
    }
    return dp[i][j]=mn;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    // cin >> t;
    t  = 1;
    while(t--)
    {
        cin>>n;
        for(ll i=1;i<=n;i++)
        {
            cin>>arr[i];
            arr[i]+=arr[i-1];
        }
        memset(dp,-1,sizeof(dp));
        cout<<func(1,n);
    }
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll r,g,b,n;
    IN(r,g,b,n);
    ll ans = 0;
    for(int i = 0;i*r <= n;i++){
        for(int j = 0;j*g<=n;j++){
            int v = n-i*r-j*g;
            if(v>=0 && v%b==0) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#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
int n;
int m;
int a[100000];
vector<int> G[100000];
bool used[100000];

vector<vector<int>> b;

void dfs(int i) {
	used[i] = true;
	b.back().pb(a[i]);

	REP(j,G[i].size()) {
		if(!used[G[i][j]])
			dfs(G[i][j]);
	}
}

int main(){
	cin >> n >> m;
	REP(i,n) {
		cin >> a[i];
	}
	REP(i,m)  {
		int x,y;
		cin >> x >> y;

		G[x].pb(y);
		G[y].pb(x);
	}
	if(m == n - 1){
		cout << 0 << endl;
		return 0;
	}

	if(n < 2 * (n - m - 1)) {
		cout << "Impossible" << endl;
		return 0;
	}

	REP(i,n) {
		if(!used[i]) {
			vector<int> aaa;
			b.pb(aaa);
			dfs(i);
		}
	}

	REP(i,b.size()) {
		sort(b[i].begin(),b[i].end());
	}

	int l = 2 * (n - m - 1);
	ll ans = 0;
	for(int i = 0;i < b.size() && l > 0 ;i++) {
		ans += b[i][0];
		b[i].erase(b[i].begin());
		l--;
	}
	priority_queue<int,vector<int>, greater<int>> que;
	REP(i,b.size()) {
		REP(j,b[i].size()) {
			que.push(b[i][j]);
		}
	}
	REP(i,l) {
		ans += que.top();
		que.pop();
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 8372
N, M, X, Y = map(int, input().split())

x = list(map(int, input().split()))
y = list(map(int, input().split()))

if max(x) + 1 <= min(y):
    Z = max(x) + 1

else:
    print("War")
    exit()

if X < Z and Z <= Y:
    print("No War")

else:
    print("War")


Measured memory_bytes: 3060
#include <cstdio>
#include <stack>
#include <cstdlib>

using namespace std;
int main(){
    char a[110];
    stack<int> s;
    while(scanf("%s", a)!=EOF){
        if(a[0] == '+'){
            int x = s.top(); s.pop();
            int y = s.top(); s.pop();
            s.push(x+y);
        }
        else if(a[0] == '-'){
            int x = s.top(); s.pop();
            int y = s.top(); s.pop();
            s.push(y-x);
        }
        else if(a[0] == '*'){
            int x = s.top(); s.pop();
            int y = s.top(); s.pop();
            s.push(x*y);
        }
        else if(a[0] == '/'){
            int x = s.top(); s.pop();
            int y = s.top(); s.pop();
            s.push(y/x);
        }
        else{
            s.push(atoi(a));
        }
    }
    printf("%d\n", s.top());
    return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef pair<string,lli> psl;

lli n,q;
queue<psl> que;
lli t = 0;

int main(){
    cin >> n >> q;
    for(lli i = 0;i < n;i++){
        string n;
        lli t;
        cin >> n >> t;
        que.push(psl(n,t));
    }
    while(!que.empty()){
        psl p = que.front();
        que.pop();
        p.second -= q;
        t += q;
        if(p.second <= 0){
            t += p.second;
            cout << p.first << " " << t << endl;
        }else{
            que.push(p);
        }
    }
    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	vll S(N); cin >> S;

	ll maxv = 0;
	for (int i = 1; i < N; i++) {
		ll sum = 0;
		for (int j = 1; i*j < N; j++) {
			int l = i*j, r = N-l-1;
			if (i >= r || l >= r && r%i == 0) break;
			sum += S[l] + S[r];
			chmax(maxv, sum);
		}
	}
	cout << maxv << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}

Measured memory_bytes: 1024
s = input()
t = input()
a =[]
for i in range(len(s)-len(t)+1):
    f = True
    for j in range(len(t)):
        if s[i+j] != '?' and s[i+j] != t[j]:
            f = False
    if f == True:
        a.append(i)

s = s.replace('?','a')
if len(a) !=0:
    print(s[:a[-1]]+t+s[a[-1]+len(t):])
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
import math
N = int(input())

a = math.ceil(math.sqrt(N))

yaku = {1,N}

for i in range(2,a+1):
  if N % i == 0:
    yaku.add(i)
    yaku.add(N // i)

sl = len(yaku)
lyaku =list(yaku)
lyaku.sort()
if sl % 2 == 1:
  print((lyaku[sl//2]-1)*2)
else:
  print(lyaku[sl//2]+lyaku[sl//2-1] -2)






Measured memory_bytes: 9432
/*
    In the name of
        "ALLAH"
    And say "AL-HAMD-U-LILLAH"
*/

#include<bits/stdc++.h>
#define   ll   long long
#define   llu  unsigned long long
#define   _    printf("\n")
int      take() {
    int n;
    scanf("%d",&n);
    return n;

}
double  ttake() {
    double n;
    scanf("%lf",&n);
    return n;
}
ll     takes() {
    ll n;
    scanf("%lld",&n);
    return n;

}

#define  Int            take()
#define  Dnt            ttake()
#define  LL             takes()
#define  done           {return 0;}
#define  fr(i,x,n,a)    for(int i=x;i<=n;i+=a)
#define  FR(a,b,x)      for(int i=(a);i<=(b);i+=(x))
#define  rfr(i,x,n,a)   for(int i=x;i>=n;i--)
int      cas;
#define  print          printf("Case %d:",++cas)
#define  vi             vector<int>
#define  vl              vector<ll>
#define  pb              push_back
#define  pii             pair<int,int>
#define  vii             vector<pii>
#define  pll             pair<ll,ll>
#define  pil             pair<int,ll>
#define  pli             pair<ll,int>
#define  mk              make_pair
#define  fill(x,v)       memset(x,v,sizeof x)

using    namespace      std;

bool     approximatelyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     essentiallyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     definitelyGreaterThan(float a, float b, float epsilon) {
    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     definitelyLessThan(float a, float b, float epsilon) {
    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
#define  STR            {struct info}
#define  dbg(x)         {cout<<"ekhane"<<x<<endl;}
#define  SS             second
#define  FF             first
#define  PQ             priority_queue
#define  great          greatest
#define  less           lesser
#define  mii            map<int,int>
#define  mil            map<int,ll>
#define  mll            map<ll,ll>
#define  msb            map<string,bool>
#define  V              vector
#define  M              100005
#define  pf             printf
//////////////////////////////////////////

int main( ){

    int n = Int , p[ n + 1 ] ;
    fr( i , 1 , n , 1 ){
        int u = Int ;
        p[ u ] = i ;
    }
    int len = 1 , ans = 1 ;
    fr( i , 2 , n , 1 ){
        if( p[ i ] > p[ i - 1 ] ) len++ ;
        else len = 1 ;
        ans = max( len , ans ) ;
    }
    cout<<n - ans<<endl;
    done ;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, c, k := scanInt(), scanInt(), scanInt()
	t := make([]int, n)
	for i := range t {
		t[i] = scanInt()
	}
	sort.Ints(t)

	ans := 1
	l := t[0] + k
	x := 1
	for i := 1; i < n; i++ {
		x++
		if x > c || t[i] > l {
			ans++
			l = t[i] + k
			x = 1
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2944
from math import *

n, k = [int(item) for item in input().split()]
ans = 0
for p in range(1, n + 1):

    if p >= k:
        ans += 1;
    else:
        x = ceil(log2(k) - log2(p))
        ans += 1.0 / (1 << x);
print(ans / n)


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

using namespace std;
//证明是我SadLava写的
char a[5]={'a','e','i','o','u'};//伟大的表

int main(){
    char c;
    c=getchar();
    for(int i=0;i<5;i++){
        if(c==a[i]){
            cout<<"vowel"<<endl;
            return 0;
        }
    }
    cout<<"consonant"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/*
void solve1() {
    vector<vector<pll>> dp(2, vector<pll>(N+1));
    dp[1][0] = pll(1000, 0);
    dp[0][0] = pll(1000, 0);
    for (int i = 0; i < N; i++) {
        ll t = dp[1][i].first / a[i];
        ll dm = dp[1][i].first - t * a[i];
        dp[0][i+1] = pll(dm, t);
        dp[1][i+1] = dp[1][i];
        for (int j = 0; j <= i; j++) {
            ll m = dp[0][j].second * a[j] + dp[0][j].first;
            dp[1][i+1] = max(dp[1][i+1], pll(m, 0));
        }
    }
    cout << dp[1][N].first << '\n';
}
*/
/* main */
int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    a.push_back(-1);
    vector<pll> v;
    ll cur = 0;
    ll ne = 0;
    for (int i = 0; i <= N; i++) {
        if (cur == 0) {
            cur = a[i];
        }
        else {
            if (ne == 0) {
                if (cur > a[i]) cur = a[i];
                else ne = a[i];
            }
            else {
                if (ne > a[i]) {
                    v.push_back(pll(cur, ne));
                    cur = a[i], ne = 0;
                }
                else {
                    ne = a[i];
                }
            }
        }
    }
    ll M = 1000;
    for (pll p : v) {
        ll t = M / p.first;
        M +=  t * (p.second - p.first);
    }
    cout << M << '\n';
}


Measured memory_bytes: 3628
#include<iostream>
void call();
void check_num();
void include3();
void end_check_num();

int i, x, n;

void call() {
    i = 1;
    check_num();
}

void check_num() {
    x = i;
    if(x % 3 == 0) {
        std::cout << " " << i;
        end_check_num();
    } else {
        include3();
    }
}

void include3() {
    if (x % 10 == 3) {
        std::cout << " " << i;
        end_check_num();
    } else {
        x /= 10;
        if (x) {
            include3();
        }
        end_check_num();
    }

}

void end_check_num() {
    if(++i <= n) {
        check_num();
    } else {
        
    }
}

int main() {

    std::cin >> n;

    call();

    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int main()
{
  char c;

  cin >> c;

  if ('a' <= c && c <= 'z') {
    printf("a\n");
  } else {
    printf("A\n");
  }

  return 0;
}


Measured memory_bytes: 3592
N = int(input())

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

ans = 0

for i in range(N):
  if i == 0:
    ans += B[0]
  elif i == N-1:
    ans += B[N-2]
  else:
    ans += min(B[i-1],B[i])
    
    
print(ans)    




Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main()
{
int n,flag=0;
cin>>n;
int d[n],value=0,tn;
tn=n*(n-1)/2;
for(int i=0;i<n;i++){
    cin>>d[i];
}
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        if(i!=j){
        value=value+d[i]*d[j];
        }
    }
}
value=value/2;
cout<<value;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const double PI = 3.1415926535;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

signed main(void){
    double n; n = in();
    vector<double> p(n);
    vector<vector<double>> dp(n + 1, vector<double>(n + 1));

    REP(i, n) cin >> p[i];

    dp[0][0] = 1.0;

    for(int i = 0; i < n; i++){
        for(int j = 0; j <= i; j++){
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
        }
    }
    
    double res = 0.0;
    for(int i = (n + 1)/ 2; i <= n; i++) res += dp[n][i];
    cout << fixed << setprecision(10) << res << endl;
    
}

Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int m,d;
	cin>>m>>d;
	int ans = 0;
	for (int i = 1; i <= m; i++){
		for (int j = 1; j <= d; j++){
			int d1 = j%10;
			int d10 = j/10;
			if(d1>=2 && d10>=2 && d1*d10==i){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  set<int> st;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    st.insert(a);
  }
  if (n == st.size()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int N = S.size();
  long long K;
  cin >> K;
  int i = 0;
  char n = 0;
  
  while (i < N) {
    if (S.at(i) != '1') {
      n = S.at(i);
      break;
    }
    i++;
  }
  
  if (K >= i+1) cout << n << endl; 
  else cout << 1 << endl;      
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(void){
  //入力部
  int N;
  cin >> N;
  string s[N];
  for (int i=0;i<N;i++){
    cin >> s[i];
  }
  int M;
  cin >> M;
  string t[M];
  for (int i=0;i<M;i++){
    cin >> t[i];
  }
  //処理部
  int count = 0;
  for (int i=0;i<N;i++){
    int num = 0;
    for (int j=0;j<N;j++){
      if (s[i] == s[j]) num++;
    }
    for (int k=0;k<M;k++){
      if (s[i] == t[k]) num--;
    }
    count = (num > count) ? num : count;
  }
  cout << count << endl;
  return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto && (i) : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, x, t;
  cin >> n >> x >> t;
  cout << updiv(n, x) * t << '\n';
  return 0;
}

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

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}

vector<int> zarray(const string &s){
  int n = s.size();
  vector<int> z(n, 0);
  int c = 0;
  for(int i = 1; i < n; i++){
    if(i + z[i - c] < c + z[c]){
      z[i] = z[i - c];
    }else{
      int j = max(0, c + z[c] - i);
      while(i + j < n && s[j] == s[i + j])j++;
      z[i] = j;
      c = i;
    }
  }
  z[0] = n;
  return z;
}

vector<int> z_search(string s, string t){
  string u = t;
  u += "$";
  u += s;
  vector<int> z = zarray(u);
  vector<int> res;
  for(int i = 1; i < u.size(); i++){
    if(z[i] >= t.size())res.push_back(i - int(t.size()) - 1);
  }
  return res;
}

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string t, p;
  cin >> t >> p;
  auto res = z_search(t, p);
  rep(i, sz(res))cout << res[i] << endl;
	return 0;
}



Measured memory_bytes: 13840