akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////


void solve() {
	int a, b, c; cin >> a >> b >> c;
	if(a == b && b == c) cout << "Yes\n";
	else cout << "No\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#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>;

int main() {
	ll a;
	double b;
	cin >> a >> b;
	ll ib=b*100+0.5;
	ll prod=a*ib/100;
	cout << prod << endl;
	return 0;
}


Measured memory_bytes: 3700
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
const int MAX = 10000;
const int INFTY = (1 << 20);
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;
int n;
vector<pair<int, int>> adj[MAX];
void dijkstra()
{
	priority_queue<pair<int, int>> PQ;
	int color[MAX];
	int d[MAX];
	for (int i = 0; i < n; i++)
	{
		d[i] = INFTY;
		color[i] = WHITE;
	}
	d[0] = 0;
	PQ.push(make_pair(0, 0));
	color[0] = GRAY;
	while (!PQ.empty())
	{
		pair<int, int> f = PQ.top();
		PQ.pop();
		int u = f.second;
		color[u] = BLACK;
		if (d[u] < f.first*(-1))
			continue;
		for (int j = 0; j < adj[u].size(); j++)
		{
			int v = adj[u][j].first;
			if (color[v] == BLACK)
				continue;
			if (d[v] > d[u] + adj[u][j].second)
			{
				d[v] = d[u] + adj[u][j].second;
				PQ.push(make_pair(d[v] * (-1), v));
				color[v] = GRAY;
			}
		}
	}
	for (int i = 0; i < n; i++)
		cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
}
int main()
{
	int k, u, v, c;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> u >> k;
		for (int j = 0; j < k; j++)
		{
			cin >> v >> c;
			adj[u].push_back(make_pair(v, c));
		}
	}
	dijkstra();
}


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

