akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 200111

typedef long long ll;
typedef long double ld;

int main(){
	int n;
	scanf("%d", &n);
	vector<int> a(n), b(n), c(n);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for(int i = 0; i < n; i++)
		scanf("%d", &b[i]);
	for(int i = 0; i < n; i++)
		scanf("%d", &c[i]);

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	ll ans = 0;
	for(int i = 0; i < n; i++){
		int prej = (lower_bound(a.begin(), a.end(), b[i]) - a.begin()) - 1 + 1;
		int po = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
		ans += 1LL * prej * po;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #pragma comment(linker, "/STACK:2000000")
  #pragma comment(linker, "/HEAP:2000000")
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  int32_t main()
  {        
    IOS
    int n;
    cin>>n;
    int a[n+2];
    int b[n+1];
    int ans=0;
    rep(i,1,n+1)
    {
      cin>>a[i];
    }
    rep(i,1,n)
    {
      cin>>b[i];
    }
    rep(i,1,n)
    {
      if(b[i]<=a[i])
      {
        a[i]-=b[i];
        ans+=b[i];
        b[i]=0;
        
      }
      else if(b[i]>a[i])
      {
        b[i]-=a[i];
        ans+=a[i];
        a[i]=0;
        if(b[i]>a[i+1])
        {
          b[i]-=a[i+1];
          ans+=a[i+1];
          a[i+1]=0;
        }
        else if(b[i]<=a[i+1])
        {
          a[i+1]-=b[i];
          ans+=b[i];
          b[i]=0;
        }
      }
    }
    cout<<ans;
    return 0;
} 

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

using namespace std;
using namespace atcoder;

int main() {
    int n, m;
    cin >> n >> m;
    dsu d(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        d.merge(a, b);
    }
    cout << d.groups().size() - 1 << "\n";
    return 0;
}


Measured memory_bytes: 9028
import java.io.*;
import java.lang.*;
import java.util.*;

class Main
{
    
    public static void main(String args[])throws IOException
    {
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	while(true)
	    {
		String line;
		line = in.readLine();
		int m,n;
		m = Integer.parseInt(line.substring(0,line.indexOf(" ")));
		n = Integer.parseInt(line.substring(line.indexOf(" ")+1));
		if(n+m == 0)break;

		LinkedList<Integer> list = new LinkedList<Integer>();
		for(int i=1;i<=m;i++)
		    list.addLast(i);

		int pos = 0;

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

		
			line = in.readLine();
			if(list.size() <= 1)continue;

			if(i%3 == 0 || i%5 == 0)
			    {
				boolean ok = true;
				if(i%3 == 0 && i%5 == 0)
				    {
					if(!line.equals("FizzBuzz"))
					    ok = false;
				    }
				else if(i%3 == 0)
				    {
					if(!line.equals("Fizz"))
					    ok = false;
				    }
				else 
				    {
					if(!line.equals("Buzz"))
					    ok = false;
				    }
				
				if(!ok)
				    {
					list.remove(pos);
					pos--;
				    }
			    }
			else
			    {
				String eq = String.valueOf(i);
				if(!eq.equals(line))
				    {
					list.remove(pos);
					pos--;		
				    }
			    }

			pos++;
			if(pos >= list.size())
			    pos = 0;
		    }

		for(int i=0;i<list.size();i++){
		    System.out.print(list.get(i));
		    if(i != list.size()-1)System.out.print(" ");
		}
		System.out.println("");
	    }
    }
}

Measured memory_bytes: 11000
#include<stdio.h>

int main(void) {
  int x[5];
  int i, j;
  
  for(j = 0; j < 5; j++){
    scanf("%d",&x[j]);
    
    if(x[j] == 0){
      i = j + 1;
    }
  }
  
  printf("%d\n", i);
  
  return 0;
}

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

using ll = long long;

int N, K;
int D[11];

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

   ll num = N;
   while (1) {
      string s = to_string(num); // 数字を文字列にする

      bool ok = true; // 嫌いな数字が存在しないならtrue
      // 嫌いな数字の有無を判定
      for (int i = 0; i < K; i++) {
         if (count(s.begin(), s.end(), D[i]+'0')) {
            ok = false;
            num++;
            break;
         }
      }

      // 嫌いな数字が無ければnumを出力して終了
      if (ok) {
         cout << num << endl;
         return 0;
      }
   }

   return 0;
}

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

#define int ll
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define fst first
#define pb push_back

const int MOD = (int)1e9 + 7;

