akhauriyash/Code-Regression huggingface dataset:
import math
N = int(input())
A = list(map(int, input().split()))

import math
from collections import Counter

def prime_count(n):
    prime_count = Counter()
    for i in range(2, math.ceil(math.sqrt(n))+1):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1
    return prime_count


ans = float('inf')

for a in A:
    c = prime_count(a)[2]
    ans = min(ans, c)

print(ans)

Measured memory_bytes: 73916
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
char c[200];
typedef long long ll;
ll mod=1e9+7;
ll dp[210][210][210];
void add(ll &x,ll y){
	x+=y;
	x%=mod;
}
int main(){
	int n,nc=0;
	cin>>n;
	rep(i,n){
		char cc;
		cin>>cc;
		if(cc!='-') c[nc++]=cc;
	}
	n=nc;
	dp[0][0][0]=1;
	rep(i,n){
		rep(j,n+1){
			rep(k,n+1){
				if(c[i]=='D'){
					if(k>0) add(dp[i+1][j+2][k-1],dp[i][j][k]*(i-j)*k);
					add(dp[i+1][j+1][k],dp[i][j][k]*(i-j));
				}else{
					if(k>0) add(dp[i+1][j+1][k],dp[i][j][k]*k);
					add(dp[i+1][j][k+1],dp[i][j][k]);
				}
			}
		}
	}
	cout<<dp[n][n][0]<<endl;
}

Measured memory_bytes: 68328
H,W = map(int,input().split())

S = []
S.append(list('@'*(W+2)))
for i in range(H):
  a = list('@'+input()+'@')
  S.append(a)
S.append(list('@'*(W+2)))

ans = []
for i in range(H+2):
  ans.append([0]*(W+2))

for i in range(H+2):
 if((i != 0)and(i != H+1)): 
  for j in range(W+2):
    if((j != 0)and(j != W+1)):      
      if(S[i+1][j-1] == '#'):
        ans[i][j] += 1   
      if(S[i+1][j] == '#'):
        ans[i][j] += 1
      if(S[i+1][j+1] == '#'):
        ans[i][j] += 1
      if(S[i][j-1] == '#'):
        ans[i][j] += 1

      if(S[i][j+1] == '#'):
        ans[i][j] += 1
      if(S[i-1][j-1] == '#'):
        ans[i][j] += 1   
      if(S[i-1][j] == '#'):
        ans[i][j] += 1      
      if(S[i-1][j+1] == '#'):
        ans[i][j] += 1
      if(S[i][j] == '#'):#自分自身が爆弾なら
        ans[i][j] = '#'
      ans[i][j] = str(ans[i][j])#出力用文字列変換
      
      
for i in range(H+2):
 if((i != 0)and(i != H+1)):
  ans[i].pop(0)
  ans[i].pop(-1)
  print(''.join(ans[i]))

Measured memory_bytes: 3188
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll f[ohara];

bool check(ll x) {
  cnt = 0;
  rep(i, n) {
    ll lim = x / f[i];
    if (a[i] <= lim) continue;
    cnt += a[i] - lim;
  }
  if (cnt <= k)
    return true;
  else
    return false;
}

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

  cin >> n >> k;
  // xにする A<=x/F
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> f[i];
  sort(a, a + n);
  sort(f, f + n);
  reverse(f, f + n);
  ll le = 0, ri = LINF, mid;
  while (ri - le > 1) {
    mid = (le + ri) / 2;
    if (check(mid))
      ri = mid;
    else
      le = mid;
  }
  if (check(le))
    Cout(le);
  else
    Cout(ri);
  return 0;
}

Measured memory_bytes: 6792
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e15 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

int ans, n, m, q, A[55], B[55], C[55], D[55];
map <deque <int>, int> M;

int give(deque <int> v) {
  int temp = 0;
  for(int i = 1; i <= q; i++) {
    if(v[B[i]-1]-v[A[i]-1] == C[i]) {
      temp += D[i];
    }
  }
  return temp;
}

void go(deque <int> v, int n) {
    if(sz(v) == n) {
      ans = max(ans, give(v));
      return;
    }
    if(M[v]) return;
    M[v] = 1;
    for(int i = 1; i <= m; i++) {
         if(v.empty() || i >= v.back()) {
           v.pb(i); go(v, n);
           v.pop_back();
         }
    }
}

