akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#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 pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=LINF,a,b,c,d[ohara],cmp,cmpp,m,h,w,x,y,sum=0,pos,k,lim,parent,ma=0;
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;
bool fl,visited[ohara];
struct edge{int to,cost;};
vector<ll> graph[2002];
map<ll,ll> nex;
map<ll,ll> dis;

//-------------------------↓↓↓↓↓↓------------------------

ll dfs_odd(ll now,ll depth){
    if(visited[now])return 0;
    visited[now]=true;
    if(depth>lim)d[now]=1;
    rep(i,Size(graph[now])){
        dfs_odd(graph[now][i],depth+1);
    }
    return 0;
}

ll dfs_even(ll now,ll depth){
    if(nex[now]>=1){
        parent=now;
    }
    if(visited[now])return 0;
    visited[now]=true;
    if(depth>lim)d[now]=1;
    if(depth==lim+1){
        dis[parent]++;
    }
    rep(i,Size(graph[now])){
        dfs_even(graph[now][i],depth+1);
    }
    return 0;
}

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n>>k;
    rep(i,n-1){
        cin>>a>>b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    if(k%2==0){
    rep(i,n){
        rep(j,n+1)d[j]=0,visited[j]=false;
        lim=k/2;
        cnt=0;
        dfs_odd(i,0);
        rep(j,n)cnt+=d[j];
        ans=min(ans,cnt);
        cnt=0;
    }
    Cout(ans);
    }
    else{
        rep(i,n){
        if(i==1)a=1;
        else a=2;
        ma=0;   
        rep(j,n+1)d[j]=0,visited[j]=false,nex[j]=0,dis[j]=0;
        rep(j,Size(graph[i])){
            nex[graph[i][j]]=1;
        } 
        lim=k/2;
        cnt=0;
        dfs_even(i,0);
        rep(j,n)cnt+=d[j];
        rep(j,n){
            ma=max(ma,dis[j]);
        }
        ans=min(ans,cnt-ma);
        cnt=0;
    }
    Cout(ans);
    }
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  ll a,b,n;
  cin>>a>>b>>n;
  if(n<b) out((a*n)/b-a*(n/b));
  else out((a*(b-1))/b);
}

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


Measured memory_bytes: 3656
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}


//for(int i = ; i < ; i++){}

int main(){
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  int ans_water = min(a,b);
  int ans_suger = 0;
  int water = 0;
  int suger = 0;
  for(int i = 0; 100*a*i<=f; i++){
    for(int j = 0; 100*b*j<=f; j++){
      for(int k = 0; k*c<=f; k++){
        for(int l = 0; l*d<=f; l++){
          water = (a*i+b*j);
          suger = k*c+l*d;
          if(water>0&&suger<=e*water&&100*water+suger<=f){
            if(100*ans_water*suger>ans_suger*100*water){
              ans_suger = suger;
              ans_water = water;
            }
          }
        }
      }
    }
  }
  cout<<100*ans_water+ans_suger<<" "<<ans_suger<<endl;
  /*int A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;
  
  int water = 0,sugar=0;
  int ans_water = min (A,B),ans_sugar=0;
  
  for(int a=0;100*A*a<=F;a++){
    for(int b=0;100*B*b<=F;b++){
      
  
  for(int c=0;c*C<=F;c++){
    for(int d=0;d*D<=F;d++){
      water = a*A+b*B;
      sugar=c*C+d*D;
      if(water>0 && sugar<=E*water && 100*water+sugar<=F){
        if(100*ans_water*sugar>ans_sugar*100*water){
          ans_water = water;
          ans_sugar = sugar;
        }
           }
           }
           }
           }
           }
           cout << 100*ans_water+ans_sugar << " "  << ans_sugar << endl;
           */
  return 0;
}




Measured memory_bytes: 256
var N,K,i,l:int64;
    pi,p:real;
begin
read(N,K);p:=0;
for i := 1 to N do 
 begin
  l:=i;pi:=1;
  while l < K do begin l:=l*2;pi:=pi/2 end;
  p:=p+pi;
 end;
write(p/N)
end.

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

