akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int f(int n){
  int total = 0;
  while (n > 0) {
    total += n % 10;
    n /= 10;
  }
  return total;
}

int main(){
  int x;
  cin >> x;
  cout << ((x % f(x) == 0)? "Yes" : "No") << endl; 
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}






int main() {
  int N,K;
  cin >> N >> K;
  double ans = 0;
  for(int i=1; i <=N; i++) {
    int cnt = 0;
    int now = i;
    while(K > now) {
      now *= 2;
      cnt++;
    }
    ans += 1/pow(2,cnt);

  }
  ans/=N;
  printf("%.15lf\n",ans);

  return 0;
}


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

int main(){
    int N;
    cin >> N;
    int v;
    int i,j,k;
    double tmp1,tmp2;
    priority_queue<double,vector<double>,greater<double>> q;
    for(i=0;i<N;++i){
        cin >> v;
        q.push(v);}
    for(i=0;i<N-1;++i){
        tmp1 = (double)1.0*q.top()/2.0;
        q.pop();
        tmp2 = (double)1.0*q.top()/2.0;
        q.pop();
        q.push(tmp1+tmp2);
    }
    cout << fixed << setprecision(16);
    cout << q.top() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int L=1,R,M,l,r;cin>>R>>M;
  for(int i=0;i<M;i++){
    cin>>l>>r;
    L=max(L,l);R=min(R,r);
  }
  cout<<max(0,R-L+1)<<endl;
}

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

