akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
	
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
	
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
	
class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
	
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}
	
int dp[100005][13];

bool solve() {
	string s; cin >> s;
	dp[0][0] = 1;
	REP (i,s.size()) {
		if (s[i] == '?') {
			REP (j,13) {
				REP (k,10) {
					dp[i+1][(10*j+k)%13] += dp[i][j];
				}
			}
		} else {
			REP (j,13) {
				dp[i+1][(10*j+s[i]-'0')%13] += dp[i][j];
			}
		}
		REP (j,13) dp[i+1][j] %= mod;
	}
	cout << dp[s.size()][5] << endl;
}
	
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 10704
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#include<queue>
#include<cstdio>
#include<vector>
#include <algorithm>
#include<string>
#define rep(i,n) for (int i=0;i<(n);++i)
using ll = long long;
using namespace std;
using P = pair<int,int>;

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans1 = a*c,ans2 = b*d,ans3 = b*c,ans4 = a*d;
    if(ans1 >= ans2 and ans1 >= ans3 and ans1 >= ans4){
        cout<<ans1<<endl;
    }else if(ans2 >= ans3 and ans2 >= ans1 and ans2 >= ans4){
        cout<<ans2<<endl;
    }else if(ans3 >= ans1 and ans3 >= ans2 and ans3 >= ans4){
        cout<<ans3<<endl;
    }else{
        cout<<ans4<<endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

const double PI = 2 * acos(0);

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<double, double> pdd;
typedef pair<double, pdd> pddd;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

ll dp[55][2];

int main() {
    int n, p;
    scanf("%d%d", &n, &p);
    dp[0][0] = 1;
    for(int i = 0; i < n; i++) {
        int t;
        scanf("%d", &t);
        dp[i+1][0] += dp[i][0];
        dp[i+1][1] += dp[i][1];
        dp[i+1][t%2] += dp[i][0];
        dp[i+1][(1+t)%2] += dp[i][1];
    }
    printf("%lld\n", dp[n][p]);
}


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

using namespace std;

const int maxn = 100 + 5;

int h, w;
char m[maxn][maxn];
int sumr[maxn], sumc[maxn];

void init() {
    cin >> h >> w;
    for(int i = 0 ; i < h ; i++) scanf("%s", m[i]);
    
    memset(sumr, 0, sizeof(sumr));
    memset(sumc, 0, sizeof(sumc));
    
    for(int i = 0 ; i < h ; i++) {
        int sum = 0;
        for(int j = 0 ; j < w ; j++) {
            sum += (m[i][j] == '#' ? 1 : 0);
        }
        sumr[i] = sum;
    }
    
    for(int j = 0 ; j < w ; j++) {
        int sum = 0;
        for(int i = 0 ; i < h ; i++) {
            sum += (m[i][j] == '#' ? 1 : 0);
        }
        sumc[j] = sum;
    }
}

void solve() {
    for(int i = 0 ; i < h ; i++) {
        for(int j = 0 ; j < w ; j++) {
            if(sumr[i] == 0 || sumc[j] == 0) continue;
            putchar(m[i][j]);
        }
        if(sumr[i] > 0) putchar('\n');
    }
}

int main() {
    init();
    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int x,a=0;
    cin>>x;
    if(x%2==0||x%5==0){
        puts("-1");
        exit(0);
    }
    for(int i=1;;i++){
        a=(a*10+7)%x;
        if(a==0) {cout<<i;break;}
    }
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int origin;
		while((origin = scan.nextInt()) > 100 || origin < 0) {
			System.out.println("もう一度数字を入力してください。");
		}
		int cube = origin*origin*origin;
		System.out.println(cube);
	}
}



Measured memory_bytes: 26092
N=int(input())
A = list(map(int,input().split()))
A2 = [ A[i]*2 for i in range(N) ]
asum = sum(A2)
tgt = asum//2
tmpa = 0
ans = 0
for i in range(N):
  tmpa += A2[i]
  if tmpa >= tgt:
    if i == 0:
      ans = tmpa - tgt
    else:
      ans = min(tmpa-tgt, tgt-(tmpa-A2[i]))
#      print(tgt, tmpa,A2[i],ans)
    break
print(ans)