void solve() {
   cin >> n >> m >> q;
   for(int i = 1; i <= q; i++) {
     cin >> A[i] >> B[i] >> C[i] >> D[i];
   }
   deque <int> dq;
   go(dq, n);
   cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }
}    


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    string a,b;cin>>a>>b;
    int cnt=0;
    rep(i,3){
        if(a[i]==b[i]){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
import java.util.*;

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

  int s;
  int w;
  String ans;

  public Main() {
    Scanner sc = new Scanner(System.in);
    try {
      s = sc.nextInt();
      w = sc.nextInt();
    } finally {
      sc.close();
    }
  }
  
  void solve() {
    ans = s <= w ? "unsafe" : "safe";
  }

  void show() {
    System.out.println(ans);
  }
}


Measured memory_bytes: 35788
#include<bits/stdc++.h>
#define ii pair<int,int>
#define int long long int 	
using namespace std;
int n;
vector<int>v;
ii dp[3001][3001][2];
ii solve(int i,int j,int turn)
{
	if(dp[i][j][turn].first!=-1 and dp[i][j][turn].second!=-1 )
		return dp[i][j][turn];

	if(i==j)
	{
		if(turn==0)
		return dp[i][j][turn]={v[i],0};
		return  dp[i][j][turn]={0,v[i]};
	}

	 ii x = solve(i+1,j,turn^1);
	 ii y = solve(i,j-1,turn^1);
	 
	if(turn == 0)
	{
		if(x.second > y.second)
		{
			return dp[i][j][turn]={y.first+v[j],y.second};
		}
		else return dp[i][j][turn]={x.first+v[i],x.second};
	}

	else
	{
		if(x.first > y.first)
			return dp[i][j][turn]={y.first,y.second+v[j]};
		else return dp[i][j][turn]={x.first,x.second+v[i]};
	}
	 
}
signed main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		v.push_back(x);
	}
	for(int i=0;i<3001;i++)
		for(int j=0;j<3001;j++)
			for(int k=0;k<2;k++)
				dp[i][j][k]={-1,-1};

	ii x=solve(0,n-1,0);
	cout<<x.first-x.second<<"\n";
	//cout<<dp[0][n-1][1]<<"\n";


}

Measured memory_bytes: 281984
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = 1e3;
int n;

void read()
{
    cin >> n;
}

void solve()
{
    if(n % 2)
        cout << fixed << setprecision(10) << double(n/2 + 1) / double(n) << endl;
    else
        cout << "0.500000000\n";
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
int a,x;
cin>>a>>x;
if(a>=x){
cout<<10<<endl;
}else{
	cout<<0<<endl;
}


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)
#define all(x) x.begin(), x.end()


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n, k, R, s, p;
	cin >> n >> k >> R >> s >> p;
	string t;
	cin >> t;
	ll ans = 0;
	forn(i, k){
		vector<char> v;
		for(int j = i; j < n; j += k){
			v.push_back(t[j]);
		}
		int l = 0, r = 0;
		int m = v.size();
		debugtwo(v);
		while(l < m && r < m){
			while(r + 1 < m && v[l] == v[r + 1]){
				r++;
			}
			//v[l] != v[r + 1] but v[l] == v[r]
			int diff = r - l + 1;
			int mul = 0;
			if(v[l] == 'r'){
				mul = p;
			}
			else if(v[l] == 's'){
				mul = R;
			}
			else if(v[l] == 'p'){
				mul = s;
			}
			trace4(l, r, v[l], mul)
			ans += (diff + 1) / 2 * mul;
			l = r = r + 1;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll unsigned long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define INF 1000000000
#define bits(n) __builtin_popcount(n)

vector<int> adj[200001];
int vis[200001];
int curr;

void dfs(int node)
{
    curr+=1;
    vis[node]=1;
    for(int child:adj[node])
    {
        if(vis[child]==0)
        {
            dfs(child);
        }
    }
}
void solve()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    int maxi=INT_MIN;
    for(int i=1;i<n;i++)
    {
        curr=0;
        if(vis[i]==0)
        {
            dfs(i);
            if(curr>maxi)
            maxi=curr;
        }
    }
    cout<<maxi;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

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

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  cin >> A;
  int sum = accumulate(all(A), 0);
  int sel = sum / (4 * M);  // no less than sel
  if (sum % (4 * M) != 0) sel++;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] >= sel) cnt++;
  }
  if (cnt >= M)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int int64_t

