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

int main(){
    string S;
    char c;
    cin >> S;
    bool flag = false;

    sort(S.begin(),S.end());
    for(int i = 0 ,c = 'a'; c <= 'z';i++,c++){
        flag = false;
        for(int j = 0 ; j < S.length();j++){
            if(S[j] == c) flag = true; 
        }
        if(!flag){
            cout << (char)c;
            return 0;
        }
    }
    cout << "None";
}

Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cmath>
using namespace std;
#define lgx cerr<<"------------"<< endl;
#define debug(x) cerr<< #x << "=" << x << endl;

int main() {
	int a, b;
	while(cin >> a >> b) {
		int ans = 0;
		for (int i = a; i <= b; i++){
			int num = i;
			string s;
			while(num) {
				int x = num%10;
				num /= 10;
				s += (x+'0');
			}
			int l = 0, r = s.size()-1, flag = 0;
			while(l <= r) {
				if(s[l] != s[r]){
					flag = 1;
					break;
				}
				l++; r--;
			}
			if(!flag) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*********************************************************************| 
|---------|    /\  ....                  ....                         |         
     |        /  \   \                    /  /------| ----- |-------| |
     |       /    \   \                  /  /           |   |         |
     |      /      \   \       /\       /  |            |   |         |
     |     /        \   \     /  \     /   |---|        |   |----|    |
     |    /__________\   \   /    \   /        |---|    |   |         |
     |   /            \   \ /      \ /              |   |   |         |
     |  /              \   |        |               /   |   |         |
     _ __              __ ...      ...      |------/  ----- _         |
                                                                      |  
        Md Tawsif Rahman                                              |
        Institute Of Information Technology                           |
        Jahangirnagar University                                      |                                                                         
                                                                      |
**********************************************************************/                 
#include<bits/stdc++.h>

using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define pii pair <int, int>
#define xx first
#define yy second
#define vi vector < int >
#define vl vector < ll >
#define inf  100000000 
#define f(i, c, n) for(i = c; i < n; i++)
#define fe(i, c, n) for(i = c; i <= n; i++)
#define fr(i, n, c) for(i = n - 1; i >= 0; i--) 
#define vbe(a) a.begin(), a.end()
#define vsort(a) sort(a.begin(), a.end())
#define mem(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define srti(a, n) sort(a, a + n)
#define srtd(a, n) sort(a, a + n, greater<int>())
#define LB(a, x) (lower_bound(vbe(a), x) - a.begin())
#define UB(a, x) (upper_bound(vbe(a), x) - a.begin())

#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

int convert_str_to_int(string s) {
    stringstream str(s);
    int x = 0;
    str >> x;
    return x;
}



int i, j, k, cs, n;


void solve() {
    int a, b; cin >> a >> b;
    if(a + b < 10) cout << a + b << endl;
    else printf("error\n");

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math;
/*Question
/????§???¢???2??? a, b ??¨?????????????§? C ???????????????????§???¢?????¢??? S?????¨????????? L, a ???????????¨????????¨???????????? h ????±???????????????°?????????????????????????????????
*/
/*Input
/a ?????????, b ?????????, C?????§??????(???)(??´??°)????????????????????§?????????????????????
*/

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		//????????¨
		StringBuffer b = new StringBuffer();
		/*??\?????¨
		/??????????????§????????????String[]???????????????double[]?????????
		/z[0]???a???z[1]???b???z[2]???C?????????
		*/
		String[] st = sc.readLine().split(" ");
		double[] z = new double[st.length];
		for(int i = 0;i < st.length;i++){
			z[i] = Double.parseDouble(st[i]);
		}
		/*?¨????
		/a*b*sinc/2??§??¢???
		/???????????????x??¨?????????x^2=a^2+b^2-2abcosc??§?±????????????§?±?????????????
		/sin,cos???????????¢????????????(Math.PI / 180)????????????????????°?????????????????¨?????¨???
		*/
		double s = z[0]*z[1]/2*Math.sin(z[2]*(Math.PI / 180));
		b.append(s+"\n");
		double x = Math.sqrt(Math.pow(z[0], 2)+Math.pow(z[1], 2)-2*z[0]*z[1]*Math.cos(z[2]*(Math.PI / 180)));
		double l = z[0] + z[1] + x;
		b.append(l+"\n");
		double h = 2*s/z[0];
		b.append(h);
		System.out.println(b);
	}
}

Measured memory_bytes: 24144
#include<bits/stdc++.h>
using namespace std;
int main(){
    char n[5];
    n[0]='a';
    for(int i=1;i<5;i++){
        cin>>n[i];
        if(n[i-1]==n[i]){
            cout<<"Bad"<<endl;
            return(0);
        }
    }
    cout<<"Good"<<endl;
    return(0);
}

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

int main(){
	int h,w;
	cin>>h>>w;
	vector<vector<char>>s(h,vector<char>(w));
	bool hantei=false;
	int kazu=0;
	for(int i=0;i<h;i++){
		for (int j = 0; j < w; j++)
		{
			cin>>s[i][j];
			if(s[i][j]=='#')kazu++;
		}
	}
	int count=0;
	for(int i=0;i<h;i++){
		for (int j = 0; j < w; j++)
		{
			
			if(s[i][j]=='#'){
				if(i!=h-1&&s[i+1][j]=='#'){
					hantei=true;
					count++;
				}else if(j!=w-1&&s[i][j+1]=='#'){
					hantei=true;
					count++;
				}else if(i!=0&&s[i-1][j]=='#'){
					hantei=true;
					count++;
				}else if(j!=0&&s[i][j-1]=='#'){
					hantei=true;
					count++;
				}
			}
		}
	}
	if(kazu==count){
    	cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main 
{
	static int n;
	static long w;
	static ArrayList<Long> w1 = new ArrayList<Long>();
	static ArrayList<Long> w2 = new ArrayList<Long>();
	static ArrayList<Long> w3 = new ArrayList<Long>();
	static ArrayList<Long> w4 = new ArrayList<Long>();

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		n = sc.nextInt();
		w = sc.nextLong();
		
		long w0 = 0;
		for(int i = 0; i < n; i++)
		{
			long wt = sc.nextLong();
			long val = sc.nextLong();
			
			if(i==0)w0=wt;
			if(wt==w0)w1.add(val);
			else if(wt==w0+1)w2.add(val);
			else if(wt==w0+2)w3.add(val);
			else if(wt==w0+3)w4.add(val);
		}
		
		w1.sort(Collections.reverseOrder());
		w2.sort(Collections.reverseOrder());
		w3.sort(Collections.reverseOrder());
		w4.sort(Collections.reverseOrder());
		
		int n1 = w1.size();
		int n2 = w2.size();
		int n3 = w3.size();
		int n4 = w4.size();
		long[] s1 = new long[n1+1];
		long[] s2 = new long[n2+1];
		long[] s3 = new long[n3+1];
		long[] s4 = new long[n4+1];
		
		for(int i = 0; i < n1; i++)
		{
			s1[i+1] = w1.get(i) + s1[i];
		}
		for(int i = 0; i < n2; i++)
		{
			s2[i+1] = w2.get(i) + s2[i];
		}
		for(int i = 0; i < n3; i++)
		{
			s3[i+1] = w3.get(i) + s3[i];
		}
		for(int i = 0; i < n4; i++)
		{
			s4[i+1] = w4.get(i) + s4[i];
		}
		
		long best = 0;
		for(int i1 = 0; i1 <= n1 && w0*i1 <= w; i1++)
			for(int i2 = 0; i2 <= n2 && w0*i1+(w0+1)*i2 <= w; i2++)
				for(int i3 = 0; i3 <= n3 && w0*i1+(w0+1)*i2+(w0+2)*i3 <= w; i3++)
					for(int i4 = 0; i4 <= n4 && w0*i1+(w0+1)*i2+(w0+2)*i3+(w0+3)*i4 <= w; i4++)
					{
						best = Math.max(best, s1[i1]+s2[i2]+s3[i3]+s4[i4]);
					}
		
		System.out.println(best);
		
	}

}


Measured memory_bytes: 23764
#include <stdio.h>

int main(void) {
  int r, w, c, r2, ans;
  while (1) {
    scanf("%d %d %d %d", &r, &w, &c, &r2);
    if (r == 0 && w == 0 && c == 0 && r2 == 0) return 0;

    if (w * c - r < 0) ans = 0;
    else if ((w * c - r) % r2 == 0)
      ans = (w * c - r) / r2;
    else
      ans = (w * c - r) / r2 + 1;
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  int x, y;
  cin >> x >> y;
  vector<int> ary;
  int cnt = 0;
  s.push_back('T');
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'F') {
      cnt++;
    } else {
      ary.push_back(cnt);
      cnt = 0;
    }
  }
  int xsum = 0, ysum = 0;
  bitset<8001> xbs(0), ybs(0);
  xbs[0] = 1, ybs[0] = 1;
  for (int i = 2; i < ary.size(); i += 2) {
    xbs = xbs | xbs << ary[i];
    xsum += ary[i];
  }
  for (int i = 1; i < ary.size(); i += 2) {
    ybs = ybs | ybs << ary[i];
    ysum += ary[i];
  }
  int xdif = xsum + ary[0] - x;
  int ydif = ysum - y;
  if (xdif % 2 | ydif % 2 | xdif / 2 > 8000 | ydif / 2 > 8000 | xdif < 0 | ydif < 0) {
    cout << "No" << endl;
  } else if (xbs[xdif / 2] == 0 | ybs[ydif / 2] == 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

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

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}


void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

ll n ;

int main(){

   cin >> n ;
   cout << 2 * ( n / __gcd( n , 2 * 1ll ) ) ;

   return 0 ;
}


Measured memory_bytes: 256
n,m,l=map(int,input().split())
a=[[0 for i in range(m)] for j in range(n)]
b=[[0 for i in range(l)] for j in range(m)]
c=[[0 for i in range(l)] for j in range(n)]
for i in range(n):
    a[i] = input().split()
for i in range(m):
    b[i] = input().split()
for i in range(n):
	s = ""
	for j in range(l):
		for k in range(m):
			c[i][j] = c[i][j] + int(a[i][k]) * int(b[k][j])
		if j == 0:
			s = str(c[i][j])
		else:
			s = s + " " + str(c[i][j])
	print(s)


Measured memory_bytes: 7172
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int n, c;
    cin >> n >> c;

    vector<int> w(n), v(n);
    rep(i, n)
    {
        cin >> w[i] >> v[i];
    }

    vector<vector<int64_t>> dp(n + 1, vector<int64_t>(c + 1));
    irep(i, n) irep(j, c)
    {
        if (i == 0 || j == 0) {
            dp[i][j] = 0;
        } else {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (j - w[i - 1] >= 0) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
            }
        }
    }
    cout << dp[n][c] << endl;

    return 0;
}

Measured memory_bytes: 80256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<cmath>
using namespace std;
int main()
{
    long long a,b,c;
    while(~scanf("%lld",&a))
    {

    b=sqrt(a);
    printf("%d\n",b*b);
    }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

	vvi A(3,vi(3)); rep(i,3) rep(j,3) cin >> A[i][j];
	int N; cin >> N;
	vi b(N); rep(i,N) cin >> b[i];

	vvi C(3,vi(3,0));

	rep(i,3) rep(j,3) {
		rep(k,N) if(A[i][j] == b[k]) C[i][j] = 1;
	} 

	rep(i,3) {
		bool flag = false;
		int a = 1;
		int b = 1;
		rep(j,3) {
			a *= C[i][j];
			b *= C[j][i];
		}
		if(a == 1 or b == 1) Yes
	}
	if(C[0][0]*C[1][1]*C[2][2] == 1) Yes
	if(C[0][2]*C[2][0]*C[1][1] == 1) Yes
	No
}

Measured memory_bytes: 256
import numpy as np
from collections import defaultdict

#key = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

# N, M = map(int, input().split())  #
# A = [int(k) for k in input().split()] 

S = input().split('/')
#print(S)

#print(type(S), S[1])

if (int(S[0]) == 2019 and int(S[1]) >= 5) or int(S[0]) >= 2020:
    print("TBD")
else:
    print("Heisei")


Measured memory_bytes: 21408
#048_C
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0

for i in range(n):
    if i==0:
        if a[i]>x:
            ans+=a[i]-x
            a[i]=x
    else:
        if a[i-1]+a[i]>x:
            ans+=a[i-1]+a[i]-x
            a[i]=x-a[i-1]
print(ans)

Measured memory_bytes: 14540
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def io_generator():
	return input()

#+++++++++++++++++++
	
def main(io):
	n=int(io())
	s=io()[:n]
	k=int(io())
	cc=s[k-1]
	ll=lambda c:c if c==cc else '*'

	return ''.join([ll(c) for c in list(s)])

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Measured memory_bytes: 3064
# ABC153d


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    h = int(input())

    def attack(n):
        if n == 1:
            return 1
        return 1+2*attack(n//2)

    print(attack(h))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

void factor(set<int>& F, int x)
{
    for (int f = 2; 1LL*f*f <= x; f++) {
        while (x % f == 0)
            F.insert(f), x /= f;
    }
    if (x > 1)
        F.insert(x);
}

int gcd(const int a, const int b)
{ return (b == 0) ? a : gcd(b,a%b); }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    int N,K;
    while (cin >> N >> K) {
        int maxx = 0, gcd_ = 0;
        FOR(i,0,N) {
            int x; cin >> x;
            maxx = max(maxx,x);
            gcd_ = gcd(x,gcd_);
        }
        string ans = "IMPOSSIBLE";
        if (maxx >= K && K % gcd_ == 0)
            ans = "POSSIBLE";
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    return x*y/(T)GCD(x,y);
}
int main(){
    int n,ans = 0; cin >> n;
    ans += (n/25);
    n = n%25;
    ans += (n/10);
    n = n%10;
    ans += (n/5);
    n = n%5;
    ans += n;
    cout << ans << endl;
}
  




Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl

template<typename T>
T gcd(T x, T y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}

int main() {
    IN(int, n);
    int sum = 0;
    vi a(n);
    REP(i, n){
        cin >> a[i];
        sum += a[i];
    }
    int av = sum/n;
    int ans = 0;
    int ans1 = 0;
    REP(i, n){
        ans += (a[i]-av)*(a[i]-av);
    }
    REP(i, n){
        ans1 += (a[i]-av-1)*(a[i]-av-1);
    }
    COUT(min(ans, ans1));
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	
	int height[10];
	int i,j,buff;
	
	for(i = 0;i < 10;i++){
		scanf(" %d",&height[i]);
	}
	
	for(i=0;i<10;i++){
		for(j=i+1;j<10;j++){
			if(height[i] < height[j]){
				buff = height[i];
				height[i] = height[j];
				height[j] = buff;
			}
		}
	}
	
	for(i=0;i<3;i++){
		printf("%d\n",height[i]);
	}
	
	return(0);
	
}

Measured memory_bytes: 600
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }
template<typename T>
class bucket {
private:
    ll bsz;
    function<T(T, T)>operation;
    T identity;
    vector<T>dat, buc;
public:
    bucket(ll dsz, ll bsz, function<T(T, T)>opr, T id)
        :bsz(bsz), operation(opr), identity(id),
        dat(dsz, identity), buc((dsz + bsz - 1) / bsz)
    {
        update();
    }
    T &operator[](ll idx)
    {
        return dat[idx];
    }
    void update()
    {
        REP(b, buc.size()) {
            auto itr = dat.begin() + b * bsz;
            buc[b] = accumulate(itr, itr + bsz, identity, operation);
        }
    }
    void update(ll idx, T val)
    {
        dat[idx] = val;
        ll b = idx / bsz;
        auto itr = dat.begin() + b * bsz;
        buc[b] = accumulate(itr, itr + bsz, identity, operation);
    }
    T query(ll l, ll r)
    {
        T ret = identity;
        REP(b, buc.size()) {
            ll lt = std::max(l, b * bsz), rt = std::min(r, (b + 1) * bsz);
            if (lt < rt) {
                if (rt - lt == bsz)ret = operation(ret, buc[b]);
                else for (ll i = lt; i < rt; ++i)ret = operation(ret, dat[i]);
            }
        }
        return ret;
    }
    static bucket<T>sum(ll dsz, ll bsz)
    {
        return bucket<T>(dsz, bsz, plus<T>(), static_cast<T>(0));
    }
    static bucket<T>product(ll dsz, ll bsz)
    {
        return bucket<T>(dsz, bsz, multiplies<T>(), static_cast<T>(1));
    }
    static bucket<T>max(ll dsz, ll bsz, T id = numeric_limits<T>::min())
    {
        return bucket<T>(dsz, bsz, static_cast<const T & (*)(const T &, const T &)>(std::max), id);
    }
    static bucket<T>min(ll dsz, ll bsz, T id = numeric_limits<T>::max())
    {
        return bucket<T>(dsz, bsz, static_cast<const T & (*)(const T &, const T &)>(std::min), id);
    }
};
int main()
{
    ll n = in(), q = in();
    auto b = bucket<ll>::min(n, sqrt(n), 0x7fffffff);
    REP(i, q) {
        ll c = in(), x = in(), y = in();
        if (c == 0)b.update(x, y);
        else cout << b.query(x, y + 1) << endl;
    }
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#define llint long long

using namespace std;

string s;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	sort(s.begin(), s.end());
	
	if(s[0] != s[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class K_City
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);

            Console.WriteLine((n - 1) * (m - 1));
        }
    }
}