Measured memory_bytes: 26220
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    char a[100];
    char b[100];
    cin>>a;
    cin>>b;
    int l,k,p,q,i;
    l=strlen(a);
    k=strlen(b);
    if(l>k)
    {
        cout<<"GREATER"<<endl;
    }
    if(l<k)
    {
        cout<<"LESS"<<endl;
    }
    if(strcmp(a,b)==0)
    {
        cout<<"EQUAL"<<endl;
    }
    if(l==k)
    {
        for(i=0;i<l;i++)
       {
           p=a[i];
           q=b[i];
          if(p>q)
          {
              cout<<"GREATER"<<endl;
              break;

          }
          if(p<q)
          {
              cout<<"LESS"<<endl;
              break;
          }
       }

    }
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {

    private static long ans = 0, low = 0;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt(), m = in.nextInt(), l = in.nextInt();
        while (n > 0) {
            Node[][] nodes = new Node[n][l + 1];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j <= l; j++) {
                    nodes[i][j] = new Node(i, j);
                }
            }
            for (int i = 0; i < m; i++) {
                int a = in.nextInt() - 1, b = in.nextInt() - 1;
                int d = in.nextInt(), e = in.nextInt();
                for (int j = 0; j <= l; j++) {
                    nodes[a][j].edges.add(new Edge(e, nodes[b][j]));
                    nodes[b][j].edges.add(new Edge(e, nodes[a][j]));
                }
                for (int j = 0; j <= l - d; j++) {
                    nodes[a][j].edges.add(new Edge(0, nodes[b][j + d]));
                    nodes[b][j].edges.add(new Edge(0, nodes[a][j + d]));
                }
            }

            PriorityQueue<Node> q = new PriorityQueue<>(Comparator.comparing(node -> node.distance));
            nodes[0][0].distance = 0;
            q.offer(nodes[0][0]);
            while (!q.isEmpty()) {
                Node node = q.poll();
                if (node.distance == Integer.MAX_VALUE) break;
                for (Edge edge : node.edges) {
                    Node next = edge.to;
                    long d = node.distance + edge.dist;
                    if (d < edge.to.distance) {
                        next.distance = d;
                        q.offer(next);
                    }
                }
            }
            long ans = Integer.MAX_VALUE;
            for (int i = 0; i <= l; i++) {
                ans = Math.min(ans, nodes[n - 1][i].distance);
            }
            out.println(ans);

            n = in.nextInt();
            m = in.nextInt();
            l = in.nextInt();
        }

        out.flush();
    }

    static class Node {
        long distance = Integer.MAX_VALUE;
        int index;
        int cost;
        List<Edge> edges = new ArrayList<>();

        Node(int index, int cost) {
            this.index = index;
            this.cost = cost;
        }
    }

    static class Edge {
        int dist;
        Node to;

        Edge(int dist, Node to) {
            this.dist = dist;
            this.to = to;
        }
    }

}



Measured memory_bytes: 118120
D, N = map(int, input().split())

if N == 100:
    if D == 0:
        print(101)
    elif D == 1:
        print(10100)
    else:
        print(1010000)
elif D == 0:
    print(N)
elif D == 1:
    print(100 * N)