signed main(){
	string s;
	cin>>s;
	int z=0,o=0;
	for(char c:s){
		if(c=='0')z++;
		else o++;
	}
	cout<<2*min(o,z)<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
struct mm
{
	int x;
}f[200001];
int a[200001];
bool cmp(mm p,mm q)
{
	return p.x>q.x;
}
int main()
{
	int n,k,i,j,s=0,h=0;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	f[s].x=1;
	sort(a,a+n);
	for(i=1;i<n;i++)
	{
		if(a[i]!=a[i-1])
		{
			s++;
			f[s].x=1;
		}
		else
		{
			f[s].x++;
		}
	}
	s++;
	sort(f,f+s,cmp);
	for(i=k;i<s;i++)
	h+=f[i].x;
	printf("%d\n",h);
} 

Measured memory_bytes: 1664
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vll;

ll getLCM (ll a, ll b) {
  return (a / __gcd(a, b)) * b;
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector <int> a(n);
  int prev = -1;
  bool ok = true;
  ll lcm = -1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0) lcm = a[i] / 2;
    lcm = getLCM(lcm, a[i] / 2);
    int cnt = 0;
    int val = a[i];
    while (val % 2 == 0) {
      cnt++;
      val /= 2;
    }
    if (prev == -1) prev = cnt;
    ok &= (prev == cnt);
  }
  if (!ok) {
    cout << 0 << '\n';
    return (0);
  }
  cout << (m / lcm + 1) / 2 << '\n';
  return (0);
}


Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  long long x, a[111], s = 0;

  std::cin >> N >> x;

  for (int i = 0; i < N; i ++)
    std::cin >> a[i];

  std::sort(a, a + N);

  int c = 0;

  for (int i = 0; i < N; i ++)
    if (i < N - 1) {
      if (x >= a[i]) {
        c ++;

        x -= a[i];
      }
    }
    else {
      if (x == a[i]) {
        c ++;
                
        x -= a[i];
      }
    }

  std::cout << c << std::endl;
      
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
inline long long Readin() {
	long long K = 0 , F = 1 ; char C = ' ' ;
	while( C < '0' or C > '9' ) F = C == '-' ? -1 : 1 , C = getchar() ;
	while( C <= '9' and C >= '0' ) K = ( K << 1 ) + ( K << 3 ) + C - '0' , C = getchar() ;
	return F * K ;
}
int N , A , B , P[105] , a , b , c ;
int main() {
	N = Readin() ;
	A = Readin() ;
	B = Readin() ;
	for(register int i = 0 ; ++i <= N ; P[i] = Readin() ) ;
	for(register int i = 0 ; ++i <= N ; ) {
		if( P[i] <= A ) ++a ;
		if( A < P[i] and P[i] <= B ) ++b ;
		if( B < P[i] ) ++c ;
	}
	return not printf( "%d\n" , min( a , min( b , c ) ) ) ;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
stair_m=[True]*(110000)
for i in range(m):
    a=int(input())
    stair_m[a]=False
dp=[0]*(110000)
dp[0]=1
for i in range(1,n+1):
    if stair_m[i]:
        dp[i]=dp[i-1]+dp[i-2]
    else:
        dp[i]=0
print(dp[n]%1000000007)

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string S;
  IN(S);

  printf("%c%c%c\n", S[0], S[1], S[2]);

  return 0;
}

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

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  }
}

struct Scanner<R: Read> {
  reader: R
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader }
  }
  fn safe_get<T: FromStr>(&mut self) -> Option<T> {
    let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
      .skip_while(|c| c.is_whitespace())
      .take_while(|c| !c.is_whitespace())
      .collect::<String>();
    if token.is_empty() { None } else { token.parse().ok() }
  }
  fn get<T: FromStr>(&mut self) -> T {
    if let Some(v) = self.safe_get() { v } else {
      writeln!(stderr(), "Terminated with EOF").unwrap();
      std::process::exit(0);
    }
  }
}

