akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<deque>
using namespace std;

long long N, A, B;

int main(){
    cin >> N >> A >> B;

    if(A + B > N + 1 || A * B < N){
        cout << -1 << endl;
        return 0;
    }

    deque<long long> res;
    int cnt = 0;
    long long resid = N - (A + B - 1);
    for(int b = 0; b < B - 1; b++){
        int tmp = 1 + min(A - 1, resid);
        for(int a = 0; a < tmp; a++){
            res.push_front(cnt + tmp - a);
        }
        cnt += tmp;
        resid -= tmp - 1;
    }
    for(int a = 0; a < A; a++){
        res.push_front(cnt + A - a);
    }
    for(auto itr = res.begin(); itr != res.end(); ++itr){
        cout << *itr << " ";
    }

    cout << endl;
}


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

//for test in *.in; do echo $test; ./a.out < $test ; done
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define pb push_back
#define all(A) A.begin(),A.end()
#define allr(A) A.rbegin(),A.rend()
#define MOD 1000000007
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int32_t main(){
	int n;
	cin >> n;
	vector<string> A(n);
	map<string,int> Map;
	int mx = 0;
	for(auto &a:A){
		cin >> a;
		Map[a]++;
		mx = max(Map[a],mx);
	}
	vector<string> B;
	for(auto m:Map)
		if(m.se==mx){
			B.push_back(m.fi);
		}
	sort(all(B));
	for(auto a:B)
		cout << a << '\n';
#ifdef LOCAL_DEFINE
	cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}







Measured memory_bytes: 28404
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int main() {
    int N; cin >> N;
    vector<string> S(N); rep(i, N) cin >> S[i];

    int cnt = 0, x = 0, y = 0, z = 0;
    rep(i, N) {
        int first = 0;
        int last = S[i].size() - 1;
        rep(j, S[i].size() - 1) {
            if ((S[i][j] == 'A') && (S[i][j + 1] == 'B')) {
                cnt++;
            }
        }

        if ((S[i][first] == 'B') && (S[i][last] == 'A')) {
            z++;
        } else if (S[i][first] == 'B') {
            y++;
        } else if (S[i][last] == 'A') {
            x++;
        }
    }

    // 末尾がA, 先頭がB
    if (z > 0) {
        // 末尾がA, 先頭がBの一つの大きい文字列を作る
        cnt += (z - 1);

        // 先頭にくっつける
        if (x > 0) {
            cnt++;
            x--;
        }

        // 末尾にくっつける
        if (y > 0) {
            cnt++;
            y--;
        }
    }

    cnt += min(x, y);

    cout << cnt << endl;
}


Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <ctime>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;
  	cin >> x;
  	if (x == 0)
    	cout << "1\n";
  	else
    	if (x == 1)
          	cout << "0\n";
    return 0;
}

Measured memory_bytes: 3636
def main():
    N = input()
    p = int(N[0])
    o = 11 - int(N[0])
    for i in N[1:]:
        j = int(i)
        np = min(p + j, o + j)
        no = min(o + 9 - j, p + 11 - j)
        p = np
        o = no
    print(min(p,o))
main()


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

 
int main()
{
    int N,A;

  
    int i=0;
    int j=0;
//    int k=0;
    int max=0;
    int max_ans=0;
  
 // 整数の入力
    scanf("%d", &N);
    scanf("%d", &A);

if(A>=(N%500)){
  printf("Yes\n");
} else {
  printf("No\n");

}


/*
  while(1){

    if(0>X-A-(B*i)) break;
  i++;
  }
*/  
//  printf("%d\n",max_ans);

return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};

const int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int H, W, N; cin >> H >> W >> N;
    int sr, sc; cin >> sr >> sc;
    sr--; sc--;
    string S, T; cin >> S >> T;

    //x
    int xmin = -1, xmax = H;
    bool f = true;
    IREP(i, N){
        if(llabs(xmax - xmin) <= 1) f = false;
        if(xmin != -1 && T[i] == 'D') xmin--;
        if(xmax != H && T[i] == 'U') xmax++;
        if(S[i] == 'D') xmax--;
        if(S[i] == 'U') xmin++;
    }

    //y
    int ymin = -1, ymax = W;
    IREP(i, N){
        if(llabs(ymax - ymin) <= 1) f = false;
        if(ymin != -1 && T[i] == 'R') ymin--;
        if(ymax != W && T[i] == 'L') ymax++;
        if(S[i] == 'R') ymax--;
        if(S[i] == 'L') ymin++;
    }
    Ans(xmin < sr && sr < xmax && ymin < sc && sc < ymax && f, "YES", "NO");

    return 0;
}


