akhauriyash/Code-Regression huggingface dataset:
n = int(input())
p = [0,0] + list(map(int,input().split()))
x = [0] + list(map(int,input().split()))

child = [[] for _ in range(n+1)]
for i,pi in enumerate(p[2:],2):
    child[pi].append(i)

tp = []
stack = [1]
while(stack):
    i = stack.pop()
    tp.append(i)
    for ci in child[i]:
        stack.append(ci)

tp = tp[::-1]

cost = [[-1,-1] for _ in range(n+1)]
for i in tp:
    tot = 0
    mins = 0
    dif = []
    for ci in child[i]:
        a,b = cost[ci]
        if(a > b):
            a,b = b,a
        mins += a
        tot += a+b
        dif.append(b-a)

    if( mins > x[i]):
        print('IMPOSSIBLE')
        exit()

    dp = 1
    dp_max = (1<<(x[i] - mins+1)) - 1
    for di in dif:
        dp = (dp|(dp<<di))&dp_max

    max_dif = -1
    while(dp>0):
        dp//=2
        max_dif += 1

    a = x[i]
    b = tot - mins - max_dif
    cost[i] = [a,b]

print('POSSIBLE')

Measured memory_bytes: 73360
#include <stdio.h>
#define MAX 100005
#define NIL -1

struct Node {
    int parent, left, right;
};

struct Node Tree[MAX];
int n, Depth[MAX];

void print (int u) {
    int i, c;

    printf("node %d: parent = %d, depth = %d, ", u, Tree[u].parent, Depth[u]);
    if ( Tree[u].parent == NIL) printf("root, ");
    else if ( Tree[u].left == NIL) printf("leaf, ");
    else printf ("internal node, ");
    printf("[");
    for ( i = 0, c = Tree[u].left; c != NIL; i++, c = Tree[c].right) {
        if (i) printf(", ");
        printf("%d",c);
    }
    printf("]\n");
}


void setDepth
 (int u, int p) {
    Depth[u] = p;
    if ( Tree[u].right != NIL) setDepth(Tree[u].right, p); //右の兄弟に同じ深さを設定
    if ( Tree[u].left != NIL) setDepth(Tree[u].left, p+1); //最も左の子に自分の深さ+1を設定
}