fn adjust<T, U>(ar: &mut Vec<(T, U)>)
  where T: Sized + PartialOrd,
        U: Sized + std::ops::Add<Output = U>
{
  let len = ar.len();
  if len < 2 { return; }
  if ar[len - 1].0 > ar[len - 2].0 { return; }
  let last = ar.pop().unwrap();
  let b_last = ar.pop().unwrap();
  ar.push((last.0, last.1 + b_last.1));
  adjust(ar);
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let s = scan!(sc; String);
  let mut sl = Vec::new();
  let mut ar = Vec::new();
  for (i, c) in s.chars().enumerate() {
    match c {
      '\\' => sl.push(i),
      '/'  => {
        if let Some(idx) = sl.pop() {
          let a = i - idx;
          ar.push((idx, a));
          adjust(&mut ar);
        }
      },
      _    => {}
    }
  }
  println!("{}", ar.iter().map(|&(_, u)| u).sum::<usize>());
  print!("{}", ar.len());
  for &(_, u) in ar.iter() {
    print!(" {}", u);
  }
  println!();
}



Measured memory_bytes: 5032
import sys
input = sys.stdin.readline
N, M = map(int,input().split())
edge_from = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    edge_from[a].append(b)
    edge_from[b].append(a)

def rec(v, visited):
    if len(visited) == N:
        return 1
    ret = 0
    for nxt in edge_from[v]:
        if nxt not in visited:
            ret += rec(nxt, [x for x in visited]+[nxt])
    return ret
print(rec(0, [0]))

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
double P[3030][3030];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	P[0][0]=1;
	cin>>N;
	FOR(i,N) {
		double p;
		cin>>p;
		FOR(j,i+1) {
			P[i+1][j]+=P[i][j]*(1-p);
			P[i+1][j+1]+=P[i][j]*p;
		}
	}
	
	double ret=0;
	FOR(i,N+1) if(i>N-i) ret+=P[N][i];
	_P("%.12lf\n",ret);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 70272
#include<bits/stdc++.h>
using namespace std; 
using lint =                            long long int;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD 1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
    lint N, M;
    cin >> N >> M;
    vector<lint> A(N);
    cin>>A;
    REP(i,N){
        A[i]/=2;
    }
    lint lcm = 1;
    for(auto a : A){
        lcm = lcm*a / __gcd(lcm,a);
        if(lcm>M){
            puts("0");
            return;
        }
    }
    //even-odd concept to differentiate; even * odd = even so equal number of times multiplication with 2 is required : Key concept;
    for(auto a : A){
        if(lcm/a % 2 == 0){
            puts("0");
            return ;
        }
    }
    int ret = 1;//for the lcm obtained;
    ret += (M-lcm)/(lcm*2);    //for odd number times of lcm ; according to the equation that we got;
    cout<<ret<<endl;

}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int count=0;
    for (int i=0;i<s.size();i++) {
        if (s[i]=='o') {
            count++;
        }
    }
    if (count+15-s.size()>=8) {
        cout<<"YES"<<endl;
    } else {
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a;
	cin>>a;
	bool na=true;
	bool t=true;
	for(int i=0;i<a.size();i++){
		if(t==true&&a[i]=='A')
			t=false;
		if(t==false&&a[i]=='Z'){
			t=true;
			cout<<"AZ";
			na=false;
		}
	}
	if(na==true)
		cout<<"-1";
	cout<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  string ans = "No";
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
  	 if ( N == i * j ){
      ans = "Yes";
      break;
     }
    }
   }
  cout << ans << endl;
}


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

typedef long long ll;
const int INF = 1e9;

using namespace std; 

#define REP(inc, bgn, end) for (int inc = bgn; inc < end; inc++)

int main() {
    int n, m, wa[100100], p, ac_count = 0, wa_count = 0;
    bool ac[100100];
    string s;

    cin >> n >> m;

    REP(i, 0, n) {
        wa[i] = 0;
        ac[i] = false;
    }

    REP(i, 0, m) {
        cin >> p >> s;
        p--;
        if (ac[p]) continue;
        else if (s == "AC") {
            ac_count++;
            wa_count += wa[p];
            ac[p] = true;
        }
        else {
            wa[p]++;
        }
    }

    cout << ac_count << ' ' << wa_count << endl;
}