Measured memory_bytes: 11092
M, K = map(int, input().split())

if K >= 2 ** M:
    print(-1)
elif M == 0:
    print("0 0" if K == 0 else -1)
elif M == 1:
    print("1 0 0 1" if K == 0 else -1)
else:
    A = [str(i) for i in range(2 ** M) if i != K]
    print(" ".join(A), K, " ".join(reversed(A)), K)


Measured memory_bytes: 16020
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		cout << 'x';
	}


	return 0;
}

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

using namespace std;

const int HUGEI = 2147483647;  // (1 << 31) - 1
const long long HUGEL = 9223372036854775807;  // (1 << 63) - 1
const string ABC = "abcdefghijklmnopqrstuvwxyz";

int main(void) {
    int n;
    vector <int> an;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        an.push_back(a);
    }
    vector <long long> bn;
    bn.push_back((long long) an[0]);
    for (int i = 1; i < n; i++) {
        bn.push_back(bn[i - 1] + (long long) an[i]);
    }
    long long res = HUGEL;
    for (int i = 0; i < n - 1; i++) {
        res = min(res, abs(bn[n - 1] - 2 * bn[i]));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3188
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll d;
  std::cin>>d;

  constexpr ll TYPE=26;

  std::array<ll,TYPE> c;
  rep(i,0,26)std::cin>>c[i];

  std::vector<std::array<ll,TYPE>> s(d);
  rep(i,0,d){
    rep(j,0,TYPE)std::cin>>s[i][j];
  }

  ll ans=0;

  std::array<ll,TYPE> last;
  last.fill(-1);

  rep(day,0,d){
    ll t;
    std::cin>>t;
    t--;
    ans+=s[day][t];
    last[t]=day;
    rep(i,0,26){
      ans-=c[i]*(day-last[i]);
    }
    std::cout<<ans<<"\n";
  }

  return 0;
}

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

