akhauriyash/Code-Regression huggingface dataset:
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
#define     PI          3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342
 
 
int main()
{
	
	string s="abcdefghijklmnopqrstuvwxyz",t="";
	ll N,x;
	cin >> N;

	while(N>0)
	{
	    N--;
	    x = N%26;
		t += s[x];
		N /= 26;
	}
	reverse(t.begin(),t.end());
	cout << t << endl;	
    

    biday;
}
 
//...............BYE BYE................

Measured memory_bytes: 3620
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b) = get!(usize, usize);

    let ans = if a + b == 15 {
        "+"
    } else if a * b == 15 {
        "*"
    } else {
        "x"
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
N,K,Q = map(int,input().split())
A=[0]*Q
for i in range(Q):
    A[i]=int(input())

sanka=[0]*N
for i in range(Q):
    sanka[A[i]-1] +=1

for j in range(N):
    sanka[j]=sanka[j]+K-Q

for k in range(N):
    if sanka[k]>=1:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 11804
from collections import deque

q = int(input())
A = deque()

for i in range(q):
    query = str(input())
    if query[0] == "0": #push
        if query[2] == "0":
            A.appendleft(int(query[4:]))
        else:
            A.append(query[4:])
    elif query[0] == "1": #randamAccess
        print(A[int(query[2:])])
    else: #pop
        if query[2] == "0":
            A.popleft()
        else:
            A.pop()



Measured memory_bytes: 28204
N, X, Y = list(map(int, input().split()))
X -= 1
Y -= 1
val = [0] * (N-1)

for i in range(N-1):
    for j in range(i+1,N):
        val[min(j-i-1, abs(X-i)+abs(Y-j), abs(Y-i) +abs(j-X))] += 1
    

for v in val:
    print(v)


Measured memory_bytes: 3444
N,M=map(int,input().split())
ln=[-1 for _ in range(N)]
f=0
for i in range(M):
    s,c=map(int,input().split())
    if ln[s-1]!=-1 and ln[s-1]!=c:
        #print(i)
        f=-1
    elif N!=1 and s-1==0 and c==0:
        f=-1
    else:
        ln[s-1]=c

if f==-1:
    print(-1)
else:
    if N==1 and ln[0]==-1:
        ln[0]=0
    elif ln[0]==-1:
        ln[0]=1
    for i in range(1,N):
        if ln[i]==-1:
            ln[i]=0
    #print("".join(ln))
    print(int("".join(map(str,ln))))


Measured memory_bytes: 3064
using System.Linq;
class Program
{
    static void Main()
    {
        var raw = System.Console.ReadLine().Split().Select(int.Parse).ToArray();
        System.Console.WriteLine( (raw[0]==raw[1] && raw[1] == raw[2]) || (raw[0] != raw[1] && raw[1] != raw[2] && raw[0] != raw[2]) ? "No" : "Yes" );
    }
}


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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define trav(e, x) for (const auto &(e) : (x))
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define lc(i) 2*i
#define rc(i) 2*i+1
//#define int long long
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vii = vector<ii>;
using vivi = vector<vi>;

const int N = 2e5 + 5, MOD = 998244353, INF = 1e9 + 5;

int add(int x, int y) { return ((x % MOD) + (y % MOD)) % MOD; }

struct SegmentTree {
    int n;
    vector<int> a, t, lazy;

    void init(int x, vector<int> y) {
        n = x;
        a = y;
        t.assign(4 * n, 0);
        lazy.assign(4 * n, 0);
    }

    int merge(int x, int y) { return add(x, y); }

    int upd(int x, int y) { return add(x, y); }

    void build(int i, int l, int r) {
        if (l == r) {
            t[i] = a[l];
            return;
        }
        int mid = (l + r) / 2;
        build(lc(i), l, mid);
        build(rc(i), mid + 1, r);
        t[i] = merge(t[lc(i)], t[rc(i)]);
    }

    void push(int i, int l, int r) {
        if (lazy[i] != 0) {
            t[i] = upd(t[i], (lazy[i] * (r - l + 1)));
            if (l != r) {
                lazy[lc(i)] = upd(lazy[lc(i)], lazy[i]);
                lazy[rc(i)] = upd(lazy[rc(i)], lazy[i]);
            }
            lazy[i] = 0;
        }
    }

    void modify(int i, int l, int r, int ql, int qr, int val) {
        push(i, l, r);
        if (l > qr || r < ql) return;
        if (l >= ql && r <= qr) {
            lazy[i] = upd(lazy[i], val);
            push(i, l, r);
            return;
        }
        int mid = (l + r) / 2;
        modify(lc(i), l, mid, ql, qr, val);
        modify(rc(i), mid + 1, r, ql, qr, val);
        t[i] = merge(t[lc(i)], t[rc(i)]);
    }

    int query(int i, int l, int r, int ql, int qr) {
        push(i, l, r);
        if (l > qr || r < ql) return 0;
        if (l >= ql && r <= qr) return t[i];
        int mid = (l + r) / 2;
        int resL = query(lc(i), l, mid, ql, qr);
        int resR = query(rc(i), mid + 1, r, ql, qr);
        return merge(resL, resR);
    }

    void modify(int l, int r, int val) { modify(1, 0, n - 1, l, r, val); }

    void modify(int pos, int val) { modify(1, 0, n - 1, pos, pos, val); }

    int query(int l, int r) { return query(1, 0, n - 1, l, r); }

    int query(int pos) { return query(1, 0, n - 1, pos, pos); }
};

signed main() {
    FAST_IO;
//    setIO("input.txt", "output.txt");

    int n, m;
    cin >> n >> m;
    vii segs(m);
    for (int i = 0; i < m; i++) cin >> segs[i].first >> segs[i].second;
    SegmentTree seg;
    seg.init(n + 1, vi(n + 1, 0));
    seg.modify(1, 1);
    for (int i = 1; i <= n; i++) {
        int cur = seg.query(i);
        for (const auto &[l, r]: segs) {
            if (i + l > n) continue;
            seg.modify(i + l, min(i + r, n), cur);
        }
    }
    cout << seg.query(n);
}

Measured memory_bytes: 11136
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int n,m;
  cin >> n >> m;

  map<int,int> cnt;

  for(int i = 0;i < m;i++){
    int a,b;
    cin >> a >> b;
    cnt[a]++;
    cnt[b]++;
  } 

  bool flag = true;
  for(auto p:cnt){
    if(p.second % 2 == 1)flag = false;
  }

  if(flag)cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 4352
while True:
    n = int(input())
    if n == 0: break
    s = list(map(int, input().split()))
    a = 0
    for i in range(n):
        a += s[i]
    a /= n
    e = 0
    for i in range(n):
        e += (s[i] - a)**2
    e = (e / n)**0.5
    print(e)



Measured memory_bytes: 5672
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

int gcd(int a,int b){
	if(!(a % b)) return b;
	return gcd(b,a % b);
}

// lcm(a.b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	nongetpop(array,&(*size));
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[]){
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d\n", (a - 1) * (b - 1));
	return 0;
}


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