int n;
char a[200005];
int f[200005],num[200005];
int a1,a2;
int ksm(long long x,int y,int mod)
{
	long long res=1;
	while(y)
	{
		if(y&1) res=res*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return res;
}
int main()
{
	int i,j,k,cnt=0;
	scanf("%d",&n);
	scanf("%s",a);
	for(i=1;i<=200000;i++)
		num[i]=num[i>>1]+(i&1);
	for(i=1;i<=200000;i++)
		f[i]=f[i%num[i]]+1;
	for(i=0;i<n;i++)
		if(a[i]=='1') cnt++;
	for(i=0,j=n-1;i<j;i++,j--)
		swap(a[i],a[j]);
	j=1; k=1;
	for(i=0;i<n;i++)
	{
		if(cnt>1)
		{
			a1=(a1+(a[i]-'0')*j)%(cnt-1);
			j=j*2%(cnt-1);
		}
		a2=(a2+(a[i]-'0')*k)%(cnt+1);
		k=k*2%(cnt+1);
	}
	for(i=n-1;i>=0;i--)
	{
		if(a[i]=='0')
		{
			j=(a2+ksm(2,i,cnt+1))%(cnt+1);
			printf("%d\n",f[j]+1);
		}
		else if(a[i]=='1')
		{
			if(cnt==1) printf("0\n");
			else
			{
				j=(a1-ksm(2,i,cnt-1)+cnt-1)%(cnt-1);
				printf("%d\n",f[j]+1);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 5576
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"-----------"<<endl;
#define ll long long
#define P pair<int,int>
#define mk make_pair
#define en endl
#define RE return 0
#define int ll

signed main(){
  int n;
  cin>>n;
  
  int ans=0;
  for(int j=19; j<=n; j++){
    int cnt=0;
    for(int i=1; i*i<=j; i++){
      if(j%i==0) {
        cnt++;
      }
    }
    if(cnt==4&&j%2) {
      ans++;
    }
  }
  cout<<ans<<en;
}




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

int keta(long long N) {
    int res = 0;
    while(N>0) N /= 10, ++res;
    return res;
}

long long Res(int c, int keta) {
    long long res = c;
    --keta;
    while(keta-->0) {
        res *= 10LL;
        res += 9LL;
    }
    return res;
}

int Left_keta(long long N) {
    while(N >= 10) N /= 10;
    return int(N);
}

int keta_sum(long long N) {
    int res = 0;
    while(N>0) res += N%10, N /= 10;
    return res;
}

int main() {
    long long N;
    cin >> N;
    int C = Left_keta(N), Keta = keta(N);
    long long res1 = Res(C,Keta), res2 = Res(C-1,Keta);
    if(res1 <= N) {
        cout << C + 9*(Keta-1) << endl;
    } else {
        cout << C-1 + 9*(Keta-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
line = gets.chomp.split("")

ans = "Yes"
line.each_with_index do |pos, i|
    if (i + 1) % 2 == 0 and pos == "R"
        ans = "No"
    end
    if (i + 1) % 2 == 1 and pos == "L"
        ans = "No"
    end
end

puts ans


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

int main()
{
	int n;
	cin>>n;
	set<int> a;
	a.insert(n);
	
	for(int i=2;;i++)
	{
		if(n%2==0)
			n/=2;
		else
			n=n*3+1;
		
		a.insert(n);
		
		if(i!=a.size())
		{
			cout<<i;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int n, t, imos[101010];

int main() {
	cin >> n >> t;
	REP(i, n) {
		int l, r;
		cin >> l >> r;
		imos[l]++;
		imos[r]--;
	}
	int ans = 0;
	REP(i, 101010) {
		if (i) {
			imos[i] += imos[i - 1];
		}
		ans = max(ans, imos[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3500
#include<iostream>
#include <string>
#include <cstdlib> //絶対値利用のため
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

//const int INF = INT_MAX / 2;



int main() {
	int a, b, k;
	cin >> a >> b >> k;
	int i;
	int counter = 0;
	for (i = 100; i >= 1; i--) {
		if (a % i == 0&& b % i == 0) counter++;
		if (counter == k) break;
	}
	cout << i << endl;
	
	return 0;
}

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

typedef long long int ll; 
#define MOD 1000000007
#define ON 200000
#define rep(i,n) fp(i,0,n)  
#define fp(i,a,b) for(ll i=(a);i<(b);++i)
#define fn(i,a,b) for(ll i=(a);i>(b);i--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define FF first
#define SS second
typedef pair<ll, ll> pll; 
typedef vector<pll> vpll;
typedef vector<ll> vll;
#define rs(t) string t;cin>>t
#define ri(t) int t;cin>>t
#define rll(t) long long int t;cin>>t
#define MK make_pair
#define PB push_back
#define PO pop_back
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
///// This part below is only for debug, not used /////
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
///// END /////

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  rll(n);
  vpll v;
  
  for(ll i=0;i<n;i++){
  	ll a;
  	cin >> a;
  	v.PB(MK(a,i));
  }
  sort(v.begin(),v.end());
  
  rep(i,n){
  	// cout << v[i].FF << ' ';
  	cout << v[i].SS+1 << ' ';
  }
  cout << endl;
  
  
  return 0;
  
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

vl a,b,c;
ll n;
ll ans;


int main(){
  cin >> n;
  a = vl(n);
  b = vl(n);
  c = vl(n);
  for(ll i = 0;i < n;i++) cin >> a[i];
  for(ll i = 0;i < n;i++) cin >> b[i];
  for(ll i = 1;i <= n-1;i++) cin >> c[i];

  for(ll i = 0;i < n;i++) ans += b[i];
  for(ll i = 1;i < n;i++){
    if(a[i] == a[i-1]+1) ans += c[a[i-1]];
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,c,a,count=0,sum=0;

    cin>>n>>m>>c;
    vector<int>v;
    for(int i=0;i<m;i++)
    {
        cin>>a;
        v.push_back(a);
    }
    for(int i=0;i<n;i++)
    {
        for(int i=0;i<m;i++)
        {
            cin>>a;
           // cout<<"a= "<<a<<"B= "<<v[i]<<endl;
            a = a*v[i];
           // cout<<"a*v[i] "<<a<<endl;
            sum +=a;
           // cout<<sum<<endl;
        }
        if(sum+c>0)
            count++;

       // cout<<sum+c<<endl;
        //cout<<count<<endl;
        sum=0;
    }
    cout<<count<<endl;
    v.clear();
    return 0;
}


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


namespace StartFinish
{
    class Program
    {
     
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            for (int k = 0; k < n; k++)
            {
                if (k != n - 1)
                {
                    Console.Write("{0} ", array[k]);
                }
                else
                {
                    Console.WriteLine(array[k]);
                }
            }

            for (int i = 1; i < n; i++)
            {
                int t = array[i];
                int j = i - 1;
                while (j >= 0 && array[j] > t)
                {
                    array[j + 1] = array[j];
                    j--;
                }
                array[j + 1] = t;
                
                for(int k = 0; k < n; k++)
                {
                    if (k != n-1)
                    {
                        Console.Write("{0} ",array[k]);
                    }
                    else
                    {
                        Console.WriteLine(array[k]);
                    }
                }

            }

        }
    }
}

Measured memory_bytes: 9720
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long cc;

cc n,p[30], Ans, i, j;
cc judge1=0, judge2=0, judge3;
string S;


int main() {
	cin >> n;
	for (i = 0; i < n; i++)
		cin >> p[i];
	for (i = 1; i < n - 1; i++) {
		if (p[i]<p[i - 1] && p[i]>p[i + 1])
			Ans += 1;
		if (p[i] > p[i - 1] && p[i] < p[i + 1])
			Ans += 1;
	}

	cout << Ans << endl;
		return 0;
	}

Measured memory_bytes: 256
N = int(input())

result = {}
for i in range(N):
  S, P = input().split()
  P = int(P)
  if S in result:
    result[S].append([P, i])
  else:
    result[S] = [[P, i]] 

score_sorted = sorted(result.items(), key=lambda x:x[0])

for kv in score_sorted:
  v = kv[1]
  s = sorted(v, key = lambda x: x[0], reverse=True)
  for i in s:
    print(i[1] + 1)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

int main(){
	int a , b;
	char c[100];
	scanf("%d %d %s", &a, &b, &c);
	getchar();
	c[b - 1] = c[b-1] + 32;
	printf("%s", c);
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 3248
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <queue> 
#include <map>
#include <set>
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
using namespace std;

int main(){

  int n;
  cin >> n;
  int t[100010],x[100010],y[100010];
  t[0] = 0; x[0] = 0; y[0] = 0;
  
  REP(i,n) cin >> t[i+1] >> x[i+1] >> y[i+1];

  
  REP(i,n){
    if(t[i+1]-t[i] < (abs(x[i+1]-x[i])+abs(y[i+1]-y[i])) || (t[i+1]-t[i]-(abs(x[i+1]-x[i])+abs(y[i+1]-y[i])))%2 != 0){
      cout << "No" << endl; return 0;
    }
  }
  
  cout << "Yes" << endl;

 return 0;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Fibonacci Number
 */
public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		int f = 0;
		if (n == 0 || n == 1) {
			f = 1;
		} else {
			int f1 = 1;
			int f2 = 1;
			for (int i = 2; i < n + 1; i++) {
				f = f1 + f2;
				f1 = f2;
				f2 = f;
			}
		}
		System.out.println(f);
	}
}

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

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

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

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

  int size(int x){
    return -data[root(x)];
  }
};

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm


int main(){
  faster();
  vvi a(3 , vi(3 , 0));
  rep(i,3)rep(j,3) cin >> a[i][j];
  int n;
  cin >> n;
  int b;
  rep(i,n){
    cin >> b;
    rep(j,3)rep(k,3){
      if(a[j][k] == b) a[j][k] = -1;
    }
  }
  if(a[0][0] == a[0][1] && a[0][0] == a[0][2]){
    cout << "Yes";
    return 0;
  }
  if(a[0][0] == a[1][0] && a[0][0] == a[2][0]){
    cout << "Yes";
    return 0;
  }
  if(a[0][0] == a[1][1] && a[0][0] == a[2][2]){
      cout << "Yes";
      return 0;
  }
  if(a[1][0] == a[1][1] && a[1][0] == a[1][2]){
      cout << "Yes";
      return 0;
  }
  if(a[2][0] == a[2][1] && a[2][0] == a[2][2]){
      cout << "Yes";
      return 0;
  }
  if(a[0][1] == a[1][1] && a[0][1] == a[2][1]){
      cout << "Yes";
      return 0;
  }
  if(a[0][2] == a[1][2] && a[0][2] == a[2][2]){
      cout << "Yes";
      return 0;
  }
  if(a[0][2] == a[1][1] && a[0][2] == a[2][0]){
    cout << "Yes";
    return 0;
  }
  cout << "No";
}


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}



Measured memory_bytes: 256
fun main() {
    val (n, a) = nextIntList()
    val x = nextIntList()
    val mx = (x + a).max() ?: a

    val dp = Array(n + 1) { Array(n + 1) { Array(n * mx + 1) { 0L } } }
    (0..n).forEach { j ->
        (0..n).forEach { k ->
            (0..(n * mx)).forEach { s ->
                when {
                    j == 0 && k == 0 && s == 0 -> dp[j][k][s] = 1
                    j > 0 && s < x[j - 1] -> dp[j][k][s] = dp[j - 1][k][s]
                    j > 0 && k > 0 && s >= x[j - 1] -> dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
                    else -> dp[j][k][s] = 0
                }
            }
        }
    }
    println((1..n).map {
        dp[n][it][it * a]
    }.sum())
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

Measured memory_bytes: 86900
import collections 
  
q = collections.deque([]) 
f=0
l = []
for i in range(1,10):
    q.append(str(i))
    
#print(q)
while f<100003:
    s = q[0]
    l.append(s)
    if int(s[-1])>0:
        q.append(s+str((int(s[-1])-1+10)%10))
    q.append(s+s[-1])
    if int(s[-1])<9:
        q.append(s+str((int(s[-1])+1)%10))
    q.popleft()
    f+=2

for i in q:
    l.append(i)

#print(l[:50])
n = int(input())
print(l[n-1])

Measured memory_bytes: 14444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string s;
    cin >> s;
    int N = s.size();

    for (int i=0; i<N-1; i++){
        string sb;
        sb = s.substr(i,2);
        if (sb == "AC"){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

int h, w;
vector<vector<int>> a;

pair<int, int> next_index(pair<int, int> xy) {
    int x = xy.first, y = xy.second;
    if (x % 2 == 0) {
        if (y == w - 1) {
            return {x + 1, w - 1};
        } else {
            return {x, y + 1};
        }
    } else {
        if (y == 0) {
            return {x + 1, 0};
        } else {
            return {x, y - 1};
        }
    }
}

int main() {
    cin >> h >> w;
    a.assign(h, vector<int>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    vector<pair<pair<int, int>, pair<int, int>>> ans;
    pair<int, int> now = {0, 0};
    pair<int, int> end = make_pair(h - 1, h % 2 == 0 ? 0 : w - 1);
    while (now != end) {
        auto next = next_index(now);
        if (a[now.first][now.second] % 2 != 0) {
            a[now.first][now.second]--;
            a[next.first][next.second]++;
            ans.push_back({now, next});
        }
        now = next;
    }
    cout << ans.size() << endl;
    for (auto e : ans) {
        cout << e.first.first + 1 << " " << e.first.second + 1 << " " << e.second.first + 1 << " "
             << e.second.second + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5232
from math import pi, cos, sqrt

a, b, h, m = map(int, input().split())

time = 60 * h + m
wa = pi / 360.0; theta_a = wa * time
wb = pi / 30.0; theta_b = (wb * time) % (2 * pi)
diff = abs(theta_a - theta_b)

ans = sqrt(a**2 + b**2 - 2*a*b*cos(diff))
print (ans)

Measured memory_bytes: 9400
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)

long long value(int bit);

string s;
int n;

int main(){
    cin>>s;
    n=s.size()-1;   // '+'が入るスペースの数
    long long sum=0; 

    for(int bit=0; bit<(1<<n); bit++){
        sum+=value(bit);
    }

    cout<<sum<<endl;
}

long long value(int bit){
    long long v=0;
    string c=s.substr(0,1);

    REP(i,n){  
        // i番目が1なら
        if(bit&(1<<i)){
            v+=stoll(c);
            c.clear();
            c=s.substr(i+1,1);
        // i番目が0なら
        }else{
            c+=s.substr(i+1,1);
        }
    }
    v+=stoll(c);
    
    return v;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second

using namespace std;

//int t;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	//cin>>t;
	//while(t--){}
	int n,m;
	cin>>n>>m;
	vector<vector<int>> g(n);
	vector<int> h(n);
	for(int &x:h)cin>>x;
	while(m--){
		int u,v; cin>>u>>v; u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int cont=n;
	for(int i=0;i<n;i++){
		for(int v:g[i]){
			if(h[v] >= h[i]){
				cont--; break;
			}
		}
	}
	cout<<cont<<"\n";

	return 0;	
}



Measured memory_bytes: 8744
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 

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

using namespace std;

int main(){
    double a,b;std::cin >> a>>b;
    std::cout << (a/b)<< std::endl;
}


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

using namespace std;

int main(){
    int N;
    bool flag = true;
    cin >> N;
    for(int i=9;0<i;i--){
        if(N%i == 0){
            N /= i;
            break;
        }
    }

    if(N<10 && 0<N && flag){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
string s,p;
int main()
{
    ft
    ll t,i,j,n,m,l=0,r;
    cin>>s>>p;
    for(i=0;i<3;i++)
    {
        if(s[i]==p[i])
        {
            l++;
        }
    }
    cout<<l<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
const ll MAX=1100000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    repl(i,2,MAX){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k)return 0;
    if(n<0 or k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
int main(){
    COMinit();
    ll N,M;cin>>N>>M;
    map<ll,ll> info;
    ll p=M;
    repl(i,2,sqrt(M)+2){
        while(p%i==0){
            info[i]++;
            p/=i;
        }
    }
    if(p!=1)info[p]++;
    ll ans=1;
    for(auto s:info){
        ans*=COM(s.se+N-1,N-1);
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

  string s,t;
  cin >> s >> t;
  cout << (s[0]==t[0])+(s[1]==t[1])+(s[2]==t[2]) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    int x;
    cin >> x;
  }
  int cnt = 0;
  N -= K; K--; cnt++;
  cnt += N / K;
  if(N % K){
    cnt++;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

int A[100], n;

void trace(int A[],int n) {
	for (int i = 0; i < n; i++) {
		if (i != 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

void insertion(int n)
{
	int j,v;
	for (int i = 1; i < n; i++) {
		j = i-1;
		v = A[i];
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, n);
	}
}

int main()
{

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

	trace(A, n);
	insertion(n);

	return 0;
}


Measured memory_bytes: 3216
#include <algorithm>
#include <cstdio>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;
using namespace std;

int main() {
    // input
    int n, m; scanf("%d%d", &n, &m);
    vector<int> a(n); repeat (i, n) scanf("%d", &a[i]);
    // solve
    ll total = 0;
    vector<ll> imos0(2 * m);
    vector<ll> imos1(2 * m);
    repeat (i, n - 1) {
        int l = a[i] - 1;
        int r = a[i + 1] - 1;
        if (r < l) r += m; // [l, r] on [0, 2n)
        total += r - l;
        if (r - l <= 1) continue;
        imos0[l + 2] += 1;
        imos0[r + 1] -= 1;
        imos1[r + 1] -= (r + 1) - (l + 2);
    }
    repeat (i, 2 * m - 1) {
        imos0[i + 1] += imos0[i];
    }
    imos1[0] += imos0[0];
    repeat (i, 2 * m - 1) {
        imos1[i + 1] += imos1[i] + imos0[i + 1];
    }
    vector<ll> reward(m);
    repeat (i, m) reward[i] = imos1[i] + imos1[i + m];
    ll result = total - *whole(max_element, reward);
    // output
    printf("%lld\n", result);
    return 0;
}


Measured memory_bytes: 4608
import sys
lines = []
for index, line in enumerate(sys.stdin):
  line = line.strip()
  if index%2 == 0:
    lines.append( [line] )
  else:
    lines[-1].append( line )
#print(lines)
lines = iter(lines)
for line in lines:
  i1 = line
  xs = list(map(int, i1[0].split() ))
  ys = list(map(int, i1[1].split() ))
  full_match = 0
  spec_match = 0
  for x, y in zip(list(xs), list(ys)):
    #print(x, y, y in xs)
    if x == y:
      full_match += 1
    elif y in xs:
      spec_match += 1
  print(full_match, spec_match)


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000; //
const ll LINF = (ll) 4000000000000000000; //
const ll MOD = (ll) 1000000007; //
const double PI = acos(-1.0); //

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())

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

int main() {
    ll n;
    cin >> n;

    ll a[n + 1];
    ll sum = 0;

    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    a[n] = a[0];

    ll s = n * (n + 1) / 2;
    if (sum % s != 0) {
        YES(false);
        return 0;
    }
    ll k = sum / s;

    ll d[n];
    rep(i, n) d[i] = a[i + 1] - a[i];

    bool can = true;

    rep(i, n) {
        if ((d[i] - k) % n != 0 || (d[i] - k) > 0) {
            can = false;
            break;
        }
    }

    YES(can);

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cmath>
#include <regex>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ba back
#define ppb pop_back
#define eb emplace_back
#define eps 1e-6
#define vll vector<long long int>
#define sz(x) (int((x.size())))
#define all(x) (x).begin(),(x).end()
#define FAST ios_base :: sync_with_stdio (false); cin.tie (NULL)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,n) for(int i=1;i<n;i++)
using namespace std;
typedef long long int ll;
void solve() {
    ll n;
    cin>>n;
    if(n==1) cout<<0;
    else if(n==0) cout<<1;

}
int main(){
    FAST;

solve();


}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin>>N;
  vector<int> A(N), B(N);
  cin>>A;
  cin>>B;

  vector<int> num(N); iota(num.begin(), num.end(), 1);
  int ord = 0;
  int a = 0, b = 0;
  do{
    if(A == num) a = ord;
    if(B == num) b = ord;
    ord++;
  }while(next_permutation(num.begin(), num.end()));

  int ans = abs(a - b);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
//#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m,MOD=1000000007;
	cin>>n>>m;
	vi in(n);
	rep(i,n)cin>>in[i];
	sort(all(in));
	vi dp(n+1);
	dp[0]=1;
	rep(i,n){
		int t=lower_bound(all(in),in[i]-m)-in.begin();
		dp[i+1]=dp[i]*(i-t+1)%MOD;
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 4360
#include <algorithm>
#include <climits>
#include <cstring>
#include <cctype>
#include <inttypes.h>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

const int mod = 1e9 + 7;
const int cap = 3001;
int N;
char s[cap];
int dp[cap][cap];

int add(int x, int y) {
    x += y;
    if (x >= mod)
        x -= mod;
    return x;
}

int main() {
    scanf("%d", &N);
    for (int i = 1; i < N; ++i)
        scanf(" %c", &s[i]);
    fill(&dp[0][0], &dp[0][0] + cap * cap, 0);
    dp[1][1] = 1;

    for (int i = 1; i < N; ++i) {
        if (s[i] == '<') {
            for (int j = 2; j <= i + 1; ++j) {
                dp[i + 1][j] = add(dp[i + 1][j - 1], dp[i][j - 1]);
            }
        }
        else {
            for (int j = i; j > 0; --j) {
                dp[i + 1][j] = add(dp[i + 1][j + 1], dp[i][j]);
            }
        }
        // for (int j = 1; j <= N; ++j)
        //     printf("%d ", dp[i + 1][j]);
        // printf("\n");
    }
    
    int ans = 0;
    for (int i = 1; i <= N; ++i)
        ans = add(ans, dp[N][i]);
    printf("%d\n", ans);
}





Measured memory_bytes: 35456
MAX_COST = 1000000000
NUM, MAX_STEP = gets.split(" ").map(&:to_i)
steps = gets.split(" ").map(&:to_i)
# 各足場に到達するためのコストを格納するdp用配列、初期値は0とする
dp = Array.new(NUM, 0)

# 足場2〜NUMまでの最小コストを順にdpに格納する
1.upto(NUM - 1) do |step_number|
  min = MAX_COST
  # 1〜MAX_STEP歩手前からのそれぞれのコストを確認する
  # ただし足場1より手前に行かないように、step_numberを最大回数とする
  1.upto([MAX_STEP, step_number].min) do |back|
    # back歩手前までのコストと、back歩手前からstep_numberまでのコストを足してminと比較する
    # minより小さければminに格納する
    if min > dp[step_number - back] + (steps[step_number - back] - steps[step_number]).abs
      min = dp[step_number - back] + (steps[step_number - back] - steps[step_number]).abs
    end
  end
  # minをdpに格納する
  dp[step_number] = min
end

puts dp.last

Measured memory_bytes: 11404
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    x = int(input())
    ans = 1
    for i in range(1, x + 1):
        for j in range(2, 11):
            if i ** j <= x:
                ans = max(ans, i ** j)
            else:
                break
    print(ans)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

a aa c ca c a b a ab a b c

"""


Measured memory_bytes: 9456
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int a, b, c;
int ans;
int N;

int main() {
	cin >> N;

	if (N % 2 == 0) {
		ans = N / 2;
	}
	else {
		ans = N / 2 + 1;
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(ll i = 1;i<=n;i++)
#define rep0(i,n) for(ll i = 0;i<n;i++)
#define reps(i,a,n) for(ll i = a;i<=n;i++)
#define sf(n) scanf("%lld",&n)
#define sff(n,m) scanf("%lld %lld",&n,&m)
#define pf(n) printf("%lld\n",n)
#define pfs(s) printf("%s\n",s)
#define bug printf("BUG\n")
#define pfstr(s) printf("%s\n",s.c_str())
#define cs(i,n) printf("Case %lld: %lld\n",i,n)
#define clr(dp,v) memset(dp,v,sizeof dp)
#define pb push_back
#define mpr make_pair
#define PLL pair<ll,ll>
#define ff first
#define ss second
#define mx 300003

int main()
{
ll x,y;
sff(x,y);

if(x%y==0) cout<<"-1"<<endl;
else
{
  if(x==1) cout<<x<<endl;
  else cout<<x*(y-1)<<endl;
}

return 0;
}


Measured memory_bytes: 256
import bisect

N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
ans = 0
for n in range(N):
    i = bisect.bisect_left(A,B[n])
    j = len(C) - bisect.bisect_right(C,B[n])
    ans += i * j
print(ans)

Measured memory_bytes: 23092
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (auto &a: v) {
    cin >> a;
  }

  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  int a = 0;
  for (int i = 0; i < v.size(); i+=2) {
    a += v[i];
  }

  int b = 0;
  for (int i = 1; i < v.size(); i+=2) {
    b += v[i];
  }

  cout << (a - b) << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
        #include <string>
       #include <algorithm>
        using namespace std; 
         
        int main(){
    int a,b,c,counter;
    counter =0;
    cin >> a >> b >> c;
    if(a!=b) counter++;
    if(a!=c) counter++;
    if(c!=b) counter++;
    if( a == b&&b==c) counter++;
     
        cout << counter;
        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define mp(x,y)          make_pair(x,y)
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto& i: a)
#define loop(n,i,a)      for(int i=a;i<n;i++)
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        loop(n,i,0){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define pp               pop_back
#define endl              "\n"
#define copy(a,b)         copy(all(a),back_inserter(b));
#define intersect(a,b,w)    set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w)      set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define diff(a,b,w)       set_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define symdiff(a,b,w)    set_symmetric_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
//int m=10000009;
//int arr[100000];
#define M                   1000000007
#define mm  998244353  
//set<int> st;

signed main()
{
    fast
    int n,m;
    cin>>n>>m;
    cout << n * (n-1) / 2 + m * (m-1) / 2 ; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair<int, int>
#define sz size()
#define pb push_back

using namespace std;

ll n, a[52], sum;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
    }
    for (int i = 1; i < n; i ++) {
        for (int j = i + 1; j <= n; j ++) {
            sum += a[i] * a[j];
        }
    }
    cout << sum;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int d,n;cin>>d>>n;
  if(n==100)n++;

  cout<<n*(int)pow(100,d);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
int h, w;
int a[505][505], b[505][505], c[505][505];
char s[505];
int main () {
	scanf ("%d%d", &h, &w);
	for (int i = 1; i <= h; i++) {
		cin >> s;
		for (int j = 1; j <= w; j++) {
			c[i][j] = (s[j-1] == '#');
			if (c[i][j] == 1) a[i][j] = b[i][j] = 1;
		}
	}
	for (int i = 1; i <= h; i++) a[i][1] = b[i][w] = 1;
	for (int i = 1; i <= h; i++) {
		if (i & 1) for (int j = 1; j < w; j++) a[i][j] = 1;
        else for (int j = 2; j <= w; j++) b[i][j] = 1;
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) printf ("%c", a[i][j] ? '#' : '.');
		puts("");
	}
	puts("");
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) printf ("%c", b[i][j] ? '#' : '.');
		puts("");
	}
    return 0;
}

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

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353
N = n+1
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(k+1):
    ans += cmb(n-1, i, mod) * m * pow(m-1, n-i-1, mod)
    ans %= mod

print(ans)


Measured memory_bytes: 112428
// ABC067_A.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int a, b, x;
	cin >> x >> a >> b;
	if (x < b - a) {
		cout << "dangerous" << endl;
	}
	else if (x >= b - a && 0 < b - a) {
		cout << "safe" << endl;
	}
	else if (0 >= b - a) {
		cout << "delicious" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define endl ("\n")
#define deb(x) cout << (#x) << " = " << (x) << endl;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail
    
    int n, m;
    cin >> n >> m;
    int arr[n+1], brr[m+1];
    for(int i = 0;i < n;i++)
    {
        cin >> arr[i+1];
    }
    for(int j = 0;j < m;j++)
    {
        cin >> brr[j+1];
    }
    long long dp[n+1][m+1];
    for(int i = 0;i <= n;i++)
    {
        for(int j =0 ;j <= m;j++)
        {
            dp[i][j] = 0ll;
            if(i == 0 or j == 0)
                dp[i][j] = 1ll;
        }
    }
    dp[0][0] = 1;
    for(int i = 1;i <= n;i++)
    {
        for(int j = 1;j <= m;j++)
        {
            if(arr[i] == brr[j])
            {
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
            }
            else
            {
                dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1];
            }
            while(dp[i][j] < 0)
            {
                dp[i][j] += mod;
            }
            dp[i][j] %= mod;
        }
    }
    cout << dp[n][m];
    return 0;
}

Measured memory_bytes: 31616
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(ll &x){
    x=0;static char ch;static bool flag;flag = false;
    while(ch=getchar(),ch<'!');if(ch == '-') ch=getchar(),flag = true;
    while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
#define rg register int
#define rep(i,a,b) for(rg i=(a);i<=(b);++i)
#define per(i,a,b) for(rg i=(a);i>=(b);--i)
const ll maxn = 100010;
ll a[maxn],d[maxn],n,m;
ll lazy[maxn<<2],tag[maxn<<2],num[maxn<<2];
void modify(ll rt,ll l,ll r,ll L,ll R,ll v){
    if(L <= l && r <= R){
        lazy[rt] += v;
        return ;
    }
    ll mid = l+r >> 1;
    if(L <= mid) modify(rt<<1,l,mid,L,R,v);
    if(R >  mid) modify(rt<<1|1,mid+1,r,L,R,v);
}
void insert(ll rt,ll l,ll r,ll L,ll R,ll s){
    if(L <= l && r <= R){
        tag[rt] += s;++ num[rt];
        return ;
    }
    ll mid = l+r >> 1;
    if(R <= mid) insert(rt<<1,l,mid,L,R,s);
    else if(L > mid) insert(rt<<1|1,mid+1,r,L,R,s);
    else{
        insert(rt<<1,l,mid,L,mid,(R-mid)+s);
        insert(rt<<1|1,mid+1,r,mid+1,R,s);
    }
}
ll res;
void query(ll rt,ll l,ll r,ll p){
    res += lazy[rt];
    res += tag[rt] + num[rt]*(r - p);
    if(l == r) return ;
    ll mid = l+r >> 1;
    if(p <= mid) query(rt<<1,l,mid,p);
    else query(rt<<1|1,mid+1,r,p);
}
int main(){
    read(n);read(m);
    rep(i,1,n){
        read(a[i]);
        if(i > 1){
            ll x = (a[i] - a[i-1] + m) % m;
            if(a[i] > a[i-1]){
                modify(1,1,m,1,a[i-1],x);
                if(a[i]+1 <= m) modify(1,1,m,a[i]+1,m,x);
                if(a[i-1]+1 <= a[i]) insert(1,1,m,a[i-1]+1,a[i],1);
            }else{
                modify(1,1,m,a[i]+1,a[i-1],x);
                insert(1,1,m,1,a[i],1);
                if(a[i-1]+1 <= m) insert(1,1,m,a[i-1]+1,m,a[i]+1);
            }
        }
    }
    ll ans = 1LL << 60;
    rep(i,1,m){
        res = 0;query(1,1,m,i);
        ans = min(ans,res);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 11136