int main () {
    int i, j, id, id_k, c, l, r;
    scanf("%d",&n);
    for ( i = 0; i < n; i++) Tree[i].parent = Tree[i].left = Tree[i].right = NIL;

    for ( i = 0; i < n; i++) {
        scanf("%d%d",&id,&id_k);
        for ( j = 0; j < id_k; j++) {
            scanf("%d",&c);
            if ( j == 0) Tree[id].left = c;
            else Tree[l].right = c;
            l = c;
            Tree[c].parent = id;
        }
    }

    for ( i = 0; i < n; i++) {
        if (Tree[i].parent == NIL) r = i;
    }

    setDepth(r, 0);

    for ( i = 0; i < n; i++) print(i);

    return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll X;
  cin >> X;

  int cnt_500 = X / 500;

  X = X - cnt_500 * 500;

  int cnt_5 = X / 5;

  cout << cnt_500*1000 + cnt_5*5 << endl;


  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env pypy3


def solve(k, bs):
    if k > max(bs):
        return False
    cs = set(bs)
    for b in cs:
        if abs(b - k) == 0 or abs(b - k) in cs:
            return True
    return False


def main():
    _, k = [int(x) for x in input().split()]
    bs = [int(x) for x in input().split()]
    print("POSSIBLE" if solve(k, bs) else "IMPOSSIBLE")


if __name__ == '__main__':
    main()


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

int main(){
    int K,i,A,B,pre;
    cin >> K >> A >> B;
    pre = A;
    for(i=A;i<=B;i++){
        if(pre % K == 0){
            cout << "OK" << endl;
            break;
        }else{
            pre++;
        }
        }
        if(pre == B+1){
            cout << "NG" << endl;
        }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

struct Dijkstra{
  int n,done;
  vector<vector<pair<int,int> > > edge; //cost,to
  vector<int> distance;
  vector<bool> visited;
  vector<int> prev;
  vector<int> cnt;

  void init(int v){
    n=v;
    edge.resize(n);
    distance.resize(n);
    visited.resize(n);
    prev.resize(n);
    cnt.resize(n,0);
  }

  void input(int from,int to,int cost){
    edge[from].push_back({cost,to});
  }

  void calc(int start){
    int i;
    for(i=0;i<n;i++){
      distance[i]=INT_MAX;
      visited[i]=0;
      prev[i]=-1;
    }
    distance[start]=0;
    done=0;

    priority_queue<pair<int,int> > q; //cost,to
    int from,to,tmp;
    q.push({0,start});

    while(!q.empty()){
      from=q.top().second;
      if(visited[from]){
        q.pop();
        continue;
      }
      visited[from]=1;
      done++;
      if(done==n){
        break;
      }
      q.pop();
      for(i=0;i<edge[from].size();i++){
        to=edge[from][i].second;
        tmp=distance[from]+edge[from][i].first;
        if(distance[to]>tmp){
          distance[to]=tmp;
          prev[to]=from;
          q.push({tmp*-1,to}); //greater
        }
      }
    }

    for(i=0;i<n;i++){
      ++cnt[distance[i]];
    }
  }

  void solve(){
    int i;
    for(i=0;i<n;i++){
      calc(i);
    }
  }

  void out(){
    int i;
    for(i=1;i<n;i++){
      printf("%d\n",cnt[i]/2);
    }
  }
};

int main(void){

  int n, x, y, i;
  cin >> n >> x >> y;

  Dijkstra G;
  G.init(n);

  for(i=0;i<n-1;i++){
    G.input(i,i+1,1);
    G.input(i+1,i,1);
  }
  G.input(x-1,y-1,1);
  G.input(y-1,x-1,1);

  G.solve();

  G.out();

  return 0;
}


Measured memory_bytes: 384
from collections import deque


def bucket_sort_deque(a):
    # Dequeは高速な双方向リスト，Pythonでリストを使うときにはDeque
    m = 10**5
    b = [deque() for _ in range(m)]
    for i in a:
        b[i].append(i)
    i = 0
    for d in b:
        while len(d) != 0:
            a[i] = d.pop()
            i += 1
n = int(input())
l = list(map(int,input().split()))
bucket_sort_deque(l)
for i in l[:n-1]:
    print(i,end = ' ')
print(l[-1])


Measured memory_bytes: 231672
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io
	
	string x;
	cin>>x;
	ll res=0;
	rep(i,0,x.length())
	{
		ll zz=x[i]-'0';
		res+=zz;
		res%=9;
	}
	cout<<((!res)?"Yes":"No");
}

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

using namespace std;


int main(){

	long long int n,inf=10000000000000000;

	cin >> n;
	vector<int>v(n+10,inf),p(n+10);
	v[0]=0;

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

	for(int i=0;i<n;i++){
		v[i+1] = min(v[i+1], v[i] + abs(p[i] - p[i+1]) );
		v[i+2] = min(v[i+2], v[i] + abs(p[i] - p[i+2]) );
	}

	cout << v[n-1] << endl;
	
	return 0;		
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int X;
    cin >> X;
    int A = 0;

    for (int i = 1; i < 100000; i++) {
        A += i;
        if (A >= X){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<vector>
typedef long long ll;
using namespace std;

int main(void){
  int n;
  cin>>n;
  vector<ll>a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i&1)b[0]-=a[i];
    else b[0]+=a[i];
}
  b[0]/=2;
  for(int i=1;i<n;i++){
    b[i]=a[i-1]-b[i-1];
  }
  for(int i=0;i<n;i++){
    cout<<2*b[i]<<" ";
  }
  cout<<endl;
}


Measured memory_bytes: 2944
#include<stdio.h>

int main(){

  int a,b,c;

  scanf("%d %d %d",&a,&b,&c);
  if(a < b && b < c){
    printf("Yes\n");
  }
  else if(a > b || b > c || a > c || a == b || b == c || a == c){
    printf("No\n");
  }

    return 0;
}

Measured memory_bytes: 580
S = input()
N = len(S)
A = int((N - 1) / 2)
if A % 2 == 0:
  B = int(A / 2)
else:
  B = int((A - 1) / 2)
X = 0
 
for i in range(A):
  if S[i] != S[-i-1]:
    X += 1
 
if N >= 5:
  for i in range(B):
  	if S[i] != S[A-1-i]:
  	    X += 1
      
if X == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int q = sc.nextInt();
    
    int[] a = new int[n];
    
    for(int i = 0 ; i < a.length ; ++i){
      a[i] = k;
    }
   
    while(sc.hasNext()){
      int number = sc.nextInt();
      int next = number - 1;
      a[next] += 1; 
    }
    
    
    
    for(int i = 0 ; i < a.length ; ++i){
      a[i] = a[i] - q;
      if(a[i] > 0){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    } 
  }
}

Measured memory_bytes: 59532
////////////////////////////////////////////    _LeMur_
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n;
int a[N];
map <int,int> mp;
map <int,int>::iterator it;

bool check(vector <int> g){
    if(g[0] == (g[1] ^ g[2]))return true;
    if(g[1] == (g[0] ^ g[2]))return true;
    if(g[2] == (g[0] ^ g[1]))return true;
    return false;
}

int main(){
	mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        mp[ a[i] ]++;
    }
    if((int)mp.size() == 1){
        if(mp.find(0) != mp.end())
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
        return 0;
    }
    if((int)mp.size() > 3){
        cout << "No" << endl;
        return 0;
    }
    if((int)mp.size() == 3){
        set <int> q;
        vector <int> g;
        for(it = mp.begin(); it != mp.end(); ++it){
            g.push_back((*it).first);
            q.insert((*it).second);
        }
        if((int)q.size() == 1 && check(g))
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
        return 0;
    }
    if(mp.find(0) == mp.end()){
        cout << "No" << endl;
        return 0;
    }
    int x;
    for(it = mp.begin(); it != mp.end(); ++it){
        if((*it).first != 0){
            x = (*it).first;
        }
    }
    if(mp[x] == 2 * mp[0])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
string s;
cin>>s;
bool flag=true;
for(int i=0;i<3;i++){
    if(s.at(i)==s.at(i+1)){
        flag=false;
    }
}
if(flag){
    cout<<"Good"<<endl;
}
else{
    cout<<"Bad"<<endl;
}
}









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

