akhauriyash/Code-Regression huggingface dataset:
/*author : Yashvardhan
Friday, May 31, 2019
6:29 PM
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n;
	cin>>n;
	vi arr(n);
	vi tmp;
	int maxi = -1;
	for(int i = 0; i < n ; i++){
		cin>>arr[i];
		maxi = max(maxi,arr[i]);
	}

	int count = 0;
	

	while(1){
		int i = 0;
		while(i < n){
			bool flag = false;
			while(arr[i] != 0 && i < n){
				arr[i]--;
				flag = true;
				i++;
			}
			if(flag) count++;
			i++;
		}
		int zc = 0;
		for(auto j: arr) if(j == 0) zc++;
		if(zc == n) break;
	}

	cout<<count<<endl;
	
	
	
	
	

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
long long a,b,t=1000000001,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a,&b);
		ans+=a;
		if(a>b)
		t=min(t,b);
	}
	if(t==1000000001)
		printf("0");
	else printf("%lld",ans-t);
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;


public class Main{
	static void main() throws Exception{
		String[]ans=new String[] {"pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"};
		pw.println(ans[sc.nextInt()%10]);
	}
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		int tc=1;
		while(tc-->0)main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}


Measured memory_bytes: 32576
#include<iostream>

using namespace std;

int main(){
  int c=0, d=0, n=0, way=0;

  cin >> n;

  for(c=0;c<4*n;++c){
    for(d=0;d<7*n;++d){
      if(n == (c*4)+(d*7)){
        ++way;
        break;
      }
    }
  }

  if(way)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) {if (x % y == 0) return y;else return LGCD(y, x % y);}
ll LLCM(ll x, ll y) {return x * y / LGCD(x, y);}

int GCD(int x, int y) {if (x % y == 0) return y;else return GCD(y, x % y);}
int LCM(int x, int y) {return x * y / GCD(x, y);}
ll dp[10000][10000];
ll combination(ll n, ll r) {
         if (n == r){dp[n][n] = 1;}
	else if (r == 0) {return dp[n][0] = 1;}
	else if (r == 1) {return dp[n][1]=n;}
	else {dp[n][r]=dp[n - 1][r - 1] % 1000000007 + dp[n - 1][r] % 1000000007;
	return dp[n][r]=combination(n - 1, r - 1) % 1000000007 + combination(n - 1, r) % 1000000007;}
}
int main() {
	int N;
	int count,ans;
	count = 0;
	cin >> N;
	vector<pair<int,int>>A(N);
	for (int i = 0;i < N;i++)
	{
		A.at(i).second = i + 1;
		cin >>A.at(i).first;

	}
	sort(A.begin(), A.end());
	for (int i = 0;i < N;i++)
	{
		cout << A.at(i).second ;
		if (i < N - 1) { cout << " "; }
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1536
#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;

string s = "URDL";
int dx[4] = { 0, 1,  0, -1};
int dy[4] = {-1, 0,  1,  0};

signed main() {
    string ans = "";
    int f[5][5][4] = {0};
    string wx[5];
    string wy[4];
    rep(i, 0, 9){
        if(i % 2 == 0){
            cin >> wx[i / 2];
        }else{
            cin >> wy[i / 2];
        }
    }
    f[0][0][0] = 1;
    int y = 0, x = 0, dir = 0;
    while(1){
        rep(i, 0, 4){
            int tmp = (dir + i) % 4;
            int ny = y + dy[tmp];
            int nx = x + dx[tmp];
            if(!(0 <= ny && ny <= 4 && 0 <= nx && nx <= 4)) continue;
            if(tmp == 0 && wy[y - 1][x] == '0') continue;
            if(tmp == 1 && wx[y][x] == '0') continue;
            if(tmp == 2 && wy[y][x] == '0') continue;
            if(tmp == 3 && wx[y][x - 1] == '0') continue;
            if(f[ny][nx][(dir + i + 3) % 4] == true) continue;
            f[ny][nx][(dir + i + 3) % 4] = true;
            y = ny;
            x = nx;
            dir = (dir + i + 3) % 4;
            ans += s[tmp];
            //o(y<<" "<<x<<" "<<dir<<" "<<ny<<" "<<nx<<" "<<tmp<<" "<<s[tmp]);
            break;
        }
        if(f[0][0][2] || f[0][0][3]) break;
    }
    cout << ans << endl;
}

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

int main(){
  int n;
  int k;
  int temp;

  while(cin>>n>>k,n,k){
    vector<int> data;
    int max=0;

    for(int i=0;i<n;++i){
      cin>>temp;
      data.push_back(temp);
    }
    
    for(int i=0;i<n-k+1;++i){
      int total=0;
      for(int j=i;j<k+i;++j){
	total+=data[j];
      }
      if(max<total)
	max=total;
    }
    cout<<max<<endl;
  }
} 

Measured memory_bytes: 3384
from sys import stdin

k,a,b = [int(x) for x in stdin.readline().rstrip().split()]

if a + 2 >= b:
    print(k+1)
    exit()

maisu = a
kaisu = a-1

if (k - kaisu) % 2 == 0:
    maisu -= a*((k-kaisu)//2)
    maisu += ((k-kaisu)//2)*b
else:
    maisu -= a*((k-kaisu)//2)
    maisu += ((k-kaisu)//2)*b+1

print(maisu)

Measured memory_bytes: 3064
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [h, n] <- getIntList
    as <- getIntList
    if h > sum as then putStrLn "No" else putStrLn "Yes"

Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
int d[2]={1,-1};
char p[2]={'+','-'};
 
int main(){
  string s;
  int a[5];
  cin>>s;
  for(int i=0;i<4;i++){
    a[i]=s[i]-'0';
  }
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
	if(a[0]+a[1]*d[i]+a[2]*d[j]+a[3]*d[k]==7){
	  cout<<s[0]<<p[i]<<s[1]<<p[j]<<s[2]<<p[k]<<s[3]<<"=7"<<endl;
	  return(0);
	}
      }
    }
  }
  return(0);
}

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

string s;
int K;
vector<string> l;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> s >> K;
    rep(i, s.size()) for (int j=1; j<=5; j++) {
        if (i+j<=s.size()) l.pb(s.substr(i, j));
    }
    sort(l.begin(), l.end());
    l.erase(unique(l.begin(), l.end()), l.end());
    //rep(i, l.size()) cout << l[i] << endl;
    cout << l[K-1] << endl;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

inline int addmod(lli x,lli y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(lli x,lli y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(lli x,lli y)
{
    return (x%mod * y%mod)%mod;
}

inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}

bool isPrime(int n){
    for(int i=2; (i*1LL*i) <= n; i++){
        if(n%i == 0) return false;
    }
    return true;

}

int main()
{
    ///freopen("output.txt","w",stdout);
   // freopen("input.txt","r",stdin);
    FastIO;
    int n;
    vector<int>primes;
    for(int i=2; i<=100; i++){
        if(isPrime(i)) primes.pb(i);
    }
    while(cin>>n){
        lli ge24 = 0 , ge2 = 0 , ge4 = 0 , ge14  =0 ;
        lli ans = 0;
        for(int p : primes){
            int cnt = 0 , now = p;
            while(n/now){
                cnt += n/now;
                now *= p;
            }
            if(cnt>=74) ans++;
            if(cnt>=24) ge24++;
            if(cnt>=14) ge14++;
            if(cnt>=4) ge4++;
            if(cnt>=2) ge2++;
        }
        ans += ge24*(ge2-1) + ((ge4*(ge4-1))/2)*(ge2-2) + ge14*(ge4-1);
        cout<<ans<<endl;
    }

    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});


Measured memory_bytes: 256
import fileinput
if __name__ == "__main__":
    for line in fileinput.input():
        v = [int(i) for i in line.split(" ")]
        x = (v[2] * v[4] - v[1] * v[5]) / (v[0] * v[4] - v[1] * v[3])
        y = (v[2] * v[3] - v[0] * v[5]) / (v[1] * v[3] - v[0] * v[4])
        if -0.0005 < x <= 0:
            x = 0.000
        if -0.0005 < y <= 0:
            y = 0.000
        print(format(x, ".3f"), format(y, ".3f"))

Measured memory_bytes: 7748
#include<iostream>
using namespace std;
int main(){
int a;
 
 cin>>a;
 int b;
 b=a/1000;
 int c;
 c=a-b*1000;
if (a%1110<=9){
 cout<<"Yes"<<endl;}
 
 else if(c%111==0){
 cout<<"Yes"<<endl;
} 
else{
	cout<<"No"<<endl;}

    	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 1E5;
int n, m;
vector<int> e[N];
int pre[N], to[2 * N];
bool used[2 * N];
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
void bfs(int s) {
    memset(pre, -1, n * sizeof(int));
    queue<int> que;
    pre[s] = -2;
    que.push(s);
    while (!que.empty()) {
        int u = que.front();
        que.pop();
        for (int i : e[u]) {
            if (used[i])
                continue;
            int v = to[i];
            if (pre[v] == -1) {
                pre[v] = i;
                que.push(v);
            }
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        to[2 * i] = --v;
        to[2 * i + 1] = --u;
        e[u].push_back(2 * i);
        e[v].push_back(2 * i + 1);
    }
    vector<int> d4;
    for (int i = 0; i < n; ++i)
        if ((int)e[i].size() % 2 == 1)
            no();
    for (int i = 0; i < n; ++i) {
        if ((int)e[i].size() >= 6)
            yes();
        if ((int)e[i].size() == 4)
            d4.push_back(i);
    }
    if ((int)d4.size() >= 3)
        yes();
    if ((int)d4.size() <= 1)
        no();
    for (int i = 0; i < 3; ++i) {
        bfs(d4[0]);
        if (i == 2)
            break;
        int u = d4[1];
        while (u != d4[0]) {
            used[pre[u]] = true;
            u = to[pre[u] ^ 1];
        }
    }
    if (pre[d4[1]] != -1)
        no();
    yes();
    return 0;
}

Measured memory_bytes: 7040
N = int(input())
X = [int(_) for _ in input().split()]
Y = [int(_) for _ in input().split()]


def calc_dist_mink(list_x, list_y, p):
    list_xy = [abs(list_x[i] - list_y[i]) for i in range(len(list_x))]
    list_xy_p = [i ** p for i in list_xy]
    ans = sum(list_xy_p) ** (1 / p)
    return(ans)

list_ans = []
ans_1 = calc_dist_mink(X, Y, 1)
list_ans.append(ans_1)

ans_2 = calc_dist_mink(X, Y, 2)
list_ans.append(ans_2)

ans_3 = calc_dist_mink(X, Y, 3)
list_ans.append(ans_3)

ans_4 = max([abs(X[i] - Y[i]) for i in range(N)])
list_ans.append(ans_4)

for ans in list_ans:
    print(f"{ans:.5f}")
    


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

int main(){
  int n,a,b,cur,a1=0,a2=0,a3=0;
  cin >> n >> a >> b;
  for(int i=0; i<n; i++){
    cin >> cur;
    if(cur<=a){ a1++;}
    else if(cur<=b){
      a2++;}
    else{
      a3++;
    }
  }
  cout << min(min(a1,a2),a3) << endl;
}

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

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

    vector<int> p(n);
    rep (i, n)
        cin >> p[i];

    sort(p.begin(), p.end());

    int ans = 0;
    rep (i, k)
        ans += p[i];

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
  int A,B;
  cin >> A >> B;

  int now_sum = 1;
  int kosuu = 0;

  while(now_sum < B){
    now_sum += A - 1;
    kosuu++;
  }
  cout << kosuu << endl;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

map<lli,lli> makePrimeList2(lli n){
    map<lli,lli> m;
    lli a = 2;
    while(n>=a*a){
        if(n%a==0){
            m[a]++;
            n /= a;
        }
        else a++;
    }
    if(n!=1)m[n]++;
    return m;
}

int main(){

	lli n;
	cin>>n;

	lli ans = 0;
	REP(c,1,n){
		lli num = n-c;
		map<lli,lli> prime = makePrimeList2(num);
		lli now = 1;
		for(auto e:prime){
			now *= (e.second+1);
		}
		ans += now;
	}

	cout<<ans<<endl;

	
    return 0;
}


Measured memory_bytes: 3640
n,t = map(int,input().split())
a = list(map(int,input().split()))
l = 0
s = 0
if(len(a)==1):
    print(t)
    exit()
for i in range(len(a)-1):
    if(a[i+1]-a[i]>t):
        l+=(a[i]+t-s)
        s = a[i+1]
if(a[-1]-a[-2]>t):
    l+=t
else:
    l+=(a[-1]+t-s)
print(l)


Measured memory_bytes: 85712
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var NK = ReadLine().Split().Select(int.Parse).ToArray();
        int N = NK[0];
        int K = NK[1];
        if (N%K == 0) WriteLine(0);
        else WriteLine(1);
    }
}


Measured memory_bytes: 28080
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<cat> A[2];
	for(int i = 0; i < 2; i++) {
		A[i] = vector<cat>(N);
		for(int j = 0; j < N; j++) cin >> A[i][j];
	}
	vector<cat> Stop(N+1, 0), Sbot(N+1, 0);
	for(int i = 0; i < N; i++) Stop[i+1] = Stop[i] + A[0][i];
	for(int i = N-1; i >= 0; i--) Sbot[i] = Sbot[i+1] + A[1][i];
	cat ans = 0;
	for(int i = 1; i <= N; i++) ans = max(ans, Stop[i]+Sbot[i-1]);
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
N, M = map(int, readline().split())

def check(Edge, Dim):
    N = len(Edge)
    if any(d&1 for d in Dim):
        return 'No'
    if max(Dim) > 4:
        return 'Yes'
    dc4 = Dim.count(4)
    if dc4 <= 1:
        return 'No'
    if dc4 >= 3:
        return 'Yes'
    a = Dim.index(4)
    st = (a+1)%N
    used = set([a, st])
    stack = [st]
    while stack:
        vn = stack.pop()
        for vf in Edge[vn]:
            if vf not in used:
                stack.append(vf)
                used.add(vf)
    if len(used) == N:
        return 'No'
    return 'Yes'
Edge = [[] for _ in range(N)]
Dim = [0]*N

for _ in range(M):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)
    Dim[a] += 1
    Dim[b] += 1

print(check(Edge, Dim))

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

int main() {
	int a,b,c,tmp1,tmp2;
	cin >> a >> b >> c;
	while (a > b || b > c) {
		if (b <= a) {
			tmp1 = a;
			a = b;
			b = tmp1;
		}
		else if (c <= b) {
			tmp2 = b;
			b = c;
			c = tmp2;
		}
	}
	cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3100
from collections import deque
h,w = map(int,input().split())
hw = [];count = 0;check = False
for i in range(h):
    ls = [x for x in input()]
    for j in range(w):
        if ls[j] == '.':count += 1
    hw.append(ls)
deq = deque()
matrix = [[False for j in range(w)] for i in range(h)]
deq.appendleft([0,0,0])
while deq:
    ls = deq.pop()
    for i in [[1,0],[-1,0],[0,1],[0,-1]]:
        x = ls[0]+i[0];y = ls[1]+i[1]
        if x < 0 or y < 0 or x >= h or y >= w:continue
        if matrix[x][y] or hw[x][y] == '#':continue
        if h-1 == x and w-1 == y:check = True;num = ls[2];break
        deq.appendleft([x,y,ls[2]+1])
        matrix[x][y] = True
    if check:break
if check:print(count-num-2)
else:print(-1)

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

int n, k;
vector<int> d(9);

int check(int m) {

    while(m > 0) {

        int flag = 0;
        rep(i, k) {
            if(m%10 == d[i]) {
                flag = 1;
                break;
            }
        }

        if(flag) {
            return 0;
        }

        m /= 10;
    }

    return 1;
}

int main() {

    cin >> n >> k;
    
    rep(i, k) {
        cin >> d[i];
    }

    int x = n;
    while(1) {

        if(check(x)) {
            cout << x << endl;
            return 0;
        }
        x++;
    }

}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		sc.close();
		out.println((a*b)%2==1?"Yes":"No");
	}
}


Measured memory_bytes: 21076
#include <iostream>
#include <cstring>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <assert.h>
#include <stdlib.h>
using namespace std;

void smain();
int main() {
    ios_base::sync_with_stdio(0);
#ifdef TASK
    freopen(TASK".in","rt",stdin);
    const clock_t start = clock();
#endif
    smain();
#ifdef TASK
    cerr << "\nTotal Execution Time: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

#ifndef M_PI
#define M_PI 3.14159265358979311599796346854418516
#endif
#define forn(i,n) for (int i=0;i<n;i++)
#define rforn(i,n) for (int i=n-1;i>=0;i--)
#define LL long long
#define int long long
#define mp(a,b) make_pair(a,b)
#define INF 2305843009213693951LL
#define MOD 1000000007
#define EPS 1E-12
#define N 2000002
/* --------- END TEMPLATE CODE --------- */
int n, k;