typedef long long LL;
const int maxn = 1e5;
int n, a, b, m[maxn+3];

bool judge(LL x)
{
    LL sum = 0;
    for(int i=0; i<n; ++i)
    {
        LL t = (LL)m[i]-x*b;
        if(t>0)
        {
            sum += (int)ceil(t*1.0/(a-b));
            if(sum > x || sum < 0)
                return false;
        }
    }
    return true;
}
int main()
{
    while(~scanf("%d%d%d",&n,&a,&b))
    {
        int imax = 0;
        for(int i=0; i<n; ++i) scanf("%d",&m[i]), imax = max(imax, m[i]);
        LL l=0, r=imax;
        while(l<r)
        {
            LL mid = l+r>>1;
            if(judge(mid)) r=mid;
            else l=mid+1;
        }
        printf("%lld\n",r);
    }
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();

        int a = Integer.valueOf(line.substring(0,2)).intValue();
        int b = Integer.valueOf(line.substring(2,4)).intValue();

        if(a>0 && a<13){
            if(b>0 && b<13){
                System.out.println("AMBIGUOUS");
            }else{
                System.out.println("MMYY");
            }
        }else{
            if(b>0 && b<13){
                System.out.println("YYMM");
            }else{
                System.out.println("NA");
            }
        }

    }
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;
vector<vector<int>> edge(111111);
vector<vector<int>> nv(333333);
bool visited[111111];
ll dist[333333];

