akhauriyash/Code-Regression huggingface dataset:
def num_divisions(num):
    for i in range(1+num):
        if num % 2**i == 0:
            pass
        else:
            return i - 1
        
        
N = int(input())
A = list(map(int, input().split()))

cnt = 0
for a in A:
    cnt += num_divisions(a)
print(cnt)

Measured memory_bytes: 4148
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)


int main() {
	ll n,s = 0,wo,ss;
	cin >> n;
	REPO(i, INF) {
		if (s >= n) {
			ss = i - 1;
			break;
		}
		s += i;
	}
	wo = s - n;
	REPO(i, ss) {
		if (i != wo) {
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin >> n >> k;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int h;
		cin >> h;
		if(h>=k)
			ans+=1;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
	int saimu = 100000;
	static const int riritsu = 5;	/* percent */
	static const int roundUnit = 1000;

	int n;
	std::cin >> n;

	for (int i = 0; i < n; ++i) {
		saimu += saimu / 100 * riritsu;
		saimu = ((saimu + roundUnit - 1) / roundUnit) * roundUnit;
	}

	std::cout << saimu << '\n';

	return 0;
}

Measured memory_bytes: 0
Sa = list(input())
Sb = list(input())
Sc = list(input())
player = 'a'
while True: 
    if player == 'a':
        if len(Sa) == 0:
            print('A')
            break
        player = Sa.pop(0)
    elif player == 'b':
        if len(Sb) == 0:
            print('B')
            break
        player = Sb.pop(0)
    else:
        if len(Sc) == 0:
            print('C')
            break
        player = Sc.pop(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,m;
  cin >> n >> m;
  vector<pair<LL,LL>> ba(n);
  for(auto &pa:ba) cin >> pa.second >> pa.first;
  sort(ba.rbegin(),ba.rend());
  set<LL> remp;
  REP(i,m) remp.insert(remp.end(),i+1);
  LL answer = 0;
  for(auto &pa:ba) {
    LL a,b;
    tie(b,a) = pa;
    if(remp.lower_bound(a)!=remp.end()) {
      answer += b;
      remp.erase(remp.lower_bound(a));
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 8320
#include <iostream>
using namespace std;
int main(){
   
   int S, s,m,h;

   cin>>S;

   h = S / 3600;
   
   m = (S % 3600) / 60;
   
   s = S % 60;
   
   
   cout<<h<<":"<<m<<":"<<s<<endl;

    
    return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi pair<ll,int> 
#define pii pair<int,ll>
 
ll mod = 1e9+7;
ll INF = 1e17;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
int main()
{
    IOS
    ll n,a,b;
    cin>>n>>a>>b;
    ll c1=n%(a+b);
    ll c2=n/(a+b);
    if(c1>a)
    {
        c1=0;
        c2++;
    }
    cout<<a*c2+c1;
    return(0);
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,d;
	long s1,s2;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	s1=a*b;
	s2=c*d;
	if(s1>s2)
	printf("%ld",s1);
	else printf("%ld",s2);
	
	
	
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

const LL  MAX = 2000001;
const LL  MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long  i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(long long  n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    long long x, y; cin >> x >> y;
    COMinit();

    auto dist = x + y;

    if (dist % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    auto total = (x + y) / 3;
    auto n = x - total;

    if (y > x * 2) {
        cout << 0 << endl;
    } else {
        auto ans = COM(total, n);
        cout << ans << endl;
    }
}


Measured memory_bytes: 47104
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s1;
    cin>>s1;
    string s2;
    cin>>s2;
    int n,m;
    m=s1.size();
    n=s2.size();
    int count=0;
    for(int i=0;i<m;i++){
        if(s1[i]!=s2[i]){
            count++;
        }
    }
    if(n==m+1&&count==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <cstring>
char s[10001];
int main()
{
	scanf("%s",s+1);int n=strlen(s+1);if(n&1){printf("No\n");return 0;}
	for(int i=1;i<=n;i+=2)if(s[i]!='h'){printf("No\n");return 0;}
	for(int i=2;i<=n;i+=2)if(s[i]!='i'){printf("No\n");return 0;}
	printf("Yes\n");return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	   int a ,b ;
	
	while(scanf("%d %d",&a ,&b ))
	{
		if(a == 0 && b == 0)
		{
			break;
			
		}
		else if(a>b)
		{
			printf("%d %d\n", b ,a);
			
		}
		else
		{
			printf("%d %d\n",a ,b );
		}
		
		
	}

return 0;

} 


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

#define ld			long double
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD         1000000007
#define sd(t) 		scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii 		cout << "hii" << endl
#define okay 		cout << "okay" << endl
#define hey 		cout << "hey" << endl

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
}

clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

const int N = 2e5+5;
int arr[N], h[N], bit[N];
int n, k;

int query(int idx){
	int ans = 0;

	while(idx > 0){
		ans = max(ans, bit[idx]);
		idx -= (idx&(-idx));
	}

	return ans;
}

void update(int idx, int val){

	while(idx <= n){
		bit[idx] = max(bit[idx], val);
		idx += (idx&(-idx));
	}
}

void solve()
{
	cin >> n;
	rep(i, 1, n+1) cin >> h[i];

	rep(i, 1, n+1) cin >> arr[i];
	int ans = 0;
	rep(i, 1, n+1){
		int curr = query(h[i])+arr[i];
		ans = max(ans, curr);
		update(h[i], curr);
	}

	cout << ans << endl;
}			 	

int32_t main(){
	fast();
    int t = 1;
    // cin>> t;
    while(t--){
    	solve();
    }
	starboy1299();
}




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

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

typedef long long ll;

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

int mod = 1000000007;
ll ans = 0;
ll N;
vector<ll> prime;

void dfs(ll acc, ll num, ll x, ll k){
    //cout << "num: " << num << ", acc: " << acc << ", prime[x]: " << prime[x] << ", k: " << k << endl;
    if(num != 1){
        acc /= k;
        acc *= (k+1);
        ans += num*acc;
    }
    for(int d = x; d < prime.size(); d++){
        if(num*prime[d] > N) return;
        if(d == x) dfs(acc, num*prime[d], d, k+1);
        else dfs(acc, num*prime[d], d, 1);
    }
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    vector<bool> pr(N+1, true);
    pr[0] = pr[1] = false;
    int ulim = sqrt(N)+1;
    for(int i = 2; i <= sqrt(N); i++){
        if(!pr[i]) continue;
        for(int j = (i << 1); j <= N; j+=i){
            pr[j] = false;
        }
    }
    for(int i = 2; i <= N; i++) if(pr[i]) prime.push_back(i);
    dfs(1, 1, 0, 0);
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 12856
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int A, B, N;
    cin >> N >> A >> B;
    int sum = 0;
    int sum_digit = 0;
    FOR(i, 1, N+1) {
        string s = to_string(i);
        REP(j, s.length()) {
            sum_digit += s[j] - '0';
        }
        if(sum_digit >=  A && sum_digit <= B) {
            sum += i;
        }
        sum_digit = 0;
    }
    cout << sum << endl;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int account=0;
		int tlecount=0;
		int wacount=0;int recount=0;
		while(n-->0) {
			String s=scan.next();
			if(s.equals("AC"))account++;
			else if(s.equals("WA"))wacount++;
			else if(s.equals("TLE"))tlecount++;
			else if(s.equals("RE"))recount++;
		}
		System.out.println("AC x "+account);
		System.out.println("WA x "+wacount);
		System.out.println("TLE x "+tlecount);
		System.out.println("RE x "+recount);
	}

}

Measured memory_bytes: 59200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {

	public void doIt() throws IOException{
		BufferedReader din = new BufferedReader(new InputStreamReader(System.in));
		String s;
		while((s = din.readLine()) != null){
			System.out.println(s.toUpperCase());
		}

	}
	public static void main(String[] args) {
		Main obj = new Main();
		try {
			obj.doIt();
		} catch (IOException e) {

		}

	}

}

Measured memory_bytes: 9040
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep_rev(i, n) for (int i = n-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

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

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}

template<class... T>
void debug_print(T... args){
    vector<lint> tmp = initializer_list<lint>{args...};
    print_vec(all(tmp));
}
template<class T>
void print(T a){ cout << a << endl;}

vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

int ord(char x){ return (int)(x - 'a');}
char chr(lint x){ return (char)(x + (lint)('a'));}
lint mod = 1e9+7;
// lint mod = 

lint sum(vlint a){lint ret = 0; for(auto&& v:a) ret += v; return ret;}
lint vmini(vlint a, lint &index){
    lint ret = LLONG_MAX;
    rep(i, Size(a)){ if (chmin(ret, a[i])) index = i;}
    return ret;
}
lint vmaxi(vlint a, lint &index){
    lint ret = -LLONG_MAX;
    rep(i, Size(a)){ if (chmax(ret, a[i])) index = i;}
    return ret;
}

lint vmin(vlint a){
    lint ret = LLONG_MAX; for (auto && v : a) chmin(ret, v); return ret;
}
lint vmax(vlint a){
    lint ret = -LLONG_MAX; for (auto && v : a) chmax(ret, v); return ret;
}


vlint base_3(int k){
    vlint ret; while (k > 0){ ret.pb(k % 3); k /= 3;} reverse(all(ret)); return ret;
}

int main(){
    INT(n, x, t); int ret = 0;
    while (n > 0){
        ret += t;
        n -= min(x, n);
    }
    print(ret);
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,n;
    cin>>x>>n;
    ll arr[1000]={0};
    ll temp;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        arr[temp]++;
    }
    ll ans=x;
    ll check=0;
    for(int i=0;i<1000;i++)
    {
        if(arr[i]!=0)
        continue;
        if(ans>abs(x-i))
        {
            ans=abs(x-i);
            check=i;
        }
    }
    cout<<check;


    
    return 0;
}

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

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  
  vector<vector<int>> color(W, vector<int>(H, 0));
  
  for (int i = 0; i < N; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      for (int k = 0; k < x; k++) {
        for (int l = 0; l < H; l++) {
          color.at(k).at(l) = 1;
        }
      }
    }
    else if (a == 2) {
      for (int k = x; k < W; k++) {
        for (int l = 0; l < H; l++) {
          color.at(k).at(l) = 1;
        }
      }
    }
    else if (a == 3) {
      for (int k = 0; k < W; k++) {
        for (int l = 0; l < y; l++) {
          color.at(k).at(l) = 1;
        }
      }
    }
    else {
      for (int k = 0; k < W; k++) {
        for (int l = y; l < H; l++) {
          color.at(k).at(l) = 1;
        }
      }
    }
  }
  
  int ans = 0;
  
  for (int k = 0; k < W; k++) {
    for (int l = 0; l < H; l++) {
      if (color.at(k).at(l) == 0) {
        ans++;
      }
    }
  }
  
  cout << ans << endl;
  
}


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

int main(){
    string str;
    cin >> str;
    bool reverseFlag = false;//これによって処理速くする
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int query1;
        cin >> query1;
        if( query1 == 1){
            reverseFlag = !reverseFlag;
        }else{
            int F;
            char mozi;
            cin >> F >> mozi;
            if(F == 1){
                if(reverseFlag == false){
                    string::iterator it = str.begin();
                    it = str.insert(it, mozi);
                }else{
                    str.push_back(mozi);
                }
            }else{
                if(reverseFlag == true){
                    string::iterator it = str.begin();
                    it = str.insert(it, mozi);
                }else{
                    str.push_back(mozi);
                }
            }
        }
    }

    int strLength = str.length();
    if(reverseFlag == true){
        for(int i = strLength - 1; i > -1; i--){
            cout << str.at(i);
        }
    }else{
        for(int i = 0; i < strLength; i++){
            cout << str.at(i);
        }
    }
    cout << endl;
}

Measured memory_bytes: 1028
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int cnt, cnt1;
	cnt = cnt1 = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (i % 2 == 0)
		{
			if (s[i] != '1')cnt++;
		}
		else
		{
			if (s[i] != '0')cnt++;
		}
	}
	for (int i = 0; i < s.length(); i++)
	{
		if (i % 2 == 1)
		{
			if (s[i] != '1')cnt1++;
		}
		else
		{
			if (s[i] != '0')cnt1++;
		}
	}
	int min = cnt < cnt1 ? cnt : cnt1;
	cout << min << endl;
}

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

int main() {
  int D,G,p[11],c[11];
  cin>>D>>G;
  rep(i,D)cin>>p[i]>>c[i];
  int ans=1001;
  for (int bit=0;bit<(1<<D);bit++) {
    int num=0,s=0,rest_max=-1;
    for (int i=0;i<D;i++) {
      if (bit &(1<<i)) {
        s+=100*(i+1)*p[i]+c[i];
        num+=p[i];
      }
      else {
        rest_max=i;
      }
    }
    if (s<G && rest_max!=-1) {
      int s1=100*(rest_max+1);
      int need=(G-s+s1-1)/s1;
      if (need>=p[rest_max]) {
        continue;
      }
      num+=need;
    }
    ans=min(ans,num);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

int main() {
	string S;
	int a[26] = { 0 };
	bool b = false;
	cin >> S;
	for (int i = 0; i<S.length(); i++) {
		a[(int)(S[i] - 'a')]++;
		if (a[(int)(S[i] - 'a')] == 2) {
			b = true;
			break;
		}
	}
	if (b) {
		cout << "no" << endl;
	}
	else {
		cout << "yes" << endl;
	}

}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');

    println!("{}", if a >= 3200 { s } else { "red".to_owned() });
}


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

int main() {
    int x,y,t;
  
    while(1){
          
        cin>>x>>y;
    
        if(x==0 && y==0) break;
    
        if(x>y){
            t=x;
            x=y;
            y=t; 
       }      

       cout<<x<<" "<<y<<endl;
    }
    
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> d(n);
  for(int i=0;i<n;i++){
      cin>>d[i];
  }
  sort(d.begin(),d.end());
  int ans=0;
  for(int i=1;i<n;i++){
      if(d[i]>d[i-1]) ans++;
  }
  cout<<ans+1<<endl;
}

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


int n;
int x[3000], y[3000];
bool mp[5001][5001];
int m, dx, dy, s;

int exists(int x, int y) {
  return 0 <= x && x <= 5000 && 0 <= y && y <= 5000 && mp[x][y] == 1;
}

int main(void) {
  while(cin >> n, n != 0) {
    REP(i, 0, 5001) {
      REP(j, 0, 5001) {
        mp[i][j] = 0;
      }
    }
    REP(i, 0, n) {
      cin >> x[i] >> y[i];
      mp[x[i]][y[i]] = 1;
    }

    m = 0;
    REP(i, 0, n) {
      REP(j, i + 1, n) {
        dx = x[i] - x[j];
        dy = y[i] - y[j];

        if(exists(x[i] + dy, y[i] - dx) && exists(x[j] + dy, y[j] - dx)) {
          s = dx * dx + dy * dy;
          if(m < s) m = s;
        }
        if(exists(x[i] - dy, y[i] + dx) && exists(x[j] - dy, y[j] + dx)) {
          s = dx * dx + dy * dy;
          if(m < s) m = s;
        }
      }
    }

    cout << m << endl;
  }

  return 0;
}

Measured memory_bytes: 25608
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  ll x = 60 * H1 + M1;
  ll y = 60 * H2 + M2;
  ll z = y - x - K;
  cout << z << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <queue>

#define ll long long
#define db(x) cout << "> " << #x << " : " << x << endl;

using namespace std;

int c[10][10];
ll cost[10];

ll dijk(int s)
{
	priority_queue < pair <int, int> > pq;
	pq.push({0, s});
	
	ll dist[10];
	for(int i = 0; i < 10; i++)
		dist[i] = (1ll << 62);
	
	dist[s] = 0;	
	while(1)
	{
		int u = pq.top().second;
		pq.pop();
		
		if(u == 1)
			return dist[u];
		
		for(int v = 0; v <= 9; v++)
		{
			if(v == u)
				continue;
			
			if(dist[v] > dist[u] +c[u][v])
			{
				dist[v] = dist[u] +c[u][v];
				pq.push({-dist[v], v});
			}
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, m;
	cin >> n >> m;
	
	for(int i = 0; i < 10; i++)
		for(int j = 0; j < 10; j++)
			cin >> c[i][j];
		
	for(int i = 0; i < 10; i++)
		cost[i] = dijk(i);
	
	ll res = 0;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			int foo;
			cin >> foo;
			
			if(foo == -1)
				continue;
			
			res += cost[foo];
		}
	}
	
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
	int a[5],i,j,k,s,flag;
	char aa[5];
	scanf("%s",aa);
	for(i=0;i<4;i++)
	{
		a[i]=aa[i]-'0';
		//printf("%d ",a[i]);
	}
	s=0;flag=0;
	for(i=0;i<2;i++)
	{
		for(j=0;j<2;j++)
		{
			for(k=0;k<2;k++)
			{
				if(i==0)
				s=a[0]+a[1];
				else if(i==1)
				s=a[0]-a[1];
				
				if(j==0)
				s+=a[2];
				else if(j==1)
				s-=a[2];
				
				if(k==0)
				s+=a[3];
				else if(k==1)
				s-=a[3];
				if(s==7)
				{
					flag=1;
					printf("%d",a[0]);
					if(i==0)
					printf("+");
					else if(i==1)
					printf("-");
					printf("%d",a[1]);
					if(j==0)
					printf("+");
					else if(j==1)
					printf("-");
					printf("%d",a[2]);
					if(k==0)
					printf("+");
					else if(k==1)
					printf("-");
					printf("%d=7\n",a[3]);
					break;
				}
			}
			if(flag)break;
		}
		if(flag)break;
	}
}

Measured memory_bytes: 128
n = int(input())
xs = map(int, input().split())
xs = sorted(list(xs))
ts = []
for i in range(n):
    for j in range(i+1, n):
        ts.append(xs[i] + xs[j])
ts.sort()
i = 0
j = 0
r = 0
xs.append(10**18)
while True:
    if j == len(xs) or i == len(ts):
        break
    if ts[i] <= xs[j]:
        i += 1
        r += n-j
    else:
        j += 1
print((n*(n-1)*(n-2)//6-r))


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<vector<int>> ab(N,vector<int>(2));
  for (int i=0;i<N;i++){
    cin >> ab[i][0] >> ab[i][1];
  }
  sort(ab.begin(),ab.end());
  priority_queue<int> pq;
  int s=0;
  int sum=0;
  for (int i=1;i<M+1;i++){
    for (int j=s;j<N;j++){
      if (ab[j][0]==i){
        pq.push(ab[j][1]);
        s++;
      }
      else {
        break;
      }
    }
    if (!pq.empty()){
      sum+=pq.top();
      pq.pop();
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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;
}

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

    string s;
    cin >> s;
    if (regex_match(s, regex("(.*keyence)")) ||
        regex_match(s, regex("(k.*eyence)")) ||
        regex_match(s, regex("(ke.*yence)")) ||
        regex_match(s, regex("(key.*ence)")) ||
        regex_match(s, regex("(keye.*nce)")) ||
        regex_match(s, regex("(keyen.*ce)")) ||
        regex_match(s, regex("(keyenc.*e)")) ||
        regex_match(s, regex("(keyence.*)"))) {
        std::cout << "YES" << '\n';
    } else {
        std::cout << "NO" << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

	int x, i, y;

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

		cin >> x >> y;

		if (x == 0 &&y == 0){
			break;
		}

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

		if (x < y||x==y){
			cout << x << " " << y << endl;
		}

	}
	return 0;
}


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

int main()
{
	int H, W, i, j;
	
	while(1)
	{
		cin >> H >> W;
		if(H == 0 && W == 0) break;
	
		for(i = 0; i < H; i++)
		{
			for(j = 0; j < W; j++)
			{
				if((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
					cout <<("#");
				else
				    cout <<(".");
			}
			cout <<endl;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int DigitsSum(int num){
  int sum=0;
  while(num > 0){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
  int N;
  string ans = "No";
  cin >> N;
  if(N % DigitsSum(N) == 0) ans = "Yes";
  
  cout << ans << endl;
}


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

void clear(char *c, int arrsize) {
  for (int i = 0; i < arrsize; i++) c[i] = '\0';
}
int main() {
  char c[10] = {'\0'}, count = 0;
  int stack[101] = {0},i=0;
  while (scanf("%s", c) != EOF) {
    count = 0;
    switch (c[0]) {
      case '+':
        stack[i-2] = stack[i-2] + stack[i-1];
        i -= 1;
        break;
      case '-':
        stack[i-2] = stack[i-2] - stack[i-1];
        i -= 1;
        break;
      case '*':
        stack[i-2] = stack[i-2] * stack[i-1];
        i -= 1;
        break;
      default:
        stack[i] = 0; 
        for (int j = 0; c[j] != '\0'; j++) count++;
        for (int j = 0; c[j] != '\0'; j++) stack[i] += (c[j] - '0') * pow(10, (count--)-1);
        i++;
        break;
    }
    clear(c, 10);
  }
  printf("%d\n", stack[0]);
  return 0;
}



Measured memory_bytes: 2932
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll c[15],a[15][15];
void solve(){
	ll n,m,v,res=pow(10,15);
	cin>>n>>m>>v;
	for(ll i=0;i<n;i++){
		cin>>c[i];
	for(ll j=0;j<m;j++)
	cin>>a[i][j];
}
	for(ll bit=0;bit<pow(2,n);bit++){
		vector<ll> g(m,0);
		ll x=bit,i=0,cost=0;
		while(x>0){
			if(x&1){
				for(ll j=0;j<m;j++)
				g[j]+=a[i][j];
				cost+=c[i];
			}
			x>>=1;
			i++;
		}
		ll f=0;
		for(ll j=0;j<m;j++)
		if(g[j]<v)
		f=1;
		if(!f)
		res=min(res,cost);
	}
	if(res==ll(pow(10,15)))
	cout<<"-1";
	else
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 4128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

// 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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n,k;
  int a[2009];
  cin>>n>>k;
  rep(i,n){
    cin>>a[i];
  }
  mint ans=0;
  rep(i,n){
    rep(j,n){
      mint cnt1=0,cnt2=0;
      if(a[j]>a[i]){
        if(j<i)cnt1+=1;
        cnt2+=1;
      }
      ans+=(cnt1*2+cnt2*(k-1))*k/2;
    }
  }
  cout<<ans.x<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

string ans(vector<vector<char>> s, int H, int W);

int main(void){
    int H, W;
    cin >> H >> W;

    vector<vector<char>> s(H+2, vector<char>(W+2,'.'));

    for(int i = 1; i < H+1; i++){
        for(int j = 1; j < W+1; j++){
            cin >> s[i][j];
        }
    }

    cout << ans(s, H, W) << endl;

    return 0;
}

string ans(vector<vector<char>> s, int H, int W){
    for(int i = 1; i < H+1; i++){
        for(int j = 1; j < W+1; j++){
            if(s[i][j] == '#' && s[i-1][j] == '.' && s[i+1][j] == '.' && s[i][j-1] == '.' && s[i][j+1] == '.'){
                return  "No";
                break;
            }
        }
    }

    return "Yes";
}


Measured memory_bytes: 256
import * as fs from "fs"

function Main(input: string) {

  const [a, x, b] = input.split(" ")

  if (x === "+") {
    console.log(parseInt(a, 10) + parseInt(b, 10))
  }
  else {
    console.log(parseInt(a, 10) - parseInt(b, 10))
  }
}


fs.readFile('/dev/stdin', (err, data) => {
  if (err) {
    Main(fs.readFileSync('./input.txt', 'utf8'))
    return null
  }
  Main(data.toString())
  return null
})

Measured memory_bytes: 7372
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 114514191
#define MOD 1000000007
inline void chmin(int &x, int v) {
  if (x > v) x = v;
}

int N, M, K;
int R[8];
int dist[200][200];
int dp[256][8];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M >> K;
  rep(i, K) cin >> R[i], R[i]--;
  rep(i, N) rep(j, N) dist[i][j] = INF;
  rep(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    chmin(dist[a][b], c);
    chmin(dist[b][a], c);
  }
  rep(k, N) rep(i, N) rep(j, N) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  rep(i, 1<<K) rep(j, N) dp[i][j] = INF;
  rep(i, K) dp[1<<i][i] = 0;
  rep(b, 1<<K) {
    rep(pos, K) {
      if (dp[b][pos] == INF) continue;
      rep(i, K) if (((1<<i) & b) == 0) {
        chmin(dp[(1<<i)|b][i], dp[b][pos]+dist[R[i]][R[pos]]);
      }
    }
  }
  int m = INF;
  rep(i, K) chmin(m, dp[(1<<K)-1][i]);
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 384
import sys
n=int(input())
a=list(map(int, input().split()))
b=[]
for i in range(n):
  if a[i]%2==0:
    b.append(a[i]) 

for i in range(len(b)):
  if (b[i]%6)*(b[i]%10)!=0:
    print('DENIED')
    sys.exit()
print('APPROVED')

Measured memory_bytes: 3060
a =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(a[k-1])

Measured memory_bytes: 3060
def resolve():
    N, M, X = map(int, input().split())
    L = []*M
    ans = 10000000000
    for i in range(N):
        L.append(tuple(map(int, input().split())))

    for i in range(2 ** N):
        s = 0
        C = [0]*M
        for j in range(N):
            if (i >> j) & 1:
                C = [a+b for (a, b) in zip(C, L[j][1:])]
                s += L[j][0]
        CC = len([c for c in C if c >= X])
        if CC == M:
            ans = min(ans, s)
    print(-1 if ans == 10000000000 else ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9228
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll a,b;
	cin >> a >> b;
	if (a == b){
		cout << a+b << endl;
	}
	if (a > b){
		cout << a+max((long long)0,(a-1)) << endl;
	}
	if (b > a){
		cout << b+max((b-1),(long long)0) << endl;
	}
	cin >> a;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string>
#include <string.h>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main (void)
{
	string a;

	cin >> a;
	int co = 700;

	for (int i = 0; i < 3; i++)
	{
		if (a.substr(i,1) == "o")
		{
			co += 100;
		}
	}

	cout << co << endl;
}

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

int main() {
    int N, X, T; cin >> N >> X>> T;
    int ans = 0;
    while (N > 0) {
        N -= X;
        ans += T;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
vector<int> x(0);

bool is753(int n, int dig){
  vector<bool> f(3,0);
  for(int i=0;i<dig;i++){
    if(n%10==3) f.at(0)=1;
    if(n%10==5) f.at(1)=1;
    if(n%10==7) f.at(2)=1;
    n/=10;
  }
  return f.at(0)&&f.at(1)&&f.at(2);
}

int dfs(int n,int dig){
  if(dig>9) return 0;
  if(is753(n,dig)) x.push_back(n);
  dfs(n+3*pow(10,dig),dig+1);
  dfs(n+5*pow(10,dig),dig+1);
  dfs(n+7*pow(10,dig),dig+1);  
}

int main(){
  int i=0,n,ans=0;cin>>n;
  dfs(0,0);
  sort(x.begin(),x.end());
  for(auto itr=x.begin();itr!=x.end();++itr){
    if(*itr<=n) ans++;
    else break;
  }
  cout<<ans;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    for (int i = 0; i < n; i++) cin >> a[i], ans += a[i];
    int gap = 1e9;
    int id = - 1;
    for (int i = 0; i < n; i++) {
        if (abs(ans - a[i] * n) < gap) gap = abs(ans - a[i] * n), id = i;
    }
    cout << id << endl;
}

Measured memory_bytes: 256
package main
import "fmt"
func main() {
  var sx,sy,tx,ty int
  var dx,dy int
  fmt.Scan(&sx,&sy,&tx,&ty)
  dx = tx-sx
  dy = ty-sy
  for i:=0;i<dx;i++ {
    fmt.Print("R")
  }
  for i:=0;i<dy;i++ {
    fmt.Print("U")
  }
  for i:=0;i<dx;i++ {
    fmt.Print("L")
  }
  for i:=0;i<dy;i++ {
    fmt.Print("D")
  }
  fmt.Print("D")
  for i:=0;i<dx+1;i++ {
    fmt.Print("R")
  }
  for i:=0;i<dy+1;i++ {
    fmt.Print("U")
  }
  fmt.Print("L")
  fmt.Print("U")
  for i:=0;i<dx+1;i++ {
    fmt.Print("L")
  }
  for i:=0;i<dy+1;i++ {
    fmt.Print("D")
  }
  fmt.Println("R")
}

Measured memory_bytes: 768
#include <stdio.h>

int main(void) {
  FILE *fp;
  fp = stdin;
  char line[5];
  if(!fgets(line, 5, fp)) return 0;
  int num;
  sscanf(line, "%d", &num);
  int shift = 0;
  while((num = num >> 1)) {
    shift++;
  }
  printf("%d\n", 1 << shift);
}

Measured memory_bytes: 128
N, M = map(int, input().split())
es = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)

def dfs(v, used, cnt):
    used[v] = 1
    if all(used):
        cnt[0]+=1
    for nv in es[v]:
        if used[nv]:
            continue
        dfs(nv, used, cnt)
    used[v] = 0

used = [0] * N
cnt = [0]
dfs(0, used, cnt)

print(cnt[0])

Measured memory_bytes: 43100
<?php
fscanf(STDIN,"%d",$n);
$ab_li = array();

for($i=0;$i<$n;$i++){
  fscanf(STDIN,"%d%d",$a,$b);    
  $ab_li[] = array($b,$a);
  
}

asort($ab_li);
//print_r($ab_li);
$my_time = 0;
foreach($ab_li as $deadline_time){
  $my_time += $deadline_time[1];
  if($my_time>$deadline_time[0]){
    echo "No";
    exit;
  }
}

echo "Yes";

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

int main(){
    ll x;
    cin >> x;
    cout << x/11*2 + (x%11+5)/6 << endl;

}

Measured memory_bytes: 256
def c_factors_of_factorial(N, MOD=10**9 + 7):
    from math import factorial
    from functools import reduce
    from operator import mul
    from collections import defaultdict

    def prime_factorization(n):
        if n == 1:
            return {2: 0}  # 1は素数の0乗の積とみなす
        i, table = 2, defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1
        return table

    ans = reduce(mul, [v + 1 for v in prime_factorization(factorial(N)).values()])
    return ans % MOD

N = int(input())
print(c_factors_of_factorial(N))

Measured memory_bytes: 3804
#include <iostream>
#include <climits>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP1(i,n) for(ll i=1;i<=(ll)(n);i++)

ll gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

ll lcm(int a, int b)
{
   return a * b / gcd(a, b);
}

double power(double a, ll n)
{
    if (n == 0)
        return 1;
    double p = power(a, n / 2);
    p = (p * p);
    if (n % 2)
        return (p * a);
    else
        return p;
}

int main(int argc, char *argv[]) {

  long double a, b, h, m;

  cin >> a >> b >> h >> m;

  const long double PI=M_PI;
    
    long double a_x = a * cos(PI*h/6 + PI*m/360);
    long double a_y = a * sin(PI*h/6 + PI*m/360);
    long double b_x = b * cos(PI*m/30);
    long double b_y = b * sin(PI*m/30);

    long double r = sqrtl((a_x-b_x)*(a_x-b_x) + (a_y-b_y)*(a_y-b_y));
      
    cout << fixed << setprecision(15) << r << endl;

  return 0;
}





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

int main() {
    string s,t; cin >> s >> t;
    s += t;
    int a = stoi(s);

    for(int i=1; i*i <= a; i++) {
        if(i*i == a) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int dp[100005][2];

int main() {
    string s;
    cin >> s;
    int n = s.size();

    dp[0][0] = 1;
    rep(i, s.size()) {
        // a+b = 0
        if(s[i] == '0') {
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = dp[i][1];
        }
        else {
            dp[i+1][1] = (dp[i][0] + dp[i][1]) % mod;
        } 
        // a+b = 1
        if(s[i] == '0') {
            (dp[i+1][1] += dp[i][1]*2 % mod) %= mod;
        }
        else {
            (dp[i+1][0] += dp[i][0]*2 % mod) %= mod;
            (dp[i+1][1] += dp[i][1]*2 % mod) %= mod;
        }
    }

    int ans = (dp[n][0] + dp[n][1])%mod;

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

Measured memory_bytes: 1280
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    h, w, n = MI()
    points = []
    cnt = 0
    # 2点とも周上にある組のみ残す
    # 原点（左上）から反時計回りに移動した距離と点の通し番号を記録
    for _ in range(n):
        i0, j0, i1, j1 = MI()
        if (0 < i0 < h and 0 < j0 < w) or (0 < i1 < h and 0 < j1 < w): continue
        for i, j in [(i0, j0), (i1, j1)]:
            if j == 0 or i == h:
                d = i + j
            else:
                d = 2 * (h + w) - i - j
            points.append([d, cnt])
        cnt += 1
    points.sort()
    first = [True] * cnt
    visited = []
    # ABABのように２つの区間がずれて重なっていたらNO
    # ABBAのように完全に含まれるのはセーフ
    for d, pi in points:
        if first[pi]:
            visited.append(pi)
            first[pi] = False
        else:
            last_pi = visited.pop()
            if pi != last_pi:
                print("NO")
                exit()
    print("YES")

main()


Measured memory_bytes: 35592
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
20min 11sec
"""
# 単純に調べるだけ。
# S_listはあらかじめ一回り大きくしておく。

def main():
    H, W = map(int, input().split())
    S_lsit = ["."*(W+2)] + \
        [ ("." + input() + ".") for i in range(H)] + \
        ["."*(W+2)]

    answer_list_list = [["#" for j in range(W)] for i in range(H)]

    next8_list = [
        [1, 1],
        [1, 0],
        [1, -1],
        [0, 1],
        [0, -1],
        [-1, 1],
        [-1, 0],
        [-1, -1]
    ]

    for i in range(1, H+1):
        for j in range(1, W+1):
            if S_lsit[i][j] == ".":
                counter = 0
                for next_pair in next8_list:
                    if S_lsit[i+next_pair[0]][j+next_pair[1]] == "#":
                        counter += 1
                answer_list_list[i-1][j-1] = str(counter)

    for answer_list in answer_list_list:
        print("".join(answer_list))

if __name__ == "__main__":
    main()




Measured memory_bytes: 3188
N = int(input())

# 二次元配列の初期化
# 0番目をaの出現回数、
# 1番目をbの出現回数とする
x = [[0 for i in range(26)] for j in range(N)]
#print(x)

for n in range(N):
    tmp=list(input())
    # 文字列をソートする
    tmp.sort()

    # 重複排除して、それぞれの文字が何回出現したかを数える
    tmp2 = set(tmp)
    for l in tmp2:
        #print(n, ord(l)-97,l,  tmp.count(l))
        x[n][ord(l)-97]= tmp.count(l)

ans  =[]
# a~zまで調べていき、全員最低1回以上出していれば、
# その文字は出力する。最低出現回数分連続させる。
for i in range(26):
    tmp3 = [row[i] for row in x]
    tmp4 = chr(97+i)* min(tmp3) if min(tmp3) != 0 else ""
    ans.append(tmp4)

print("".join(ans))


Measured memory_bytes: 3064
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.main = function (N, M, abList) {
    abList.sort(function (x, y) {
        if (x[0] < y[0])
            return -1;
        if (x[0] > y[0])
            return 1;
        return 0;
    });
    var res = 0;
    var remain = M;
    for (var i = 0; i < N; i++) {
        var _a = abList[i], a = _a[0], b = _a[1];
        if (b < remain) {
            res += a * b;
            remain -= b;
        }
        else {
            res += a * remain;
            break;
        }
    }
    return res;
};
var input = require('fs').readFileSync('/dev/stdin', 'UTF-8');
var lines = input.split('\n');
var _a = lines[0].split(' ').map(function (item) { return Number(item); }), N = _a[0], M = _a[1];
var abList = [];
for (var i = 0; i < N; i++) {
    abList.push(lines[i + 1].split(' ').map(function (l) { return Number(l); }));
}
var res = exports.main(N, M, abList);
console.log(res);


Measured memory_bytes: 50220
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
bool is_prime(long long n) {  //素数判定
  for(int64_t i = 2; i * i <= n; i++) {
    if(n % i == 0) return false;
  }
  return true;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;
  cin >> n;
  while(!(is_prime(n))){
    n++;
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
int main(){
    int n;cin>>n;
    string s;cin>>s;
    int ans=0;
    for(int i=1;i<n;i++){
        int t=0;
        string a="",b="";
        for(int j=0;j<i;j++)
        a+=s[j];
        for(int j=i;j<s.size();j++)
        b+=s[j];
        int c[26]={};
        for(int j=0;j<a.size();j++)
        c[a[j]-'a']++;
        for(int j=0;j<b.size();j++){
            if(c[b[j]-'a']>0)
            t++;
            c[b[j]-'a']=0;
        }
        if(t>ans)
        ans=t;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3644
#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() {
  int x;
  cin >> x;

  if (x == 1) cout << "0" << endl;
  else cout << "1" << endl;

  return 0;
}



Measured memory_bytes: 3592
#include <iostream>
using namespace std;
long long M=1e9+7, d[5]={1};
string a;
int main() {
	int i, j;
	cin>>a;
	for(i=0; a[i]; i++) {
		if(a[i]=='?') {
			for(j=3; j>=0; j--) d[j] = (d[j]*3 + (j ? d[j-1] : 0)) % M;
		} else {
			j = a[i] - 'A' + 1;
			d[j] = (d[j] + d[j-1]) % M;
		}
	}
	cout<<d[3];
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){

  int i,a[26]={0};
  char b,bun[1201];

  while( scanf("%s",&bun) != EOF ){

  for(i=0;bun[i]!='\0';i++){
    
    if('a' <= bun[i] && bun[i] <= 'z'){
      a[bun[i]-'a']++;
    }
    if('A' <=bun[i] && bun[i]<='Z'){
      a[bun[i]-'A']++;
      }
  }
  }
  for(i=0;i<26;i++){
    printf("%c : %d\n",i+'a',a[i]);
  }
  return 0;
}

Measured memory_bytes: 544