int main(){
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    int dmax = K - A.at(N-1) + A.at(0);
    for (int i = 0; i < N-1; i++){
        dmax = max(A.at(i+1) - A.at(i), dmax);
    }
    cout << K - dmax << endl; 
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ll  long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define MAX_N 100000
using namespace std;
// int dx[4] = {1,-1,0,0};
// int dy[4] = {0,0,1,-1};

double solve(vector<double>&arr, int n,int x,vector<vector<double>>&dp){
    if(x==0)
        return 1;
    if(n==0)
        return 0;

    if(dp[n][x]>-0.9)
        return dp[n][x];

    // db(n);
    // db1(x);

    return dp[n][x] = arr[n-1]*solve(arr,n-1,x-1,dp)+(1-arr[n-1])*solve(arr,n-1,x,dp);
}

void solve(){

    ll n;
    cin>>n;

    vector<double>arr(n);
    rep(i,n)
    cin>>arr[i];

    vector<vector<double>>dp(n+1,vector<double>((n+1)/2+1,-1));

    cout<<fixed<<setprecision(10)<<solve(arr,n,(n+1)/2,dp)<<endl;
}
int main(){ 

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





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

using namespace std;

class Disjointset {

private:
	vector<int> p, rank;

	void makeset(int x) {
		p[x] = x;
		rank[x] = 0;
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		} else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				++rank[y];
			}
		}
	}

public:
	Disjointset(int size) {
		p.resize(size, 0);
		rank.resize(size, 0);
		for (int i = 0; i < size; ++i)
			makeset(i);
	}

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

	int findSet(int x) {
		if (p[x] != x) {
			p[x] = findSet(p[x]);
		}
		return p[x];
	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

};