int main(){

	REP(i,333333)dist[i] = INF;
	vector<pair<ll,pair<ll,ll>>> v;
	int n,m;cin >> n >> m;
	REP(i,m){
		int a,b,c;cin >> a >> b >> c;
		v.PB(MP(c,MP(a,b)));
	}

	sort(ALL(v));
	int cou = 0,prv = 0,col = n+1;
	while(cou < v.size()){
		prv = cou;
		vector<int> tmp;
		while(cou < v.size() - 1 && v[cou].FI == v[cou+1].FI){
			tmp.PB(v[cou].SE.FI);
			tmp.PB(v[cou].SE.SE);
			edge[v[cou].SE.FI].PB(v[cou].SE.SE);
			edge[v[cou].SE.SE].PB(v[cou].SE.FI);
			cou++;
		}
		tmp.PB(v[cou].SE.FI);
		tmp.PB(v[cou].SE.SE);
		edge[v[cou].SE.FI].PB(v[cou].SE.SE);
		edge[v[cou].SE.SE].PB(v[cou].SE.FI);
		cou++;
		for(int i = prv;i < cou;i++){
			if(!visited[v[i].SE.FI]){
				queue<int> q;
				q.push(v[i].SE.FI);
				visited[v[i].SE.FI] = true;
				while(!q.empty()){
					int now = q.front();q.pop();
					nv[now].PB(col);
					nv[col].PB(now);
					REP(j,edge[now].size()){
						if(!visited[edge[now][j]]){
							visited[edge[now][j]] = true;
							q.push(edge[now][j]);
						}
					}
				}
				col++;
			}
		}
		REP(i,tmp.size()){
			edge[tmp[i]].clear();
			visited[tmp[i]] = false;
		}
	}

	dist[1] = 0;
	queue<int> q;
	q.push(1);
	while(!q.empty()){
		int now = q.front();q.pop();
		REP(i,nv[now].size()){
			if(dist[nv[now][i]] > dist[now] + 1){
				dist[nv[now][i]] = dist[now] + 1;
				q.push(nv[now][i]);
			}
		}
	}

	if(dist[n] == INF){
		cout << -1 << endl;
	}
	else{
		cout << dist[n] / 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 33132
#include <iostream>
#include <cstdio>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vmb;   /// Matrix boolean using vector
typedef vector<vll> vmll; /// Matrix long long using vector
 
const int INF = 1e9;
 
/// Top-down knapsack using Branch and bound approach
/// dp:     calculate subproblem
/// isDone:   if subproblem is calculated before
/// weight: weight of element
/// value:  value of element
/// n: length of array
/// i: index
/// j: weight
int tdkp01(vmll &dp, vmb &isDone, vi &weight, vi &value, int n, int i, int j)
{
    if (j <= 0)     /// Cant take more elements
        return 0;
 
    if (i == n)     /// End of array
        return INF;
 
    if (isDone[i][j]) /// If solved before
        return dp[i][j];
 
    isDone[i][j] = true; /// Solving Recursively
    return dp[i][j] = min(tdkp01(dp, isDone, weight, value, n, i + 1, j),
                          tdkp01(dp, isDone, weight, value, n, i + 1, j - value[i]) + weight[i]);
}

/// Finding max sum where total weight <= limit
int kp01(vmll &dp, vmb &isDone, vi &weight, vi &value, int n, int k, int vsum)
{
    vsum++;
    while (vsum--) /// Finding from limit -> 0 for faster ending
        if (tdkp01(dp, isDone, weight, value, n, 0, vsum) <= k)
            return vsum;
 
    return 0;
}
 
int main()
{
    int n, k;
    cin >> n >> k;
 
    vi weight(n), value(n);
    int vsum = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> weight[i] >> value[i];
        vsum += value[i];
    }
 
    vmll dp(n + 1);
    vmb isDone(n + 1);
    for (int i = 0; i <= n; ++i)
    {
        dp[i].assign(vsum, 0);
        isDone[i].assign(vsum, 0);
    }
 
    cout << kp01(dp, isDone, weight, value, n, k, vsum);
    return 0;
}

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

int main(){
    string S;
    cin >> S;
    if( S.at(2) == S.at(3) && S.at(4) == S.at(5)){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" << endl;
    } 

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        final String AC = "AC";
        final String WA = "WA";
        final String TLE = "TLE";
        final String RE = "RE";
        final String x = " x ";

        int ACc = 0;
        int WAc = 0;
        int TLEc = 0;
        int REc = 0;

        int N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            String S = sc.next();
            if (S.equals(AC)) {
                ACc++;
            } else if (S.equals(WA)) {
                WAc++;
            } else if (S.equals(TLE)) {
                TLEc++;
            } else {
                REc++;
            }
        }
        System.out.println(AC + x + ACc);
        System.out.println(WA + x + WAc);
        System.out.println(TLE + x + TLEc);
        System.out.println(RE + x + REc);
    }
}

