akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
	int r,c;
	cin >> r >> c ;
	int matrix[101][101];
	
	for(int i=0; i<r ;i++){
		for(int j=0 ;j<c;j++){
			cin >>matrix[i][j];
		}
	}
	//input end
	
	//start caliculation
	for(int i=0;i<r;i++){
		matrix[i][c] =0;
		for(int j=0;j<c;j++){
			matrix[i][c] += matrix[i][j];
		}
	}
	// end line sum
	//start row sum
	for(int i=0;i<c;i++){
		matrix[r][i] =0;
		for(int j=0;j<r;j++){
			matrix[r][i] += matrix[j][i];
		}
	}
	//end
	//start total
	matrix[r][c] =0;
	for(int i=0;i<c;i++){
		matrix[r][c] += matrix[r][i];
	}
	//start output
	for(int i = 0; i<=r ;i++){
		for(int j = 0; j<=c ;j++){
			cout<<matrix[i][j];
			if(j!=c){cout <<" ";}
			else{cout <<endl;}
		}
	}

}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

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

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

char toLowerCase(char c){
  if(isLowerCase(c)){
    return c;
  }else{
    return c+'a'-'A';
  }
}
char toUpperCase(char c){
  if(isLowerCase(c)){
    return c-('a'-'A');
  }else{
    return c;
  }
}
ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string s,t;cin>>s>>t;
  if(s.size()<t.size()){
    cout<<"LESS"<<endl;
    return 0;
  }else if(s.size()>t.size()){
    cout<<"GREATER"<<endl;
    return 0;
  }else{
    for(int i=0;i<s.size();i++){
      if(s[i]==t[i]){
        continue;
      }
      cout<<((s[i]<t[i])?"LESS":"GREATER")<<endl;
      return 0;
    };
  }
  cout<<"EQUAL"<<endl;
  return 0;
}


Measured memory_bytes: 3604
def solve(N, A):
    a = A[0]
    ans = 0
    for i in xrange(1, N):
        if a > 0 and a + A[i] < 0:
            a = a + A[i]
        elif a > 0 and a + A[i] >= 0:
            ans += A[i] + a + 1
            a = -1
        elif a < 0 and a + A[i] > 0:
            a = a + A[i]
        else:
            ans += -(A[i]+a)+1
            a = 1
    return ans


N = input()
A = map(int, raw_input().split())

if A[0] == 0:
    A[0] = -1
    ans1 = solve(N, A) + 1
    A[0] = 1
    ans2 = solve(N, A) + 1
    print min(ans1, ans2)
else:
    ans1 = solve(N, A)
    if A[0] > 0:
        tmp = A[0] + 1
        A[0] = -1
    else:
        tmp = -A[0] + 1
        A[0] = 1
    ans2 = solve(N, A) + tmp
    print min(ans1, ans2)


Measured memory_bytes: 41780
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

void Mark(int v, int c, const vector<vector<int>>& gr, vector<int>& color) {
  color[v] = c;
  for (int u : gr[v]) {
    if (color[u] == -1) {
      Mark(u, c, gr, color);
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int N, M;
  cin >> N >> M;
  
  vector<int> A(N);
  for (int& a : A) {
    cin >> a;
    --a;
  }
  
  vector<vector<int>> gr(N);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    
    gr[a].push_back(b);
    gr[b].push_back(a);
  }
  
  vector<int> color(N, -1);
  int c = 0;
  for (int i = 0; i < N; ++i) {
    if (color[i] == -1) {
      Mark(i, c, gr, color);
      ++c;
    }
  }
  
  int result = 0;
  for (int i = 0; i < N; ++i) {
    if (color[i] == color[A[i]]) {
      ++result;
    }
  }
  
  cout << result << '\n';
  
  return 0;
}


Measured memory_bytes: 9600
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		String str = stdIn.next();
		for(int i = str.length() - 1; i >= 0; --i)
		{
			System.out.print(str.charAt(i));
		}
		System.out.println();
	}
}

Measured memory_bytes: 17128
N = int(input())
C = []
for i in range(N):
    a, b = map(int, input().split())
    C.append((a+b, a, b))

C.sort(reverse=1)

ans = 0
for i in range(N):
    _, a, b = C[i]
    if i % 2 == 0:
        ans += a
    else:
        ans -= b
print(ans)


Measured memory_bytes: 20992
#include<algorithm>
#include<cstring>
#include <iostream>
#include <cstdio>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef unsigned long long ull;
typedef set<int>::iterator sit;
#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b & 1)ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans;}
struct cmp{bool operator()(const pii & a, const pii & b){return a.second < b.second;}};
int lb(int x){return  x & -x;}
//friend bool operator < (Node a,Node b)   重载
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int maxn = 305+10;


int main()
{
	int n;
	scanf("%d",&n);
	ll k = 7;
	for (int i = 1; i <= n; i ++ )
	{
		ll x = k % n;
		// printf("%d\n",x);
		if(x == 0)
		{
			printf("%d\n",i);
			return 0;
		}
		x = x * 10 + 7;
		k = x;
	}
	printf("-1\n");
}



Measured memory_bytes: 3196
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, m;

int solve() {
    return (1<<m) * (100 * (n - m) + 1900 * m);
}

