akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

const static char weekdays[][4] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
const static char times[][6] = {"Day","Night"};

const char* compute_weekday(int minutes){
  int tmp = (minutes / (60 * 24)) % 7;
  return weekdays[tmp];
}

const char* compute_time_band(int minutes){
  int idx = 0;
  int tmp = minutes % (60 * 24);
  if(tmp >= 6 * 60
     && tmp < 18 * 60){
    idx = 0;
  }
  else{
    idx = 1;
  }
  return times[idx];
}


int main(){
  int wait_hatch;
  int num_of_egg;
  int stage_life;
  char mutation_weekday[4];
  char mutation_time_band[6];
  int inv_mutation_prob;
  int total_stages;
  double probs[101];
  while(~scanf("%d %d %d %s %s %d %d",
               &wait_hatch,
               &num_of_egg,
               &stage_life,
               mutation_weekday,
               mutation_time_band,
               &inv_mutation_prob,
               &total_stages)){
    
    if(total_stages == 0) break;

    probs[0] = 1.0;
    for(int i=0;i<num_of_egg;i++){
      probs[i+1] = probs[i] * (1.0 - 1.0/inv_mutation_prob);
    }

    double res = 0.0;
    for(int start=0; start < 60 * 24 * 7;start++){
      int init_start = start;
      double prob = 1.0;
      
      for(int round = 0; round < total_stages; round++){
        int time = init_start + wait_hatch;

        if(strcmp(mutation_weekday,"All") != 0
           && strcmp(compute_weekday(time),mutation_weekday) != 0){
          init_start += stage_life;
          continue;
        }

        if(strcmp(mutation_time_band,"All") != 0
           && strcmp(compute_time_band(time),mutation_time_band) != 0){
          init_start += stage_life;
          continue;
        }

        if(strcmp(mutation_weekday,"All") != 0
           && strcmp(compute_weekday(init_start),compute_weekday(time)) != 0){
          init_start += stage_life;
          continue;
        }
        if(strcmp(mutation_time_band,"All") != 0
           && strcmp(compute_time_band(init_start),compute_time_band(time)) != 0){
          init_start += stage_life;
          continue;
        }

        prob *= probs[num_of_egg];
        init_start += stage_life;
      }
      res = max(res,1.0-prob);
    }
    printf("%.10f\n",res);
  }
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  int ans=0;
  for(int i=1;i<n-1;i++){
    if(a[i-1]<a[i]&&a[i]<a[i+1]) ans++;
    if(a[i-1]>a[i]&&a[i]>a[i+1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  cout << 180 * (n - 2) << endl;
}


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

int main(){
	int n, k, a[100010];
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> a[i];
	/*
	int c = n / (k-1);
	if(n % (k-1) == 0 || n % (k-1) == 1) cout << c << "\n";
	else cout << c + 1 << "\n";
	*/

	for(int g = 1; g <= 1000000000; g++){
		if(n <= k + (k-1)*(g-1)) {
			cout << g << "\n";
			break;
		}
	}
	
	return 0; 
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;
const int N = 10;

bool dfs(int cards[N], int now, int cnt3, int cnt2){
    if(cnt3 == 4 && cnt2 == 1) return true;
    else if(now >= N) return false;
    else{
        bool ret = false;

        if(cnt3 < 4){
            if(cards[now] >= 3){
                REP(i, 3) cards[now]--;
                ret = max(ret, dfs(cards, now, cnt3 + 1, cnt2));
                REP(i, 3) cards[now]++;
            }
            if(now <= 7 && cards[now] && cards[now + 1] && cards[now+ 2]){
                REP(i, 3) cards[now + i]--;
                ret = max(ret, dfs(cards, now, cnt3 + 1, cnt2));
                REP(i, 3) cards[now + i]++;
            }
        }
        if(!cnt2 && cards[now] >= 2){
            REP(i, 2) cards[now]--;
            ret = max(ret, dfs(cards, now, cnt3, cnt2 + 1));
            REP(i, 2) cards[now]++;
        }
        ret = max(ret, dfs(cards, now + 1, cnt3, cnt2));
        return ret;
    }
}


int main(){
    string str;
    while(cin >>str){
        int cards[N] = {0};
        REP(i, str.size()) cards[str[i] - '0']++;

        vector<int> ans;
        FOR(i, 1, N){
            if(cards[i] > 3) continue;
            cards[i]++;
            if(dfs(cards, 1, 0, 0)) ans.push_back(i);
            cards[i]--;
        }

        if(ans.size() == 0) cout <<0 <<endl;
        else{
            sort(ans.begin(), ans.end());
            REP(i, ans.size()){
                if(i == 0) cout <<ans[i];
                else cout <<" " <<ans[i];
            }
            cout <<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1204
N,W = map(int,input().split())
v = [[] for _ in range(4)]
w0,vv = map(int,input().split())
v[0].append(vv)
for _ in range(N-1):
    ww,vv = map(int,input().split())
    v[ww-w0].append(vv)
for i in range(4):
    v[i].sort(reverse=True)
cum =[[0] for _ in range(4)]
for i in range(4):
    for j in range(len(v[i])):
        cum[i].append(cum[i][j]+v[i][j])
ans = 0
for i in range(len(v[0])+1):
    for j in range(len(v[1])+1):
        for k in range(len(v[2])+1):
            for l in range(len(v[3])+1):
                if (i+j+k+l)*w0 + j + 2*k + 3*l > W:
                    continue
                #ここから下は制約を満たすことが保証される
                candidate = cum[0][i] + cum[1][j] + cum[2][k] + cum[3][l]
                ans = max(ans,candidate)
print(ans)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
using namespace std;
int		cnt;

int		main(void)
{
	int		N;
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		if (to_string(i).size() % 2)
			cnt++;
	}
	cout << cnt << endl;
}


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

int main(){
    int n, c;
    cin >> n >> c;
    int d[c+1][c+1];
    for(int i = 1; i <= c; i++){
        for(int j = 1; j <= c; j++){
            cin >> d[i][j];
        }
    }
    int cl[n][n];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> cl[i][j];
        }
    }
    long long int sum0[c+1] = {};
    long long int sum1[c+1] = {};
    long long int sum2[c+1] = {};
    long long int mi = 1000000000000;
    for(int i = 1; i <= c; i++){
                for(int p = 0; p < n; p++){
                    for(int q = 0; q < n; q++){
                        if((p+q)%3 == 0){
                            sum0[i] += d[cl[p][q]][i];
                        }
                    }
                }
    }
    for(int i = 1; i <= c; i++){
                for(int p = 0; p < n; p++){
                    for(int q = 0; q < n; q++){
                        if((p+q)%3 == 1){
                            sum1[i] += d[cl[p][q]][i];
                        }
                    }
                }
    }
    for(int i = 1; i <= c; i++){
                for(int p = 0; p < n; p++){
                    for(int q = 0; q < n; q++){
                        if((p+q)%3 == 2){
                            sum2[i] += d[cl[p][q]][i];
                        }
                    }
                }
    }
    long long int sum = 0;
    for(int i = 1; i <= c; i++ ){
        for(int j = 1; j <= c; j++ ){
            for(int k = 1; k <= c; k++ ){
                if(k==i || i==j || j==k) continue;
                sum = sum0[i] + sum1[j] + sum2[k];
                mi = min(mi, sum);
            }
        }
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
int main(){
  int n;
  std::cin >> n;
  std::vector<int> h(n);
  for(auto &e : h)
    std::cin >> e;
  h.push_back(0);
  int ans = 0;
  for(int d = 1; d <= 100; ++d)
    for(int i = 0; i < n; ++i)
      if(h[i] >= d && h[i + 1] < d)
        ++ans;
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

func init() {
	sc = bufio.NewScanner(os.Stdin)
	buffsize := 1000000
	buff := make([]byte, buffsize)
	sc.Buffer(buff, buffsize)
	sc.Split(bufio.ScanWords)
}

func loadint() (result int) {
	sc.Scan()
	result, _ = strconv.Atoi(sc.Text())
	return
}

func main() {
	n := loadint()
	k := loadint()
	if n%k == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(1)
	}
}


Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
char a;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	a=getchar();
	if(a>=65&&a<=90)cout<<'A'<<endl;
	else cout<<'a'<<endl;
	return 0;
}

Measured memory_bytes: 3632
d = int(input().rstrip())

import math
sin60 = math.sin(math.radians(60))
cos60 = math.cos(math.radians(60))


def make_koch(d, p1, p2):
    s = ((p1[0]*2 + p2[0]) / 3, (p1[1]*2 + p2[1]) / 3)
    t = ((p1[0] + p2[0]*2) / 3, (p1[1] + p2[1]*2) / 3)
    u = ((t[0] - s[0]) * cos60 - (t[1] - s[1])*sin60 + s[0], (t[0] - s[0]) * sin60 + (t[1] - s[1]) * cos60 + s[1])
    if d == 0:
        return [p1]
    elif d == 1:
        return [p1, s, u, t]
    else:
        return make_koch(d-1, p1, s) + make_koch(d-1, s, u) + make_koch(d-1, u, t) + make_koch(d-1, t, p2)
result_list = make_koch(d, (0, 0), (100, 0))

for result in result_list:
    print(result[0], result[1])
print("100 0")
        
        
        
        


Measured memory_bytes: 6280
import sys
readline = sys.stdin.readline

import numpy as np
from numba import njit


def main():
    @njit('i8(i4[::1],)', cache=True)
    def f(A):
        count = np.zeros((A.max() + 1))
        for a in A:
            if count[a] > 1:
                continue
            count[::a] += 1

        ret = 0
        for a in A:
            ret += count[a] == 1

        return ret

    N = int(input())
    A = np.array(readline().split(), np.int32)

    print(f(A))


if __name__ == '__main__':
    main()

Measured memory_bytes: 127408
n=int(input())
a=list(map(int,input().split()))
c=0
d=0
e=0
f=0
for i in range(n):
    k=a[i]
    e+=k
    f+=k
    if i%2==0:
        if e<=0:
            c+=1-e
            e=1
        if f>=0:
            d+=f+1
            f=-1
    else:
        if e>=0:
            c+=1+e
            e=-1
        if f<=0:
            d+=1-f
            f=1
print(min(c,d))

Measured memory_bytes: 14468
#include <stdio.h>
#include <string.h>
int main()
{
        int a[26] = {0};
        int i;
        char s[100];
        scanf("%s",s);
        int len,j;
        int flag =1;
        len = strlen(s);
        for(i = 0; i < len; i ++)
          {
              j = s[i] - 'a';
              a[j] ++;
          }
        for(i = 0; i < 26; i++)
        {
                if ( a[i] % 2 == 1)
                        flag =0;
        }
        if(flag == 1)
                printf("Yes");
        else
                printf("No");
        return 0;
}

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

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
        int n, k, s;
        cin >> n >> k >> s;

        int N = 1e9;
        if(s == N)
            N--;
        for(int i=0;i<k;i++)
            cout << s << ' ';
        for(int i=k;i<n;i++)
            cout << N << ' ';
        cout << '\n';
        
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 1280
function Main(input) {
  input = input.split("\n")[1].split(" ");
  var output = 0;
  for(var i = 1; i < input.length - 1; i++){
    var mae = parseInt(input[i - 1]);
    var ato = parseInt(input[i + 1]);
    var ima = parseInt(input[i]);
    
    if((mae < ima && ima < ato) || (mae > ima && ima > ato)){
      output++;
    }
  }
  console.log(output);
}

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

Measured memory_bytes: 9420
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
//#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch RedAndGreenApples | diff RedAndGreenApples.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address RedAndGreenApples.cpp && ./a.out

/*
 
 3/28/2020
 
 5:57-6:50 TLE
 7:00 WA. Give up
 
 8:31-
 
 */

//const int MAX_N=1e6+1;
int X,Y;
int N[3];
vector<vector<LL>> A(3);

void solve() {
  REP(i,3) sort(ALL(A[i])),reverse(ALL(A[i]));
  LL cursum=0,csum=0,res=0;
  dumpC(N,N+3);
  REP(i,3) dumpc(A[i]);
  REP(i,X) cursum+=A[0][i];
  REP(i,Y) cursum+=A[1][i];
  int ii[2]={X-1,Y-1};
  res=cursum;
  dump(res,cursum,csum);
  REP(i,min(N[2],X+Y)) {
    csum+=A[2][i];
    int taken=0;
    if(ii[0]<0) taken=1;
    else if(ii[1]>=0&&A[0][ii[0]]>A[1][ii[1]]) taken=1;
    assert(ii[taken]>=0);
    LL x=A[taken][ii[taken]];
    cursum-=x;
    ii[taken]--;
    SMAX(res,cursum+csum);
    dump(i,res,csum,cursum,c,x);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>X>>Y;
  REP(i,3) {
    cin>>N[i];
    A[i].resize(N[i]);
  }
  REP(i,3)REP(j,N[i]) cin>>A[i][j];
  solve();
  
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<char> c(n);
    int rtow = 0;
    int wtor = 0;
    rep(i, n) {
        cin >> c[i];
        if (c[i] == 'R') rtow++;
    }

    int ans = 2000000;
    for (int i = 0; i <= n; i++) {
        int cnt = max(rtow, wtor);
        ans = min(ans, cnt);
        if (i == n) break;
        if (c[i] == 'R') rtow--;
        else wtor++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3580
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll maxi=0,f=0,mini=INF,sum=0;
    string str,str2;
    ll h,w;
    ll n,x,m;
    ll a,b,d;
    multiset<int> s;
    cin>>a>>b;
    for(ll i=a;i<=b;i++){
        str=to_string(i);
        if(str[0]==str[4]&&str[1]==str[3]) sum++;
    }
    cout<<sum<<endl;
}


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

const int INF = 1e9;

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

    vector<int> dp(n+1, INF);
    dp[n] = 0;
    
    queue<int> Q;
    Q.push(0);
    for(int i = n-1; i >= 0; i--) {
        while(1) {
        if(Q.size() == 0) {
            puts("-1");
            return 0;
        }
        if(Q.front() != INF && Q.size() <= m) {
            break;
        } 
        Q.pop();
        }
        if(s[i] == '0') {
            dp[i] = Q.front() + 1;
        } 
        Q.push(dp[i]);
    }
    
    vector<int> ans;
    int x = 0;
    int rest = dp[0];
    while(x < n) {
        rest--;
        int i = 1;
        while(dp[x+i] != rest) {
            i++;
        } 
        ans.push_back(i);
        x += i;
    }

    rep(i, ans.size()) {
        printf("%d%c", ans[i], i==int(ans.size())-1?'\n':' ');
    }

    return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <memory>
#include <cassert>
#include <algorithm>

using namespace std;

int main() {

    int N;
    cin>>N;
    vector<int> fl(100, 0);
    vector<int> sl(100, 0);
    int dp[2][100];

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

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

    dp[0][0] = fl[0];
    for(int i=0; i<N; ++i)
        dp[0][i+1] = fl[i+1] + dp[0][i];

    dp[1][0] = dp[0][0] + sl[0];
    for(int i=0; i<N; ++i)
        dp[1][i+1] = max(dp[0][i+1]+sl[i+1], dp[1][i]+sl[i+1]);

    cout<<dp[1][N-1]<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;
int main(){
	int n;
	cin>>n;
	double a[n+1][n+1]={0},ans=0.0;
	a[0][0]=1;
	
	double p[n];
	for(int i=0;i<n;i++)
	cin>>p[i];
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j)
			a[i][j]=(a[i-1][j-1]*p[i-1]);
			a[i][j]+=(a[i-1][j]*(1.0-p[i-1]));
			}
		}
	for(int i=0;i<=n;i++){
		if(i>n-i)
		ans+=a[n][i];
}
printf("%0.10f",ans);
}


Measured memory_bytes: 70528
package main

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

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func nextLine() string {
	var line, buffer []byte
	isPrefix := true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func nextStringArray() []string {
	return strings.Split(nextLine(), " ")
}
func nextInt() int {
	n, _ := strconv.Atoi(nextLine())
	return n
}
func nextIntArray() []int {
	s := strings.Split(nextLine(), " ")
	n := len(s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}

func main() {
	n := nextInt()
	a := nextIntArray()
	b := nextIntArray()

	a = append([]int{0}, a...)
	b = append([]int{0}, b...)

	for i := 0; i < n; i++ {
		a[i+1] = a[i] + a[i+1]
		b[i+1] = b[i] + b[i+1]
	}

	candy := 0
	for i := 1; i < n+1; i++ {
		if c := a[i] + b[n] - b[i-1]; c > candy {
			candy = c
		}
	}

	fmt.Println(candy)
}


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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;

int main(){
    string b;
    cin >> b;
    if(b == "A") cout << "T" << endl;
    if(b == "T") cout << "A" << endl;
    if(b == "C") cout << "G" << endl;
    if(b == "G") cout << "C" << endl;
    return 0;
}




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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  char c; cin>>c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') print("vowel");
  else print("consonant");

  return 0;
}

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

typedef long long ll;

const long long MOD = 1000000007;
long long modpow(long long a, long long n, long long m)
{
    long long ans = 1;
    while (n)
    {
        if (n & 1)
        {
            ans = (ans * a) % m;
        }
        a = (a * a) % m;
        n >>= 1;
    }
    return ans;
}
long long combi(long long n, long long a)
{
    long long ans = 1, ans1 = 1;
    for (long long i = n - a + 1; i <= n; i++)
    {
        ans *= i % MOD;
        ans %= MOD;
    }

    for (long long i = 2; i <= a; i++)
        ans1 = (ans1 * i) % MOD;
    ans1 = modpow(ans1, MOD - 2, MOD);
    return ((ans % MOD) * ans1) % MOD;
}

void dfs(string s, char mx, ll N)
{
    if (s.length() == N)
    {
        cout << s.c_str() << endl;
    }
    else
    {
        for (char c = 'a'; c <= mx; c++)
        {
            dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx), N);
        }
    }
}

int bfs(int a, int b, int h, int w, char tmp[][101])
{
    int ans[101][101] = {0};
    char c[101][101] = {0};
    queue<pair<int, int>> s;

    for (int i = 0; i <= h; i++)
    {
        for (int j = 0; j <= w; j++)
        {
            c[i][j] = tmp[i][j];
        }
    }

    s.push(make_pair(a, b));

    while (s.size() > 0)
    {

        pair<int, int> tmp = s.front();
        s.pop();
        c[tmp.first][tmp.second] = '#';
        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                if (tmp.first + i < 1 || tmp.first + i > h)
                {
                    continue;
                }
                if (tmp.second + j < 1 || tmp.second + j > w)
                {
                    continue;
                }
                if (i != 0 && j != 0)
                {
                    continue;
                }
                if (i == 0 && j == 0)
                {
                    continue;
                }
                if (c[tmp.first + i][tmp.second + j] == '#')
                {
                    continue;
                }
                c[tmp.first + i][tmp.second + j] = '#';
                if (ans[tmp.first + i][tmp.second + j] == 0)
                {
                    ans[tmp.first + i][tmp.second + j] = ans[tmp.first][tmp.second] + 1;
                }
                else
                {
                    ans[tmp.first + i][tmp.second + j] = min(ans[tmp.first + i][tmp.second + j], ans[tmp.first][tmp.second] + 1);
                }
                s.push(make_pair(tmp.first + i, tmp.second + j));
            }
        }
    }

    int asd = 0;

    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            asd = max(a, ans[i][j]);
        }
    }

    return asd;
}

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

    vector<ll> a(n+1);
    vector<ll> diff(n);

    ll total = 0;
    for (int i = 0; i<n; i++){
        cin >> a[i];
    }
    a[n] = k;

    ll ans = a[0] + k-a[n-1];
    for (int i = 1; i<n; i++){
        ans = max(ans, a[i] - a[i-1]);
    }

    cout << k - ans << endl;

    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            new Program().Solve();
        }

        void Solve()
        {
            var s1 = Console.ReadLine();
            var s2 = Console.ReadLine();
            var s3 = Console.ReadLine();
            var ans = s1[0].ToString() + s2[1].ToString() + s3[2].ToString();
            Console.WriteLine(ans);
        }


    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"
