akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<string>
#include <algorithm>

using namespace std;

int main(){
  int N,M,point,ans=0;
  cin>>N;
  vector<string> a(N);

  for(int i=0;i<N;i++)cin>>a.at(i);

  cin>>M;
  vector<string> b(M);
  for(int i=0;i<M;i++)cin>>b.at(i);
  
  for(int i=0;i<N;i++){
    point=0;
    for(int j=0;j<N;j++)
      if(a.at(i)==a.at(j))point++;
    for(int j=0;j<M;j++)
      if(a.at(i)==b.at(j))point--;
    ans=max(ans,point);
  }
  cout<<max(ans,0)<<endl;
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	vi arr(n);
	for(int &i:arr)cin>>i;
	int now = 1;
	for(int i:arr) {
		//cerr<<i<<" "<<now<<" ";
		if(i==now)now++;
	}
	if(now==1) cout<<-1;
	else cout<<n-now+1;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3956
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int num[110] = {0};
  int max = 0;
  vector<int> maxnum;
  int n;
  while(cin>>n){
    num[n]++;
    if(num[n] > max){
      maxnum.clear();
      maxnum.pb(n);
      max = num[n];
    }else if(num[n] == max){
      maxnum.pb(n);
    }
  }
  sort(all(maxnum));
  rep(i,maxnum.size())cout<<maxnum[i]<<endl;

}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int N;
vector<double> p;
vector<vector<double>> dp;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	p.assign(N, 0);
	dp.assign(N+1, vector<double>(N+1, 0));
	for(int i =0 ; i < N; i++){
		cin >> p[i];
	}

	double sol = 0;
	dp[0][0] = 1;
	for(int i = 1; i <= N; i++){
		for(int heads = i; heads >= 0; heads--){
			int tails = i - heads;

			dp[i][heads] += dp[i-1][heads-1]*p[i-1] + dp[i-1][heads]*(1 - p[i-1]);
			if (i == N && heads > tails) sol += dp[i][heads];
		}
	}

	printf("%.15f\n", sol);

	return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    llint h,n;
    cin>>h>>n;
    struct mahou{
        llint a,b;
        
    };
    vector<mahou> v(n);
    REP(i,n){
        cin >> v[i].a >> v[i].b;
    }
    vector<llint> dp(20000+1, inf);
    dp[0] = 0;
    REP(i,n){
        REP(j,20000+1){
            if(j+v[i].a<20000+1){
                dp[j + v[i].a] = min(dp[j + v[i].a], dp[j] + v[i].b);
            }
        }
    }
    llint result = linf;
    REP(i,20000+1){
        if(i>=h){
            result = min(result, dp[i]);
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 1016
# -*- coding:utf-8 -*-
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = [ list(map(int,input().split())) for i in range (M) ]

for tmp in range (M):
    ans = P[tmp][1]
    for tmp2 in range (N):
        if tmp2 == P[tmp][0] - 1:
            continue
        else:
            ans += T[tmp2]
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

void solve0(ll n) {
    V<ll> a(n);
    V<ll> sum0(n), sum1(n + 2);
    rep(i, n) {
        cin >> a[i];
        (i & 1 ? sum1 : sum0)[i] = a[i];
    }
    rep(i, n - 1) sum0[i + 1] += sum0[i];
    FORR(i, n - 1) sum1[i] += sum1[i + 1];

    ll ans = sum1[0];
    for(int i = 0; i < n; i += 2) {
        chmax(ans, sum0[i] + sum1[i + 2]);
    }
    cout << ans << endl;
    exit(0);
}

void solve1(ll n) {
    ll sum = 0;
    V<ll> a(n + 1);
    FOR(i, 1, n + 1) cin >> a[i], sum += a[i];
    V<V<ll>> dp(n + 1, V<ll>(2, inf));
    dp[0][0] = 0;
    FOR(i, 1, n + 1) {
        if(i & 1) {
            chmin(dp[i][1], dp[i - 1][0] + a[i]);
            if(i > 1) chmin(dp[i][1], dp[i - 2][1] + a[i]);
        } else {
            chmin(dp[i][0], min(dp[i - 1][0], dp[i - 2][0]) + a[i]);
            chmin(dp[i][1], min(dp[i - 1][1], dp[i - 2][1]) + a[i]);
        }
    }
    cout << sum - min(dp[n - 1][1], dp[n][1]) << endl;

    exit(0);
}

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

    ll n;
    cin >> n;
    if(n % 2 == 0) solve0(n);
    solve1(n);

    return 0;
}

Measured memory_bytes: 16160
n=int(input())
s=[input() for _ in range(n)]
t=input()
ls,fs=[],[]
for i in range(n):
    a = s[i].replace('?', 'a')
    z = s[i].replace('?', 'z')
    if a <= t <= z:
        fs.append(s[i])
    if z < t:
        ls.append(s[i])
l = len(ls)+1
r = l + len(fs)
print(' '.join(map(str,range(l, r+1))))


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

using namespace std;

#define ll long long
int m = 1000000007;

ll bin_pow(int a, int pow) {
    if (pow == 1) return a % m;
    if (pow % 2 == 0) {
        ll tmp = bin_pow(a, pow / 2) % m;
        return tmp * tmp % m;
    }
    return (a % m) * (bin_pow(a, pow - 1) % m) % m;
}

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

    char x;
    cin >> x;

    cout << (char) (x + 1);
    return 0;
}

