akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int a, b;
  cin >> a >> b;
  if(a>9 || b>9) cout << -1 << endl;
  else cout << a * b << endl;

  


}


Measured memory_bytes: 3620
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
int a,b,c;
cin >> a >> b >> c;
    cout << min(c, b/a) << endl;

}

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

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

int main() {
	string a, b, c;
	cin >> a >> b >> c;

	if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
		
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e3 + 5;
string s;
int n , p;
ll ans;
map<int , int> mp;
int main() {
    abdelrahman010
    cin >> n >> p >> s;
    int acc = 0;
    if(p == 2 || p == 5) {
        for(int i = n - 1;i >= 0;i--) {
            if((s[i] - '0') % p == 0)
                acc++;
            ans += acc;
        }
    } else {
        mp[0]++;
        int  pw = 1;
        for(int i = n - 1;i >= 0;i--) {
            acc = (acc + (1ll * pw * (s[i] - '0')) % p) % p;
            pw = (10ll * pw) % p;
            ans += mp[acc]++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3972
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		long N = sc.nextLong();
		int sqrt = (int)Math.sqrt(N);
		int d = 0;
		for (int i = sqrt; i > 0; i--) {
			if (N % i == 0) {
				d = i;
				break;
			}
		}
		long ans = N / d + d - 2;
		System.out.println(ans);
	}
	
	public static long gcd(long a, long b) {
		long remainder = a % b;
		if (remainder == 0) {
			return b;
		} else {
			return gcd(b, remainder);
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 23380
<?php
list($n) = ints();
$a = ints();
$cnt4 = $cnt2 = $cnt1 = 0;
for ($i = 0; $i < $n; ++$i) {
    if ($a[$i] % 4 === 0) $cnt4++;
    elseif ($a[$i] % 2 === 0) $cnt2++;
    else $cnt1++;
}
if ($cnt2 > 0) echo $cnt4 >= $cnt1 ? 'Yes' : 'No';
else echo $cnt4 >= $cnt1 - 1 ? 'Yes' : 'No';
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

using namespace std;

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

  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      int test = i * j + (n - i) * (m - j);
      if (test == k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std;

int is_square(int n) {
  int s = floor(sqrt(n));
  return (s * s == n);
}

int main() {
  string a, b;
  cin >> a >> b;
  string num = a + b;
  if(is_square(atoi(num.c_str()))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll res=pow(x,y/2);
  res*=res;
  res%=mod;
  if(y%2==1) res*=x;
  return res%mod;
}
ll gyaku(ll x){
  return pow(x,mod-2);
}
vector<ll> frac,gfrac;
void set_frac(ll n){
  frac.push_back(1);
  gfrac.push_back(1);
  for(ll i=1;i<=n;i++){
    frac.push_back(frac[i-1]*i%mod);
    gfrac.push_back(gyaku(frac[i]));
  }
}
ll nCr(ll n,ll r){
  ll res=frac[n]*gfrac[r]%mod;
  res*=gfrac[n-r];
  return res%mod;
}
ll dp[1005][1005]={0};
int main(){
  ll n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  set_frac(n+100);
  dp[0][0]=1;
  for(int j=0;j<=b;j++){
    for(int i=0;i<=n;i++){
      ll num=dp[i][j];
      dp[i][j+1]+=dp[i][j];
      dp[i][j+1]%=mod;
      if(a<=(j+1)&&(j+1)<=b){
        for(int l=1;l<=d;l++){
          if(i+(j+1)*l<=n){
            num*=nCr(n-i-(l-1)*(j+1),j+1);
            num%=mod;
            if(c<=l&&l<=d){
              dp[i+l*(j+1)][j+1]+=(num*gfrac[l])%mod;
              dp[i+l*(j+1)][j+1]%=mod;
            }
          }
        }
      }
    }
  }
  cout<<dp[n][b]<<'\n';
}


Measured memory_bytes: 8192
#include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s)                                                               \
    do {                                                                       \
    } while (0)
#define dump(x)                                                                \
    do {                                                                       \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

void solve() {
    string s;
    cin >> s;
    VI a(4);
    REP(i, 0, 4) a[i] = s[i] - '0';
    string t = "-+";
    REP(i, 0, 8) {
        vector<bool> bo(3);
        REP(j, 0, 3) bo[j] = i & (1 << j);
        int sum = a[0];
        REP(j, 1, 4) sum += (bo[j - 1] ? 1 : -1) * a[j];
        if (sum == 7) {
            cout << a[0];
            REP(j, 1, 4) {
                cout << t[bo[j - 1]];
                cout << a[j];
            }
            cout << "=7" << endl;
            break;
        }
    }
}

signed main() {
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()

int main() {
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  vector<int> ans(n);
  rep(i,n){
while(a[i]%2==0){
  a[i]/=2;
  ans[i]++;
}
  }
 int min=30;
  rep(i,n){
    if(ans[i]<min) min=ans[i];
  }
  cout<<min<<endl;
return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
	let n = read::<usize>();
	let arr = read_vector::<usize>();
	let mut ans = vec![0; n];
	let mut sum = 0;
	for i in 0..(n / 2) {
		sum += 2 * arr[i * 2 + 1];
	}
	ans[0] = arr.iter().fold(0, |acc, &val| acc + val) - sum;
	for i in 1..n {
		ans[i] = 2 * arr[i - 1] - ans[i - 1];
	}
	print(&ans);
}

fn print(ans: &[usize]) {
	for i in 0..ans.len() {
		if i < ans.len() - 1 {
			print!("{} ", ans[i]);
		} else {
			println!("{}", ans[i]);
		}
	}
}

#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .trim()
        .parse()
        .unwrap();
}

#[allow(dead_code)]
fn read_vector<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();
}

#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    use std::io::prelude::*;
    let stdin = stdin();
    return stdin
        .lock()
        .lines()
        .map(|line| line
            .unwrap()
            .split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect())
        .collect();
}

Measured memory_bytes: 8692
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
using namespace std;
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; }
const ll INF=1LL<<60;

string s;

int main(){
    cin>>s;
    string ans="";

    rep(i,0,s.size()){
        if(ans!=""){
            if(s[i]=='0') ans=ans+"0";
            else if(s[i]=='1') ans=ans+"1";
            else ans.pop_back();
        }
        else{
            if(s[i]=='0') ans=ans+"0";
            else if(s[i]=='1') ans=ans+"1";           
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3604
N=int(input())
a=[int(i) for i in input().split()]
ans=[]
for mode in range(2):
	tempans=0
	sumA=0
	#print(sumA)
	for i in range(0,N):
		#above 0
		sumA+=a[i]
		if (i+mode)%2==0:
			if sumA<=0:
				tempans-=(sumA-1)
				sumA=1
		else:
			if sumA>=0:
				tempans+=(sumA+1)
				sumA=-1
		#print(sumA)
	ans.append(tempans)
print(min(ans))

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

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

const int MOD = 1e9+7;
const int MAXN = 1e6+5;
int cop[10][MAXN],v[MAXN],p[MAXN];

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);
	for (int i=0;i<MAXN;++i) cop[0][i]=1;
	for (int i=2;i<=1000001;++i) {
		if (!p[i]) {
			for (int j=i;j<=1000001;j+=i) {
				cop[cop[0][j]++][j]=i;
				p[j]=1;
			}
			p[i]=0;
		}
	}
	int n,f,l;
	cin >> n;
	bool pair=true;
	cin >> l;
	f=l;
	for (int i=1;i<n;i++) {
		int a;
		cin >> a;
		f=__gcd(f,a);
		if (pair) {
			for (int i=1;i<10;++i) {
				if (cop[i][a]==0) break;
				if (v[cop[i][a]]) {
					pair = false;
					break;
				}
				v[cop[i][a]]=1;
			}
		}
	}
	if (pair) cout << "pairwise coprime\n";
	else if (f==1) cout << "setwise coprime\n";
	else cout << "not coprime\n";
}

Measured memory_bytes: 38344
from collections import deque

def bfs(maze, visited, s, h, w):
  queue = deque(s)
  #　返り値
  va = 0
  while queue:
    y,x = queue.popleft()
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if new_x < 0 or new_x >= w or new_y < 0 or new_y >=h :
        continue
      if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
        #　移動回数の計算
        visited[new_y][new_x] = visited[y][x] + 1
        va = max(va,visited[new_y][new_x])
        queue.append([new_y, new_x])
  return va
############

h,w = map(int,input().split())

maze = [['.' for j in range(w)] for i in range(h)]
visited = [[-1]*(w) for _ in range(h)]
s = []
s_append = s.append
for i in range(h) :
  m1 = input()
  for j in range(w) :
    if m1[j] == '#' :
      s_append([i,j])
      visited[i][j] = 0

print(bfs(maze, visited, s, h, w))

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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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

class Union_Find_size{
public:
  vector<int> Parent;
  //コンストラクタ
  Union_Find_size(int N){
    Parent=vector<int>(N,-1);
  }
  //木の根を求める
  int root(int x){
    //x（自分）が親ならxを返す
    if(Parent.at(x)<0)  return x;
    //経路圧縮しながら return する
    return Parent.at(x)=root(Parent.at(x));
  }
  //xの属する木の要素数を調べる
  int size(int x){
    return -Parent.at(root(x));
  }
  //xとyが同じ集合に属するかを判定する
  bool same(int x,int y){
    return root(x)==root(y);
  }
  //xとyの属する集合を併合する
  void unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y)  return;
    if(size(x)<size(y)) swap(x,y);
    Parent.at(x)+=Parent.at(y);
    Parent.at(y)=x;
  }
};

//abc097d,abc120d,abc126e

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  ll N,M;
  cin >> N >> M;
  vector<int> A(M),B(M);
  rep(i,M){
    cin >> A.at(i) >> B.at(i);
    A.at(i)--;
    B.at(i)--;
  }
  reverse(all(A));
  reverse(all(B));

  vector<ll> ans(M,-1);
  ll now=N*(N-1)/2;
  ans.at(0)=now;
  Union_Find_size uni(N);
  rep(i,M-1){
    if(!uni.same(A.at(i),B.at(i))){
      int a=uni.size(A.at(i));
      int b=uni.size(B.at(i));
      now-=a*b;
      uni.unite(A.at(i),B.at(i));
    }
    ans.at(i+1)=now;
  }
  reverse(all(ans));
  rep(i,M)  cout << ans.at(i) << endl;

  return 0;
}

Measured memory_bytes: 5284
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastReader s = new FastReader();
		String inp = s.next();
		if(inp.equals("ABC")) System.out.println("ARC");
		else System.out.println("ABC");
	}
	
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
	}

}


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