int main() {
  int K, S;
  cin >> K >> S;

  long count = 0;
  for(int i=0; i<=K; i++){
    int X = i;
    for(int j=0; j<=K; j++){
      int Y = j;
      int Z = S-X-Y;
      if(Z <= K && Z >= 0){
        count++;
      }
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
//#include<chrono>
//cout<<setprecision(12)
//fixed
//#include<random>
using namespace std;
typedef long long int llint;
typedef long double lldo;
const int big=1e9+100000;
const int mod=1e9+7;
const lldo eps=1e-9;
const long double pai=3.141592653589793238462643;
#define mt make_tuple
#define mp make_pair
#define fir first
#define sec second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define res resize
#define ins insert
#define era erase
#define dme(in) cout<<in<<endl;return 0
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	int i,j,n,r;cin>>n>>r;
	vector<pair<int,int>>mati(n);//x,y
	vector<int>toppo;//??¨??£??????
	int hi=0;//???(???)
	for(i=0;i<n;i++){
		cin>>mati[i].fir>>mati[i].sec;
		if(mati[i]<mati[hi]){hi=i;}
	}
	toppo.pub(hi);
	while(-1){
		int bas=toppo.back();
		int nex=-1;//????£?
		lldo neyx=-big;//??????y/x
		for(i=0;i<n;i++){
			if(bas==i){continue;}
			lldo dy=mati[i].sec-mati[bas].sec;
			lldo dx=mati[i].fir-mati[bas].fir;
			if(dx==0&&dy>0){nex=i;break;}
			if(dx<=0){continue;}
			if(neyx<dy/dx){nex=i;neyx=dy/dx;}
		}
		if(nex==-1){break;}
		toppo.pub(nex);
	}
	while(-1){
		int bas=toppo.back();
		int nex=-1;//????£?
		lldo neyx=-big;//??????y/x
		for(i=0;i<n;i++){
			if(bas==i){continue;}
			lldo dy=mati[i].sec-mati[bas].sec;
			lldo dx=mati[i].fir-mati[bas].fir;
			if(dx==0&&dy<0){nex=i;break;}
			if(dx>=0){continue;}
			if(neyx<dy/dx){nex=i;neyx=dy/dx;}
		}
		if(nex==-1){break;}
		toppo.pub(nex);
	}
	//??¨??£??????????±??????£??????
	lldo ans=0;
	vector<tuple<lldo,int,int>>road;
	for(i=0;i<r;i++){
		int s,t;cin>>s>>t;s--;t--;
		lldo dis=sqrt((mati[s].fir-mati[t].fir)*(mati[s].fir-mati[t].fir)+(mati[s].sec-mati[t].sec)*(mati[s].sec-mati[t].sec));
		road.pub(mt(dis,s,t));
	}
	for(i=0;i<toppo.size()-1;i++){
		int s=toppo[i];
		int t=toppo[i+1];
		lldo dis=sqrt((mati[s].fir-mati[t].fir)*(mati[s].fir-mati[t].fir)+(mati[s].sec-mati[t].sec)*(mati[s].sec-mati[t].sec));
		ans+=dis;
		road.pub(mt(0,s,t));
	}
	sort(road.begin(),road.end());
	vector<int>go(n);//union_find O(N)
	for(i=0;i<n;i++){go[i]=i;}
	for(i=0;i<road.size();i++){
		lldo dis=get<0>(road[i]);
		int a=get<1>(road[i]);
		int b=get<2>(road[i]);
		while(a!=go[a]){a=go[a];}
		while(b!=go[b]){b=go[b];}
		if(a==b){continue;}
		ans+=dis;
		go[a]=b;
	}
	cout<<setprecision(12)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3320
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	string str;
	bool flag[4] = {};
	cin >> str;
	for(int i = 0;i < str.size();i++){
		if(str[i] == 'N') flag[0] = true;
		else if(str[i] == 'S') flag[1] = true;
		else if(str[i] == 'W') flag[2] = true;
		else flag[3] = true;
	}

	if(flag[0] && flag[1] && !flag[2] && !flag[3]) cout << "Yes" << endl;
	else if(!flag[0] && !flag[1] && flag[2] && flag[3]) cout << "Yes" << endl;
	else if(flag[0] && flag[1] && flag[2] && flag[3]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int dp[413][413];
int main()
{
	long long int n,i,l,j,k;
	 long long int s; 
	cin>>n;
	long long int a[n+10];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	long long int sum[n+10]={0};
//	sum[0]=0;
	for(i=1;i<=n;i++)
	{
		sum[i]=sum[i-1]+a[i-1];
	}
	//long long int dp[n+10][n+10];
	
	unsigned long long int p=1000000000000000013;
	for(l=2;l<=n;l++)
	{
		for(i=1;i<=n-l+1;i++)
		{
			j=i+l-1;
			dp[i][j]=p;
			s=sum[j]-sum[i-1];
			for(k=i;k<j;k++)
			{
				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+s);
			}
		}
	}
	cout<<dp[1][n]<<endl;
}

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

int main(){
    int N;
    cin >> N;
    int d[N] = {};
    for(int i=0; i<N; i++){
        cin >> d[i];
    }
    int sum = 0, ans = 0;
    for(int i=0; i<N;i++){
        for(int j=i+1; j<N; j++){
            sum += d[j];
        }
        ans += d[i]*sum;
        sum = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
var
	N,i,j,ans:int64;
begin
	read(N);
	i:=1;
	while i<=N do begin
		j:=N div(N div i)+1;
		inc(ans,(j-i)*(i+j-1)*(N div i)*(N div i+1)div 4);
		i:=j;
	end;
	writeln(ans);
end.

Measured memory_bytes: 1380
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  ll A, B, K;
  cin >> A >> B >> K;
  ll a = min(A, K);
  A -= a;
  K -= a;
  ll b = min(B, K);
  B -= b;
  K -= b;
  cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 200005
#define MOD 1000000007
ll mx[4*MAXN];

class segTree
{
    public:
    
    void update(ll i,ll v,ll x,ll lx,ll rx)
    {
        if(lx == rx)
        {
            mx[x] = v;
            return;
        }
        
        ll mid = (lx + rx)/2;
        
        if(i <= mid)
            update(i,v,2*x + 1,lx,mid);
        else
            update(i,v,2*x + 2,mid + 1,rx);
        
        mx[x] = max(mx[2*x + 1],mx[2*x + 2]);
    }
    
    void update(ll i,ll v,ll N)
    {
        update(i,v,0,0,N - 1);
    }
    
    ll query(ll L,ll R,ll x,ll lx,ll rx)
    {
        if(rx < L || lx > R)
            return(0);
        
        if(lx >= L && rx <= R)
            return(mx[x]);
        
        ll mid = (lx + rx)/2;
        ll left = query(L,R,2*x + 1,lx,mid);
        ll right = query(L,R,2*x + 2,mid + 1,rx);
        
        return(max(left,right));
    }
    
    ll query(ll L,ll R,ll N)
    {
        return(query(L,R,0,0,N - 1));
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N; cin>>N;
    ll H[N],B[N];
    
    for(ll i=0;i<N;++i)
    {
        cin>>H[i]; 
        H[i]--;
    }
    
    for(ll i=0;i<N;++i)
        cin>>B[i];
    
    segTree st;
    
    for(ll i=0;i<N;++i)
    {
        ll val = st.query(0,H[i],N);
        st.update(H[i],val + B[i],N);
    }
    cout<<st.query(0,N - 1,N)<<endl;
}

Measured memory_bytes: 10880
#プログラミング日記   一寸先は闇が人生
# https://pyteyon.hatenablog.com/entry/2018/09/02/094228
# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N,K = map(int, input().split())

# 偶数、奇数共に
# a,b,c mod 0,0,0 ⇒Kの倍数
multip_K =[i for i in range(K,N+1,K)]

#multip_Kから３つ選び並べる順列組み合わせ
le =len(multip_K)
ans_mod_0 =le **3

# 偶数のみ
# a,b,c mod K/2,K/2,K/2 
ans_mod_haf =0
if K%2 ==0:
    multip_haf =[i for i in range(1,N+1) if i %K ==K//2 ]
    le_haf =len(multip_haf)
    ans_mod_haf =le_haf **3

ans =ans_mod_0 +ans_mod_haf
print(ans)

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

int w, h, x, y;

void hawawa()
{
	string str;
	cin >> str;
	if (str[0] == str[1] || str[1] == str[2] || str[2] == str[3]) {
		cout << "Bad\n";
	}
	else {
		cout << "Good\n";
	}
}


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


Measured memory_bytes: 256
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

char grid[1002][1002];

int solve(int n, int m)
{
    int dp[n+1][m+1];
    dp[n][m] = 1;
    for(int i = n; i >= 1; i--)
    {
        for(int j = m; j >= 1; j--)
        {
            if(i == n && j == m)
                continue;
            if(grid[i][j] == '#')
                dp[i][j] = 0;
            else dp[i][j] = (((i == n) ? 0 : dp[i+1][j]) + ((j == m) ? 0 : dp[i][j+1])) % mod;
        }
    }
    return dp[1][1];
}

int main() {
    int n,m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
            cin >> grid[i][j];
    }
    cout << solve(n,m);
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define int         long long
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
using namespace std;

signed main(){
    tezz   
    
    int n;
    cin >> n;
    if(n<=9){cout << 0 << endl;return 0;}
    if(n%2==1){
        // int c=0;
        // for(int i=1; i<50; i++){
        //     c+=(n/(int)pow(5,i));
        // }
        // int c1=c;
        // c=0;
        // for(int i=1; i<35; i++){
        //     c+=(n/(int)pow(5,i))/10;
        // }
        // c+=n/10;
        // cout << c1-c << endl;
        cout << 0 << endl;
        return 0;
    }
    int c=0;
    for(int i=1; i<35; i++){
        c+=(n/(int)pow(5,i))/10;
    }
    c+=n/10;
    cout << c << endl;
    
    return 0;
}   


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
typedef unsigned int UINT;
using namespace std;

bool tailtohead(string & front, string& ria) {
    if (front.back() == ria.front())
        return true;
    else
        return false;
}
int main(void) {
    string A, B, C;
    bool IsFail = false;
    cin >> A >> B >> C;
    if (!tailtohead(A, B)) {
        IsFail = true;
    }
    if (IsFail||
        !tailtohead(B, C))
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    return 0;

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	string n;
	cin >> n;
	cout << (n[0] == n[2] ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int M {100002};

int main() {
    int n, x, b[M] {0};
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> x;
        b[x]++;
        b[x+1]++;
        b[x+2]++;
    }
    cout << *max_element(b, b + M) << endl;

    return 0;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
for _ in range(Q):
  B.append(list(map(int, input().split())))


d = [0]*(10**5+1)
ans = 0
for i in range(N):
  d[A[i]] += 1
  ans += A[i]

for j in range(Q):
  ans = ans - d[B[j][0]]*B[j][0] + d[B[j][0]]*B[j][1]
  d[B[j][1]] += d[B[j][0]]
  d[B[j][0]] = 0
  print(ans)


Measured memory_bytes: 92548
#include<iostream>

using namespace std;

void Greatest_Common_Divisor(size_t x, size_t y){
  size_t r;
  size_t tmp;
   if(x<y){
     tmp = x;
     x= y;
     y = tmp;
   }
   r= x%y;
   while(r!=0){
  x = y;
  y = r;
  r= x % y ;
}

  cout<< y << endl;

}



int main(){
  size_t  x;
  size_t  y;

  cin>> x;
  cin >> y;

  Greatest_Common_Divisor(x,y);

  return 0;
}



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

int fact(int n)
{
    if(n==1)
    {
        return 1;
    }
    return n*fact(n-1);
}
int main()
{
    int n;
    cin>>n;
    cout<<(1+n)*n/2<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  int n123 = n / 10;
  int n234 = n % 1000;
  
  if (n123 % 111 == 0 || n234 % 111 == 0) { cout << "Yes" << endl; }
  else { cout << "No" << endl; }
}

Measured memory_bytes: 3636
let rec read u =
  try let (a, b, e, c, d, f) =
        Scanf.scanf "%d %d %d %d %d %d\n" (fun i1 i2 i3 i4 i5 i6 -> (i1, i2, i3, i4, i5, i6)) in
      let adbc = a * d - b * c and
          s = e * d - b * f and
          t = a * f - e * c in
      let x = (float s)/.(float adbc) and
          y = (float t)/.(float adbc) and
          f z = if z = -0.0 then 0.0 else z in
      Printf.printf "%.3f %.3f\n" (f x) (f y);
      read u
  with
    End_of_file -> ()
    in read ();;

Measured memory_bytes: 2380
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){

    bool tile[10][10];
    char ch;
    int h,w;
    int x=0,y=0;
    bool possi = true;

    cin >> h >> w;

    FOR(i,0,h){
        FOR(j,0,w){
            cin >> ch;
            if(ch == '.')tile[i][j] = false;
            else tile[i][j] = true;
        }
    }

    tile[0][0] = false;

    FOR(i,0,h+w-1){
        if(tile[x][y+1] == true && y+1 < w){
            tile[x][y+1] = false;
            y++;
        }else if(tile[x+1][y] == true){
            tile[x+1][y] = false;
            x++;
        }
    }

    FOR(i,0,h){
        FOR(j,0,w){
            if(tile[i][j] == true)possi = false;
        }
    }

    if(possi == true)cout << "Possible";
    else cout << "Impossible";

    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):

    return [il(t) for _ in range(N)]


def solve():
    N = ii()
    # 時刻ｔにx, yを訪れる
    # t+1 で (x+1, y), (x-1, y), (x, y+1), (x, y-1)に移動
    T = [0] * (N + 1)
    X = [0] * (N + 1)
    Y = [0] * (N + 1)
    for n in range(N):
        t = il()
        T[n + 1] = t[0]
        X[n + 1] = t[1]
        Y[n + 1] = t[2]
    for i in range(N):
        dt = T[i + 1] - T[i]
        dst = abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i])
        if dt < dst or dt % 2 != dst % 2:
            return "No"
    return "Yes"


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 11764
n,k=map(int,input().split())
p=list(map(int,input().split()))
for i in range(n):
    p[i] = (p[i]+1)/2
s = [0] *(n+1)
ma = 0
cnt = 0
for i in range(k):
    cnt += p[i]
ma =cnt
for i in range(n):
    if i+k >= n:
        break
    cnt += p[i+k]
    cnt -= p[i]
    ma = max(ma,cnt)
print(ma)

Measured memory_bytes: 71792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll d,g,p[11],c,s[11]={},ans=1e5,kari,ka,idx;
  cin>>d>>g;g/=100;
  Fr(i,d){cin>>p[i]>>c;c/=100;s[i]=i*p[i]+c;}
  fr(i,1<<d){
    kari=0;ka=0;
    fr(j,d){
      if((i>>j)&1){kari+=s[j+1];ka+=p[j+1];}
    }
    if(kari>=g){ans=min(ans,ka);continue;}
    fr(j,d) if(1-((i>>j)&1)) idx=j+1;
    if(kari+idx*p[idx]>=g) ans=min(ans,ka+1+(g-kari-1)/idx);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
d=[]
a=[]
for i in range(K):
    d.append(int(input()))
    a.append(list(map(int,input().split())))
    
aa=[0]*N
counts=0

#リストaの中からk番目のリストを取り出す（k自体もリスト）
for k in a:
    for j in k:
        aa[j-1]+=1
        
for x in aa:
    if x==0:
        counts+=1

print(counts)

Measured memory_bytes: 9140
n = int(input())
a_list = list(map(int,input().split()))
a_list_r = a_list[::-1]
ruisekiwa = [a_list_r[0]]
for i in range(1,n+1):
  ruisekiwa.append(ruisekiwa[-1] + a_list_r[i])
ruisekiwa = ruisekiwa[::-1]
max_leaf = a_list[-1]
count = 0
check = True
node = 0
for i in range(n):
  if i == 0:
    if  n == 0 and a_list[0] == 1:
      count = 1
      break
    elif a_list[0] != 0:
      check = False
      break
    else:
      count = 1
      node = 1
  else:
    cand = 2 * node
    if cand < a_list[i]:
      check = False
      break
    node = min(ruisekiwa[i+1],2*node - a_list[i])
    count += node + a_list[i]
if check == False:
  print(-1)
elif n == 0 and a_list[0] == 1 and len(a_list) == 1:
  print(1)
elif 2 * node < a_list[-1]:
  print(-1)
elif a_list[-1] == 0:
  print(-1)
else:
  print(count + a_list[-1])
  

      


Measured memory_bytes: 92628
#include<stdio.h>
int fibo(int);

int main(){
  int n;
  scanf("%d",&n);
  printf("%d\n",fibo(n));
  return 0;
}

int fibo(int i){
  int j;
  int f[]={1,1};
  for(j=1;j<=i;j++) f[j%2]+=f[(j+1)%2];
  return f[j%2];
}



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

int gcd( int x, int y )
{
  return ( y > 0 and x >= y )? gcd( y, x % y ) : x;
}

int main()
{
  int x, y;
  cin >> x >> y;
  if( y > x ) swap( x, y );
  cout << gcd( x, y ) << endl;
}




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

int a[32][100005]={0};
int b[32]={0};

int main(){
    int n, c;
    cin >> n >> c;
    int maxi = 0;
    for(int i=0;i<n;++i){
        int s, t, cc;
        cin >> s >> t >> cc;
        maxi = max(maxi, t);
        a[cc][s-1]++;
        a[cc][t]--;
    }
    for(int i=1;i<=c;++i){
        int cnt = 0;
        bool flag = false;
        for(int j=0;j<=maxi;++j){
            cnt += a[i][j];
            if(flag && cnt > 0){
                a[i][j] = 0;
            }else if(flag && cnt == 0){
                flag = false;
            }else if(!flag && cnt > 0)flag = true;
        }
    }
    int ans = 0;
    for(int i=0;i<=maxi;++i){
        int tmp = 0;
        for(int j=1;j<=c;++j){
            b[j] += a[j][i];
            tmp += b[j];
        }
        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const int mx = 710000;


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

ll a,b;
int main(){
	cin >> a >> b;
	ll g = gcd(a,b);
	ll ans = 1;
	// set<ll> ans = {1};
	for(int i = 2; i <= sqrt(g) + 1; i++){
		// if(g%i == 0)ans.insert(i);
		if(g%i == 0)ans++;
		while(g%i == 0){
			g /= i;
		}
	}
	if(g > 1)ans++;
	// cout << g << endl;
	// set<ll> ans = {1};
	// for(int i = 2; i< max_divisor + 1; i++){
	// 	while(max_divisor % i == 0){
	// 		ans.insert(i);
	// 		cout << i << endl;
	// 		max_divisor /= i;
	// 	}
	// 	cout <<  max_divisor << endl;
	// }
	cout << ans << endl;
}

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

using namespace std;

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

    int d[31][31];
    for(int i = 0; i < c; i++) {
        for(int j = 0; j < c; j++) {
            cin >> d[i][j];
        }
    }

    int e[501][501];

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

    int cost[3][51];

    for(int m = 0; m <= 3; m++) {
        for(int col = 0; col < c; col++) {
            cost[m][col] = 0;
            for(int i = 0; i < n; i++) {
                for(int j = 0; j < n; j++) {
                    if((i + j) % 3 != m) {
                        continue;
                    }

                    cost[m][col] += d[e[i][j]-1][col];
                }
            }
        }
    }

    int ans = 1 << 29;

    for(int i = 0; i < c; i++) {
        for(int j = 0; j < c; j++) {
            if(i == j) {
                continue;
            }
            for(int k = 0; k < c; k++) {
                if(i == k || j == k) {
                    continue;
                }

                ans = min(ans, cost[0][i] + cost[1][j] + cost[2][k]);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e4 + 10;
int n, Min, a[maxn], b[maxn], p[maxn];
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) a[i] = 1, b[i] = -1;
	for(int i = 1; i <= n; ++i) 
	{
		scanf("%d", &p[i]);
		a[p[i]] += i;
		b[p[i] + 1] -= i;
	}
	for(int i = 1; i <= n; ++i) 
	{
		a[i] += a[i - 1];
		printf("%d ", a[i]);
		b[i] += b[i - 1];
		Min = min(Min, b[i]);
	}
	puts("");
	--Min;
	for(int i = 1; i <= n; ++i)
	{
		b[i] -= Min;
		printf("%d ", b[i]);
	}
	return 0;
}
	 

Measured memory_bytes: 3996
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
#define PI 3.14159265359
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

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

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        int n;
        cin >> n;
        int a[n];
        loop(0, n) {
            cin >> a[i];
        }
        int x = a[0];
        loop(1, n) {
            x = x ^ a[i];
        }
        loop(0, n) {
            int temp = a[i] ^ x;
            cout << temp << " ";
        }
        cout << endl;
    }
    return 0;
}


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

int main(){
    long long A,B,V,W,T;
    cin >> A >> V >> B >> W >> T;
    if( (V-W)*T>=abs(B-A) ){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3636
function readInt(str){
  return parseInt(str, 10);
}
function solve(R,G,B,N){
  let count=0;
  for(let r=0;r<=N;r+=R)
    for(let g=0;r+g<=N;g+=G)
      {
        if((N-r-g)%B==0)count++;
      }
  return count;
}
function Main(raw: string) {
  const input = raw.split("\n");
  const [R,G,B,N] = input[0].split(" ").map(readInt);
  //出力
  console.log(solve(R,G,B,N));
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

using p = pair<int, int>;
int main() {
    init();

    int n, m; cin >> n >> m;
    vector<p> a(m); cin >> a;
    rSORT(a, [](p x, p y) { return x.second < y.second; });
    
    int ans = 0, k = 0;
    FOR(i, 0, m) {
        if (k < a[i].first) {
            k = a[i].second - 1;
            ++ans;
        }
    }

    cout << ans << "\n";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,c=0,i,j,k,l,r;
    cin>>n;
    long long int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=n-1;i>=1;i--)
    {
        l=0;
        r=i-1;
        while(l<r)
        {
            if(a[l]+a[r]>a[i]) {c+=r-l;
            r--;}
            else
             l++;
        }

    }
  cout<<c;
  return 0;
}


Measured memory_bytes: 256
import java.util.*


fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    var S: String
    S = sc.next()
    var T: String
    T = sc.next()
    solve(S, T)
}

fun solve(S: String, T: String) {
    var res = 0
    for (i in S.indices) {
        if (S[i] == T[i]) {
            res++
        }
    }
    println(res)
}



Measured memory_bytes: 31388
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
// #define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE
void solve(void)
{
  int X,Y;
  cin>>X>>Y;
  if(X%Y == 0)
  {
    cout<<-1<<endl;
  }
  else
  {
    cout<<X<<endl;
  }
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
w,h,n = map(int,input().split())

xl = 0
xr = w
yu = h
yd = 0

for i in range(n):
    xi,yi,ai = map(int,input().split())
    if ai == 2:
        xr = min(xr,xi)
    elif ai == 1:
        xl = max(xl,xi)
    elif ai == 4:
        yu = min(yu,yi)
    else:
        yd = max(yd,yi)

print(max(0,xr-xl)*max(0,yu-yd))



Measured memory_bytes: 38256
#include <stdio.h>

int fib(int n)
{
  int a, b, sum, i;

  a = 0;
  b = 1;
  sum = 1;

  for (i = 0; i < n; i++)
  {
    sum = a + b;
    a = b;
    b = sum;
  }

  return sum;
}

int main()
{
  int n;

  scanf("%d", &n);

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

  return 0;
}


Measured memory_bytes: 2140
import java.util.*;
 
public class Main {
    static int N;
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        int [] A = new int [N];
        for(int i=0; i<N; i++){
            A[sc.nextInt()]++;
        }
        long ans = cal(A);
        System.out.println(ans);
    }
    static boolean check(int [] A){
        if(N%2==0){
            for(int k=1; k<N; k+=2){
                if(A[k]!=2)return false;
            }
        }else{
            if(A[0]!=1)return false;
            for(int k=2; k<N; k+=2){
                if(A[k]!=2)return false;
            }
        }
        return true;
    }
    static long cal(int [] A){
        if(!check(A)){
            return 0;
        }else{
            return pow(2,N/2);
        }
    }
    static long pow(long a, long x){
        long mod = 1000000007;
        if(a==1||x==0)return 1;
        if(x%2==0){
            return pow(a*a%mod,x/2)%mod;
        }else{
            return a*pow(a,x-1)%mod;
        }
    }
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
string to_str(ll x){string res; while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return res;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
    int n; scanf("%d",&n);
    string s,t; cin>>s>>t;
    string ans;
    rep(i,0,n)ans+=s[i],ans+=t[i];
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
ll n,minv=(ll)1e9,temp;

int f(ll a, ll b){
    //cout<<a<<" "<<b<<endl;
    //cout<<floor(log10(a))<<" "<<floor(log10(b))<<endl;
    return max(floor(log10(a)),floor(log10(b)));
}

int main(void){
    cin>>n;
    for(int i=1;i<sqrt(n)+1;i++){
        if(n%i==0){
            temp=f(n/i, i); 
            if(temp < minv)minv=temp;
        }
    }
    cout<<temp+1<<endl;
}

Measured memory_bytes: 512
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ABC = []
for x in range(X):
    for y in range(Y):
        for z in range(Z):
            if (x+1)*(y+1)*(z+1) <= K:
                ABC.append(A[x]+B[y]+C[z])
            else:
                break

ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])

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

int N, m, k, toll[101], a, tot1=0, tot2=0;

int main () {
    cin >> N >> m >> k;
    for (int i=1; i<=m; i++) {
        cin >> a;
        toll[a]=1;
    }
    for(int i=1; i<=k; i++){
        tot1 += toll[i];
    }
    for(int i=k; i<=N; i++){
        tot2 += toll[i];
    }
    if (tot2<tot1){
        cout << tot2 << endl;
    }
    else {
        cout << tot1 << endl;
    }
}

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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll inf = 2e9+7;
const int MAX_N = 5e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[MAX_N],fac[MAX_N];

template <class T = int> T in(){T x;cin >> x;return (x);}
inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%inf;}a=a*a%inf;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<MAX_N;i++){fac[i]=fac[i-1]*i%inf;}for(int i=0;i<MAX_N;i++){inv[i]=POW(fac[i],inf-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%inf)*inv[n-r]%inf;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

class UnionFind {
private:
	int par[MAX_N];
	int rank[MAX_N];
public:
	void init(int n);
	int find(int x);
	void unite(int x,int y);
	bool same(int x,int y);
};

void UnionFind::init(int n) {
	for (int i = 0;i < n;i++) {
		par[i] = i;
		rank[i] = 0;
	}
}

int UnionFind::find(int x) {
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void UnionFind::unite(int x,int y) {
	x = find(x);
	y = find(y);
	if (rank[x] < rank[y]) par[x] = y;
	else {
		par[y] = x;
		if (rank[x] == rank[y]) rank[x]++;
	}
}

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

int main() {
	int a = in(),b = in(),c = in();
	cout << min(b/a,c) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x)	make_pair(x);
    
#define debug(x) 		cerr << #x << '=' << x << endl;
#define debug2(x, y)	cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (auto _x: _a) cerr << _x << ' '; cerr << endl;
#define debugm(a) 		cerr << #a << ":\n"; \
						for (auto v: a) { for(auto x: v) cout << x << ' '; cerr << "\n"; }
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long
 
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;
 
const int INF  = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 998244353;

const int N = 100009;

vi adj[N];

int32_t main()
{
	FAST_IO;
	
	int a, b;
	cin >> a >> b;
	
	if (a <= 9 && b <= 9) cout << a*b << endl;
	else cout << -1 << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


Measured memory_bytes: 2560