Measured memory_bytes: 256
S = input()
flag = True
for i in range(len(S)):
  if (i+1) % 2 == 1:
    if S[i] =="R" or S[i] =="U" or S[i] =="D":
      pass
    else:
      flag = False
      break
  else:
    if S[i] =="L" or S[i] =="U" or S[i] =="D":
      pass
    else:
      flag = False
      break
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9016
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	static class Edge {
		int v;
		long cost;
		public Edge(int v, long cost) {
			this.v = v;
			this.cost = cost;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<List<Edge>> list = new ArrayList<>(n);
		for(int i = 0; i < n; i++) list.add(new ArrayList<>());
		for(int i = 0; i < n - 1; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			long c = sc.nextLong();
			list.get(a).add(new Edge(b, c));
			list.get(b).add(new Edge(a, c));
		}
		Queue<Integer> queue = new LinkedList<>();
		long[] sum = new long[n];
		boolean[] used = new boolean[n];
		int q = sc.nextInt();
		int k = sc.nextInt() - 1;
		queue.add(k);
		while(!queue.isEmpty()) {
			int now = queue.poll();
			used[now] = true;
			for(Edge e : list.get(now)) {
				if(!used[e.v]) {
					sum[e.v] = sum[now] + e.cost;
					queue.add(e.v);
				}
			}
		}
		for(int i = 0; i < q; i++) {
			int x = sc.nextInt() - 1;
			int y = sc.nextInt() - 1;
			System.out.println(sum[x] + sum[y]);
		}
	}
}


Measured memory_bytes: 180252
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

const int MAX = 2e5 + 1;
int n, arr[MAX], sum[MAX], ans;

signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		sum[i] = (arr[i] + sum[i - 1]) % MOD;
	}
	for (int i = 1; i < n; i++) {
		ans += (arr[i] * (sum[n] - sum[i] + MOD)) % MOD;
		ans %= MOD;
	}
	cout << ans;
}

Measured memory_bytes: 6720
# -*- coding: utf-8 -*-
"""
B - Resistors in Parallel
https://atcoder.jp/contests/abc138/tasks/abc138_b

"""
import sys


def solve(resistors):
    res = 0
    for r in resistors:
        res += 1 / r
    return 1 / res


def main(args):
    N = int(input())
    resistors = [int(a) for a in input().split()]
    ans = solve(resistors)
    print(ans)


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


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

using namespace std;

#define MAX 3005
string s, t;
int n, m;
int dp[MAX][MAX];
typedef pair<pair<int, int>, char> PII;
typedef pair<int,int> PI;
map<PI, PII> mp;