void smain() {
    for (; cin >> n >> k;) {
        map<int, int> cnt;
        forn(i, n) {
            int x;
            cin >> x;
            cnt[x] += 1;
        }
        vector<pair<int, int> > a;
        for (auto it : cnt) a.emplace_back(it.second, it.first);
        int res = 0;
        sort(a.begin(), a.end());
        for (int i = 0; i + k < (int)a.size(); ++i) {
            res += a[i].first;
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 17776
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    string s, a, b, c;

    cin >> s;

    a = s.substr(s.size() / 2 + 1);

    b = s.substr(0, s.size() / 2);

    c = b;

    reverse(b.begin(), b.end());

    if (a == b && a == c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
/*
Author: QAQAutomaton
Lang: C++
Code: A.cpp
Mail: lk@qaq-am.com
Blog: https://www.qaq-am.com/
*/
#include<bits/stdc++.h>
#define int long long
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int inf;
const double eps=1e-8;
const double pi=acos(-1.0);
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
template<class T>int dcmp(T a,T b){return a>b;}
template<int *a>int cmp_a(int x,int y){return a[x]<a[y];}
#define min mmin
#define max mmax
#define abs aabs
struct __INIT__{
	__INIT__(){
		memset(&inf,0x3f,sizeof(inf));
	}
}__INIT___;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	template<typename A>
	inline bool read (A &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;else if(c==EOF)return 0;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
		return 1;
	}
	inline bool read (char &x) {
		while((x=gc())==' '||x=='\n' || x=='\r');
		return x!=EOF;
	}
	inline bool read(char *x){
		while((*x=gc())=='\n' || *x==' '||*x=='\r');
		if(*x==EOF)return 0;
		while(!(*x=='\n'||*x==' '||*x=='\r'))*(++x)=gc();
		*x=0;
		return 1;
	}
	template<typename A,typename ...B>
	inline bool read(A &x,B &...y){
		return read(x)&&read(y...);
	}
	template<typename A>
	inline bool write (A x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
		return 0;
	}
	inline bool write (char x) {
		putc(x);
		return 0;
	}
	inline bool write(const char *x){
		while(*x){putc(*x);++x;}
		return 0;
	}
	inline bool write(char *x){
		while(*x){putc(*x);++x;}
		return 0;
	}
	template<typename A,typename ...B>
	inline bool write(A x,B ...y){
		return write(x)||write(y...);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: write;
signed main(){
#ifdef QAQAutoMaton 
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
#endif
	int n,a,b;
	read(n,a,b);
	if(a>b)swap(a,b);
	if((a-b)&1){
		write(min((a+b)>>1,(n+n-a-b+1)>>1),'\n');
	}
	else{
		write((b-a)>>1,'\n');
	}
	return 0;
}



Measured memory_bytes: 2304
# A[i]が採用されるとき、A[i-1]も採用されるという単調性があるので二分探索で解く
N, M, V, P = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)

capacity = M * (N-V)


def isOK(i):
    ai = A[i]  # 基準となる値
    s = 0
    # 0~P-2番目のP-1問とi番目とi番目以降には全員が投票しても構わない
    # P-1番目からi-1番目までについて考える必要がある
    for j in range(P-1, i):
        d = A[j] - ai
        # A[j]とaiの差がM以上あるということは、A[0]からA[j-1]までも差がM以上あり追いつけない
        if d > M:  # この時点で先頭のA[j]問を含む先頭の問題たちはaiが追いつけないスコアをもっている
            return False
        s += d
    if s > capacity:
        return False
    else:
        return True


left = -1
right = N
while right - left > 1:
    mid = (right+left)//2
    if isOK(mid):  # 中央値が満たすなら下界をあげる
        left = mid
    else:  # 中央値が満たさないなら上界を下げる
        right = mid
print(left + 1)


Measured memory_bytes: 14964
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

using namespace std;

class BShiftOnly {
public:
    void solve(istream& cin, ostream& cout) {
        ll n;
        vector<ll> a;
        cin >> n;
        for(int i=0; i<n; i++) {
            int tp;
            cin >> tp;
            a.push_back(tp);
        }
        ll cnt = 0;
        while(true) {
            int i;
            for( i=0; i<n; i++) {
                if(a[i] %2) break;
                a[i] /= 2;
            }
            if(i!=n)break;
            cnt++;
        }
        cout << cnt << '\n';
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    BShiftOnly solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[N-1];
		int sum = 0;

		for(int i = 0; i<N;i++) {
			a[i] = sc.nextInt();
		}
		for(int i = 0; i<N;i++) {
			b[i] = sc.nextInt();
		}
		for(int i = 0; i<N-1;i++) {
			c[i] = sc.nextInt();
		}

		for(int i = 0;i<N;i++) {
			sum += b[i];

		}
		for(int i = 0;i<N-1;i++) {
			if(a[i+1] == a[i] + 1) {
				sum += c[a[i]-1];
			}
		}
		System.out.println(sum);

		sc.close();
	}
}




Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main()
{
  int n,k;
  cin >> n >> k;
  vector<bool> check(n,false);
  vector<set<int> > list(k);
  for(int i=0; i<k; i++){
    int m;
    cin >> m;
    for(int j=0; j<m; j++){
      int l;
      cin >> l;
      list[i].insert(l);
    }
  }
  int r;
  cin >> r;
  for(int i=0; i<r; i++){
    int m,l;
    cin >> m >> l;
    for(int j=0; j<k; j++){
      if(list[j].find(m) != list[j].end() && list[j].find(l) != list[j].end()){
        check[m-1] = true;
        check[l-1] = true;
        break;
      }
    }
  }
  int count = 0;
  for(int i=0; i<n; i++){
    if(check[i]) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using ll = long long;

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

    int X, A;
    cin >> X >> A;
    if (X < A) {
        cout << 0 << endl;
    }
    else {
        cout << 10 << endl;
    }
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

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

	int N=in(),C=in();
	vector<vector<ll>> D(C,vector<ll>(C));
	REP(i,C){
		REP(j,C){
			D[i][j] = in<ll>();
		}
	}
	map<int,ll> cm[3];
	REP(i,N){
		REP(j,N){
			cm[(i+1+j+1)%3][in()-1]++;
		}
	}

	ll minF = 1e18+7;
	REP(i1,C){
		ll sum1 = 0;
		for(auto& x:cm[0]){
			sum1 += x.second*D[x.first][i1];
		}
		REP(i2,C){
			if(i1==i2) continue;
			ll sum2 = 0;
			for(auto& x:cm[1]){
				sum2 += x.second*D[x.first][i2];
			}
			REP(i3,C){
				if(i1==i3 || i2==i3) continue;
				ll sum3 = 0;
				for(auto& x:cm[2]){
					sum3 += x.second*D[x.first][i3];
				}
				minF = min(minF,sum1+sum2+sum3);
			}
		}
	}
	
	cout << minF << endl;
	return 0;
}


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

int main(){
	int n,t=1;
  	cin >>n;
  	vector<int> vec(n);
  	for (int i=0;i<n;i++){
    	cin >> vec[i];
    }
  	for (int i=0;i<n;i++){
    	for(int j=i+1;j<n;j++){
        	if(vec[i]>=vec[j])swap(vec[i],vec[j]);
        }
    }
  	for (int i=0;i<n;i++){
    if (vec[i] < vec[i+1]) t++;
    }
  cout << t << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
#include<limits.h>
#include<iomanip>
using namespace std;

const int N=1e5+5;
int n;
long long tot,cur,ans;
int a[N],o[N];
long long suf[N],sum[N];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		char c;
		if(i!=1) scanf(" %c",&c);
		if(c=='+'||i==1) o[i]=1;
		else o[i]=0;
		scanf("%d",a+i);
	}
	for(int i=n;i>=1;i--){
		suf[i]=suf[i+1];
		sum[i]=sum[i+1]+1ll*a[i];
		tot+=1ll*a[i];
		if(!o[i]){
			suf[i]+=tot;
			tot=0;
			ans-=a[i];
		}else ans+=a[i];
	}
	for(int i=1;i<=n;i++){
		if(o[i]) cur+=1ll*a[i];
		else cur-=1ll*a[i];
		if(o[i]==0) ans=max(ans,cur+suf[i+1]-(sum[i+1]-suf[i+1]));
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	int W,H,K,blacksum = 0;
  cin >> H >> W >> K;
  vector<vector<char>> b(H,vector<char>(W));
    vector<vector<char>> work(H,vector<char>(W));
    vector<vector<char>> work2(H,vector<char>(W));

  froop1(0,H){
    for(int j = 0;j < W;j++){
      cin >> b.at(i).at(j);
    }
  }

  
  int allw = 1 << W;
  int allh = 1 << H;
  int count = 0;
  for(int bitw = 0;bitw < allw;bitw++){
    work = b;
    
    froop1(0,W){
      if((bitw >> i) & 1){
        for(int j = 0;j < H;j++){
          work.at(j).at(i) = 'R';
        }
      }
      }
    
    for(int bith = 0;bith < allh;bith++){
      work2 = work;
          froop1(0,H){
      if((bith >> i) & 1){
        for(int j = 0;j < W;j++){
          work2.at(i).at(j) = 'R';
        }
      }
      }

      int c = 0;
    froop1(0,H){
      for(int j = 0;j < W;j++){
      if(work2.at(i).at(j) == '#')c++;  
      }
    }
      
    
   
    if(c == K)count++;
    
    }
  }
    

  cout << count << endl;
  
  
return 0;
}

Measured memory_bytes: 3560
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
long long ans,n,a,b,c;
map<long long,long long> m;
vector<long long> v;

long long gcd(long long x,long long y)
{	
	if(y==0)
		return x;
	return gcd(y,x%y);	 
}

int main()
{
	cin>>a>>b;
	long long g=gcd(a,b);
	for(long long i=1;i<=sqrt(g);i++)
	{
		if(g%i==0)
		{
			if(i!=sqrt(g))
			{
				v.push_back(i);
				m[i]++;
			}
			v.push_back(g/i);
			m[g/i]++;	
		}
	}
	sort(v.begin(),v.end(),greater<long long>());
	ans=v.size();
	for(long long i=0;i<v.size();i++)
	{
		for(long long o=2;o<=sqrt(v[i]);o++)
		{
			if(v[i]%o==0 && m[v[i]/o]!=0)
			{
				ans--;
				break;
			}
			else if(v[i]%o==0 && m[o]!=0)
			{
				ans--;
				break;
			}
		}
	}
	cout<<ans<<endl;		
} 

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

int main() {
    int n, m; cin >> n >> m;
    vector<int> A(2 * n);
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        A[i] = a;
    }
    vector<pair<int, int>> C(m);
    for (int i = 0; i < m; i++) {
        int b, c; cin >> b >> c;
        C[i] = make_pair(c, b);
    }

    sort(C.begin(), C.end());
    int l = n;
    for (int i = m - 1; i >= 0; i--) {
        int b = C[i].second, c = C[i].first;
        int jmax = min(b, 2 * n - l);
        for (int j = 0; j < jmax; j++) {
            A[l++] = c;
        }
    }

    sort(A.begin(), A.end());
    cout << accumulate(A.end() - n, A.end(), 0LL) << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
    int n;
    char buf[10];
    cin>>n;
    sprintf(buf,"%d",n);
    int len=strlen(buf);
    for(int i=0;i<=len/2;i++)
    {
        if(buf[i]!=buf[len-i-1])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

a = [0] * N

# 各スイッチがどの電球に繋がっているか
for i in range(M):
    l = list(map(int, input().split()))
    k = l[0]
    S = l[1:]
    for j in range(k):
        s = S[j]
        s -= 1
        # s番目のスイッチにi番目の電球が繋がっている
        a[s] |= 1 << i

p = 0
l = list(map(int, input().split()))
for i in range(M):
    p |= l[i] << i

ans = 0
# スイッチの押し方全通り
for s in range(1 << N):
    t = 0
    for i in range(N):
        # iビット目が立っているか
        if s >> i & 1:
            # スイッチを押して、つながった電球の状態を反転させる
            t ^= a[i]
    # 各スイッチを押した後の電球の状態が理想と一致するか
    if t == p:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    p = LI()
    t = LI()
    dp = [inf] * (10**5)
    dp[0] = 0
    for i in range(10**5):
        for num,ti in enumerate(t):
            if i - ti >= 0:
                dp[i] = min(dp[i], dp[i - ti] + p[num])
    for i in range(10**5-1, 0, -1):
        dp[i - 1] = min(dp[i], dp[i - 1])
    print(dp[n])
    return

#B
def B():
    def yaku(n):
        res = 0
        if n == 0:
            return 0
        for i in range(1, int(math.sqrt(n-1)) + 1):
            if n % i == 0:
                res += 2
        if float.is_integer(math.sqrt(n)):
            res += 1
        return res
    q = II()
    ya = [yaku(i) for i in range(10 ** 5 + 1)]
    ya[0] = 0
    for i in range(1,10 ** 5 + 1):
        if ya[i] >= 5:
            ya[i] = 1
        else:
            ya[i] = 0
        ya[i] += ya[i - 1]
    for i in range(q):
        n = II()
        print(ya[n])
    return

#C
def C():
    return

#D
def D():
    a, b = LI()
    if b % a == 0 or a == 2:
        print(-1)
    else:
        x = b // a + 1
        c = a * x
        if x < c // b + c % b:
            print(c)
        else:
            print(-1)

#E
def E():
    return

#F
def F():
    return

#G  
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()



Measured memory_bytes: 8204
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
 
using namespace std;
using namespace __gnu_pbds;
 	// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inff (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
#define SPEED ios_base::sync_with_stdio(false) ;cin.tie(NULL) ;cout.tie(NULL) ;
#define fp(i,a,n) for(ll i=n-1; i>a ;i--)
#define deb(x) cout << #x << " ---> " << x << endl;
#define X first
#define Y second
#define pia 3.1415926536
#define mod 1000000007 
#define N 150050
#define ml map<ll,ll>
#define mll map<pair<ll,ll> ,ll>
#define letsh(a,b) a<<b
#define rigsh(a,b) a>>b 
#define vvl vector<vl>
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count()) ;
		ll lcm(ll a, ll b)
		{
               return a / __gcd(a, b) * b;
       	}
       ll power(ll a,ll n,ll m=mod)
	   {
        ll ans=1;
        while(n)
		{
        if(n&1) ans=(ans*a)%mod;
        a=(a*a)%mod ;
        n=n>>1;
   		 }
   		 return ans;
      }
      vll dir({{1, 0}, {-1, 0}, {0, 1}, {0, -1}}) ;
  
	//	vl vis(N+1,0) ;
      
      void solve()
      {
        string s ;cin>>s ;
        string t ; cin>>t ;
		ll ans=0 ;
		f(i,0,s.size()-t.size()+1)
		{
			///<<i<<endl ;
			ll sum =0  ,k=0;
			f(j,i,i+t.size())
			{if(s[j] == t[k]) sum++ ;
			k++;
				
			 } 
			ans = max(ans,sum) ;
		}
		//cout<<ans<<endl ;
		cout<<(ll)t.size()-ans<<endl ;
	 }
      
      int main() 
	  {
	  	SPEED
        ll t =1; 
        while(t--) solve() ; 
	  }

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define endl '\n'
#define fast_in ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp  make_pair
#define pb  push_back
#define  sz(x)   (int)x.size()
#define  all(x)  x.begin(), x.end()
#define	 allr(x)  x.rbegin(), x.rend()
#define  bit(x)  __builtin_popcountll(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
const int inf = (int) 1e9+99999, mod = (int)1e9+7;
const ll linf = (ll) 2e18+99999;
int mul (int x, int y) { return ((ll)x * y) % mod; } 
int sub (int x, int y) { x -= y; if (x < 0) return x + mod; return x; } 
int add (int x, int y) { x += y; if (x >= mod) return x - mod; return x; }
 
const int maxn = (int) 3e5;
 
int g[maxn], d[maxn];
bool used[maxn];

void solve () {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> g[i];
	}	

	queue <int> q;
	q.push (1);
	d[1] = 1;
	while (q.size()) {
		int cur = q.front ();
		q.pop ();
		if (!used[g[cur]]) {
			used[g[cur]] = true;
			q.push (g[cur]);
			d[g[cur]] = d[cur] + 1;
		}
	}

	cout << d[2]-1;
}

main () { fast_in;
    int t = 1; //cin >> t;
    while (t --) {
    	solve ();    
    }
	return 0;
}

Measured memory_bytes: 4536
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int isEmpty(int);
int isFull(int);
void push(int);
int pop(void);
 
int top;
int stack[100];
 
int main(){
  int x;
  char s[100];
  int d1, d2;
 
  //initialize
  top = 0;
 
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      d1 = pop();
      d2 = pop();
      push(d1 + d2);
    } else if ( s[0] == '-' ){
      d1 = pop();
      d2 = pop();
      push(d2 - d1);
    } else if ( s[0] == '*' ){
      d1 = pop();
      d2 = pop();
      push(d1 * d2);
    } else {
      x = atoi(s);
      push(x);
    }
  }
 
  printf("%d\n", stack[1]);
 
  return 0;
}
 
int isEmpty(int top){
  //isEmpty
  if(top == 0)return 1;
  //isn'tEmpty
  else return 0;
}
int isFull(int top){
  //isFull
  if(top == 100)return 1;
  //isn'tFull
  else return 0;
}
 
void push(int x){
  if(isFull(top) == 1)
    printf("Fullerror\n");
  top++;
  stack[top] = x;
//  printf("%d is push\n", x);
}
 
int pop(){
  if(isEmpty(top) == 1)
    printf("Emptyerror\n");
  top--;
//  printf("%d is pop\n", stack[top+1]);
  return stack[top+1];
}

Measured memory_bytes: 548
#include <iostream>
#include <cstdio>

using namespace std;

int main() {

	int n, m, l;
	cin >> n >> m >> l;

	int a[100][100] = {};

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}

	int b[100][100] = {};

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < l; j++) {
			cin >> b[i][j];
		}
	}

	long long int c[100][100] = {};

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++) {
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			if (j != l - 1) {
				printf("%lld ", c[i][j]);
			}
			else {
				printf("%lld\n", c[i][j]);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1312