void input() {
    cin >> n >> m;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
        cout << '\n';
    }
};

void prog()
{
    input in;
    output out;

    out(in.read<int>() == in.read<int>() ? "Yes" : "No");
}

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


Measured memory_bytes: 256
from collections import Counter
def main(n:int,lst:list)->int:
    lst1 = lst[::2]
    lst2 = lst[1::2]
    c1 = Counter(lst1).most_common()
    c2 = Counter(lst2).most_common()
    if c1[0][0] == c2[0][0]:
        if len(c1)!=1 and len(c2)!=1:
            return n - max(c1[0][1] + c2[1][1],c2[0][1] + c1[1][1])
        else:
            return n//2
    else:
        return n - c1[0][1] - c2[0][1]

n = int(input())
lst = input().split()
print(main(n,lst))


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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    ll ans = 1, B = A[0];
    for (int i = 1; i < N; i++) {
        if (B * 2 >= A[i]) {
            ans++;
        } else {
            ans = 1;
        }
        B += A[i];
    }
    cout << ans << endl;
}

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

const int N = 2e5 + 7;

int a[N], b[20][N];


int jump(int pos, int x) {
	for(int i = 19; i >= 0; i--) if((x >> i) & 1) {
		pos = b[i][pos];
	}
	return pos;
}

int main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int L; cin >> L;
	for(int i = 1; i <= n; i++) {
		int l = upper_bound(a + 1, a + n + 1, a[i] + L) - a - 1;
		b[0][i] = l;
	}
	for(int i = 1; i < 20; i++) {
		for(int j = 1; j <= n; j++) {
			b[i][j] = b[i - 1][b[i - 1][j]];
		}
	}
	int q; cin >> q;
	for(int i = 1; i <= q; i++) {
		int p, q; cin >> p >> q; 
		if(p > q) {
			swap(p, q);
		}
		int l = 0, r = n;
		while(l < r) {
			int mid = (l + r) >> 1;
			if(jump(p, mid) >= q) {
				r = mid;
			} else l = mid + 1;
		}
		cout << r << endl;
	}
}

Measured memory_bytes: 11936
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
typedef long long int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	cin >> n;
	vector <ll> v;
	m=n;
	while(n>0)
	{
		n--;
		v.pb(n%26);
		n/=26;
	}
	str s;
	for(j=v.size()-1;j>=0;j--)
	{
		s+=char((ll)'a'+v[j]);
	}

	cout << s << "\n";
	return 0;
}

Measured memory_bytes: 3656
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int a,b;
  cin >> a >> b;

  cout << a * b - a - b + 1;


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int num;
  int kami, simo;

  scanf("%d", &num);
  kami=num/100;//上二桁
  simo=num%100;//下二桁

  // printf("kami=%d simo=%d\n", kami, simo);
  if((kami<1||12<kami)&&(simo<1||12<simo)){
    printf("NA\n");
  }else if((1<=kami&&kami<=12)&&(simo<1||12<simo)){
    printf("MMYY\n");
  }else if((kami<1||12<kami)&&(1<=simo&&simo<=12)){
    printf("YYMM\n");
  }else{
    printf("AMBIGUOUS\n");
  }

  return 0;
}


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

int main() {
	int n, sum;
	int up = 1, down = 6, right = 3, left = 4, front = 2, back = 5;
	string action;

	while (1) {
		cin >> n;
		if (n == 0) break;

		up = 1;
		down = 6;
		right = 3;
		left = 4;
		front = 2;
		back = 5;

		sum = 1;

		for (int i = 0; i < n; i++) {
			cin >> action;

			if (action == "North") {
				back = up;
				up = front;
				front = down;
				down = 7 - up;
			}
			else if (action == "East") {
				right = up;
				up = left;
				left = down;
				down = 7 - up;
			}
			else if (action == "West") {
				left = up;
				up = right;
				right = down;
				down = 7 - up;
			}
			else if (action == "South") {
				front = up;
				up = back;
				back = down;
				down = 7 - up;
			}
			else if (action == "Right") {
				left = front;
				front = right;
				right = back;
				back = 7 - front;
			}
			else if (action == "Left") {
				right = front;
				front = left;
				left = back;
				back = 7 - front;
			}

			sum += up;

		}

		cout << sum << endl;

	}
	return 0;
}


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

using namespace std;

typedef long long ll;

const ll maxx = 2005, mod = 1e9 + 7;

ll dp[maxx][maxx], n, k, fac[maxx * maxx];

ll pw(ll a, ll b)
{
	if (!b) return 1ll;
	ll x = pw(a, b / 2);
	x = (x * x) % mod;
	if (b % 2) x = (x * a) % mod;
	return x;
}