const uint32_t mod = 998244353;

unsigned long long log2i(unsigned long long n) {
  return CHAR_BIT*sizeof(n) - __builtin_clzll(n);
}
constexpr uint32_t mul(uint32_t a, uint32_t b, uint32_t mod) {
  return uint64_t(a)*b%mod;
}
template <typename F> uint32_t add(uint32_t a, uint32_t b) {
  auto res = a+b; return res < F::mod ? res : res-F::mod;
}
uint32_t powm(uint32_t base, uint32_t exp, uint32_t mod) {
  uint32_t res=1;
  for (; exp; exp>>=1, base = mul(base, base, mod))
    if (exp&1)
      res = mul(res, base, mod);
  return res;
}
uint64_t modinv(uint64_t a, uint64_t mod) {
  return powm(a, mod-2, mod);
}

vector<uint32_t> fac;
vector<uint32_t> facinv;

uint32_t nCr(uint32_t n, uint32_t r) {
  if (r > n) return 0;
  return uint64_t(fac[n])*facinv[n-r]%mod*facinv[r]%mod;
}

uint32_t count(uint32_t a, uint32_t b, uint32_t n) {
  return uint64_t(nCr(n, a))*nCr(n, b)%mod;
}

#define int int64_t
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);

  int n, a, b, k; cin >> n >> a >> b >> k;

  fac.push_back(1);
  facinv.push_back(1);
  for (int i=1; i<=n; ++i) {
    fac.push_back(mul(fac.back(), i, mod));
    facinv.push_back(modinv(fac.back(), mod));
  }
  
  int cnt = 0;
  
  for (int i=0; i<=n; ++i) {
    int a_score = i*a;
    int b_score = k - a_score;
    if (b_score%b)
      continue;
    int j = b_score/b;

    cnt = (cnt + count(i, j, n))%mod;
  }
  cout << cnt << '\n';
}