Measured memory_bytes: 58008
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
int pa[MAX];
int ra[MAX];
void init(){
  for(int i=0;i<MAX;i++){
    pa[i]=i;
    ra[i]=0;
  }
}

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

void unite(int x,int y){
  x=find(x),y=find(y);
  if(x==y)return;
  if(ra[x]<ra[y])swap(x,y);
  pa[y]=x;
  if(ra[x]==ra[y])ra[x]++;
}

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

int n,m,q,a,b;
int main(){
  init();
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d %d",&a,&b);
    unite(a,b);
  }
  scanf("%d",&q);
  for(int i=0;i<q;i++){
    scanf("%d %d",&a,&b);
    cout<<(same(a,b)?"yes":"no")<<endl;
  }
  return 0;
}

Measured memory_bytes: 1980
N, M = map(int, input().split())
xval = [float("INF")]*(N+1)
road = {}
for i in range(1, N+1):
    road[i] = {}
for i in range(M):
    r, l, d = map(int, input().split())
    road[r][l] = d
    road[l][r] = -d

checked = set()
i = 1
while len(checked) < N:
    for j in range(i, N+1):
        if j in checked:
            continue
        else:
            i = j
            checked.add(i)
            break
    xval[i] = 0
    check = set([i])
    while len(check) > 0:
        nextcheck = set()
        for x in check:
            for y in road[x].keys():
                if xval[y] == float("INF"):
                    xval[y] = xval[x] + road[x][y]
                    checked.add(y)
                    nextcheck.add(y)
                else:
                    if xval[y] != xval[x] + road[x][y]:
                        print("No")
                        exit()
                    else:
                        continue
        check = nextcheck