signed main() {
    int N, X;

    cin >> N >> X;

    vector<int> As(N);
    REP(i, N) {
        cin >> As.at(i);
    }

    // 見ながらキャンディーを食べていく
    int ans = 0;

    int prev = As.at(0);
    FORE(i, 1, N-1) {
        const int current = As.at(i);

        if ((current + prev) > X) {
            const int eaten = (current + prev - X);
            // cout << "eat at " << i << " " << eaten << endl;
            ans += eaten;

            if (current >= eaten) {
                prev = current - eaten;
            } else {
                // 次のprevは食べきったのでゼロ
                // 個数については以前のどこかで帳尻合わせられると思う
                prev = 0;
            }

            debug(i);
            debug(current);
            debug(eaten);
            debug(prev);
            hyphen();
        } else {
            prev = current;
        }
    }

    debug(ans);
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    char a;
    cin >> a;
    
    char ans = 'A';
    if (a>='a' && a<='z') ans = 'a';
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define ll long long
#define Arman_Sykot ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
 
using namespace std;

int main()
{
/*********************/
// Author:
        Arman_Sykot;
/*********************/
    
    int x;
    cin >> x;
    int res = x / 500 * 1000;
    
    x %= 500;
    res += x / 5 * 5;
    
    cout << res << "\n";
    
    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int h, n;
  cin >> h >> n;
  int sum = 0;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    sum += a;
  }
  if(h <= sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

struct Combination2
{
	vector<vector<ll>> dp;

	Combination2(int n) : dp(n + 1, vector<ll>(n + 1))
	{
		for (auto i = 0; i <= n; ++i)
		{
			dp[i][0] = 1;
			dp[i][i] = 1;
		}

		for (auto i = 1; i <= n; ++i)
		{
			for (auto j = 1; j <= n; ++j)
			{
				dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
			}
		}
	}

	ll calcCombination(int n, int k)
	{
		return dp[n][k];
	}
};


int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	vector<ll> v(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> v[i];
	}
	sort(v.begin(), v.end(), greater<ll>());

	auto sum = 0ll;
	auto numLastV = 0;
	auto lastV = 0ll;
	auto numNeed = 0;
	for (auto i = 0; i < N; ++i)
	{
		if (i < A)
		{
			sum += v[i];
			if (v[i] == lastV)
			{
				++numLastV;
				++numNeed;
			}
			else
			{
				numLastV = 1;
				numNeed = 1;
				lastV = v[i];
			}
		}
		else if (v[i] == lastV)
		{
			++numLastV;
		}
	}

	auto avg = (double)sum / A;
	auto comb = 1ll;
	if(numLastV > numNeed)
	{
		Combination2 c(numLastV);
		if (lastV == v[0])
		{
			comb = 0;
			for (auto i = A; i <= min(B, numLastV); ++i)
			{
				comb += c.calcCombination(numLastV, i);
			}
		}
		else
		{
			comb = c.calcCombination(numLastV, numNeed);
		}
	}

	cout << fixed << setprecision(10) << avg << endl;
	cout << comb << endl;

	return 0;
}

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

using namespace std;

string S, T, U;
int a, b;

int main(){
    cin >> S >> T;
    scanf("%d %d", &a, &b);
    cin >> U;

    if (U == S)
        a--;
    if (U == T)
        b--;

    printf("%d %d\n", a, b);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    int distance = 0;
    rep(i,N){
        int a_dis = max(2 * vec[i], -2 * vec[i]);
        int b_dis = max(2 * (K - vec[i]), 2 * (vec[i] - K));
        distance += min(a_dis,b_dis);
    }
    cout << distance << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

struct Edge{
  int from, to, cost;
};


const int MAXV = 1002;
const int MAXE = 2002;
Edge edges[MAXE];
bool is_pass[MAXV];
ll d[MAXV];
int V, E;

bool berm(){
  fill(d, d + V, -LL_INF);
  d[0] = 0;
  is_pass[0] = true;
  for(int ct=0;ct<V - 1;ct++){
    for(int i=0;i<E;i++){
      int v = edges[i].to;
      int u = edges[i].from;
      int c = edges[i].cost;
      if(!is_pass[u]) continue;
      is_pass[v] |= is_pass[u];
      if(d[u] + c > d[v]){
        d[v] = d[u] + c;
      }
    }
  }
  ll pv = d[V-1];
  for(int ct=0;ct<V - 1;ct++){
    for(int i=0;i<E;i++){
      int v = edges[i].to;
      int u = edges[i].from;
      int c = edges[i].cost;
      if(!is_pass[u]) continue;
      is_pass[v] |= is_pass[u];
      if(d[u] + c > d[v]){
        d[v] = d[u] + c;
        /*        if(ct == V-1&&is_pass[u]){
          return false;
          }*/
      }
    }
  }
  if(pv != d[V - 1]) return false;
  return true;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> V >> E;
  REP(i,E){
    int u, v, c;
    cin >> u >> v >> c;
    --u;
    --v;
    edges[i] = {u, v, c};
  }
  if(not berm()){
    cout << "inf" << endl;
  }else{
    cout << d[V-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
#define ll long long

#define MAX 100020
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
#define ll long long

#define MAX 100020

int main(){
string s;
int n;
cin>>n>>s;

for(int i=0;i<s.length();i++){
    if(s[i]+n > 'Z')
        {
            int diff=  s[i] +n -'Z';
            s[i]='A'+diff -1;
        }        
    else
        s[i]= s[i]+n;
}
cout<<s;
}

Measured memory_bytes: 3040
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    ll a;
    cin >> a;
    string s;
    cin >> s;
    ll b = 0;
    rep(i,0,sz(s)){
	if(s[i]  != '.'){
	    b *= 10;
	    b += s[i] - '0';
	}
    }

    ll ans = a * b / 100;
    P(ans);
    return  0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    if((a[1] - a[0]) % 2 == 0){
        cout << a[2] - a[1] + (a[1] - a[0]) / 2 << endl;
    }else{
        cout << a[2] - a[1] + (a[1] - a[0] + 1) / 2 + 1 << endl;
    }
}

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

typedef long long ll;
typedef pair<int, ll> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

ll d[310][310];

void warshall_floyd(int n){
    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
    int n; cin>>n;
    int a[n][n];
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cin>>a[i][j];
            d[i][j]=a[i][j];
        }
    }

    warshall_floyd(n);

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(a[i][j]!=d[i][j]){
                cout << -1 << endl;
                return 0;
            }
        }
    }

    ll ans=0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            bool remove=false;
            for(int k=0; k<n; k++){
                if(i==k || j==k) continue;
                if(d[i][k]+d[k][j]==d[i][j]) remove=true;
            }
            if(!remove) ans+=d[i][j]; 
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {

    static HashSet<Integer> q;
    static HashMap<Integer, ArrayDeque<Integer>> map;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            ArrayDeque<Integer> deq = new ArrayDeque<>(n-1);
            for (int j = 0; j < n-1; j++) {
                deq.add(sc.nextInt()-1);
            }
            map.put(i, deq);
        }
        int ans = 0;
        q = new HashSet<>();
        for (int i = 0; i < n; i++) {
            check(i,q);
        }
        while(!q.isEmpty()){
            ans++;
            HashSet<Integer> nexq = new HashSet<>();
            for(int i : q){
                int a = i / 10000;
                int b = i % 10000;
                map.get(a).poll();
                map.get(b).poll();
            }
            for(int i : q){
                int a = i / 10000;
                int b = i % 10000;
                check(a, nexq);
                check(b, nexq);
            }
            q = nexq;
        }
        boolean able = true;
        for (int i = 0; i < n; i++) {
            if(0 < map.get(i).size()){
                able = false;
                break;
            }
        }
        System.out.println(able ? ans : -1);
        sc.close();

    }

    private static void check(int i , HashSet<Integer> set){
        if(map.get(i).isEmpty()) return;
        int x = map.get(i).peek();
        if(map.get(x).isEmpty() || map.get(x).peek() != i) return;
        int tmp = i * 10000 + x;
        if(x < i) tmp = x * 10000 + i;
        set.add(tmp);
    }

}


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