else:
    print(10000 * N)

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k;
	string s;
	cin >> k >> s;
	if(s.size() <= k) cout << s << endl;
	else{
		rep(i,k) cout << s[i];
		cout << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define pushb(x) push_back(x)
#define popb() pop_back()
#define makep make_pair
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv);
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v);
template<typename T> ll gcd(T a,T b);
template<typename T> ll lcm(T a,T b);
int main(){
    int n,l;cin>>n>>l;
    int sum=0;
    rep(i,n){
        sum+=l+i;
    }
    if(l>=0){
        cout<<sum-l<<endl;
        return 0;
    }
    if(l+n-1<=0){
        cout<<sum-l-n+1<<endl;
        return 0;
    }
    cout<<sum<<endl;
    return 0;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << ' ';
    }
    return s;
}
template<typename T> ll gcd(T a,T b){
    if(b==0){
        return a;
    }
    return gcd(b,a%b);
}
template<typename T> ll lcm(T a,T b){
    return a*b/gcd(a,b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

struct edge{int to; ll cost;};

const int N = 1000, B = 101;
const ll INF = LLONG_MAX/111;

vector<edge> G[N];
ll d[N][B];

using pi = pair<int,int>;
using P = pair<ll,pi>;

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

    int n,m,s1,s2,t;
    while(cin >>n >>m >>s1 >>s2 >>t,n){
        rep(i,N) G[i].clear();

        --s1;
        --s2;
        --t;

        rep(i,m){
            int a,b;
            string w;
            cin >>a >>b >>w;
            --a;
            --b;

            ll cost;
            if(w == "x") cost = -1;
            else cost = stoll(w);

            G[a].pb({b,cost});
            G[b].pb({a,cost});
        }

        rep(i,N)rep(j,B) d[i][j] = INF;

        d[t][0] = 0;
        priority_queue<P, vector<P>, greater<P>> pq;
        pq.push({0,{t,0}});
        while(!pq.empty()){
            P now = pq.top();
            pq.pop();
            int v = now.se.fi, b = now.se.se;
            if(now.fi > d[v][b]) continue;

            for(const auto &e:G[v]){
                if(e.cost == -1){
                    if(b+1<B && d[e.to][b+1] > d[v][b]){
                        d[e.to][b+1] = d[v][b];
                        pq.push({d[e.to][b+1], {e.to,b+1}});
                    }
                }
                else{
                    if(d[e.to][b] > d[v][b]+e.cost){
                        d[e.to][b] = d[v][b]+e.cost;
                        pq.push({d[e.to][b], {e.to,b}});
                    }
                }
            }
        }

        vector<ll> cand;
        cand.pb(0);
        cand.pb(INF);
        rep(b1,B)rep(b2,B){
            if(b1 == b2) continue;
            if(d[s1][b1] == INF || d[s2][b2] == INF) continue;

            ll D = abs(d[s1][b1] - d[s2][b2]);
            D /= abs(b1-b2);
            for(int i=-1; i<=1; ++i)if(D+i>0) cand.pb(D+i);

            D = abs(d[s1][b1] - d[s1][b2]);
            D /= abs(b1-b2);
            for(int i=-1; i<=1; ++i)if(D+i>0) cand.pb(D+i);

            D = abs(d[s2][b1] - d[s2][b2]);
            D /= abs(b1-b2);
            for(int i=-1; i<=1; ++i)if(D+i>0) cand.pb(D+i);
        }
        sort(all(cand));
        cand.erase(unique(all(cand)), cand.end());

        ll ans = INF;
        for(ll w:cand){
            ll d1 = LLONG_MAX, d2 = LLONG_MAX;
            rep(i,B){
                if(d[s1][i]<INF) d1 = min(d1, d[s1][i]+w*i);
                if(d[s2][i]<INF) d2 = min(d2, d[s2][i]+w*i);
            }

            ans = min(ans, abs(d1-d2));
        }

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



Measured memory_bytes: 6568
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
const LL INF = 1e18;
const int MXN = 0;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define Be begin()
#define En end()
#define FOR(i, L, R) for (int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i != (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);

int main()
{
    // IOS;
    int n;
    LL k;
    cin >> n >> k;
    vector<LL> v(n);
    FOR(i, 0, n) { cin >> v[i]; }
    sort(v.Be, v.En);
    LL L = -INF, R = INF, M, cnt;
    while (L + 1 != R)
    {
        // cout << L << ' ' << R << '\n';
        M = (L + R) >> 1;
        cnt = 0;
        FOR(i, 0, n)
        {
            if (v[i] < 0)
            {
                int LL = i, RR = n, MM = 0;
                while (LL + 1 < RR)
                {
                    // cout << LL << ' ' << RR << '\n';
                    MM = (LL + RR) >> 1;
                    (v[i] * v[MM] <= M) ? (RR = MM) : (LL = MM);
                }
                cnt += n - RR;
            }
            else
            {
                int LL = i, RR = n, MM = 0;
                while (LL + 1 < RR)
                {
                    // cout << LL << ' ' << RR << '\n';
                    MM = (LL + RR) >> 1;
                    (v[i] * v[MM] <= M) ? (LL = MM) : (RR = MM);
                }
                cnt += LL - i;
            }
        }
        (cnt < k) ? (L = M) : (R = M);
    }
    cout << R << '\n';
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define int long long
#define MOD 1000000007
#define mod 998244353
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define endl "\n"
using namespace std;

int colour[100005];
int vis[100005];
void solve1();
void solve()
{
    int T=10;cin>>T;
    for(int z=1;z<=T;z++)
    {
        solve1();
    }
}
signed main()
{
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve1();
    return 0;
}
void solve1()
{
    int n;cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(arr[i]!=arr[j]&&arr[i]!=arr[k]&&arr[j]!=arr[k])
                {
                    if((arr[i]+arr[j]>arr[k])&&(arr[k]+arr[j]>arr[i])&&(arr[i]+arr[k]>arr[j]))
                    {
                        ans++;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include<utility>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<stack>
#include<complex>
#include<cmath>
#include<iostream>
#include<set>
#include<map>
#include<sstream>
#include<fstream>
#include<climits>
#include<chrono>
#include<random>
#include<functional>
#include<regex>

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

// ???§?????????°INF
const int INF = (1 << 30);
// ??¨?±?????????????????
const double EPS = (1e-10);
// 2??????????????????????????????????????????
#define EQ(a,b) (abs((a)-(b)) < EPS)


int main()
{
	cin.tie(0);
	ios::ios_base::sync_with_stdio(false);
	int N, W, H;
	cin >> N >> W >> H;
	vector<bool> w((W << 1) + 1, false), h((H << 1) + 1, false);
	int x, y, r;
	for (int i = 0; i < N; ++i) {
		cin >> x >> y >> r;
		fill(w.begin() + max(0, (x - r) << 1), w.begin() + min(W << 1, (x + r) << 1) + 1, true);
		fill(h.begin() + max(0, (y - r) << 1), h.begin() + min(H << 1, (y + r) << 1) + 1, true);
	}
	for (int j = 1; j <= (W << 1) - 1; j += 2) {
		if (w[j])continue;
		for (int k = 1; k <= (H << 1) - 1; k += 2) {
			if (!h[k]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1252
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int combination(int n, int r){
    if(r==0||r==n){
        return 1;
    }
    if(r==1){
        return n;
    }
    return combination(n-1,r-1)+combination(n-1,r);
}

int main(){
    int n;
    scanf("%d", &n);
    int t[101];
    rep(i, 0, 101){
        t[i] = 0;
    }
    rep(i, 2, n+1){
        int buf = i;
        while(buf % 2 == 0){
            t[2]++;
            buf /= 2;
        }
        for(int i=3; i*i<=buf; i+=2){
            while(buf % i == 0){
                t[i]++;
                buf /= i;
            }
        }
        if(buf > 1){
            t[buf]++;
        }
    }
    int cnt_2 = 0, cnt_4 = 0, cnt_14 = 0, cnt_24 = 0, cnt_74 = 0;
    int ans = 0;
    rep(i, 0, 101){
        if(t[i] >= 2){
            cnt_2++;
        }
        if(t[i] >= 4){
            cnt_4++;
        }
        if(t[i] >= 14){
            cnt_14++;
        }
        if(t[i] >= 24){
            cnt_24++;
        }
        if(t[i] >= 74){
            cnt_74++;
        }
    }
    if(cnt_2 >= 1 && cnt_4 >= 2){
        ans += (cnt_2-2) * combination(cnt_4, 2);
    }
    if(cnt_4 >= 1 && cnt_14 >= 1){
        ans += (cnt_4-1) * cnt_14;
    }
    if(cnt_2 >= 1 && cnt_24 >= 1){
        ans += (cnt_2-1) * cnt_24;
    }
    ans += cnt_74;
    printf("%d", ans);

    return 0;
}

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

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

    int N, M;
    cin >> N >> M;

    vector<int> A(N);
    for (int i=0; i<N; ++i) {
        cin >> A[i];
        A[i] %= M;
    }

    vector<long long> ac(N+1);
    ac[0] = 0;
    for (int i=0; i<N; ++i) {
        ac[i+1] = (ac[i] + A[i]) % M;

    }

    map<long long, long long> m;
    for (int i=0; i<ac.size(); ++i) {
        m[ac[i]] ++;
    }
  
    long long ans = 0;
    for (auto it=m.begin(); it!=m.end(); ++it) {
        ans += it->second * (it->second - 1) / 2LL;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5376
a = input()
n = len(a)
r = 0
g ,p =0, 0
for i in a:
    if i =="g":
        if g>p:
            r+=1
            p+=1
        else:
            g+=1
    else:
        if g>p:
            p+=1
        else:
            g+=1
            r-=1
print(r)


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

int cmp(const void *a, const void *b)
{
  return *(int*)a - *(int*)b;
}

int main(void)
{
  int data[3];

  scanf("%d %d %d", &data[0], &data[1], &data[2]);

  qsort(data, 3, sizeof(int), cmp);

  printf("%d %d %d\n", data[0], data[1], data[2]);

  return 0;
}

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

using namespace std;

int main()
{
  string s; cin >> s;
  vector<char> cv;
  char ans;
  bool flag = true;

  for (int i = 0; i < s.length(); i++) {
    char x = s[i];
    cv.push_back(x);
  }

  sort(cv.begin(), cv.end());
  cv.erase(unique(cv.begin(), cv.end()), cv.end());

  for (int i = 0; i < 26; i++) {
    // cout << cv[i] << endl;
    int asc = 97 + i;
    if (cv[i] != asc) {
      ans = asc;
      flag = false;
      break;
    }
  }

  if (flag) cout << "None" << endl;
  else      cout << ans << endl;

  return 0;
}


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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " = " << x << endl
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)2e9
#define infll 1e18
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };



//===========================DEBUG======================//
#define XOX 1
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

//================================================================//



//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;


int main(){
    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
    fast

    ll n,w; cin>>n>>w;
    ll wt[n+1],v[n+1],dp[lmt][2];
    loop1(i,n)cin>>wt[i]>>v[i];

    int flag=0;
	loop(j,n+1){
		loop(i,lmt){
			if(i==0)dp[i][flag]=0;
			else if(j==0)dp[i][flag]=inf;
			else{
				dp[i][flag] = dp[i][1-flag];
				if(i>=v[j]) dp[i][flag]=min(wt[j]+dp[i-v[j]][1-flag],dp[i][flag]);	
			}
		}
		flag = 1-flag;
	}    
	ll ans=0;
	for(int i=lmt-1; i>=0; i--){
		if(dp[i][1-flag]<=w){ans=i; break;}
	}

    pt(ans);
}


/*


*/





Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sumvec(vector<S>&a){return accumulate(all(a),S());}
template<class S>S maxvec(vector<S>&a){return *max_element(all(a));}
template<class S>S minvec(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

vvl comb(ll n, ll r) {
  vvl v(n + 1,vl(n + 1, 0));
  for (ll i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (ll j = 1; j < v.size(); j++) {
    for (ll k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}


int main(void){
  	cin.tie(0);
  	ios::sync_with_stdio(false);
  	
  	ll n;
  	cin>>n;
  	vl h(n);
  	cin>>h;
  	h.push_back(INF);
  	h.push_back(INF);
  	h.push_back(INF);
  	
  	vl cost(n+2,INF);
  	cost[0]=0;
  	/*
  	range(i,1,n){
  	    ll a,b=INF;
  	    a=abs(h[i]-h[i-1]) + cost[i-1];
  	    if(i>1) b=abs(h[i]-h[i-2]) + cost[i-2];
  	    //cout<<a<<" "<<b<<" ";
  	    cost[i]=min(a,b);
  	    //puta(cost[i]);
  	}*/
  	
  	
  	range(i,0,n-1){
  	    ll a,b;
  	    a=abs(h[i]-h[i+1]);
  	    b=abs(h[i]-h[i+2]);
  	    //cout<<a<<" "<<b<<" ";
  	    cost[i+1]=min(cost[i+1],cost[i]+a);
  	    cost[i+2]=min(cost[i+2],cost[i]+b);
  	    //cout<<cost[i]<<" "<<cost[i+1]<<" "<<cost[i+2]<<endl;
  	}
  	
  	puta(cost[n-1]);

}


Measured memory_bytes: 1792
import sys
S= sys.stdin.read()
print('a : '+str(S.count('a')+S.count('A')))
print('b : '+str(S.count('b')+S.count('B')))
print('c : '+str(S.count('c')+S.count('C')))
print('d : '+str(S.count('d')+S.count('D')))
print('e : '+str(S.count('e')+S.count('E')))
print('f : '+str(S.count('f')+S.count('F')))
print('g : '+str(S.count('g')+S.count('G')))
print('h : '+str(S.count('h')+S.count('H')))
print('i : '+str(S.count('i')+S.count('I')))
print('j : '+str(S.count('j')+S.count('J')))
print('k : '+str(S.count('k')+S.count('K')))
print('l : '+str(S.count('l')+S.count('L')))
print('m : '+str(S.count('m')+S.count('M')))
print('n : '+str(S.count('n')+S.count('N')))
print('o : '+str(S.count('o')+S.count('O')))
print('p : '+str(S.count('p')+S.count('P')))
print('q : '+str(S.count('q')+S.count('Q')))
print('r : '+str(S.count('r')+S.count('R')))
print('s : '+str(S.count('s')+S.count('S')))
print('t : '+str(S.count('t')+S.count('T')))
print('u : '+str(S.count('u')+S.count('U')))
print('v : '+str(S.count('v')+S.count('V')))
print('w : '+str(S.count('w')+S.count('W')))
print('x : '+str(S.count('x')+S.count('X')))
print('y : '+str(S.count('y')+S.count('Y')))
print('z : '+str(S.count('z')+S.count('Z')))




Measured memory_bytes: 5580
import sys

N = int(input())
XY = [[int(_) for _ in input().split()] for i in range(N)]

mc = [0, 0]
maxl = 0

for x, y in XY:
    l = abs(x) + abs(y)
    maxl = max(maxl, l)
    mc[l % 2] += 1

if mc[0] > 0 and mc[1] > 0:
    print(-1)
    sys.exit()

#print(maxl)

def calc(sx, sy, ex, ey, d):
    dx, dy = ex - sx, ey - sy
    rx, ry = dx - dy, dx + dy
    if rx > 0:
        if ry > 0:
            d, x, y = "R", sx + d, sy
        else:
            d, x, y = "D", sx, sy - d
    else:
        if ry > 0:
            d, x, y = "U", sx, sy + d
        else:
            d, x, y = "L", sx - d, sy
    return d, x, y

import math

l = math.ceil(math.log(maxl + 1, 2))

ms = [2 ** (l - i - 1) for i in range(l)]

rms = ms

if mc[0] > 0:
    rms = [1] + ms

print(len(rms))
print(*rms)

for ex, ey in XY:
    x, y = 0, 0
    w = ""
    if mc[0] > 0:
        w = "R"
        x += 1
    for m in ms:
        d, x, y = calc(x, y, ex, ey, m)
        w += d
    print(w)



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

int main(){
double n;

while(scanf("%lf",&n)!=EOF){
if(n<=48.00)printf("light fly\n");
else if(48.00<n&&n<=51.00)printf("fly\n");
else if(51.00<n&&n<=54.00)printf("bantam\n");
else if(54.00<n&&n<=57.00)printf("feather\n");
else if(57.00<n&&n<=60.00)printf("light\n");
else if(60.00<n&&n<=64.00)printf("light welter\n");
else if(64.00<n&&n<=69.00)printf("welter\n");
else if(69.00<n&&n<=75.00)printf("light middle\n");
else if(75.00<n&&n<=81.00)printf("middle\n");
else if(81.00<n&&n<=91.00)printf("light heavy\n");
else if(91.00<n)printf("heavy\n");
}
return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main(){
  int x, y;
  cin >> x >> y;
  if(y - 2 * x >= 0 && ((y - 2 * x ) % 2 == 0) && 4 * x -y >= 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

typedef pair<int, int> P;

int main(){
  int w,h;
  cin>>w>>h;
  vector<int> p(w), q(h);
  rep(i,w) scanf("%d", &p[i]);
  rep(i,h) scanf("%d", &q[i]);

  vector<P> vec(w+h);
  rep(i,w) vec[i] = mp(p[i], 0);
  rep(i,h) vec[i+w] = mp(q[i], 1);

  sort(all(vec));
  int nw=w+1, nh=h+1;
  long res=0;
  rep(i, w+h){
    if(vec[i].se==0){ //p w のほうをつかう
      res += (long)vec[i].fi * nh;
      nw--;
    } else {
      res += (long)vec[i].fi * nw;
      nh--;
    }
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 2688
#include<stdio.h>
int main(void){
    int i,n,x[101],max=0,avr1,avr2,hp1=0,hp2=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }

    for(i=0;i<n;i++){
        max+=x[i];
    }
    avr1=max/n;
    avr2=avr1+1;

    for(i=0;i<n;i++){
        hp1+=(x[i]-avr1)*(x[i]-avr1);
    }
    for(i=0;i<n;i++){
        hp2+=(x[i]-avr2)*(x[i]-avr2);
    }
    if(hp1<hp2){
        printf("%d",hp1);
    }else{
        printf("%d",hp2);
    }
    
    return 0;    
}


Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x, a, b = LI()
    if b <= a:
        print("delicious")
    elif b <= a + x:
        print("safe")
    else:
        print("dangerous")

    return

#B
def B():
    n = II()
    a = IR(n)
    check = [False] * (n + 1)
    check[1] = True
    now = a[0]
    for i in range(1,n+1):
        if check[now]:
            break
        if now == 2:
            print(i)
            return
        check[now] = True
        now = a[now - 1]
    print(-1)
    return

#C
def C():
    return

#D
def D():
    def find(x):
        if x == par[x]:
            return x
        par[x] = find(par[x])
        return par[x]
    def same(x, y):
        return find(x) == find(y)
    def unite(x, y):
        x = find(x)
        y = find(y)
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
        return True
    n = II()
    par = [i for i in range(n)]
    rank = [0] * n
    xy = LIR(n)
    for i in range(n):
        xy[i].append(i)
    xy.sort(key=lambda x: x[0])
    edg = [None] * (2 * n - 2)
    a = 0
    for i in range(n-1):
        edg[i] = [xy[i + 1][0] - xy[i][0], xy[i][2], xy[i + 1][2]]
    xy.sort(key=lambda x: x[1])
    for i in range(n-1):
        edg[n + i - 1] = [xy[i + 1][1] - xy[i][1], xy[i][2], xy[i + 1][2]]
    ans = 0
    a = 0
    edg.sort(key=lambda x: x[0])
    for i in range(2 * n - 2):
        value, p0, p1 = edg[i]
        if a == n - 1:
            break
        if not same(p0, p1):
            unite(p0, p1)
            a += 1
            ans += value
    print(ans)
    return

#Solve
if __name__ == '__main__':
    D()


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

int main(){
    int m,n;
    cin >> n >> m;
    
    vector<vector<int>> a(n+1,vector<int>(m+1,0));
    vector<int> b(m+1,0);
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
            cin >> a[i][j];
    for(int i=1; i<=m; i++)
        cin >> b[i];
    
    for(int i=1; i<=n; i++){
        int sum=0;
        for(int j=1; j<=m; j++)
            sum+=a[i][j]*b[j];
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
#define v_inputrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)

int main(){
    ll n, k;
    cin >> n >> k;

    ll a = n % k;
    cout << min(a, abs(a-k));
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    long long a,b,g,h,t;
    while(scanf("%lld %lld",&a,&b) != EOF){
        g = a; h = b;
        while(h > 0){
            t = h;
            h = g%h;
            g = t;
        }
        printf("%lld %lld\n",g,(a*b)/g);
    }
    return 0;
}

Measured memory_bytes: 596
n = int(input())
s = list(map(int,input().split()))
cnt = 1
for i in range(n-1,0,-1):
    result = True
    for j in range(i-1,-1,-1):
        if s[j] > s[i]:
            result = False
            break
    if result:
        cnt +=1
print(cnt)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k, m = 1;
    cin >> n >> k;
    while(n > 0 && m <= k){
        m *= 2;
        n--;
    }
    FOR(i,0,n){
        m += k;
    }
    cout << m << endl;
}

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

using namespace std;
typedef long long 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() {
  Cin(int, n);
  Cin(string, s, t);

  int same = 0;
  for (int i = 0; i < n; ++i) {
    if (s.substr(n - 1 - i) == t.substr(0, i + 1)) same = i + 1;
  }

  cout << (max(n, 2 * n - same)) << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

long long a, arr[200005], diff[200005];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    long long k;
    int n; cin >> n >> k;

    for(int i = 0; i < n; ++i) cin >> arr[i];
    for(int i = 0; i < n; ++i) cin >> diff[i];

    sort(arr,arr + n);
    sort(diff,diff+n);

    long long cur, mid, left = 0, right = 1e12;

    for(int i = 0; i < 100; ++i){
        mid = (left + right) / 2;
        cur = 0;
        for(int j = 0; j < n; ++j)
            cur += max(0ll, arr[j] - (mid / diff[n-j-1]));
        if(cur <= k) right = mid;
        else left = mid;
    }

    cout << right;

    return 0;

}


Measured memory_bytes: 3328
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb emplace_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(x) (int)(x).size()

double PI = acos(-1.0);

int32_t main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	IOS;

	int m, d;
	cin >> m >> d;

	int ans(0);

	for(int i = 1; i <= m; ++i)
	{
		for(int j = 1; j <= d; ++j)
		{
			if(j >= 10 and j%10 >= 2 and (j/10) >= 2 and ((j%10)*(j/10) == i))
			{
				// cout << i << ' ' << j << '\n';
				++ans;
			}
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <tuple>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG



int main(void){

    long num;
    cin >> num;

    // 1のときは0を出力
    if (num == 1) {
      cout << 0 << endl;
      return 0;
    }

    //素因数分解して、各底の指数をカウントする
    int count = 0;
    long i = 2;
    map<long, int> Factor;
    vector<long> check(0);

    while(num >= i * i){

        if (num % i == 0) {
            count++;
            check.push_back(i);
            Factor[i] = count;
            num /= i;
        }

        else {
            count = 0;      
            i++;
        }
    }

    check.push_back(num);
    Factor[num] += 1; //最後に余ったのは素因数



    //各素因数の指数に対して答えを計算していく
    int result = 0;
    int A;

    for(long c : check){
        A = 0;

        if(Factor[c] <= 0){
            continue;
        }
        while(1){
          A++;
          Factor[c] -= A;
          if (Factor[c] < 0){
              break;
          } 
          result++;
          
            
        }
    }

    if(result == 0){
        cout << 1 << endl;
    }

    else {
        cout << result << endl;
    }

}

Measured memory_bytes: 3592
def main():
    N, M = map(int, input().split())
    d = {}
    for _ in range(M):
        a, b = map(int, input().split())
        if a in d:
            d[a].append(b)
        else:
            d[a] = [b]
        if b in d:
            d[b].append(a)
        else:
            d[b] = [a]
    for x in d[1]:
        if N in d[x]:
            return 'POSSIBLE'
    return 'IMPOSSIBLE'
print(main())


Measured memory_bytes: 48476
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)

fun main() {
    val (a,b,c)= readIntegerList()
    if (a<= b*c){
        println("Yes")
    }else{
        print("No")
    }

}

Measured memory_bytes: 36448
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N;
	while(cin>>N)
	{
		vector<int> dish_list(N+1),sat(N+1),Csat(N+1);
		for(int i=1;i<=N;i++)
		{
			cin>>dish_list[i];
		}
		for(int i=1;i<=N;i++)
		{
			cin>>sat[i];
		}
		for(int i=1;i<=N-1;i++)
		{
			cin>>Csat[i];
		}
		int sum=sat[dish_list[1]];
		for(int i=2;i<=N;i++)
		{
			sum+=sat[dish_list[i]]+(dish_list[i]==dish_list[i-1]+1)*Csat[dish_list[i-1]];
		}
		cout<<sum<<'\n';
	}
}

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

using namespace std;

int main(){

string s;
cin >> s;
if(s == "Sunny"){
cout << "Cloudy" << endl;
} else if(s == "Rainy"){
cout << "Sunny" << endl;
} else {
cout << "Rainy" << endl;
}
return 0;
}

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

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

ll N,K;
ll R,S,P;
string T;

ll dp[200005][3]; // r,s,p

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

    cin >> N >> K >> R >> S >> P >> T;

    ll ans = 0;
    for (int i = 0;i < K;i++){
        //memset(dp,0,sizeof(dp));
        ll las = i;
        for (int j = i;j < N-K;j += K){
            //cout << dp[j][0] << " " << dp[j][1] << " " << dp[j][2] << endl;
            if(T[j] == 'r') dp[j][2] += P;
            if(T[j] == 's') dp[j][0] += R;
            if(T[j] == 'p') dp[j][1] += S;
            for (int k = 0;k < 3;k++){
                //cout << dp[j][k] << " ";
                dp[j+K][(k+1)%3] = max(dp[j+K][(k+1)%3],dp[j][k]);
                dp[j+K][(k+2)%3] = max(dp[j+K][(k+2)%3],dp[j][k]);
            }
            //cout << endl;
            las = j+K;
        }
        if(T[las] == 'r') dp[las][2] += P;
        if(T[las] == 's') dp[las][0] += R;
        if(T[las] == 'p') dp[las][1] += S;
        ans += max({dp[las][0],dp[las][1],dp[las][2]});
        //cout << ans << endl;
    }
    
    cout << ans << endl;

    return 0;

}

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

using ll = long long;
#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, n, m) for(int (i)=(n); (i)<(m); ++i)
constexpr ll INF = 1LL << 60;
constexpr int mod = 1e9+7;

int N, W, w0;
vector<vector<int>> wv;
ll ans = 0;
ll answ = 0;
void solve(ll sum, ll w, int depth){
  if(depth == 4){
    if(ans < sum){
      ans = sum;
      answ = w; 
    }
    return;
  }
  solve(sum, w, depth+1);
  REP(i, wv[depth].size()){
    sum += wv[depth][i];
    w += w0+depth;
    if(w > W) break;
    solve(sum, w, depth+1);
  }
}

int main(){
  cin >> N >> W;
  vector<int> w(N), v(N);
  wv.resize(4);
  REP(i, N){
    cin >> w[i] >> v[i];
    wv[w[i]-w[0]].push_back(v[i]);
  };
  w0 = w[0];
  REP(i, 4){
    sort(wv[i].rbegin(), wv[i].rend());
  };
  solve(0, 0, 0);
  cout << ans << endl;
//  cout << answ << endl;
  return 0;
}


Measured memory_bytes: 256