Measured memory_bytes: 768
#include <math.h>
#include <stdio.h>
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  ll x, y = 0;
  for (int i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {
      x = i;
      y = N / i;
    }
  }

  if (y == 0) {
    cout << N - 1 << endl;
  } else {
    cout << x + y - 2 << endl;
  }

  return 0;
}

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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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

int main(){
    ll ans=0,sum=0;
    ll n;
    cin >>n;
    
    ll k,skip;
    k = ceil((sqrt(8*n+1)-1)/2);

    skip = k*(k+1)/2 - n;

    for (int i = 1; i <= k; ++i){
        if(i == skip)continue;
        cout << i << endl;
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<bitset>
#include<deque>
#include<iterator>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define pii pair<ll,ll>
#define mp make_pair 
#define M 1000000007
int main()
{
  ll x;
  cin>>x;
  ll cnt=100,ans=0;
  while(cnt<x)
  {
  	cnt=cnt+cnt/100;
  	ans++;
  }
  cout<<ans;
	return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define CIN(type, ...) \
  type __VA_ARGS__;    \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define COUT(...) write_to_cout(__VA_ARGS__);

#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

bool ac[100000];
int wa[100000];

int main() {
  CIN(int, N, M);
  REP(i, M) {
    CIN(int, p);
    CIN(string, S);
    if(S=="AC")ac[p-1]=true;
    if(S=="WA"&&!ac[p-1])++wa[p-1];
  }
  int acs=0,was=0;
  REP(i,N)if(ac[i]){++acs;was+=wa[i];}
  COUT(acs,was);
}


Measured memory_bytes: 768
n = int(input())
a = list(map(int, input().split()))
ruiseki = [0] * (n+1)
for i in range(n):
    ruiseki[i+1] = ruiseki[i] + a[i]

dp = [[-1]*(n+1) for i in range(n+1)]

def solve(l, r):
    if dp[l][r] != -1:
        return dp[l][r]
    if r - l == 1:
        dp[l][r] = 0
        return dp[l][r]
    ans = 10**18
    for i in range(l+1, r):
        ans = min(ans, solve(l, i) + solve(i, r) + ruiseki[r] - ruiseki[l])
    dp[l][r] = ans
    return dp[l][r]

solve(0, n)
print(dp[0][n])

Measured memory_bytes: 43500
#include <bits/stdc++.h>
#define maxn 305
using namespace std;

double dp[maxn][maxn][maxn];
int cnt[4] = {};
int n;

double dfs(int x, int y, int z) {
    if(x + y + z == 0) return 0.00;
    if(dp[x][y][z] != 0.00) return dp[x][y][z];
    int cnt = x + y + z;
    int zero = n - cnt;
    dp[x][y][z] = 0.00;
    if(z) dp[x][y][z] += (dfs(x, y + 1, z - 1)) * ((double)z / cnt);
    if(y) dp[x][y][z] += (dfs(x + 1, y - 1, z)) * ((double)y / cnt);
    if(x) dp[x][y][z] += (dfs(x - 1, y, z)) * ((double)x / cnt);
    dp[x][y][z] = dp[x][y][z] + ((double)n / (n - zero));
    return dp[x][y][z];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        int x; cin >> x; cnt[x]++;
    }
    cout << setprecision(20) << dfs(cnt[1], cnt[2], cnt[3]) << '\n';
    return 0;
}


Measured memory_bytes: 112628
from functools import reduce

def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y 
            y = z
        else:
            return z

def main():
    _ = input()
    monsters = [int(n) for n in input().split(" ")]
    max_gcd = reduce(gcd, monsters)
    print(max_gcd)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14596
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

#define EPS (1e-7)
#define IINF ((int)1e9)


MY_NAMESPACE(testbed)
int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<ll> u(n), v(n);
	for (int i = 0; i < n - 1; i++)
	{
		cin >> u[i] >> v[i];
	}

	ll vertices = 0;
	for (int i = 0; i < n; i++)
	{
		vertices += 1LL * (i + 1) * (n - i);
	}

	ll edges = 0;
	for (int i = 0; i < n - 1; i++)
	{
		ll this_u = u[i];
		ll this_v = v[i];
		if (this_v < this_u)
			swap(this_u, this_v);
		edges += 1LL * this_u * (n - this_v + 1);
	}

	ll res = vertices - edges;
	cout << res << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 6328
ARGF.each_line do |line|
  n, x = line.split.map(&:to_i)

  break if n == 0 && x == 0
  
  count = 0
  (1..n).each do |i|
    (i..n).each do |j|
      (j..n).each do |k|
        if [i,j,k].uniq.count == 3 && i + j + k == x
          count += 1
        end
      end
    end
  end

  puts count
end

Measured memory_bytes: 6096
#include <iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main(void){
    int a,b;
    int x = 0;
    char c;
    for(int i = 0;; i++){
        cin>>a>>c>>b;
        if(c=='?')break;
        if(c=='+'){
            x = a+b;
            cout<<x<<endl;
        }
        if(c=='-'){
            x = a-b;
            cout<<x<<endl;
        }
        if(c=='*'){
            x = a*b;
            cout<<x<<endl;
        }
        if(c=='/'){
            x = a/b;
            cout<<x<<endl;
        }
    }
    
    
    
    return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,q;
  cin>>n>>m>>q;
  vector<int> a(q);
  vector<int> b(q);
  vector<int> c(q);
  vector<int> d(q);
  for(int i=0;i<q;i++){
    cin>>a.at(i)>>b.at(i)>>c.at(i)>>d.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  vector<bool> p;
  for(int i=0;i<n;i++)
    p.push_back(0);
  for(int i=0;i<m-1;i++)
    p.push_back(1);
  bool f=1;
  int ma=0;
  while(f){
    vector<int> x;
    int ai=1;
    for(int i=0;i<(int)p.size();i++){
      if(p.at(i))
        ai++;
      else
        x.push_back(ai);
    }
    int s=0;
    for(int i=0;i<q;i++)
      s+=(x.at(b.at(i))-x.at(a.at(i))==c.at(i)?d.at(i):0);
    ma=max(s,ma);
    f=next_permutation(p.begin(),p.end());
  }
  cout<<ma<<endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    Integer A[] = new Integer[N];
    for (int i = 0 ; i < N ; i++) {
      A[i] = scan.nextInt();
    }
    Arrays.sort(A, Collections.reverseOrder());
    for (int i = 0 ; i < N - 1 ; i++) {
      if(A[i].equals(A[i + 1])){
        System.out.println("NO");  
        return;
      }
    }
    System.out.println("YES");    
  }
}

Measured memory_bytes: 94116
import bisect

S = input()
T = input()

Sset = set(list(S))
Tset = set(list(T))
if len(Tset-Sset) > 0:
  print(-1)
  exit()

SS = S * 2
SSpos = {}
for i in range(len(SS)):
  if SS[i] in SSpos:
    SSpos[SS[i]].append(i)
  else:
    SSpos[SS[i]] = [i]
for i in SSpos:
  SSpos[i].sort()
#print(SSpos)

ans = 0
i = 0
for t in T:
  j = bisect.bisect_left(SSpos[t],i)
  ans += SSpos[t][j] - i + 1
  #print(t,SSpos[t],ans,i,j)
  i = SSpos[t][j] + 1
  if i >= len(S):
    i -= len(S)
print(ans)


Measured memory_bytes: 55024
#include <iostream>
#include <array>
#include <functional>
#include <algorithm>
using namespace std;

int main() {
  int64_t n;
  array<int64_t, 3> abc;
  cin >> n >> abc[0] >> abc[1] >> abc[2];
  string out, s[n];
  for (int i = 0; cin >> s[i]; ++i) {}
  function<bool(string*, array<int64_t, 3>&, int)> solve = [&](string* const s, auto& abc, int i) {
    if (i == n) {
      return true;
    }
    --abc[s[i].front() - 'A'];
    ++abc[s[i].back() - 'A'];
    if (abc[0] >= 0 && abc[1] >= 0 && abc[2] >= 0 && solve(s, abc, i + 1)) {
      out.push_back(s[i].back());
      out.push_back('\n');
      return true;
    }
    abc[s[i].front() - 'A'] += 2;
    abc[s[i].back() - 'A'] -= 2;
    if (abc[0] >= 0 && abc[1] >= 0 && abc[2] >= 0 && solve(s, abc, i + 1)) {
      out.push_back(s[i].front());
      out.push_back('\n');
      return true;
    }
    --abc[s[i].front() - 'A'];
    ++abc[s[i].back() - 'A'];
    return false;
  };
  if (solve(s, abc, 0)) {
    reverse(begin(out), end(out));
    cout << "Yes" << out;
  } else {
    cout << "No";
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 int x,a,b; 
  cin >> x >> a >>b ;
  int ans=(x-a)%b;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
#define LARGE 100000
int V,E;
int color=0;
 
typedef struct list{
  int id;
  struct list *next;
}list;
 
 
list * makelist(int x){
  list *new = malloc(sizeof(list));
  new->id = x;
  new->next = NULL;
  return new;
}
 
void list_insert(list* L[], int x, list *new){
    list **p = &L[x];
     
    while((*p) != NULL){
      p = &((*p)->next);
    }
    (*p) = new;
     
    return;
}
 
int push(int stack[], int x, int top){
  stack[top++] = x;
  return top;
}
 
int pop(int stack[], int *top){
  (*top)--;
  return stack[*top];
}
 
void dfs(int C[], int x, list* L[]){
  int stack[LARGE];
  int top = 0;
  int temp;
  list *p;
     
  color++;
  top = push(stack,x,top);
  while(top > 0){
    temp = pop(stack,&top);
    if(C[temp] == 0) C[temp] = color;
    p = L[temp];
    while(p != NULL){
      if(C[p->id] == 0){
    top = push(stack,p->id, top);
    C[p->id] = color;
            }
      p = p->next;
        }
  }
     
  return;
}
 
int main(){
  int i, j, s, t, q, x, y, C[LARGE];
  list *L[LARGE], *new;
  
  scanf("%d %d", &V, &E);
     
  for(i = 0 ; i < V ; i++){
    L[i] = NULL;
    C[i] = 0;
  }
     
  for(i = 0 ; i < E ; i++){
    scanf("%d %d", &s, &t);
    new = makelist(t);
    list_insert(L, s, new);
    new = makelist(s);
    list_insert(L, t, new);
  }
     
  scanf("%d", &q);
  for(i = 0 ; i < q ; i++){
    scanf("%d %d", &x, &y);
    if(C[x] == 0) dfs(C, x, L);
    if(C[y] == 0) dfs(C, y, L);
    if(C[x ]== C[y]) printf("yes\n");
    else printf("no\n");
  } 
         
  return 0;
}



Measured memory_bytes: 9128
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  int A[26]={0};
  for(auto c:S)A[c-'a']+=1;
  REP(i,26)if(A[i]==0){
    cout<<(char)('a'+i)<<endl;
    return 0;
  }
  cout<<"None"<<endl;
  return 0;
}


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

int main() {
  int A,B;

  while(cin>>A>>B, A|B) {
    int rem = B-A;
    int th = 0, fi = 0, hu = 0;
    while(rem >= 1000) {
      rem -= 1000;
      th++;
    }
    while(rem >= 500) {
      rem -= 500;
      fi++;
    }
    while(rem >= 100) {
      rem -= 100;
      hu++;
    }
    cout<<hu<<" "<<fi<<" "<<th<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
#define PAI 3.14159265358979
// ver1.6
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  string s;
  cin >> s;
  int l = s.size();
  int P=0;
  rep(i,0,l){
    if(s[i]=='p') P++;
  }
  
  int me = l/2;
  cout << me-P << endl;
}


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

int sq_er(int x, int y){
    return (x-y)*(x-y);
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, m;
    cin >> n >> m;

    vector<int> ans;

    while(n != 0 && m != 0){

        vector<int> c(m);
        for(int i=0; i<m; i++){
            cin >> c[i];
        }
        vector<int> x(n);
        for(int i=0; i<n; i++){
            cin >> x[i];
        }

        // dp[i][j] は i 番目が j のときのそこまでの二乗誤差の最小値
        int INF = 1<<30;
        INF = INF<<30;
        // n=20000 はでかすぎ？
        vector<vector<int>> dp(n, vector<int>(256, INF));
        for(int i=0; i<m; i++){
            int ny = 128 + c[i];
            if(ny < 0) ny = 0;
            if(ny > 255) ny = 255;
            dp[0][ny] = sq_er(ny, x[0]);
        }

        for(int i=1; i<n; i++){
            for(int j=0; j<m; j++){
                for(int y=0; y<256; y++){
                    int ny = y + c[j];
                    if(ny < 0) ny = 0;
                    if(ny > 255) ny = 255;
                    dp[i][ny] = ((dp[i][ny] > dp[i-1][y] + sq_er(ny, x[i]))? dp[i-1][y] + sq_er(ny, x[i]) : dp[i][ny]);
                }
            }
        }

        int min_sq_er = INF;
        for(int y=0; y<256; y++){
            min_sq_er = ((min_sq_er > dp[n-1][y])? dp[n-1][y] : min_sq_er);
        }
        ans.push_back(min_sq_er);

        cin >> n >> m;    
    }

    for(int i=0; i<ans.size(); i++){
        cout << ans[i] << endl;
    }

    return 0;
}


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

int main()
{
  int A, B;

  cin >> A >> B;

  if (A == 1) {
    A = 14;
  }
  if (B == 1) {
    B = 14;
  }

  if (A > B) {
    cout << "Alice" << endl;
  } else if (A < B) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N, R;
    scan(N, R);
    auto ans = N >= 10 ? R : R + 100 * (10 - N);
    writeln(ans);
}









void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
/* Akshat Sharma @akshat98 */
#include <iostream>
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp   make_pair
#define pb   push_back
#define F    first
#define S    second
#define ll   long long
#define MOD  1000000007
#define MAX  1000000001
#define vi   vector<int>
#define vl   vector<ll>
#define vpi  vector<pair<int,int> >
#define vpl  vector<pair<ll,ll> >
#define rep(i,a,b) for(i=a;i<b;i++)
#define reqp(i,a,b) for(i=a;i<=b;i++)
#define ren for(i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;


int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input_file.txt", "r", stdin);
	// //freopen("output_file.txt", "w", stdout);
	// #endif
	int i,j,k,l,n,test_case,m,r;
	test_case=1;
	//cin>>test_case;
	while(test_case--){
		cin>>n>>m;
		vi vec(n);
		int sum=0;
		ren{
			cin>>vec[i];
			sum+=vec[i];
		}
		sort(ALL(vec));
		reverse(ALL(vec));
		// rep(i,0,m){
		// 	sum+=vec[i];
		// }
		if(vec[m-1]<(int)(ceil(1.0*sum/(4*m)))){
			cout<<"No \n";
		}else cout<<"Yes \n";


	}
	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

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




using namespace std;
int main() {

	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a*b, a - b))<<endl;


	return 0;
}

Measured memory_bytes: 256
import math


def read():
    N, P = list(map(int, input().strip().split()))
    return N, P


def solve(N, P):
    # problem constraint
    if N >= 40:
        return 1
    # solve
    v3 = math.floor(P**(1/N)) + 1
    for v in range(v3, 0, -1):
        if P % (v**N) == 0:
            return v
    return 1


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Measured memory_bytes: 3060
#include <iostream>

using namespace std;



int main()
{
    int s, i, c=0, ma=0;
    char a;
    s=3;
    for(i=0; i<s; i++){
        cin >> a;
        if(a=='R'){
            c++;
        }
        else{
            ma=max(ma, c);
            c=0;
        }
    }
    ma=max(ma, c);
    cout << ma << '\n';
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
void func(int,int,double,int);
int p,q,a,n,cnt;
double k;
 
int main(){
  while(1){
    cin>>p>>q>>a>>n;
    if(!p&&!q&&!a&&!n) break;
    k=1.0*p/q;
    cnt=0;
    func(0,1,0,1);
    cout<<cnt<<endl;
  }
  return 0;
}
 
void func(int x,int w,double y,int I){
  if(-0.00000001<=k-y&&k-y<=0.00000001) cnt++;
  if(x==n) return ;
  for(int i=I;w*i<=a;i++){
    if(y+1.0/i>k+0.5) continue;
    func(x+1,w*i,1.0/i+y,i);
  }
}

Measured memory_bytes: 1160