ll sel(ll a, ll b)
{
	ll x = fac[a];
	x = (x * pw(fac[b], mod - 2)) % mod;
	x = (x * pw(fac[a-b], mod - 2)) % mod;
	return x;
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	fac[0] = 1ll; for(ll i = 1; i < maxx * maxx; i++) fac[i] = (fac[i-1] * i) % mod;
//	cout << pw(2, 11111) << " " << sel(45 * 46 - 1, 44) << endl;
	cin >> n >> k;
	if (k == 1) return cout << 1 << endl, 0;
	dp[0][0] = 1;
	for(ll i = 1; i <= n; i++)
	{
		for(ll j = 0; j < i; j++)
		{
			dp[i][j] = ((j ? dp[i][j-1] : 0ll) + (((sel(i * (k - 1) + j - 1, k - 2)) * dp[i-1][j]) % mod)) % mod;
//			if (i == n)
//			cout << i << " " << j << "     " << dp[i][j] << endl;
		}
		dp[i][i] = dp[i][i-1]; 
//		cout << i << " " << i << "      " << dp[i][i] << endl;
	}
//	cout << dp[n][n] << endl;
	cout << (1ll * dp[n][n] * fac[n]) % mod << endl;
	return 0;
}

Measured memory_bytes: 62976
#include<bits/stdc++.h>
#define MOD 1000000007
#define MAX 2001
using namespace std;
long long N,K;
long long Inv[MAX*MAX];
long long Dp[MAX][MAX];
long long Factorial[MAX*MAX];
inline long long Quick_Power(long long X,int P)
{
	register long long Return;
	Return=1;
	while(P)
	{
		if(P&1)
		{
			Return=Return*X%MOD;
		}
		X=X*X%MOD;
		P>>=1;
	}
	return Return;
}
inline long long Combination(long long A,long long B)
{
	return Factorial[A]*Inv[B]%MOD*Inv[A-B]%MOD; 
}
int main(void)
{
	register long long i,j;
	cin>>N>>K;
	if(K==1)
	{
		cout<<1<<endl;
		return 0;
	}
	Factorial[0]=1;
	for(i=1;i<=N*K;i++)
	{
		Factorial[i]=Factorial[i-1]*i%MOD;
	}
	Inv[N*K]=Quick_Power(Factorial[N*K],MOD-2);
	for(i=N*K-1;i>=0;i--)
	{
		Inv[i]=Inv[i+1]*(i+1)%MOD;
	}
	Dp[0][0]=1;
	for(i=1;i<=N;i++)
	{
		for(j=0;j<=i;j++)
		{
			if(!j)
			{
				Dp[i][j]=Dp[i-1][j];
				continue;
			}
			Dp[i][j]=Dp[i-1][j]+Dp[i][j-1]*(N-j+1)%MOD*Combination(N*K-i-1-(j-1)*(K-1),K-2)%MOD;
		}
	}
	cout<<Dp[N][N]<<endl;
	return 0;
}

Measured memory_bytes: 88688
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

#include <iomanip>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const ll INF = 1e17;
ll dp[100005][13];