int main(){
    long long a,b,x(0),k;

    cin >> a >> b >> k;

    for(long long i=a;i<=b;i++){
        if(i<a+k){
            cout << i << endl;
            if(i>b-k)
                continue;
        }
        if(i>b-k){
            cout << i << endl;
        }
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;




int main() {
    int q;
    cin >> q;
    vector<int> l(q), r(q);
    rep(i, q)cin >> l[i] >> r[i];
    //hurui
    vector<int> p(100010, 1);
    int n = p.size();
    p[0] = 0;
    p[1] = 0;
    for (int i = 2; i < (int)(n); i++) {
        if (p[i] == 0)continue;
        for (int j = 2; i*j < (int)(n); j++) {
            
            p[i * j] = 0;
        }
    }
    //2017
    vector<int> a(100010, 0);
    for (int i = 2; i < (int)100010; i++) {
        if (p[i] % 2 == 0)continue;
        if (p[i] == 1 && p[(i + 1) / 2] == 1)a[i] = 1;
    }
    //累積和
    vector<int> s(100010, 0);
    for (int i = 2; i < (int)100008; i++) s[i + 1] = s[i] + a[i];

    //クエリ
    rep(i, q) {

        cout << s[r[i]+1] - s[l[i]] << endl;
    }
   
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;
long long comb[2001][2001];

void solve(){
  memset(comb, 0, sizeof(comb));
  comb[0][0]=1;
  comb[1][0]=1;
  comb[1][1]=1;
  for(int cnt0=2; cnt0<2001; cnt0++){
    for(int cnt1=0; cnt1<=cnt0; cnt1++){
      if(cnt1==0 || cnt1==cnt0) comb[cnt0][cnt1]=1;
      else comb[cnt0][cnt1]=(comb[cnt0-1][cnt1-1] + comb[cnt0-1][cnt1])%mod;
    }
  }
  /*
  for(int cnt0=1; cnt0<10; cnt0++){
    for(int cnt1=0; cnt1<=cnt0; cnt1++){
      cout << "comb[" << cnt0 << "][" << cnt1 << "]: " << comb[cnt0][cnt1] << " ";
    }
    cout << endl;
  }
  */
}

int main(int argc, char** argv){
  int N, K;
  cin >> N >> K;
  
  
  solve();
  for(int i=1; i<=K; i++){
    if(N-K+1 < i) {printf("0\n"); continue;}
    printf("%lld\n", comb[K-1][i-1]*comb[N-K+1][i]%mod);
  }
  return 0;
}

Measured memory_bytes: 31488
/*
"Won't stop untill I'm Phenomenal"
- Phenomenal, EMINEM
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    ll n; cin>>n;
    ll ans = 0;
    vector<int> faclist;
    for(ll i = 2; i*i <=n; i++){
        if(n%i==0){
            int c = 0;
            while(n%i==0){
                c++;
                n/=i;
            }
            faclist.push_back(c);
        }  
    }
    if(n>=2) ans++;
    
    
    for(int i : faclist){
        int c = 0;
        int s = 0;
        while(s<i){
            c++;
            s+=c;
            if(s<=i)
                ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<sstream>
#include<string>
 
int main(){
    while(1){
      std::string str1,str2;
      std::cin>>str1;
      if(str1==".") break;
      std::cin>>str2;
      std::string s11[201],s22[201];
      for(int i=0;i<201;i++){
	s11[i]=".";s22[i]=".";
      }
      s11[0]="";s22[0]="";
      int now1=0,now2=0;
      int l1,l2;
      l1=str1.size();
      l2=str2.size();
      for(int i=0;i<l1;i++){
	if(str1[i]=='"'){
	  now1++;
	  s11[now1]="";
	}else s11[now1]+=str1[i];
      }
      for(int i=0;i<l2;i++){
	if(str2[i]=='"'){
	  now2++;
	  s22[now2]="";
	}else s22[now2]+=str2[i];
      }
      int mistake=0;
      for(int i=0;i<201;i++){
	if(s11[i]!=s22[i]){
	  if(i&1){
	    mistake++;
	  }else mistake+=2;
	}
      }
      if(mistake==0){
	std::cout<<"IDENTICAL";
      }else if(mistake==1){
	std::cout<<"CLOSE";
      }else{
	std::cout<<"DIFFERENT";
      }
      std::cout<<"\n";
    }
}


Measured memory_bytes: 3196
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ld ans;
    ld r;
    cin>>r;
    ans=2*M_PI*r;
    cout<<ans<<"\n";
}

int main(int argc, char const *argv[]){
    ThunderClap;
    cout<<fixed<<setprecision(10);
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 3800
// Written by newbiechd
#include <cstdio>

const int maxN = 5003;
int dp[maxN];
inline int min(int x, int y) { return x < y ? x : y; }

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  
  dp[0] = 1;
  for (int i = 1; i < n; ++i) {
    int k = min(i, n - i + 1);
    for (int j = k; j < n; ++j)
      dp[j] = (dp[j] + dp[j - k]) % m;
  }
  
  int ans = 0;
  for (int j = 0; j < n; ++j)
    ans = (1ll * (n - j) * dp[j] + ans) % m;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    string t[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

    string s;
    cin >> s;

    rep(i, 7){
        if(t[i] == s){
            cout << 7 - i << endl;
            return 0;
        }
    }

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
const int MAXN = 5005;
const int mod = 1e9 + 7;

lint ipow(lint x, lint p){
	lint ret = 1, piv = x % mod;
	while(p){
		if(p&1) ret *= piv;
		piv *= piv;
		ret %= mod;
		piv %= mod;
		p >>= 1;
	}
	return ret % mod;
}
typedef pair<int, int> pi;

vector<int> gph[MAXN];
int sz[MAXN], msz[MAXN];

void dfs(int x, int p){
	sz[x] = 1;
	for(auto &i : gph[x]){
		if(i != p){
			dfs(i, x);
			sz[x] += sz[i];
			msz[x] = max(msz[x], sz[i]);
		}
	}
}

int cnt[MAXN];
int n, c;

void dfs2(int x, int p, int c){
	cnt[c]++;
	for(auto &i : gph[x]){
		if(i != p){
			dfs2(i, x, c);
		}
	}
}

int dp[MAXN][MAXN];
lint fact[MAXN], invf[MAXN];

int solve(int y, int i){
	lint ans = (fact[y] * invf[y - i] % mod) * (fact[y] * invf[y - i] % mod);
	ans %= mod;
	ans *= invf[i];
	ans %= mod;
	if(i % 2 == 1) ans = (mod - ans) % mod;
	return ans;
}

int f(int x, int y){
	if(x == c+1) return fact[y];
	if(~dp[x][y]) return dp[x][y];
	lint ret = f(x+1, y);
	for(int i=1; i<=cnt[x]; i++){
		ret += 1ll * f(x+1, y-i) * solve(cnt[x], i) % mod;
		ret %= mod;
	}
	return dp[x][y] = ret;
}

void solve(int r){
	fact[0] = 1;
	for(int i=1; i<=n; i++) fact[i] = 1ll * i * fact[i-1] % mod;
	for(int i=0; i<=n; i++) invf[i] = ipow(fact[i], mod - 2);
	for(auto &i : gph[r]){
		dfs2(i, r, ++c);
	}
	memset(dp, -1, sizeof(dp));
	printf("%d\n", f(1, n));
}

int main(){
	scanf("%d",&n);
	for(int i=0; i<n-1; i++){
		int s, e;
		scanf("%d %d",&s,&e);
		gph[s].push_back(e);
		gph[e].push_back(s);
	}
	dfs(1, 0);
	pi cen(1e9, 0);
	for(int i=1; i<=n; i++){
		int cur = max(msz[i], n - sz[i]);
		cen = min(cen, pi(cur, i));
	}
	solve(cen.second);
}


Measured memory_bytes: 98944
import java.util.Scanner;

public class Main {

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		String[] arr = input.split("");
		StringBuilder sb = new StringBuilder();

		for(int i = 0, len = arr.length; i < len; i++){
			switch(arr[i]){
				case "0":
				case "1":
					sb.append(arr[i]);
					break;
				case "B":
					if(sb.length() != 0){
						sb.deleteCharAt(sb.length() - 1);
					}
					break;
			}
		}

		System.out.println(sb);
	}

}

Measured memory_bytes: 9428
#include <iostream>

using namespace std;

int main(){
  int age;
  cin >> age;
  if(age == 1){
  	cout << "Hello World" << endl;
  }else if(age == 2){
    int num1;
    int num2;
    cin >> num1 >> num2;
    cout << num1 + num2 << endl;
  }
  
  return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

    int N;
    std::cin >> N;

    int M = 1110 - N;
    std::cout << M << std::endl;
}


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

using namespace std;

void Main() {
    long long N, K;
    cin >> N >> K;
    vector<long long> H(N, 0);
    for (long long i = 0; i < N; ++i) {
        cin >> H[i];
    }

    sort(H.begin(), H.end(), greater<long long>());
    for (long long i = 0; i < N; ++i) {
        if (K > 0) {
            H[i] = 0;
        }
        else {
            break;
        }
        --K;
    }

    long long ans = accumulate(H.begin(), H.end(), 0LL);
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 4728
def main():
    N = int(input())
    C = N
    if N%2 == 1:
        n = N//2+1
    else:
        n = N//2
    for i in range(1,n+1):
        A = str(i)
        B = str(N-i)
        c = 0
        for k in range(len(B)):
            if k < len(A):
                c += int(A[-k-1])+int(B[-k-1])
            else:
                c += int(B[-k-1])
        C = min(C, c)
    return C

if __name__ == "__main__":
    print(main())


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;

typedef unsigned long long ll;

const long long MOD = 1000000000 + 7;

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

//Union-Find tree
struct UnionFind{
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N;  i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る : root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y) { //xとyの木を併合
        int rx = root(x); //xの木の根をrx
        int ry = root(y); //yの木の根をyx
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)ときはそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時 : xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// 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;}



int main(){
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    mint fact[h+w+1];
    fact[0] = 1;
    for(int i = 1;i <= h + w; i++ ){
        fact[i] = fact[i-1]*i;
    }
    mint res=0;
    for(int i = h-a-1;i>=0;i--){
        int wide = max(b-1,0);
        mint part = fact[wide+i]/fact[wide]/fact[i];
        part *= fact[w-1-b+h-i-1]/fact[w-1-b]/fact[h-i-1];
        res += part;
    }
    cout << res << endl;
    return 0;
}


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

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

  ll x2 = 0;
  rep(i,N){
    if(i % 2 == 0) x2 += 2*A[i];
    else x2 -= 2*A[i];
  }
  ll x = x2/2;

  rep(i,N){
    if(i==0){
      cout << x << " ";
    } else if(i==N-1){
      x = 2*A[i-1] - x;
      cout << x << endl;
    } else {
      x = 2*A[i-1] - x;
      cout << x << " ";
    }
  }
}


Measured memory_bytes: 2048
pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                std::cmp::Ordering::Less => {
                    low = mid + 1;
                }
                std::cmp::Ordering::Equal | std::cmp::Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                std::cmp::Ordering::Less | std::cmp::Ordering::Equal => {
                    low = mid + 1;
                }
                std::cmp::Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

fn main() {
    proconio::input! {
        d: usize,
        cs: [i64; 26],
        sss: [[i64; 26]; d],
        ts: [usize; d],
    }
    let mut lastd = vec![vec![]; 26];
    fn lastdi(d: usize, i: usize, lastd: &Vec<Vec<usize>>) -> usize {
        let v = &lastd[i];
        *v.iter().filter(|x| **x <= d).last().or(Some(&0)).unwrap()
    }
    let mut score = 0i64;
    for (i, t) in ts.into_iter().enumerate() {
        score += sss[i][t - 1];
        lastd[t - 1].push(i + 1);
        let decline = (0..26)
            .map(|j| cs[j] * ((i + 1) as i64 - lastdi(i + 1, j, &lastd) as i64))
            .sum::<i64>();
        score -= decline;
        println!("{}", score);
    }
}


Measured memory_bytes: 2332
#include <stdio.h>

int main(){
int j=0,ai=0;
int i;
char moji[10002]={'\0'};

while(scanf("%s",moji) != EOF){
j=0;
ai=0;
for(i=0;moji[i+2]!='\0';i++){
if(moji[i]=='J' && moji[i+1]=='O' && moji[i+2]=='I'){
j++;
}
else if(moji[i]=='I' && moji[i+1]=='O' && moji[i+2]=='I'){
ai++;
}
}
printf("%d\n",j);
printf("%d\n",ai);
}
return 0;
}

Measured memory_bytes: 560
#include <stdio.h>
int main(void)
{
    int n;
    scanf("%d",&n);
    int L[n],i;
    
    for(i=0;i<n;i++){
        scanf("%d",&L[i]);
    }

    int j,k=0,l;
    j=L[0];
    for(i=0;i<n;i++){
        if(j<L[i]){
            j=L[i];
        }
    }

    for(i=0;i<n;i++){
        k=k+L[i];
    }

    if(j<k-j){
        puts("Yes");
    }else{
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 128
//  Created by liszt on 2019/07/27.
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n; cin>>n;
    vector<int> a(n+2);
    a[0]=a[n+1]=0;
    for(int i=1;i<=n;i++)cin>>a[i];
    
    long long sum=0;
    for(int i=0;i<=n;i++)sum+=abs(a[i]-a[i+1]);
    
    for(int i=1;i<=n;i++){
        long long ans=sum+abs(a[i-1]-a[i+1])-(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]));
        cout<<ans<<endl;
    }
    return 0;
}

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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

// template starts
typedef long long int ll;

// template ends here

ll b(ll N){
	ll low = 0, high = 1e8;
	ll ans= 0;
	while(low <= high){
		ll mid = (low+high)/2;
		ll temp = mid*(mid+1);
		temp /= 2;
		
		if(N >= temp){
			ans = mid;
			low = mid+1;
		}
		else high = mid-1;
	}
	return ans;
	
}

void solve(){
	// code starts from here
	ll N;
	cin >> N;
	
	ll ans = 0;
	for(ll i = 2; i*i <= N; i++){
		ll cnt = 0;
		while(N%i == 0){
			N /= i;
			cnt++;
		}
		ans += b(cnt);
	}
	if(N != 1) ans++;
	cout << ans << endl;
}

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

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h> 
using namespace std; 
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(void) {
    io;
    int a;
    cin >> a;
    int count = 0;
    if (a &1) count++;
    if (a & 2) count++;
    if (a & 4) count++;
    cout << count << endl;
    return 0;
}



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

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

using namespace std;

int main(){
    ll N, K;
    ll ans = 0;
    cin >> N >> K;
    if(K % 2){
        ans = pow(N / K, 3);
    }else{
        ll k = K / 2;
        ll x = N / K;
        // KでわってkあまるN以下の数のパターン数.
        ll y = (N + ((K -k) % K)) / K;
        ans = x * x * x + y * y * y;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*input
3
1 2 3
*/
#include <bits/stdc++.h>
using namespace std;
#define TEMPLATE

#ifdef TEMPLATE
	typedef long long ll;
	typedef long double ld;
	typedef complex<ld> cd;

	typedef pair<int, int> pi;
	typedef pair<ll,ll> pl;
	typedef pair<ld,ld> pd;

	typedef vector<int> vi;
	typedef vector<vi> vii;
	typedef vector<ld> vd;
	typedef vector<ll> vl;
	typedef vector<vl> vll;
	typedef vector<pi> vpi;
	typedef vector<vpi> vpii;
	typedef vector<pl> vpl;
	typedef vector<cd> vcd;
	typedef vector<pd> vpd;
	typedef vector<bool> vb;
	typedef vector<vb> vbb;
	typedef std::string str;
	typedef std::vector<str> vs;

	#define x first
	#define y second
	#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

	const int MOD = 1000000007;
	const ll INF = std::numeric_limits<ll>::max();
	const int MX = 100101;
	const ld PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270L;

	template<typename T>
	pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
	template<typename T>
	pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
	template<typename T>
	T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
	template<typename T>
	T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

	template<typename T>
	void print(vector<T> vec, string name = ""){
		cout << name;
		for(auto u: vec)
			cout << u << ' ';
		cout << '\n';
	}

#endif

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N;
	cin >> N;
	int nuliu = 0;
	vi sk(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> sk[i];
		nuliu ^= sk[i];
	}

	if(nuliu){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
	if(N > 3){
		if(nuliu == N)
			printf("Yes\n");
		else
			printf("No\n");
		return 0;
	}

	if((sk[0] ^ sk[1]) == sk[2] or (sk[0] ^ sk[2]) == sk[1] or (sk[1] ^ sk[2]) == sk[0])
		printf("Yes\n");
	else
		printf("No\n");
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( ) 
* array bounds
*/
	

Measured memory_bytes: 640
#include <iostream>
#include<vector>
using namespace std;
int k,i;
bool isPrime(int val) {
	if (val < 2)
		return false;
	for (k = 2; k * k <= val; k++) {
		if(val%k==0){
			return false;
		}
	}
	return true;
}

int main() {
	int n;
	int val,cnt;
	cnt=0;
	cin>>n;
	for(i=0;i<n;++i){
		cin>>val;
		if(isPrime(val)){cnt++;}
	}
	cout<<cnt<<endl;
return 0;
}

Measured memory_bytes: 3096
import math

N = int(input())

A = [0] * (N + 1)

for x in range(1, int(math.sqrt(N))):
    for y in range(1, int(math.sqrt(N))):
        for z in range(1, int(math.sqrt(N))):
            ans = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if (ans > N):
                break
            else:
                A[ans] += 1


for i in range(1, N + 1):
    print(A[i])


Measured memory_bytes: 69356
l={}
s=[]
h=[0]
n=d=m=0
for c in raw_input():
    if c=="\\":
        l[d]=n
        d-=1
    elif c=="/":
        d+=1
        if d in l:
            while len(s) and s[-1][1]>l[d]: s.pop()
            s.append([l[d],n])
    n+=1
    h.append(d)

a=[sum([h[i]-k for k in h[i:j+1]]) for i,j in s]
print sum(a)
print " ".join(map(str,[len(a)]+a))

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int main(){
    ll a,bl,ans;
    double b;
    cin>>a>>b;
    bl=b*100+0.5;
    ans=a*bl/100;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n,in[100000],p,i;
    cin>>n;

    for(i=1;i<=n;i++)
    {

        cin>>p;
        in[p]=i;
    }
    for(i=1;i<=n;i++)
        {
            cout<<in[i]<<" ";
        }
    return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
int main(void){
    int n;
    scanf("%d", &n);
    int num[100000+5]={0};
    for(int i=0; i<n; i++){
        int a;
        scanf("%d", &a);
        num[a]++;
    }
    
    int ans=0;
    for(int i=1; i<100000; i++){
        if(ans<num[i-1]+num[i]+num[i+1])ans=num[i-1]+num[i]+num[i+1];
    }
    printf("%d\n", ans);
    return 0;
}


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

typedef struct{
    double x;
    double y;
}point;

double ppp(int n,double leftx,double lefty,double rightx,double righty){
    if(n!=0){
        double temp[3][2];
        temp[0][0]=(2*leftx+rightx)/3;
        temp[0][1]=(2*lefty+righty)/3;
        temp[2][0]=(leftx+2*rightx)/3;
        temp[2][1]=(lefty+2*righty)/3;
        temp[1][0]=(temp[2][0]-temp[0][0])/2-(temp[2][1]-temp[0][1])*sqrt(3)/2+temp[0][0];
        temp[1][1]=(temp[2][0]-temp[0][0])*sqrt(3)/2+(temp[2][1]-temp[0][1])/2+temp[0][1];

        ppp(n-1,leftx,lefty,temp[0][0],temp[0][1]);
        printf("%lf %lf\n",temp[0][0],temp[0][1]);
        ppp(n-1,temp[0][0],temp[0][1],temp[1][0],temp[1][1]);
        printf("%lf %lf\n",temp[1][0],temp[1][1]);
        ppp(n-1,temp[1][0],temp[1][1],temp[2][0],temp[2][1]);
        printf("%lf %lf\n",temp[2][0],temp[2][1]);
        ppp(n-1,temp[2][0],temp[2][1],rightx,righty);
    }
    else return 0;
}

int main(){
    int n;
    scanf("%d",&n);
    point p1, p2;
    p1.x = 0.0;
    p1.y = 0.0;
    p2.x = 100.0;
    p2.y = 0.0;
    printf("%lf %lf\n",p1.x,p1.y);
    ppp(n,p1.x,p1.y,p2.x,p2.y);
    printf("%lf %lf\n",p2.x,p2.y);
    return 0;
}


Measured memory_bytes: 2056
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define ARR_MAX 200000
#define BUF_SIZE (ARR_MAX*7+50)

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    for(i = 0; i < size; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtol(tmp, NULL, 10);
        tmpbuf = NULL;
    }
#else
#error
#endif
    return 0;
}

#define max(a,b) ((a) > (b) ? (a) : (b))

int main(void) {
    static int arr[ARR_MAX];
    static int cum[ARR_MAX+1];
    int num, k;
    get_int2(&num, &k);
    fget_array(arr, num);
    int i;
    for(i = 1; i <= num; i++) {
        cum[i] = cum[i-1] + arr[i-1];
    }
    double ans = 0;
    for(i = k; i <= num; i++) {
        ans = max(ans, cum[i] - cum[i-k]);
    }
#ifdef DEBUG
    printf("%d\n", (int)ans);
#endif
    ans = (double)(ans + k)/2;
    printf("%.7lf\n", ans);
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 == 1 && b % 2 == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y,z;
bool flag=0;
cin>>x>>y;
if(y==100) z=(x*1000)+y;
if(y<100&&y>9) z=(x*100)+y;
if(y<=9) z=(x*10)+y;
for(int i=0;i<350;++i){

if(i*i==z){

flag=1;
break;
}}
if(flag==1)
cout<<"Yes\n";
else cout<<"No\n";

}


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

int main(void) {
  int n,m;
  cin >> n >> m;

  ll ans=0;
  if(n==1 && m==1){
    ans=1;
  } else if(n==1 || m==1) {
    ans=max(n,m)-2;
  } else {
    ans=(ll)(n-2)*(m-2);
  }

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


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

// type StringList []string

// func (s StringList) Len() int {
// 	return len(s)
// }

// func (s StringList) Swap(i, j int) {
// 	s[i], s[j] = s[j], s[i]
// }

// func (s StringList) Less(i, j int) bool {
// // ここで渡された Less が使う
// 	return s[i] < s[j]
// }

type StringList []string

func (a StringList) Len() int           { return len(a) }
func (a StringList) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a StringList) Less(i, j int) bool { return a[i] < a[j] }



var sc = bufio.NewScanner(os.Stdin)


func main() {
	var n, l int
	var s StringList = []string{}
	var ans string = "";

	fmt.Scan(&n, &l)
	for i := 0; i < n; i++{
		var inputString string
		fmt.Scan(&inputString)
		s = append(s, inputString)
	}

	sort.Sort(s)

	for  i := 0; i < n; i++ {
		ans += s[i]
	}

	fmt.Printf("%s\n", ans)
}


Measured memory_bytes: 2472
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
bool edge[3030][3030]; 
ll a[3030][3030];
int n;
ll ans;
bool flag;
int main()
{
	cin>>n;
	REP(i,n)
		REP(j,n)
			cin>>a[i][j];
	REP(k,n)
		REP(i,n)
			REP(j,n)
			{
				if(i==j||i==k||j==k)continue;
				if(a[i][j]==a[i][k]+a[k][j])
                    edge[i][j]=1; 
                if(a[i][j]>a[i][k]+a[k][j])
                    flag=1;
			 } 
	if(flag){
		cout<<-1<<endl;
		return 0;
	}
	REP(i,n)
		REP(j,n)
			if(!edge[i][j])ans+=a[i][j];
	cout<<ans/2<<endl;		
	return 0;
}



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

using namespace std;
 
typedef long long ll;

ll maxnr = 400000000;
set<ll> s;
void bkt(ll x)
{
    if(s.find(x) != s.end())
        return;
    s.insert(x);
    if(x >= maxnr)
        return;
    if(x == 0)
        for(int i = 1; i <= 9; ++i)
            bkt(i);
    else
    {
        int lst = x%10;
        if(lst > 0)
            bkt(x*10 + (lst-1));
        bkt(x*10 + lst);
        if(lst < 9)
            bkt(x*10 + (lst+1));
    }
}
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    int k;
    cin >> k;
    bkt(0);
    while(k)
    {
        s.erase(s.begin());
        --k;
    }
    cout << *s.begin();
    return 0;
}


Measured memory_bytes: 5504
#include <iostream>

using namespace std;

int main() {
    int L, R, d;
    cin >> L >> R >> d;

    int sum = 0;
    for (int i = L; i <= R; i++) {
        if (i % d == 0) {
            sum++;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3620
N = int(input())
stlist = []
bf = 0
al = 0
ab = 0
ba = 0
#test = ["BEWPVCRWH","ZZNQYIJX","BAVREA", "PA", "HJMYITE0X","BG","BP","QABZ","PRA"]
for i in range(N):
    tmp = str(input())
    ab += tmp.count("AB")
    if tmp[0] == 'B' and tmp[-1] == 'A':
        ba += 1
    elif tmp[0] =='B':
        bf+=1
    elif tmp[-1] =='A':
        al+=1
if al+bf+ba==0:
    print(ab)
elif al == 0 and bf ==0:
    print(ba-1+ab)
elif al * bf ==0:
    print(max(min(al-1, bf-1), 0) + ba + ab)
else:
    print(max(min(al-1, bf-1), 0) + ba +1 + ab)

Measured memory_bytes: 3064
n,k=map(int,input().split())
H=list(map(int,input().split()))

def flog(n):
	inf=float('inf')
	dp=[inf]*n
	
	dp[0]=0
	
	for i in range(n):
		for j in range(1,min(k+1,n-i)):
			dp[i+j]=min(dp[i+j],dp[i]+abs(H[i+j]-H[i]))
	
	return dp[n-1]
print(flog(n))

Measured memory_bytes: 55008
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
typedef long long ll;
const ll INF = 1e+18;

int main(){
    int A,B;
    int h=100;
    int w=100;
    int cnt;
    cin >> A >> B;
    int large,small;
    large=max(A,B);
    small=min(A,B);
    vector<vector<char>> ans(h,vector<char>(w,'#'));
    cnt=0;
    //A>B前提
    bool flag=false;
    for(int i=0;i<h;i+=4){
        for(int j=0;j<w;j+=4){
            rep(k,3){
                rep(l,3){
                    ans[i+k][j+l]='.';
                }
            }
            cnt++;
            if(cnt==large){
                flag=true;
            }
            if(flag) break;
        }
        if(flag) break;
    }

    cnt=0;
    flag=false;
    for(int i=0;i<h;i+=4){
        for(int j=0;j<w;j+=4){
            if(cnt==small-1){
                flag=true;
            }
            if(flag) break;
            ans[i+1][j+1]='#';
            cnt++;
            
        }
        if(flag) break;
    }

    if(A<B){
        rep(i,h){
            rep(j,w){
                if(ans[i][j]=='#') ans[i][j]='.';
                else ans[i][j]='#';
            }
        }
    }
    cout << h << " " << w << endl;
    rep(i,h){
        rep(j,w){
            cout << ans[i][j];
        }
        cout << endl;
    }
    
    
    



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long A, B, C;
	cin >> A >> B >> C;
	if (A == B) {
		cout << (4*A < C ? "Yes" : "No") << endl;
	} else {
		auto x = C-A-B;
		if (x <= 0) {
			cout << "No" << endl;
		} else {
			cout << (4*A*B < x*x ? "Yes" : "No") << endl;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int a[5001];
int main(int argc, const char * argv[]) {
  int n, k;
  cin >> n >> k;
  

  int ans = n;
  
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  sort(a, a + n);
  
  int sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (sum + a[i] < k) {
      sum += a[i];
    } else {
      ans = min(ans, i);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

n,m = map(int, sys.stdin.readline().split())

mid1 = set()
mid2 = set()
for _ in range(m):
    a,b, = map(int, input().split())
    if a == 1:
        mid1.add(b)
    elif b == n:
        mid2.add(a)
result = bool(mid1 & mid2)
if result:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 19024
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

bool is_prime(ll num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return false;
  else if (num % 2 == 0)
    return false;

  double sqrt_num = sqrt(num);
  for (ll i = 3; i <= sqrt_num; i += 2) {
    if (num % i == 0) return false;
  }
  return true;
}

void Main() {
  Cin(ll, n);
  if (is_prime(n)) {
    cout << n - 1 << endl;
    return;
  }
  ll ans = n - 1;
  for (ll i = 1; i <= sqrt(n); ++i) {
    ll j = n / i;
    if (i * j == n) ans = min(ans, i + j - 2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque

S = input()
Q = int(input())
right, left = deque(), deque()
right_inv, left_inv, S_inv = False, False, False

for q in range(Q):
  T = input().split(" ")
  if len(T) == 1:
    # reverse
    S_inv = not S_inv
    right_inv = not right_inv
    left_inv = not left_inv
  else:
    # append
    F, C = int(T[1]), T[2]
    if (F == 1) ^ S_inv:
      left.appendleft(C)
    else:
      right.append(C)

if S_inv:
  print(''.join(list(right)[::-1]), S[::-1], ''.join(list(left)[::-1]), sep='')
else:
  print(''.join(list(left)), S, ''.join(list(right)), sep='')

Measured memory_bytes: 6772
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int n, y;
  cin >> n >> y;
  int i, j, k;
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= n; j++) {
      for (k = 0; k <= n; k++) {
        if (10000 * i + 5000 * j + 1000 * k == y && i + j + k == n) {
          cout << i << ' ' << j << ' ' << k << endl;
          return 0;
        }
        if (10000 * i + 5000 * j + 1000 * k > y || i + j + k > n) {
          break;
        }
      }
      if (10000 * i + 5000 * j > y || i + j > n) {
        break;
      }
    }
    if (10000 * i > y) {
      break;
    }
  }
  cout << -1 << ' ' << -1 << ' ' << -1 << endl;
  return 0;
}


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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

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

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

int main(void)
{
    string s;
    cin >> s;
    int ans = s.size(), cnt = 0;
    for (auto c : s)
    {
        if (c == 'S')
            cnt++;
        else
        {
            if (cnt > 0)
                ans -= 2, cnt--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
N = int(input())
ans = 0
count = 0
#1の約数の数は絶対1、面倒なので2~Nのカウントにした。+1忘れないように
for i in range(2, N+1):
   for j in range(1, i+1):
      if i % j == 0:
         count += 1
   if count == 8 and i % 2 == 1:
      ans += 1
   count = 0

print(ans)

Measured memory_bytes: 9140
import math
n=int(input())
t=[int(input()) for _ in range(n)]
#print(t)
if n==1:
    print(t[0])
    exit()

for i in range(n-1):
    if i==0:
        lcm=(t[i]*t[i+1])//math.gcd(t[i],t[i+1])
    else:
        lcm=(lcm*t[i+1])//math.gcd(lcm,t[i+1])
print(lcm)

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//chcp 65001

signed main()
{
	int n,k;cin>>n>>k;
	int ans = k;
	for(int i = 1, i_len = (int)n; i < i_len; ++i){
		ans*=(k-1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, m, v, p) = (v[0] as usize, v[1], v[2], v[3]);
    let mut a = read_vec::<i64>();

    a.sort();
    a.reverse();

    let criterion = |x: usize| -> bool {
        let mut used = (p - 1) * m;
        let border = a[x] + m;
        for i in p as usize - 1..n {
            if i == x {
                continue;
            }
            if a[i] > border {
                return false;
            }
            used += min(m, border - a[i]);
        }
        if used >= m * (v as i64 - 1) {
            return true;
        } else {
            return false;
        }
    };
    let (ok, ng) = binary_search(0, n, criterion);
    println!("{}", ok + 1);
}

fn binary_search<F>(lb: usize, ub: usize, criterion: F) -> (usize, usize)
where
    F: Fn(usize) -> bool,
{
    let mut ok = lb;
    let mut ng = ub;
    while ng - ok > 1 {
        let mid = (ng + ok) / 2;
        if criterion(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    (ok, ng)
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main(){
	string S, A = "Good";
	cin >> S;
	for(int i = 0; i < 3; i++){
		if(S.at(i) == S.at(i+1))
			A = "Bad";
	}
	cout << A << endl;
	return 0;
}

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

int main(){
  string str = "";
  string str1, str2;
  cin >> str1 >> str2;
  str += str1;
  str += str2;
  int num = stoi(str);
  for(int i=1; i<=1000; i++){
    if(i*i == num){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std;

typedef long long int64;

int main()
{
  int N, T;

  cin >> N >> T;

  int64 ret = 0;
  int64 prev = -1;
  for(int i = 0; i < N; i++) {
    int64 A;
    cin >> A;

    if(i == 0) {
    } else if(prev + T >= A) {

      ret += A - prev;
    } else {
      ret += T;
    }
    prev = A;
  }

  cout << ret + T << endl;
}

Measured memory_bytes: 256
n, y = map(int, open(0).read().split())

for a in range(0, n+1):
    for b in range(0, n-a+1):
        c = n - a - b
        if a*10000 + b*5000 + c*1000 == y:
            print(a, b, c)
            import sys
            sys.exit(0)

print('-1 -1 -1')

Measured memory_bytes: 40784
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, P: "List[int]", Y: "List[int]"):
    from itertools import count
    from collections import defaultdict
    Q = sorted(zip(Y, P, count(0)))
    c = defaultdict(int)
    ans = [None] * M
    for y, p, i in Q:
        c[p] += 1
        ans[i] = str(p).zfill(6) + str(c[p]).zfill(6)
    return ans


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]"
    Y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        P[i] = int(next(tokens))
        Y[i] = int(next(tokens))
    print(*solve(N, M, P, Y), sep='\n')

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 37936