const double PI = 3.14159265358979323846;

signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
    
    int a,b;
    cin>>a>>b>>h>>m;
    
    double theta = 30*h;
    double theta1 = 6*m;
    //cout<<theta<<endl;
    theta += 0.5*(m);
   
    theta = min(abs(theta-theta1) , 360-abs(theta-theta1));
    
    
    theta = theta/180.0;
    theta=theta*PI;
    
    
    
    ans = b*b + a*a;
    theta1 = 2*b*a*cos(theta);
    
    theta = (double)ans-(double)theta1;
    
    cout<<setprecision(20)<<sqrt(theta)<<endl;
    
    
    
    
}

Measured memory_bytes: 4296
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end
n, blist = gets_n_and_i_list

ans = blist.last

if n >= 2
  (n-2).downto(1) do |i|
    ans += [blist[i], blist[i-1]].min
  end
end

puts ans + blist[0]


Measured memory_bytes: 14496
#include <bits/stdc++.h>
                            #include<string>
                            using namespace std;
                            #define pb push_back
                            #define endl '\n'
                            #define all(x) (x).begin(), (x).end()
                            #define forn(i, n) for (int i = 0; i < (int)(n); i++)
                            #define init(arr,value) memset(arr,value,sizeof(arr))
                            #define test unsigned int tet;cin >> tet;while(tet--)
                            #define sz(a) int((a).size())
                            typedef long long ll;
                            typedef unsigned long long ull;
                            typedef long double ld;
                            typedef vector<int> vi;
                            typedef pair<int, int> pii;
                            typedef pair<ll, ll> pll;
                            #define sf scanf 
                            #define pf printf 
                            #define SUM(v) accumulate(all(v),ll(0))
                            #define present(container, element) (container.find(element) != container.end())
                            #define cpresent(container, element) (find(all(container),element) != container.end())
                            int max(int a,float b){
                                if(a>b)
                                   return a;
                                return b;
                            }
                            ll gcd(ll a,ll b){
                                if(a%b==0)
                                    return b;
                                else
                                    return gcd(b,a%b);
                            }
                            ll lcm(ll a,ll b){
                                return a*b/gcd(max(a,b),min(a,b));
                            }
                            bool sort_pair(pair<int,int>a,pair<int,int> b){
                               return a.first<b.first;
                            }
                            bool sort_pair_(pair<int,int>a,pair<int,int>b){
                                return a.second>b.second;
                            }
                            bool isprime(int x){
                                for(int i=2;i<=sqrt(x);i++){
                                    if(x%i==0)
                                    return 0;
                                }
                                return 1;
                            }
                            
                           
                            
                            
                          int main(){
                                int x;
                            	sf("%d",&x);
                            	if(x>=30)pf("Yes");
                            	else pf("No");
                                    
                                    
                          
                                cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
                    	return 0;
                            }

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