int main(){
	string s;
	cin >> s;
	if(s[5] == '1' || s[6] == '5' ||s[6] == '6' ||s[6] == '7' ||s[6] == '8' ||s[6] == '9'){
		cout << "TBD" << endl;
	}
	else if(s[6] == '4' && s[8] == '3' && s[9] == '1'){
		cout << "TBD" << endl;
	}
	else{
		cout << "Heisei" << endl;
	}
}

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

using namespace std;

const int64_t INF = 1LL << 60;

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

  int N, M, S;
  cin >> N >> M >> S;
  vector<vector<pair<int, int>>> G(N);
  vector<int64_t> A(M), B(M);
  for (int i = 0; i < M; i++) {
    int u, v;
    cin >> u >> v >> A[i] >> B[i];
    u--, v--;
    G[u].emplace_back(make_pair(v, i));
    G[v].emplace_back(make_pair(u, i));
  }

  vector<int64_t> C(N), D(N);
  for (int i = 0; i < N; i++) {
    cin >> C[i] >> D[i];
  }

  int mx = 3000;
  vector<vector<int64_t>> H(N, vector<int64_t>(mx + 1, INF));
  priority_queue<pair<int64_t, pair<int, int>>,
                 vector<pair<int64_t, pair<int, int>>>,
                 greater<pair<int64_t, pair<int, int>>>>
      que;
  que.push(make_pair(0, make_pair(0, min(mx, S))));

  while (!que.empty()) {
    auto q = que.top();
    que.pop();

    int64_t t = q.first;
    int u = q.second.first, c = min(mx, q.second.second);

    if (H[u][c] != INF) continue;

    H[u][c] = t;
    que.push(make_pair(t + D[u], make_pair(u, c + C[u])));

    for (auto g : G[u]) {
      int v = g.first;
      int64_t a = A[g.second], b = B[g.second];
      if (a > c) continue;
      que.push(make_pair(t + b, make_pair(v, c - a)));
    }
  }

  for (int i = 1; i < N; i++) {
    cout << *min_element(H[i].begin(), H[i].end()) << '\n';
  }
  return 0;
}


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