Measured memory_bytes: 920
#include <bits/stdc++.h>
#define endl '\n'
#define pi 3.1415926535897932384626433832
#define ll long long
using namespace std;
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / __gcd(a, b); }
bool isPrime(int n) {if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false;
return true;}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin>>t;
	vector<ll> pip(26);
	for(auto &i:pip){
		cin>>i;
	}
	vector<vector<ll>> daw(t,vector<ll>(26));
	for(int i=0;i<t;i++){
		for(int j=0;j<26;j++){
			cin>>daw[i][j];
		}
	}
	vector<int> sou(t);
	for(auto &i:sou){
		cin>>i;
	}
	vector<int> last(26,0);
	ll sat=0;
	for(int i=0;i<t;i++){
		sat+=daw[i][sou[i]-1];
		last[sou[i]-1]=i+1;
		for(int j=0;j<26;j++){
			sat-=pip[j]*(i+1-last[j]);
		}
		cout<<sat<<endl;
	}
	return 0;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6+9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

// ll n,k,a,b,c,d,x,y,z,m,l;
// ll ans;
// vecl arr(N);
// ll dp[509][509];
// ll pre[N];

int sum[N];

void test_case() {
	
    int n, d, a;
    cin>>n>>d>>a;

    vector<pii> arr(n);

    rep(i,n) {
        cin>>arr[i].first >> arr[i].second;
    }

    sort(all(arr));

    int dp[N];

    for(int i=0; i<n; i++) {
        int re = 2*d + arr[i].first;
        pii temp = mpr(re, LONG_MAX);
        auto it = upper_bound(all(arr),temp);
        dp[i] = it - arr.begin();
    }

    int ans =0;
    int num =0;

    for(int i=0; i<n; i++) {
        num+= sum[i];

        if(arr[i].second - num >= 0) {
            int co = ((arr[i].second - num) + a - 1)/a;
            ans+= co;
            num+= co*a;
            sum[dp[i]] -= co*a;
        }
    }

    cout<<ans<<endl;



}


signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while(t--)
    {   
        test_case();
    }
}

Measured memory_bytes: 9428
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

const int N=1e5+5;
const ll inf=1e18;
ll mm[N];