int main() {

	int n, q;
	scanf("%d %d", &n, &q);

	Disjointset disjointset(n);

	for (int i = 0; i < q; ++i) {
		int com, x, y;
		scanf("%d %d %d", &com, &x, &y);

		if (com == 0) {
			disjointset.unite(x, y);
		} else {
			if (disjointset.same(x, y)) {
				cout << 1 << endl;
			} else {
				cout << 0 << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3284
function main() {
  var
  i, j, n, m, x,
  len = input.length;
  for(i = 0; i < len; i++) {
    n = parseInt(input[i], 10);
    if(n === 0) break;
    m = ~~(n / 2);
    for(x = 0, j = 0; primes[j] <= m; j++) {
      if(primesTable[n - primes[j]]) x++;
    }
    console.log(x);
  }
}

var
primes = (function(n){
  var
  i, j, flag,
  primes = [2];
  if(n < 2) return [];
  for(i = 3;i <= n; i += 2) {
    flag = true;
    for(j = 0; primes[j] < i*i; j++) {
      if(i % primes[j] == 0) {
        flag = false;
        break;
      }
    }
    if(flag) {
      primes.push(i);
    }
  }
  return primes;
})(50000),
primesTable = primes.reduce(function(m, a) {
  m[a] = true;
  return m;
}, {});

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 14088
//Bismillah_hir_rahmanir_rahim


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



int main()
{
   int n , t , a , b ;

   vector< int > vec ;
   
   cin >> n >> t ;
   vec.clear() ;
   for(int i = 0 ;i<n ; ++i)
   {
       cin >> a >>  b; 
       if(b<=t)
       {
           vec.push_back(a);
       }
   }
   sort(vec.begin(),vec.end());
   if(vec.size()==0)
    cout<<"TLE"<<endl;
   else
    cout<< vec.front() <<endl;
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
#define mod 1000000007
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}
bool vis[200005];
vector<int> vec[100005];
int child[100005];
int div1[100005];
void dfs(int node)
{
    vis[node] = 1;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            child[node] += child[vec[node][i]];
        }
    }
}
void belman(int n, int m, vector<pair<int, pair<int, int>>> vec, int dis[])
{
    for (int i = 0; i <= n + m - 1; i++)
    {
        for (int j = 0; j < vec.size(); j++)
        {
            int u = vec[j].second.first;
            int v = vec[j].second.second;
            int w = vec[j].first;

            if (dis[u] + w < dis[v])
            {
                dis[v] = dis[u] + w;
            }
        }
    }
}
int fun(int a, int b)
{
    if (a > b)
        return 0;
    if (a == b)
        return 1;
    else
    {
        return fun(a + 1, b) + fun(a, b - a);
    }
}
int32_t main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    int j = 1;
    for (int i = 2; i < 1001; i++)
    {
        if (!vis[i * j])
        {
            while (i * j < 1001)
            {
                div1[i * j] = i;
                vis[i * j] = 1;
                j++;
            }
        }
        j = 1;
    }
    div1[1] = 1;
    // for (int i = 1; i < 20; i++)
    //   cout << div1[i] << "\n";
    int n;
    cin >> n;
    map<int, int> mp;
    int ans = 1;
    for (int i = 2; i <= n; i++)
    {
        vector<int> vec;
        int p = i;
        while (p != 1)
        {
            vec.push_back(div1[p]);
            p /= div1[p];
        }
        for (auto itr : vec)
            mp[itr]++;
    }
    for (auto itr : mp)
    {
        ans = (ans * (itr.second + 1)) % mod;
    }
    cout << ans << "\n";
    return 0;
}


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

int main() {
    //
    long long num, c, k;
    long long cntBus = 0;

    cin >> num >> c >> k;

    vector<long long> vec(num);
    for (int i = 0; i < num; i++) { cin >> vec.at(i); }

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

    long long cnt = 0, genkaiTi;
    for (int i = 0; i < num;) {
        cntBus++;
        cnt = i;
        genkaiTi = vec.at(i) + k;

        while (i < num && vec.at(i) <= genkaiTi && i - cnt < c) {
            i++;
        }
    }

    cout << cntBus;
}

Measured memory_bytes: 4032
import heapq
import sys
input = sys.stdin.readline

N, M, S, T = map(int, input().split())

import heapq


class Edge():
    """ 重み付き有向辺 """

    def __init__(self, _to, _cost):
        self.to = _to
        self.cost = _cost


class Dijkstra():
    def __init__(self, V):

        self.G = [[] for i in range(V+1)]
        self._E = 0
        self._V = V

    def add(self, _from, _to, _cost):
        """ 2頂点と、辺のコストを追加"""
        self.G[_from].append(Edge(_to, _cost))
        self._E += 1

    def shortest_path(self, s):
        """ 始点sから頂点iまでの最短路リスト 
        """
        que = []
        heapq.heapify(que)
        d = [float("inf")] * (self._V+1)
        d[s] = 0
        heapq.heappush(que, (0, s))  

        while len(que) != 0:
            cost, v = heapq.heappop(que)
            if d[v] < cost:
                continue

            for i in range(len(self.G[v])):
                e = self.G[v][i]  # vのi個目の隣接辺e
                if d[e.to] > d[v] + e.cost:
                    d[e.to] = d[v] + e.cost
                    heapq.heappush(que, (d[e.to], e.to))
        return d
graph_snuke = Dijkstra(N)
graph_yen = Dijkstra(N)
for _ in range(M):
    u, v, a, b = map(int, input().split())
    graph_yen.add(u, v, a)
    graph_yen.add(v, u, a)
    graph_snuke.add(u, v, b)
    graph_snuke.add(v, u, b)

yen = graph_yen.shortest_path(S)
snuke = graph_snuke.shortest_path(T)
minimum_case = [10**15 for i in range(N+1)]
for i in range(N):
    minimum_case[1+i] -= (yen[i+1]+snuke[i+1])
for i in range(N-1, -1, -1):
    minimum_case[i] = max(minimum_case[i], minimum_case[i+1])
for i in range(1, N+1):
    print(minimum_case[i])

Measured memory_bytes: 152568
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n = input_n
a = input_a
b = Array.new(n)
a.each_with_index do |num, i|
  b[num - 1] = i + 1
end
puts b.join(" ")


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

char N[55][55],M[55][55];
int n,m;

bool isSame(int startX, int startY)
{
	for(int k=1;k<=m;k++)
		for(int l=1;l<=m;l++)
			if(N[startX+k-1][startY+l-1]!=M[k][l])
				return false;

	return true;
} 

int main()
{   
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>N[i][j];
	for(int i=1;i<=m;i++)
		for(int j=1;j<=m;j++)
			cin>>M[i][j];

	for(int i=1;i<=n-m+1;i++)
		for(int j=1;j<=n-m+1;j++)
			if(isSame(i,j))
			{
				printf("Yes\n");
				return 0;
			}


	printf("No\n");
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    
    if(S.at(0) != S.at(1) ||S.at(1) != S.at(2)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

int n, a, b, c, d, e;

int32_t main() {

    cin >> n >> a >> b >> c >> d >> e;

    int slowest = min(a, min(b, min(c, min(d, e))));

    int groups = (n+slowest-1)/slowest;

    int ans = 4 + groups;

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


Measured memory_bytes: 256
/*input
4 5 10
2 5 12
1 5 12
2 3 15
1 2 20
1 1 28
2 4 26
3 2 27
4 5 21
3 5 10
1 3 10
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=3e3+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    ll res=0LL;
    while(b){
        if(b&1) res=(res+a)%MOD;
        a=(a+a)%MOD;
        b>>=1;
    }
    return res%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn][maxn];
ll dp[maxn][maxn][4];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int r,c,n;
    cin>>r>>c>>n;
    REP(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        arr[a][b]=c;
    }
    REP1(i,r){
        REP1(j,c){
            REP(k,4){
                dp[i][j][k]=max(dp[i-1][j][k],dp[i][j-1][k]);
                if(k==0){
                    REP(z,4) MXTO(dp[i][j][k],dp[i-1][j][z]);
                }
                else if(k==1){
                    MXTO(dp[i][j][k],dp[i][j-1][k-1]+arr[i][j]);
                    REP(z,4) MXTO(dp[i][j][k],dp[i-1][j][z]+arr[i][j]);
                }
                else{
                    MXTO(dp[i][j][k],dp[i][j-1][k-1]+arr[i][j]);
                }
            }
        }
    }
    ll ans=0;
    REP(z,4) MXTO(ans,dp[r][c][z]);
    cout<<ans<<'\n';
}



Measured memory_bytes: 320284
H, W, K = gets.split.map(&:to_i)
ary = []
H.times do
    ary << gets.chomp.split('')
end
ret = 0
[0, 1].repeated_permutation(H).each do |h|
    [0, 1].repeated_permutation(W).each do |w|
        cnt = 0
        h.each_with_index do |n, i|
            w.each_with_index do |m, j|
                next if n == 0 || m == 0
                cnt += 1 if ary[i][j] == '#'
            end
        end
        ret += 1 if cnt == K
    end
end
puts ret

Measured memory_bytes: 14336
#define _USE_MATH_DEFINES
  #include <set>
  #include <array>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <stack>
  #include <queue>
  #include <vector>
  #include <tuple>
  #include <string>
  #include <math.h>
  #include <time.h>
  #include <bitset>
  #include <stdio.h>
  #include <string.h>
  #include <iostream>
  #include <algorithm>
  #include <limits>
  #include <climits>
  #include <numeric>
  #include <functional>
  #include <iomanip>
  #include <cmath>

  #define lnd '\n'
  // #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
  #define from(i, n) for (ll i = 0; i < n; ++i)
  #define loop(i, n) for(ll i = 0; i < n; i++)
  #define REPN(i, n) for (ll i = 1; i <= n; ++i)
  #define ALL(s) (s).begin(), (s).end()
  #define rALL(s) (s).rbegin(), (s).rend()
  #define sz(s) (int)(s).size()
  #define mk make_pair
  #define pb push_back
  #define sqr(s) ((s) * (s))

  using namespace std;

  typedef long long ll;
  typedef long long int lli;
  typedef long double ld;
  typedef unsigned long long ull;
  typedef unsigned int ui;

  template <class T>
  T GCD (T a, T b) {
    if(a == 0) return b;
    return GCD(b%a, a);
  }

  template <class T>
  T LCM(T a, T b){
    return a*b/GCM(a,b);
  }

  template <class T>
  T modpow(T x, T p){
      T res = 1;
      while(p > 0){
          if(p&1) res *= x;
          x *= x;
          p /= 2;
      }
      return res;
  }

  template <class T>
  T modpow(T x, T p, ll mod){
      T res = 1;
      while(p > 0){
          if(p&1) res = (res*x)%mod;
          x = (x*x)%mod;
          p /= 2;
      }
      return res%mod;
  }

  template <class T>
  void print(T a[], ll n){
      for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
      cout << endl;
  }

  template<class T>
  void printc(T c){
      for(auto const& v: c) std::cout << v << ' ';
      cout << endl;
  }

  struct HASH{
    size_t operator()(const pair<long,long>&x)const{
      return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
    }
  };

  bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
      if(p1.first != p2.first) return p1.first < p2.first;
      else return p1.second < p2.second;
  }

  const int INF = std::numeric_limits<int>::max();
  const ll M_INF = std::numeric_limits<ll>::min();
  const ll LL_INF = std::numeric_limits<ll>::max();

  void solution();
  int main(){
      ios_base::sync_with_stdio(0);
      cin.tie(0);
      cout.tie(0);
      solution();
      return 0;
  }

  void solution(){
    ll n;
    cin >> n;
    ll ans = 0;
    ll last = sqrt(n);
    for(ll i = 2; i <= last; i++){
      if(n%i) continue;
      ll count = 0;
      while(n%i == 0){
        n = n/i;
        count++;
      }

      ll index = 1;
      while(count >= index){
        ans++;
        count -= index;
        index++;
      }
    }
    if(n>1) ans++;

    cout << ans << endl;
  }    
    




Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli mod=1000000007;

int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}


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

using ll = long long;
using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(false)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;

ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return (a == 0 || b == 0) ? 0 : (a / __gcd(a, b) * b); }

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;

	ll sum = 0;
	vector<ll> p(n);
	rep(i, n) {
		cin >> p[i];
		if(p[i] != i + 1) ++sum;
	}

	YN(sum == 2 || sum == 0);

	return 0;
}


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

int main(void)
{
    int a, b, h, m;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &h);
    scanf("%d", &m);

    //r.theta座標変換

    long double theta_a, theta_b, theta_diff;

    theta_a = (double)h * 2.f * M_PI / 12.f + (double)m * 2.f * M_PI / 60.f / 12.f;
    theta_b = (double)m * 2.f * M_PI / 60.f;

    theta_diff = fabs(theta_a - theta_b);

    double d;

    d = a * a + b * b - 2 * a * b * cos(theta_diff);
    d = sqrt(d);

    printf("%.20f", d);

    return 0;
}

Measured memory_bytes: 4184
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,s,dp[12][331][1030];
int solve(int now,int sum,int a){
	int ans=0;
	if(dp[now][sum][a]!=-1)
		return dp[now][sum][a];
	if(sum>s)
		return dp[now][sum][a]=0; 
	if(now==n+1){
		if(sum==s)
		return dp[now][sum][a]=1;
	}
	now++;
	for(int i=0;i<10;i++){
		if(!((a>>i)&1))
		ans+=solve(now,sum+i*(now-1),a|(1<<i));
	}
	return dp[now-1][sum][a]=ans;
}
int main(){
	while(cin>>n>>s){
		int a[10];
		for(int i=0;i<12;i++)
			for(int j=0;j<331;j++)
				for(int k=0;k<1030;k++)
				dp[i][j][k]=-1;
		//now sum
		cout<<solve(1,0,0)<<endl;
	}
	return 0;
}

Measured memory_bytes: 16000
N,K,Q=map(int,input().split())
lst=[]
for i in range(Q):
  lst.append(int(input()))
Score=[0]*N
for i in range(Q):
  Score[lst[i]-1]+=1
  
for i in range(N):
  if Score[i]>Q-K:
    print('Yes')
  else:
    print('No')

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

using namespace std;

class range {
private:
  struct Iterator {
    int val;
    int operator*() {return val;}
    bool operator!=(Iterator &itr) {return val < itr.val;}
    void operator++() {++val;}
  };
  Iterator i, n;
public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator &begin() {return i;}
  Iterator &end() {return n;}
};

template<class T> T at(vector<T> v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

long long mod_inverse(long long a, long long mod) {
  long long b = mod, x = 1, y = 0;
  while (b) {
    long long t = a / b;
    swap(a -= t * b, b);
    swap(x -= t * y, y);
  }
  return (mod + x % mod) % mod;
}

pair<long long, long long> linear_congruence(const vector<long long>& A, const vector<long long>& B, const vector<long long>& M) {
  long long x = 0, m = 1;
  for (int i : range(A.size())) {
    long long a = A[i] * m;
    long long b = B[i] - A[i] * x;
    long long d = __gcd(M[i], a);
    if (b % d != 0) return make_pair(0, -1);
    int t = b / d * mod_inverse(a / d, M[i] / d) % (M[i] / d);
    x = x + m * t;
    m *= M[i] / d;
  }
  return make_pair(x % m, m);
}

const long long INF = 1e9;

int main() {
  int n, m, d;
  cin >> n >> m >> d;
  long long a[m];
  for (int i : range(m)) cin >> a[i];
  long long r[d][m];
  for (int i : range(d)) for (int j : range(m)) cin >> r[i][j];
  vector<long long> A, B, M;
  for (int i : range(d)) {
    A.clear(); B.clear(); M.clear();
    for (int j : range(m)) if (r[i][j] != -1) {
      A.emplace_back(1);
      B.emplace_back(r[i][j]);
      M.emplace_back(a[j]);
    }
    if (A.empty()) continue;
    auto x = linear_congruence(A, B, M);
    if (x.second == -1) {
      cout << -1 << endl;
      return 0;
    }
    while (x.first + x.second <= n) x.first += x.second;
    if (x.first > n) {
      cout << -1 << endl;
      return 0;
    }
    n = x.first;
  }
  cout << n << endl;
}

Measured memory_bytes: 1228
//Author- VMAX


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
        
    }
}
  */
  long long lcm(long long a, long long b){//最小公倍数を求める
   return a * b / gcd(a, b);
}
       int main()
       
       {
        fast
        
        
        ll n;cin>>n;
        vector<pair<ll,ll>>v(n);
        ll i,x,y;
        f(i,n)
        {
            cin>>x>>y;
            v[i]=mp(y,x);
        }
        
        sort(all(v));
        
        ll f=1,s=0;
        f(i,n)
        {
            s+=v[i].S;
            if(s>v[i].F)
            {
                f=0;
                break;
            }
        
        }
        
        if(f==0)
        {
            No
            re
        }
        Yes
        
        
 
          re
}


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

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


signed main(){

	int N, W;
	int w[101], v[101];

	cin >> N >> W;
	for (int i = 0; i<N; i++)
		cin >> w[i] >> v[i];

	int dp[101][101*1001+1];
	fill(dp[0], dp[0] + 101 * 1001 + 1, INF);

	dp[0][0] = 0;
	for (int i = 0; i <N; i++){
		for (int j = 0; j <= N*1001; j++){
			if (j < v[i]){
				dp[i+1][j] = dp[i][j];
			}
			else{
				dp[i+1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
			}
		}
	}

	int ret = 0;
	for (int i = 0; i < N * 1001; i++)
		if (dp[N][i] <= W) ret = i;

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 80000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int N = 0;
		Scanner sc = new Scanner(System.in);
		N = Integer.parseInt(sc.next());
		int i;
		long[] A = new long[N];
		long[] ls = new long[N + 1];
		long[] rs = new long[N + 1];

		long max = 0;
		long gcd = 0;
		for (i = 0; i < N; i++) {
			A[i] = Integer.parseInt(sc.next());
		}
		int j;
		for (i = 0; i < N; i++) {
			j = (N - 1) - i;
			ls[i + 1] = gcd(ls[i], A[i]);
			rs[j] = gcd(rs[j + 1], A[j]);
		}
		for (i = 0; i < N; i++) {
			gcd = gcd(ls[i], rs[i + 1]);
			if (max < gcd) {
				max = gcd;
			}
		}
		System.out.println(max);
	}

	private static long gcd(long m, long n) {
		if (m < n)
			return gcd(n, m);
		if (n == 0)
			return m;
		return gcd(n, m % n);
	}

}

Measured memory_bytes: 47660
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int intpow(int a, int n) {
	// a^nのint ver
	rep(i, n-1)
		a *= a;
	return a;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1))%mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	//約数の数（だっけ？）
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	//1桁目切り上げ
	return (n + 9) / 10 * 10;
}
int DIGIT(int n,int k) {
	//nのk桁目
	rep(i, k-1)
		n /= 10;
	return n % 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	//nをkで何回割れるか的な
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool between(int x, int min, int max) {
	if (min < x && x < max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	int X, Y;
	cin >> X >> Y;
	if (X%Y!=0)
		cout << X << endl;
	else
		cout << -1 << endl;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Cryptography;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var h = int.Parse(spl[0]);
        var w = int.Parse(spl[1]);
        var a = int.Parse(spl[2]);
        var b = int.Parse(spl[3]);

        if(a > w/2) return No;
        if(b > h/2) return No;

        var tbl = new int[h][];
        for(int i=0; i<h; i++) tbl[i] = new int[w];

        for(int i=0; i<h; i++) {
            for(int j=0; j<w; j++) {
                if(i < b && j < a) tbl[i][j] = 1;
                if(i >= b && j >= a) tbl[i][j] = 1;
            }
        }

        var sb = new StringBuilder();
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                sb.Append(tbl[i][j]);
            }
            sb.AppendLine();
        }

        return sb;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 29384
#include <iostream>
using namespace std;
long long n, p, a, s=1, c[2];
int main() {
	cin>>n>>p;
	while(n--) cin>>a, c[a%2]=1, s<<=1;
	cout<<(c[1] ? s/2 : p?0:s);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<vector>

//#include <bits/stdc++.h>

using namespace std;

vector<int> vec;
int n, x;
int fun(int a, int b) {
	if (b == 0)
		return a;
	else
		return fun(b, a%b);
}
int main()
{
	cin >> n >> x;
	int number;
	vec.push_back(x);
	for (int i = 0; i < n; i++)
	{
		cin >> number;
		vec.push_back(number);
	}
	sort(vec.begin(), vec.end());
	if (vec.size() == 2)
	{
		cout << vec[1] - vec[0] << endl;
		return 0;
	}
	vector<int> van;
	for (int i = 1; i < vec.size(); i++)
	{
		van.push_back(vec[i] - vec[i - 1]);
	}
	int ans = fun(van[0],van[1]);
	for (int i = 2; i < van.size(); i++)
	{
		ans = fun(ans, van[i]);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
    
    char str[10];
    scanf("%s", str);
    
    int ans = 0;
    int temp = 0;
    for(int i = 0; str[i]; i++){
        if(str[i] == 'A' || str[i] == 'G' || str[i] == 'C' || str[i] == 'T') temp++;
        else{
            ans = max(ans, temp);
            temp = 0;
        }
    }
    ans = max(ans, temp);
    printf("%d", ans);

	return 0;
}


Measured memory_bytes: 256
input();S=input();d=m=0
for c in S:
 if c=="(":d-=1
 else:d+=1
 m=max(d,m)
S="("*m+S;d=m=0
for c in S[::-1]:
 if c=="(":d+=1
 else:d-=1
 m=max(d,m)
print(S+")"*m)

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	reverse(s.begin(),s.end());
	string a="maerd",b="remaerd",c="esare",d="resare";
	int i=0,n=s.size();
	while(i<n){
		if(i+4<n && (s.substr(i,5)==a || s.substr(i,5)==c)) i+=5;
		else if(i+5<n && s.substr(i,6)==d) i+=6;
		else if(i+6<n && s.substr(i,7)==b) i+=7;
		else{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 512
h,w=map(int,input().split())
ans = 10**15
import sys
if h%3==0 or w%3==0:
  print(0)
  sys.exit()
h0 = 1
while h0 <h:
  s1=h0*w
  if (h-h0)%2==0:
    s2=w*(h-h0)//2
    s3=s2
  else:
    s2=w*(h-h0)//2
    s3=w*(h-h0)//2+w
  ans1 = max(s1,s2,s3)-min(s1,s2,s3)
  if w%2==0:
    s4=(h-h0)*(w//2)
    s5=s4
  else:
    s4=(h-h0)*(w//2)
    s5=(h-h0)*(w//2)+(h-h0)
  ans2 = max(s1,s4,s5)-min(s1,s4,s5)
  ans = min(ans,ans1,ans2)
  h0 += 1
w0 = 1
while w0 <w:
  s6=w0*h
  if (w-w0)%2==0:
    s7=h*(w-w0)//2
    s8=s7
  else:
    s7=h*(w-w0)//2
    s8=h*(w-w0)//2+h
  ans3 = max(s6,s7,s8)-min(s6,s7,s8)
  if h%2==0:
    s9=(w-w0)*(h//2)
    s10=s9
  else:
    s9=(w-w0)*(h//2)
    s10=(w-w0)*(h//2)+(w-w0)
  ans4 = max(s6,s9,s10)-min(s6,s9,s10)
  ans = min(ans,ans3,ans4)
  w0 += 1
print(ans)


Measured memory_bytes: 3064
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))


def fur(n,r):
    p,q = 1,1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p * pow(q,mod-2,mod) % mod

x, y = nm()

if (x + y) % 3 != 0:
    print(0)
    exit()

n = (2*y - x) // 3 # (X, Y) -> (X+1, Y+2) 
m = (2*x - y) // 3 # (X, Y) -> (X+2, Y+1) 

if n < 0 or m < 0:
    print(0)
    exit()

print(fur(n+m, n))



Measured memory_bytes: 39280