int main() {
    int N, M;
    cin >> N >> M;
    int cnt=0;
    for (int i=0; i<N+M-1; i++) {
        for (int j=i+1; j<N+M; j++) {
            if ((i<N && j<N)|| i>=N) cnt++;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 256
package main

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

func solution(s string) int {
        n := len(s) + 1
        a := make([]int, n)
        for i := 0; i < n-1; i++ {
                if s[i] == '<' {
                        a[i+1] = max(a[i+1], a[i]+1)
                }
        }

        for i := n - 2; i >= 0; i-- {
                if s[i] == '>' {
                        a[i] = max(a[i], a[i+1]+1)
                }
        }
        out := 0
        for i := 0; i < n; i++ {
                out += a[i]
        }
        return out
}

func max(x, y int) int {
        if x > y {
                return x
        }
        return y
}

func main() {
        var fp *os.File = os.Stdin
        reader := bufio.NewReaderSize(fp, 1024)
        var s string
        fmt.Fscan(reader, &s)
        fmt.Println(solution(s))
}

Measured memory_bytes: 8192
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n>>m;
    a.clear();
    a.resize(n+1,0);
    lli cnt=0,p=0;
    fo(i,m)
    {
        cin>>in>>s;
        if(s=="WA")
            a[in]++;
        else
        {
            if(a[in]<0)
                continue;
            p+=a[in];
            cnt++;
            a[in]=-INF;
        }
    }
    cout<<cnt<<" "<<p<<endl;
}   aryanc403();
    return 0;
}


Measured memory_bytes: 1024
from collections import deque
N, M = map(int, input().split())
K = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    K[a-1].append(b-1)
S, T = map(int, input().split())
used = [[0]*3 for _ in range(N)]

q = deque([[S-1, 0, 0]])
used[S-1][0] = 1
ans = [[-3]*3 for _ in range(N)]
while(len(q)>0):
    u, v, c = q.popleft()
    v_n = (v + 1) % 3
    for j in K[u]:
        if used[j][v_n] == 0:
            used[j][v_n] = 1
            ans[j][v_n] = c+1
            q.append([j, v_n, c+1])

print(ans[T-1][0]//3)

Measured memory_bytes: 82336
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define forn(i,x,y) for(int i=x;i<y;++i)
#define fornr(i,x,y) for(long long i=x;i>=y;--i)
#define testcase int _t; cin >> _t; while(_t--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 110;
int main()
{
	ios_base :: sync_with_stdio(false);
  	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ll n,weight;
	cin >> n >> weight;
	vector<int> w(n+1), cost((int)1e5+1);
	forn(i,1,n+1)
		cin >> w[i] >> cost[i];
//	ll dp[n+1][(int)1e5+1];
	vector<vector<ll>> dp(n+1);
	forn(i,0,n+1)
		dp[i].resize((int)1e5+1);
	/* 
		минимальный вес который можно получить из первых i сумок и стоимостью j
		3 4
		5 6
		2 4
        dp[i][j] = {
			min(
				dp[i-1][j],
				dp[i-1][j-cost[i]] + w[i]	
			)
		}
	*/
	forn(i,0,n+1){
		forn(j,0,(int)1e5+1){
			dp[i][j] = 1LL*1e15;
		}
	}
	dp[0][0] = 0;
	forn(i,1,n+1){
		forn(j,0,(int)1e5+1){
			if(j - cost[i] < 0)
				dp[i][j] = dp[i-1][j];
			else
				dp[i][j] = min(dp[i-1][j], dp[i-1][j-cost[i]] + w[i]);		
		}
	}
	ll ans = 0;
	forn(j,1,(int)1e5+1){
		//cout << dp[n][j] << " ";
		if(dp[n][j] <= weight)
			ans = j;
	}
	cout << ans;

  	return 0;
}

 	/* 















 	*/


Measured memory_bytes: 82920
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int n;
int cnt = 60;
vector<ll> vec;
ll mod = 1e9+7;

ll solve() {
  vector<vector<int>> sum_zero(n+1, vector<int>(cnt, 0));
  vector<vector<int>> sum_one(n+1, vector<int>(cnt, 0));

  ll ans = 0;
  reps(i, 1, n+1) {
    rep(j,cnt) {
      if (vec.at(i-1) >> j & 1ll) {
        sum_one.at(i).at(j) = sum_one.at(i-1).at(j) + 1;
        sum_zero.at(i).at(j) = sum_zero.at(i-1).at(j);
      } else {
        sum_one.at(i).at(j) = sum_one.at(i-1).at(j);
        sum_zero.at(i).at(j) = sum_zero.at(i-1).at(j) + 1;
      }
    }
  }
  rep(i, n-1) {
    ll t = 1;
    rep(j, cnt) {
      ll v;
      if (vec.at(i) >> j & 1ll) {
        v = (sum_zero.at(n).at(j) - sum_zero.at(i+1).at(j));
      } else {
        v = (sum_one.at(n).at(j) - sum_one.at(i+1).at(j));
      }
      ans += v * t;
      ans %= mod;
      t *= 2;
      t %= mod;
    }
  }
  return ans;
}

int main()
{ 
  cin >> n;
  vec.resize(n);
  rep(i, n) cin >> vec.at(i);
  cout << solve() << endl;
  
  return 0;
}

Measured memory_bytes: 169560
#include <stdio.h>
#include <math.h>

int main(void) {
	int n, a, b, c, ma, mb, mc;
	int i;
	
	scanf("%d", &n);
	for (i=0; i<n; i++) {
		scanf("%d%d%d", &a, &b, &c);
		mc = a*a + b*b;
		mb = c*c + a*a;
		ma = b*b + c*c;
		if (ma == a*a || mb == b*b || mc == c*c) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	
	return 0;
}

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <int, int> pii;
typedef long double ld;
typedef vector <ll> vi;

const int N = 2e3 + 1;
const ll INF = 1e18 + 9;
const int B = 1e9 + 7;

int n, m;
int a[N][N], c[N], d[N];

bool check(int x) {
    forn(i, 1, m) c[i] = 0, d[i] = 0;
    while (1) {
        bool new_it = 0;
        forn(i, 1, n) {
            int j = 1;
            while (j <= m && d[a[i][j]]) ++j;
            if (++c[a[i][j]] > x) {
                d[a[i][j]] = 1;
                forn(k, 1, m) c[k] = 0;
                new_it = 1;
                break;
            }
            if (j > m) return 0;
        }
        if (!new_it) break;
    }
    return 1;
}

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m;
    forn(i, 1, n)
        forn(j, 1, m)
            cin >> a[i][j];
    int l = 1, r = n;
    while (l < r) {
        int m = (l + r) / 2;
        if (!check(m)) l = m + 1;
        else r = m;
    }
    cout << l << "\n";

    return 0;
}


Measured memory_bytes: 3712
X, N =map(int, input().split())
if N ==0:
  print(X)
  exit()
S_1 = set(map(int, input().split()))
S_2 = {i for i in range(102)}
S = S_2 - S_1
L = 1000
for s in S:
  if abs(X-s) < abs(X-L):
    L = s
print(L)

Measured memory_bytes: 9188
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
import itertools
#from scipy.misc import comb

N,M = map(int, input().split())

G = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

l = [i for i in range(1,N)]

ans = 0
for v in itertools.permutations(l, N-1):
    tmp = 0
    a = 0
    for b in v:
        if b in G[a]: tmp += 1
        a = b

    if tmp == N-1: ans += 1

print(ans)

Measured memory_bytes: 12204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n,l;cin>>n>>l;
  vector<int>vec(n);
  int cnt=0;
  rep(i,n){
    vec[i]=l+i;
    cnt+=vec[i];
  }
  int ans=1e9;
  rep(i,n){
    ans=min(ans,abs(vec[i]));
  }
  if(cnt>=0)cout<<cnt-ans<<endl;
  else cout<<cnt+ans<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <utility>
using namespace std;

int main() {
	long long N;
	cin >> N;
	long long A[100000]={};
	
	for(int i=0; i<N; i++){
		long long a;
		cin >> a;
		A[a]++;
	}
	
	long long ans=0;
	
	for(int i=0; i<99998; i++){
		long long s=A[i]+A[i+1]+A[i+2];
		ans=max(s,ans);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

#define MAX (300)

using namespace std;

int S[MAX];
int top;

void initialize(){
    top = 0;
}

bool isEmpty(){
    return top == 0;
}

bool isFull(){
    return top >= MAX - 1;
}

void push(int x){
    if(isFull()){
        
    }
    top++;
    S[top] = x;
}

int pop(){
    if(isEmpty()){
        
    }
    top--;
    return S[top+1]; 
}

int main(void){
    int x;
    char s[100];
    
    while(scanf("%s",s) != EOF){
        if(s[0] == '+'){
            int a = pop();
            int b = pop();
            int c = a + b;
            push(c);
        }else if(s[0] == '-'){
            int a = pop();
            int b = pop();
            int c = b - a;
            push(c);
        }else if(s[0] == '*'){
            int a = pop();
            int b = pop();
            int c = a * b;
            push(c);
        }else if(s[0] == '/'){
            int a = pop();
            int b = pop();
            int c = b / a;
            push(c);
        }else{
            x = atoi(s);
            push(x);
        }
    }
    
    cout << pop() << endl;
}


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

int main() {
    int n, k;
    cin>>n>>k;
    vector<int> a(n);
    vector<int> dp(n, INT_MAX);
    for(int i=0; i<n; i++) cin>>a[i];
    dp[0] = 0;
    for(int i=1; i<n; i++) {
        for(int j=1; i-j>=0 && j<=k; j++) {
            dp[i] = min(dp[i-j] + abs(a[i] - a[i-j]), dp[i]);
        }
    }
    cout<<dp.back()<<endl;
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target (sse, sse1, sse2, tune=native, popcnt)

#include <bits/stdc++.h>
/*
const int MAX_MEM = 3e8;
int mpos = 0;
char mem[MAX_MEM];
inline void* operator new(size_t n) {
    char *res = mem + mpos;
    mpos += n;
    assert(mpos <= MAX_MEM);
    return (void *) res;
}
inline void operator delete(void *) {}
*/
using namespace std;

#define loop(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, n) for(int i = a; i < n; ++i)
#define vec vector
#define paii pair<int, int>
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define SZ(x) (int)x.size()
#define Unique(x) x.erase(unique(all(x)), x.end())
#define ll long long

#define int long long

const int inf = 1e17 + 47, MAXN = 5e5 + 47, mod = 1e9 + 7, N = 201;

mt19937 rnd(time(0));

int n, s;
vec<int> val;

void solve() {
    cin >> n >> s;
    val.resize(n);
    loop(i, n) cin >> val[i];
    FOR(i, 1, n) {
        if(val[i] + val[i - 1] >= s) {

            cout << "Possible" << endl;
            loop(j, i - 1) cout << j + 1 << endl;

            for(int j = n - 2; j >= i; --j) cout << j + 1 << endl;
            cout << i << endl;
            return ;
        }
    }
    cout << "Impossible" << endl;
}

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

    #ifdef COFFEE_MACHINE
        freopen("input.cpp", "r", stdin);
        freopen("output.cpp", "w", stdout);
    #endif // COFFEE_MACHINE

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


Measured memory_bytes: 1664
let () = Scanf.scanf "%d %d" @@ fun a b ->
  let grid = Array.init 100 @@ fun i ->
    if i < 50
    then String.make 100 '#'
    else String.make 100 '.' in
  print_endline "100 100";
  for i = 0 to (a - 1) / 50 - 1 do
    for j = 0 to 49 do
      grid.(2 * i).[2 * j] <- '.'
    done
  done;
  for j = 0 to (a - 1) mod 50 - 1 do
    grid.((a - 1) / 50 * 2).[2 * j] <- '.'
  done;
  for i = 0 to (b - 1) / 50 - 1 do
    for j = 0 to 49 do
      grid.(99 - 2 * i).[2 * j] <- '#'
    done
  done;
  for j = 0 to (b - 1) mod 50 - 1 do
    grid.(99 - (b - 1) / 50 * 2).[2 * j] <- '#'
  done;
  Array.iter print_endline grid

Measured memory_bytes: 384