akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const int INF = INT_MAX / 2;

vector<vector<int>> edges;
map<int, int> dists;

void solve(const int start, const int N) {
    vector<int> dist(N, INF);
    dist[start] = 0;

    queue<int> q;
    q.push(start);

    while (!q.empty()) {
        int cur = q.front();
        q.pop();

        for (auto next : edges[cur]) {
            if (dist[next] != INF) {
                continue;
            }

            dist[next] = dist[cur] + 1;
            q.push(next);
        }
    }

    for (int i = 0; i < N; i++) {
        dists[dist[i]]++;
    }
}

int main(void) {
    int N, X, Y;
    cin >> N >> X >> Y;

    edges.resize(N);
    for (int i = 0; i < N; i++) {
        if (i != N - 1) {
            edges[i].push_back(i + 1);
        }
        if (i != 0) {
            edges[i].push_back(i - 1);
        }
    }
    edges[X - 1].push_back(Y - 1);
    edges[Y - 1].push_back(X - 1);

    for (int i = 0; i < N; i++) {
        solve(i, N);
    }

    for (int i = 1; i < N; i++) {
        cout << dists[i] / 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 512
N, A, B = map(int, input().split())

sum_n = 0
for n in range(1, N+1):
    total = 0
    q = n
    while True:
        q, mod = divmod(q, 10)
        total += mod
        if q == 0:
            break
    if A <= total and total <= B:
        sum_n += n
    
print(sum_n)


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

using ll = long long;

// 繰り返し自乗法(x^nをmで割った余り) O(logn)
ll power(ll x, ll n, ll m) {
  ll res = 1;
  if (n > 0) {
    res = power(x, n / 2, m);
    if (n % 2 == 0) res = (res * res) % m;
    else res = (((res * res) % m) * x) % m;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  string x;
  cin >> n >> x;
  
  ll stand = 0;
  for (int i = 0; i < n; i++) {
    if (x[i] == '1') stand++;
  }
  
  ll stand1 = stand - 1, stand2 = stand + 1;
  
  ll sum1 = 0, sum2 = 0;
  if (stand > 0) {
    for (ll i = 0; i < n; i++) {
      if (x[i] == '1') {
        if (stand1 > 0) {
          sum1 += power(2, n - 1 - i, stand1);
          sum1 %= stand1;
        }
        sum2 += power(2, n - 1 - i, stand2);
        sum2 %= stand2;
      }
    }
  }
  
  for (ll i = 0; i < n; i++) {
    ll keep;
    if (x[i] == '1') {
      if (stand1 == 0) {
        cout << 0 << '\n';
        continue;
      }
      keep = sum1;
      keep -= power(2, n - 1 - i, stand1);
      keep += stand1;
      keep %= stand1;
    }
    else {
      keep = sum2;
      keep += power(2, n - 1 - i, stand2);
      keep %= stand2;
    }
    //cout << keep << endl;
    /*if (keep == 0) {
      cout << 0 << '\n';
      continue;
    }*/
    
    ll ans = 1;
    while (keep > 0) {
      keep = keep % __builtin_popcount(keep);
      ans++;
    }
    
    cout << ans << '\n';
  }
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;



signed main(){
	int N;
	cin>>N;
	string s;
	cin>>s;
	int ans = 1;
	REP(i,N-1){
		if(s[i]!=s[i+1])ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
def christmas_eve(n,k,h):
    _h = sorted(h)
    opt = 0
    ans = 10**9 + 1
    _k = k - 1
    loop = n - _k
    for i in range(loop):
        opt = _h[i+_k] - _h[i]
        if ans >= opt:
            ans = opt

    return ans
if __name__ == '__main__':
    n,k = map(int,raw_input().split())
    h = [int(raw_input()) for _ in range(n)]

    print christmas_eve(n,k,h)

Measured memory_bytes: 9716
N,M,C=(int(x) for x in input().split())
B=input().split()
for i in range(M):
    B[i]=int(B[i])
count=0
for i in range(N):
    A=input().split()
    for i in range(M):
        A[i]=int(A[i])
    K=C
    for i in range(M):
        K+=A[i]*B[i]
    if K>0:
        count+=1
print(count)


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

using namespace std ;

int main ()
{
    int a , b , c , d ;
    cin >> a >> b >> c >> d ;
    if ( b >= a ){
        cout << a * c ;
        return 0 ;
    }
    cout << ( ( ( a - b ) * d ) + ( b * c ) ) ;
    return 0 ;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, L;
    cin >> N >> L;

    vector<ll> A(N);
    vector<ll> B(N-1);

    REP(i, N){
        cin >> A[i];
    }
    REP(i, N-1){
        B[i] = A[i] + A[i+1];
    }

    ll bmax = 0;
    ll bid = 0;
    REP(i ,N-1){
        if(B[i] > bmax){
            bmax = B[i];
            bid = i;
        }
    }
    if(bmax < L){
        cout << "Impossible" << endl; 
    }
    else{
        cout << "Possible" << endl; 
        for(ll i=0; i<=bid-1; i++){
            cout << i+1 << endl;
        }
        for(ll i=N-2; i>=bid+1; i--){
            cout << i+1 << endl;
        }
        cout << bid+1 << endl;
    }
    return 0;
}

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

int func(string &str){
  int front;
  for(front=0;front<str.size()&&!str[front];++front);
  if(front==str.size()){
    return 0;
  }
  string backup = str;
  int res = 100000;
  for(int back = front;back<str.size();++back){
    for(int j=back;j>=front;--j){
      str[j] = (str[j] - str[front]+10)%10;
    }
    res = min(res, 1+func(str));
    str=backup;
  }
  return res;
}
int main(){
  int N;
  while(cin >> N && N){
    string a, b;
    cin>>a>>b;
    for(int i=0;i<N;++i){
      a[i] = (a[i] - b[i] + 10) % 10;
    }
    cout << func(a) << endl;
  }
  return 0;
}



Measured memory_bytes: 3036
def PrintArr(a)
	a.length.times { |i|
		print " " unless i == 0
		print a[i]
	}
	puts
end

def InsertionSort(a, g)
	for i in g...a.length
		v = a[i]
		j = i - g
		while j >= 0 and v < a[j]
			a[j+g] = a[j]
			j = j - g
			$cnt += 1
		end
		a[j+g] = v
	end
end

a = Array.new
gets.to_i.times { a << gets.to_i }

$cnt = 0
g = Array.new
m = 0
n = 0

while true
	n += 3**m
	break if n > a.length
	g << n
	m = g.length
end

g.sort!.reverse!

for i in 0...m
	InsertionSort(a, g[i])
end

puts m
PrintArr(g)
puts $cnt
a.each {|n| puts n }

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

typedef pair<ll,ll> P;
int main(){
    ll n,m;
    cin>>n>>m;
    vector<vector<ll>> lis(n,vector<ll>());
    rep(i,m){
        ll u1,u2;
        cin>>u1>>u2;
        lis[u1-1].push_back(u2-1);
    }
    ll s,t;
    cin>>s>>t;
    vector<vector<ll>> mini(n,vector<ll>(3,1e9));
    queue<P> que;
    que.push(P(s-1,0));
    mini[s-1][0]=0;
    while(que.size()){
        ll p=que.front().first;
        ll l=que.front().second;
        ll nl=(l+1)%3;
        que.pop();
        for(ll to:lis[p]){
            if(mini[to][nl]==1e9){
                mini[to][nl]=mini[p][l]+1;
                que.push(P(to,nl));
            }
        }
    }
    if(mini[t-1][0]==1e9){
        cout<<-1<<endl;
    }else{
        cout<<mini[t-1][0]/3<<endl;
    }
}


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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    ll cnt = 0;
    rep(i, n) {
        ll d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2)
            cnt++;
        else
            cnt = 0;
        if (cnt == 3) {
            cout << "Yes" << '\n';
            return;
        }
    }
    cout << "No" << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main () {
  int a, b, c;
  char k, m, d;
  cin >> k >> m >> d;
  a = ((k == 'A') ? 0 : 1);
  b = ((m == 'A') ? 0 : 1);
  c = ((d == 'A') ? 0 : 1);
  int an = a + b + c;
  if (an == 0 || an == 3) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());

		if (b-a > x){
			System.out.println("dangerous");
		}else if (b-a > 0){
			System.out.println("safe");
		}else {
			System.out.println("delicious");
		}
	}
}

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

typedef long long ll;
void solve()
{
	int n;
	ll i,j,W;
	cin>>n>>W;
	vector <ll> wt(n+1);
	vector <ll> val(n+1);
	for(i=0;i<n;i++)
		cin>>wt[i]>>val[i];
	vector <vector <ll>>dp(n+1,vector <ll>(W+1,0));
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=W;j++)
		{
			if(j<wt[i-1])
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i-1]]+val[i-1]);
		}
	}
	cout<<dp[n][W]<<"\n";
}
int main()
{
	solve();
	return 0;
}

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

