akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H1, M1, H2, M2, K = map(int, rl().split())
    
    t1 = H1 * 60 + M1
    t2 = H2 * 60 + M2
    ans = t2 - K - t1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 61640
#include<iostream>

using namespace std;

int main() {
  int i, j, k, l;

  int n;
  cin >> n;

  string s, t[100];
  cin >> s;
  for(i = 0; i < n; ++i)
    cin >> t[i];

  int ct = 0;
  for(i = 0; i < n; ++i) {
    for(j = 0; (j + 1) * s.size() - j <= t[i].size(); ++j) {
      for(k = 0; k <= t[i].size() - (j + 1) * s.size() + j; ++k) {
        for(l = 0; l < (int)s.size() && t[i][k + (j + 1) * l] == s[l]; ++l) ;
        if(l >= (int)s.size()) break;
      }
      if(k <= t[i].size() - (j + 1) * s.size() + j) break;
    }
    if((j + 1) * s.size() - j <= t[i].size())
      ++ct;
  }

  cout << ct << endl;
  return 0;
}

Measured memory_bytes: 1224
#include<stdio.h>

#define maxn 101111
int fa[maxn];
int vis[maxn];
int find_father(int x)
{
    if(x == fa[x])return x;
    return fa[x] = find_father(fa[x]);
}
void uni(int x,int y)
{
    int fx = find_father(x);
    int fy = find_father(y);
    if(fy!=fx)
    {
        fa[fx] = fy;
    }
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i)fa[i] = i;
    for(int i=1;i<=m;++i)
    {
        int x,y,w;
        scanf("%d%d%d",&x,&y,&w);
        uni(x,y);
    }
    int ans = 0;
    for(int i=1;i<=n;++i)
    {
        if(!vis[find_father(i)])
        {
            vis[find_father(i)]=1;
            ans++;
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  ll z,w;
  cin >> n >> z >> w;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  ll ans = 0;
  maxs(ans,(ll)abs(w-a[n-1]));
  if(n>1)maxs(ans,(ll)abs(a[n-1]-a[n-2]));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
/*
https://open.spotify.com/track/1nEjpWJlqcOsf2ZaRQ3XdW?si=gmXBzPYtTPy6Mi9iqI9hvA

In the particularly cold night
Perhaps you couldn’t sleep well
In the bright morning woken up from sleep
You are full of darkness
You, who were so worried for some reason that you
Hugged me tightly and asked for my love

You broke and ruined my everything
My daily life and even my people yeah
I resent you all day
But to leave you I oh I

Don’t worry babe
I love you babe
I’ll be by your side
Maybe

Maybe

Looks about to collapse but remains
And the cycle continues unsteadily
I’m about to give up but when I see you I Oh I

No babe
I love you babe
I’ll hold your hand
Maybe

Maybe
I’ll be by your side
Maybe
I’ll trust you

Stay with me, stay with me
So you won’t think of anything
I’ll stay here pretending to be reluctant
So hold me back
Maybe

Maybe
I will be by your side
Maybe
I’ll trust you

Maybe

*/

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a - 1; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

using namespace std;
using cd = complex<double>;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<cd> vcd;
typedef vector<ii> vii;
typedef vector<vector<int> > vvi;

const int modd1 = 1e9 + 7, modd2 = 998244353, maxn = 18, K = 26;
const double pi = acos(-1);
int n, m, dp[maxn][1 << maxn], cost[1 << maxn], gr[maxn][maxn];

void solve(){
	int i, j, k, l, r, mask;
	cin >> n >> m;
	for1(i, 1, m){
		int u, v, w; cin >> u >> v >> w; u--; v--;
		gr[u][v] = w; gr[v][u] = w;
	}
	int lim = 1 << n;//  cout << lim <<  ' ';
	for0(mask, 1, lim){
		for0(i, 0, n){
			for0(j, i + 1, n){
				if(((mask >> i) & 1) && ((mask >> j) & 1)){
					cost[mask] += gr[i][j];
				}
			}
			dp[i][mask] = -1;
		}
	}
	dp[0][1] = 0;
	for0(mask, 1, lim){
		for0(i, 0, n){
			if(dp[i][mask] != -1){
				for0(j, 0, n){
					if(!((mask >> j) & 1) && gr[i][j]){
						dp[j][mask | (1 << j)] = max(dp[j][mask | (1 << j)], dp[i][mask] + gr[i][j]);
					}
				}
				int now = (lim - 1) ^ mask;
				for(int it = now; it > 0; it = (it - 1) & now){
					dp[i][mask | it] = max(dp[i][mask | it], dp[i][mask] + cost[it | (1 << i)]);
				}
			}
		}
	}
  //cout << cost[lim - 1] <<  ' ' << dp[n - 1][lim - 1] << ' ';
	cout << cost[lim - 1] - dp[n - 1][lim - 1];
}

signed main() {
    //freopen(".INP", "r", stdin);
    //freopen(".OUT", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}


Measured memory_bytes: 7816
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int r,g,b,n,ans=0;
    scanf("%d %d %d %d",&r,&g,&b,&n);
    for(int i=0;i*r<=n;i++){
        for(int j=0;j*g+i*r<=n;j++){
            if((n-i*r-j*g)%b==0){
                ans++;
            }
        }
    }
    printf("%d\n",ans);
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<ll> sum(N + 1);
    rep(i, N) {
        cin >> A[i];
        sum[i + 1] = A[i];
    }
    sum.push_back(__LONG_LONG_MAX__);

    for (int i = 0; i < N; i++) {
        sum[i + 1] += sum[i];
    }

    ll ans = __LONG_LONG_MAX__;
    for (int i = 0; i < N; i++) {
        if (i < 2) continue;
        if (i > N - 2) continue;

        ll X = sum[i];
        int l = 0;
        int r = i + 1;
        while (r - l >= 1) {
            int mid = (r + l) / 2;
            if (2 * sum[mid] >= X) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }

        ll P, Q;
        // rかr-1が候補
        ll p1 = sum[r]; ll q1 = X - p1;
        ll p2 = sum[r - 1]; ll q2 = X - p2;
        if (abs(q1 - p1) > abs(q2 - p2)) {
            P = p2; Q = q2;
        } else {
            P = p1; Q = q1;
        }
// cout << "  i: " << i << ", P: " << P << ", Q: " << Q << endl;

        ll Y = sum[N] - X;
        l = i + 1;
        r = N + 1;
        while (r - l >= 1) {
            int mid = (r + l) / 2;
            if (2 * (sum[mid] - sum[i]) >= Y) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }

        ll R, S;
        ll r1 = sum[r] - sum[i]; ll s1 = Y - r1;
        ll r2 = sum[r - 1] - sum[i]; ll s2 = Y - r2;
        if (abs(s1 - r1) > abs(s2 - r2)) {
            R = r2; S = s2;
        } else {
            R = r1; S = s1;
        }
        // cout << "  i: " << i << ", R: " << R << ", S: " << S << endl;

        ans = min(ans, max(P, max(Q, max(R, S))) - min(P, min(Q, min(R, S))));
    }
    cout << ans << endl;
}


Measured memory_bytes: 7212
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

long long mod_pow(long long x, long long n){
   if(n == 0) return 1;
   long long res = mod_pow(x*x, n / 2);
   if(n & 1) res = res*x;
   return res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int ans = (n - m) * 100 + m * 1900;
    cout << ans * mod_pow(2, m) << endl;
}


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

long long gcd(long long n1, long long n2) {
    if (n2 == 0) {
        return n1;
    }
    return gcd(n2, n1 % n2);
}

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

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    int n, broken = 0, curIndex = 1;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        std::cin >> a;
        if (a != curIndex) {
            ++broken;
        } else {
            ++curIndex;
        }
    }
    std::cout << (broken == n ? -1 : broken) << '\n';
    return 0;
}
#endif

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N=200200;
int n,m;
vi g[N];
int c1[N],cn[N];

