akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ARC067
{
    public class C
    {
        private const long Mod = 1000000007;

        public static Dictionary<long, int> Factors(long n)
        {
            var res = new Dictionary<long, int>();
            for (int i = 2; i * i <= n; ++i)
            {
                while (n % i == 0)
                {
                    if (res.ContainsKey(i)) { res[i] += 1; }
                    else { res.Add(i, 1); }
                    n /= i;
                }
            }
            if (n != 1)
            {
                res.Add(n, 1);
            }
            return res;
        }
        private void Run()
        {
            var N = int.Parse(Console.ReadLine().Trim());

            var dict = new Dictionary<long, int>();
            for (int i = 2; i <= N; i++)
            {
                foreach (var pair in Factors(i))
                {
                    if (dict.ContainsKey(pair.Key))
                    {
                        dict[pair.Key] += pair.Value;
                    }
                    else { dict.Add(pair.Key, pair.Value); }
                }
            }

            long result = 1;
            foreach (var pair in dict)
            {
                result *= (pair.Value + 1);
                result %= Mod;
            }

            Console.WriteLine(result);
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new C().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cstdlib>
using namespace std;

typedef long long ll;


int main()
{
	ll a, b, c;
	cin >> a >> b >> c;
	long long ans = ((c - (a + b)) * (c - (a + b))) - 4 * a * b;
	if (c > a + b && ans > 0)cout << "Yes";
	else
		cout << "No";

}

Measured memory_bytes: 256
#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>;

ll GCD(ll m, ll n) {
	if (n == 0) return m;
	return GCD(n, m % n);
}

ll LCM(ll a, ll b) {
	return a / GCD(a, b) * b;
}

int main() {
	ll A, B;
	cin >> A >> B;

	ll lcm = LCM(A, B);
	cout << lcm << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int k, n;
    cin >> k >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    int d[n];
    rep(i, n-1){
        d[i] = a[i+1]-a[i];
    }
    d[n-1] = a[0] + k -a[n-1];

    int dmax = 0;
    rep(i, n){
        chmax(dmax, d[i]);
    }

    cout << k-dmax << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
int l,r,n,a[55];
int main(){
	while(1){
		cin>>n>>l>>r;if(n==0) return 0;
		rep(i,n) cin>>a[i];
		int ans = 0;
		for(int x=l;x<=r;x++){
			rep(i,n){
				if(x%a[i] == 0){
					if(i%2 == 0) ans++;
					goto nxt;
				}
			}
			if(n%2 == 0) ans++;
		nxt:;
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 3104
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x



if __name__ == '__main__':
    N, K = mulinputs()
    d = (N+K-1)//K

    # 出力
    ans = int(abs(N-d*K))
    if N < ans:
        print(N)
    else:
        print(ans)


Measured memory_bytes: 5756
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll t;
  cin>>t;
  for(ll i = 1; ;i++){
    t -= i;
    if(t<=0){
      cout<<i<<endl;
      break;
    }
  }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
typedef long long ll;

ll a;
ll b;

int main() {
	cin >> a >> b;
	double ans = b * 10;
	bool now = false;
	while (!now && floor(ans / 10) == b) {
		if (floor(ans * 0.08) == a) {
			now = true;
		}
		else {
			ans++;
		}
	}
	cout << (now ? ans:-1) << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        struct Sushi
        {
            public readonly int t;
            public readonly long d;

            public Sushi(long[] V)
            {
                t = (int)V[0];
                d = V[1];
            }
        }

        static long Solve(int N, int K, Sushi[] sushis)
        {
            long sum = 0;
            var dic = new Dictionary<int, int>();
            Array.Sort(sushis, (a, b) => b.d.CompareTo(a.d));
            for (int i = 0; i < K; ++i)
            {
                if (!dic.ContainsKey(sushis[i].t)) { dic[sushis[i].t] = 0; }
                ++dic[sushis[i].t];
                sum += sushis[i].d;
            }
            long max = sum + Math.BigMul(dic.Count, dic.Count);
            int p = K - 1, q = K;
            while (true)
            {
                while (p >= 0 && dic[sushis[p].t] < 2) { --p; }
                if (p < 0) { break; }
                sum -= sushis[p].d;
                --dic[sushis[p].t];
                --p;

                while (q < N && dic.ContainsKey(sushis[q].t)) { ++q; }
                if (q >= N) { break; }
                sum += sushis[q].d;
                dic[sushis[q].t] = 1;
                ++q;

                max = Math.Max(sum + Math.BigMul(dic.Count, dic.Count), max);
            }
            return max;
        }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int N = V[0], K = V[1];
            var sushis = new Sushi[N];
            for (int i = 0; i < N; ++i) { sushis[i] = new Sushi(ReadLongs()); }
            Console.WriteLine(Solve(N, K, sushis));
        }
    }
}


Measured memory_bytes: 21316
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
lli dp[1001][1001];

int main(){
 	ios::sync_with_stdio(0);
    cin.tie(0);
    lli n,m;
    cin>>n>>m;
    lli a[n][m];
    for(lli i=0;i<n;i++){string st;cin>>st;for(lli j=0;j<m;j++){if(st[j]=='.')a[i][j]=1;else a[i][j]=0;}}
    for(lli i=0;i<n;i++){if(a[i][0]==0)break;dp[i][0]=1;}
	for(lli i=0;i<m;i++){if(a[0][i]==0)break;dp[0][i]=1;}
 	dp[0][0]=1;
 	for(lli i=1;i<n;i++){
 		for(lli j=1;j<m;j++){
 			if(a[i][j]==0){dp[i][j]=0;continue;}
 			dp[i][j]+=dp[i-1][j]+dp[i][j-1];
 			dp[i][j]%=1000000007;
 		}
 	}
 	cout<<dp[n-1][m-1];
	return 0;
 }

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

#define GIRI 1
#define IKA 0

string S;
long long K;

//idx, GIRI or IKA, num
long long dp[200][2][5];

int main(){
	cin >> S >> K;

	dp[0][GIRI][0] = 1;
	for(long long i = 0; i < S.size(); i++) {
		long long num = S[i] - '0';

		//IKAからの移動
		//0
		for(long long k = 0; k <= K; k++) {
			dp[i + 1][IKA][k] += dp[i][IKA][k];
		}
		//0以外
		for(long long n = 1; n < 10; n++) {
			for(long long k = 0; k <= K; k++) {
				dp[i + 1][IKA][k+1] += dp[i][IKA][k];
			}
		}
		//GIRIからの移動
		//0
		for(long long k = 0; k <= K; k++) {
			if(num == 0) {
				dp[i + 1][GIRI][k] += dp[i][GIRI][k];
			} else {
				dp[i + 1][IKA][k] += dp[i][GIRI][k];
			}
		}
		//0< < num
		for(long long n = 1; n < num; n++) {
			for(long long k = 0; k <= K; k++) {
				dp[i + 1][IKA][k+1] += dp[i][GIRI][k];
			}
		}
		//num
		if(num != 0) {
			for(long long k = 0; k <= K; k++) {
				dp[i + 1][GIRI][k+1] += dp[i][GIRI][k];
			}
		}
	}

	cout << dp[S.size()][IKA][K] + dp[S.size()][GIRI][K] << endl;

}



Measured memory_bytes: 3644
let NK = readLine()!.split(separator: " ").compactMap { Int($0) }
let n = NK[0]
let k = NK[1]

let AN = readLine()!.split(separator: " ").compactMap { Int($0) }

for i in 0..<n {
    if i < k {
        continue
    }

    if AN[i] - AN[i-k] > 0 {
        print("Yes")
    } else {
        print("No")
    }
}


Measured memory_bytes: 22232
<?php
    $fnum = trim(fgets(STDIN));
    $sline = trim(fgets(STDIN));
    $sarray = explode(' ',$sline);
    insertion_sort($sarray, $fnum);
    
    function insertion_sort($array, $num) {
        for ($i = 0; $i <= $num - 1; $i++) {
            $v = $array[$i];
            $j = $i - 1;
            while ($j >= 0 && $array[$j] > $v) {
                $array[$j + 1] = $array[$j];
                $j--;
                $array[$j + 1] = $v;
            }
            foreach ($array as $key => $value) {
                echo $value;
                if ($key != $num - 1) {
                    echo " ";
                } else {
                    echo "\n";
                }
            }
        }
    }
    

Measured memory_bytes: 15404
#include<bits/stdc++.h>
using namespace std;
int n,a,b,sum;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b;
		sum+=b-a+1;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
N,M = map(int, input().split()) 
H= list(map(int, input().split()))  
ANS=[1]*N
A=[0]*M
B=[0]*M
count=1
for i in range(M):
  A[i], B[i] = map(int, input().split())
#print(A[0])
for i in range(M):
  AA=A[i]
  BB=B[i]
  if H[AA-1]<=H[BB-1]:
    ANS[AA-1]=0
  if H[AA-1]>=H[BB-1]:
    ANS[BB-1]=0
print(sum(ANS))

Measured memory_bytes: 21720
/**
*
* Author: MARC
* Lang: GNU C++14
*
**/

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

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >

typedef unsigned long long ull;
typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl pi = 3.1415926535897932385;
const ldbl E = 2.71828182845904523536;
const dbl eps = 1e-9;
const ll mod = 1e9+7;
const ll inf = 1e17;

/** /////////// ** Code ** /////////// **/

const int N=200200;
ll a[N];

int main()
{
    int n; scanf("%d",&n);
    ll mn=inf;

    ll sum1=0 , sum2=0;

    for(int i=1 ; i<=n ; i++){
        scanf("%lld",&a[i]);
        sum1+=a[i];
    }

    for(int i=1 ; i<n ; i++){
        sum1-=a[i];
        sum2+=a[i];

        mn=min(mn,abs(sum1-sum2));

    }


    printf("%lld",mn);

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>

int main(){

    char tulisanA[11];
    char tulisanB[11];
    char tulisanC[11];

    scanf("%s %s %s", &tulisanA, &tulisanB, &tulisanC);

    int panjangA = strlen (tulisanA);
    int panjangB = strlen(tulisanB);

    if(tulisanA[panjangA-1] == tulisanB[0] && tulisanB[panjangB-1] == tulisanC[0]){
        puts("YES");
    }
    else{
        puts("NO");
    }
	return 0;
}



Measured memory_bytes: 1600
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

var arr = [Int](repeating: 0, count: 26)
let w = readLine()!.toArray()
for c in w {
    arr[Int(c.utf8.first! - "a".utf8.first!)] += 1
}
if [Int](repeating: 0, count: 26) == (arr.map{$0 % 2}) {
    print("Yes")
} else {
    print("No")
}


Measured memory_bytes: 7396
n = int(input())
a = list(map(int,input().split()))

left = []
now = a[0]
le = 1
s = a[0]
for i in range(1,n):
    s += a[i]
    while le < i and abs(2*now-s) > abs(2*now+2*a[le]-s):
        now += a[le]
        le += 1
    left.append([now,s-now])

right = []
now = a[-1]
ri = 2
s = a[-1]
for i in range(2,n+1):
    s += a[-i]
    
    while ri < i and abs(2*now-s) > abs(2*now+2*a[-ri]-s):
        now += a[-ri]
        ri += 1
    right.append([now,s-now])

ans = float("INF")
for i in range(n-3):
    a,b = left[i]
    c,d = right[n-4-i]
    ans = min(ans,max(a,b,c,d)-min(a,b,c,d))
print(ans)

Measured memory_bytes: 68244
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

		List<String> Slist = new ArrayList<>();
		List<String> Tlist = new ArrayList<>();
		//文字列を1文字ずつリストに入れる
		for (int i = 0; i < s.length(); i++) {
			Slist.add(s.substring(i, i+1));
		}
		for (int i = 0; i < t.length(); i++) {
			Tlist.add(t.substring(i, i+1));
		}

		//Slistを昇順に並び替え
		Collections.sort(Slist);
		String S = "";
		for (String str : Slist) {
			S += str;
		}

		//Tlistを降順に並び替え
		Collections.sort(Tlist, Collections.reverseOrder());
		String T = "";
		for (String str : Tlist) {
			T += str;
		}

		//System.out.println("S：" + S);
		//System.out.println("T：" + T);

		String judge = "No";
		//文字列の大小を比較
		//辞書的にSがTより大きい時：1、SがTより小さい時：-1、SとTが等しい時：0
		if (S.compareTo(T) < 0) {
			judge = "Yes";
		}
		System.out.println(judge);

	}
}

Measured memory_bytes: 23124
import fractions
A, B, C, D = map(int, input().split())

num = (C*D)//(fractions.gcd(C, D))
if(A%C==0):
    num1 = A//C-1
else:
    num1 = A//C
if(A%D==0):
    num2 = A//D-1
else:
    num2 = A//D
if(A%num == 0):
    num3 = A//num-1
else:
    num3 = A//num
print(int(B-A+1-((B//C-num1)+(B//D-num2)-(B//num-num3))))

Measured memory_bytes: 5048
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define N 200020
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,a[N],b[N],T,p[N],ans;
ll s[N],dp[33];
int main(){
	n=read(),T=read();
	for(int i=1;i<=n;++i){
		a[i]=read()+1,b[i]=read()+a[i],p[i]=i;
	}
	sort(p+1,p+n+1,[&](int i,int j){return a[i]>a[j];});
	int m=n;
	while(m&&a[p[m]]==1)--m;
	sort(p+1,p+m+1,[&](int i,int j){return 1LL*b[i]*(a[j]-1)<1LL*b[j]*(a[i]-1);});
	sort(p+m+1,p+n+1,[&](int i,int j){return b[i]<b[j];});
	for(int i=1;i<=n-m;++i){
		s[i]=s[i-1]+b[p[i+m]];
	}
	for(int i=1;i<=30;++i){
		dp[i]=0x3f3f3f3f;
	}
	dp[0]=0;
	for(int i=1;i<=m;++i){
		for(int j=30;j>=1;--j){
			dp[j]=min(dp[j],1LL*dp[j-1]*a[p[i]]+b[p[i]]);
		}
	}
	int now=0;
	for(int i=30;i>=0;--i){
		if(dp[i]>T)continue;
		while(now<n-m&&s[now+1]<=T-dp[i]){
			++now;
		}
		ans=max(ans,now+i);
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 7488
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int N,M;
int A[100005];
int B[100005];
int ans[100005];
int parent[100005];
int linked[100005];

void init(int N){
    rep(i,N)parent[i]=i;
    rep(i,N)linked[i]=1;
}
int root(int x){
    if(parent[x]==x)return x;
    parent[x]=root(parent[x]);
    return parent[x];
}
int linked_town(int x){
    return linked[parent[x]];
}
int unite(int x,int y){//return "new couple"
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return 0;
    parent[ry]=rx;//結合
    int newcouple=linked[ry]*linked[rx];
    linked[rx]=linked[ry]+linked[rx];
    return newcouple;
}
signed main(){
    scanf("%lld %lld",&N,&M);
    init(N);
    rep(i,M){scanf("%lld %lld",&A[i],&B[i]);A[i]--;B[i]--;}
    ans[M-1]=N*(N-1)/2;
    for(int i=M-1;i>-1;i--){
        int newcouple=unite(A[i],B[i]);
        ans[i-1]=ans[i]-newcouple;
    }
    rep(i,M)printf("%lld\n",ans[i]);
}

Measured memory_bytes: 5600
import java.util.ArrayList;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		int n;
		int[] array; int[] box; int t;
		while (str.equals("-") == false) {
			n = scan.nextInt();
			array = new int[str.length()];
			box = new int[str.length()];
			for (int i = 0; i < str.length(); i++) {
				array[i] = i;
			}
			for (int i = 0; i < n; i++) {
				t = scan.nextInt();
				for (int j = 0; j < array.length; j++) {
					box[j] = array[(j + t) % array.length];
						
				}
				for (int j = 0; j < array.length; j++) {
					array = (int[])box.clone();
				}
			}
			for (int j = 0; j < str.length(); j++) {
				System.out.print(str.charAt(box[j]));
			}
			System.out.println();
			str = scan.next();
		}
	}

}

Measured memory_bytes: 42012
c = [1, 5, 10, 50, 100, 500]
loop do
    num = gets.to_i

    break if num == 0
    oturi = 1000 - num
    uns = 0
    t = 0
    (c.size - 1).downto(0) do |i|
        t = oturi/c[i]
        oturi -= (c[i] * t)
        uns += t
    end
    puts uns

end


Measured memory_bytes: 8868
n, m = map(int, input().split())

ac = [0]*n
wa = [0]*n

for _ in range(m):
    p, s = map(str, input().split())
    p = int(p)

    if ac[p-1]:
        continue
    else:
        if s == 'AC':
            ac[p-1] = 1
        else:
            wa[p-1] += 1

AC = 0
WA = 0
for i in range(n):
    AC += ac[i]
    if ac[i]:
        WA += wa[i]

print(AC, WA)

Measured memory_bytes: 4596
#include<bits/stdc++.h>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int N,A,B,ans;
  cin>>N>>A>>B;
  vector<long long int> X(N);
  REP(i,N)cin>>X[i];
  REP(i,N-1){
    if(A*(X[i+1]-X[i])>B)ans+=B;
    else ans+=A*(X[i+1]-X[i]);
  }
  cout<<ans;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,sum=0,s1=0;
  cin>>n;

  string s[n];
  int t[n];
  for(int i=0;i<n;i++){
    cin>>s[i]>>t[i];
    sum+=t[i];
  }
  string x;
  cin>>x;
  for(int i=0;i<n;i++){
    s1+=t[i];
    if(s[i]==x)
    break;
  }
  cout<<sum-s1<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>

int paper[10][10];
int vecx[] = { 0, 1, 0, -1 }, vecy[] = { -1, 0, 1, 0 };

int main()
{
	int x, y, size;
	
	while( scanf( "%d,%d,%d", &x, &y, &size ) != EOF ){
		switch( size ){
			case 1:
				paper[x][y]++;
				for( int i = 0; i < 4; i++ ){
					int nx = x + vecx[i], ny = y + vecy[i];
					
					if( nx >= 0 && nx < 10 && ny >= 0 && ny < 10 ){
						paper[nx][ny]++;
					}
				}
				break;
			case 2:
			        for( int i = -1; i <= 1; i++ ){
					for( int j = -1; j <= 1; j++ ){
						if( x + i >= 0 && x + i < 10 && y + j >= 0 && y + j < 10 ){
							paper[x+i][y+j]++;
						}
					}
				}
				
				break;
			case 3:
				for( int i = -1; i <= 1; i++ ){
					for( int j = -1; j <= 1; j++ ){
						if( x + i >= 0 && x + i < 10 && y + j >= 0 && y + j < 10 ){
							paper[x+i][y+j]++;
						}
					}
				}
				
				for( int i = 0; i < 4; i++ ){
					int nx = x + vecx[i] * 2, ny = y + vecy[i] * 2;
					
					if( nx >= 0 && nx < 10 && ny >= 0 && ny < 10 ){
						paper[nx][ny]++;
					}
				}
				break;
		}
	}
	
	int a = 0, b = 0;
	
	for( int i = 0; i < 10; i++ ){
		for( int j = 0; j < 10; j++ ){
			if( !paper[i][j] ){
				a++;
			}
			else{
			 	b = std::max( b, paper[i][j] );
			}
		}
	}
	
	std::cout << a << std::endl;
	std::cout << b << std::endl;

 	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <stdio.h>
#include <queue>
#include <string>
#define MAX 100001

using namespace std;

int main()
{
    int n, quantum, stamp = 0;
    scanf("%d %d", &n, &quantum);

    string name;
    int time;
    queue<pair<string, int> > Q;
    for (int i = 0; i < n; i++)
    {
        cin >> name >> time;
        Q.push(make_pair(name, time));
    }

    while (!Q.empty())
    {
        name = Q.front().first;
        time = Q.front().second;
        Q.pop();

        if (time > quantum)
        {
            Q.push(make_pair(name, time - quantum));
            stamp += quantum;
        }
        else
        {
            stamp += time;
            printf("%s %d\n", name.c_str(), stamp);
        }

    }



    return 0;
}



Measured memory_bytes: 6432
#include <iostream>
#include <map>
#include <queue>
#include <string>
using namespace std;

typedef pair<string ,int> P;

int bfs(string str)
{
	map<string, int> m;
	queue<P> que;
	que.push(P(str,1));
	while(!que.empty())
	{
		P p = que.front();que.pop();
		if(m[p.first]) continue;//すでに数字が存在するときはやりなおし
		bool flag=true;
		for(int i=0;i<p.first.size()-1;++i){
			if(p.first[i] != p.first[i+1])
				flag = false;
		}
		if(flag) return p.second-1;
		m[p.first] = p.second;//重複をなくす
		for(int i=0;i<str.size()-1;++i){
			char c;
			if(p.first[i] == p.first[i+1])
				continue;
			if(p.first[i] != 'r' && p.first[i+1] != 'r')
				c = 'r';
			if(p.first[i] != 'g' && p.first[i+1] != 'g')
				c = 'g';
			if(p.first[i] != 'b' && p.first[i+1] != 'b')
				c = 'b';
			string next = p.first;
			next[i] = next[i+1] = c;
			que.push(P(next,p.second+1));
		}
	}
	return -1;
}

int main(void)
{
	while(1){
		string str;
		cin >> str;
		if(str[0] == '0')
			return 0;
		int res = bfs(str);
		if(res >= 0)
			cout << res << endl;
		else
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 3388
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const X = arg[1].split(" ").map(n=>parseInt(n));
    const sortedX = [...X].sort((a,b)=>a-b);
    
    const medianOne = sortedX[(N / 2) - 1];
    const medianTwo = sortedX[N / 2];

    let answer = [];
    
    for(let i in X) {
        if(X[i] < medianTwo) {
            answer.push(medianTwo);
        } else {
            answer.push(medianOne);
        }
    }
    
    console.log(answer.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 65020
use proconio::*;
use std::cmp::max;
use std::collections::BinaryHeap;

#[fastout]
fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    };

    let mut score = 0;
    let mut lasts = [-1; 26];
    let mut t = vec![26; d];
    let depth = 400;
    for i in 0..d {
        let mut max_score = -10000000;
        for j in 0..26 {
            let tmp = search(i, j, &c, &s, &mut lasts, depth, d, 0, 2);
            if tmp > max_score {
                max_score = tmp;
                t[i] = j;
            }
        }
        score += max_score;
        lasts[t[i]] = i as i64;
    }

    for &a in &t {
        println!("{}", a + 1);
    }
}

fn calc_score(i: usize, j: usize, c: &Vec<i64>, s: &Vec<Vec<i64>>, lasts: &mut [i64; 26]) -> i64 {
    let mut res = s[i][j];
    let tmp = lasts[j];
    lasts[j] = i as i64;

    for j in 0..26 {
        let i = i as i64;
        let last = lasts[j];
        res -= c[j] * (i - last);
    }

    lasts[j] = tmp;
    res
}

fn search(
    i: usize,
    t: usize,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    lasts: &mut [i64; 26],
    depth: usize,
    d: usize,
    cscore: i64,
    l: usize,
) -> i64 {
    if depth == 0 || i == d - 1 {
        return calc_score(i, t, &c, &s, lasts) + cscore;
    }

    let l = max(1, l - 1);
    let mut max_score = -1000000;
    let tmp_last = lasts[t];
    lasts[t] = i as i64;
    let tmp_score = calc_score(i, t, &c, &s, lasts);
    let mut cands = BinaryHeap::new();
    for j in 0..26 {
        let tmp_score = calc_score(i + 1, j, &c, &s, lasts);
        cands.push((tmp_score, j));
    }
    for &(_, j) in cands.iter().take(l) {
        let tmp = search(i + 1, j, &c, &s, lasts, depth - 1, d, cscore + tmp_score, l);

        if tmp > max_score {
            max_score = tmp;
        }
    }

    lasts[t] = tmp_last;
    max_score + cscore
}


Measured memory_bytes: 2640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

const int INF = 1 << 30, Array= 1400;
int dp[Array][Array];

int main(){
    int h, w, maxedge = 0;
    bool tail[Array][Array];
    scanf("%d%d", &h, &w);
    for(int i = 0; i < h; i++){
        for(int j = 0;j <w; j++){
            scanf("%d", &tail[ i ][ j ]);
            if(!tail[ i ][ j ]){
                dp[ i ][ j ] = 1;
                maxedge = 1;
            }
        }
    }
    for(int i = 1; i < h; i++){
        for(int j = 1; j < w; j++){
            if(!tail[ i ][ j ])
                dp[ i ][ j ] = min(dp[ i - 1 ][ j - 1 ], min(dp[ i - 1 ][ j ], dp[ i ][ j - 1 ]) ) + 1;
             maxedge = max( maxedge, dp[ i ][ j ]);
        }
    }
    printf("%d\n", maxedge * maxedge);
    return 0;
}

Measured memory_bytes: 9420
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

  vector<int> L(N); 
  for(int i=0; i<N; i++){
    cin>>L.at(i);
  } 

  sort(L.begin(), L.end());
  
  int ans=0;

  for(int i=N-1; i>=2; i--){
    if(L.at(0)+L.at(1)>L.at(i)){
      ans+=i*(i-1)/2;
    }
    else{
      for(int j=i-1; j>0; j--){
        for(int k=j-1; k>=0; k--){
          if(L.at(k)+L.at(j)>L.at(i)){
            ans++;
          }
          else{
            break;
          }
        }
      }
    }
  }

  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXSIZE=10000020;
int bufpos;
char buf[MAXSIZE];
#define NEG 0
void init(){
    #ifdef LOCAL
        freopen("C.txt","r",stdin);
    #endif
    buf[fread(buf,1,MAXSIZE,stdin)]='\0';
    bufpos=0;
}
#if NEG
int readint(){
    bool isneg;
    int val=0;
    for(;!isdigit(buf[bufpos]) && buf[bufpos]!='-';bufpos++);
    bufpos+=(isneg=buf[bufpos]=='-');
    for(;isdigit(buf[bufpos]);bufpos++)
        val=val*10+buf[bufpos]-'0';
    return isneg?-val:val;
}
#else
int readint(){
    int val=0;
    for(;!isdigit(buf[bufpos]);bufpos++);
    for(;isdigit(buf[bufpos]);bufpos++)
        val=val*10+buf[bufpos]-'0';
    return val;
}
#endif
char readchar(){
    for(;isspace(buf[bufpos]);bufpos++);
    return buf[bufpos++];
}
int readstr(char* s){
    int cur=0;
    for(;isspace(buf[bufpos]);bufpos++);
    for(;!isspace(buf[bufpos]);bufpos++)
        s[cur++]=buf[bufpos];
    s[cur]='\0';
    return cur;
}
bitset<2005002> b;
int main(){
    init();
    int n=readint(),sum=0;
    b[0]=1;
    while(n--){
        int x=readint();
        b|=b<<x;
        sum+=x;
    }
    sum=(sum+1)/2;
    while(!b[sum])
        sum++;
    printf("%d",sum);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main (){
    string s;
    cin >> s;
    s+='R';
    int l=s.size();
    bool rorl=true;
    vector<int>ans(l);
    int rcount=0;int lcount=0;
    int rans,lans;
    rep(i,l){
        if(s[i]=='R'){
            if(!rorl){
                if((rcount+lcount)%2==0||rcount==lcount){
                    ans[rans]=(rcount+lcount)/2;
                    ans[lans]=(rcount+lcount)/2;
                }
                else{
                    int judge=max(rcount,lcount);
                    judge--;
                    if(rcount>lcount){
                        if((rcount-1)%2==0){
                            ans[rans]=(rcount+lcount)/2+1;
                            ans[lans]=(rcount+lcount)/2;
                        }
                        else{
                            ans[rans]=(rcount+lcount)/2;
                            ans[lans]=(rcount+lcount)/2+1;
                        }
                    }
                    else{
                        if((lcount-1)%2==0){
                            ans[rans]=(rcount+lcount)/2;
                            ans[lans]=(rcount+lcount)/2+1;
                        }
                        else{
                            ans[rans]=(rcount+lcount)/2+1;
                            ans[lans]=(rcount+lcount)/2;
                        }
                    }
                }
                rcount=0;lcount=0;
            }
            rcount++;
            rorl=true;
        }
        if(s[i]=='L'){
            lcount++;
            if(rorl){
                rans=i-1;
                lans=i;
            }
            rorl=false;
        }
    }
    rep(i,l-1){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


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

/***typededfs***/
typedef long long ll;
typedef long double ldb;

/***defines***/
#define M1 1000000007
#define M2 998244353
#define F first
#define S second
#define pb push_back
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forz(i,n) for(int i=0;i<(n);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define rforz(i,n) for(int i=(n-1);i>=0;i--)
#define rfore(i,a,b) for(int i=(a);i>=(b);i--)
#define test int T; cin>>T; while(T--)
#define all(v) v.begin(),v.end()
#define mm(a,b) ((a%M1)*(b%M1))%M1
#define ma(a,b) ((a%M1)+(b%M1))%M1

int main(){
    FASTIO;
  	string s;
  	cin>>s;
  	int n = s.size();
  	if(s[n-1]=='s')s+="es";
  	else s+='s';
  	cout<<s<<'\n';    
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string a,b;
  cin>>a>>b;
  a=a+a;
  if(a.find(b)<a.size())
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define ALL(a) a.begin(), a.end()
static const int INF = 1000000007;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;

int d[205][205];

int main(){
    int n,m,r;
    cin >> n>> m>> r;
    vector<int> vec(r);
    rep(i,r){
        int R;
        cin >> R;
        R--;
        vec[i]=R;
    }
    sort(ALL(vec));
    rep(i,n)rep(j,n)d[i][j]=INF;
    rep(i,n)d[i][i]=0;
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        d[a][b]=c;
        d[b][a]=c;
    }
    rep(k,n)rep(i,n)rep(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    int ans=INF;
    do{
        int temp=0;
        rep(i,r-1){
            temp+=d[vec[i]][vec[i+1]];
        }
        ans=min(temp,ans);
    }while(next_permutation(ALL(vec)));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    ll N, A, B;
    cin >> N >> A >> B;

    ll ans = (A + B * (N - 1)) - (B + A * (N - 1)) + 1;
    print(max(0LL, ans));

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	double w,h,x,y;
	cin >> w >> h >> x >> y;

	double centerX,centerY;
	double s;
	int ans=0;
	centerX=w/2;
	centerY=h/2;
	s=w*h/2;
	if(x==centerX && y==centerY) ans=1;

	cout << fixed << s << " " << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var ab = Reads();
            var a = ab[0];
            var b = ab[1];
            var s = Console.ReadLine();
            var ans = "Yes";
            for (int i = 0; i < s.Length; i++)
            {
                bool f = false;
                if (i != a)
                {
                    for (int j = 0; j <= 9; j++)
                    {
                        char c = (char)('0' + j);
                        if (s[i] == c) f = true;
                    }
                }
                else if (s[i] == '-') f = true;

                if (!f) ans = "No";
            }
            Console.WriteLine(ans);


            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define pb push_back
#define F first
#define S second
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)

# define M_PIl          3.141592653589793238462643383279502884L /* pi */

const ll M=1e9+7;
const int MaxM=100005;


void SieveOfEratosthenes(int n)                                   //all prime <= n
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}


bool isPowerOfTwo (int x)
{
    return x && (!(x&(x-1)));
}



bool comp(pair<int,int> a,pair<int,int> b){
  if(a.F==b.F){
    return a.S>b.S;
  }
  return a.F<b.F;
}




void solve(){

int n;cin>>n;

double a[n];
double key =1.0;
for(int i=0;i<n;i++){
          cin>>a[i];
}

double dp[n+1][n+1]={0};

for(int i=0;i<=n;i++){dp[i][0]=0;}
    for(int j=0;j<=n;j++){dp[0][j]=0;}
        
        dp[0][0]=1;

for(int i=1;i<=n;i++){
    for(int j=0;j<=n;j++){
           if(j==0){
                dp[i][j]=dp[i-1][j]*(1.0-a[i-1]);
           }
           else{
            dp[i][j]=a[i-1]*dp[i-1][j-1] + dp[i-1][j]*(1.0-a[i-1]);
           }
    }
}
double ans=0;
for(int i=(n+1)/2;i<=n;i++){
    ans+=dp[n][i];
}

cout<<setprecision(10)<<ans;

}

int main(){


   int t=1;
//  cin>>t;
   while(t--){
      solve();
       }

 }


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

int max(int a, int b) { return a < b ? b : a; }
int board[2010][2010];
int main() {
    int N, K; scanf("%d%d", &N, &K);

    int sum = 0, white = 0;
    for(int i=0; i<N; i++) {
        int x, y; char c; scanf(" %d%d %c", &x, &y, &c);
        x %= 2*K, y %= 2*K;
        if(c == 'B') board[x+1][y+1]++, sum++;
        if(c == 'W') board[x+1][y+1]--, sum--, white++;
    }

    for(int i=1; i<=2*K; i++) {
        for(int j=1; j<=2*K; j++) {
            board[i][j] += board[i][j-1];
        }
    }

    for(int j=1; j<=2*K; j++) {
        for(int i=1; i<=2*K; i++) {
            board[i][j] += board[i-1][j];
        }
    }

    int ma = -(1 << 25);
    for(int i=0; i<=K; i++) {
        for(int j=0; j<=K; j++) {
            int a = board[i][j];
            int b = board[i+K][j+K] - board[i+K][j] - board[i][j+K] + board[i][j];
            int c = board[2*K][j] - board[i+K][j];
            int d = board[i][2*K] - board[i][j+K];
            int e = board[2*K][2*K] - board[2*K][j+K] - board[i+K][2*K] + board[i+K][j+K];
            int tmp = a + b + c + d + e;
            ma = max(ma, max(tmp, sum - tmp));
        }
    }
    ma += white;
    printf("%d\n", ma);
    return 0;
}

Measured memory_bytes: 17416
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            int n = int.Parse(In[0]);
            int l = int.Parse(In[1]);
            int sum = 0;
            int low = Int32.MaxValue;
            for(int i = l; i < l + n; i++)
            {
                sum += i;
                int a = (int)Math.Abs(i);
                if (a < (int)Math.Abs(low)) low = a;
            }
            if(sum>=0) Console.WriteLine(sum - low);
            else Console.WriteLine(sum + low);
        }
    }
}


Measured memory_bytes: 27456
h, w, k = map(int, input().split())
mod = 10**9+7

if w == 1:
    print(1)
    exit()

dp = [[0]*w for _ in range(h+1)]
dp[0][0] = 1
for i in range(1, h+1):
    for p in range(2**(w-1)):
        L = [0]*(w-1)
        for q in range(w-1):
            if (p >> q) & 1:
                L[q] = 1
        flag = True
        for q in range(w-2):
            if L[q] == 1 and L[q+1] == 1:
                flag = False
        if not flag:
            continue
        for j in range(w):
            if j == 0:
                if L[j] == 1:
                    dp[i][j] += dp[i-1][1]
                else:
                    dp[i][j] += dp[i-1][0]
            elif j == w-1:
                if L[j-1] == 1:
                    dp[i][j] += dp[i-1][w-2]
                else:
                    dp[i][j] += dp[i-1][w-1]
            else:
                if L[j-1] == 1:
                    dp[i][j] += dp[i-1][j-1]
                elif L[j] == 1:
                    dp[i][j] += dp[i-1][j+1]
                else:
                    dp[i][j] += dp[i-1][j]
            dp[i][j] %= mod

#print(dp)
print(dp[h][k-1])


Measured memory_bytes: 74292
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    long long int N;
    cin>>N;
    vector<long long int> A(N,0);
    vector<long long int> B(N,0);
    REP(i,N){
        cin>>A[i];
    }
    //条件終了
    long long int sum=0;
    REP(i,N){
        sum+=A[i];
    }
    long long int sumB=0;
    for(int i=0;i<N-1;i=i+2){
        sumB+=A[i]*2;
    }
    B[N-1]=sum-sumB;
    for(int i=N-2;i>=0;i--){
        B[i]=(A[i]-B[i+1]/2)*2;
    }
    REP(i,N){
        cout<<B[i]<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;

int main() {
  ll N,ans=1000;
  cin>>N;
  while(N>99){
    ll n=N%1000;
    //cout<<ans<<endl;
    if(n>753){
      n-=753;
    }
    else{
      n=753-n;
    }
    ans=min(ans,n);
    N/=10;
  }
  
  cout<<ans;
  
}


Measured memory_bytes: 256