const int N = 100005;
const int md = 1e9 + 7;
const long long inf = 2e18 + 123;

int n;
long long S[N];
long long A, B;
int f[N][2];
int ans;

// 0 XA - 1 YB
int reachable[N][2];
int nr[N][2];

void add(int &x, int y) { x += y; while(x >= md) x -= md; if (x < 0) x += md; }

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> A >> B;
	for (int i = 1; i <= n; ++i) cin >> S[i];
	S[n + 1] = inf; S[0] = -inf;
	// calculate 'reachable'
	for (int j = 0; j < 2; ++j) {
		long long val = (j == 0) ? A : B;
		reachable[n + 1][j] = n + 1;
		for (int i = n; i >= 1; --i) {
			reachable[i][j] = ((S[i + 1] - S[i] >= val) ? reachable[i + 1][j] : i);
		}
	}

	// calculate 'nearest'
	for (int j = 0; j < 2; ++j) {
		long long val = (j == 0) ? A : B;
		int ptr = n + 1;
		for (int i = n; i >= 1; --i) {
			while(ptr > i && S[ptr - 1] >= S[i] + val) --ptr;
			nr[i][j] = ptr;
		}
	}

	// dp
	f[1][0] = f[1][1] = 1;
	f[2][0] = f[2][1] = md - 1;
	for (int i = 1; i < n; ++i) for (int j = 0; j < 2; ++j) {
		add(f[i][j], f[i - 1][j]);
		int r = reachable[i][j]; ++r;
		int l = max(i + 1, nr[i - 1][j ^ 1]);
		if (l > r) continue;
		add(f[l][j ^ 1], f[i][j]); add(f[r + 1][j ^ 1], (-f[i][j] + md) % md); 
 	}
 	for (int j = 0; j < 2; ++j) add(f[n][j], f[n - 1][j]);

 	for (int j = 0; j < 2; ++j) {
 		for (int i = 1; i <= n; ++i) if (reachable[i][j] > n) add(ans, f[i][j]);
 	}

 	cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,k;
  cin>>n>>k;
  ll ans=k;
  rep(i,n-1){
    ans*=(k-1);
  }
  COUT(ans);
}
    


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<ll> a(n),b(m);
	rep(i,n) cin >> a[i];
	rep(i,m) cin >> b[i];
	vector<ll> c = convolution(a,b);
	for (int i=0;i < n + m -1;i++) {
		printf("%lld ",c[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 27240
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,x,y,z;
    cin>>a>>b>>c;
    int temp =a;
        a=b;
        b=temp;
    int t2=a;
        a=c;
        c=t2;
        cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define pb push_back
#define mem(a, b)     memset(a, b, sizeof(a))
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*sort(v.begin(), v.end(),
     [](const pair<int, int>& x, const pair<int, int>& y)
{
    if (x.first != y.first)
        return x.first < y.first;
    return x.second < y.second;
});
*/
int const fx[]= {+1,+0,-1,+1};
int const fy[]= {-1,+1,+0,+0};
const int inf = numeric_limits<int>::max();
const int mx=2e5;
const ll mod=1e9+7;
int main()
{
    int n,i;
    cin >> n;
    vector<ll>v(n);
    for(i=0;i<n;i++)cin >> v[i];
    sort(v.rbegin(),v.rend());
    ll sum=0;
    n-=2;
    sum+=v[0];
    i=1;
    while(n>0)
    {
        if(n!=1)
            sum+=(2*v[i]);
        else
            sum+=v[i];
        i++;
        n-=2;
    }
    cout << sum <<endl;
    return 0;
}




Measured memory_bytes: 4840
import java.awt.Point;
import java.util.Scanner;

public class Main {

    private static Point NA = new Point(0, 0);

    public static void main(String[] args) {
        int[] vals = input();
        int min = Integer.MAX_VALUE;
        for (int t = 1; t < vals.length; t++) {
            int diff = calc(t, vals);
            if (diff < min) {
                min = diff;
            }
        }
        System.out.println(min);
    }

    private static int calc(int t, int[] vals) {
        int sum1 = 0;
        int sum2 = 0;

        for (int i = 0; i < vals.length; i++) {
            if (i < t) {
                sum1 += vals[i];
            } else {
                sum2 += vals[i];
            }
        }

        return sum1 > sum2 ? sum1 - sum2 : sum2 - sum1;
    }

    private static int[] input() {
        try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int[] vals = new int[N];
            for (int i = 0; i < N; i++) {
                vals[i] = scanner.nextInt();
            }
            return vals;
        }
    }
}


Measured memory_bytes: 22868
def main():
    N = int(input())
    A = list(map(int, input().split()))

    M = max(A)
    L = M.bit_length()
    ans = 0
    mod = 10**9 + 7
    k = [0]*max(1, L)
    k[0] = 1
    for i in range(1, L):
        k[i] = k[i-1]*2
    for j in range(L):
        count = 0
        for x in A:
            if (x >> j) % 2 == 1:
                count += 1
        ans += count*(N - count)*k[j]
    ans %= mod
    print(ans)


main()


Measured memory_bytes: 125624
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define db long double
  #define PB push_back
  int32_t main()
  {         
    
    
    IOS
   
    
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    
    int ans=0;
    for(int i=1;i<n-1;i++)
    {
        vector<int> v;
        v.PB(arr[i]);
        v.PB(arr[i-1]);
        v.PB(arr[i+1]);
        sort(v.begin(),v.end());
        if(v[1]==arr[i])
        {
            ans++;
        }
    }
    
    cout<<ans;
    return 0;
  }           

Measured memory_bytes: 256
N = int(input())
L = []
for i in range(N):
  L.append(input())

print("AC x "+str(L.count('AC'))+
"\nWA x "+str(L.count('WA'))+
"\nTLE x "+str(L.count('TLE'))+
"\nRE x "+str(L.count('RE')))

Measured memory_bytes: 16280
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

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

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {

        Int N;
        cin >> N;

        vector<vector<Int>> cnt(10, vector<Int>(10, 0));

        for (int i = 1; i <= N; ++i) {
            Int tail = i % 10;

            string s = to_string(i);
            Int head = s[0] - '0';

            cnt[head][tail]++;
        }

        Int ans = 0;
        for (int hi = 0; hi <= 9; ++hi) {
            for (int ti = 0; ti <= 9; ++ti) {
                Int tmp = cnt[hi][ti] * cnt[ti][hi];
                ans += tmp;
//                for (int hj = 0; hj <= 9; ++hj) {
//                    for (int tj = 0; tj <= 9; ++tj) {
//                    }
//                }
            }
        }

        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
from collections import defaultdict
N,M,K=map(int,input().split())
MOD=998244353
 
def comb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % MOD )
    inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )
    g2.append( (g2[-1] * inverse[-1]) % MOD )

  
ans=0
col=M
 
for x in range(N-1,-1,-1):
  now=col*comb(N-1,x,MOD)%MOD
  if x<=K:
    ans = (ans+now)%MOD
  col =col*(M-1)%MOD

print(ans%MOD)

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

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

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

#define endl "\n"

void use_cio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto x : V) os << x << ", ";
  return os << "]";
}