int main() {
	scanf("%d%d", &n, &m);
	FOR(i,m) {
		int a,b;
		scanf("%d%d", &a, &b);
		g[a].pb(b);
		g[b].pb(a);
	}
	FOR(i,SZ(g[1])) c1[g[1][i]]=1;
	FOR(i,SZ(g[n])) cn[g[n][i]]=1;
	FORI(i,n) if (c1[i] && cn[i]) {
		printf("POSSIBLE\n");
		return 0;
	}
	printf("IMPOSSIBLE\n");
	return 0;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

int n, k;

int32_t main() {

    cin >> n >> k;

    if(k == 1) cout << 0 << endl;
    else {
        cout << n-k << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>
#include<queue>

#define mod 1000000007
#define MAX 100000

long long three_pow[MAX];

void init_pow()
{
	three_pow[0] = 1;
	for (int i = 1; i < MAX; i++)
		three_pow[i] = (three_pow[i - 1] * 3) % mod;

}

long long get_three_pow(int n)
{
	if (n < 0) return 0;
	else return three_pow[n];
}

int main()
{
	long long sum{};
	long long ia_table[MAX]{}, kc_table[MAX]{}, l_table[MAX]{}, r_table[MAX]{};
	std::string s;
	std::cin >> s;
	init_pow();

	for (int i = 1; i < s.size(); i++)
	{
		ia_table[i] = ia_table[i - 1] + (s[i - 1] == 'A');
		l_table[i] = l_table[i - 1] + (s[i - 1] == '?');
	}
	for (int i = s.size() - 2; i >= 0; i--)
	{
		kc_table[i] = kc_table[i + 1] + (s[i + 1] == 'C');
		r_table[i] = r_table[i + 1] + (s[i + 1] == '?');
	}
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] != 'B' && s[i] != '?') continue;
		ia_table[i] = ia_table[i] * get_three_pow(l_table[i]) % mod;
		ia_table[i] = (ia_table[i] + l_table[i] * get_three_pow(l_table[i] - 1)) % mod;
		kc_table[i] = kc_table[i] * get_three_pow(r_table[i]) % mod;
		kc_table[i] = (kc_table[i] + r_table[i] * get_three_pow(r_table[i] - 1)) % mod;
		sum = (sum + ia_table[i] * kc_table[i]) % mod;
	}
	printf("%lld\n", sum);

	return 0;
}

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