print("Yes")

Measured memory_bytes: 86608
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0

for i in range(N):
    ans += B[i]
    if i != 0:
        if A[i]-1 == A[i-1]:
            ans += C[A[i-1]-1]


print(ans)

Measured memory_bytes: 3064
fn main() {
    let t = rv::<i64>();
    let a = rv::<i64>();
    let b = rv::<i64>();
    let ta1=t[0]*a[0];
    let ta2=t[1]*a[1];
    let ta=ta1+ta2;
    let tb1=t[0]*b[0];
    let tb2=t[1]*b[1];
    let tb=tb1+tb2;
    if ta==tb {
        println!("infinity");
    }
    else if (ta<tb) == (ta1<tb1) {
        println!("0");
    }
    else {
        let x=(tb1-ta1).abs();
        let y=(ta-tb).abs();
        println!("{}",x/y*2+if x%y==0 {0} else {1});
    }
}
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}
fn rv<T>() -> Vec<T>
  where T: std::str::FromStr, T::Err: std::fmt::Debug, {
    rl().split_whitespace().map(|x|x.parse::<T>().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	cin >> n;
	vector<int> d(n), ans;
	rep(i, 0, n) {
		cin >> d[i];
	}
	sort(all(d));
	rep(i, 0, min(n,(int)4)) {
		rep(j, 0, min(n,(int)4)) {
			if (i == j) continue;
			int k = 0, t = d[i];
			while (t) {
				k++;
				t /= 10;
			}
			//cout << d[i] << " " << k << endl;
			int tmp = d[i] + d[j] * pow((int)10, k);
			ans.push_back(tmp);
		}
	}
	sort(all(ans));
	cout << ans[2] << endl;
}

Measured memory_bytes: 1308
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

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

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N;
    multiset<int> d;
    cin >> N;
    for (int i=0;i<N;i++) {
        int x;
        cin >> x;
        d.insert(x);
    }
    auto itr = d.begin();
    for (int i=0;i<N/2;i++) itr++;
    int sc = (*itr);
    sc -= *(--itr);
    cout << sc << endl;

    return 0;
}