signed main(void) {
  ll N;
  cin >> N;

  vector<double> x(N), y(N);
  double ans = 0;
  rep(i, N) {
    cin >> x[i] >> y[i];
    rep(j, i) {
      ans += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
  }

  ans = ans*2/N; 
  cout << setprecision(7) << fixed << ans << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
max_length = max(max(A), K).bit_length()
A_bin = [bin(a)[2:].zfill(max_length) for a in A]
K_bin = bin(K)[2:].zfill(max_length)

count = []
for digit in range(max_length):
  count_zero = 0
  for a_bin in A_bin:
    if a_bin[digit] == '0':
      count_zero += 1
  count.append(count_zero)


half = -(-N//2)
X = ''
tight = True
for i, c in enumerate(count):
  if c < half:
    X += '0'
    if K_bin[i] == '1':
      tight = False
  else:
    if K_bin[i] == '1' or not tight:
      X += '1'
    else:
      X += '0'


X = int(X, 2)
ans = 0
for a in A:
  ans += X^a


print(ans)

Measured memory_bytes: 17820
#include <bits/stdc++.h>
using namespace std;
// map<pair<int,int>,string> dp;
vector<vector<int>> dp(3003,vector<int>(3003,-1));
int n,m;
string s,t;
void find(int i,int j,int cnt,string str)
{
     if(cnt==0&&(i>=n||j>=m))
     {
         cout<<str;
         exit(0);
     }
     if(i>=n||j>=m)
     return;
     if(dp[i][j]!=cnt)
     return;
     if(s[i]==t[j])
     find(i+1,j+1,cnt-1,str+s[i]);
     else{
         find(i+1,j,cnt,str);
         find(i,j+1,cnt,str);
     }
}
int solve(int i,int j)
{
    if(i>=n||j>=m)
    return 0;
    if(dp[i][j]!=-1)
    return dp[i][j];
    int ans = 0;
    if(s[i]==t[j])
    ans = max(ans,1+solve(i+1,j+1));
    else{
    ans = max(ans,solve(i+1,j));
    ans = max(ans,solve(i,j+1));
    }
     return dp[i][j]=ans;
}
int main() {
    cin>>s>>t;
    n = s.length();
    m = t.length();
    int cnt = solve(0,0);
    find(0,0,cnt,"");
}


Measured memory_bytes: 48392
/*
@title Macro
@category template
*/
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;

template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;

const double PI = acos(-1.0);

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";


#line 1 "/Users/knaga/programming/procon_library/geometory/template.cpp"


#line 5 "/Users/knaga/programming/procon_library/geometory/template.cpp"
/*
@title Geometory/template.cpp
@category Geometory
*/

typedef complex<double> Point;
typedef pair<Point, Point> Segment;
#define EPS (1e-10)
#define EQ(a, b) (abs((a) - (b)) < EPS)
Point operator*(const Point &p, const double &d) {
  return Point(real(p) * d, imag(p) * d);
}
// 内積
double dot(Point a, Point b){
    return (a.real() * b.real() + a.imag() * b.imag());
}
//外積
double cross(const Point &a, const Point &b){
    return (a.real() * b.imag() - a.imag() * b.real());
}

/*
"https://onlinejudge.u-aizu.ac.jp/courses/library/4/CGL/2/CGL_1_A"
直線 l に p から引いた交点を求める
*/
Point projection(const Segment &l, const Point &p){
    double t = dot(p - l.first, l.second - l.first) / norm(l.second - l.first);
    return l.first + t * (l.second - l.first);
}

Point reflection(const Segment &l, const Point &p){
    return p + (projection(l,p)-p)*2.0;
}

bool is_intersected_ls(Point a1, Point a2, Point b1, Point b2){
    return (cross(a2-a1, b1-a1)*cross(a2-a1, b2-b1) < EPS) && (cross(b2-b1, a1-b1)*cross(b2-b1, a2-b1) < EPS);
}


#line 4 "CGL_1_B.test.cpp"

int main(){
    cout << fixed << setprecision(20);
    int xp1, yp1, xp2, yp2;
    cin >> xp1 >> yp1 >> xp2 >> yp2;
    Point p1(xp1, yp1);
    Point p2(xp2, yp2);
    Segment l = make_pair(p1, p2);
    int q;
    cin >> q;
    rep(_, q){
        int px, py;
        cin >> px >> py;
        Point p(px, py);
        Point ans = reflection(l, p);
        cout << ans.real() << " " << ans.imag() << endl;
    }
}


Measured memory_bytes: 3340
import numpy as np


def acinput():
    return list(map(int,input().split(" ")))


N,D=acinput()
X=[]
for i in range(N):
        X.append(np.array(acinput()))


count=0
for i in range(N-1):
        for j in range(i+1,N):
                tmp=np.linalg.norm(X[i]-X[j])
                if tmp%1.0==0:
                        count+=1


print(count)




Measured memory_bytes: 12500
#include <iostream>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

string solve(const vector<int>& a){
    int v = a[0];
    for(auto& t : a) v = gcd(v, t);
    if(v > 1) return "not coprime";
    vector<int> m(1000000, 0);
    for(auto& t : a){
        int v = t;
        for(int d=2;d*d<=v;d++){
            if(v%d) continue;
            if(m[d]) return "setwise coprime";
            while(v%d == 0) v /= d;
            m[d] = 1;
        }
        if(v > 1){
            if(m[v]) return "setwise coprime";
            m[v] = 1;
        }
    }
    return "pairwise coprime";
}

int main(){
    int N; cin >> N;
    vector<int> a(N);
    for(auto& t : a) cin >> t;
    cout << solve(a) << endl;
}

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

using Board=vector<vector<int>>;
int dx[]={0,-1,-1,0,1,1};
int dy[]={1,0,-1,-1,0,1};
bool isRange(int x,int y,const Board& b){
    return 0<=x && x<b.size() && 0<=y && y<b[x].size();
}
bool dfs(int x,int y,int c,vector<vector<int>>& used,const Board& b){
    if(!isRange(x,y,b)) return false;
    if(b[x][y]==0) return true;
    if(b[x][y]!=c) return false;
    if(used[x][y]) return false;
    used[x][y]=true;
    for(int i=0;i<6;i++){
        if(dfs(x+dx[i],y+dy[i],c,used,b)) return true;
    }
    return false;
}
int calc(const Board& b,int c){
    int res=0;
    for(int i=0;i<b.size();i++){
        for(int j=0;j<b[i].size();j++){
            if(b[i][j]!=0){
                vector<vector<int>> used(b.size());
                for(int i=0;i<b.size();i++){
                    used[i].assign(b[i].size(),0);
                }
                bool rem=!dfs(i,j,b[i][j],used,b);
                if(!rem) continue;
                if(b[i][j]==c){
                    res--;
                }
                else{
                    res++;
                }
            }
        }
    }
    return res;
}
int solve(int n,int c,Board& b){
    int res=-1e8;
    for(int i=0;i<b.size();i++){
        for(int j=0;j<b[i].size();j++){
            if(b[i][j]==0){
                b[i][j]=c;
                res=max(res,calc(b,c));
                b[i][j]=0;
            }
        }
    }
    return res;
}
int main(){
    int n,c;
    while(cin>>n>>c,n){
        Board b(n);
        for(int i=0;i<n;i++){
            b[i].assign(i+1,0);
            for(int j=0;j<i+1;j++){
                cin>>b[i][j];
            }
        }
        cout<<solve(n,c,b)<<endl;
    }
    return 0;
}


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

int dh[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};

int main() {
    int H,W;
    cin >> H >> W;
    vector<string> f(H);
    vector<vector<int>> r(H, vector<int>(W,0));
    rep(i,H)
        cin >> f.at(i);

    rep(i,H)
        rep(j,W)
            if(f.at(i).at(j) == '#')
                rep(k,8) {
                    int nh=i+dh[k], nw=j+dw[k];
                    if(nh<0 || nh>=H || nw<0 || nw>=W)
                        continue;
                    if(f.at(nh).at(nw) == '#')
                        continue;
                    r.at(nh).at(nw)++;
                }
    
    rep(i,H) {
        rep(j,W)
            if(f.at(i).at(j) == '#')
                cout << '#';
            else
                cout << r.at(i).at(j);
        cout << endl;
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <cstdio>

using std::endl;

#define ll long long int
#define FOR(a, s, n) for(int a = s; a < n; ++a)
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define INF 1145141919810
#define MOD 1000000007
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std
#define asn ans

ll N, Data[12345678] = { 0 }, ans = 0;
ll buf;
int main()
{
	IN >> N;

	LEP(a, N)
	{
		IN >> buf;
		if (buf > 10000000) ans++;
		else
		{
			Data[buf]++;
		}
	}

	LEP(a, 12345678)
	{
		if (Data[a] - a < 0) ans += Data[a];
		else
			ans += std::min(Data[a], Data[a] - a);
	}

	OUT << ans << endl;

	return 0;
}

Measured memory_bytes: 78208
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define _GLIBCXX_DEBUG // ArrayOutofBounds
#define rep(i, N) for (int i = 0; i < N; i++) //制御変数iを用いてN回転
using namespace std;
using ll = long long;

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    cout << (N + X - 1) / X*T << endl;
    return 0;
}

Measured memory_bytes: 3620
n,k=map(int, input().split())

if n < k:
    tmp = abs(n-k)
    print(min(tmp, n))
else:
    tmp = n%k
    while True:
        a = tmp-k
        b = abs(a)
        if a < 0:
            print(min(tmp, b))
            break
    

Measured memory_bytes: 38384
from collections import deque

h, w = map(int, input().split())
a = ['#' * (w + 2)] * 2
a[1: 1] = ('#' + input() +  '#' for _ in range(h))
r = 0
for i in range(1, h + 1):
  for j in range(1, w + 1):
    if a[i][j] == '.':
      b = list(map(list, a))
      q = deque()
      b[i][j] = 0
      q.append((i, j))
      while(q):
        i, j = q.popleft()
        r = max(r, b[i][j])
        d = 0
        for i1 in range(i - 1, i + 2):
          for j1 in range(j - d, j + 2, 2):                
            if b[i1][j1] == '.':
              b[i1][j1] = b[i][j] + 1
              q.append((i1, j1))
          d ^= 1
print(r)


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

class P
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int res = 0;
        if (a[0] < 0 && a[1] < 0)
        {
            if (a[0] > a[1])
            {
                res = a[0] - a[1] + 2;
            }
            else
            {
                res = a[1] - a[0];
            }
        }
        else if (a[0] > 0 && a[1] > 0)
        {
            if (a[0] > a[1])
            {
                res = a[0] - a[1] + 2;
            }
            else
            {
                res = a[1] - a[0];
            }
        }
        else
        {
            res = Math.Min(Math.Abs(a[1] + a[0]) + 1, (a[1] - a[0] >= 0 ? a[1] - a[0] : int.MaxValue));
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define pb push_back
#define mp make_pair
#define se second
#define fi first
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int maxn = 500005;
const ll mod = 1000000007;
const ll inf = 0x7f7f7f7f;
//int edgenum, head[maxn], vet[maxn*2], nxt[maxn * 2], wt[maxn * 2];
//void add(int u,int v){edgenum++;vet[edgenum]=v;nxt[edgenum]=head[u];head[u]=edgenum;}
//void add(int u,int v,int w){edgenum++;vet[edgenum]=v;nxt[edgenum]=head[u];head[u]=edgenum;wt[edgenum]=w;}
//ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
/********HEAD********/
int main() {
	int n, k;
	cin >> k >> n;
	int sum = 0, x;
	for(int i = 1; i <= n; i ++) cin >> x, sum += x;
	if(sum > k) cout << -1;
	else cout << k - sum;
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int a;
	int b;
	int ap;
	int bp;
	
	while (1) {
		scanf("%d", &n);
		if (n == 0) {
			break;
		}
		ap = 0;
		bp = 0;
		for (i = 0; i < n; i++) {
			scanf("%d %d", &a, &b);
			if (a > b) {
				ap += a + b;
			}
			else if (a < b) {
				bp += a + b;
			}
			else {
				ap += a;
				bp += b;
			}
		}
		printf("%d %d\n", ap, bp);
	}
	
	return (0);
}

Measured memory_bytes: 600
inp = input()
inp_len = len(inp)
chars = map(ord,list(inp))
dic = {}
an = ""
if inp == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
if inp_len == 26:
    for i in range(25):
        if ord(inp[-1 - i]) > ord(inp[-2 - i]):
            an = inp[:-2-i]
            ls = inp[-2-i]
            for char in map(ord,list(inp[-1-i:])):
                dic[char] = "exist"
            break
    for j in range(26):
        if  97 + j in dic and 97+ j  >  ord(ls):
            an =  an + chr(97+j)
            break
else:
    for char in chars:
        dic[char] = "exist"
    for i in range(26):
        if not (97 + i) in dic:
            an =  inp + chr(97+i)
            break
print(an)


Measured memory_bytes: 3064
n, x = [int(_) for _ in input().split(' ')]
l = [int(_) for _ in input().split(' ')]

d = 0
answer = 0
for i in range(n + 1):
    if i > 0:
        d += l[i - 1]
    if d <= x:
        answer += 1
print(answer)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string n;
    cin>>n;
    long long ans = 0;
    for(int i=0;i<n.size();i++) ans+=n[i]-'0';
    if(ans%9==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3692
// ProblemURL : https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_a
// ---------------------------------------------
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	c := -1
	for i := range s {
		if s[i] == 'C' {
			c = i
			break
		}
	}
	f := -1
	for i := range s {
		if s[i] == 'F' {
			f = i
		}
	}
	if c != -1 && f != -1 && c < f {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  vector<vvi> rm(4,vvi(3,vi(10,0)));
  int n;
  cin >> n;
  REP(i,n){
    int b,f,r,v;
    cin >> b >> f >> r >> v;
    b--;f--;r--;
    rm[b][f][r] += v;
  }
  REP(i,4){
    REP(j,3){
      REP(k,10) cout << " " << rm[i][j][k];
      puts("");
    }
    if(i!=3){
      REP(j,20)cout << '#';
      puts("");
    }
  }
}


Measured memory_bytes: 3164
#include <cstdio>

int n;
int a[200010];
long long D = 1000000007;
long long f[200010], u[200010];
long long res = 0;
int have[200010];

long long pw2(long long x, long long aa)
{
	long long y = 1;
	while(aa>0){
		if(aa % 2 == 1){
			y *= x;
			y %= D;
		}
		aa /= 2;
		x *= x;
		x %= D;
	}
	return y;
}

void pre()
{
	int i;
	f[0] = f[1] = 1;
	for(i=2; i<=n+2; i++){
		f[i] = f[i-1] * i;
		f[i] %= D;
	}
	u[0] = u[1] = 1;
	for(i=2; i<=n+2; i++){
		u[i] = pw2(f[i], D-2);
	}
}

//long long calcC(long long nn, long long mm)
long long calcC(int nn, int mm)
{
	//long long nn = nni;
	//long long mm = mmi;
	if(nn < mm)
		return 0;
	long long r = f[nn];
	r *= u[mm];
	r %= D;
	r *= u[nn-mm];
	r %= D;
	return r;
}

void solve()
{
	pre();
	int i;
	int vv, ll=-1, rr=-1;
	for(i=0; i<n+1; i++){
		have[a[i]] ++;
		if(have[a[i]] == 2)
			vv = a[i];
	}
	for(i=0; i<n+1; i++){
		if(a[i] == vv){
			if(ll==-1)
				ll = i;
			else
				rr = i;
		}
	}
	printf("%d\n", n);
	for(i=2; i<=n; i++){
		res = 0;
		res += calcC(n-1, i);
		res += calcC(n-1, i-1);
		res %= D;
		res += calcC(n-1, i-1);
		res %= D;
		res += D;
		res -= calcC(n+1-(rr-ll+1), i-1);
		res %= D;
		res += calcC(n-1, i-2);
		res %= D;
		printf("%lld\n", res);
	}
	printf("%d\n", 1);
}

int main()
{
	int i;
	scanf("%d", &n);	
	for(i=0; i<n; i++)
		scanf("%d", &a[i]);
	solve();
	return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <map>
#include <cassert>
namespace boost {template <class T>struct integer_iterator {T a;bool operator != (integer_iterator const & it) const { return a != it.a; }T operator * () const { return a; }integer_iterator & operator ++ () { ++ a; return *this; }integer_iterator operator ++ (int) { return { a ++ }; }};template <class T>struct integer_range {T l, r;typedef integer_iterator<T> iterator;iterator begin() const { return { l }; }iterator end  () const { return { r }; }};template <class T>integer_range<T> irange(T l, T r) { assert (l <= r); return { l, r }; }template <class T>struct integer_iterator_with_step {T a, d, i;bool operator != (integer_iterator_with_step const & it) const { return a != it.a or d != it.d or i != it.i; }T operator * () const { return a+d*i; }integer_iterator_with_step & operator ++ () { ++ i; return *this; }integer_iterator_with_step operator ++ (int) { return { a, d, i ++ }; }};template <class T>struct strided_integer_range {T l, r, s;typedef integer_iterator_with_step<T> iterator;iterator begin() const { return { l, s, 0 }; }iterator end  () const { return { l, s, (r - l) / s }; }};template <class T>strided_integer_range<T> irange(T l, T r, T s) { assert (s > 0 ? l <= r : s < 0 ? l >= r : false); return { l, r, s }; }}
typedef long long ll;
using namespace std;
using namespace boost;
int main() {
    while (true) {
        int hn, wn; cin >> hn >> wn;
        if (hn == 0 and wn == 0) break;
        vector<int> h(hn+1), w(wn+1); // accumulated
        for (int i : irange(0, hn)) { cin >> h[i+1]; h[i+1] += h[i]; }
        for (int i : irange(0, wn)) { cin >> w[i+1]; w[i+1] += w[i]; }
        map<int,int> hc, wc;
        for (int i : irange(0, hn)) for (int j : irange(i+1, hn+1)) hc[h[j] - h[i]] += 1;
        for (int i : irange(0, wn)) for (int j : irange(i+1, wn+1)) wc[w[j] - w[i]] += 1;
        ll result = 0;
        for (auto p : hc) result += p.second * wc[p.first];
        cout << result << endl;
    }
    return 0;
}

Measured memory_bytes: 32460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;
const int MAX_N = 2e5;

int main(){
  int n, k;
  cin >> n >> k;
  int a[200000];
  rep(i, n) cin >> a[i];
  int ub = 1e9, lb = 0;
  int m = (ub + lb)/2;
  int tmp = 0;
  while(ub - lb > 1){
    m = (ub + lb)/2;
    int cutnum = 0;
    for(int i = 0; i < n; i++){
      if(a[i] > m) cutnum += a[i]%m ? a[i]/ m : a[i]/m - 1;
      if(cutnum > k) break;
    }
    if(cutnum > k) lb = m;
    else ub = m;
    tmp = cutnum;
  }
  if(tmp > k) m++;
  cout << m << endl;
}

Measured memory_bytes: 4376
def show(nums):
    for i in range(len(nums)):
        if i!=len(nums)-1:
            print(nums[i],end=' ')
        else:
            print(nums[i])
def bubbleSort(A,N):
    count = 0
    flag = True
    while flag:
        flag = False
        for i in range(1,N):
            if A[i-1] > A[i]:
                A[i-1],A[i]=A[i],A[i-1]
                count+=1
                flag = True
    show(A)
    print(count)
X = int(input())
Y = list(map(int,input().split()))
bubbleSort(Y,X)


Measured memory_bytes: 5608
n, a, b, c, d = list(map (int, input().split()))
s = input ()
s = '#' + s
 
ans = True
 
if '##' in s[a:max(c,d)+1]:
    ans = False
else:
    if d < c:
        ans = False
        if '...' in s[b-1:d+2]:
            ans = True
        
 
if ans is True:
    print ('Yes')
else:
    print ('No')


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();

		String[] ana = new String[3];
		ana = line.split(" ");
		int jal[] = new int[3];
		int t = 0;
		for (int i = 0; i < ana.length; i++)
			jal[i] = Integer.parseInt(ana[i]);
		if((jal[0]==2) || (jal[1]==1))
			System.out.println("No");
		else if((jal[0]==1) || (jal[0]==3) || (jal[0]==5) || (jal[0]==7) || (jal[0]==8) || (jal[0]==10) || (jal[0]==12))
			if((jal[1]==1) || (jal[1]==3) || (jal[1]==5) || (jal[1]==7) || (jal[1]==8) || (jal[1]==10) || (jal[1]==12))
				System.out.println("Yes");
			else System.out.println("No");
		else if((jal[0]==1) || (jal[0]==6) || (jal[0]==9) || (jal[0]==11))
			if((jal[1]==6) || (jal[1]==9) || (jal[1]==11))
				{System.out.println("Yes");}
			else
				System.out.println("No");
	}
}


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

int main() {
  int N;
  scanf("%d", &N);
  vector<int64_t> L(N + 1);
  
  L.at(0) = 2;
  L.at(1) = 1;
  
  for (int i = 2; i < N + 1; i++)
    L.at(i) = L.at(i - 2) + L.at(i - 1);
  
  printf("%ld\n", L.at(N));
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef pair<int,int> P;
typedef long long ll;

const int INF = 1e9;

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

	int n;
	cin >> n;
	
	if(n == 0){
		cout << 0 << "\n";
		return 0;
	}

	vector<int> ans;

	int tmp;
	while(true){
		tmp = n / (-2);
		if(n % (-2) == -1){
			tmp++;
			ans.push_back(1);
		}
		else ans.push_back(n % (-2));

		if(tmp == 1){
			ans.push_back(1);
			break;
		}
		n = tmp;
	}

	for(auto i=ans.end() -1;i != ans.begin()-1;i--){
		cout << *i;
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type
typedef long long ll;
typedef long double ld;
// loop
//#define For(i, l, r, x)     for (int i = l; i < r; i+=x)
//#define ForE(i, l, r, x)    for (int i = l; i <= r; i+=x)
//#define Ford(i, r, l)       for (int i = r; i > l; i--)
//#define FordE(i, r, l)      for (int i = r; i >= l; i--)
//#define Fora(i, a)          for (auto i : a)
// I/O 
#define FAST_IO             std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define PrintV(a)           Fora(ii, a) cout << ii << ' '; cout << endl;
//#define PrintVl(a)          Fora(ii, a) cout << ii << endl;
//#define PrintA(a, l, r)     for (int ii = l; ii <= r; ii++) cout << a[ii] << ' '; cout << endl;
//#define PrintAl(a, l, r)    for (int ii = l; ii <= r; ii++) cout << a[ii] << endl;
//#define Ptest(x)            return cout << x, 0;
#define setpre(n)           fixed << setprecision(n)
// pair
#define F                   first
#define S                   second
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pdd                 pair<ld, ld>
// vector & !!?(string)
#define eb                  emplace_back
#define pb                  push_back
#define all(a)              a.begin(), a.end()
#define rall(a)             a.rbegin(), a.rend()
#define sz(a)               a.size()
#define len(a)              a.length()
// geometry calc    
#define pi                  acos(-1.0)
#define g_sin(a)            sin(a*pi/180)
#define g_cos(a)            cos(a*pi/180)
#define g_tan(a)            tan(a*pi/180)
// set val
#define ms0(a)              memset(a,        0, sizeof(a));
#define ms1(a)              memset(a,        1, sizeof(a));
#define msn1(a)             memset(a,       -1, sizeof(a));
#define msinf(a)            memset(a, 0x3f3f3f, sizeof(a));
// constant
const int mod1 = 998244353, mod2 = 1e9+7;
const int MAX_N = 100005, MAX_M = 200010;
//
vector<ll> tot;
ll pre[1001], n, k, x;
void Solve() {
    cin >> n >> k;
    pre[0] = 0;
    for (int i = 1; i <= n; i++){
        cin >> x;
        pre[i] = pre[i-1]+x;
    }
    for (int i = 0; i < n; i++){
        for (int j = i+1; j <= n; j++){
            tot.pb(pre[j]-pre[i]);
        }
    }
    ll ans = 0;
    for (int b = 50; b >= 0; b--){
        ll c = 0;
        for (auto x:tot){
            //cout << x << ' ';
            if ((ans&x) == ans){
                if ((x&(1ll << b)) == (1ll << b)){
                    c++;
                }
            }
        }
        if (c >= k){
            ans ^= (1ll << b);
        }
    }
    
    cout << ans;
}

signed main(){
    FAST_IO;
    int TC = 1; 
	// cin >> TC;
    while(TC--) Solve();
    return 0;
}


Measured memory_bytes: 6512
#include<cstdio>
int N;
int dif(int a,int b){return a>b?a-b:b-a;}
int calc(int*s,int*t,int sl,int tl,int ty){
	int ans=1<<30;
	for(int i=ty;i<=sl;i+=2){
		int tmp=0;
		if(i+tl<=sl){
			tmp=sl-tl;
			for(int j=0;j<sl;j++)tmp+=j<i?s[j]:j<i+tl?dif(s[j],t[j-i]):N-s[j]-2;
		}
		else{
			tmp=i*2+tl-sl;
			for(int j=0;j<sl;j++)tmp+=j<i?s[j]:dif(s[j],t[j-i]);
			for(int j=sl-i;j<tl;j++)tmp+=N-t[j]-2;
		}
		if(tmp<ans)ans=tmp;
	}
	return ans;
}
int s[5010],t[5010],sl,tl;
char str[5010];
int main(){
	scanf("%d%s",&N,str);
	for(int i=0;i<N;i++)if(str[i]==str[i+1])s[sl++]=i;
	int ty=*str;
	scanf("%s",str);
	for(int i=0;i<N;i++)if(str[i]==str[i+1])t[tl++]=i;
	ty^=*str;
	int ans1=calc(s,t,sl,tl,ty),ans2=calc(t,s,tl,sl,ty),ans=ans1<ans2?ans1:ans2;
	if(ty&&!sl&&!tl)ans=N;
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<long long int> a(n);
  for(long long int i=0; i<n; i++){
    cin>>a.at(i);
  }
  long long int ans=999999999999;
  for (int i = -100; i <= 100; i++)
  {
    long long int preans=0;
    for (int j = 0; j < n; j++)
    {
      preans+=pow(a.at(j)-i,2);
    }
    ans=min(ans,preans);
  }
  
  cout<<ans<<endl;
}

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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pull pair<ull, ull>
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	
	if(n < 3){
		cout << "0";
		exit(0);
	}
	
	int ref[s.size()+1][3];
	for(int i=0 ; i<3 ; ++i)ref[n-1][i] = 0;
	for(int i=s.size()-2 ; i>=0 ; --i){
		for(int j=0 ; j<3 ; ++j){
			ref[i][j] = ref[i+1][j];
		}
		if(s[i+1] == 'R')ref[i][0]++;
		if(s[i+1] == 'G')ref[i][1]++;
		if(s[i+1] == 'B')ref[i][2]++;
	}
	
	ll c=0;
	for(int i=0 ; i<s.size()-2 ; ++i){
		for(int j=i+1 ; j<s.size()-1 ; ++j){
			if(s[j] != s[i]){
				if(s[i] == 'R'){
					if(s[j] == 'G'){
						c += ref[j][2];
						if(j+j-i < s.size() && s[j+j-i] == 'B')c--;
					}
					else{
						c += ref[j][1];
						if(j+j-i < s.size() && s[j+j-i] == 'G')c--;
					}
				}
				if(s[i] == 'G'){
					if(s[j] == 'R'){
						c += ref[j][2];
						if(j+j-i < s.size() && s[j+j-i] == 'B')c--;
					}
					else{
						c += ref[j][0];
						if(j+j-i < s.size() && s[j+j-i] == 'R')c--;
					}
				}
				if(s[i] == 'B'){
					if(s[j] == 'R'){
						c += ref[j][1];
						if(j+j-i < s.size() && s[j+j-i] == 'G')c--;
					}
					else{
						c += ref[j][0];
						if(j+j-i < s.size() && s[j+j-i] == 'R')c--;
					}
				}
			}
		}
	}
	
	cout << c;
}


Measured memory_bytes: 3664