int main() {
    string s;
    cin>>s;
    int mn=1000;
    for (int i=0;i+3<=s.size();i++) {
        int a=stoi(s.substr(i,3));
        mn=min(mn,abs(753-a));
    }
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int a, p, ans;

int main(){
	cin >> a >> p;
	
	ans = (a*3 + p)/2;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

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

    vector<int> vec(N);
    for (int i = 0; i < N; i++)
    {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());

    cout << vec.at(N/2) - vec.at(N/2-1) << endl;
    
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
 
  vector <string> a,b;
  string tmp;
  int n,i;
 
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>tmp;
    a.push_back(tmp);
  }

  b.assign(a.begin(),a.end());

  for(i=0;i<n-1;i++)
  {
   for(int j=n-2;j!=i-1;j--) 
   {
    if(a[j][1]>a[j+1][1])
    {
     swap(a[j],a[j+1]);
    }
   }
  }

  for(i=0;i<n-1;i++)
  {
   cout<<a[i]<<" ";
  }
  cout<<a[n-1]<<endl<<"Stable"<<endl;
 
  for(i=0;i<n-1;i++)
  {
    int now,minnum=101;
    for(int j=i;j<n;j++)
    {
      if(minnum>b[j].at(1)-'0')
      {
        now=j;
        minnum=b[j].at(1)-'0';
      }
    }
    if(i!=now)  swap(b[i],b[now]);
  }
 
  for(i=0;i<n-1;i++)
  {
    cout<<b[i]<<" ";
  }
  cout<<b[n-1]<<endl;
  if(a==b) cout<<"Stable"<<endl;
  else cout<<"Not stable"<<endl;
 
  return 0;
 
}


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

int main(){
    vector<int> a(3);
    vector<int> b(3);
    for (int i = 0; i < 3; i++)
    {
        cin>>a[i];
    }
    b[0]=a[2];
    b[1]=a[0];
    b[2]=a[1];
    cout<<b[0]<<" "<<b[1]<<" "<<b[2];
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
typedef long long ll;
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ld long double
#define ss second
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define PI 3.1415926535897932384626
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)

const int mod = 1'000'000'007;

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}


	
int main()
{
		fastio;
		ll t = 1;
		//cin >> t;
		rep(tt,1,t+1)
		{
		int n, w;
	    cin >> n >> w;
	    vector<int> wei(n), val(n);
	    for(int i = 0; i<n; i++) cin >> wei[i] >> val[i];
	   // for(int i = 0; i<n; i++) cin >> wei[i];
	   int max_val = 1e5;
	    vector<vector<ll>> dp(n+1, vector<ll> (max_val+1, INT_MAX));
	    rep(i, 0, n+1) dp[i][0] = 0;
	    
	    // dp[i][j] = min weight required from 1.....i elements so to reach value i
	    for(int j = 1; j<max_val+1; j++)
	    {
	        for(int i = 1; i<n+1; i++)
	        {
	            dp[i][j] = dp[i-1][j];
	            if(j - val[i-1] >= 0 && dp[i-1][j-val[i-1]] != INT_MAX)
	            {
	                dp[i][j] = min(dp[i][j], dp[i-1][j-val[i-1]]+wei[i-1]);
	            }
	        }
	    }
	    // int ans = 0;
        for(int i = max_val; i>=0; i--)
        {
            if(dp[n][i] <= w)
            {
				//deb(dp[n][i]);
                cout << i << endl;
                break;
            }
        }
	}
	return 0;
}