int main() {
    // input
    int N;
    cin >> N;

    // solve
    bool color[8] = {false};
    int tmp = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if (3200 <= a) tmp++;
        else if (2800 <= a) color[7] = true;
        else if (2400 <= a) color[6] = true;
        else if (2000 <= a) color[5] = true;
        else if (1600 <= a) color[4] = true;
        else if (1200 <= a) color[3] = true;
        else if (800 <= a) color[2] = true;
        else if (400 <= a) color[1] = true;
        else color[0] = true;
    }
    int ans = 0;
    for (int i = 0; i < 8; ++i) {
        if (color[i] == true) ans++;
    }

    // output
    cout << (ans == 0 ? 1 : ans) << " " << ans + tmp << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define N 100
#define MAX 2000
#define MIN 1

/*
制約
 1≤n≤100
 0≤aij≤2,000(aij≠−1のとき)
 aij=aji
 グラフGは連結である。
*/

int main(){
  int i, j;
  int n, small, aij, sum=0, data, q_data;
  int A[N][N], B[N], C[N];
  
  scanf("%d",&n);
  if(n<1 || n>100) exit(1);
  
  for(i=0; i<n; i++)
    for(j=0; j<n; j++) scanf("%d", &A[i][j]);

  for(i=0; i<n; i++){
    B[i] = 0;
    if(i == 0){
      C[i] = 0;
      continue;
    }
    C[i] = MAX;
  }
  
  for(i=0; i<n-1; i++){
    small = MAX;
    for(j=0; j<n; j++){
      if(C[j] < small && B[j] == 0){
	aij = j;
	small = C[j];
	data = 30;
      }
    }
    
    B[aij] = MIN;
    q_data = 30;
    for(j=0; j<n; j++){
      if(A[aij][j] != -MIN && A[aij][j] < C[j] && B[j] == 0)
	C[j] = A[aij][j];  
    }
  }
  
  for(i=0; i<n; i++) sum = sum + C[i];
  
  printf("%d\n",sum);
  
  return 0;
}



Measured memory_bytes: 2080
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0);
    char s[20],t[20];
    cin>>s;
    cin>>t;
    int n=0;
    for(int i=0;i<strlen(s);i++){
        if(s[i]==t[i]){
           n++;
        }
    }
    if(n==strlen(s)){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }


return 0;
}


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

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep2(i,a,b) for(ll i=a; i<=b; i++)
#define drep2(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back


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

  rep(i, N+1) {
    rep(j, N-i+1) {
      int z = N-i-j;
      if (10000 * i + 5000 * j + 1000 * z == Y) {
        cout << i << " " << j << " " << z << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1 " << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

from collections import deque

n = int(input())

connect_list = [[] for _ in range(n)]

ab = [list(map(int, input().split())) for i in range(n-1)]

for i in range(n-1):
    a, b = ab[i]
    connect_list[a-1].append(b-1)
    connect_list[b-1].append(a-1)


color_list = {}
check_list = [0]*n

color_max = max(map(len, connect_list))

vertex = [0 for i in range(n)]
d = deque([0])

while(len(d) > 0):
    # print(d)
    index = d.pop()
    check_list[index] = 1

    index_list = connect_list[index]

    for i in index_list:
        if check_list[i] == 1:
            continue

        check_list[i] = 1
        d.append(i)
        num = vertex[index] % color_max+1
        color_list[(min(index, i), max(index, i))] = num
        vertex[index], vertex[i] = num, num


print(color_max)
for a, b in ab:
    print(color_list[(a-1, b-1)])


Measured memory_bytes: 58048
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
int n,m,k;
int main(){
	cin>>n>>m>>k;
	int a=max(n,m),b=min(n,m);
	cout<<(k+a-1)/a<<endl;
	return 0;
}

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

using namespace std;

int main()
{
    string a;
    cin >> a;
    if(a == "zyxwvutsrqponmlkjihgfedcba")
    {
        cout << -1 << endl;
        return 0;
    }
    vector<bool> is(26, true);
    for(int i = 0; i < a.size(); i++)
    {
        is[(int)(a[i] - 'a')] = false;
    }
    for(int i = 0; i < 26; i++)
    {
        if(is[i])
        {
            cout << a << (char)(i + 'a') << endl;
            return 0;
        }
    }
    bool y = false;
    for(int i = a.size() - 1; i >= 0; i--)
    {
        for(char d = a[i] + 1; d <= 'z'; d++)
        {
            y = true;
            for(int j = i - 1; j >= 0; j--)
            {
                if(a[j] == d)
                {
                    y = false;
                    break;
                }
            }
            if(y)
            {
                for(int j = 0; j < i; j++)
                {
                    cout << a[j];
                }
                cout << d << endl;
                return 0;
            }
        }

    }
    cout << -1 << endl;
    return 0;
}





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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

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

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T &b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T &b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { 1,  0, -1,  0,  1, -1,  1, -1};
static const int dy[8] = { 0,  1,  0, -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;


int get_input(){
    return 1;
}
void output(){;}

string s;

struct P{
    int num,ischar;
    P(int num,int ischar):num(num),ischar(ischar){;}
};

int deal(vector<int> &vi){
    int sz = vi.size();
    if(sz == 1){
        return (vi[0]+1)/2;
    }
    else{
        int ret = 0;
        sort(ALL(vi));
        _for(i,0,(sz+1)/2){
            ret += vi[i];
        }
        return ret;
    }

}

int main()
{
    int T;
    scanf("%d",&T);
    while(T--){
        cin >> s;
        stack<P> st;
        int sz = s.size();
        _for(i,0,sz){
            if(s[i] == '['){
                st.push(P(-1,1));
            }
            else if(isdigit(s[i])){
                int l = i;
                while(isdigit(s[i+1]))i++;
                string num = s.substr(l,i-l+1);
                stringstream ss(num);
                int nn; ss >> nn;

                st.push(P(nn,0));
            }
            else if(s[i] == ']'){
                vector<int> vi;
                while(!(st.top().ischar)){
                    vi.PB(st.top().num);
                    st.pop();
                }
                int ret = deal(vi);
                st.pop();
                st.push(P(ret,0));
            }
        }
        cout << st.top().num << endl;

    }

    return 0;
}



Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
#define nn 1008
#define ll long long
#define pii pair<int,int>
int n;ll w[nn],s[nn],v[nn],f[20008],id[nn];
bool cmp(int x,int y)
{
	return s[x]+w[x]>s[y]+w[y];
}
ll ans=0;
void upd(ll &x,ll y)
{
	ans=max(ans,y);
	x=max(x,y);
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>w[i]>>s[i]>>v[i],id[i]=i;
	sort(id+1,id+n+1,cmp);
	for(int di=1;di<=n;di++)
	{
		int i=id[di];
		for(int j=0;j<20004;j++)
		{
			if(j>=w[i])
				upd(f[min(j-w[i],s[i])],f[j]+v[i]);
		}
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
   int m, d;
   cin >> m;
   cin >> d;
   int cifra1, cifra2;
   int numar = 0;
   for (int i = 4; i <= m; i++)
   {
       for (int j = 22; j <= d; j++)
       {
           cifra1 = j % 10;
           cifra2 = j / 10;
           if (cifra1 * cifra2 == i && cifra1 != 1 && cifra2 != 1)
           {
               numar++;
           }
       }
   }
   cout << numar;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 3005
#define MAXM 200005
#define INF 0x3f3f3f3f
#define p 1000000007
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int h, w, n, f[MAXN], fac[MAXM], inv[MAXM];

struct A {int x, y;} a[MAXN];

bool CMP(A a, A b)
{
	if(a.x==b.x) return a.y<b.y;
	return a.x<b.x;
}

void init()
{
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(rint i=2; i<=200000; ++i) inv[i]=1LL*inv[p%i]*(p-p/i)%p;
	for(rint i=2; i<=200000; ++i)
	{
		fac[i]=1LL*fac[i-1]*i%p;
		inv[i]=1LL*inv[i-1]*inv[i]%p;
	}
}

int comb(int x, int y)
{
	return 1LL*fac[x]*inv[y]%p*inv[x-y]%p;
}

int main()
{
	init();
	scanf("%d%d%d", &h, &w, &n);
	for(rint i=1; i<=n; ++i) scanf("%d%d", &a[i].x, &a[i].y);
	a[n+1].x=h; a[n+1].y=w;
	sort(a+1, a+n+2, CMP);
	for(rint i=1; i<=n+1; ++i)
	{
		f[i]=comb(a[i].x+a[i].y-2, a[i].x-1);
		for(rint j=1; j<i; ++j)
		{
			if(a[j].y>a[i].y) continue;
			int dx=a[i].x-a[j].x;
			int dy=a[i].y-a[j].y;
			f[i]=(f[i]+p-1LL*f[j]*comb(dx+dy, dx)%p)%p;
		}
		//printf("%d %d!!\n", i, f[i]);
	}
	printf("%d\n", f[n+1]);
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

int gcd(int x, int y) {
    if (y > x) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}

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

    vector<int> l(N), r(N);
    rep(i, N - 1) l[i + 1] = gcd(l[i], a[i]);
    for (int i = N - 1; i >= 1; i--) r[i - 1] = gcd(r[i], a[i]);

    int ans = 1;
    rep(i, N) ans = max(ans, gcd(l[i], r[i]));
    cout << ans << endl;
}

Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
n, a, b = map(int, input().split())

diff = b - a
if abs(diff) % 2 == 0:
    print(diff // 2)
else:
    worst = min(b-1, n-a)
    if a-1 < n-b:
        t = a
    else:
        t = n-b+1
    t += (b - a - 1) // 2
    print(min(t, worst))


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>

using namespace std;

int CalcSaidaiKouyakusu(int a, int b)
{
	int A = max(a, b);
	int B = min(a, b);

	while (1)
	{
		if (A % B == 0)
		{
			return B;
		}
		int tmp = A % B;
		A = B;
		B = tmp;
	}
	return 0;
}

int main() {

	int N;
	cin >> N;

	vector<int> vNum(N, 0);

	for (int i = 0; i < N; i++)
	{
		cin >> vNum[i];
	}

	bool isKisu = false;
	for (int i = 0; i < N; i++)
	{
		if (vNum[i] < 0)
		{
			isKisu = !isKisu;
		}
	}
	for (int i = 0; i < N; i++)
	{
		vNum[i] = abs(vNum[i]);
	}

	sort(vNum.begin(), vNum.end());
	//reverse(vNum.begin(), vNum.end());

	long long retValue = 0;
	for (int i = 0; i < vNum.size(); i++)
	{
		if (isKisu && i == 0)
		{
			retValue -= abs(vNum[i]);
		}
		else
		{
			retValue += abs(vNum[i]);
		}
	}

	cout << retValue << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007


int main(){
    int n;
    cin >> n;
    int dict[n],p[n],q[n];
    rep(i,n){
        dict[i] = i+1;
    }
    rep(i,n){
        int a;
        cin >> a;
        p[i] = a;
    }
    rep(i,n){
        int a;
        cin >> a;
        q[i] = a;
    }
    int a,b,count;
    count = 0;

    do{
        bool pok = true;
        bool qok = true;
        rep(i,n){
            if(dict[i] != p[i]) pok = false;
            if(dict[i] != q[i]) qok = false;
        }
        if(pok) a = count;
        if(qok) b = count;
        count++;
    }while(next_permutation(dict,dict+n));
    cout << abs(a-b) << endl;

}

Measured memory_bytes: 3620
# include <bits/stdc++.h>
using namespace std;
# define ll long long
const int N = 2e5 + 10;
ll a[N] , b[N] , diff[N] , ans , k , n;
bool check(ll x){
	ll res = 0;
	for(int i = 0; i < n; i ++)
		res += max(0ll , a[i] - x / b[i]);
	return res <= k;
}
int main(){
	cin >> n >> k;
	for(int i = 0; i < n; i ++) cin >> a[i];
	for(int i = 0; i < n; i ++) cin >> b[i];
	sort(a , a + n);
	sort(b , b + n);
	reverse(b , b + n);
	ll l = 0 , r = a[n - 1] * b[0];
	while(l <= r){
		ll m = (l + r) >> 1;
		if(check(m)) r = m - 1 , ans = m;
		else l = m + 1;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3328
def main():
	n, m =  map(int , input().split())
	ab = []
	for i in range(0 , n):
		ab.append(list(map(int , input().split())))
	ab.sort()
	ans = 0
	for i in range(0 , n):
		if (m-ab[i][1]>=0):
			m = m-ab[i][1]
			ans = ans+(ab[i][0]*ab[i][1])
		elif(m>0):
			ans = ans+(m*ab[i][0])
			m  = 0
	print(ans)
if __name__ =="__main__":
	main()

Measured memory_bytes: 90224
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <map>

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

using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int sum = A + B + C;
    int M = max(C, max(A, B));
    int t = M;
    if(M % 2 != sum % 2){
        t = M + 1;
    }
    int ans = (3 * t - sum) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def main(sx, sy, tx, ty):
    answer = ''
    d_x = tx - sx
    d_y = ty - sy

    one_right = 'R' * d_x
    one_up    = 'U' * d_y
    answer += one_up + one_right

    one_down  = 'D' * d_y
    one_left  = 'L' * (d_x + 1)
    answer += one_down + one_left

    two_up    = 'U' * (d_y + 1)
    two_right = 'R' * (d_x + 1)
    answer += two_up + two_right + 'DR'

    two_down  = 'D' * (d_y + 1)
    two_left  = 'L' * (d_x + 1)
    answer += two_down + two_left + 'U'

    return answer

# print(main(
#     0, 0, 1, 2
# ))

if __name__ == '__main__':
    sx, sy, tx, ty = [int(e) for e in input().split()]
    print(main(sx, sy, tx, ty))


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

using namespace std;

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int num1 = (C+B-1)/B;
  int num2 = (A+D-1)/D;

  string ret = (num1 <= num2) ? "Yes" : "No";
  
  cout << ret << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n;i++)
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
    string s;
    cin >> s;
    int ans=0;
    int n=s.size();
    rp(i,n/2){
        if(s.at(i)!=s.at(n-1-i)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
S = input()
flag = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "L":
            flag = 1
            break
    else:
        if S[i] == "R":
            flag = 1
            break

if flag == 0:
    print("Yes")
else:
    print("No")

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

int main()
{
    long long a,b,c,d,mx;
    cin >> a >> b >> c >> d;
        
    mx = max(a*c,b*d);
    mx = max(mx,max(a*d,b*c));
    cout << mx << endl;
    
    return 0;
}

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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;
const ll llmx = 2e18;

ll pow2(ll a, ll b){
  ll ans=1;
  for(ll i=0; i<b; i++){
    ans = ans*a;
  }
  return ans;
}

int main(void){
  ll X;
  cin >> X;
  
  ll test=0,pre=0,ans=0;
  vector<ll> gojo;
  
  for( ; abs(ans-pre)<=X; test++){
    pre=ans;
    ans=pow2(test,5);
    gojo.push_back(ans);
  }
  
  for(int i = 0; i<gojo.size(); i++){
    //cout << i << " " << gojo[i] << "\n";
    for(int j = i; j<gojo.size(); j++){
      if(X==gojo[i]+gojo[j]){
        cout << i << " -" << j;
        return 0;
      }
      if(X*-1==gojo[i]+gojo[j]){
        cout << "-" << i << " " << j;
      }
      if(X==gojo[i]-gojo[j]){
        cout << i << " " << j;
      }
      if(X*-1==gojo[i]-gojo[j]){
        cout << "-" << i << " -" << j;
      }
    }
  }
  
  
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

int main()
{

    int n;
    std::cin >> n;
    std::vector<int> a(n);
    std::set<int> as;
    for (int i = 0; i < n; i++)
    {
        std::cin >> a[i];
        as.insert(a[i]);
    }

    std::sort(a.begin(), a.end());

    int ans = 1;
    for (auto itr = as.begin(); itr != as.end(); itr++)
    {
        int max = std::upper_bound(a.begin(), a.end(), (*itr) + 2) - std::lower_bound(a.begin(), a.end(), (*itr));
        ans = std::max(ans, max);
    }

    std::cout << ans << "\n";
}


Measured memory_bytes: 6564
#include <bits/stdc++.h>
#include <iomanip>      // std::setprecision
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FENWICK(k) (k&-k)
#define FOREACH(i,t) for (auto i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define LL long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}};
const int fxx[8][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int rogi[4][2] = { {1,1}, {1,-1}, {-1,1}, {-1,-1} };


void dane() {
	int a,b;
	cin>>a>>b;
	cout<<(a<b?"0":"10");
}   


int main() {
	IOS
	// int t;
	// cin>>t;
	// F(i,0,t)
	    dane();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

lin c[4];
int main(void)
{
    rep(i,3)
    {
        lin a,b;
        cin >> a >> b;
        c[a-1]++;
        c[b-1]++;
    }

    bool res = true;
    rep(i,4)
    {
        if(c[i] >= 3)
            res = false;
    }

    if(res)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


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

const int MOD = 1000000007;

struct mint
{
    int64_t x;
    mint(int64_t x = 0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += MOD - a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(int64_t n) const
    {
        if (n == 0)
            return 1;
        mint t = pow(n >> 1);
        t *= t;
        if (n & 1)
            t *= *this;
        return t;
    }
    mint inv() const { return pow(MOD - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

vector<mint> fac;
vector<mint> fac_inv;
vector<mint> inv;
void init_comb(int mx)
{
    fac = vector<mint>(mx + 1), fac_inv = vector<mint>(mx + 1), inv = vector<mint>(mx + 1);
    fac.at(0) = fac.at(1) = 1;
    fac_inv.at(0) = fac_inv.at(1) = 1;
    inv.at(1) = 1;
    for (int i = 2; i <= mx; i++)
    {
        fac.at(i) = fac.at(i - 1) * i;
        inv.at(i) = -inv.at(MOD % i) * (MOD / i);
        fac_inv.at(i) = fac_inv.at(i - 1) * inv.at(i);
    }
}
mint comb(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac.at(n) * fac_inv.at(k) * fac_inv.at(n - k);
}

void solve(int K, string S)
{
    init_comb((int)1e6 * 2 + 1);
    int len = K + S.size();

    mint res = 0;
    for (int r = 0; r <= K; r++)
    {
        res += comb(len - r - 1, S.size() - 1) * mint(25).pow(K - r) * mint(26).pow(r);
    }
    cout << res << endl;
}

int main()
{
    int K;
    cin >> K;
    string S;
    cin >> S;
    solve(K, S);
    return 0;
}


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

int a[100];

int main()
{
    memset(a,0,sizeof(a));
    int i,j;
    for(i=1;i<10;i++)
        for(j=1;j<10;j++)
            a[i*j]=1;
    int n;
    while(cin>>n)
        if(a[n])
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
}


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

using namespace std;

int main()
{
    int n;
    cin >>n;
    int v[n];
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    sort(v,v+n);
    double ans=v[0];
    for(int i=1;i<n;i++){
        ans=(ans+v[i])/2.0;
    }
    cout << setprecision(20)<< ans << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()

flag = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "L":
            flag = 1
    else:
        if S[i] == "R":
            flag = 1
if flag == 1:
    print("No")
else:
    print("Yes")

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

const int MAX_N = 200005;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(MAX_N);

vector<int> to[MAX_N];

struct DP {
  mint dp;
  int t;
  DP(mint dp=1, int t=0):dp(dp),t(t) {}
  DP& operator+=(const DP& a) {
    dp *= a.dp;
    dp *= comb(t+a.t, t);
    t += a.t;
    return *this;
  }
  DP operator-(const DP& a) const {
    DP res(*this);
    res.t -= a.t;
    res.dp /= comb(res.t+a.t, res.t);
    res.dp /= a.dp;
    return res;
  }
  DP addRoot() const {
    DP res(*this);
    res.t++;
    return res;
  }
};

vector<DP> dp[MAX_N];
DP dpSum[MAX_N];

DP dfs(int v, int p=-1) {
  dp[v] = vector<DP>(to[v].size());
  rep(i,to[v].size()) {
    int u = to[v][i];
    if (u == p) continue;
    dp[v][i] = dfs(u,v);
    dpSum[v] += dp[v][i];
  }
  return dpSum[v].addRoot();
}
void bfs(int v, const DP& dpP=DP(), int p=-1) {
  if (p != -1) dpSum[v] += dpP;
  rep(i,to[v].size()) {
    int u = to[v][i];
    if (u == p) {
      dp[v][i] = dpP;
      continue;
    }
    DP d = dpSum[v] - dp[v][i];
    bfs(u, d.addRoot(), v);
  }
}

int main() {
  int n;
  cin >> n;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  dfs(0);
  bfs(0);
  rep(i,n) {
    cout << dpSum[i].addRoot().dp << endl;
  }
  return 0;
}

Measured memory_bytes: 34292
N, K = map(int, input().split())
coin_num_list = []
if N != K:
    for i in range(1, min(K, N+1)):
        dice_val = i
        j = 0
        while dice_val < K:
            dice_val *= 2
            j += 1
        coin_num_list.append(j)
else:
    for i in range(1, K):
        dice_val = i
        j = 0
        while dice_val < K:
            dice_val *= 2
            j += 1
        coin_num_list.append(j)
pro_sum = 0
for coin_val in coin_num_list:
    pro_sum += (1/2)**coin_val
if N >= K:
    print((N-K+1)/N + pro_sum/N)
else:
    print(pro_sum/N)

Measured memory_bytes: 3316
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
int zyu(int x)
{
	if (x % 10 == 0)
		return x;
	else
		return (x/10+1) * 10;
}

int main()
{
	vector<int> x(5);
	for (int i = 0; i < 5; i++)
		cin >> x.at(i);
	
	int t=0;
	for (int j = 4; j >= 0; j--)
	{
		if (x.at(j) % 10 != 0)
			t = j;
	}
	for(int m=t;m<4;m++)
	{if (x.at(m) % 10 > x.at(m + 1)%10 && x.at(m + 1)%10 > 0)
		{
			if (x.at(m + 1) % 10 < x.at(t) % 10)
					t = m + 1;
		}
	}
	int Sum = zyu(x[0]) + zyu(x[1]) + zyu(x[2]) + zyu(x[3]) + zyu(x[4]);
	if (x.at(t) % 10 == 0)
		cout << Sum << endl;
	else
		cout << Sum + x.at(t)%10 - 10 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint n, a, b; cin >> n >> a >> b;
  
  if((b - a) % 2 == 0) {
    cout << (b - a) / 2 << endl;
  } else {
    lint ans1 = a - 1;
    ans1 += (b - a - 1) / 2 + 1;
    lint ans2 = n - b + (b - a - 1) / 2 + 1;
    cout << min(ans1, ans2) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int N;
	int a[110];
	int b[9];
	for (int i = 0; i < 9; ++i) {
		b[i] = 0;
	}
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		for (int j = 0; j < 8; ++j) {
			if (j * 400 <= a[i] && a[i] < (j + 1) * 400)
				b[j]++;
		}
		if (3200 <= a[i])
			b[8]++;
	}
	int mn = 0;
	int mx = 0;
	for (int j = 0; j < 8; ++j) {
		if (b[j] > 0) {
			mn++;
			mx++;
		}
	}
	if (mn == 0)mn++;
	if (b[8] > 0)mx += b[8];
	cout << mn << " " << mx;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int a,b,c,d;cin>>a>>b>>c>>d;
    int ans;

    if(a<=c && c<=b && a<=d && d<=b) ans = d-c;
    else if(a<=c && c<=b) ans = b-c;
    if(c<=a && a<=d && c<=b && b<=d) ans = b-a;
    else if(c<=a && a<=d ) ans = d-a;
    if(d<=a) ans = 0;
    if(b<=c) ans = 0;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////
 
#define fs first
#define sc second
#define pb push_back
//#define int long long
#define len(x) (int)(x).size()     
#define all(x) (x).begin(), (x).end()
#define test int _; cin >> _; while(_--)
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
 
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MOD = 1e9+7;
 
inline ll gcd(ll a, ll b){while(b){ a %= b; swap(a, b); } return a; }
inline ll mod(ll a, ll b){return ((a%b)+b)%b;}
inline ll expo(ll b, ll p, ll m = MOD){
  ll ans = 1; 
  while(p > 0){
    if(p&1LL) ans = mod(ans*b, m); 
    b = mod(b*b, m); 
    p >>= 1LL;
  } 
  return ans;
}
 
////////////////////////// Solution starts below. //////////////////////////////

int32_t main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
  return 0; 
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m; cin >> n >> m;
	vs v(m);
	cin >> v;
	int ans = 0, ansdif = 0, dif = 0;
	REP(i, n)REP(j, m)
	{
		if (v[j][i] == 'W') dif++;
	}
	ansdif = dif;
	REP(i, n)
	{
		REP(j, m)
		{
			if (v[j][i] == 'W')
			{
				dif -= 2;
			}
			else
			{
				dif += 2;
			}
		}
		if (ansdif > dif)
		{
			ans = i + 1;
			ansdif = dif;
		}
	}
	cout << ans << " " << ans + 1 << endl;
	return 0;
}


Measured memory_bytes: 4264
import heapq as pq

N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

day_to_reward = {}
for a, b in AB:
    if day_to_reward.get(a) is None:
        day_to_reward[a] = [b]
    else:
        day_to_reward[a].append(b)

ans = 0
candidate = []
for i in range(1, M+1):
    for reward in day_to_reward.get(i, []):
        pq.heappush(candidate, - reward)
    if candidate:
        ans += - pq.heappop(candidate)

print(ans)


Measured memory_bytes: 33868
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#define int long 
using namespace std;

signed main() {
	int N;
	cin >> N;
	vector<int> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	vector<int> count(1000000);
	for(int i = 0;i < N;i++) {
		count.at(vec.at(i))++;
		count.at(vec.at(i) + 1)++;
		count.at(vec.at(i) + 2)++;
	}
	int answer = 0;
	for(int i = 0;i < 1000000;i++) {
		answer = max(answer,count.at(i));
	}
	cout << answer << endl;
}

Measured memory_bytes: 8832
#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;

const int N = 1e5 + 2;

int n, h[N];
long long dp[N];

long long calc(int i)
{
    if (i == n - 1)
    {
        return 0;
    }
    long long &ret = dp[i];
    if (ret != -1)
    {
        return ret;
    }
    ret = 1e9;
    ret = min(ret, calc(i + 1) + abs(h[i + 1] - h[i]));
    if (i + 2 < n)
    {
        ret = min(ret, calc(i + 2) + abs(h[i + 2] - h[i]));
    }
    return ret;
}

int main()
{
    memset(dp, -1, sizeof dp);
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> h[i];
    }
    cout << calc(0) << endl;
    return 0;
}

Measured memory_bytes: 4608
from itertools import combinations
from fractions import gcd

#coding:utf8
import random

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True
ans=0

a,b=map(int,input().split())
c=gcd(a,b)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
s=make_divisors(c)
for i in s:
    ans=ans+is_prime3(i)
print(ans+1)

Measured memory_bytes: 5612
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    string A,B,C;
    int N,M,K,X,Y,W,H;
    int ans;
    string S;
    int temp[100]={0};
    bool f=true;
    bool fir=true;

int main(){
    cin>>A>>B>>C;
    N='a'-'A';
    S+=(A[0]-=N);
    S+=(B[0]-=N);
    S+=(C[0]-=N);
    cout<<S;
    return 0;

}


Measured memory_bytes: 256
from fractions import gcd

def lcm (x, y):
    return (x * y) // gcd(x, y)

N = int(input())
a = list(map(int, (input().split())))
l = (a[0] * a[1]) // gcd(a[0], a[1])

for i in a[2:]:
    l = lcm(l, i)

l -= 1

ans = sum(map(lambda x: l%x , a))
print(ans)

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

using namespace std;
using ll = long long;
using P = pair<int,int>;

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

    int A,X;
    cin >> A >> X;

    if (X > A) {
        cout << "0" << endl;
    }

    else if (X <= A) {
        cout << "10" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vll path;
//***********//
int main() {
	cin >> N;
	vl A(N);
	for (i = 0; i < N; i++) cin >> A[i];
	for (i = 0; i < N; i++) {
		if ((i + 1) % 2 == 1 && A[i] % 2 == 1) ans++;
	}
	co(ans);
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N+2, 0), B(N+2, 0);
	for (ll i = 1; i <= N; ++i)
	{
		cin >> A[i];
		B[i] = A[i];
	}
	A[0] = A[N+1] = 0;

	vector<ll> dist(N+1, 0);
	for (ll i = 0; i < N+1; ++i)
		dist[i] = abs(A[i] - A[i+1]);
	ll ds = accumulate(dist.begin(), dist.end(), 0ll);

	for (ll i = 1; i <= N; ++i)
	{
		ll res{ds};
		res -= (dist[i-1] + dist[i]);
		res += abs(A[i-1] - A[i+1]);
		std::cout << res << std::endl;
	}
}


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

int main(){
  int a,b,c,d,e,f;
  int maxcheck=-1,maxnumber;
  scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
  int water[35];
  int consent[35],maxsuger[35];
  int i,j,k;
  int suger=0;
  for(i=0;i<35;i++){
    water[i]=0;
    maxsuger[i]=0;
    consent[i]=0;
  }
  for(i=0;i<30;i++){
    for(j=0;j<20;j++){
      if(a*i*100+b*j*100<=f){
        water[a*i+b*j]=1;
      }
    }
  }
  for(i=1;i<=30;i++){
    if(water[i]==1){
      suger = i*e;
      for(j=0;j<50;j++){
        for(k=0;k<50;k++){
          if((c*j+d*k<=suger) && (c*j+d*k+i*100<=f) && (maxsuger[i] < c*j+d*k)){
            maxsuger[i]=c*j+d*k;
          }
        }
      }
    }
  }
  for(i=1;i<30;i++){
    if(water[i]==1){
      consent[i]=maxsuger[i]*10000/(i*100+maxsuger[i]);
    }
  }
  for(i=1;i<35;i++){
    if(consent[i]>maxcheck && water[i] == 1){
      maxcheck = consent[i];
      maxnumber = i;
    }
  }
  printf("%d %d\n",maxnumber*100+maxsuger[maxnumber],maxsuger[maxnumber]);
  return 0;
}

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

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

int main() {
  long N;
  cin >> N;
  long ans = 0;
  for (auto[a, b] : pf(N)) {
    int i = 1;
    while (b >= i) b -= i++, ans++;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3616