int main(){	
	int n;scanf("%d",&n);
	FER(i,0,n)scanf("%lld",&mm[i]);
	ll pos=-1,mx=inf;
	int c=0;
	FER(i,0,n){
		if(mx>abs(mm[i])){
			mx=abs(mm[i]);
			pos=i;
		}
		if(mm[i]<0)c++;
	}
	ll ans=0;
	FER(i,0,n)ans+=abs(mm[i]);
	if(c%2==0){
		printf("%lld\n",ans);
		return 0;
	}
	ans-=2*mx;
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[200000]={};
  long long sum=0,tsum=0,x;
  cin>>n;
  for(int i=0;i<n;i++){cin>>a[i];tsum+=a[i];}
  long long ans=1000000000000000000;
  for(int i=0;i<n-1;i++){
    sum+=a[i];
    x=abs(sum-(tsum-sum));
    if(x<ans) ans=x;
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 1024
n =int(input())
A = [x for x in list(str(input()))]
B = [x for x in list(str(input()))]
C = [x for x in list(str(input()))]
ans = 0

for i in range(n):
    if A[i] != B[i] and A[i] != C[i] and B[i] != C[i]:
        ans += 2
    elif A[i] == B[i] and A[i] == C[i] and B[i] == C[i]:
        ans += 0
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3064
/**
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define ll long long int
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
#define nl cout<<"\n";
using namespace std;
const ll c=1e9+7;
int main()
{
IOS
ll n;
cin>>n;
vector<ll> a(n),pre(n),post(n);
for(ll i=0;i<n;i++)
{
    cin>>a[i];
    if(i==0)continue;
    else
        pre[i]=pre[i-1]^a[i-1];
}
for(ll i=n-2;i>=0;i--)
{
    post[i]=post[i+1]^a[i+1];
}
cout<<post[0]<<" ";
for(ll i=1;i<n-1;i++)
{
    ll k=pre[i]^post[i];
    cout<<k<<" ";
}
cout<<pre[n-1];
return 0;
}



Measured memory_bytes: 7916
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N, M, X;
	std::vector<int> A;
	std::cin >> N >> M >> X;
	A.resize(M);
	for (auto& a : A) {
		std::cin >> a;
	}
	
	std::vector<int> T;
	T.resize(N+1);
	for (auto a : A) {
		T[a] = 1;
	}
	
	int left = 0;
	int right = 0;
	for (int i = X - 1; i >= 0; --i) {
		left += T[i];
	}
	for (int i = X + 1; i <= N; ++i) {
		right += T[i];
	}
	
	std::cout << std::min(left, right) << "\n";
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>

using namespace std;

int main()
{
	long long n,T;
	cin >> n >> T;
	vector<long long> t(n);
	long long now=T;
	long long ans=T;
	for(int i=0;i<n;i++)
	{
		cin >> t[i];
		if(now<=t[i])
		{
			ans+=T;
			now=t[i]+T;
		}
		else
		{
			ans+=(T-(now-t[i]));
			now=t[i]+T;
		}
	}


	cout << ans << endl;



}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main(void) {

	int a,b;
	int c,i,div;

	scanf("%d %d",&a,&b);
	if(a < b){
		c = a;
		a = b;
		b = c;
	}else if(a == b){
		printf("%d\n",a);
		return 0;
	}
	else {}

	for(div=a%b;div>0;div--){
		if(a % div == 0 && b % div == 0) break;
		else {}
	}
	printf("%d\n",div);
	
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}


ll dp[60][205000];
int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll h,w,k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    ll ans = 0;
    rep(bith, 1 << h){
        rep(bitw, 1 << w){
            ll sum = 0;
            rep(i, h){
                if(bith >> i & 1) continue;
                rep(j, w){
                    if(bitw >> j & 1) continue;
                    if(s[i][j] == '#') sum++;
                }
            }
            if(sum == k) ans++;
        }
    }
    print(ans);


}



Measured memory_bytes: 3664
from functools import reduce
l = int(input())
src = list(map(lambda x: 1 if x=="." else 0, input()))
lb = 0
rw = sum(src)
a = rw
for i in range(l):
  if src[i]==0:
    lb+=1
  else:
    rw-=1
  a = min(a, lb + rw)
  if a==0:
    break
print(a)

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int main()
{
    canhazfast();

    char s[8];

    cin >> s;
    sort(s, s+4);
    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


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

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_153_e
    {
        /// <summary>
        /// テスト環境の動作確認用
        /// </summary>
#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            var ar = ReadIntArray();
            int N = ar[1];
            int H = ar[0];
            int[] A = new int[N];
            int[] B = new int[N];
            for(int i=0;i<N;i++)
            {
                ar = ReadIntArray();
                A[i] = ar[0];
                B[i] = ar[1];
            }

            int ans = solve(H, A, B);

            Console.WriteLine(ans.ToString());
        }

        private static int solve(int h, int[] a, int[] b)
        {
            // 最小の コストを返す
            int[] d = new int[h + 1];

            for(int i=0;i<=h;i++)
            {
                d[i] = int.MaxValue;
            }

            d[0] = 0;

            for (int i=0;i<h;i++)
            {
                if (d[i] == int.MaxValue) continue; // スキップ

                for(int j=0;j<a.Length;j++)
                {
                    // a : モンスターの体力
                    // b : 利用する体力
                    int di = i + a[j];
                    int next_di = d[i] + b[j];
                    
                    if (di > h) di = h; // 最大領域

                    if (next_di < d[di])
                    {
                        d[di] = next_di;
                    }
                }
            }
            return d[h];
        }

        private static int[] ReadIntArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = int.Parse(ss[i]);
            }
            return ar;
        }

#if TEST
#else
    }
}
#endif

Measured memory_bytes: 13220
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using Lf = long double;
using plong = pair<ll,ll>;
const int mod = 1000000007;

class edge{
public:
    ll to;
    ll cost;
};

const ll MAX_V = 100;
const ll INF = 999999999;
ll V=100;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(ll s){
    priority_queue<plong,vector<plong>,greater<plong>> que;
    fill(d,d+V,INF);
    d[s] = 0;
    que.push(plong(0,s));
    while(!que.empty()){
        plong p = que.top();que.pop();
        ll v = p.second;
        if(d[v]<p.first)continue;
        for(ll i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to] = d[v]+e.cost;
                que.push(plong(d[e.to],e.to));
            }
        }
    }
}


int main(){
    ll H,W;
    cin>>H>>W;
    ll C[10][10];
    for(ll i=0;i<10;i++){
        for(ll j=0;j<10;j++){
            ll c;
            cin>>c;
            if(i==j)continue;
            edge e1 = {j,c};
            G[i].push_back(e1);
        }
    }

    map<ll,ll>mp;
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            ll a;cin>>a;
            mp[a]++;
        }
    }
    mp.erase(-1);
    mp.erase(1);
    ll res=0;
    for(auto p:mp){
        dijkstra(p.first);
        res += d[1]*p.second;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
	int N;
	vector<int> a;
	int inputA;
	long sunuke = 0;
	long araiguma = 0;
	vector<long> answer;
	int ans = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> inputA;
		a.push_back(inputA);
		araiguma += inputA;
	}

	for (int i = 0; i < N-1; i++) {
		sunuke += a[i];
		araiguma -= a[i];
		int num = abs(sunuke - araiguma);
		answer.push_back(abs(sunuke-araiguma));
	}

	ans = *min_element(answer.begin(), answer.end());
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
# モジュールのインポート
import math

# 標準入力の取得
A, B, N = list(map(int, input().split()))


def f(x: int) -> int:
    """目的関数

    Arguments:
        x {int} -- 非負整数

    Returns:
        int -- 目的関数値
    """
    return math.floor(A*x/B) - A*math.floor(x/B)


def main() -> None:
    """Entry point
    """
    # 求解処理
    """
    f(x+B) = f(x)より、0 <= x <= (B-1)についてのみ考える.
    このとき、f(x) = floor(Ax/B)であり、これはxについての単調増加関数である.
    よって、求める最大値はf(min(B-1, N))である.
    """
    result = f(min(B-1, N))

    # 結果出力
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9116
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main (void) {
    ll n[3];

    for (int i = 0; i < 3; i++) {
        cin >> n[i];
        if (n[i] % 2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    sort(n, n + 3, greater<ll>());

    cout << n[1] * n[2] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x,a,b;
  cin>>x>>a>>b;
  if(abs(x-a)<abs(x-b))cout<<"A"<<endl;
  else cout<<"B"<<endl;

  return 0;

}


Measured memory_bytes: 256
# Harshad Number
import sys

N = int(input())

def getAns(n) :
    total = 0
    wkN = n
    while wkN > 0 :
        total = total + (wkN % 10)
        wkN = wkN // 10
    if n % total == 0 :
        return "Yes"
    else :
        return "No"

print(getAns(N))

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1000000000;
const ll MOD = 1000000007;
const ll NUM = 101010;


int main(){

    ll N, K, S;
    cin >> N >> K >> S;
    rep(i, N){
        if(i < K)cout << S;
        else if(S < INF)cout << 1000000000;
        else cout << 1;
        if(i + 1 == N)cout << endl;
        else cout << " ";
    }
    
    return 0;
}

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





int main(){

    int n,d;
    cin>>n>>d;
    vector<vector<int>>x(n,vector<int>(d));
    for(int i=0;i<n;i++){
      for(int j=0;j<d;j++){
        cin>>x[i][j];
      }
    }
    
    int count =0;
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        int dis=0;
        for(int k=0;k<d;k++){
          dis+=(x[j][k]-x[i][k])*(x[j][k]-x[i][k]);
          
        }

        for(long long l=1;l<1000;l++){
          if(dis == l*l){
            count++;
          }
        }
      }
    }

    cout<<count<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,y,y1,y2,x,x1,x2,n;
	scanf("%d",&n);
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	if(n%a>0){
		x=n/a+1;
		x1=x*b;
	}
	else{
		x=n/a;
		x1=x*b;
	}
	if(n%c>0){
		y=n/c+1;
		y1=y*d;
	}
	else{
		y=n/c;
		y1=d*y;
	}
	if(x1<y1){
		printf("%d\n",x1);
	}
	else if(x1>y1){
		printf("%d\n",y1);
	}
	else{
		printf("%d\n",x1);
	}
	return 0;
}



Measured memory_bytes: 2756
#include<bits/stdc++.h>
#include <ext/rope>

#define min3(a,b,c)   min(a,min(b,c))
#define max3(a,b,c)   max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))

#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)    __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)       __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)       __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define PI   M_PI
#define endl "\n"
#define sc   scanf
#define pf   printf

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep1(i,n)       for(int i = 0; i < n; i++)
#define rep2(a,b)       for(int i = a; i <= b; i++)
#define rep3(a,b,c)     for(int i = a; i <= b; i+=c)
#define irep(a,b,c)     for(int i = b; i >=a; i-=c)
#define repit(it,type)  for(it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
using namespace __gnu_cxx;

int main()
{
     IOS
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n,i,ans=0;

    cin>>n;

    ll a[n];

    rep1(i,n)
    {
         cin>>a[i];
         ans^=a[i];
    }
    rep1(i,n)
    {
         cout<<(ans^a[i])<<" ";
    }
}



Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007

int main() {
    ll r, D, x;
    cin >> r >> D >> x;
    vector<ll> X(11, x);
    rep(i, 10) {
        X[i + 1] = r * X[i] - D;
        cout << X[i + 1] << endl;
    }
}


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_A
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = n-1; i>=0; i--){
    cin >> a[i];
  }
  for(int i=0; i<n-1; i++){
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
}

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

using namespace std;

const int MOD = 1000000007;

int main(){
    int N, X;
    while(cin >> N >> X){
        vector<int> L(N);
        for(auto& t : L) cin >> t;
        sort(L.rbegin(), L.rend());
        vector<vector<long long>> dp(1, vector<long long>(X+1, 0));
        dp[0][0] = 1;
        for(auto& l : L){
            vector<vector<long long>> next(X/l+1, vector<long long>(X+1, 0));
            for(int i=0;i<dp.size();i++){
                for(int j=0;j<dp[i].size();j++){
                    if(!dp[i][j]) continue;
                    if(j+l <= X){
                        next[i+1][j+l] += dp[i][j];
                        next[i+1][j+l] %= MOD;
                    }
                    next[i][j] += dp[i][j] * (j - i*(l-1) + MOD);
                    next[i][j] %= MOD;
                    for(int d=1;d<=l-1;d++){
                        if(j+d > X) break;
                        next[i][j+d] += 2 * i * dp[i][j];
                        next[i][j+d] %= MOD;
                    }
                    if(i >= 2){
                        for(int d=0;d<=l-2;d++){
                            if(j+d > X) break;
                            next[i-1][j+d] += i * (i-1) * (l-d-1) * dp[i][j];
                            next[i-1][j+d] %= MOD;
                        }
                    }
                }
            }
            dp = next;
        }
        long long res = 0;
        long long f = 1;
        for(int i=1;i<dp.size();i++){
            f = (f*i)%MOD;
            res += f * dp[i][X];
            res %= MOD;
        }
        cout << res << endl;
    }
}

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

public class Main {
	
	private static int n, m, l;
	private static long[][] a, b;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		n = Integer.parseInt(strArr[0]);
		m = Integer.parseInt(strArr[1]);
		l = Integer.parseInt(strArr[2]);
		
		a = new long[n][m];
		b = new long[m][l];
		
		for(int i = 0;i < n;i++){
			a[i] = toLongArray(br.readLine().split(" "));
		}
		
		for(int i = 0;i < m;i++){
			b[i] = toLongArray(br.readLine().split(" "));
		}
		
		
		for(int i = 0;i < n;i++){
			for(int j = 0;j < l;j++){
				System.out.print(get(i, j));
				if(j == l - 1){
					break;
				}
				System.out.print(" ");
			}
			System.out.println();
		}
	}
	
	private static long get(int r, int c){
		long sum = 0;
		for(int i = 0;i < m;i++){
			sum += a[r][i] * b[i][c];
		}
		return sum;
	}
	
	private static long[] toLongArray(String[] strArray){
		long[] arr = new long[strArray.length];
		for(int i = 0;i < arr.length;i++){
			arr[i] = Long.parseLong(strArray[i]);
		}
		return arr;
	}
}

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

int main(void)
{
	int n,m;
	cin >> n >> m;
	int a[m],b[m],c[n] = {0};
	for (int i=0;i<m;i++) {
		cin >> a[i] >> b[i];
		c[a[i]-1]++;
		c[b[i]-1]++;
	}
	for (int i=0;i<n;i++) {
		cout << c[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    
    while(sc.hasNext()){
      a[sc.nextInt() - 1] ++;
    }
    
    for(int i = 0; i < n; i++){
      System.out.println(a[i]);
    }
  }
}

Measured memory_bytes: 66056
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
int main() {
	int n; std::cin >> n;
	std::vector<int> sticks(n); for (auto& s : sticks) std::cin >> s;
	std::sort(sticks.begin(), sticks.end());
	int count = 0;
	for (auto i = 0; i < n; ++i) for (auto j = i + 1; j < n; ++j) for (auto k = j + 1; k < n; ++k) {
		if (i < j && j < k && sticks[i] + sticks[j] > sticks[k]) {
			++count;
		}
	}
	std::cout << count << std::endl;
}

Measured memory_bytes: 888
# 公約数列挙
# 重複する約数は1つにまとまるので注意
def make_common_divisors(x1, x2):
    cd = [1]
    for i in range(2, min(x1, x2) + 1):
        if x1 % i == 0 and x2 % i == 0:
            cd.append(i)
    return cd

A,B,K = map(int,input().split())
print(make_common_divisors(A,B)[-K])

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<math.h>
#include<vector>
using namespace std;
int main(){
    int N;
    cin>>N;
    int A[N],B[N+1];
    int MAX=0;
    cin>>A[0];
    B[0]=A[0];
    MAX+=abs(B[0]);
    for(int i=1;i<N;i++){
        cin>>A[i];
        B[i]=A[i]-A[i-1];
        MAX+=abs(B[i]);
    }
    B[N]=-A[N-1];
    MAX+=abs(B[N]);
    for(int i=0;i<N;i++){
        if(B[i]*B[i+1]<0){
            cout<<MAX-2*min(abs(B[i]),abs(B[i+1]))<<"\n";
        }
        else 
            cout<<MAX<<"\n";
    }
    return 0;

}


Measured memory_bytes: 2048
x,n=map(int,input().split())
if n>0:
	p=list(map(int,input().split()))
	ans,cnt=0,0
	while cnt<=100:
		if x-cnt not in p:
			ans=x-cnt
			break
		if x+cnt not in p:
			ans=x+cnt
			break
		cnt+=1
	print(ans)
else:
	print(x)

Measured memory_bytes: 9192
#include <iostream>
#include <set>
#include <queue>
#include <utility>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    vector<int>t(3);
    vector<vector<int>>board(3, t);
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> board[i][j];
        }
    }
    int n; cin >> n;
    vector<int>b(n);
    for(int i = 0; i < n; i++){
        cin >> b[i];
        //cout << b[i] << endl;
        for(int a = 0; a < 3; a++){
            for(int x = 0; x < 3; x++){
                if(board[a][x] == b[i]){
                    board[a][x] = 0;
                }
            }
        }
    }
    string ans = "No";
    //rows
    if(board[0][0] == board[0][1] && board[0][2] == board[0][0] &&board[0][0] == 0) ans = "Yes";
    if(board[1][0] == board[1][1] && board[1][2] == board[1][0] &&board[1][0] == 0) ans = "Yes";
    if(board[2][0] == board[2][1] && board[2][2] == board[2][0] &&board[2][0] == 0) ans = "Yes";
    
    //check columns
    if(board[0][0] == board[1][0] && board[2][0] == board[0][0] && board[0][0] == 0) ans = "Yes";
    if(board[0][1] == board[1][1] && board[2][1] == board[0][1] && board[0][1] == 0) ans = "Yes";
    if(board[0][2] == board[1][2] && board[2][2] == board[0][2] && board[0][2] == 0) ans = "Yes";
    
    //diagnals
    if(board[0][0] == board[1][1] && board[2][2] == board[0][0] && board[0][0] == 0) ans = "Yes";
    if(board[0][2] == board[1][1] && board[2][0] == board[0][2] && board[0][2] == 0) ans = "Yes";
    
    cout << ans << endl;
    
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double c = 0;
        for (int i = 0;i < N; i++){
            double a = sc.nextDouble();
            String st = sc.next();
            if (st.equals("JPY")) {
                c += a;
            }
            else if (st.equals("BTC")) {
                c += a * 380000;
            }
        }
        System.out.println(c);
    }
}

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

int h,w;

int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            string s;cin>>s;
            if(s=="snuke"){
                char c = 'A'+j;
                cout<<c<<1+i<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
double dp[300000];
int main()
{
	int num, beg, dif;
	scanf("%d%d%d", &num, &beg, &dif);
	dp[0] = 0;
	dp[1] = 1;
	for (int i = 2; i <= num; i++)
	{
		dp[i] = dp[i - 1] + (dp[i - 1] / double(i * 2)) * 2 + 1;
	}
	printf("%lf\n", dp[num] * double(beg + (beg + dif*(2 * num - 1))) / 2.0);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
const int INF = 1<<28;

typedef long long lli;

struct Edge {
  int v, w;
};

typedef vector<vector<Edge> > Graph;

vector<int> bfs(int src, const Graph &g) {
  const int n = g.size();
  vector<int> cost(n, INF);
  queue<int> que;
  cost[src] = 0;
  que.push(src);
  while(que.size()) {
    const int v = que.front();
    que.pop();
    for(int i = 0; i < g[v].size(); ++i) {
      int nv = g[v][i].v;
      if(cost[nv] != INF) continue;
      cost[nv] = cost[v] + 1;
      que.push(nv);
    }
  }
  return cost;
}

int main() {
  for(int N, M, s, t; cin >> N >> M >> s >> t; ) {
    --s; --t;
    Graph G(N);
    for(int i = 0; i < M; ++i) {
      int x, y; cin >> x >> y;
      --x; --y;
      G[x].push_back((Edge){y, 1});
      G[y].push_back((Edge){x, 1});
    }
    vector<int> cs = bfs(s, G);
    vector<int> ct = bfs(t, G);
    int mini = cs[t];
    sort(ct.begin(), ct.end());
    lli res = 0;
    for(int i = 0; i < N; ++i) {
      if(cs[i] == INF) continue;
      int target = mini - 2 - cs[i];
      res += upper_bound(ct.begin(), ct.end(), target)
        - lower_bound(ct.begin(), ct.end(), target);
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 9140
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int n=1;
    int e=3;
    while(n){
        if(e%2==1){
            c-=b;
        }else a-=d;
        if(a<=0 || c<=0 ) n=0;
        e++;
    }

    if(a<=0){
        cout << "No" ENDL;
    }else cout << "Yes" ENDL;
    return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
  int n;
  string s;
  cin >> s;
  n = s.size();
  vector<int> ans(n);
  rep(ri, 2){
    int cnt = 0;
    rep(i, n){
      if(s[i] == 'R') cnt++;
      else {
        ans[i - 1] += (cnt + 1) / 2;
        ans[i] += cnt / 2;
        cnt = 0;
      }
    }

    reverse(ans.begin(), ans.end());
    reverse(s.begin(), s.end());
    rep(i, n){
      if(s[i] == 'L') s[i] = 'R';
      else s[i] = 'L';
    }
  }

  rep(i, n){
    printf("%d%c", ans[i], i == n - 1? '\n': ' ');
  }
}


Measured memory_bytes: 1024
i,p[1000],P;main(n,m){for(;scanf("%d%d",&n,&m)*n;i=P=!printf("%d\n",P)){for(;i-n;P+=p[i++])scanf("%d",p+i);for(qsort(p,n,4,"YXZRPQ\213\0+\2\303");i>=m;)P-=p[i-=m];}}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string s;
	int K;
	cin >> s >> K;
	vector<string>check(1);
	int count = 0;
	for (int i = 0; i <= s.length() - 1; i++) {
		for (int j = 1; j <= K && i + j - 1 <= s.length(); j++) {
			check[count] = s.substr(i, j);
			count++;
			check.resize(count+1);
		}
	}
	int anscount = 0;
	sort(check.begin(), check.end());
	string ans;
	for (int i = 1; i <= count; i++) {
		if (i >= 2) {
			if (check[i] != check[i-1]) {
				anscount++;
			}
		}
		else if(i==1)anscount++;
		if (anscount == K)ans = check[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 4212
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define Ms(s, n) memset(s, n, sizeof(s))
#define Rp(i,l,m) for(int i=l; i<m; ++i)
#define Rpd(i,l,m) for(int i=l; i>=m; --i)
#define Rpp(i,l,m) for(int i=l; i<=m; i++)
#define RpAll(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define All(a) (a).begin(), (a).end()
#define Fi first
#define Se second
#define Pb push_back
#define Pf push_front
#define Is insert
#define Sz(a) int((a).size())
#define ooi INT_MAX
#define ool LLONG_MAX
#define endl "\n"
#define maxx(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline ll gcd(ll a,ll b) {ll r;while(b){r=a%b;a=b;b=r;}return a;}
inline ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
inline ll fpow(ll n,ll k){ll r=1; for(;k;k>>=1){if(k&1)r=r*n%MOD;n=n*n%MOD;}return r;}
const int base = 311;
const int N = 2e5 + 5;

ll m, n, x, y, k, q, ans;
string a[N];

void Solve(){
    string s;
    cin >> s;
    n = Sz(s);
    if(n==1) cout << 1, exit(0);
    string v = "";
    k = 0;
    a[0] = s[0];
    for(int i = 1; i < n; i++){
        v += s[i];
        if(v != a[k]){
            k++;
            a[k] = v;
            v = "";
        }
    }
    if(v != "") k++;
    while(v==a[k - 1]){
        v = a[k - 1] + v;
        k--;
    }
    x = 0;
    a[0] = s[0] +s [1];
    for(int i = 2; i < n; i++){
        v += s[i];
        if(v != a[x]){
            x++;
            a[x] = v;
            v = "";
        }
    }
    if(v != "") x++;
    while(v==a[x - 1]){
        v = a[x - 1] + v;
        x--;
    }
    reverse(s.begin(), s.end());
    v = "";
    m = 0;
    a[0] = s[0];
    for(int i = 1; i < n; i++){
        v += s[i];
        if(v != a[m]){
            m++;
            a[m] = v;
            v = "";
        }
    }
    if(v != "") m++;
    while(v == a[m - 1]){
        v = a[m - 1] + v;
        m--;
    }
    y = 0;
    a[0] = s[0] + s[1];
    for(int i = 2; i < n; i++){
        v += s[i];
        if(v != a[y]){
            y++;
            a[y] = v;
            v = "";
        }
    }
    if(v != "") y++;
    while(v==a[y - 1]){
        v = a[y - 1] + v;
        y--;
    }
    cout << max(max(x,y), max(m, k)) + 1;
}

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







Measured memory_bytes: 11028
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

struct BIT{
  // 1-indexed BIT
private:
  int N; vector<int> bit;
public:
  BIT(int size){
    N = size;
    bit.assign(N+1, 0);
  }
  void add(int a, int w){
    for(int x = a; x <= N; x += x & -x)
      bit[x] += w;
  }
  int sum(int a){ // prefix sum
    int res = 0;
    for(int x = a; x > 0; x -= x & -x)
      res += bit[x];
    return res;
  }
};

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

  int N, A[200000]; cin >> N;
  int origA[200000];
  REP(i, N){
    cin >> A[i];
    origA[i] = A[i];
  }
  sort(A, A+N);
  map<int, int> mp;
  REP(i, N){
    mp[A[i]] = i+1;
  }
  REP(i, N){
    origA[i] = mp[origA[i]];
  }
  BIT b(N);
  int ans = 0;
  REP(i, N){
    ans += i - b.sum(origA[i]);
    b.add(origA[i], 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 19996
def prime_decomp(n):
    i = 2
    table = []
    while i*i <= n:
        while n%i == 0:
            n /= i
            table.append(i)
        i += 1
    if n> 1:
        table.append(n)
    table = [int(i) for i in table]
    return table


A, B = map(int, input().split())
As = set(prime_decomp(A))
Bs = set(prime_decomp(B))
cnt = 1
for a in As:
    if a in Bs:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064