Measured memory_bytes: 83164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n,w;
		n=sc.nextInt();
		w=sc.nextInt();
		int[] wt=new int[n];
		long[] val=new long[n];
		for(int i=0;i<n;i++)
		{
			wt[i]=sc.nextInt();
			val[i]=sc.nextLong();
		}
		System.out.println(knap(wt,val,n,w));
	
		sc.close();

	}
	private static long knap(int[] wt,long[] val,int n,int w)
	{
		long[][] dp=new long[n+1][w+1];
		
		for(int i=1;i<n+1;i++)
		{
			for(int j=1;j<w+1;j++)
			{
				if(wt[i-1]<=j) {
				dp[i][j]=Math.max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);}
				else {
					dp[i][j]=dp[i-1][j];
				}
			}
		}
		return dp[n][w];
	}

}


Measured memory_bytes: 140440
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var l = int.Parse(input[0]);
            var r = int.Parse(input[1]);
            var d = int.Parse(input[2]);

            var cnt = 0;
            for (var i = l; i <= r; i++)
            {
                if (i % d == 0)
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 17860
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e10;
using Graph = vector<vector<int>>;

signed main(){
  int X;
  cin >> X;
  if( X < 600 ){
    cout << 8 << endl;
  }else if( X < 800 ) cout << 7 << endl;
  else if( X < 1000 ) cout << 6 << endl;
  else if( X < 1200 ) cout << 5 << endl;
  else if( X < 1400 ) cout << 4 << endl;
  else if( X < 1600 ) cout << 3 << endl;
  else if( X < 1800 ) cout << 2 << endl;
  else cout << 1 << endl;


}


Measured memory_bytes: 3632
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
 	  Scanner sc = new Scanner(System.in);
 
    String s = sc.next();
    String t = sc.next();
 
    boolean answer = false;
 
    for(int i = 0; i < s.length(); i++){
      boolean checker = true;
      for(int j = 0; j < s.length(); j++){
        if(s.charAt(j) != t.charAt((j+i)%s.length())){
          checker = false;
        }
      }
      if(checker){
        answer = true;
        break;
      }
    }
 
    System.out.println(answer? "Yes" : "No"); 
  }
}

Measured memory_bytes: 21076
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e18;

struct Sieve{
    ll n;
    vector<ll> f, primes;
    //コンストラクタを定義
    Sieve(ll n=1):n(n), f(n+1){//メンバ変数の初期化
        f[0]=f[1]=-1;
        for(ll i=2;i<=n;i++){
            if(f[i]) continue;
            primes.push_back(i);
            f[i]=i;
            for(ll j=i*i;j<=n;j+=i){
                if(!f[j]) f[j]=i;
            }
        }
    }
    bool isPrime(ll x) { return f[x]==x;} //xが素数かどうかを判定
    vector<ll> factorList(ll x){//xの素因数を重複ありで小さい順に列挙
        vector<ll> res;
        while(x!=1){
            res.push_back(f[x]);
            x/=f[x];
        }
        return res;
    }
    vector<pll> factor(ll x){//xの素因数と、その出現回数
        vector<ll> fl=factorList(x);
        if(fl.size()==0) return {};
        vector<pll> res(1,pll (fl[0],0));
        for(ll p : fl){
            if(res.back().first==p){
                res.back().second++;
            }else{
                res.emplace_back(p,1);
            }
        }
        return res;
    }
};