int main() {
  int N, H, W;
  int res{0};
  std::cin >> N >> H >> W;
  for (int i = 0; i < N; i++) {
    int a, b;
    std::cin >> a >> b;
    if (a >= H && b >= W) res++;
  }
  std::cout << res << std::endl;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int X; cin >> X;
    int A, B; cin >> A >> B;
    X-=A;
    while(X >= B) X -= B;
    cout << X << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int a,b;
    vector<pair<int,int>> c;

    pair<int,int> buf;
    while(cin >> a >> b){
        if(a == 0 && b == 0){
            break;
        }

        buf.first = a;
        buf.second = b;

        c.push_back(buf);
    }

    for(auto k : c){
        a = k.first;
        b = k.second;

        for (int c = 0; c < a; ++c) {
            for (int d = 0; d < b; ++d) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3088
function main(input) {
    input = input.split(" ");
    var k = input[0];
    var x = input[1];

    if (500*k >= x) {
        console.log("Yes");
    } else {
        console.log("No");
    }
  }
   
  main(require("fs").readFileSync("/dev/stdin", "utf8"));

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


vector<pair<long long,long long> > vec;

int main (){
	int n,m;cin>>n>>m;
	for(long long i=0;i<n;i++){
		long long x,y;cin>>x>>y;
		vec.push_back(make_pair(x,y));
	}
	sort(vec.begin(),vec.end());
	ll ans=0;
	for(long long i=0;i<n;i++){
		if(m>=vec[i].second) ans+=1ll*vec[i].second*vec[i].first,m-=vec[i].second;
		else {
			ans+=vec[i].first*m;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2420
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[][] dp;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int X = sc.nextInt();
        for (int i = X - K + 1; i < K + X; i++) {
            System.out.print(i + " ");
        }
        System.out.println();
    }
}

Measured memory_bytes: 22612
#define pb push_back
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int n, q;
typedef struct Node{
	int t;
	string name;
	Node(int ttt, string nnn){
		t = ttt; name = nnn;
	}
} node;
string s;
int t;
void solve(){
	cin >> n >> q;
	queue<Node*> qq;
	for(int i = 0; i < n; i++){
		cin >> s >> t;
		Node* nn = new Node(t, s);
		qq.push(nn);
	}
	int count = 0;
	while(qq.size()){
		Node* nn = qq.front(); qq.pop();
		if(nn->t <= q){
			cout << nn->name << " " << (count + nn->t) << endl;
			count += nn->t;
		}else{
			nn->t -= q;
			qq.push(nn);
			count += q;
		}
		
	}
}
int main(){
	solve();
	
	return 0;
}


Measured memory_bytes: 7464
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"input();a=['']\n"
"for i in input().split():a.insert(int(i)-1,i)\n"
"print(*a[-1]and[-1]or a)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n, a, b;
  cin >> n >> a >> b;

  string s;
  cin >> s;

  ll pa=0, pb=0, pc=0, cl=0;
  REP(i, n){
    if(s[i] == 'a'){
      if(cl < a + b){
        cl++;
        cout << "Yes" << endl;
      }
      else cout << "No" << endl;
    }
    else if(s[i] == 'b'){
      pb++;
      if(cl < a + b && pb <= b){
        cl++;
        cout << "Yes" << endl;
      }
      else cout << "No" << endl;
    }
    else cout << "No" << endl;;
  }

  return 0;
}


Measured memory_bytes: 848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int A, B, C, D, E;
	cin >> A >> B >> C >> D >> E;

	int kotae = -1;
	kotae += (A + 9) / 10;
	kotae += (B + 9) / 10;
	kotae += (C + 9) / 10;
	kotae += (D + 9) / 10;
	kotae += (E + 9) / 10;

	A = (A - 1) % 10 + 1;
	B = (B - 1) % 10 + 1;
	C = (C - 1) % 10 + 1;
	D = (D - 1) % 10 + 1;
	E = (E - 1) % 10 + 1;

	kotae *= 10;
	int a[5];
	a[0] = A;
	a[1] = B;
	a[2] = C;
	a[3] = D;
	a[4] = E;
	kotae += *min_element(a, a + 5);

	co(kotae);

	Would you please return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<ll> cnt(60,0);
    ll a;
    for (int i = 0;i < n;++i) {
        scanf("%lld",&a);
        for (int j = 0;j < 60;++j) if ((a>>j)&1) cnt[j]++;
    }
    ll ans = 0;
    for (int i = 0;i < 60;++i) (ans += (1LL<<i)%mod*cnt[i]%mod*(n-cnt[i])%mod) %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n;
    cin >> n;
    int a = 1;
    while(a*2 <= n) {
        a *= 2;
    }
    cout << a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int n;
long M, m, s;

int main(void) {
  cin >> n;

  M = -1000000;
  m =  1000000;
  s = 0;

  REP(i, 0, n) {
    long a;
    cin >> a;
    M = max(M, a);
    m = min(m, a);
    s += a;
  }

  cout << m << " " << M << " " << s << endl;

  return 0;
}

Measured memory_bytes: 1168
N = int(input())
S = input()

res = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            x = S.find(str(i))
            y = S.find(str(j), x + 1)
            z = S.find(str(k), y + 1)

            if -1 < x < y < z:
                res += 1

print(res)

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

#define MAX_N 100100

ll GCD(ll a, ll b) {
    if (a <= 0 || b <= 0) {
        return -1;
    }
    if (a > b) {
        if (a % b == 0) {
            return b;
        } else {
            GCD(b, a % b);
        }
    } else if (a < b) {
        if (b % a == 0) {
            return a;
        } else {
            GCD(a, b % a);
        }
    } else {
        return a;
    }
}

bool IsPrime(int n) {
    for (ll i = 2; i*i <= n; i++) {
        if (n%i == 0) {
            return false;
        }
    }
    return n != 1;
}

ll prime[MAX_N];
bool is_prime[MAX_N+1];
ll sieve(ll n) {
    ll p = 0;
    rep (i, n+1) {
        is_prime[i] = true;
    }
    is_prime[0] = is_prime[1] = false;
    for (ll i = 2; i <= n; i++) {
        if (is_prime[i]) {
            prime[p++] = i;
            for (ll j = 2*i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return p;
}

vector<ll> Divisor(int n) {
    vector<ll> res;
    for (ll i = 1; i*i <= n; i++) {
        if (n%i == 0) {
            res.push_back(i);
            if (i != n/i) {
                res.push_back(n/i);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}

/*
map<ll, ll> mPrimeFactor(int n) {
    map<ll, ll> res;
    for (ll i = 2; i*i <= n; i++) {
        while (n%i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) {
        res[n] = 1;
    } else {
        return res;
    }
}
*/

vector<Pll> PrimeFactor(ll n) {
    vector<Pll> res;
    for (ll i = 2; i*i <= n; i++) {
        if (n%i) {
            continue;
        }
        res.emplace_back(i, 0);
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) {
        res.emplace_back(n, 1);
    }
    return res;
}

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

    ll N, P;
    cin >> N >> P;

    vector<Pll> p = PrimeFactor(P);
    ll ans = 1;
    rep (i, p.size()) {
        if (p[i].second >= N) {
            ans *= pow(p[i].first, (p[i].second/N));
        }
    }

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

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

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

	if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	else if (a == b) {
		cout << "a == b" << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const ll oo = 1e18;
const int mod = 1e9+7;
const int maxn = 1e4 + 50;

string k;
int d,n;
ll dp[maxn][110][2];

ll calc(int idx,int r,bool e){
	if(idx == n)return (r == 0);
	ll &ret = dp[idx][r][e];
	if(ret != -1)return ret;
	ret = 0;
	for(int i=0;i<10;i++){
		if(i > k[idx] - '0' && e)continue;
		bool q = e;
		if(i < k[idx] - '0')q = 0;
		ret = (ret + calc(idx + 1,(r + i)%d, q)) % mod;
	}
	return ret;
}

int main(){
	memset(dp,-1,sizeof(dp));
	cin>>k>>d;
	n = k.size();
	cout << (calc(0,0,1) - 1 + mod)%mod << endl;
}

Measured memory_bytes: 18432
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 2e5 + 10;

vector<int> g[N], stk;
int pref_max[N], ans[N], lazy[N];

void dfs(int u, int p, int mxp, int since);
void dfs2(int u, int p, int lz);

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i < n; ++i) {
		int u, v;
		cin >> u >> v;
		g[u].pb(v); g[v].pb(u);
	}
	stk.pb(0);
	dfs(1, 0, 1, 0);
	dfs2(1, 0, 0);
	for (int i = 2; i <= n; ++i) {
		cout << ans[i] - 1 << ' ';
	}
	cout << endl;
}

void dfs(int u, int p, int mxp, int since) {
	stk.pb(u);
	int k = stk.size();
	pref_max[k - 1] = max(pref_max[k - 2], u);
	int ch = stk[mxp];
	if (mxp < k - 1) {
		ch = stk[mxp + 1];
		if (pref_max[mxp - 1] > since) {
			ch = stk[mxp];
		}
	}
	++lazy[ch];
	for (auto &v : g[u]) {
		if (v == p) {
			continue;
		}
		if (v < stk[mxp]) {
			dfs(v, u, mxp, max(since, v));
		} else {
			dfs(v, u, k, 0);
		}
	}
	stk.pop_back();
}

void dfs2(int u, int p, int lz) {
	ans[u] = lz + lazy[u];
	for (auto &v : g[u]) {
		if (v == p) {
			continue;
		}
		dfs2(v, u, lz + lazy[u]);
	}
}

Measured memory_bytes: 30712
#include <iostream>

using namespace std;

int main() 
{
    int x, y, z, i;
    for (i=1; i<=3000; i++)
    {
       cin >> x >> y ; 
     if (x == 0 && y == 0)  
       break;
     if (x > y){
     
      z = y;
      y = x;
      x = z;
     }

      cout << x << " " << y << endl;
    }
    if (x < y)
    cout << x << " " << y << endl;
    
    
}


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

typedef long long ll;

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    ll x[N];
    for(int i=0;i<N;i++) cin >> x[i];
    ll ans=0;
    for(int i=1;i<N;i++){
        ll s=(x[i]-x[i-1])*A;
        if(s<B){
            ans+=s;
        }else{
            ans+=B;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

H, W = map(int, input().split())

C = [0] * 10
for i in range(10):
    C[i] = list(map(int, input().split()))

A = [0] * H
for i in range(H):
    A[i] = list(map(int, input().split()))

for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][k] + C[k][j], C[i][j])

ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] == -1 or A[i][j] == 1:
            continue
        ans += C[A[i][j]][1]
print(ans)



Measured memory_bytes: 68832
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

const int MAX_H = 100;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
// const int BASE  = 1000000000 + 7;          // 10^9 + 7
// const int INFI  = 1000000000 + 7;          // 10^9 + 7
// const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

int H, W;
string M[MAX_H];
int CNT[26];

bool check() {
  if (H % 2 == 0 && W % 2 == 0) {
    for (int i = 0; i < 26; i++) {
      if (CNT[i] % 4 != 0) return false;
    }
    return true;
  } else if (H % 2 != 0 && W % 2 != 0) {
    int a = 0, b = 0;
    for (int i = 0; i < 26; i++) {
      if (CNT[i] % 4 == 1) b++;
      else if (CNT[i] % 4 == 2) a++;
      else if (CNT[i] % 4 == 3) { a++; b++; }
    }
    if (b != 1) return false;
    return (2 * a <= H + W - 2);
  } else {
    int a = 0;
    for (int i = 0; i < 26; i++) {
      if (CNT[i] % 2 != 0) return false;
      if (CNT[i] % 4 != 0) a++;
    }
    if (H % 2 == 0) {
      return (2 * a <= H);
    } else {
      return (2 * a <= W);
    }
  }
}

void solve() {
  for (int i = 0; i < 26; i++) CNT[i] = 0;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int c = (int) (M[i][j] - 'a');
      CNT[c]++;
    }
  }

  if (check()) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

int main() {
  cin >> H >> W;
  for (int i = 0; i < H; i++) cin >> M[i];

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

map<int64_t, int> prime_factor(int64_t n)
{
    map<int64_t, int> ret;
    for (int64_t i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

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

    vector<ll> v(n + 1, 0);

    for (int i = 1; i <= n; i++)
    {
        auto p = prime_factor(i);
        
        for (auto x : p)
        {
            v[x.first] += x.second;
        }
    }

    ll ans = 0;

    for (int i = 0; i <= n; i++)
    {
        if (v[i] >= 74)
        {
            ans++;
        }
    }

    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            if (i == j)
            {
                continue;
            }

            if (v[i] >= 2 && v[j] >= 24)
            {
                ans++;
            }

            if (v[i] >= 4 && v[j] >= 14)
            {
                ans++;
            }
        }
    }

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

                if (v[i] >= 4 && v[j] >= 4 && v[k] >= 2)
                {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
// scanf 等でエラーを出さないように追加
#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <memory>
#include <algorithm>
#include <numeric>
#include <set>
#include <functional>
#include <utility>


using namespace std;


typedef long long ll;





int main() {

	char A[128], B[128];
	scanf("%s", A);
	scanf("%s", B);

	if (strlen(A) > strlen(B)) {
		printf("GREATER\n");
		return 0;
	}
	else if (strlen(A) < strlen(B)) {
		printf("LESS\n");
		return 0;
	}
	else {
		if (A[0] > B[0]) {
			printf("GREATER\n");
			return 0;
		}
		else if (A[0] < B[0]) {
			printf("LESS\n");
			return 0;
		}
		else {
			printf("EQUAL\n");
			return 0;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef unsigned long long ull;

const int MOD = 1000000007 ; //  , 1000000009 , 1000000023 ,998244353
const ll INF = ll(1e18);
const ld PI = 4*atan((ld)1);

ll power(ll x,ll n) {
  ll result=1;
  while(n>0){
    if(n&1)result = ((result) * (x));
    
    x=((x)*(x));
    
    n >>= 1;
  }
  return result;
}
ll gcd(ll a,ll b){
  if(a==0)return b;
  return gcd(b%a,a);
}

int main() {
  #ifdef AVI  
    freopen("input.txt" , "r" , stdin);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  
  ll a,b,c;
  cin >> a >> b >> c;
  if(a+b+c>=22)cout << "bust";
  else cout << "win";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<" ";
	if(a+b>=n)
		cout<<a+b-n<<endl;
	else
		cout<<"0"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
	int a,b,i,j,l,flag=0,count=0,ccount=0;
	char s[25];
	scanf("%s",s);
	l=strlen(s);


    for(i=1;i<l;i++){
        if(s[i]>='a'&&s[i]<='z') count++;
    }
    for(i=2;i<l-1;i++){
        if(s[i]=='C') ccount++;
    }
    if(count==l-2&&s[0]=='A'&&ccount==1){
        printf("AC\n");
    }
    else  printf("WA\n");


	return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m, x, ans = INF32; cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int> (m));
	for(int i = 0; i < n; i++)
	{
		cin >> c[i];
		for(int j = 0; j < m; j++) cin >> a[i][j];
	}
	for(int i = 1; i < (1<<n); i++)
	{
		int ii = i, jj = 0, cur = 0;
		bool shit = 1;
		vector<int>u(m);
		while(ii){
            if(ii&1){
            cur += c[jj];
            for(int j = 0;j<m;j++) u[j] += a[jj][j];
            }
            ii /= 2;
            jj++;
		}
		for(int j = 0;j<m;j++){
      if(u[j]<x){shit = 0;break;}
		}
		if(shit)ans = min(ans,cur);
    }
    if(ans == INF32) cout << -1;
    else cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3612
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String strstr = sc.next();
		char[] str = strstr.toCharArray();
		char[] rs = new char[str.length];
		for(int i=0;i<str.length;i++){
			rs[i] = str[str.length-i-1];
		}
		System.out.println(rs);
	}
}

Measured memory_bytes: 26064
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        s: String,
    }
    if n&1==1 {
        println!{"No"};
        return;
    }
    let (s1, s2) = s.split_at(n/2);
    println!("{}", if s1==s2 {"Yes"} else {"No"});
}


Measured memory_bytes: 2120
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let mut var: Vec<u32> = (0..3).map(|_| read()).collect();
    var.sort();
    let is_sad  = (var[0] == var[1] && var[0] != var[2]) || (var[1] == var[2] && var[0] != var[1]);
    if is_sad {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import itertools
N, M = map(int, input().split())
xyz = list()
for n in range(N):
    xyz.append([int(x) for x in input().split()])
ans = 0
for a,b,c in itertools.product([-1,1], repeat=3):
    tmp = []
    for x, y, z in xyz:
        tmp.append(a*x+b*y+c*z)
    tmp.sort(reverse=True)
    ans = max(ans, sum(tmp[:M]))
print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s, t;
	cin >> s >> t;

	vector<vector<int>> dp(s.length() + 1, vector<int>(t.length() + 1));

	for (int i = 1, s_len = (int)s.length(); i <= s_len; i++) {
		for (int j = 1, t_len = (int)t.length(); j <= t_len; j++) {

			if (s[i - 1] == t[j - 1] && dp[i][j] < dp[i - 1][j - 1] + 1) dp[i][j] = dp[i - 1][j - 1] + 1;
			else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

		}
	}
	
	string ans;
	int x = (int)s.length(), y = (int)t.length();
	while (x > 0 && y > 0) {

		if (dp[x][y] == dp[x - 1][y]) x--;
		else if (dp[x][y] == dp[x][y - 1]) y--;
		else {
			ans.push_back(s[x - 1]);
			x--, y--;
		}
	}

	reverse(ans.begin(), ans.end());
	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 35584
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

#define PUDDLE 0
#define FLAGSTONE 1
#define START 2
#define HOLE 3
#define FOOD 4

#define MAX 6

struct Data{int x,y,hp,time;};

int main()
{
  int w,h,ans;
  int i,j;
  int sx,sy;
  int dx[4]={0,1,0,-1};
  int dy[4]={-1,0,1,0};
  while(cin>>w>>h,w|h){
    vector< vector<int> > d(h+2,vector<int>(w+2,PUDDLE));
    vector< vector<int> > visited(h+2,vector<int>(w+2,0));
    queue<Data> q;

    for(i=1;i<=h;i++)for(j=1;j<=w;j++){
      cin>>d[i][j];
      if(d[i][j]==2){sy=i;sx=j;}
    }

    ans=-1;
    Data ant={sx,sy,MAX,0};
    q.push(ant);
    while(q.size()){
      Data ant=q.front();
      q.pop();
      if(d[ant.y][ant.x]==PUDDLE)continue;
      if(ant.hp==0)continue;
      if(visited[ant.y][ant.x]>=ant.hp)continue;
      if(d[ant.y][ant.x]==FOOD)ant.hp=MAX;
      if(d[ant.y][ant.x]==HOLE){
	ans=ant.time;
	break;
      }
      ant.hp--;
      ant.time++;
      visited[ant.y][ant.x]=ant.hp;
      for(i=0;i<4;i++){
	Data t={ant.x+dx[i],ant.y+dy[i],ant.hp,ant.time};
	q.push(t);
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int sum = 0;
    bool flag = false;
    int pos = 0;
    for(int i = 1; i <= n; i++)
    {
        sum += i;
        if(n == sum)
        {
            flag = true;
            pos = i;
            break;
        }
    }
    if(!flag)
    {
        cout << "No" << endl;
        return 0;
    }
    vector<vector<int>> ans(pos+1);
    int i = 1;
    int x = pos;
    int cur = 1;
    while(cur <= n)
    {
        for(int j = 1; j <= x; j++)
        {
            ans[pos-x].push_back(cur);
            ans[pos-x+j].push_back(cur);
            cur++;
        }
        x--;
    }
    cout << "Yes" << endl;
    cout << pos+1 << endl;
    for(int i = 0; i <= pos; i++)
    {
        cout << pos << " ";
        for(int j = 0; j < pos; j++)
        {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}




Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
const ll M=1000000007;
//------------------------------------------//

int main(){
    int H,W;cin>>H>>W;
    char C[H][W];
    char A[2*H][W];
    rep(i,H){
        rep(j,W){
            cin>>C[i][j];
            A[2*i][j]=C[i][j];
            A[2*i+1][j]=C[i][j];
        }
    }
    rep(i,2*H){
        rep(j,W){
            cout<<A[i][j];
        }
    cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3652
n = int(input())
s = input()

E = [0]*(n)
eCount = 0
for i in range(n):
    E[i] = eCount
    if s[i] == 'W':
        eCount += 1

W = [0]*n
wCount = 0
for i in range(n-1, -1, -1):
    W[i] = wCount
    if s[i] == 'E':
        wCount += 1

ans = E[0] + W[0]
for i in range(1, n):
    ans = min(ans, E[i]+W[i])

print(ans)

Measured memory_bytes: 75336
#include <stdio.h>
int main(){
    int k,n,i,value=0,count=1,temp=0;
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++){
        if(value>=k){
            count+=k;
            value=count;
        }
        else{
            count=count*2;
            value=count;
        }
    }
    printf("%d\n",value);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")



int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	vector<ll> F(N);
	REP(i, 0, N) cin >> A[i];
	REP(i, 0, N) cin >> F[i];
	sort(A.begin(), A.end(), greater<ll>());
	sort(F.begin(), F.end(), less<ll>());
	auto calc = [&](ll X) {
		ll ret = 0;
		REP(i, 0, N) ret += max(A[i] - X / F[i], 0LL);
		return ret;
	};
	ll l = -1;
	ll r = (ll)1e18;
	while (r - l > 1) {
		ll mid = l + (r - l) / 2;
		if (calc(mid) <= K) r = mid;
		else l = mid;
	}
	PRI(r);
	return 0;
}




Measured memory_bytes: 6428
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> PII;
#define MOD (1000000007ll)

int main(void){
	int a,b,c,i,j,k,x,ans=0;
	cin >> a >> b >> c >> x;
	for(i=0; i<=a; i++){
		for(j=0; j<=b; j++){
			for(k=0; k<=c; k++){
				if(500*i+100*j+50*k == x){
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()
previous_c = S[0]
present_c = ""
total_count = 1
for c in S[1:]:
    present_c += c
    if present_c != previous_c:
        total_count += 1
        previous_c = present_c
        present_c = ""

    else:
        pass
print(total_count)


Measured memory_bytes: 3500
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
struct stu{
 int x;
 long long y;
 int z;
};
stu  c[120000];
int cmp(stu xx,stu yy){
 if(xx.x==yy.x)
 return xx.y<yy.y;
 else
 return xx.x<yy.x;
}
int cmpp(stu xxx,stu yyy)
{
 return xxx.z<yyy.z;
}
int main()
{
 int n,m;
 cin>>n>>m;
 for(int i=0;i<m;i++)
 {
  cin>>c[i].x>>c[i].y;
  c[i].z=i+1;
 }
 sort(c,c+m,cmp);
 int ok=c[0].x;
 c[0].y=1;
 long long  t=2;
 for(int i=1;i<m;i++)
 {
  if(c[i].x!=ok)
  {
   t=1;
   ok=c[i].x;
  }
  c[i].y=t++;
 }
 sort(c,c+m,cmpp);
 for(int i=0;i<m;i++)
 {
  printf("%06d%06d\n",c[i].x,c[i].y);
 }
}

Measured memory_bytes: 3840
using System;
using System.IO;

class Solve
{
    static void Main(string[] args) {
        var arr = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        long X = Math.Abs(arr[0]), K = arr[1], D = arr[2];
        var y = Math.Min(K, X / D);
        K -= y;
        X -= y * D;
        var answer = K % 2 == 0 ? X : D - X;
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 27580
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  vector<pair<long,long>> data(N);
  for(int i = 0; i < N; i++) {
    cin >> data.at(i).first >> data.at(i).second;
  }
  sort(data.begin(), data.end());
  long value = 0,sum = M;
  for(int i = 0; i < N; i++) {
    value += min(data.at(i).second ,sum) * data.at(i).first;
    sum -= min(data.at(i).second ,sum);
    if(sum == 0) break;
  }
  cout << value << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
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;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}

int main() {
    string s;
    cin >> s;
    int r = s.size()-1;
    int cnt = 0;
    while(r>0){
        r--;
        if ((r+1)%2==0) {
            int half = (r+1)/2;
            string left = s.substr(0,half-1);
            string right = s.substr(half,half-1);
            if (left == right) {
                cout << half*2 << "\n";
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <list>
#include <stack>

using namespace std;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

/* function */
int gcd(int x, int y);

/* main */
int main() {
    int a, b;
    cin >> a >> b;

    cout << gcd(a, b) << '\n';

}

int gcd(int x, int y) {

    while (y) {
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}



Measured memory_bytes: 3120
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define F first
#define S second


int main()
{

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//ios_base& scientific (ios_base& str);
    ll n, m, d, temp;
    cin >> n >> m;
    vector<vector<ll>> adj(n + 1);
    vector<ll> heights(n);
    for (int i = 0; i < n; i++)
        cin >> heights[i];
    //cin >> n >> k;
    ll a, b;
    while (m--)
    {
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    vector<ll> vis(n + 1, 0);
    ll count = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!vis[i])
        {
            ll f = 1;
            for (auto u : adj[i])
            {
                if (heights[i - 1] <= heights[u - 1])
                    f = 0;
                else
                    vis[u] = 1;
            }
            if (f)
            {
                //cout << i << "\n";
                count++;
            }
        }
    }
    cout << count << "\n";
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    long long N, K;
    cin >> N >> K;
    vector<int> dest(N+1);
    for (int i = 1; i <= N; ++i) cin >> dest[i];
    if (K == 0) {
        cout << 1 << endl;
        return 0;
    }

    vector<int> path;
    vector<bool> visited(N+1, false);
    vector<int> pos(N+1);
    int i;
    for (i = 1; !visited[i]; i = dest[i]) {
        pos[i] = path.size();
        path.push_back(i);
        visited[i] = true;
    }
    int cycleStart = pos[i];
    int cycleLen = path.size() - cycleStart;

    if (K <= cycleStart) {
        cout << path[K] << endl;
    }
    else {
        K -= cycleStart;
        K %= cycleLen;
        cout << path[cycleStart + K] << endl;
    }

    return 0;
}


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

#define llint long long int

using namespace std;

int main()
{
    int N;

    cin >> N;

    int prev;

    cin >> prev;

    llint ans = 0;

    for (int i = 1; i < N; i++)
    {
        int A;

        cin >> A;

        if (A < prev)
        {
            ans += prev - A;
        }
        else
        {
            prev = A;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() 
{
    ll ar[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    cin>>k;
    k--;
    cout<<ar[k];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;

vector<int> ra(MX,0);
vector<int> par(MX,0);


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

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

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

signed main(){
    int n, m ;
    cin >> n >> m;
    
    for (size_t i = 0; i < n; i++)
    {
        par[i] = i;
    }

    for (size_t i = 0; i < m; i++)
    {
        int x,y,z;
        cin >> x >> y >> z;
        unite(x-1,y-1);
    }

    int ans=0;
    set<int> ansset; 
    for (size_t i = 0; i < n; i++)
    {
        ansset.insert(find(i));
    }
    cout << ansset.size() << endl;
    
    return 0;
}

Measured memory_bytes: 20608
from collections import Counter
n=int(input())
c=Counter(list(map(int, input().split())))
l=list()
for k,v in c.items():
    for _ in range(v//2):
        l.append(k)

l.sort()
l.reverse()
if len(l)>=2:
    print(l[0]*l[1])
else:
    print(0)

Measured memory_bytes: 22084