//--------------------------------------------------//

int main() {
  use_cio();
  int a, b;
  cin >> a >> b;
  if (a >= 13)
    cout << b;
  else if (a >= 6)
    cout << b / 2;
  else
    cout << 0;
}


Measured memory_bytes: 256
function Main(input){
	input = input.split(" ").map(a=>~~a);
	var A = input[0];
  var B = input[1];
  var C = input[2];
  
  var delicious = 0;
  
  var hoge = Math.min(B,C);
  
  delicious += hoge * 2;
  B -= hoge;
  C -= hoge;
  
  var fuga = Math.min(A,C);
  
  delicious += fuga;
  
  A -= fuga;
  C -= fuga;
  
  if(B != 0)delicious += B;
  if(C != 0)delicious += 1;
  
 	return delicious; 
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
8 8 1
`);

Measured memory_bytes: 7372
using System;
using System.Linq;

class C
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var x = read();
		int n = h[0], k = h[1];
		Console.WriteLine(Enumerable.Range(0, n - k + 1).Min(i => x[i + k - 1] - x[i] + Math.Min(Math.Abs(x[i + k - 1]), Math.Abs(x[i]))));
	}
}


Measured memory_bytes: 23264
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((LL) (r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl, system("pause")
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, system("pause")
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, system("pause")
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl, system("pause")

#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;

LL n;

LL gao() {
    if (n == 0 || n & 1) return 0;
    n = n / 2;
    LL ans = 0;
    while (n != 0) ans += n / 5, n /= 5;
    return ans;
}

int main() {
    // FASTIO;
    while (cin >> n) cout << gao() << '\n';
    return 0;
}


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

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

  int t[100000];
  for(int i = 0; i < n; i++){
    cin >> t[i];
  }

  sort(t, t+n);

  int ans = 1, s = t[0], cnt = 1;
  for(int i = 1; i < n; i++){
    if(s + k >= t[i] and cnt < c){
      cnt++;
    }else{
      ans++;
      s = t[i];
      cnt = 1;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
n=int(input())
c=[0]*(n+1)
for i in range(2,n+1):
  num=i
  for j in range(2,i+1):
    while num%j==0:
      c[j]+=1
      num //= j
def cnt(x):
  count=0
  for i in range(n+1):
    if c[i]>=x-1:count+=1
  return count
      
print(cnt(75)+cnt(25)*(cnt(3)-1)+cnt(15)*(cnt(5)-1)+cnt(5)*(cnt(5)-1)*(cnt(3)-2) //2)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int i = 1;
		int x;
		while(((x = sc.nextInt()) != 0)){
			System.out.println("Case " + i++ + ": " + x);
		}
	}
}

Measured memory_bytes: 41944
N , K = map(int, input().split())
l = list(map(int, input().split()))
ll = sorted(l)
res = 0
if N == K :
    res = sum(ll)
elif K==1 : 
    res = ll[0]
else:
    for i in range (K):
        res += ll[i]
print(res)

Measured memory_bytes: 9212
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		long ans = a * b;

		long min = Math.min(a, b);
		List<Long> list = new ArrayList<>();
		
		for (long i = 2; i <= min; i++) {
			if (a % i == 0 && b % i == 0 ) {
				min /= i;
				a /= i;
				b /= i;
				list.add(i);
				i--;
			}
		}
		
		for (Long long1 : list) {
			ans /= long1;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<utility>

using namespace std;

int main(void){
  int A, B, C;
  cin >> A >> B >> C;
  if(B < A) swap(A, B);
  if(A < C && C < B) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

const int N=12,c[11]={0,1,2,4,7,12,20,29,38,52,73};
ll w[N][N],p[N],n,M;

int main(){
	cin>>n;
	rep(i,2,n){
		rep(j,1,i-1) w[i][j]=w[j][i]=(M+1)*c[j];
		if(i==n) break;
		rep(j,1,i) p[j]=j;
		do{
			if(p[1]>p[i]) continue;
			ll sum=0;
			rep(j,1,i-1) sum+=w[p[j]][p[j+1]];
			M=max(M,sum);
		}while(next_permutation(p+1,p+i+1));
	}
	rep(i,1,n) rep(j,1,n)
		printf("%lld%c",w[i][j]," \n"[j==n]);
	return 0;
}

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

using namespace std;

bool withinRegion(int i, int j, int h, int w, char **matrix)
{
    if (i >= 0 && i < h && j >= 0 && j < w && matrix[i][j] == '.') {
        return true;
    }
    return false;
}

void init_searched(int h, int w, int **searched)
{
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            searched[i][j] = -1;
        }
    }
}

int main()
{
    int h, w;
    cin >> h >> w;
    queue<pair<int, int> > q;
    int max = -1;

    char **matrix = new char*[h];
    int **searched = new int*[h];
    for (int i = 0; i < h; i++) {
        matrix[i] = new char[w];
        searched[i] = new int[w];
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> matrix[i][j];
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (matrix[i][j] == '.') {
                int tmpmax = -1;
                init_searched(h, w, searched);
                searched[i][j] = 0;
                q.push(make_pair(i, j));
                while (!q.empty()) {
                    int r = q.front().first;
                    int c = q.front().second;
                    q.pop();
                    if (withinRegion(r + 1, c, h, w, matrix) && searched[r + 1][c] == -1) {
                        searched[r + 1][c] = searched[r][c] + 1;
                        q.push(make_pair(r + 1, c));
                    }
                    if (withinRegion(r, c + 1, h, w, matrix) && searched[r][c + 1] == -1) {
                        searched[r][c + 1] = searched[r][c] + 1;
                        q.push(make_pair(r, c + 1));
                    }
                    if (withinRegion(r - 1, c, h, w, matrix) && searched[r - 1][c] == -1) {
                        searched[r - 1][c] = searched[r][c] + 1;
                        q.push(make_pair(r - 1, c));
                    }
                    if (withinRegion(r, c - 1, h, w, matrix) && searched[r][c - 1] == -1) {
                        searched[r][c - 1] = searched[r][c] + 1;
                        q.push(make_pair(r, c - 1));
                    }
                }
                for (int r = 0; r < h; r++) {
                    for (int c = 0; c < w; c++) {
                        if (withinRegion(r, c, h, w, matrix) && tmpmax < searched[r][c]) {
                            tmpmax = searched[r][c];
                        }
                    }
                }
                if (tmpmax > max) {
                    max = tmpmax;
                }
            }
        }
    }

    cout << max << endl;

    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define ll  long long 
#define mp make_pair
#define pb push_back
#define f first
#define s second
const ll mod=998244353;
const ll N=2e5+5;
const ll INF = 1e17;
unordered_map<ll,vector<ll>> adj;
vector<ll> vis(300005,0);
vector<ll> p(100005,0);
ll c[100005];
ll cnt;
ll n;
void dfs(ll node)
{
  if(vis[node])
    return;
  vis[node]=1;
  cnt++;
  for(auto i:adj[node])
    {
      dfs(i);
    }
}
struct range{
  ll l;
  ll r;
  ll a;
};
bool cmp(range& p1,range& p2)
{
    if(p1.a==p2.a)
      return p1.l<p2.l;
    return p1.a<p2.a;
}
int main()
{
   ll n,m,l;
   cin>>n>>m>>l;
   ll c,a,b;
   ll d[n+1][n+1];
  ll f[n+1][n+1];
  ll i,j,k;
  for(i = 1; i <= n; i++) {
        for(j = 1; j <=n; j++) {
            f[i][j] = INF;
            d[i][j] = INF;
        }
        f[i][i] = 0;
        d[i][i] = 0;
    }
  
   while(m--)
   { 
      cin>>a>>b>>c;
      d[a][b]=c;
      d[b][a]=c;
   }
   for(i=1;i<=n;i++)
      d[i][i]=0;
  for(k=1;k<=n;k++)
  {
     for(i=1;i<=n;i++)
     {
        for(j=1;j<=n;j++)
        {
            d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
        }
     }
  }
  for(i=1;i<=n;i++)
  {
     for(j=1;j<=n;j++)
     {
        if(i==j)
          continue;
        if(d[i][j]<=l)
           {
            f[i][j]=1;
           // cout<<i<<" "<<j<<" "<<d[i][j]<<endl;
          }
     }
  }
  for(k=1;k<=n;k++){
  for(i=1;i<=n;i++)
  {
     for(j=1;j<=n;j++)
     {
         f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
     }
  }
}
ll q;
cin>>q;
ll s,t;
    while(q--)
    {
        cin>>s>>t;
        if(f[s][t]==INF)
            cout<<"-1\n";
        else
          cout<<f[s][t]-1<<endl;
    }

}

Measured memory_bytes: 7700
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN=2e5+10;
const int mod=1e9+7;
const int INF=1e9+10;
const double EPS=1e-3;
const LL invTwo=500000004;

int x[MAXN][2];
LL y[4005][4005],inv[8005],fra[8005];

LL power(LL a,LL b){
    LL c=1;
    while(b){
        if (b%2==1) c=c*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return c;
}

LL C(LL n,LL m){
    if (n<0 || m<0 || n<m) return 0;
    return fra[n]*inv[m]%mod*inv[n-m]%mod;
}

int n;

int main(){
    fra[0]=1; for(int i=1;i<=8000;i++) fra[i]=fra[i-1]*i%mod;
    inv[8000]=power(fra[8000],mod-2); for(int i=7999;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
    scanf("%d",&n);
    memset(y,0,sizeof(y));
    for(int i=1;i<=n;i++){
        scanf("%d%d",&x[i][0],&x[i][1]);
        y[2000-x[i][0]][2000-x[i][1]]++;
    }
    for(int i=0;i<=4000;i++)
        for(int j=0;j<=4000;j++){            
            if (i>0) y[i][j]+=y[i-1][j];
            if (j>0) y[i][j]+=y[i][j-1];
            y[i][j]%=mod;
        }
    LL ans=0;
    for(int i=1;i<=n;i++){
        ans+=y[2000+x[i][0]][2000+x[i][1]];
        ans-=C(x[i][0]*2+x[i][1]*2,x[i][0]*2);
        ans%=mod;
    }
    if (ans<0) ans+=mod;
    printf("%lld\n",ans*power(2,mod-2)%mod);
    return 0;
}

Measured memory_bytes: 127232
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const LL MOD = 1e9 + 7;

inline LL mod_add(LL a, LL b) {
    return (a + b) % MOD;
}

inline LL mod_sub(LL a, LL b) {
    return (a + MOD - b) % MOD;
}

inline LL mod_mul(LL a, LL b) {
    return ((a % MOD) * (b % MOD)) % MOD;
}

LL mod_bipow(LL x, LL y) {   // power using bisection method
    if (y == 0) return 1;
    else if (y == 1) return x % MOD;
    else if (y % 2 == 0) {
        LL val = mod_bipow(x, (LL)(y / 2));
        return mod_mul(val, val);
    } else {
        LL val = mod_bipow(x, (LL)(y / 2));
        return mod_mul(mod_mul(val, val), x);
    }
}

LL mod_inv(LL x) {   // compute x^{-1}=x^{MOD-2} (when MOD is a prime number) using Fermat theorem
    return mod_bipow(x, MOD - 2);
}

LL mod_div(LL a, LL b) {   // using a/b=a*b^{-1}
    return mod_mul(a, mod_inv(b));
}

void solve(LL N, LL M){
	VI primes, counts;
	int m = M;
	FOR(i, 2, m) {
		if (M < i) break;
		int count = 0;
		while (M % i == 0) {
			count++;
			M /= i;
			//cout << M << endl;
		}
		if (count > 0) {
			primes.push_back(i);
			counts.push_back(count);
		}
	}
	/*
	REP(i, SZ(primes)) {
		cout << primes[i] << " " << counts[i] << endl;
	}
	cout << "---" << endl;
	*/
	LL sum = 1;
	REP(i, SZ(primes)) {
		LL comb = 1;
		for (LL n = N; n <= (counts[i] + N - 1); n++) {
			comb = mod_mul(comb, n);
		}
		for (LL r = 2; r <= counts[i]; r++) {
			comb = mod_div(comb, r);
		}
		//cout << i << " " << comb << endl;
		sum = mod_mul(sum, comb);
	}
	cout << sum << endl;
}


int main(){	
	LL N;
	LL M;
	scanf("%lld",&N);
	scanf("%lld",&M);
	solve(N, M);
	return 0;
}



Measured memory_bytes: 256
from collections import deque
H, W, K = map(int, input().split())
sh, sw, gh, gw = map(int, input().split())
sh, sw, gh, gw = sh - 1, sw - 1, gh - 1, gw - 1
G = [list(input()) for _ in range(H)]
INF = 10 ** 9


D = [[INF] * W for _ in range(H)]
D[sh][sw] = 0
directions = [(0, 1), (0, -1), (1, 0), (-1, 0)]
que = deque([(sh, sw)])

while que:
    nh, nw = que.pop()
    for dh, dw in directions:
        for k in range(1, K + 1):
            nx_h, nx_w = nh + k * dh, nw + k * dw
            if not (0 <= nx_h < H and 0 <= nx_w < W):
                break

            if G[nx_h][nx_w] == '@':
                break

            if D[nx_h][nx_w] < D[nh][nw] + 1:
                break

            if D[nx_h][nx_w] > D[nh][nw] + 1:
                D[nx_h][nx_w] = D[nh][nw] + 1
                que.appendleft((nx_h, nx_w))

print(D[gh][gw] if D[gh][gw] != INF else -1)


Measured memory_bytes: 137200
N,M = map(int,input().split())

a=[0]*N
b=[0]*N
c=[0]*M
d=[0]*M


for i in range(N):
    a[i],b[i] = map(int,input().split())
    
    
for i in range(M):
    c[i],d[i] = map(int,input().split())
    
    
for i in range(N):
    x = a[i]
    y = b[i]
    
    for j in range(M):
        
        cx = c[j]
        cy = d[j]
        
        temp = abs(cx-x) + abs(cy-y)
        
        if j==0:
            Min = temp
            result =1
        elif Min > temp:
            result = j+1
            Min = temp
            
            
    print(result)

Measured memory_bytes: 3064
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m,k = list(map(int, input().split()))
ans = "No"
for i in range(n+1):
    for j in range(m+1):
        val = i*j + (n-i)*(m-j)# - i*(m-j) - j*(n-i)
#         print(val)
        if val==k:
            ans = "Yes"
            break
    if ans=="Yes":
        break
print(ans)

Measured memory_bytes: 64504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define EPS 1e-15



int main() {
	string s;
	cin >> s;
	cout << count(all(s), '1') << endl;
	return 0;
}






Measured memory_bytes: 256