Measured memory_bytes: 4992
import sys
sys.setrecursionlimit(100)

def cmb(n,r):
    if r>n/2:
        r=n-r
    if r==0:
        return 1
    else:
        return n*cmb(n-1,r-1)/r

N,P=map(int,input().split())
A=list(map(int,input().split()))
Am=[]

for a in A:
    Am.append(a%2)
even=Am.count(0)
odd=N-even
ans=0

if P==0:
    for o in range(0,odd+1,2):
        ans+=int(cmb(odd,o))
    ans*=2**even
else:
    for o in range(1,odd+1,2):
        ans+=int(cmb(odd,o))
    ans*=2**even

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
	int n, m; cin>>n>>m;
	vector<int>digit(n,-1);
	bool found=true;
	for(int i=0;i<m;i++){
		int dig, val; cin>>dig>>val;
		dig--;
		if(digit[dig]== -1)
			digit[dig]=val;
		else if(digit[dig] != val)
			found=false;
	}
	if(!found){
		cout<<-1<<endl;
		return 0;
	}
	if(digit[0]==0){
		if(n==1) cout<<0<<endl;
		else cout<<-1<<endl;
		return 0;
	}
	string s;
	if(m==0){
		s +='1';
		for(int i=1;i<n;i++)
			s+='0';
		if(n==1) s[0]='0';
		cout<<s<<'\n';
		return 0;
	}
	for(int i=0;i<n;i++){
		if(digit[i]!=-1){
			s+= digit[i]+'0';
		}
		else s+='0';
	}
	if(s[0]=='0') 
		s[0]='1';
	cout<<s<<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>;
