akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int N, K; cin >> N >> K;
  auto x = vector<ll>(N);
  for (int i = 0; i < N; ++i) cin >> x[i];
  ll ans = 1e9;
  for (int i = 0; i < N - K + 1; ++i) {
    if (x[i] * x[i + K - 1] >= 0) {
      ans = min(ans, max(abs(x[i]), abs(x[i + K - 1])));
    } else {
      ans = min(ans, min(abs(x[i]) * 2 + x[i + K - 1], abs(x[i]) + x[i + K - 1] * 2));
    }
  }
  cout << ans << endl;
  return 0;
}


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

int D[100];
int dp[1 << 16];

vector<int> G[100];

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

	int N, M, K;
	cin >> N >> M >> K;
	memset(D, -1, sizeof D);

	int dn = 0;
	vector<int> ds;
	for(int i = 0; i < M; i++) {
		int x;
		cin >> x;
		x--;
		D[x] = dn++;
		ds.push_back(x);
	}

	for(int i = 0; i < N; i++) {
		for(int j = 0; j < K; j++) {
			int v;
			cin >> v;
			G[i].push_back(v - 1);
		}
	}

	const int INF = 1 << 25;
	fill((int*)begin(dp), (int*)end(dp), INF);

	dp[(1 << M) - 1] = 0;
	queue<int> q;
	q.push((1 << M) - 1);
	while(q.size()) {
		int s = q.front();
		int t = dp[s];
		q.pop();
		for(int k = 0; k < K; k++) {
			int ns = 0;
			for(int i = 0; i < M; i++) {
				if(s >> i & 1) {
					int v = ds[i];
					int u = G[v][k];
					if(D[u] == -1) continue;
					ns |= 1 << D[u];
				}
			}
			if(ns == 0) {
				cout << t + 1 << endl;
				return 0;
			}
			if(dp[ns] > t + 1) {
				dp[ns] = t + 1;
				q.push(ns);
			}
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif


struct UnionFind {
  vector<ll> par, siz;
  UnionFind(ll n):par(n),siz(n,1) {
    for (ll i = 0; i < n; ++i) par[i] = i;
  }
  ll size() { return par.size(); };
  ll root(ll x) {
    assert(x < size());
    if (par[x] == x) return x;
    else return par[x] = root(par[x]);
  }
  void merge(ll x, ll y) {
    assert(x < size());
    assert(y < size());
    ll rx = root(x);
    ll ry = root(y);
    if (rx == ry) return;
    if (siz[rx] < siz[y]) std::swap(rx, ry);
    par[rx] = ry;
    siz[ry] += siz[rx];
  }
  bool same(ll x, ll y) { 
    assert(x < size());
    assert(y < size());
    return root(x) == root(y);
  }
  ll size(ll x) {
    assert(x < size());
    return siz[root(x)];
  }
};

int dx[8] = {-1, 0, 1, 0, -1, 1, -1, 1};
int dy[8] = {0, -1, 0, 1, -1, -1, 1, 1};

int dx2[4] = {-2, 0, 2, 0};
int dy2[4] = {0, -2, 0, 2};


int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n,m;
  cin >> n >> m;
  vector<int> p(n);
  rep(i,n) {
    cin >> p[i];
    p[i]--;
  }
  UnionFind tree(n);
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    x--; y--;
    tree.merge(x,y);
  }

  vector<map<int,int> > maps(n);
  rep(i,n) {
    if (tree.size(i) > 1) {
      // debug(tree.root(i), maps[tree.root(i)].size());
      maps[tree.root(i)][i]++;  
    }
  }
  int ans = 0;
  rep(i,n) {
    if (tree.size(i) == 1) {
      if (i == p[i]) ans++;
    }
    else {
      if (maps[tree.root(i)].count(p[i]) > 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 14496
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/10 20:03:01
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

void run() {
    int A, B, C, k; cin >> A >> B >> C >> k;
    int ans = min(A, k);
    k -= ans;
    if (k) {
        k -= B;
    }
    if (k > 0) {
        ans -= min(C, k);
    }
    cout << ans << '\n';
}

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

Measured memory_bytes: 3640
using System;
using System.Text;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            int count = 0;
            
            for (var i = 0; i < n - 2; i++)
            {
                if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
                {
                    count++;
                    i = i + 2;
                }
            }
            
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13140
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define N 100001
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
const int S=(1<<19)-1;
int n,ans,f[N];
int cnt,head[N],nxt[N+N],to[N+N];
void dfs(int u,int fa)
{
	int mx=0;
	for(int i=head[u],v;i;i=nxt[i])
		if((v=to[i]) != fa)
		{
			dfs(v,u);
			mx=max(mx,f[u]&f[v]);
			f[u]|=f[v];
		}
	int mn=0;
	while((f[u]>>mn&1) || ((1<<mn)<=mx))++mn;
	f[u]=(f[u]>>mn<<mn)|(1<<mn);
	ans=max(ans,mn);
	// for(int i=18;;--i)
	// 	if(i<mn || (mx>>i&1))
	// 	{
	// 		++i;
	// 		// f[u]&=S-((1<<i)-1);
	// 		// f[u]|=1<<i;
	// 		f[u]=(f[u]>>i<<i)|(1<<i);
	// 		ans=max(ans,i);
	// 		// cerr<<u<<" "<<i<<endl;
	// 		break;
	// 	}
}
int main()
{
	re(n);
	for(int i=1,u,v;i<n;++i)
	{
		re(u),re(v);
		add_edge(u,v);
		add_edge(v,u);
	}
	dfs(1,0);
	printf("%d\n",ans);
}
/*
10
1 2
2 3
3 4
4 5
5 6
6 7
4 8
8 9
9 10
*/


Measured memory_bytes: 7168
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int64_t n;
    cin >> n;
    string ans = "";
    while(n-- > 0){
        ans += (char)((n % 26) + 'a');
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
"""
http://abc067.contest.atcoder.jp/tasks/arc078_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(cards):
    grand_total = sum(cards)
    # 上から順番にカードを引いていき、できるだけ合計の半分に近づける
    snuke_total = cards[0]      #  すぬけ君は最低でも1枚は引く必要がある
    min_diff = abs(grand_total - (snuke_total*2))
    for c in cards[1:-1]:       #  アライグマは最低1枚は引く必要があるので、最後のカードはすぬけ君には渡さない
        snuke_total += c
        min_diff = min(abs(min_diff), abs(grand_total - (snuke_total*2)))
    return min_diff


def main(args):
    N = int(input())
    cards = [int(x) for x in input().split()]
    result = solve(cards)
    print(result)



if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 23800
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
long long cl(long long a, long long b) {
	return (a - (a%b))/ b;//b=0だと積む
}
int ord(int a, int p) {
	if (a%p == 0) {
		return ord(a / p, p) + 1;
	}
	else {
		return 0;
	}
}
long long pow(int a) {
	if (a == 0) {
		return 1;
	}
	else {
		long long  x = pow(a - 1);
		return 2 * x;
	}
}
int main() {
	long n, k; long ans = 0;
	cin >> n >> k;
	vector<long long> b((n*(n + 1)) / 2);
	vector<long long> a(n);
	vector<int> d(n*(n+1)/2, 1);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ch = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			if (j == i) {
				b[ch] = a[i];
			}
			else {
				b[ch] = b[ch - 1] + a[j];
			}
			ch++;
		}
	}
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());
	for (int i = 40; i >= 0; i--) {
		int co = 0;
		vector<int> yobi((n*(n+1))/2);
		yobi = d;
		for (int j = 0; 2 * j < (n*(n + 1)); j++) {
			if (cl(b[j], pow(i)) % 2 == 1) {
				if (d[j] == 1) {
					co++;
				}
			}
			else {
				yobi[j] = 0;
			}
		}
		if (co >= k) {
			d = yobi;
			ans = ans + pow(i);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8064
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;
int inf=1<<30;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int main(void){
    int n=in(),k=in(),a[100000],i;
    rep(i,n)a[i]=in();
    print((n-1)/(k-1)+!!((n-1)%(k-1)));
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
    using namespace std;
int main()
    {
      long long  n;
      cin>>n;
      vector<long long > v(n);
      long long  ans=0;
      for(long long  &i:v) {cin>>i;}
      sort(v.begin(),v.end());
      ans=v[n-1];
      long long  j=n-2;
      long long  cnt=0;
      for(long long  i=0;i<n-2;i++)
      {
        ans+=v[j];
        cnt+=1;
        if(cnt==2)
        {
        cnt=0;
        j--;
        }
      }
      cout<<ans<<endl;
      
    }

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


signed main() {
  int N;
  cin >> N;
  vector<int> S(N);
  
  int ans = 0;
  for( int i = 0; i < N; i++ ){
    cin >> S.at(i);
    ans += S.at(i);
  }
  sort(S.begin(), S.end());
  if( ans % 10 != 0 ){
    cout << ans << endl;
    return 0;
  }else{ //トータルが10で割り切れてしまう数の場合
    for( int i = 0; i < N; i++ ){
      if( S.at(i) % 10 != 0 ){ //もしS.at(i)が10で割り切れる数じゃなかったら
        cout << ans - S.at(i) << endl;
        return 0;
      }
    }
  }
  
  //もしSが全部10で割り切れる数だったら
  cout << 0 << endl;
  
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <string.h>
	#include <math.h>
using namespace std;
//2乗＝pow(x,2)
//root=sqrt(x)
typedef long long ll;
typedef vector<int> VI;
#define rep(i,n) for(int i=0;i<(n);++i)

//example rep(i,n) cin >> h[i];

int main (){

int n,k,q;
string s;
  //char s[101];
  k=0;

  cin>>n;
  cin>>s;
  
  
  vector<char> vec(40);

  for(char mozi='A';mozi<='Z'; mozi++ ){

  
  vec.at(k)=mozi;
  k++;
 
  
  }


  for(int i=0;i<s.size();i++){
    q=0;
      for(char mozi='A';mozi<='Z'; ++mozi){

  
  if(s.at(i)==mozi){
    s.at(i)=vec.at((q+n)%26);
   break; 
  }
  q++;
 if(q==26)q=0;
  
  }
    
  }
  //rep(i,sizeof(s))if(s[i]==s[i+1]&&s[i]!='\0')k++;
// cout<<"Hellow worldy yes"<<endl;
 
  //k=k*n;
  for(int i=0;i<s.size();i++)cout<<s.at(i);//0~25 == A~Z

  //sort(vec.begin(),vec.end());
  //reverse(vec.begin(),vec.end());

  
 return 0; 
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    cout << min(A * N, B) << endl;
}


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

/**
 * 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;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DLunlunNumber solver = new DLunlunNumber();
        solver.solve(1, in, out);
        out.close();
    }

    static class DLunlunNumber {
        long next(long act) {
            StringBuilder s = new StringBuilder(String.valueOf(act));
            for (int i = s.length() - 1; i > 0; i--) {
                if (s.charAt(i) <= s.charAt(i - 1) && s.charAt(i) < '9') {
                    int a = (s.charAt(i) - '0') + 1;
                    s.setCharAt(i, (char) (a + '0'));
                    for (int j = i + 1; j < s.length(); j++) {
                        a--;
                        s.setCharAt(j, (char) (Math.max(0, a) + '0'));
                    }
                    return Long.valueOf(s.toString());
                }
            }
            if (s.charAt(0) == '9') {
                return act + 1;
            } else {
                StringBuilder ret = new StringBuilder();
                int a = (s.charAt(0) - '0') + 1;
                ret.append(a);
                for (int j = 1; j < s.length(); j++) {
                    a--;
                    ret.append((char) (Math.max(a, 0) + '0'));
                }
                return Long.valueOf(ret.toString());
            }
        }

        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int k = sc.nextInt();
            long ans = 1;
            for (int i = 1; i < k; i++) {
                ans = next(ans);
            }
            out.println(ans);


        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}



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

int main(){
  int n;
  cin >> n;
  int sum = 0, temp = n;
  while(temp > 0){
    sum += temp % 10;
    temp /= 10;
  }
  if(n % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

Measured memory_bytes: 2604
/* 
* Complete Binaly Tree
* output 1)node_number, 2)parent_number, 3)depth, 4)kind_of_node, 5)child_list
*/

/* inclution */
#include <stdio.h>

/* definition */
#define HEAP_SIZE_MAX 250
#define VALUE_MAX 2000000
#define NIL -1

/* Prototype */
void printTree(int);
void getDepth(int, int);

///* Global Variables */
//struct Node {
//  int parent, left, right;
//};
//struct Node A[HEAP_SIZE]; //array for tree
//int n;

/* main */
int main(){
  int i, n, A[HEAP_SIZE_MAX];
  
  /* input the number of A[] */
  scanf("%d",&n);
  
  /* initialize array */
  for(i=1;i<=n;i++) { //??¨??????NIL??§?????????
    A[i] = NIL;
  }

  /* input array */
  for(i=1;i<=n;i++) {
    scanf("%d", &A[i]);
  }
  
  /* print */
  for(i=1;i<=n;i++) {
    printf("node %d: key = %d, ", i, A[i]);
    /* parent */
    if(i/2 > 0) {
      printf("parent key = %d, ", A[i/2]);
    }
    /* left */
    if(2*i <= n) {
      printf("left key = %d, ", A[2*i]);
    }
    if(2*i+1 <= n) {
      printf("right key = %d, ", A[2*i+1]);
    }
      printf("\n");
  }

  return 0;
}

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

int main(){
    string s;
    int y=0;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=="Y")y=1;
    }
    if(y==0)cout<<"Three"<<endl;
    else{
        cout<<"Four"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3600
// Created by SAMAN on ۷/۳۱/۲۰۲۰ م..
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O2")
#pragma GCC optimization ("unroll-loops") 
#include <iostream>
#include <algorithm>
#include <map>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> 
#include <vector>
#include <set>
#include <fstream>
#include <cstdlib>
#include <iterator>
#include <cmath>
#include <ctime>
#include <iomanip>
//#warning not there YET
//#error hello
#define lint long long int
#define endl '\n'
#define kill(x) return cout<<x<<'\n', 0;
#define debug(x) cout << #x << " : " << x << '\n'
#define pb push_back
#define ppb pop_back
#define speed  cout<<clock()*1000/CLOCKS_PER_SEC<<" ms"; 
#define f first
#define s second
#define _ri [i<<1|1]
#define _le [i<<1]  
typedef long long  ll;
typedef long double ld;


using namespace std;

const int maxn = 100 * 100;
ld dp[maxn];
ld a[maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
    //freopen("kn.txt","r",stdin);
    ll n;
    cin >> n;
    dp[0] = 1;
    for(int i = 1;i <= n;i++){
        cin >> a[i];  
        for(int j = i;j>=0;j--){
            if( i == 0)
                dp[j] = dp[j] * (1-a[i]);
            else    
                dp[j] = dp[j-1] * a[i] + dp[j] * (1-a[i]);
        }
    }
    ld ans = 0.0;
    for(int i = n/2+1;i<=n;i++)
        ans+=dp[i];
    cout<<setprecision(10)<<ans;
}



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

int main(int argc, char const *argv[])
{
    char a;
    cin>>a;
    if(isupper(a))
        cout<<'A'<<endl;
    else if(islower(a))
        cout<<'a'<<endl;
    
    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin >> s;

    stack<char> stk;
    for(char c:s){
        if(c == 'B' && stk.empty() == false)stk.pop();
        if(c == '0')stk.push('0');
        if(c == '1')stk.push('1');
    }

    string ans = "";
    while(!stk.empty()){
        char c = stk.top();
        stk.pop();
        ans += c;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 256
while True :
    H, W = map(int, input().split())
    if H == 0 :
        break
    else :
        for i in range(H) :
            for j in range(W) :
                if i == 0 or i == H - 1 or j == 0 or j == W - 1 :
                    print("#", sep = "", end = "")
                else :
                    print(".", sep = "", end = "")
            print()
        print()


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	
	vector<int> A(n);
	for (int i = 0; i < n; i++)
		cin >> A[i];
	
	
	int m;
	cin >> m;
	vector<int> B(m);
	for (int i = 0; i < m; i++)
		cin >> B[i];
	
//	bool result = B.size() > A.size();
//	
//	int bound = min(B.size(), A.size());
//	
//	for (int i = 0; i < bound; i++)
//	{
//		if (B[i] > A[i])
//		{
//			result = true;
//			break;					
//		}	
//		else if (B[i] < A[i])
//		{
//			result = false;	
//			break;		
//		}
//
//	}
//	cout << result << endl;


	//使用库函数
	 cout << lexicographical_compare(A.begin(), A.end(), B.begin(), B.end()) << endl;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int a,b,c; cin>>a>>b>>c;
    if(a==b&&a!=c){
        cout<<"Yes"<<endl;
    }else if(b==c&&c!=a){
        cout<<"Yes"<<endl;
    }else if(c==a&&a!=b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

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

int main() {
  int q;
  cin >> q;
  while(q--) {
    string x, y;
    cin >> x >> y;
    int dp[1001][1001];

    for(int i = 0; i < x.size(); i++) {
      dp[i][0] = 0;
    }
    for(int i = 0; i < y.size(); i++) {
      dp[0][i] = 0;
    }

    for(int i = 0; i < x.size(); i++) {
      for(int j = 0; j < y.size(); j++) {
        dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
        if(x[i] == y[j]) {
          dp[i+1][j+1] = dp[i][j] + 1;
        }
      }
    }
    cout << dp[x.size()][y.size()] << endl;
  }
  return 0;
}


Measured memory_bytes: 7072
# ABC106D - AtCoder Express 2
from itertools import accumulate as acc


def main():
    # 2D cumulative sum
    N, M, Q, *X = map(int, open(0).read().split())
    LR, PQ = X[: 2 * M], X[2 * M :]
    imos = [[0] * (N + 1) for _ in range(N + 1)]
    for l, r in zip(*[iter(LR)] * 2):
        imos[l][r] += 1
    imos = [list(acc(a)) for a in zip(*[acc(a) for a in imos])]
    ans = []
    for p, q in zip(*[iter(PQ)] * 2):
        cur = imos[q][q] - imos[p - 1][q] - imos[q][p - 1] + imos[p - 1][q - 1]
        ans.append(cur)
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 57672
s = input()

stack = []

i = 0
while i<len(s):
    if stack == []:
        stack.append(s[i])
        i+=1

    else:
       st = s[i]

       j = i+1
       while stack[-1]==st and j<len(s):
           st+=s[j]
           j+=1
       if j == i:
           i+=1
       else:
           i = j
       stack.append(st)
ans = 0
for i in range(1,len(stack)):
    if stack[i] != stack[i-1]:
        ans+=1
print(ans+1)
# for i in




Measured memory_bytes: 56268
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
//#include <unordered_map>
//#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

char in[55][55];
int main() {
	int H, W, i, j, k, l;
	scanf("%d %d", &H, &W);
	for (i = 1; i <= H; i++) {
		scanf("%s", in[i] + 1);
	}

	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			if (in[i][j] == '.') continue;
			for (k = 0; k < 4; k++) {
				int x = i + "1102"[k] - '1';
				int y = j + "0211"[k] - '1';
				if (in[x][y] == '#') break;
			}
			if (k >= 4) return !printf("No\n");
		}
	}
	return !printf("Yes\n");
}

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

long long n, k, j = 0, t = 0;
long long a[200000], b[200000], c[200000];

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

	fill(c, c + n + 1, -1);

	for (long long i = 0; i < n; i++)
		cin >> a[i];

	while (c[j] < 0) {
		c[j] = t;
		b[t] = j;
		t++;
		j = a[j] - 1;
	}
	
	if(k < t)
		cout << b[k] + 1 << endl;
	else {
		k = (k - c[j]) % (t - c[j]) + c[j];
		cout << b[k] + 1 << endl;
	}
}


Measured memory_bytes: 8064
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    tree = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        tree[a - 1].append(b - 1)
        tree[b - 1].append(a - 1)

    def dfs(v, p):
        for u in tree[v]:
            if u == p:
                continue
            elif visited[u]:
                continue
            else:
                visited[u] = True
                dfs(u, v)

    visited = [False for _ in range(n)]
    visited[0] = True
    dfs(0, -1)
    for i in visited:
        if not i:
            print("No")
            exit()

    def bfs(v):
        pre = [-1 for _ in range(n)]
        pre[0] = 0
        q = deque()
        q.append(v)
        while q:
            u = q.popleft()
            for nv in tree[u]:
                if pre[nv] == -1:
                    pre[nv] = u
                    q.append(nv)
        return pre

    res = bfs(0)
    print("Yes")
    for i in range(1, n):
        print(res[i] + 1)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 140780
#include<bits/stdc++.h>
#define M 100005
#define L long long
using namespace std;
L n,last,m;
L a[M]={0},pls[M]={0},jump[M]={0};
L unless=0,now=0,maxn=0;
int main(){
	scanf("%lld%lld%lld",&n,&m,&last);
	for(L i=2;i<=n;i++){
		L x; scanf("%lld",&x);
		if(x>=last){
			jump[last+1]++; jump[x+1]--; 
			a[last]++,a[x]--,pls[x+1]+=x-last,unless+=x-last;
		}
		else{
			jump[last+1]++; jump[m+1]--;
			jump[1]++; jump[x+1]--;
			a[last]++; a[m]--; pls[m+1]+=m-last;
			a[1]++; a[x]--; pls[1]-=m-last+1; pls[x+1]+=(m-last+x);
			unless+=m-(last-x);maxn=max(maxn,now);
		}
		last=x;
	}
	for(L i=1;i<=m;i++){
		now=now-pls[i];
		now-=jump[i];
		maxn=max(maxn,now);
		a[i]+=a[i-1];
		now+=a[i];
	}
	cout<<unless-maxn<<endl;
}

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

template <typename T>
inline T read(){
	T x=0,f=1;char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-f;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint
#define readint read<int>()
#define readlint read<lint>()
const int inf=1e9+1e7,MAXN=2e5+1e1;
const double eps=1e-10;

struct Node{
	int w2,w5,p;
};

Node a[MAXN<<1];
int b[3100][3100],n;
lint ans=0;

void Read(int id){
	int x=0,f=1,X=0,F=1,cnt=0;char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-f;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	if(c=='.'){
		while(!isdigit(c)){	if(c=='-') F=-F;c=getchar();}
		while(isdigit(c)){X=(X<<3)+(X<<1)+(c-48);++cnt;c=getchar();}
	}
	lint k3=X*F;
	if(k3==0) cnt=0;
	while((k3) && (k3%10==0)) k3/=10,--cnt;
	lint k1=x*f;
	a[id].p=cnt;
	while(cnt--) k1*=10;
	lint k2=k1+k3;
	while((k2) && (k2%2==0)) ++a[id].w2,k2/=2;
	while((k2) && (k2%5==0)) ++a[id].w5,k2/=5;
	return;
}

int main(void){

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%d",&n);
	for(int i=1;i<=n;i++) Read(i);
	// for(int i=1;i<=n;i++) printf("%d %d %d\n",a[i].w2,a[i].w5,a[i].p);
	for(int i=1;i<=n;i++){
		lint res=0;
		int w2=a[i].w2,w5=a[i].w5,p=a[i].p;
		for(int j=0;j<=w2-p+48;j++) for(int k=0;k<=w5-p+48;k++) res+=b[j][k];
		++b[p-w2+48][p-w5+48];
		ans+=res;
		// printf("%lld ",res);
		// printf("%d %d\n",max(a[i].p-a[i].w2,0),max(a[i].p-a[i].w5,0));
	}
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 6192
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll h;
    cin >> h;
    cout << setprecision(14) << powl(2, (ll)(log2l(h))+1) - 1 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	char a[n+1][m+1];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	int dp[n+1][m+1];
	memset(dp,0,sizeof(dp));
    dp[1][1]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(i==1 && j==1);
			else if(a[i][j]=='.')
				dp[i][j]=dp[i-1][j]+dp[i][j-1];
			dp[i][j]=dp[i][j]%1000000007;
		}
	}
	cout<<dp[n][m]<<endl;
		return 0;
}

Measured memory_bytes: 5120
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val a = new Array[Int](N+1)
  for (i <- 1 to N) {
    a(i) = in.next().toInt
  }

  //
  var ans: List[Int] = Nil
  val dp = new Array[Boolean](N+1)

  def calcDp(n: Int): Int = {
    var num = n.toLong + n
    var res = 0

    if (n == 1) {
      for (i <- 2 to N) 
        if (dp(i))
          res += 1
    }
    else {
      while(num <= N) {
        if (dp(num.toInt))
          res += 1
        num += n
      }
    }

    res
  }


  for (i <- (1 to N).reverse) {
    val tmp = calcDp(i)
    if (a(i) == 1) {
      if(tmp % 2 == 0) {
        ans = i :: ans
        dp(i) = true
      }
    }
    else {
      if(tmp % 2 == 1) {
        ans = i :: ans
        dp(i) = true
      }
    }
  }



  println(ans.length)
  println(ans.mkString(" "))
}

class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

string sed(string s,string a,string b){
    string res;
    for(int i=0;i<s.size();i++){
        if(i+a.size()<=s.size() && s.substr(i,a.size())==a){
            res+=b;
            i+=a.size()-1;
        }
        else{
            res+=s[i];
        }
    }
    return res;
}
void solve(int n){
    vector<string> a(n),b(n);
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    string x,y;
    cin>>x>>y;
    set<string> s;
    queue<pair<string,int>> que;
    que.push({x,0});
    while(!que.empty()){
        auto tmp=que.front(); que.pop();
        string str=tmp.first;
        int d=tmp.second;
        if(s.count(str)) continue;
        s.insert(str);
        if(y==str){
            cout<<d<<endl;
            return;
        }
        for(int i=0;i<n;i++){
            string to=sed(str,a[i],b[i]);
            if(to.size()>y.size()) continue;
            que.emplace(to,d+1);
            
        }
    }
    cout<<-1<<endl;
    return;
}
int main(){
    int n;
    while(cin>>n,n){
        solve(n);
    }
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(food) memset(food,0,sizeof(food))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;
    ll k;
    cin>>n>>k;
    int arr[n];
    rep(i,0,n)cin>>arr[i];
    sort(arr,arr+n,greater<int>());
    int food[n];
    rep(i,0,n)cin>>food[i];

    sort(food,food+n);
    ll prod[n];
    rep(i,0,n)prod[i]=arr[i]*(ll)food[i];
    ll l=0,r=1e12+2,mid;
    while(l<r)
    {
        mid=(l+r)/2;
        ll cost=0;
        rep(i,0,n)
        {
            if(prod[i]>mid)
            {
                ll m=mid/food[i];
                cost+=arr[i]-m;
            }
        }
        if(cost<=k)r=mid;
        else l=mid+1;
    }
    cout<<l;
    return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

const long long int MAX = pow(10, 9);

int main(){
	string n;
	cin >> n;
	if(n.at(0) == '9' || n.at(1) == '9') cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
/**
 * @author: Jenniekim
 * @date  : 02-21-2019
 **/
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define el '\n'
#define MOD 1000000007

int n, k;
int arr[100005], dp[100005];
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        cin >> arr[i];
    }

    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);

    for(int i=3;i<=n;i++){
        int g=1000000000;
        for(int j=1;j<=k;j++){
            if(i-j > 0){
                g = min(g, dp[i-j]+abs(arr[i]-arr[i-j]));
            }
        }
        dp[i]=g;
    }
    cout << dp[n] << el;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main() {
  long long n, m;
  cin >> n >> m;
  map<int, int> mp;
  for(int i = 1; i <= m; ++i) mp[i] = 0;
  long long c, e;
  for(int i = 0; i < n; ++i){
    cin >> c;
    for(int j = 0; j < c; ++j){
      cin >> e;
      mp[e]++;
    }
  }
  long long ans = 0;
  for(int i = 1; i <= m; ++i)
      if(mp[i] == n) ans++;
  cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a+b==c+d) printf("Balanced\n");
  else if(a+b>c+d) printf("Left\n");
  else printf("Right\n");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n = in();
  vi x(n), y(n), h(n);
  rep(i,n) cin >>x[i]>>y[i]>>h[i];
  int ih;
  rep(i,n) if(h[i]>0){ ih = i; break; }

  rep(cx,0,101){
    rep(cy,0,101){
      int H = h[ih]+abs(x[ih]-cx)+abs(y[ih]-cy);
      bool ok = true;
      rep(i,n){
        if(h[i]>0 && H!=h[i]+abs(x[i]-cx)+abs(y[i]-cy)) {
          ok = false;
        }
        if(h[i]==0 && H-abs(x[i]-cx)-abs(y[i]-cy)>0){
          ok = false;
        }
      }
      if(ok){ printf("%d %d %d", cx, cy, H); }
    }
  }
  return 0;
}


Measured memory_bytes: 256
N,D = map(int , input().split()) #第二引数(この場合だと---)を第一引数に変換(この場合だとint型)に変換する
ans = 0

for i in range(N) :
    x,y = map(int , input().split())
    if x**2 + y**2 <= D**2:
        ans += 1

print(ans)



Measured memory_bytes: 9132
n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
d = [1] * n
for i in range(m):
  a,b = list(map(int,input().split()))
  a -= 1
  b -= 1
  if h[a] > h[b]:
    d[b] = 0
  elif h[b] > h[a]:
    d[a] = 0
  else:
    d[a] = 0
    d[b] = 0

print(sum(d))

Measured memory_bytes: 19960
N=int(input())
x=[]
y=[]
for _ in range(N):
  a, b=map(int, input().split())
  x.append(a)
  y.append(b)

from math import factorial
from math import sqrt
ans=0

def d(x1, x2, y1, y2):
  return sqrt((x1-x2)**2+(y1-y2)**2)

num=factorial(N-1)*2
for i in range(N-1):
  for j in range(i+1,N):
    ans+=num*d(x[i],x[j],y[i],y[j])
print(ans/factorial(N))

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int A;
  int c = 1;
  cin >> A;
  rep(i, 10000) {
    if(c > A) {
      break;
    }
    c *= 2;
  }
  cout << c / 2 << endl;
}
    

Measured memory_bytes: 3624
import heapq
n = int(input())
a,b = [int(i) for i in input().split()],[]
for i in a: b.append(-i)
x,y = a[:n],b[2*n:]
heapq.heapify(x)
heapq.heapify(y)
num,num2 = sum(a[:n]),sum(a[2*n:])
a2,b2 = [num],[num2]
for i in range(n+1,2*n+1):
	j = 3*n+1-i
	num += a[i-1]-heapq.heappushpop(x,a[i-1])
	num2 += a[j-1]+heapq.heappushpop(y,b[j-1])
	a2.append(num)
	b2.append(num2)
b2,ans = b2[::-1],-float("inf")
for i in range(n+1): ans = max(ans,a2[i]-b2[i])
print(ans)

Measured memory_bytes: 39952
import java.util.Scanner;

public class Main {

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

    int N = sc.nextInt();
    
    long[] H = new long[N];
    for (int i = 0; i < N; i++) {
        H[i] = sc.nextLong();
    }

    int gMax = 0;
    int lMax = 0;
    for (int i = 1; i < N; i++) {
        // System.out.println("H[i]=" + H[i] + ", H[i-1]=" + H[i-1]);
        if (H[i] <= H[i-1]) {
            lMax++;
            gMax = Math.max(gMax, lMax);
        } else {
            lMax = 0;
            gMax = Math.max(gMax, lMax);
        }
    }

    System.out.println(gMax);
  }
}

Measured memory_bytes: 49064
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


a, b = LI()
if a>=13:
    print(b)
elif 12>=a>=6:
    print(b//2)
else:
    print(0)

Measured memory_bytes: 39664
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int X; cin >> X;
    
    string ans = "NO";
    if (X == 3 || X == 5 || X == 7) ans = "YES";

    cout <<  ans << endl;

    return 0;
}

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

class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){ roll(1, 2, 4, 3);}
  void roll_y(){ roll(0, 2, 5, 3);}
  void roll_x(){ roll(0, 1, 5, 4);}
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j]; f[j]= f[k]; f[k] = f[l]; f[l] = t;
  }
};

bool eq ( Cube c1, Cube c2 ){
  for ( int i = 0; i < 6; i++ ){
    if ( c1.f[i] != c2.f[i] ) return false;
  }
  return true;
}

bool equal ( Cube c1, Cube c2 ){
  for ( int i = 0; i < 6; i++ ){
    for ( int j = 0; j < 4; j++ ){
      if ( eq(c1, c2) ) return true;
      c1.roll_z();
    }
    if ( i % 2 == 0 ) c1.roll_y();
    else c1.roll_x();
  }
  return false;
}

int main(){
  Cube c1, c2;

  for (int i = 0; i <6; i++ ) cin >> c1.f[i];
  for (int i = 0; i <6; i++ ) cin >> c2.f[i];

  if ( equal(c1, c2) )cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3112
n, k = map(lambda x: int(x), input().split())
r, s, p = map(lambda x: int(x), input().split())
t = input()

rsp = [[r, 's'], [s, 'p'], [p, 'r']]
rsp.sort()
rsp.reverse()

sum = 0
t_list = [t[i] for i in range(len(t))]
temp_list = [t[i] for i in range(len(t))]
for hand in rsp:
  for i, _ in enumerate(t_list):
    if hand[1] == _:
      if i >= k and temp_list[i-k] != hand[1]:
        sum += hand[0]
      elif i < k:
        sum += hand[0]
      else:
        temp_list[i] = 'a'
print(sum)

Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int N, P;
	cin >> N >> P;
	vector<int> A(N);
	rep(i, N)cin >> A[i];
	vector<vector<ll>> dp(N + 1, vector<ll>(2, 0));
	//dp[i][j]...i個の袋の選び方, j：0ならば偶数, 1ならば奇数
	
	dp[0][0] = 1;
	
	rep(i, N){
		if(A[i] % 2 == 0){
			dp[i + 1][0] = dp[i][0] + dp[i][0];
			dp[i + 1][1] = dp[i][1] + dp[i][1];
		} else {
			dp[i + 1][0] = dp[i][1] + dp[i][0];
			dp[i + 1][1] = dp[i][0] + dp[i][1];
		}
	}
	cout << dp[N][P] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,c=0,d,add=0;
	cin >> n;
	int a[n],b[n];
	for(int i=0;i<n;i++)
		cin >> a[i];
	for(int i=0;i<n;i++)
		cin >> b[i];
	for(int i=1;i<n;i++)
	{
		d=0;
		for(int j=1;j <= i;j++)
			d += a[j]-b[j-1]; 
		if(d>c)
		{ 
			add=i;
			c=d;
		} 
	}
	int ans=0;
	for(int i=0;i<add+1;i++)
		ans += a[i]; 
	for(int i=add;i<n;i++)
		ans += b[i]; 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import  deque
S = input()
Q = int(input())
rev = 1
q = deque(list(S))
for _ in range(Q):
    op = input().split(" ")
    if int(op[0]) == 1:
        rev *= -1
    else:
        f, ch = op[1:]
        if rev == 1:
            if f == "1":
                q.appendleft(ch)
            else:
                q.append(ch)
        else:
            if f == "1":
                q.append(ch)
            else:
                q.appendleft(ch)
S = "".join(q)
if rev == -1:
    S = S[::-1]
print(S)

Measured memory_bytes: 8676
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		Console.ReadLine();
		int[] S = Console.ReadLine().Split().Select(str => int.Parse(str)).ToArray();
		int q = int.Parse(Console.ReadLine().Split()[0]);
		int[] T = Console.ReadLine().Split().Select(str => int.Parse(str)).ToArray();

		int count = 0;

		for (int i = 0; i < q; i++)
		{
			if (Check(S, T[i]))
			{
				count++;
			}
		}
		System.Console.WriteLine(count);
	}

	static bool Check(int[] S, int query)
	{
		int first = 0;
		int last = S.Length - 1;
		while (first <= last)
		{
			int pivot = (last + first) / 2;
			if (S[pivot] > query)
			{
				last = pivot - 1;
			}
			else if (S[pivot] < query)
			{
				first = pivot + 1;
			}
			else
			{
				return true;
			}
		}
		return false;
	}
}



Measured memory_bytes: 22888