akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <type_traits>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using ISS = istringstream;
using OSS = ostringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define NUMBERED( name, number ) NUMBERED2( name, number )
#define NUMBERED2( name, number ) name ## _ ## number
#define REP1( n ) REP2( NUMBERED( REP_COUNTER, __LINE__ ), n )
#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2, REP1 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a ) ( remove_all_extents< decltype( a ) >::type * )a, ( remove_all_extents< decltype( a ) >::type * )a + sizeof( a ) / sizeof( remove_all_extents< decltype( a ) >::type )
#define DRANGE( c, p ) begin( c ), begin( c ) + ( p ), end( c )

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

template < typename T > inline bool chmin( T &a, const T &b ){ if ( b < a ) { a = b; return true; } return false; }
template < typename T > inline bool chmax( T &a, const T &b ){ if ( a < b ) { a = b; return true; } return false; }

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );
	cout << setprecision( 12 ) << fixed;

	int N;
	cin >> N;

	string S, T;
	cin >> S >> T;

	REP( i, N + 1 )
	{
		if ( equal( begin( S ) + i, end( S ), begin( T ), end( T ) - i ) )
		{
			cout << 2 * N - ( N - i ) << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long,long>
#define pdd pair<double,double>
#define ff first
#define ss second
#define w(x) int x; cin>>x; while(x--)
using namespace std;
void ffast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
int main()
{
    ffast();
    int n;
    cin>>n;
    ll a,b,c;
    cin>>a>>b>>c;
    ll dp[n][3];
    dp[0][0] = a;
    dp[0][1] = b;
    dp[0][2] = c;
    for(int i=1;i<n;i++){
    	cin>>a>>b>>c;
    	dp[i][0] = a + max(dp[i-1][1],dp[i-1][2]);
    	dp[i][1] = b + max(dp[i-1][0],dp[i-1][2]);
    	dp[i][2] = c + max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}

Measured memory_bytes: 5900
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    A = list(map(int, input().split()))
    total = sum([A[j] * B[j] for j in range(M)])
    if total + C > 0:
        ans += 1
print(ans)


Measured memory_bytes: 2940
#include <iostream>
 
using namespace std;
 
int main() {
  int h, w;
  while (true){
      cin >> h >> w;
      if (h == 0 && w == 0) break;
      for ( int i = 0; i < h; i++ ){
        for ( int j = 0; j < w; j++ ){
          cout << "#";
        }
        cout << endl;
      }
      cout << endl;
    }
  return 0;
}

Measured memory_bytes: 1152
s = input()
k = int(input())
m = 0
n = 0
j = 0
for i in range(len(s)):
    if s.count(s[0]) == len(s):
        print(len(s) * k // 2)
        exit()
    if len(s) <= j + 1:
        if s[0] == s[-1] == s[-2]== s[-3]== s[-4]== s[-5]== s[len(s)//3] \
                and s[0] == s[1] == s[2]== s[3]== s[4]== s[5]:
            n+=1
        break
    if s[j] == s[j + 1]:
        if j == len(s) - 1:
            n += 1
        else:
            m += 1
        j += 1
    j += 1
print(m * k + n*(k-1))


Measured memory_bytes: 3064
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});    
    var n = parseInt(input[0][0], 10);
    var m = parseInt(input[0][1], 10);
    var v_price = [];
    var arr_dp = [Array.from({length: n + 1}, () => Number.MAX_SAFE_INTEGER)];
    arr_dp[0][0] = 0;
    var tmp;
    for (var i = 0; i < m; i++){
        v_price.push(parseInt(input[1][i]));
        tmp = v_price[i];
        arr_dp.push([]);
        for (var j = 0; j <= n; j++){
            if (j < tmp) arr_dp[i + 1].push(arr_dp[i][j]);
            if (j >= tmp){
                arr_dp[i + 1].push(Math.min(arr_dp[i][j], arr_dp[i + 1][j - tmp] + 1));
            }
        }
    }
    console.log(arr_dp[m][n]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 


Measured memory_bytes: 43364
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

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

	vector<int> a(3, 0), b(3);
	rep(i, 0, 3)b[i] = c[0][i];
	rep(i, 1, 3)a[i] = c[i][0] - b[0];

	bool flag = true;
	rep(i, 1, 3) {
		rep(j, 1, 3) {
			if (c[i][j] != a[i] + b[j])flag = false;
		}
	}

	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}

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

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

  for (ll k = 1; k * k <= N; k++) {
    // N = k(m + 1) ( k < m )
    if (N % k == 0) {
      ll m = N / k - 1;
      if (k < m) ans += m;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main extends PrintWriter {
    Main()
    {
        super(System.out);
    }
    public static void main(String args[]) {
      Main o=new Main();
      o.main();
      o.flush();
      o.close();
    }
    void main()
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int arr[]=new int[n];
        int i,j,k;
        for(i=0;i<n;i++)
        arr[i]=sc.nextInt();
        int c=0;
        for(i=0;i<n;i++)
        {
            for(j=i+1;j<n;j++)
            {
                if(arr[i]!=arr[j])
                {
                for(k=j+1;k<n;k++)
                {
                    if(arr[j]!=arr[k] && arr[i]!=arr[k])
                    {
                        if((arr[i]+arr[j]>arr[k]) && (arr[i]+arr[k]>arr[j]) && (arr[j]+arr[k]>arr[i]))
                        c++;
                    }
                }
                }
            }
        }
        println(c);
        sc.close();
    }
}

Measured memory_bytes: 36552
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll A,B,C,D;

void solve(){
    cout << min(A,B) + min(C,D) << endl;
}

int main(){
    cin >> A >> B >> C >> D;

    solve();
}

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

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int b = int.Parse(input[0]);
            int c = int.Parse(input[1]);

            if (b % 3 == 0 || c % 3 == 0 || (b + c) % 3 == 0)
            {
                Console.WriteLine("Possible");
            }
            else
            {
                Console.WriteLine("Impossible");
            }
        }
    }
}


Measured memory_bytes: 11092
n,d=map(int,input().split())
x=[0]*n
for i in range(n):
  x[i]=list(map(int,input().split()))
  
def f(i):
  return (i**0.5-int(i**0.5))==0.0
  
ans=0
for i in range(n):
  for j in range(i+1,n):
    dist=0
    for k in range(d):
      dist+=(x[i][k]-x[j][k])**2
    ans+=1 if f(dist) else 0
print(ans)


Measured memory_bytes: 9460
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int N, K, Q;
vector<long long> A;

int main() {
    while (cin >> N >> K >> Q) {
        A.resize(N);
        for (int i = 0; i < N; ++i) cin >> A[i];

        long long res = 1LL<<60;
        for (int i = 0; i < N; ++i) {
            vector<long long> vec;
            vector<long long> tmp;
            for (int j = 0; j < N; ++j) {
                if (A[j] < A[i]) {
                    if (tmp.size() >= K) {
                        sort(tmp.begin(), tmp.end());
                        for (int k = 0; k < (int)tmp.size() - (K-1); ++k) {
                            vec.push_back(tmp[k]);
                        }
                    }
                    tmp.clear();
                }
                else {
                    tmp.push_back(A[j]);
                }
            }
            if (tmp.size() >= K) {
                sort(tmp.begin(), tmp.end());
                for (int k = 0; k < (int)tmp.size() - (K-1); ++k) {
                    vec.push_back(tmp[k]);
                }
            }
            
            //cout << i << ", " << A[i] << ": " << vec << endl;
            
            sort(vec.begin(), vec.end());
            if (vec.size() >= Q) {
                chmin(res, vec[Q-1] - vec[0]);
            }
        }
        
        cout << res << endl;
    }
}
























Measured memory_bytes: 384
nums =input().rstrip().split(" ")
tate=int(nums[0])
yoko=int(nums[1])
if tate==1 or yoko==1:
    masu=1
elif yoko%2==0:
    masu=int(yoko/2)*tate
elif yoko%2==1:
    masu=yoko*int(tate/2)+(tate%2)*int((yoko+1)/2)
print(masu)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    if(abs(a-b)%2==0)cout<<"Alice"<<endl;
    else cout<<"Borys"<<endl;
    return 0;
}


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