/*
 * Local variables:
 * compile-command:"g++ -D_GLIBCXX_DEBUG -g3 -ggdb3 -O0 -Wall -Wextra -std=c++14 b.cc -o b && for f in *.in; do echo \"--- $f -------------\"; ./b <$f; done"
 * end:
 */



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

int c=0;
void selectionSort(int A[], int n);

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, A[100];
    cin>>n;
    for(int i=0; i<n; i++) {
        cin>>A[i];
    }
    selectionSort(A, n);
    for(int i=0; i<n-1; i++) {
        cout<<A[i]<<' ';
    }
    cout<<A[n-1]<<'\n'<<c<<'\n';
    return 0;
}

void selectionSort(int A[], int n)
{
    for(int i=0; i<n-1; i++) {
        int mini=i;
        for(int j=i+1; j<n; j++) {
            if(A[j]<A[mini]) mini=j;
        }
        if(i!=mini) {
            swap(A[i], A[mini]);
            c++;
        }
    }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int INF = 2e9;

int gcdTable[201][201];
int gcd(int a, int b) {
    if (gcdTable[a][b] != -1)
        return gcdTable[a][b];
    int ans = b==0 ? a : gcd(b, a%b);
    gcdTable[a][b] = ans;
    gcdTable[b][a] = ans;
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    memset(gcdTable, -1, sizeof gcdTable);
    int k; cin>>k;
    int ans=0;
    for (int a=1; a<=k; a++) {
        for (int b=1; b<=k; b++) {
            for (int c=1; c<=k; c++) {
                int temp = gcd(a,b);
                temp = gcd(temp,c);
                ans += temp;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

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

// #include <iostream>
// #include <fstream>
// #include <string>
// #include <map>
// #include <vector>
// #include <algorithm>
// #include <regex>
// #include <chrono>
// #include <sstream>
// #include <iomanip>
// #include <queue>
// #include <stack>
// #include <set>
// #include <unordered_map>
// #include <unordered_set>


using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 998244353;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}

int n, m, p;
int a[5050], b[5050], c[5050];


signed main() {

	cin >> n >> m >> p;

	for(int i = 0; i < m; i++) {
		
		cin >> a[i] >> b[i] >> c[i];
		c[i] = p - c[i];
	}
	
	vector<int> dist(n+1, INF);
	dist[1] = 0;
	
	for(int l = 0; l < n-1; l++) {
		for(int i = 0; i < m; i++) {
			
			if(dist[a[i]] == INF) continue;
			chmin(dist[b[i]], dist[a[i]] + c[i]);
		}
	}

	vector<bool> neg(n+1, false);
	int ans = dist[n];

	for(int l = 0; l < n; l++) {
		for(int i = 0; i < m; i++) {

			if(dist[a[i]] == INF) continue;

			if(chmin(dist[b[i]], dist[a[i]] + c[i]) || neg[a[i]]) 
				neg[b[i]] = true;
		}
	}

	if(neg[n]) cout << -1 << endl;
	else cout << max(0,-ans) << endl;
			
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
int N=0;
int h[100002];
int dp[100002];

int func(int i){
if(dp[i]!=-1) return dp[i];
if(i>=N-1)
	return 0;
int a=abs(h[i]-h[i+1]);
int b=abs(h[i]-h[i+2]);
if(i==N-2) b=100000;
return dp[i] = min(a+func(i+1), b+func(i+2));

}

int main(){
scanf("%d", &N);
for(int i=0; i<N; ++i){
	scanf("%d", &h[i]);
	dp[i]=-1;
}
h[N]=0;
h[N+1]=0;
int resp=func(0);
cout << resp;

return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>
int main()
{
    long int n,i,x,a[200000],sum,j;
    scanf("%ld",&n);
    for(i=0;i<=n;i++)
    {
        a[i]=0;
    }
    for(i=1;i<n;i++)
    {
        scanf("%ld",&x);
        a[x]++;
    }
    a[n]=0;
    for(j=1;j<=n;j++)
    {
        printf("%ld\n",a[j]);
    }
    return 0;

}


Measured memory_bytes: 3240
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#define LL long long


using namespace std;

int main() {
    LL x,y;
    scanf("%lld %lld",&x,&y);
    if(llabs(x-y)>=2)
        printf("Alice\n");
    else
        printf("Brown\n");
    return 0;
}


Measured memory_bytes: 256
// Cats and Dogs

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	int A, B, X;
	cin >> A >> B >> X;

	if (X-A < 0)
		cout << "NO" << endl;
	else if (X-A >= 0 && X-A <= B)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
s = list(map(int,input().split()))
t = list(map(int,input().split()))
dp0 = [[0 for i in range(m+2)] for j in range(n+2)]
dp1 = [[0 for i in range(m+2)] for j in range(n+2)]
dp0[0][0] = 1
mod = 10**9+7
for i in range(n+1):
    for j in range(m+1):
        dp0[i+1][j] = (dp0[i+1][j]+dp0[i][j])%mod
        dp1[i][j] = (dp1[i][j]+dp0[i][j])%mod
        dp1[i][j+1] = (dp1[i][j+1]+dp1[i][j])%mod
        if i != n and j != m and s[i] == t[j]:
            dp0[i+1][j+1] = (dp1[i+1][j+1]+dp1[i][j])%mod
print(dp1[n][m])

Measured memory_bytes: 108252
#include <bits/stdc++.h>	
#define pb push_back
typedef long long ll;
const int inf = 2e9;
using namespace std;

char S[300005];

int main(){
	int n;
	scanf("%d%s",&n,S);
	int wt=0,et=0,w=0,e=0;

	for (int i = 0; i < n; ++i)
	{
		if(S[i]=='E') et++;
		else wt++;
	}

	int minimo = inf,r;


	for (int i = 0; i < n; ++i)
	{
		r = w;
		if(S[i]=='E') e++;
		else w++;
		r += et - e;
		minimo = min(minimo,r);
	}

	return !printf("%d\n", minimo);
}

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

#A
def A():
    a = II()
    s = input()
    print(s if a >= 3200 else "red")
    return

#B
def B():
    II()
    a = LI()
    ans = 0
    for ai in a:
        ans += 1 / ai
    print(1/ans)
    return

#C
def C():
    n = II()
    v = LI()
    q = []
    for vi in v:
        heappush(q, vi)
    while 1:
        a = heappop(q)
        if q:
            b = heappop(q)
            heappush(q, (a + b) / 2)
        else:
            print(a)
            return

#D
def D():
    n, q = LI()
    tree = [[] for i in range(n)]
    for _ in range(n - 1):
        a, b = LI_()
        tree[a].append(b)
        tree[b].append(a)
    ans = [0] * n
    c = defaultdict(int)
    for _ in range(q):
        p, x = LI_()
        x += 1
        ans[p] += x
    c[0] = 1
    q = deque([0])
    while q:
        p = q.pop()
        for nex in tree[p]:
            if c[nex]:
                continue
            c[nex] += 1
            ans[nex] += ans[p]
            q.appendleft(nex)
    print(*ans)
    return

#E
def E():
    return

#F
def F():
    return

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


Measured memory_bytes: 112840
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
string s;
bool f(int l,int r){
    int cnt=0;
    for(int i=l;i<=(l+r)/2;i++){
        if(s[i]!=s[r-cnt]){
            return false;
        }
        cnt++;
    }
    return true;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>s;
    int n=s.size();;
    if(f(0,n-1) && f(0,(n-1)/2 -1) && f((n+3)/2 -1,n-1)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 250000;

signed
main(){
		vector<bool> prime(MAX, true);
		prime[0] = false;
		prime[1] = false;
		for(int i=2;i<=MAX;i++)
		{
				if(prime[i])
				{
						for(int j=2*i;j<=MAX;j+=i)
						{
								prime[j] = false;
						}

				}
		}
		int n;
		while(cin >> n and n!=0)
		{
				int cnt = 0;
				for(int i=n+1;i<=2*n;i++)
				{
						if(prime[i]) cnt++;
				}
				cout << cnt << endl;
		}
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >>n;
  
  int a[n], b[n];
  for (int i = 0; i < n; i++)
    cin >> a[i] >> b[i];
  
  sort(a, a+n);
  sort(b, b+n);
  
  int ans = 0;
  ans += a[n-1] + b[0];
  
  cout << ans << endl;
}

Measured memory_bytes: 4408
n=int(input())
P=list(map(int,input().split()))
x=0
for i in range(0,n-2):
    if P[i+1] != max(P[i],P[i+1],P[i+2]) and P[i+1] != min(P[i],P[i+1],P[i+2]):
        x += 1
        
print(x)

Measured memory_bytes: 3060
#include <stdio.h>

int main(int argc, const char * argv[]) {
    unsigned int N;
    int Number[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    int Result[100];
    scanf("%u", &N);
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            Result[i * 9 + j] = Number[i] * Number[j];
            if (N == Result[i * 9 + j])
            {
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    int i,j;
    int d1,d10;
    int M,D;
    int count=0;

    scanf("%d %d",&M,&D);

    for(i=1;i<=M;i++){
        for(j=12;j<=D;j++){
            d1=j%10;
            d10=j/10%10;
            if(d1>=2 && d10>=2 && d1*d10==i){
                count++;
            }
        }
    }

    printf("%d\n",count);
    return 0;

}

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

int main()
{
  int n;
  int i;
  string x;
  int p = 0;
  int w = 0;
  int g = 0;
  int y = 0;
  
  cin >> n;
  
  i = 0;
  while (i < n)
  {
    cin >> x;
    if ( x == "P")
      p++;
    else if (x == "W")
      w++;
    else if (x == "G")
      g++;
    else if (x == "Y")
      y++;
    i++;
  }
  
  i = 0;
  if (p > 0)
    i++;
  if (w > 0)
    i++;
  if (g > 0)
    i++;
  if (y > 0)
    i++;
  
  if (i == 3)
    cout << "Three" << endl;
  else if (i == 4)
    cout << "Four" << endl;

}

Measured memory_bytes: 256
N, L = map(int, input().split())
min_abs = 1000
for i in range(N):
    if abs(min_abs) > abs(L + i):
        min_abs = L + i
ans = 0

for i in range(N):
    if min_abs == L + i:
        continue
    ans += L + i
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <string>


using namespace std;


int main()
{
	int box[4][14];		// スペード:0、ハート:1、クラブ:2、ダイヤ:3
	string _suit = "SHCD";
	int n;			// 手持ちのカードの枚数
	char suit;		// カードの柄
	int x;			// カードのランク

	// 初期化
	for(int i = 0; i < 4; i++)
		for(int j = 1; j < 14; j++)
			box[i][j] = 0;

	// 入力
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> suit >> x;

		switch(suit){
			case 'S':
				box[0][x] = 1;
				break;
			case 'H':
				box[1][x] = 1;
				break;
			case 'C':
				box[2][x] = 1;
				break;
			case 'D':
				box[3][x] = 1;
				break;
		}
	}

	// 足りないカードの表示
	for(int i = 0; i < 4; i++)
		for(int j = 1; j < 14; j++)
			if(!box[i][j])
				cout << _suit[i] << " " << j << endl;

	return 0;
}


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

using namespace std;

const int N = 1e5 + 5;

typedef long long ll;

const ll mod = 1e9 + 7;

ll x, y, z, rs, rs1, a[N], b[N], ans;
multiset <ll> st;

struct node {
    ll a, b, c;
} p[N];

bool cmp(node a, node b) {
    return a.a - a.b < b.a - b.b;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> x >> y >> z;
    int n = x + y + z;
    for (int i = 1; i <= n; i++) {
        cin >> p[i].a >> p[i].b >> p[i].c;
        rs += p[i].c;
    }
    sort(p + 1, p + 1 + n, cmp);
    for (int i = 1; i <= n; i++) {
        rs1 += (p[i].b - p[i].c);
        st.insert(p[i].b - p[i].c);
        if (i > y) {
            rs1 -= *st.begin();
            st.erase(st.begin());
        }
        a[i] = rs1;
    }
    st.clear();
    rs1 = 0;
    for (int i = n; i >= 1; i--) {
        rs1 += (p[i].a - p[i].c);
        st.insert(p[i].a - p[i].c);
        if (n - i >= x) {
            rs1 -= *st.begin();
            st.erase(st.begin());
        }
        b[i] = rs1;
    }
    for (int i = y; i <= n - x; i++) {
        ans = max(ans, rs + b[i + 1] + a[i]);
    }
    cout << ans;
}


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

int main() {
  long long A,B;
  cin >> A >> B;
  long long x = A*B,tmp,r;
  if(A<B){
    tmp = A;
    A = B;
    B = tmp;
  }
  r = A%B;
  while(r!=0){
    A = B;
    B = r;
    r = A%B;
  }
  cout << x/B;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLineIntSpilit();
            var result = 0;

            if(n[0]+n[1] >= 24) { result = (n[0] + n[1]) - 24; } else { result = n[0] + n[1]; }
            Console.WriteLine(result);
            ReadLine();
        }

        /// <summary>
        /// コンビネーション
        /// </summary>
        /// <param name="n"></param>
        /// <param name="m"></param>
        /// <returns></returns>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }

        static string[] GetAplhaLowerArray() => new string[]{ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}

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

int main() {
    int N;
    cin >> N;
    if(N < 1000) cout << "ABC" << endl;
    else cout << "ABD" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;
    vl ds(n);
    cin>>ds;
    sort(rng(ds));

    vector<bool> bs(24);
    rep(i, n) {
        if (i % 2) {
            if (bs[ds[i]]) {
                cout<<0<<endl;
                return 0;
            }
            bs[ds[i]] = true;
        }
        else {
            if (bs[24 - ds[i]]) {
                cout<<0<<endl;
                return 0;
            }
            bs[24 - ds[i]] = true;
        }
    }
    ll ans = ds[0];
    ll cur = 0;
    rep(i, 24) {
        if (bs[i]) {
            chmin(ans, min(i - cur, 24 - (i - cur)));
            cur = i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
S = list(str(input()))

ans = 0
last_str = ''
for s in S:
  if (last_str == s) and s == '0':
    ans += 1
    last_str = '1'
  elif (last_str == s) and s == '1':
    ans += 1
    last_str = '0'
  else:
    last_str = s
print(ans)

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

int n;
double ans, x;

int main() {
    cin >> n;
    string u;
    rep(i, n) {
        cin >> x >> u;
        if (u[0] == 'B') x *= 380000;
        ans += x;
    }
    cout << ans << endl;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n,x,y;
	cin>>n>>x>>y;
	x--;
	y--;
	vector<int> ans(n-1,0);
	rep(i,n){
		repi(j,i+1,n){
			int len = min(j-i, min(abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j)));
			ans[len-1]++;
		}
	}
	for(auto x:ans)cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#define rep(i,n) for(long long i=0;i<n;++i)
#define mod 1000000007
using namespace std;

int main()
{
	long long N;	cin >> N;
	long long ans = 1;
	vector<int> num(1001, 1);
	for (long long i = N; i > 0; --i) {
		int a = i;
		for (long long j = 2; j <= N; ++j) {
			while (a%j == 0) {
				++num[j];
				a /= j;
			}
		}
	}
	rep(i, N + 1)	ans = (ans*num[i]) % mod;
	cout << ans << endl;
	cin >> N;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <iostream>
#include <math.h>
#include <cmath>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <string.h>
#include <cstring>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <list>
#include <stack>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <stdio.h>
#include <bitset>
#include <vector>
#include <random>

using namespace std;

#define dout if (debug) cout
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) (int((x.size())))

typedef long double ld;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<PII> VPI;

#define REP(i,a,n) for (int i=a;i<n;i++)
#define PER(i,a,n) for (int i=n-1;i>=a;i--)
#define db(x)		 cerr << #x << " = " << x << endl
#define db2(x, y)	{cerr << #x << " = " << x << "\t";	db(y);		}
#define db3(x, y, z){cerr << #x << " = " << x << "\t";	db2(y,z);	}

template <typename t1, typename t2> inline bool upmax(t1 &a, t2 b) { if (a<(t1)b) { a = (t1)b; return true; } else return false; }
template <typename t1, typename t2> inline bool upmin(t1 &a, t2 b) { if (a>(t1)b) { a = (t1)b; return true; } else return false; }
template <typename T>inline bool pal(T &x){ int n = SZ(x); REP(i, 0, n / 2) { if (x[i] != x[n - i - 1]) return 0; } return 1; }
template <typename T>inline T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template <typename T>inline T lcm(T a, T b) { return a*(b / gcd(a, b)); }
template <typename T>inline T sqr(T a) { return a*a; }

int month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };

inline ll mp(ll a, ll b) { return (a << 31) + b; }

class PQ_compare{
public:
	bool operator()(const int a, const int b) const {
		return 1;
	}
};

const int INF = 1000000404;
const ll  MOD = 1000000007ll;
const ld  PI = acos(-1.0);
const ld  EPS = 1e-9;

int SQ = 404;

#define debug 1
#define N 111111


void solve()
{
	ll x, y;
	cin >> x >> y;
	if (x%y == 0) {
		cout << -1;
	} else { 
		cout << x;
	}







}

int main()
{


	//freopen("codeforces.in", "r", stdin);
	//freopen("codeforces.out", "w", stdout);
	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	int t = 1;

	//cin >> t;

	while (t--) solve();
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
using namespace std;

struct UnionFind{
  vector<int> Par;

  //N個の独立した根として初期化
  UnionFind(int N) : Par(N) {
    for( int i = 0; i < N; i++ ) Par.at(i) = -1;
  }

  //どこの根に属するか得る再帰関数
  int root(int X){
    if( Par.at(X) < 0 ) return X;
    else return Par.at(X) = root(Par.at(X));
  }

  //XとYが同じ根に属するか判定
  bool same(int X, int Y){
    return root(X) == root(Y);
  }

  //XとYの木を合体
  void unite(int X, int Y){
    X = root(X);
    Y = root(Y);
    if( X == Y ) return;
    Par.at(X) = Y;
  }

  //XとYの木を合体　サイズを持つ
  bool merge(int X, int Y){
    X = root(X);
    Y = root(Y);
    if( X == Y ) return false;
    if( Par.at(X) > Par.at(Y) ) swap(X, Y); //小さいほうから大きいほうに繋ぎ変える
    Par.at(X) += Par.at(Y);
    Par.at(Y) = X;
    return true;
  }

  //所属する木のサイズを取得
  int size(int X){
    return Par.at(root(X));
  }
};

signed main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  vector<int> B(M);
  for( int i = 0; i < M; i++ ){
    cin >> A.at(i) >> B.at(i);
    A.at(i)--;
    B.at(i)--;
  }
  reverse(A.begin(), A.end());
  reverse(B.begin(), B.end());


  //橋が1本もないときの不便さが初期値
  int now = N*(N-1)/2;
  UnionFind T(N);

  vector<int> res;
  for( int i = 0; i < M; i++ ){
    res.push_back(now);
    //すでに連結である場合は変化がないので飛ばす
    if( T.same(A.at(i), B.at(i)) ) continue;

    int Asize = T.size(A.at(i));
    int Bsize = T.size(B.at(i));
    now -= Asize*Bsize;

    T.merge(A.at(i), B.at(i));

  }

  reverse(res.begin(), res.end());
  for( int i = 0; i < res.size(); i++) cout << res.at(i) << endl;


}


Measured memory_bytes: 4596
#include <iostream>
#include <string>
#include <stack>
#include <cstdlib>
#include <cstdio>
using namespace std;
stack <int> st;
int solve(string);
int main() {
	string str;
	while (cin >> str)
	{
		if (str == "+" || str == "-" || str == "*" || str == "/")
			st.push(solve(str));
		else st.push(atoi(str.c_str()));
		if (getchar() == '\n')
		{
			cout << st.top() << endl;
			return 0;
		}
	}
}
int solve(string str) {
	int b = st.top(); st.pop();
	int a = st.top(); st.pop();
	if (str == "+")return a + b;
	else if (str == "-")return a - b;
	else if (str == "*")return a * b;
	else if (str == "/")return a / b;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
#define mod 1000000007
#define N 1000007
ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res%mod;
}
ll ncr(ll n,ll k){
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro)%mod;
}

void swap(ll *a,ll *b) {
    ll temp=*a;
    *a=*b;
    *b=temp;
}
vector<ll> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
vector<ll> parent;
ll find(ll p) {
    if(parent[p]==p) return parent[p];
    return parent[p]=find(parent[p]); 
}
void unun(ll a,ll b) {
    ll r1=find(a);
    ll r2=find(b);
    if(r1!=r2) parent[r2]=r1;
}
void solve() {   
    ll n,a,b;
    cin>>n>>a>>b;
    for(int i=a;i<=b;i++) {
        if(i%n==0) {
            cout<<"OK";
            return ;
        }
    }
    cout<<"NG";
    return ;
}   


int main(void){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<endl;
    }
    return 0; 

}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main()
{

long long a,b,c;
// long long count=0;
cin>>a>>b;
int count=0,count1=0;

if(a<=8 and b<=8){
	cout<<"Yay!";
}
else
cout<<":(";


return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>

int n, m, a, b;
std::vector<int> v[9];
bool used[9];

int dfs(int x, int cnt) {
    used[x] = true;
    int ret = 0;
    if (cnt == n) {
        used[x] = false;
        return 1;
    }

    for (int i = 0; i < v[x].size(); ++i) {
        if (!used[v[x][i]]) {
            ret += dfs(v[x][i], cnt+1);
        }
    }
    used[x] = false;
    return ret;
}

int main() {
    std::cin >> n >> m;

    for (int i = 0; i < m; ++i) {
        std::cin >> a >> b;
        v[a-1].push_back(b-1);
        v[b-1].push_back(a-1);
    }

    int ans;
    ans = dfs(0, 1);

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int N, K; cin >> N >> K;
    vector<int> P(N); for (auto &p : P) cin >> p;
    sort(begin(P), end(P));
    cout << accumulate(begin(P), begin(P) + K, 0) << endl;
    return 0;
}


Measured memory_bytes: 3600