int main()
{
    cin >> s >> t;
    n = s.length(), m = t.length();
    memset(dp, 0, sizeof dp);
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(dp[i-1][j] > dp[i][j]){
                dp[i][j] = dp[i-1][j];
                //mp[make_pair(i, j)] = make_pair(make_pair(i-1, j), '#');
            }
            if(dp[i][j-1] > dp[i][j]){
                dp[i][j] = dp[i][j-1];
                //mp[make_pair(i, j)] = make_pair(make_pair(i, j-1), '#');
            }
            if(s[i-1] == t[j-1] && dp[i-1][j-1]+1 > dp[i][j]){
                dp[i][j] = dp[i-1][j-1]+1;
                //mp[make_pair(i, j)] = make_pair(make_pair(i-1, j-1), s[i-1]);
            }
        }
    }
    string ans = "";
    int x = n, y = m;
    while(x*y != 0){
        if(s[x-1] == t[y-1]){
			ans += s[x-1];
			x--;
			y--;
        }
        else {
            if(dp[x-1][y] > dp[x][y-1]) x--;
            else y--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
int INF=1e9+7;
int n;
struct mem
{
	char a;//储存字母 
	int digit;//储存数字 
};
struct mem stu[100005],ctu[100005];//stu，ctu分别用于归并排序和快速排序
struct mem R[100005],L[100005];
/*归并排序，归并排序是一种稳定的高级排序*/
int Merge(struct mem stu[],int left,int mid,int right)
{
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;i++) L[i]=stu[left+i];
	for(int i=0;i<n2;i++) R[i]=stu[mid+i];
	L[n1].digit=INF;
	R[n2].digit=INF;
	int i=0,j=0;
	for(int k=left;k<right;k++)
	{
		if(L[i].digit<=R[j].digit)
		{
			stu[k]=L[i];
			i++;
		}
		else 
		{
			stu[k]=R[j];
			j++;
		}
	 } 
	 return 0;
}
int MergeSort(struct mem stu[],int left,int right)
{
	if(left+1<right)
	{
		int mid=(left+right)/2;
		MergeSort(stu,left,mid);
		MergeSort(stu,mid,right);
		Merge(stu,left,mid,right);
	}
	return 0;
}
/*快速排序*/
int Partition(struct mem ctu[],int p,int r)//这里p,r分别是数组的第一个元素与最后一个元素的位置 
{
	struct mem temp=ctu[r];
	struct mem t;
	int i=p-1;
	for(int j=p;j<r;j++)
	{
		if(ctu[j].digit<=temp.digit)
		{
			i=i+1;
			t=ctu[i];
			ctu[i]=ctu[j];
			ctu[j]=t;
		}
	 }
	 t=ctu[i+1];
	 ctu[i+1]=ctu[r];
	 ctu[r]=t;
	  return i+1;
} 
int QuikSort(struct mem ctu[],int p,int r)
{
	int q;
	if(p<r)
	{
		q=Partition(ctu,p,r);
		QuikSort(ctu,p,q-1);
		QuikSort(ctu,q+1,r);
	}
}
int main()
{
	int flag=1;
	scanf("%d",&n);
	char s[10];
	int v;
	for(int i=0;i<n;i++)
	{
		scanf("%s %d",s,&v);
		stu[i].a=ctu[i].a=s[0];
		stu[i].digit=ctu[i].digit=v;
		//ctu[i]=stu[i];
	}
	MergeSort(stu,0,n);
	QuikSort(ctu,0,n-1);
	for(int i=0;i<n;i++)
	{
		if(stu[i].a!=ctu[i].a)
		{
			flag=0;
            break;
		}
	}
	if(flag) printf("Stable\n");
	else printf("Not stable\n");
	for(int i=0;i<n;i++)
	{
		printf("%c %d\n",ctu[i].a,ctu[i].digit);
	}
	return 0;
}



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

int main(void){
    int a,b;
    cin >> a >> b;

    int ar[] = {a+b, a-b, a*b};
    int max = ar[0];
    for(int i=1; i<3; i++){
        if(ar[i] > max){
            max = ar[i];
        }
    }
    cout << max;
}

Measured memory_bytes: 256
#D
S=int(input())
mod=10**9+7

N=S//3-1

dp=[[0 for i in range(S)] for j in range(N+1)]
wa=[[0 for i in range(S)] for j in range(N+1)]

for j in range(3,S-2):
    dp[1][j]=1
    wa[1][j]=wa[1][j-1]+1
    
for i in range(2,N+1):
    for j in range(3,S-2):
        dp[i][j]=wa[i-1][j-3]
        wa[i][j]=wa[i][j-1]+dp[i][j]
        
ans=1
for i in range(1,N+1):
    ans+=sum(dp[i])
    ans%=mod
    
if S<3:
    ans=0
print(ans)

Measured memory_bytes: 229404
#include <bits/stdc++.h>
using namespace std;
#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))
string ans="";
string tmp="";
vector<string> v;
vector<vector<int>> vv;
vector<vector<string>> dp;
int w,h;
bool check(int a,int b){
    if(0<=a&&a<h&&0<=b&&b<w) return true;
    return false;
}
string cmp(string a,string b){
    if(a.size()<b.size()) return b;
    if(a.size()>b.size()) return a;
    if(a>b) return a;
    return b;
}
string foo(int a,int b){
    // tmp+=v[a].substr(b,1);
    if(vv[a][b]) return dp[a][b];
    vv[a][b]=1;
    // if(ans.size()<tmp.size()) ans=tmp;
    // else if(ans.size()==tmp.size()&&ans<tmp) ans=tmp;
    string ret="";
    if(check(a+1,b)&&isdigit(v[a+1][b])) ret=cmp(ret,foo(a+1,b));
    if(check(a,b+1)&&isdigit(v[a][b+1])) ret=cmp(ret,foo(a,b+1));
    // tmp=tmp.substr(0,tmp.size()-1);
    return dp[a][b]=v[a].substr(b,1)+ret;
}
int main(){
    while(cin>>w>>h,h||w){
        v.clear();
        v=vector<string>(h);
        vv=vector<vector<int>>(h,vector<int>(w,0));
        dp=vector<vector<string>>(h,vector<string>(w,""));
        rep(i,h){
            cin>>v[i];
        }
        ans="";
        rep(i,h){
            rep(j,w){
                if(isdigit(v[i][j])&&v[i][j]!='0'){
                    if(vv[i][j]) continue;
                    ans=cmp(ans,foo(i,j));
                    // cout<<i<<" "<<j<<" "<<v[i][j]<<" "<<ans<<endl;
                }
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1380
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
3
())
---+/
/+---test
6
)))())
---+/
/+---test
8
))))((((
---+/

void main(string[] args) {
  const N = readln.chomp.to!long;
  const S = readln.chomp;

  long dep, lcnt;
  foreach (c; S) {
    if (c == '(') ++dep;
    if (c == ')') {
      if (dep > 0) {
        --dep;
      } else {
        ++lcnt;
      }
    }
  }
  (cycle("(").take(lcnt).array.to!string~S~cycle(")").take(dep).array.to!string).writeln;
}


Measured memory_bytes: 256
use proconio::input;
use std::cmp::min;

fn main() {
    input! {
        n: usize,
        h: [i32; n],
    }

    let mut dp = vec![0; n];

    for i in 1..n {
        if i > 1 {
            // i-1 か i-2 からしか来ることはない
            dp[i] = min(dp[i - 1] + (h[i - 1] - h[i]).abs(), 
                        dp[i - 2] + (h[i - 2] - h[i]).abs())
        } else {
            // i-2 < 1 のときに i-2 はないので i-1のみ
            dp[i] = dp[i - 1] + (h[i - 1] - h[i]).abs();
        }
    }
    println!("{}", dp[n - 1]);
}


Measured memory_bytes: 3184
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

struct UnionFind {
	vector<int> data;
	void init(int n) { data.assign(n, -1); }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if(x != y) {
			if(data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
};

int main() {
	int N; int M;
	while(~scanf("%d%d", &N, &M)) {
		UnionFind uf;
		uf.init(N + M);
		rep(i, N) {
			int K;
			scanf("%d", &K);
			rep(j, K) {
				int L;
				scanf("%d", &L), -- L;
				uf.unionSet(i, N + L);
			}
		}
		bool ans = true;
		rep(i, N)
			ans &= uf.findSet(0, i);
		puts(ans ? "YES" : "NO");
	}
	return 0;
}


Measured memory_bytes: 1024
// test.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#include <iostream>
#include <algorithm>
#include <vector>




using namespace std;


int main()
{
	// 整数の入力
	int N;
	cin >> N;
	
	
	int count = 0;
	for (int i = 1; i < N+1; i++) {
		if (i % 2 != 0) {
			count++;
		}
	}
	double answer = (double)count / N;

	cout << answer << endl;
	
	return 0;
}





// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

int main() {
  int N;
  cin >> N;
  int former;
  cin >> former;
  former--;
  bool check = true;
  for(int i = 1; i < N; i++) {
    int h;
    cin >> h;
    if(h > former) {
      former = h - 1;
    }
    else if(h == former) {
      former = h;
    }
    else {
      check = false;
      break;
    }
  }
  if(check) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }  
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	while (s.size() < 15)
	{
		s += 'o';
	}
	int win = 0;
	for(int i = 0; i < 15; i++)
	{
		if (s[i] == 'o') win++;
	}
	if (win >= 8) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;

#define YES(condition) if(condition) cout << "YES" << endl; else cout << "NO" << endl
#define Yes(condition) if(condition) cout << "Yes" << endl; else cout << "No" << endl
#define POSS(condition) if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl
#define Poss(condition) if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl
#define First(condition) if(condition)cout << "First" << endl; else cout << "Second" << endl
#define negative(condition, num) if(condition)cout << -1 << endl; else cout << num << endl
long power(long base, long exponent, long mod){ if(exponent % 2){ return power(base, exponent - 1, mod) * base % mod; }else if(exponent){ long root_ans = power(base, exponent / 2, mod); return root_ans * root_ans % mod; }else{ return 1; }}

int main(){
    long X, Y;
    cin >> X >> Y;
    if(abs(X - Y) >= 2){
        cout << "Alice" << endl;
    }else{
        cout << "Brown" << endl;
    }
}



Measured memory_bytes: 256
from collections import Counter
H,W,N = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(N)]

blacks = Counter()
for y,x in src:
    for i in range(-1,2):
        if not 0 <= y+i < H: continue
        for j in range(-1,2):
            if not 0 <= x+j < W: continue
            blacks[(x+j, y+i)] += 1

ans = [0] * 10
for (x,y),v in blacks.items():
    if x<2 or y<2: continue
    ans[v] += 1
ans[0] = (H-2)*(W-2) - sum(ans[1:])
print(*ans,sep='\n')

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

#define Bye return 0
#define ll long long

using namespace std;
const int MAX = 1e-6;

void solve(){
    int n; cin>>n;
    printf("%.12f\n", (double) n*n*n/27);
}

int main(){
    solve();
    Bye;
}


Measured memory_bytes: 3744
#include <stdio.h>
 
int main()
{
  int a[4],b,c;
  scanf("%d%d%d",&a[0],&a[1],&a[2]);
  b = a[0] - a[2];
  c = a[0] - a[1];
  if (b < 0)
    b *= -1;
  if (c < 0)
    c *= -1;
  if (b < c)
  	printf("B");
  else
    printf("A");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

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

	int m;
	cin >> m;
	int ans = 24 - m + 24;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i, a, b, c, k;
  long max = 0;
  
  scanf("%d %d %d %d", &a, &b, &c, &k);
  
  for(i = 0; (i < a) && (k > 0); i++){
    max += 1;
    k--;
  }
  
  for(i = 0; (i < b) && (k > 0); i++){
   	k--;
  }
  
  for(i = 0; (i < c) && (k > 0); i++){
    max -= 1;
    k--;
  }
  
  printf("%ld\n",max);
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define PI 3.14159265359
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
typedef vector<pair<ll,ll> > vpii;
typedef vector<ll> vi;
const ll INF=1e13+7;
void input(ll *a,ll n){
    for(ll i=0;i<n;i++)cin>>a[i];
}
ll lcm(ll a,ll b){return (a*b)/__gcd(a,b);}
bool isprime(ll n){
    if(n==1)return false;
    if(n==2 || n==3)return true;
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0)return false;
    }
    return true;
}
//ll x[100001]={0};
ll a[200001]={0};
//ll b[100001]={0};
//bool c[1000001]={0};
//vector<pair<ll,ll> > adj[100001];
//vector<pair<pair<ll,ll>,ll> > edge;
//vector<ll> adj[200001];
//vpii edges;
////bool color[200001]={0};
//ll dist[100001]={0};

ll binary_expon(ll a,ll b){
    ll res=1;
    while(b){
        if(b%2)res=(res*a)%INF;
        a=(a*a)%INF;
        b/=2;
    }
    return res%INF;
}

void sieve(ll n,bool *a)
{
    for (ll p=2; p*p<=n; p++){
        if (!a[p]){
            for (ll i=p*p;i<=n;i+=p)
                a[i]=true;
        }
    }
}

ll fact(ll n){
    ll res=1;
    for(ll i=1;i<=n;i++)res*=i;
    return res;
}

double distance(ll x1,ll y1,ll x2,ll y2){
    return (sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
}

/*void tree_dfs(ll curr,ll prev){
    for(auto u:adj[curr]){
        if(u!=prev){
            tree_dfs(u,curr);
        }
    }
}*/

/*void dfs(ll x,ll y){
    if(x<0 || y<0 || x>=n || y>=m)return;
    //if(grid[x][y]!=color)return;
    if(visited[x][y] || Map[x][y]=='#'){
        //f=true;
        return;
    }
    visited[x][y]=true;
    Map[x][y]='#';
    //if(px!=(x+1) || py!=y)
        dfs(x+1,y);
    //if(px!=(x-1) || py!=y)
        dfs(x-1,y);
    //if(px!=(x) || py!=y+1)
        dfs(x,y+1);
    //if(px!=(x) || py!=y-1)
        dfs(x,y-1);
}*/

/*bool isVowel(char c){
    return(c=='a'||c=='e'||c=='i'||c=='o'||c=='u');
}*/
//ll grid[1001][1001]={0};

/*void dfs(ll s){
    if(visited[s])return;
    visited[s]=true;
    for(auto u:adj[s]){
        dfs(u);
        dp[s]=max(dp[s],1+dp[u]);
    }
}*/
//set<pair<ll,ll> >edges;
/*vector<ll> z(string s) {
    ll n=s.length();
    vector<ll> z(n);
    ll x=0,y=0;
    for(ll i=1;i<n;i++) {
        z[i]=max(0ll,min(z[i-x],y-i+1));
        while(i+z[i]<n&&s[z[i]]==s[i+z[i]]){
            x = i; y = i+z[i]; z[i]++;
        }
     }
    return z;
}*/
ll dp[3001][3001];

void solve(){
    ll n;cin>>n;
    input(a,n);    

    for(ll i=0;i<n;i++){
        dp[i][i]=a[i];
    }

    for(ll i=n-1;i>=0;i--){
        for(ll j=i;j<n;j++){
            dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
        }
    }

    cout<<dp[0][n-1];
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    //sieve(1000001,c);
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++){
        solve();
    }
}


Measured memory_bytes: 49732
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int cnt1,cnt2;
const int MXV=100005;
vl G[MXV];
vl d(MXV,0);

void dfs(int v,int p){
    rep(i,G[v].size()){
        if(G[v][i]!=p){
            dfs(G[v][i],v);
          	d[v]^=d[G[v][i]]+1;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    rep(i,n-1){
        int u,v;
        cin >> u >> v;
        G[u].pb(v);
        G[v].pb(u);
    }
    dfs(1,0);
    if(d[1]==0){
        cout << "Bob" << endl;
    }
    else{
        cout << "Alice" << endl;
    }
}

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

#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

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

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)


void solve(){
    rep(i,5){
        int a; cin >> a;
        if(a==0){ cout << i+1 << endl; return;}
    }

}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    string S,T;
    cin >> S >> T;
    int num = S.size();
    int ans = 0;
    rep(i,num){
        if(S[i] != T[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ll x = min(a, k);
    k -= x;
    ans += x;
    x = min(b, k);
    k -= x;
    ans += 0;
    x = min(c, k);
    k -= x;
    ans -= x;

    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    int flag = false;
    
    std::cin >> n;
    
    for(int i = 0; i < 16; i++){
        for(int j = 0; j < 26; j++){
            if( i != 0 || j != 0){
                if( n % (i * 7 + j * 4) == 0){
                    flag = 1;
                }
            }
        }
    }
    
    if(flag) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
using namespace std;
int main() {
	int n;
	long double x1, y1, x2, y2, x3, y3, x4, y4;
	cin >> n;
	for (int z = 0; z < n; z++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		if((y2-y1)/(x2-x1)==(y4-y3)/(x4-x3)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 3204
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
#define intmax 2147483647
#define intmin –2147483648
#define llmax 9223372036854775807
#define llmin -9223372036854775808
using namespace std;

int n, m;
ll ans;

int main(){
	cin >> n >> m;
	if (n - 1 != m&&n != m&&n + 1!=m) {
		cout << 0 << endl;
		return 0;
	}
	ans = 1;
	lp(n)
		ans = (ans*(i + 1)) % mod;
	lp(m)
		ans = (ans*(i + 1)) % mod;
	if (n == m)
		ans = (ans * 2) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.begin(),a.end(), greater<int>());;
  int Alice = 0; int Bob = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) Alice += a[i];
    else if (i % 2 == 1) Bob += a[i];
  }
  cout << Alice - Bob << endl;
  return 0;
}

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

int dp[101][101];

int main() {
  int n;
  cin >> n;
  vector<int> p(n + 1);
  rep(i, n) cin >> p[i] >> p[i + 1];

  for (int l = 2; l <= n; ++l) {
    for (int i = 1; i <= n - l + 1; ++i) {
      int j = i + l - 1;
      dp[i][j] = __INT_MAX__;
      for (int k = i; k <= j - 1; ++k) {
        dp[i][j] =
            min(dp[i][j], dp[i][k] + dp[k + 1][j] + p[i - 1] * p[k] * p[j]);
      }
    }
  }
  cout << dp[1][n] << endl;

  return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>
#include <algorithm>  // fill 関数を使うのに必要
#define PN_NUM 1000000    // 1000000 未満の非負数を素数判定する
using namespace std;

bool prime_number[PN_NUM];

// エラトステネスのふるい
void set_prime_number(bool* array) {

  fill(array, array + PN_NUM, true); // array の全要素を true にする
  array[0] = array[1] = false; // 0 と 1 は素数ではない
  for (int i = 2; i < PN_NUM; i++) {
    if (!array[i])
      continue;
    for (int j = i * 2; j < PN_NUM; j += i) {
      array[j] = false; // 素数の倍数は，素数ではない
    }
  }

}

int main() {
  int cnt, n;

  set_prime_number(prime_number);
  while (scanf("%d", &n) != EOF) {
    cnt = 0;
    for (int i = 0; i <= n; i++) {
      if (prime_number[i]) // i が素数ならば
        cnt++;             // cnt をインクリメント
    }
    printf("%d\n", cnt);   // cnt を出力
  }

  return 0;
}

Measured memory_bytes: 2000
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,K;
LL x[51];
LL y[51];
typedef pair<LL,LL>P;

LL check(int a,int b){
   LL ay=min(y[a],y[b]);
   LL by=max(y[a],y[b]);
   vector<P>v;
   REP(i,N){
       if(ay<=y[i]&&y[i]<=by){
          v.push_back(P(x[i],y[i]));
       }
   }
   sort(v.begin(),v.end());
   if(v.size()<K)return 5*1e18;
   LL ans=5*1e18;
   for(int i=0;i+K-1<v.size();i++){
       LL ax=v[i].first;
       LL bx=v[i+K-1].first;
       ans=min(ans,(bx-ax)*(by-ay));
   }
   return ans;
}

int main(){
    cin>>N>>K;
    REP(i,N){
        cin>>x[i]>>y[i];
    }
    LL ans=5*1e18;
    REP(i,N){
        REP(j,i){
            ans=min(ans,check(i,j));
        }
    }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 256
while true
  n, arr = gets.to_i, []
  
  break if n == 0
  
  n.times do |i|
    arr[i] = gets.split.map(&:to_i)
    arr[i][n] = 0
    
    n.times do |j|
      arr[i][n] += arr[i][j]
    end
  end
  
  arr[n] = Array.new(n + 1, 0)
  
  (n + 1).times do |i|
    (n + 1).times do |j|
      arr[n][i] += arr[j][i] unless j == n
      print sprintf("%5d", arr[i][j])
    end
    puts
  end
end

Measured memory_bytes: 6124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for(int i=0; i<n; i++){
        cin >> h[i];
    }

    vector<int> GorB(n);
    for(int i=0; i<m; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        if(h[a] < h[b]){
            GorB[a]++;
        }
        else if(h[b] < h[a]){
            GorB[b]++;
        }
        else if(h[b] == h[a]){
            GorB[a]++;
            GorB[b]++;
        }
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        if(GorB[i] == 0) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4052
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var p = next();
  var a = [0,0];
  for(var i = 0; i < n; i++)a[next() & 1]++;
  var ans = 0;
  if(p && a[1] === 0)return 0;
  for(var i = p; i <= a[1]; i+=2)ans += ncr(a[1],i);
  return ans * Math.pow(2,a[0]);
}
function ncr(n,r){
  var res = 1;
  if(r > n-r)r = n-r;
  for(var i = 0 ;i < r; i++)res *= n-i, res /= i+1;
  return res;
}

Measured memory_bytes: 29636
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int N=200005;
int n,p[N],a[N],rt[N],s[N][2],ch[N][2];
vector<int> vec[N];
ll ans;
bool cmp(int a,int b){
	return 1LL*s[a][1]*s[b][0]<1LL*s[b][1]*s[a][0];
}
int merge(int x,int y){
	if(!x||!y){
		return x+y;
	}
	if(cmp(y,x)){
		swap(x,y);
	}
	ch[x][0]=merge(ch[x][0],y);
	swap(ch[x][0],ch[x][1]);
	return x;
}
void dfs(int u){
	s[u][a[u]]=1;
	for(int v:vec[u]){
		dfs(v);
		rt[u]=merge(rt[u],rt[v]);
	}
	while(rt[u]&&cmp(rt[u],u)){
		ans+=1LL*s[u][1]*s[rt[u]][0];
		s[u][0]+=s[rt[u]][0];
		s[u][1]+=s[rt[u]][1];
		rt[u]=merge(ch[rt[u]][0],ch[rt[u]][1]);
	}
	rt[u]=merge(rt[u],u);
}
int main(){
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		scanf("%d",&p[i]);
		vec[p[i]].push_back(i);
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	dfs(1);
	int tmp=0;
	while(rt[1]){
		ans+=1LL*tmp*s[rt[1]][0];
		tmp+=s[rt[1]][1];
		rt[1]=merge(ch[rt[1]][0],ch[rt[1]][1]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 35196
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int b = sc.nextInt();
		int c = sc.nextInt();
        int d = sc.nextInt();
        int e = Math.max(a,c);
        int f = Math.min(b,d);
		System.out.println(Math.max(0,f-e));
	}
}


Measured memory_bytes: 21972
S=input()
L=len(S)

from itertools import product

P=product(range(2),repeat=L-1)

ans=0
for p in P:
    s=0
    temp=S[0]
    for i in range(L-1):
        if p[i]==1:
            s+=int(temp)
            temp=S[i+1]
        else:
            temp+=S[i+1]
    s+=int(temp)
    ans+=s
print(ans)

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

const int MAXN = 110;

int a[MAXN], c[MAXN];

int main(){
	int N, d = 0;
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i){
		scanf("%d", &a[i]), ++c[a[i]];
		if (a[i] > d)
			d = a[i];
	}
	bool flag = 0;
	if (d & 1){
		if (c[d + 1 >> 1] != 2)
			flag = 1;
		for (int i = d + 1 >> 1; i <= d; ++i)
			if (c[i] < 2){
				flag = 1;
				break;
			}
		for (int i = d >> 1; i >= 1; --i)
			if (c[i]){
				flag = 1;
				break;
			}
	}
	else {
		if (c[d >> 1] != 1)
			flag = 1;
		for (int i = (d >> 1) + 1; i <= d; ++i)
			if (c[i] < 2){
				flag = 1;
				break;
			}
		for (int i = (d >> 1) - 1; i >= 1; --i)
			if (c[i]){
				flag = 1;
				break;
			}
	}
	if (flag)
		printf("Impossible");
	else
		printf("Possible");
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main(){
	int a,b,c,d;
	scanf("%d %d",&a,&b);
	if(b<10) a*=10;
	else if(b<100) a*=100;
	else a*=1000;
	c=a+b;
    d=sqrt(c);
    if(c==d*d) printf("Yes\n");
    else printf("No\n");
    return 0;
}
	

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

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

    int N; cin>>N;
    vector<int> x(N),y(N);
    for(int i=0;i<N;i++) cin>>x[i]>>y[i];

    vector<int> p(N);
    for(int i=0;i<N;i++) p[i]=i;

    auto calc=[&]()
    {
        double res=0.0;
        for(int i=0;i<N-1;i++){
            res+=hypot(abs(x[p[i]]-x[p[i+1]]),abs(y[p[i]]-y[p[i+1]]));
        }
        return res;
    };
    
    double ans=0.0;
    do{
        ans+=calc();
    }while(next_permutation(p.begin(),p.end()));

    for(int i=1;i<=N;i++) ans/=i;
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}

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

int main(){
    char set[1001];
    while(1){
        int sum = 0, i = 0;
        cin >> set;
        if(set[0]=='0') break;
        
        while(set[i]!='\0'){
            sum += set[i] - '0';
            i++;
        }
        cout << sum << endl;
    }
    return 0;
}



Measured memory_bytes: 3032
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
int n , k ;
vector<int> a ;
vector<bool> vis ;
vector<int> dp ;
int start = -1 ;
int current = -1 ;
void dfs(int x, int cur){
    if ( cur == 0 ){
        cout << x + 1 << endl;
        exit(0) ;
    }
    if ( vis[x] ) {
        start = x ;
        current = cur ;
        return ;
    }
    vis[x] = true ;
    dp[x] = 0 ;
    dfs(a[x], cur - 1) ;
    dp[x] = 1 + dp[a[x]] ;
}
void dfs2(int x, int cur){
    if ( cur == 0 ){
        cout << x + 1 << endl;
        exit(0) ;
    }
    dfs2(a[x], cur - 1) ;
}
signed main(){
    fastio
    cin >> n >> k ;
    a = vector<int>(n) ;
    dp = vector<int>(n, -1) ;
    vis = vector<bool>(n) ;
    for(int i = 0; i < n; i++){
        cin >> a[i] ;
        a[i]--;
    }
    dfs(0, k) ;
    debug() << imie(dp) ;
    dfs2(start, current % dp[start]);
    return 0; 
}

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

#define NULL -1

#ifdef LOCAL
#define MAX 50
#endif

#ifndef LOCAL
#define MAX 2050
#endif

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ll long long

int solve(int C[MAX][MAX], int x, int y, int K) {
	int cnt = 0;
	int x1, x2, x3, y1, y2, y3;

	if (x == 0) x1 = NULL;
	else x1 = x - 1;

	if (x + K - 1 >= 2 * K) x2 = 2 * K - 1;
	else x2 = x + K - 1;

	if (x2 == 2 * K - 1) x3 = NULL;
	else x3 = 2 * K - 1;

	if (y == 0) y1 = NULL;
	else y1 = y - 1;

	if (y + K - 1 >= 2 * K) y2 = 2 * K - 1;
	else y2 = y + K - 1;

	if (y2 == 2 * K - 1) y3 = NULL;
	else y3 = 2 * K - 1;

	if ((x1 != NULL) && (y1 != NULL)) cnt += C[x1][y1];

	if ((x1 != NULL) && (y3 != NULL)) {
		cnt += C[x1][y3];
		cnt -= C[x1][y2];
	}

	if ((x3 != NULL) && (y1 != NULL)) {
		cnt += C[x3][y1];
		cnt -= C[x2][y1];
	}

	cnt += C[x2][y2];
	if (x1 != NULL) cnt -= C[x1][y2];
	if (y1 != NULL) cnt -= C[x2][y1];
	if ((x1 != NULL) && (y1 != NULL)) cnt += C[x1][y1];

	if ((x3 != NULL) && (y3 != NULL)) {
		cnt += C[x3][y3];
		cnt -= C[x2][y3];
		cnt -= C[x3][y2];
		cnt += C[x2][y2];
	}

	return cnt;
}

int main() {
	int N, K; scanf("%d%d", &N, &K);
	int C[MAX][MAX]; FOR(i, 0, MAX) FOR(j, 0, MAX) C[i][j] = 0;

	FOR(i, 0, N) {
		ll x, y; char s[5]; scanf("%lld%lld%s", &x, &y, &s);
		if (s[0] == 'B') C[x % (2 * K)][y % (2 * K)]++;
		else C[x % (2 * K)][(y + K) % (2 * K)]++;
	}

	FOR(i, 0, 2 * K) FOR(j, 1, 2 * K) C[i][j] += C[i][j - 1];
	FOR(i, 0, 2 * K) FOR(j, 1, 2 * K) C[j][i] += C[j - 1][i];

	int m = 0;

	FOR(i, 0, K) FOR(j, 0, K) { 
		if (m < solve(C, i, j, K)) m = solve(C, i, j, K); 
		if (m < N - solve(C, i, j, K)) m = N - solve(C, i, j, K);
	}

	printf("%d\n", m);

	return 0;
}

Measured memory_bytes: 16640