int main(){
    Sieve sieve=Sieve(10000001);
    ll n;
    cin >> n;
    vector<ll> p(10000001),q(10000001,INF);
    ll ans=0;
    for(ll i=2;i<=n;i++){
        if(q[i]==INF){
            for(ll j=i;j<=n;j+=i){
                q[j]=min(q[j],i);
            }
        }
    }
    for(ll i=2;i<=10;i++){
        //cout << q[i] << endl;
    }
    for(ll i=1;i<=n;i++){
        if(i==1){
            ans+=1;
            p[i]=1;
            continue;
        }
        if(sieve.isPrime(i)){
            ans+=i*2;
            p[i]=2;
            continue;
        }
        else{
            ll cnt=0;
            ll v=i;
            while(v%q[i]==0){
                cnt++;
                v/=q[i];
            }
            p[i]=(cnt+1)*p[v];
            ans+=p[i]*i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 243084
n,x = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
ans,b,c = sum(a),[i for i in a],[i for i in range(n)]
for i in range(n):
	for j in range(n): c[j] = min(a[j-i],b[j])
	ans,b,c = min(ans,sum(c)+x*i),c,b
print(ans)

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

int main(){
    int a,b;
    char op;
    while(1){
        cin >> a >> op >>b;
        if(op =='?')break;
        
        if (op =='+') cout << a+b << endl;
        else if (op=='-') cout << a-b << endl;
        else if (op=='*') cout << a*b << endl;
        else if (op=='/') cout << a/b << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
w,h,n=map(int,input().split())
wlist=[0]*w
hlist=[0]*h
for _ in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    for i in range(x):
      wlist[i]=1
  elif a==2:
    for i in range(x,w):
      wlist[i]=1
  elif a==3:
    for i in range(y):
      hlist[i]=1
  elif a==4:
    for i in range(y,h):
      hlist[i]=1
print(wlist.count(0)*hlist.count(0))

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

int main() {
  int N;
  cin >> N;
  int original = N;
  int S = 0;
  while (N > 0) {
    S += N % 10;
    N /= 10;
  }
  // cout << S << endl;
  if (original % S == 0) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,a[60];

bool is()
{
	rep(i,n) if(a[i]!=i+1) return false;
	return true;
}

int main()
{
	cin>>n;
	rep(i,n) cin>>a[i];
	if(is())
	{
		puts("YES");
		return 0;
	}
	rep(i,n)
	{
		rep(j,n)
		{
			if(i==j) continue;
			swap(a[i],a[j]);
			if(is())
			{
				puts("YES");
				return 0;
			}
			swap(a[i],a[j]);
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
X=input()
lst = [int(s) for s in list(X)]
N=len(lst)
X=int(X)
ans=0
#N桁より小さい753数を足す
for i in range(3,N):
  ans+=(3**i-3*(2**i)+3)
#N桁の753数を考える
ls=[7,5,3]
for i in range(1,N):
  ls_3=[10*s+3 for s in ls]
  ls_5=[10*s+5 for s in ls]
  ls_7=[10*s+7 for s in ls]
  ls=ls_3+ls_5+ls_7
 #753数か？
def judge(n):
  if n>X:
    return 0
  else:
    if(('3' in str(n))and('5' in str(n))and('7' in str(n))):
      return 1
    else:
      return 0
for t in ls:
  ans+=judge(t)
print(ans)

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

vector<LL> d;
vector<vector<pair<int, LL>>> g;

void dfs(int to, int from, LL c) {
    d[to] = c;
    for(auto gg : g[to]){
        int next = gg.fi;
        LL cc = gg.se;
        if(next == from) continue;
        dfs(next, to, c+cc);
    }
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    d.resize(n);
    g.resize(n);
    inc(i, 0, n-1){
        int a, b, c;cin >> a >> b >> c;
        a--;b--;
        g[a].pb({b, c});
        g[b].pb({a, c});
    }
    int q, k;cin >> q >> k;k--;
    dfs(k, -1, 0);
    inc(i, 0, q){
        int x, y;cin >> x >> y;x--;y--;
        cout << d[x]+d[y] << endl;
    }
    return 0;
}


Measured memory_bytes: 14336
def main():
    n, m = map(int, input().split())
    divisors = get_divisors(m)
    small = [d for d in divisors if d >= n][0]
    print(m // small)


def get_divisors(m):
    divisors = []
    for i in range(1, int(m ** 0.5) + 1):
        if m % i == 0:
            divisors.append(i)
            if i != m // i:
                divisors.append(m // i)
    return sorted(divisors)


main()


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

last_t, last_x, last_y = 0, 0, 0
for _ in range(n):
    t, x, y = map(int, input().split())
    remaining_time = t - last_t
    distance = abs(x - last_x) + abs(y - last_y)
    if remaining_time < distance or (remaining_time - distance) % 2:
        print('No')
        exit()
    last_t, last_x, last_y = t, x, y

print('Yes')

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

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

int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll ans = 1;
    ll limit = pow(10, 18);
    //0の確認
    rep(i, N){
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i, N){
        if(ans <= (limit / a[i])){
            ans *= a[i];
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4012
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N, M;
    cin >> N >> M;
    vector<vector<int>> table(N, vector<int>());
    for (int i = 0; i < M; i++) {
        int s, t;
        cin >>s >> t;
        s--; t--;
        table[s].push_back(t);
        table[t].push_back(s);
    }

    queue<int> que;
    que.push(0);
    vector<int> visited(N, false);
    visited[0] = true;

    vector<int> ans(N, -1);
    ans[0] = INF;

    while (!que.empty()) {
        int s = que.front();
        que.pop();
        for (int next : table[s]) {
            if (visited[next]) continue;
            ans[next] = s;
            que.push(next);
            visited[next] = true;
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i < N; i++) cout << ans[i] + 1 << endl;
    return 0;
}

Measured memory_bytes: 13620
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <sstream>
using namespace std;
typedef long long ll;


int main(){
	string s;
	cin >> s;
	long long sum = 0;
	for(int i = 0 ; i < (1<<(s.size()-1)) ; i++){
	
		string t = s;
		for(int j = s.size() - 2 ; j >= 0 ; j--){
			if( i >> j & 1 ) t.insert(t.begin() + j + 1, ' ');
		}
		stringstream ss(t);
		long long  x;
		while( ss >> x ){
			sum += x;
		}
	}
	
	cout << sum << endl;
}

Measured memory_bytes: 768
#include <stdio.h>
 
class Dice2{
public:
    Dice2(){
        number = new int[6];
        relative = new int[55];
        relative[31] = relative[43] = relative[24] = relative[12] = 0;
        relative[3] = relative[20] = relative[52] = relative[35] = 1;
        relative[1] = relative[40] = relative[54] = relative[15] = 2;
        relative[4] = relative[10] = relative[51] = relative[45] = 3;
        relative[2] = relative[30] = relative[53] = relative[25] = 4;
        relative[21] = relative[42] = relative[34] = relative[13] = 5;
    };
    ~Dice2(){
        delete[] number;
        delete[] relative;
    };
 
    void setNumber(int index,int num){
        number[index] = num;
    };
 
    int returnRight(int top,int front){
        int top_index,front_index;
        for(int i = 0; i < 6; i++){
            if(number[i] == top)
                top_index = i;
            if(number[i] == front)
                front_index = i;
        }
        return number[relative[10*top_index+front_index]];
    }
private:
    int* number;
    int* relative;
};
 
int main(){
    Dice2 dice2;
    int x,q,top,front;
    for(int i = 0; i < 6; i++){
        scanf("%d",&x);
        dice2.setNumber(i,x);
    }
    scanf("%d",&q);
    for(int i = 0; i < q; i++){
        scanf("%d %d",&top,&front);
        printf("%d\n",dice2.returnRight(top,front));
    }
}



Measured memory_bytes: 2720
#include<bits/stdc++.h>
using namespace std;
vector<array<int,3>> v;
vector<array<int,3>> dp;
int happiness(int i,int t){
    if(i<0)return 0;
    if(dp[i][t]!=0)return dp[i][t];
    if(t==0){
        dp[i][t] = max(happiness(i-1,1)+v[i][1],happiness(i-1,2)+v[i][2]);
        return dp[i][t];
    }else if(t==1){
        dp[i][t] = max(happiness(i-1,0)+v[i][0],happiness(i-1,2)+v[i][2]);
        return dp[i][t];
    }
    dp[i][t] = max(happiness(i-1,1)+v[i][1],happiness(i-1,0)+v[i][0]);
    return dp[i][t];
}
int main(){
    int n;
    cin>>n;
    v.resize(n);
    dp.resize(n,{0,0,0});
    for(int i=0;i<n;i++){
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    }
    int ans = 0;
    for(int i=0;i<3;i++){
        ans = max(ans,happiness(n-1,i));
    }
    cout<<ans<<"\n";
    return 0;
}

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

int H, W;
vector<string>S;
int bfs(int ik, int jk){
    using P = pair<int, int>;
    vector<vector<int>>flag(H, vector<int>(W, 0));
    queue<P> que;
    que.push(P(ik, jk));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][j] == '#') flag[i][j] = 1;
        }
    }
    int res = 0;
    while (true) {
        queue<P> que2;
        while (! que.empty()) {
            auto t = que.front(); que.pop();
            int it = t.first;
            int jt = t.second;
            if (flag[it][jt] == 1) continue;
            flag[it][jt] = 1;

            que2.push(P(it-1, jt));
            que2.push(P(it+1, jt));
            que2.push(P(it, jt-1));
            que2.push(P(it, jt+1));
        }
        res++;
        if (que2.empty()) break;
        while (! que2.empty()) {
            que.push(que2.front());
            que2.pop();
        }
    }
    return res - 2;
}

int main() {
    cin >> H >> W;
    H += 2; W += 2;
    S.resize(H);
    for (int i = 1; i < H-1; ++i) {
        cin >> S[i];
        S[i] = '#' + S[i] + '#';
    }
    for (int i = 0; i < W; ++i) {
        S[0] = S[0] + '#';
    }
    S[H-1] = S[0];

    int ans = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][j] == '#') continue;
            ans = max(ans, bfs(i, j));
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), F(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> F[i];

    sort(all(A));
    sort(all(F));
    reverse(all(F));

    ll l = -1, r = 1e12;
    while (r - l > 1) {
        ll c = (l + r) / 2;
        ll cnt = 0;
        rep(i, N) {
            cnt += max(0LL, A[i] - c / F[i]);
        }
        if (cnt <= K) {
            r = c;
        }
        else {
            l = c;
        }
    }

    cout << r << endl;
    return 0;
}

Measured memory_bytes: 3328
/*
   AtCoder Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    if(A + B < C * 2){
        cout << X * A + Y * B << endl;
    } else {
        int numAB = min(X, Y);
        int cost = numAB * C * 2;
        if(C * 2 > (X > Y ? A : B)){
            cost += (-1 * numAB + (X > Y ? X : Y)) * (X > Y ? A : B);
        } else {
            cost += (-1 * numAB + (X > Y ? X : Y)) * C * 2;
        }
        cout << cost << endl;
    }


    return 0;
}


Measured memory_bytes: 256
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 32


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


N, K, L = lmi()
pq = llmi(K)
rs = llmi(L)


class _UnionFind(object):
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


class UnionFind(_UnionFind):
    pass


uf_road = UnionFind(N)
for p, q in pq:
    uf_road.union(p - 1, q - 1)
uf_train = UnionFind(N)
for p, q in rs:
    uf_train.union(p - 1, q - 1)
# road_dict = collections.defaultdict(set)  # parent node -> set of member
# train_dict = collections.defaultdict(set)
# for i in range(N):
#     road_dict[uf_road.find(i)].add(i)
#     train_dict[uf_train.find(i)].add(i)
#
# print(' '.join(str(len(road_dict[uf_road.find(i)]&train_dict[uf_train.find(i)])) for i in range(N)))

d = collections.defaultdict(int)
for i in range(N):
    key = uf_road.find(i), uf_train.find(i)
    d[key] += 1

print(' '.join(str(d[(uf_road.find(i), uf_train.find(i))]) for i in range(N)))


Measured memory_bytes: 93504
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main()
{
  int n,i;cin>>n;
  static double x[100],a,y,p1,p2,p3,p4;

  for(i=0;i<n;i++)cin>>x[i];
  for(i=0;i<n;i++)cin>>y,a=abs(x[i]-y),p1+=a,p2+=a*a,p3+=a*a*a,p4=p4<a?a:p4;
  cout<<fixed<<p1<<endl<<sqrt(p2)<<endl<<cbrt(p3)<<endl<<p4<<endl;
  return 0;
}

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


#define ll          long long
#define uint        unsigned int 
#define ld          long double
#define SAM         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define mod         1000000007
#define mxn         200005
#define pb          push_back
#define pii         pair<int,int>
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define all(x)      x.begin(),x.end()

using namespace std;


int main()
{
    SAM;
    char c;
    cin>>c;
    if(c>=65 && c<=90)
        cout<<"A";
    else
        cout<<"a";
    
    return 0;
}


Measured memory_bytes: 3644
x = int(input())
if x <= 599:
    print(8)
elif x <= 799:
    print(7)
elif x <= 999:
    print(6)
elif x <= 1199:
    print(5)
elif x <= 1399:
    print(4)
elif x <= 1599:
    print(3)
elif x <= 1799:
    print(2)
elif x <= 1999:
    print(1)

Measured memory_bytes: 9176
#ABC159D
import sys, math
from collections import Counter

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

def comb(n):
    return int(math.factorial(n)/(2*math.factorial(n-2)))

total = 0
L = Counter(A)
for v in L.values():
    if v>=2:
        total += comb(v)

for k in range(N):
    print(total - (L[A[k]]-1))


Measured memory_bytes: 25920
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
 
class Program{
  static void Main(){
	var num = int.Parse(ReadLine());
    string[] subs = new string[num];
    int count =0;
    var list = new List<string>();
	
    for(var i = 0;i < num;i++){
      subs[i] = ReadLine();
    }
    var x = subs.GroupBy(a => a).Select(a => new{subject = a.Key,number = a.Count()}).ToArray();
    
    for(var i = 0;i < x.Length;i++){
    	if(x[i].number >= count){
        	count = x[i].number;
        }
    }
    
    var y = x.Where(b => b.number == count).ToArray();
 
    
    foreach(var z in y){
    	list.Add(z.subject);
    }
    
    list.Sort(StringComparer.Ordinal);
    
    foreach(var z in list){
    	WriteLine(z);
    }
    
  }
}

Measured memory_bytes: 69656
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  cin >> n >>m;
int sum;
vector<int>A(n);
for(int i = 0;i < n;i++){
  cin >> A[i];
  sum += A[i];
}
sort(A.begin(),A.end());

if(A[n-m]*4*m < sum){
  cout << "No" <<endl;
}
else{
  cout << "Yes" <<endl;
}
}


Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define jkl int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    ll n, ans = 0;
    ll a[102], b[102], c[102], d[102];
    bool rused[102];
    REP(i, 102)rused[i] = false;
    vector<pair<ll, ll>> red, blue;
    cin >> n;
    REP(i, n){
        cin >> a[i] >> b[i];
        red.push_back(make_pair(a[i], b[i]));
    }
    REP(i, n){
        cin >> c[i] >> d[i];
        blue.push_back(make_pair(c[i], d[i]));
    }
    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());
    jkl;
    ll rx, ry, bx, by;
    ll max_y, max_y_j;
    REP(i, n){
        max_y = -1;
        max_y_j = -1;
        bx = blue[i].first;
        by = blue[i].second;
        REP(j, n){
            rx = red[j].first;
            ry = red[j].second;
            if(rx > bx || ry > by || rused[j])continue;
            if(max_y > ry)continue;
            max_y = ry;
            max_y_j = j;
        }
        if(max_y_j == -1)continue;
        rused[max_y_j] = true;
        ans++;
    }
    print(ans);
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; }
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
#[warn(dead_code)]
fn sieve_of_eratosthenes(n: usize) -> Vec<usize> {
    // spf:
    // store smallest prime factor of number
    // 最小の素因数を格納
    // is_prime:
    // 配列番号が素数であるかどうかを示す
    let mut spf = vec![None; n + 1];
    let mut is_prime = vec![true; n + 1];
    let mut primes = Vec::new();

    // 0 と 1 は素数ではない
    is_prime[0] = false;
    is_prime[1] = false;

    for i in 2..n + 1 {
        // is_prime[i]:
        // それ以下の素数で割り切られていなければ True となる
        if is_prime[i] {
            // この if 文より i は素数なので
            primes.push(i);

            // 素数はそれ自身の最も小さい素因数であるから
            spf[i] = Some(i);
        }

        // 全ての prime の倍数(prime * i)を取り除く
        for prime in &primes {
            // prime が i の最も小さい因数よりも大きくなってしまったら探索終了
            if i * prime >= n + 1 || prime > &spf[i].unwrap() {
                break;
            }

            is_prime[i * prime] = false;

            // i * primes[j] の最も小さい素数は primes[j] 自身
            spf[i * prime] = Some(*prime);
        }
    }
    primes
}
use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

#[warn(unused_mut)]
#[warn(unused_imports)]
use std::collections::BTreeSet;
fn main() {
    input! { r: u64};

    println!("{}", r.pow(2));
}


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

int main()
{
    ll N, a;
    cin >> N;
    vector<pair<ll, ll>> A(N);
    rep(i, N)
    {
        cin >> a;
        A[i] = make_pair(a, i + 1);
    }
    sort(A.begin(), A.end());
    cout << A[0].second;
    rep(i, N - 1) cout << " " << A[i + 1].second;
    cout << endl;

    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};


int main(){
  int N, M;
  std::cin >> N >> M;
  std::vector<long long > C(M);
  std::vector<int > L(M), R(M);
  std::vector<std::pair<int, long long> > edge[100004];
  for (int i=0; i<M; i++) {
    std::cin >> L[i] >> R[i] >> C[i];
    L[i]--;
    R[i]--;
    edge[L[i]].push_back(std::make_pair(R[i], C[i]));
  } 
  for (int i=1; i<N; i++) {
    edge[i].push_back(std::make_pair(i-1, 0));
  }
  std::vector<long long> dist(N+4, 1e18);
  std::priority_queue<std::pair<long long, int>,
                      std::vector<std::pair<long long, int> >,
                      std::greater<std::pair<long long, int> > > queue;
  queue.push(std::make_pair(0, 0));
  while(queue.size() > 0) {
    int v = queue.top().second;
    long long d = queue.top().first;
    queue.pop();
    if (dist[v]<d) continue;
    for (auto &entry : edge[v]) {
      int vv = entry.first;
      long long dd = entry.second;
      if (dist[vv]>d+dd ) {
        dist[vv] = d+dd;
        queue.push(std::make_pair(d+dd, vv));
      }
    }
  }
  if (dist[N-1] == (long long)1e18) {
    std::cout << -1 << std::endl;
  } else {
    std::cout << dist[N-1] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 13296
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int E;
		if(A>B) {
			if(C>D) {
				E = B+D;
			}else {
				E=B+C;
			}
		}else if(C>D) {
			E=A+D;
		}else {
			E=A+C;
		}
		System.out.println(E);
	}
}


Measured memory_bytes: 23764
package main

import "fmt"

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func dist(x0, y0, x1, y1 int) int {
	return abs(x0-x1) + abs(y0-y1)
}

func main() {
	var n int
	fmt.Scan(&n)
	ts := make([]int, n+1)
	xs := make([]int, n+1)
	ys := make([]int, n+1)
	ts[0] = 0
	xs[0] = 0
	ys[0] = 0
	for i := 1; i < n+1; i++ {
		fmt.Scan(&ts[i], &xs[i], &ys[i])
	}

	for i := 0; i < n; i++ {
		dist := dist(xs[i], ys[i], xs[i+1], ys[i+1])
		dt := ts[i+1] - ts[i]
		if dist > dt || (dt-dist)%2 != 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 5504