const int MAX = 1000;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)

int main() {
	int a, b; cin >> a >> b;
	char s1[10], s2[10];
	char *ans = s1;
	memset(s1, 0x00, sizeof(s1));
	memset(s2, 0x00, sizeof(s2));
	rep(i, b) {
		s1[i] = a + 48;
	}
	rep(i, a) {
		s2[i] = b + 48;
	}
	int m = min(strlen(s1), strlen(s2));
	rep(i, m) {
		if (s2[i] < s1[i]) ans = s2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3580
# -*- coding: utf-8 -*-
import sys
import os
from collections import Counter

n,k = [int(p) for p in input().split()]

a = []
d = []
c = []
for i in range(k):
    d.append(int(input()))
    s = input()
    a.append([int(p) for p in s.split()])
    c.extend([int(p) for p in s.split()])

total = 0

for i in range(1,n+1):
    x = c.count(i)
    #print(i, x)
    if x == 0:
        total += 1

print(total)

Measured memory_bytes: 9448
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int count = 0;
		while(B >= A) {

			count++;
			if(count == C)break;
			B -= A;
		}
		System.out.println(count);
	}
}



Measured memory_bytes: 27008
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys

N = int(sys.stdin.readline())
a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param

left = [0]*(N+1)
for i in range(N):
    left[i+1] = left[i]^a[i]

right = [0]*(N+1)
for i in range(N)[::-1]:
    right[i] = right[i+1]^a[i]

#print(left,right)

ret = []
for i in range(N):
    #print(i,left[max(0,i)],right[i+1])
    ret.append(left[max(0,i)]^right[i+1])

print(" ".join(map(str,ret)))

Measured memory_bytes: 120808
import sys
sys.setrecursionlimit(1000000)
def main():
    n, m = [int(x) for x in input().split()]
    global dp
    dp = [-1]*n
    grafo = [[] for _ in range(n)]

    for _ in range(m):
        x, y = [int(x) for x in input().split()]
        x -= 1
        y -= 1

        grafo[x].append(y)

    resp = 0
    for u in range(n):
        resp = max(dfs(u, grafo), resp)

    print(resp)
        

def dfs(u, grafo):
    global dp

    if len(grafo[u]) == 0:
        dp[u] = 0
        return dp[u]

    if dp[u] != -1:
        return dp[u]


    for v in grafo[u]:
        dp[u] = max(dfs(v, grafo) + 1, dp[u])

    return dp[u]
        
main()

Measured memory_bytes: 61308
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
#include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

LL f(LL b, LL n) {
	if (n < b)return n;
	else return f(b, n / b) + n%b;
}

int main() {
	LL n, s;
	cin >> n >> s;
	LL i = 2;
	for (; i <= sqrt(n); i++) {
		if (f(i, n) == s) {
			cout << i << endl;
			return 0;
		}
	}
	LL a = n - s;
	if (a < 0) {
		cout << -1 << endl;
		return 0;
	}
	else if (a == 0) {
		cout << n + 1 << endl;
		return 0;
	}
	LL ans = LINF;
	for (; i >= 1; i--) {
		if (a%i != 0)continue;
		LL b = a / i + 1;
		if (f(b, n) == s) {
			ans = min(ans, b);
		}
	}
	if (ans != LINF) {
		cout << ans << endl;
	}
	else {
		cout << -1 << endl;
	}

}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    ll a[7];
    Rep(i,7) Scll(a[i]);

    ll ans = a[0]/2*2+a[1]+a[3]/2*2+a[4]/2*2;
    ll comp = (a[0]%2 + a[3]%2 + a[4]%2 );
    if( !(a[0] == 0 || a[3] == 0 || a[4] == 0) )
    if( comp == 3 ) ans+=3;
    else if( comp == 2 ) ans+=1;
    printf ("%llu\n", ans);

    return 0;
}



Measured memory_bytes: 256
import sys

N = int(input().rstrip())

limit = pow(10, 18)

nums = list(input().split())

for num in nums:
    num = int(num)
    if num == 0:
        print(0)
        sys.exit(0)

accum = 1
for num in nums:
    num = int(num)
    try:
        accum *= num
    except Exception:
        accum = -1
        break

    if accum > limit:
        accum = -1
        break

print(accum)


Measured memory_bytes: 19232