int n, m, q;
int a[55], b[55], c[55], d[55];

int ans;

void dfs(vector<int> &v){
	if(v.size() == n+1){
		int score = 0;
		rep(i,q){
			if(v[b[i]] - v[a[i]] == c[i]) score += d[i];
		}
		chmax(ans, score);
		return;
	}
	int bck = v.back();
	for(int nex = bck; nex <= m; ++nex){
		v.push_back(nex);
		dfs(v);
		v.pop_back();
	}
	return;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m >> q;
	rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	ans = 0;
	vector<int> v(1, 1);
	dfs(v);
	cout << ans << endl;
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

template<typename T> bool chmax(T &a,const T b){if(a < b){a=b; return true;} return false;}
template<typename T> bool chmin(T &a,const T b){if(a > b){a=b; return true;} return false;}

const int MAX_N=10010010;
int par[MAX_N]; 
int depth[MAX_N];

void init(int n){
    for(int i=0; i<n; i++){
        par[i]=i;
        depth[i]=0;
    }
}

int find(int x){
    if(par[x] == x) return x;
    else return par[x]=find(par[x]);
}

void unite(int x, int y){
    x=find(x), y=find(y);
    if(x == y) return;

    if(depth[x] < depth[y]) par[x]=y;
    else{
        par[y]=x;
        if(depth[x] == depth[y]) depth[x]++;
    }
}

bool same(int x, int y){
    return find(x) == find(y); 
}

int main(){
    int N, M; cin >> N >> M;
    init(N);
    for(int i=0; i<M; i++){
        int A, B; cin >> A >> B;
        A--, B--;
        unite(A, B);
    }
    int ans=1;
    vi size(N, 0);
    for(int i=0; i<N; i++){
        chmax(ans, ++size[find(i)]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5584
#include<iostream>
#include <vector>
#include<algorithm>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(),v,end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ac, ad, bc, bd;
	ac = (a - 1) / c;
	ad = (a - 1) / d;
	bc = b / c;
	bd = b / d;

	ll k = c * d;
	if (d > c) swap(c, d);
	ll r = c % d;
	while (r != 0) {
		c = d;
		d = r;
		r = c % d;
	}
	k /= d;
	k = b / k - (a - 1) / k;
	ll ans = (b - a + 1) - ((bc - ac) + (bd - ad) - k);
	cout << ans << endl;
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;


void Solve() {
	UL a, b, c; cin >> a >> b >> c;
	if (a + b + c > 21) cout << "bust" << endl;
	else  cout << "win" << endl;
}

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

Measured memory_bytes: 256
def main():
    import math

    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(input())
    ABCD = [list(map(int, input().split())) for i in range(N)]
    for A,B,C,D in ABCD:
        # 在庫が買う本数以下 or 在庫追加が買う本数以下
        if A < B or D < B:
            print("No")
            continue

        A %= B
        # 在庫が買う本数以下になり、補給出来ない
        if C < A:
            print("No")
            continue
        if B == D:
            print("Yes")
            continue

        flag = True
        #print((B-A-1)%(D-B) ,">", (B-1)-(C+1))
        if (B-A-1)%(gcd(D,B)) <= (B-1)-(C+1):
            flag = False
        
        print("Yes" if flag else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mod 1000000007


int vec[100005][3];
vector<int> a, b, c;

int dp(int pos, int sel, int n)
{
    if(vec[pos][sel-1]!=-1)
        return vec[pos][sel-1];
    if(pos==n)
        return vec[pos][sel-1]=0;
    if(sel==1)
        return vec[pos][sel-1]=a[pos]+max(dp(pos+1, 2, n), dp(pos+1, 3, n));
    if(sel==2)
        return vec[pos][sel-1]=b[pos]+max(dp(pos+1, 1, n), dp(pos+1, 3, n));
    if(sel==3)
        return vec[pos][sel-1]=c[pos]+max(dp(pos+1, 1, n), dp(pos+1, 2, n));
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        vec[i][0]=vec[i][1]=vec[i][2]=-1;
        int x, y, z;
        cin>>x>>y>>z;
        a.pb(x);
        b.pb(y);
        c.pb(z);
    }
    cout<<max(max(dp(0, 1, n), dp(0, 2, n)), dp(0, 3, n));
    return 0;
}

Measured memory_bytes: 9952
#include <atcoder/fenwicktree>
#include <cstdio>

using namespace std;
using namespace atcoder;


int main(){
  int n, q;
  scanf("%d %d", &n, &q);
  
  fenwick_tree<long long> fw(n);
  for (int i = 0; i < n; i ++) {
    int a;
    scanf("%d", &a);
    fw.add(i, a);
  }
  
  for (int i = 0; i < q; i ++) {      
    int t, u, v;
    scanf("%d %d %d", &t, &u, & v);
    if (t == 0){
      fw.add(u, v);
    }
    else{
      printf("%lld\n", fw.sum(u, v));
    }
    
  }
    
  return 0;
  
}  

Measured memory_bytes: 8216
# include <iostream>


using namespace std;


int main() {
    int n; cin >> n;
    for (int i=1; i<=9; i++) {
        for (int j=1; j<=9; j++) {
            if (i*j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}



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

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var n = rint();
        long ans = 0;
        for (long i = 1; i <= n; i++)
        {
            for (long j = 1; j <= n; j++)
            {
                long g = GCD(i, j);
                for (long k = 1; k <= n; k++)
                {
                    long gk = GCD(g, k);
                    ans += gk;
                }
            }
        }

        Write(ans);
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


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

int main(void){
  
  long long int A,B,V,W,T;
  cin >> A >> W;
  cin >> B >> V;
  cin >> T;
  if(abs(A-B)<=T*(W-V)){
    cout << "YES" << endl;
  }else{
	cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x;
  cin >> x;
  ll ans = 0;
  ans += x / 11 * 2;
  x %= 11;
  if(x > 6)
    ans += 2;
  else if(x > 0)
    ans += 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
z1=max(x)+1
z2=min(y)
flag=False
if z1>z2:
    print('War')
else:
    for i in range(z1,z2+1):
        if X<i<=Y:
            flag=True
            break
    if flag:
        print('No War')
    else:
        print('War')

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){

    int a, b, c;
    scanf("%d %d\n", &a, &b);
    
    if(a < b)
        printf("a < b\n");
    if(a > b)
        printf("a > b\n");
    if(a == b)
        printf("a == b\n");
    
    return 0;
}


Measured memory_bytes: 2032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws java.lang.Exception {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int a[][] = new int[n][m];
		int b[] = new int[m];
		int c[] = new int[n];

		for(int i=0; i<n; i++) {
			for(int j=0; j<m; j++) {
				a[i][j] = sc.nextInt();
			}
		}

		for(int i=0; i<m; i++) {
			b[i] = sc.nextInt();
		}

		for(int i=0; i<n; i++) {
			for(int j=0; j<m; j++) {
				c[i] += a[i][j] * b[j];
			}
			System.out.println(c[i]);
		}
	}

}



Measured memory_bytes: 40312
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    static readonly int Mod = (int)1e9 + 7;
    static void Add(ref long a, long b) { if ((a += b) >= Mod) a -= Mod; }

    public void Solve()
    {
        int N = Reader.Int(), C = Reader.Int();
        var A = Reader.IntArray(N);
        var B = Reader.IntArray(N);

        int Bmax = B.Max();
        var powSum = new long[Bmax + 1, C + 1];
        for (int x = 1; x <= Bmax; x++)
            for (long n = 0, p = 1; n <= C; n++, p = p * x % Mod)
                powSum[x, n] = (powSum[x - 1, n] + p) % Mod;

        var dp = new long[C + 1];
        dp[0] = 1;
        for (int i = 0; i < N; i++)
        {
            var nextdp = new long[C + 1];
            for (int sum = 0; sum <= C; sum++)
                for (int add = 0; sum + add <= C; add++)
                {
                    long v = (Mod + powSum[B[i], add] - powSum[A[i] - 1, add]) % Mod;
                    Add(ref nextdp[sum + add], v * dp[sum] % Mod);
                }
            dp = nextdp;
        }

        Console.WriteLine(dp[C] % Mod);
    }

}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

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

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

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

            Graph graph = new Graph(n);
            for (int i = 0; i < n - 1; i++) {
                int from = in.nextInt() - 1;
                int to = in.nextInt() - 1;

                graph.addUndirectedEdge(from, to);
            }

            int[] d1 = new int[n];
            rec(graph, d1, 0, -1);

            int[] d2 = new int[n];
            rec(graph, d2, n - 1, -1);

            int cnt1 = 0;
            int cnt2 = 0;
            for (int i = 0; i < n; i++) {
                if (d1[i] <= d2[i]) cnt1++;
                else cnt2++;
            }

            out.println(cnt1 > cnt2 ? "Fennec" : "Snuke");
        }

        private void rec(Graph graph, int[] d1, int from, int parent) {
            for (int to : graph.get(from)) {
                if (to != parent) {
                    d1[to] = d1[from] + 1;
                    rec(graph, d1, to, from);
                }
            }
        }

    }

    static class Graph {
        int n;
        ArrayList<Integer>[] G;

        public Graph(int n) {
            this.n = n;
            G = new ArrayList[n];
            for (int i = 0; i < n; i++) {
                G[i] = new ArrayList<>();
            }
        }

        public void addUndirectedEdge(int from, int to) {
            G[from].add(to);
            G[to].add(from);
        }

        public ArrayList<Integer> get(int from) {
            return G[from];
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

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

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

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

    }
}



Measured memory_bytes: 76140
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>

using namespace std;

/*
int maxflow(const vector<vector<pair<int, int> >  > &flow_v, int s, int g) {
    const int size = flow_v.size();

    vector<vector<int> > capacity(size, vector<int>(size, 0));
    for(int i = 0; i < size; ++i) {
        for(int j = 0; j < flow_v[i].size(); ++j) {
            int to = flow_v[i][j].first;
            int cost = flow_v[i][j].second;
            capacity[i][to] = cost;
        }
    }
    vector<vector<int> > flow(size, vector<int>(size, 0));

    int ans = 0;
    while(true) {
        queue<int> q;
        vector<int> prev(size, -1);
        prev[s] = s;
        q.push(s);
        while(!q.empty()) {
            int n = q.front();
            q.pop();
            for(int i = 0; i < size; ++i) {
                if(capacity[n][i] - flow[n][i] <= 0) continue;
                if(prev[i] != -1) continue;
                prev[i] = n;
                q.push(i);
                if(i == g) goto endloop;
            }
        }
endloop:
        if(prev[g] == -1) break;
        int res = INT_MAX;
        for(int i = g; prev[i] != i; i = prev[i]) {
            res = min(res, capacity[prev[i]][i]-flow[prev[i]][i]);
        }
        for(int i = g; prev[i] != i; i = prev[i]) {
            flow[orev[i]][i] += res;
            flow[i][prev[i]] -= res;
        }
        ans += res;
    }
    return ans;
}
*/

int main() {
    ios::sync_with_stdio(0);
    int N, M;
    cin >> N >> M;

    vector<vector<int> > v(N+1, vector<int>(N+1, 0));
    vector<vector<int> > d(N+1, vector<int>(N+1, 0));
    vector<vector<int> > num(N+1, vector<int>(N+1, 0));
    for(int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        v[x][y] = v[y][x] = 1;
        d[x][y] = 1;
        num[x][y] = num[y][x] = i+1;
    }

    int S, G;
    cin >> S >> G;

    int ans = 0;
    vector<int> flips;
    while(true) {
        bool modified = false;

        queue<int> q;
        vector<int> prev(N+1, -1);
        prev[S] = 0;
        q.push(S);
        while(!q.empty()) {
            int p = q.front();
            q.pop();

            if(p == G) {
                ++ans;
                int cur = p;
                while(cur != S) {
                    if(!d[prev[cur]][cur]) {
                        flips.push_back(num[prev[cur]][cur]);
                    }
                    v[cur][prev[cur]] = v[prev[cur]][cur] = 0;
                    cur = prev[cur];
                }
                modified = true;
                break;
            }

            for(int i = 0; i < N+1; ++i) {
                if(v[p][i] && prev[i] == -1) {
                    prev[i] = p;
                    q.push(i);
                }
            }
        }
        if(!modified) break;
    }

    cout << ans << endl;
    cout << flips.size() << endl;;
    for(int i = 0; i < flips.size(); ++i) {
        cout << flips[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 0
# 20:42
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
dic = {'r':p, 's':r, 'p':s}
t1 = ['']*n
score = 0
for i in range(k):
    score += dic[t[i]]
    t1[i] = t[i]
for i in range(k,n):
    if t[i] != t1[i-k]:
        score += dic[t[i]]
        t1[i] = t[i]
    else:
        t1[i] = 'x'
print(score)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define INF 100000000

int dp[260][1005];

int main(){
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<int> v;
  rep(i,N){
    int l;
    cin >> l;
    v.push_back(l);
  }

  sort(ALLOF(v));

  rep(i,260) rep(j,1005) dp[i][j] = INF;
  
  for(int S=1; S<(1<<N); S++){
    int sum = 0;
    int cnt = 0;
    rep(i,N){
      if((S>>i)&1){
        sum += v[i];
        cnt++;
      }
    }
    rep(i,1005){
      dp[S][i] = (cnt-1) * 10 + abs(sum-i);
    }
  }

  int ret = INF;
  
  REP(a,1,(1<<N)){
    REP(b,1,(1<<N)){
      REP(c,1,(1<<N)){
        if((a & b) != 0 || (a & c) != 0 || (b & c) != 0) continue;
        ret = min(ret, dp[a][A] + dp[b][B] + dp[c][C]);
      }
    }
  }

  cout << ret << endl;
  
  return 0;
}



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

typedef long long ll;

vector<ll> score(int D, vector<ll> c, vector<ll> t, vector<vector<ll>> s) {
    vector<vector<ll>> last(D + 1, vector<ll>(26, 0));
    vector<ll> ret(D);
    ll p = 0;
    rep(d, D) {
        p += s[d][t[d] - 1];
        rep(i, 26) last[d + 1][i] = last[d][i];
        last[d + 1][t[d] - 1] = d + 1;
        rep(i, 26) {
            p -= c[i] * (d + 1 - last[d + 1][i]);
        }
        ret[d] = p;
    }
    return ret;
}

int main() {
    int D;
    cin >> D;
    vector<ll> c(26), t(D);
    rep(i, 26) cin >> c[i];
    vector<vector<ll>> s(D, vector<ll>(26)), last(D + 1, vector<ll>(26, 0));
    rep(i, D) rep(j, 26) cin >> s[i][j];
    ll p = 0;
    rep(d, D) {
        ll q, r = 0, maxq = -1e18;
        rep(j, 26) {
            q = s[d][j];
            rep(i, 26) last[d + 1][i] = last[d][i];
            last[d + 1][j] = d + 1;
            rep(i, 26) {
                q -= c[i] * (d + 1 - last[d + 1][i]);
            }
            if (q > maxq) {
                maxq = q;
                r = j;
            }
        }
        t[d] = r + 1;
        p += maxq;
        rep(i, 26) last[d + 1][i] = last[d][i];
        last[d + 1][r] = d + 1;
    }
    auto ans = score(D, c, t, s);
    ll maxs = ans.back();
    //cout << maxs << "\n";
    rep(j, min(D - 1, 100)) rep(i, D - 1 - j) {
        swap(t[i], t[i + 1 + j]);
        ans = score(D, c, t, s);
        if (ans.back() > maxs) {
            maxs = ans.back();
        } else {
            swap(t[i], t[i + 1 + j]);
        }
    }
    rep(i, D) cout << t[i] << "\n";
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}


template<typename T>
struct edge {
  int src, to;
  T cost;
  // edge(int src, int to, T cost): src(src), to(to), cost(cost) {}
  // // G[i].push_back({src, to, cost}) requires no constructor
};

template<typename T>
using Graph = vector<vector<edge<T>>>;


vi pr;
template<typename T>
vector<T> dijkstra(const Graph<T> &g, int s) {
  const auto INF = numeric_limits<T>::max();
  vector<T> d(g.size(), INF);

  using Pi = pair<T, int>;
  priority_queue<Pi, vector<Pi>, greater<Pi>> que;
  d[s] = 0;
  que.emplace(d[s], s);
  while (!que.empty()) {
    T cost;
    int v;
    tie(cost, v) = que.top();
    que.pop();
    if (d[v] < cost) continue;
    for (auto &e : g[v]) {
      auto nxt = cost + e.cost;
      if (d[e.to] > nxt) {
        d[e.to] = nxt;
        pr[e.to] = v;
        que.emplace(nxt, e.to);
      }
    }
  }
  return d;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, m; cin >> n >> m;
  Graph<int> g(n);
  REP(i, m) {
    int u, v; cin >> u >> v;
    u--; v--;
    g[u].push_back({u, v, 1});
    g[v].push_back({v, u, 1});
  }

  pr.resize(n, -1);
  auto d = dijkstra(g, 0);

  REP(i, n) {
    if(d[i] == INT_MAX) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  FOR(i, 1, n) {
    cout << pr[i]+1 << endl;
  }

}
























Measured memory_bytes: 15364
#include<stdio.h>
int main(void)
{
	int H,W;
	int i,j;
	
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0)break;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
/*Program from Luvwgyx*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const ll  inf=1e18;
const int maxn=2e5+10;
const int maxm=1e2+10;
char s[maxn];int n,lst,nxt[maxn],pre[maxn][26];
ll l,r,cutpos,ans[26],cnt[maxm],f[maxm][26];
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(ll x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(ll x){print(x);putchar(' ');}
void get_nxt(){
    nxt[1]=0;
    for(int i=2,j;i<=n;i++){
        j=nxt[i-1];
        while(j&&s[j+1]!=s[i])j=nxt[j];
        nxt[i]=s[j+1]==s[i]?j+1:0;
    }
}
void cal1(ll x,ll v){
    if(x<=0)return ;ll tmp=x/cutpos;
    for(int i=0;i<26;i++)ans[i]+=v*tmp*pre[cutpos][i];
    tmp=x%cutpos;
    for(int i=0;i<26;i++)ans[i]+=v*pre[tmp][i];
}
void get_fib(){
    cnt[1]=n;
    for(int i=1;i<=n;i++){f[1][s[i]-'a']++;f[2][s[i]-'a']++;}
    cnt[2]=n+cutpos;
    for(int i=0;i<26;i++)f[2][i]+=pre[cutpos][i];
    for(int i=3;;i++){
        for(int j=0;j<26;j++)f[i][j]=f[i-2][j]+f[i-1][j];
        cnt[i]=cnt[i-2]+cnt[i-1];if(cnt[i]>inf){lst=i;break;}
    }
}
void cal2(ll x,ll v){
    for(int i=lst;i>=1;i--)
        if(cnt[i]<=x){
            x-=cnt[i];
            for(int j=0;j<26;j++)ans[j]+=v*f[i][j];
        }
    for(int i=0;i<26;i++)ans[i]+=v*pre[x][i];
}
int main(){
    scanf("%s",s+1);l=read();r=read();n=strlen(s+1);n>>=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<26;j++)pre[i][j]+=pre[i-1][j];
        pre[i][s[i]-'a']++;
    }get_nxt();cutpos=n-nxt[n];
    if(!n%cutpos){cal1(r,1);cal1(l-1,-1);}
    else {get_fib();cal2(r,1);cal2(l-1,-1);}
    for(int i=0;i<26;i++)write(ans[i]);
    return 0;
}

Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
	int a;
  	int d = 0;
  	cin >> a;
  	
  	if(a >= 100){
      d++;
      a = a - 100;
    }
      if(a >= 10){
        d++;
      a = a -10;
      }
	if(a == 1)
      d++;
  	cout << d << endl;
  

}

Measured memory_bytes: 256
import sys
from fractions import gcd

input = sys.stdin.readline

def lcm(x, y):
    return (x*y) // gcd(x, y)

def main():
    A, B, C, D = map(int, input().split())
    
    c = B // C - A // C + (not A % C)
    d = B // D - A // D + (not A % D)
    
    x = lcm(C, D)
    x = B // x - A // x + (not A % x)
    
    print(B-A+1-c-d+x)
    
if __name__ == '__main__':
    main()
    

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

int n;

int main(){
	cin >> n;
	int ans = 0;
	if(n < 10) ans = n;
	else if(n < 100)ans = 9;
	else if(n < 1000)ans = 9 + (n - 100 + 1);
	else if(n < 10000)ans = 909;
	else if(n < 100000)ans = 909 + (n - 10000 + 1);
	else ans = 90909;
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n,x;
    cin >> n >> x;
    int a[101];
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a, a+n);
    int ans = 0;
    for(int i=0;i<n;i++){
        if(i==n-1){
            if(a[i]==x) ans++;
        }
        else if(a[i] <= x){
            ans++;
            x -= a[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define y1 as214
#define ii pair < int , ll >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)

#define ll long long
#define oo INT_MAX

/// dp[i][j] số tổng điểm đạt được vs i đồng xu đầu và trong đó có j đồng xu là tail.

const int N = 3e3 + 5;
int n;
long double a[N];
long double dp[N][N];
long double res;

int main()
{
    //freopen("I.inp","r",stdin);
    cin >> n;
    FOR(i , 1 , n)
        cin >> a[i];
    dp[1][0] = a[1];
    dp[1][1] = 1 - a[1];
    FOR(i , 2 , n)
    {
        FOR(j , 0 , n / 2)
        {
            if(j == 0)
                dp[i][j] += dp[i - 1][j] * a[i];
            else
                dp[i][j] += (dp[i - 1][j - 1] * (1 - a[i]) + dp[i - 1][j] * a[i]);
        }
    }
    FOR(i , 0 , n / 2)
        res += dp[n][i];
    cout << setprecision(10) << fixed << res << endl;
}


Measured memory_bytes: 139648
#145_E
n, t = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]

#dp1[i][j] ... 1~iでj分以内の最大値
#dp2[i][j] ... i~nでj分以内の最大値
dp1 = [[0 for _ in range(t)] for _ in range(n+1)]
dp2 = [[0 for _ in range(t)] for _ in range(n+2)]

for i in range(1, n+1):
    a, b = ab[i-1]
    for j in range(1, t):
        if j - a >= 0:
            dp1[i][j] = max(dp1[i-1][j], dp1[i-1][j-a] + b)
        else:
            dp1[i][j] = dp1[i-1][j]

for i in range(n, 0, -1):
    a, b = ab[i-1]
    for j in range(1, t):
        if j - a >= 0:
            dp2[i][j] = max(dp2[i+1][j], dp2[i+1][j-a] + b)
        else:
            dp2[i][j] = dp2[i+1][j]

ans = 0
for i in range(1, n+1):
    b = ab[i-1][1]
    for j in range(0, t):
        x = dp1[i-1][j] + dp2[i+1][t-j-1] + b
        ans = max(ans, x)

print(ans)

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

#define LL long long
#define ULL unsigned long long
LL INF=10000000000000001LL;
#define PI 2.0*acos(0.0)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define READ 		freopen("in.txt","r",stdin)
#define WRITE  		freopen("out.txt","w",stdout)
#define BOOST		ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sf 			scanf
#define pf 			printf
#define F  			first
#define S  			second
#define pb 			push_back
#define NL			pf("\n")
#define ALL(v)		v.begin(),v.end()
#define si(x)		sf("%d",&x);
#define sii(x,y)	sf("%d%d",&x,&y);
#define siii(x,y,z)	sf("%d%d%d",&x,&y,&z);
#define sl(x)		sf("%lld",&x);
#define sll(x,y)	sf("%lld%lld",&x,&y);
#define slll(x,y,z)	sf("%lld%lld%lld",&x,&y,&z);
#define clr(x,y) 	memset(x,y,sizeof (x) )
#define ch 			printf("Came Here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
#define SV(v)		sort(v.begin(),v.end())
#define SVR(v,cmp)	sort(v.begin(),v.end(),cmp)
#define FOR(i,n)	for(int i=0;i<n;i++)
#define cnd			tree[idx]
#define lc			tree[idx*2]
#define rc			tree[idx*2+1]
#define lnd 		(2*idx),(b),((b+e)/2)
#define rnd 		((2*idx)+1),(((b+e)/2)+1),(e)
// graph direction array [4]
LL X[4]={0,0,1,-1};
LL Y[4]={1,-1,0,0};
// graph direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Bishop direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Knight Direction Array
//int KX[8] = {1,1,2,2,-1,-1,-2,-2};
//int KY[8] = {2,-2,1,-1,2,-2,1,-1};

bool Check(int N,int pos){return (bool)(N & (1<<pos));} // check bit
int Set(int N,int pos){	return N=N | (1<<pos);}// set bit

const LL mod=1000000000+7;
LL modMul(LL a, LL b){

//	return (a%mod * b%mod)%mod;
    LL ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}

LL powerMod(LL a,LL b){
	if(b==0)return 1%mod;
	LL x=powerMod(a,b/2);
	x = (x%mod*x%mod)%mod;
//	x = modMul( x,x )%mod;
	if(b%2==1){
		x = (x%mod*a%mod)%mod;
//		x = modMul(x,a)%mod;
	}
	return x%mod;
}

LL lcm( LL a,LL b ){
	LL g = __gcd(a,b);
	return (a*b)/g;
}
const int mx = 300005;
// ----------------------------------------------

int A[2005];


int main(){
//  READ;
//  WRITE;
//	BOOST;
    int t,n,m,k;
    si(n);
    FOR(i,n)si(A[i]);
    int sum = 0;
    FOR(i,n)sum += A[i];
    if( sum%2 ) sum = sum/2 + 1;
    else sum /= 2;
    bitset<4000005> bits;
    bits[0] = 1;
    FOR(i,n)bits |= (bits<<A[i]);
    for(int i=sum;i<4000001;i++){
		if(bits[i]){
            pf("%d\n",i);
            break;
		}
    }



    return 0;
}



Measured memory_bytes: 1664
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<double> as(n); cin >> as;
    double ans = 0;
    for(auto& a : as){
        ans += 1 / a;
    }
    cout << fixed << setprecision(20) << 1 / ans << '\n';
}


Measured memory_bytes: 888
n = int(input())
b = list(map(int,input().split()))
ans = [min(x,y) for x,y in zip(b[:-1],b[1:])]

if n>2:
    ans.insert(0,b[0])
    ans.insert(n-1,b[n-2])
    print(sum(ans))
else:
    ans.insert(0,b[0])
    ans.insert(n-2,b[0])
    print(sum(ans))


Measured memory_bytes: 3060