akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
from math import ceil
from itertools import chain

def solve(N: int, K: int, V: "List[int]"):
    # i: num to pick, j: num to pick from left
    ans = -10**10
    for i in range(min(K+1, N+1)):
        max_n = min(K-i, i)
        for j in range(i+1):
            V2 = sorted(chain(V[:j], V[N-(i-j):]))
            k=0
            while True:
                if k>=max_n or V2[k]>=0:
                    break
                k+=1
            ans = max(sum(V2[k:]), ans)
    print(ans)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    V = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, V)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int n,k;
int a[200010];
int b[200010];
int main(){
	scanf("%d%d",&n,&k);
	rep(i,0,n)scanf("%d",a+i);
	rep(_,0,k){
		memset(b,0,sizeof(int)*n);
		rep(i,0,n)b[max(i-a[i],0)]++,b[min(i+a[i]+1,n)]--;
		a[0]=b[0];
		int cnt=a[0]==n;
		rep(i,1,n)a[i]=a[i-1]+b[i],cnt+=a[i]==n;
		if(cnt==n)break;
	}
	rep(i,0,n)printf("%d ",a[i]);
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct Point {
    double x, y;
};

ll n;
vector<Point> p;

double dist(Point a, Point b) {
    double dx = a.x - b.x;
    double dy = a.y - b.y;
    return sqrt(dx * dx + dy * dy);
}

double f(double x, double y) {
    double res = 0;
    rep(i, n) {
        res = max(res, dist((Point){x, y}, p[i]));
    }
    return res;
}

double g(double x) {
    double l = 0, r = 1000;
    rep(i, 80) {
        double lm = (l * 2 + r) / 3;
        double hm = (l + r * 2) / 3;
        if (f(x, lm) > f(x, hm)) l = lm;
        else r = hm;
    }
    return f(x, l);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    cin >> n;
    p = vector<Point>(n);
    rep(i, n) cin >> p[i].x >> p[i].y;
    double l = 0, r = 1000;
    rep(i, 80) {
        double lm = (l * 2 + r) / 3;
        double hm = (l + r * 2) / 3;
        if (g(lm) > g(hm)) l = lm;
        else r = hm;
    }
    double ans = g(l);
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, M; cin >> N >> M;
    vector<int> a(M, 0);
    vector<int> b(M, 0);
    for (int i = 0; i < M; ++i) cin >> a[i] >> b[i];
    for (int i = 1; i <= N; ++i) {
        int cnt = 0;
        for (int j = 0; j < M; ++j) {
            if (i == a[j]) cnt++;
            if (i == b[j]) cnt++;
        }
        printf("%d\n", cnt);
    }
}


Measured memory_bytes: 3724
function Main(input)
{
	input = input.split("\n");

	var i = input[1].substring(0, input[1].length - 1);
	if (input[0] == i)
	{
		console.log("Yes");
	}else{
		console.log("No");
	}

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29504
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    ll x[n], y[n];
    vector<ll> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        vec[i] = x[i];
    }
    ll ret = -1;
    sort(vec.begin(), vec.end());
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            ll H = max(y[i], y[j]);
            ll h = min(y[i], y[j]);
            int first = 0;
            int last = 1;
            while (last < n) {
                int count = 0;
                for (int k = 0; k < n; k++) {
                    if ((h <= y[k])&&(y[k] <= H)&&(vec[first] <= x[k])&&(x[k] <= vec[last])) count++;
                }
                if (count >= k) {
                    if ((ret == -1)||(ret > (H - h) * (vec[last] - vec[first]))) ret = (H - h) * (vec[last] - vec[first]);
                    first++;
                }
                else {
                    last++;
                }
            }
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3588
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	d = readline() |> split |> parseMap
	m = readline() |> parseInt
	t = readline() |> split |> parseMap
	d = sort(d)
	t = sort(t)
	l = 1
	r = 1
	while l <= n && r <= m
		if d[l] == t[r]
			l += 1
			r += 1
		elseif d[l] < t[r]
			l += 1
		else
			break
		end
	end
	println(r>m?"YES":"NO")
end

main()


Measured memory_bytes: 141056
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main()
{
    long long h, w, x, y;
    cin >> w >> h >> x >> y;
    long double ans = (h * w) / 2.0;
    if ((w % 2 == 0) && (h % 2 == 0) && (x == w / 2) && (y == h / 2))
    {
        cout << setprecision(17) << ans << " " << 1 << endl;
    }
    else
    {
        cout << setprecision(17) << ans << " " << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
//#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);

ll n;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("meetings.in", "r", stdin);
	//freopen("meetings.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	if (n & ll(1))
	{
		cout << 0;
		return 0;
	}
	ll res = 0;
	ll x = n;
	while (x)
	{
		x /= 5;
		res += x - (x / 2);
		if (x & 1)
			res--;
	}
	
	cout << res;
	return 0;
}

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

#define int long long 

int32_t main() {
    int n, x, y; cin >> n >> x >> y;
    int dist_cnt[n] = {0};
    for (int i = 1; i < n; i++) {
        for (int j = i+1; j <= n; j++) {
            int dist = j - i;
            int curr = 0;
            if (i == y) {
                curr += 1;
            } else {
                curr += abs(x - i);
            }

            curr += 1;

            if (j == x) {
                curr += 1;
            } else {
                curr += abs(y - j);
            }

            dist = min(dist, curr);

            curr = 0;

            if (i == y) {
                curr += 1;
            } else {
                curr += abs(i - x);
            }

            if (j == y) {
                curr += 1;
            } else {
                curr += abs(j - x);
            }

            dist = min(dist, curr);


            curr = 0;

            if (i == x) {
                curr += 1;
            } else {
                curr += abs(i - y);
            }

            curr += 1;

            if (j == y) {
                curr += 1;
            } else {
                curr += (j - x);
            }

            dist = min(dist, curr);

            curr = 0;

            if (i == x) {
                curr += 1;
            } else {
                curr += abs(i - y);
            }

            if (j == x) {
                curr += 1;
            } else {
                curr += abs(j - y);
            }


            dist = min(dist, curr);

            dist_cnt[dist]++;


        }
    }
    for (int k = 1; k <= n-1; k++) {
        cout << dist_cnt[k] << endl;
    }
}

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

int max(int a, int b){
    if(a>b){
        return a;
    }else{
        return b;
    }
}

int main()
{
    int a,b;
    cin >> a >> b;
    cout << max(max(a+b,a-b),a*b) <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define ll long long int
#define vi vector<ll>
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define iiii pair<ii,ii>
#define pb push_back
#define fi first
#define se second
using namespace std;
int t;
int coin[10] = {500,100,50,10,5,1};
int dp(int n){
	cout<<n<<"\n";
	if(n<=0) return 0;
	int maxi = 0;
	for(int i = 0;i<6;i++){
//		cout<<coin[i]<<"c\n";
		if(coin[i] <= n){
			maxi = max(maxi,
			dp(n-coin[i]) + (coin[i] == 500 ? 1000 : coin[i] == 5 ? 5 : 0));
//			cout<<maxi<<"maxi\n";
		}
	}
//	if(!maxi) return 0;
	return maxi;
}
int main(){
	int n;
	ios::sync_with_stdio(0), cin.tie(0);
	cin>>n;
	int ans = 0;
	ans = n/500 * 1000 + (n%500)/5 * 5;
	cout<<ans  <<"\n";
	return 0;
}

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

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

    sort(A, A+N);

    int ans;
    long tmp;
    bool flag;
    tmp=-1;
    ans=0;
    flag=true;
    if(N==1){
        ans=1;
    }else{
        for(int i=0; i<N; i++){
            if( tmp!=A[i] || flag ){
                tmp=A[i];
                if( ( i<N-1 && tmp!=A[i+1] ) || i == N-1 ){
                    ans++;
                }else{
                    flag=false;
                }
            }else{
                flag=true;
                continue;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        kind = [10, 50, 100, 500]
        first = True
        while True:            
            payment = input()
            if payment == 0:
                break
            p = map(int, raw_input().split())

            change = sum(i * j for i, j in zip(kind, p)) - payment
            c = [0 for i in range(4)]
            tmp = change
            for i in reversed(range(4)):
                c[i] = tmp / kind[i]
                tmp %= kind[i]
            ans = [max(0, i - j) for i, j in zip(p, c)]
            if first:
                first = False
            else:
                print
            for i in range(4):
                if ans[i] == 0:
                    continue
                print str(kind[i]) + ' ' + str(ans[i])
        
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

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

int main(){
   long long a,b,c,d;
   cin>>a>>b>>c>>d;
   for(long long i=1;i<1000;i++){
       if(c<=b*i){
           cout<<"Yes"<<endl;
           break;
       }
       if(a<=d*i){
           cout<<"No"<<endl;
           break;
       }
   }
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i )
#define drep( i, s, t ) for( register int i = (t); i >= (s); -- i )
#define re register
#define int long long
#define ls(x) tr[x].l
#define rs(x) tr[x].r
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int P = 1e9 + 7 ; 
const int N = 2e5 + 5 ; 
int n, m, cnt, num, Rt, M, lef[N], ref[N], dp[N] ;
struct node { int p, f ; } a[N << 1] ;
struct Px { int x, y ; } c[N] ; 
bool cmp( node x, node y ) { return x.p < y.p ; }
bool cmp2( Px a, Px b ) { return ( a.x == b.x ) ? ( a.y > b.y ) : a.x < b.x ; }
struct Tr { int l, r, w ; } tr[N * 20] ;
void insert( int &x, int l, int r, int wh, int val ) {
	if( !x ) x = ++ num ; tr[x].w += val, tr[x].w %= P ; 
	if( l == r ) return ; 
	int mid = ( l + r ) >> 1 ; 
	if( mid >= wh ) insert( ls(x), l, mid, wh, val ) ;
	else insert( rs(x), mid + 1, r, wh, val ) ;
}
int query( int x, int l, int r, int wh ) {
	if( l == r ) return tr[x].w ; 
	int mid = ( l + r ) >> 1 ; 
	if( mid >= wh ) return query( ls(x), l, mid, wh ) ;
	else return ( query( rs(x), mid + 1, r, wh ) + tr[ls(x)].w ) % P ; 
}
signed main()
{
	n = gi(), m = gi() ; int maxn = 0 ;
	rep( i, 1, n ) a[i].p = gi(), maxn = max( maxn, a[i].p ), a[i].f = 1 ; 
	rep( i, 1, m ) a[i + n].p = gi(), maxn = max( maxn, a[i + n].p ) ; 
	M = n + m, ++ maxn ; 
	sort( a + 1, a + M + 1, cmp ) ;
	rep( i, 1, M ) lef[i] = ( a[i].f ) ? lef[i - 1] : a[i].p ; 
	drep( i, 1, M ) ref[i] = ( a[i].f ) ? ref[i + 1] : a[i].p ; 
	rep( i, 1, M ) {
		if( (!lef[i]) || (!ref[i]) || (!a[i].f) ) continue ; 
		++ cnt, c[cnt].x = a[i].p - lef[i], c[cnt].y = ref[i] - a[i].p ; 
	}
	sort( c + 1, c + cnt + 1, cmp2 ) ; int Ans = 1 ; 
	rep( i, 1, cnt ) {	
		if( c[i].x == c[i - 1].x && c[i].y == c[i - 1].y ) continue ; 
		dp[i] = 1 + query( 1, 1, maxn, c[i].y + 1 ) ;
		insert( Rt, 1, maxn, c[i].y + 2, dp[i] ) ;
		Ans = ( Ans + dp[i] ) % P ; 
	}
	cout << Ans << endl ; 
	return 0 ;
}

Measured memory_bytes: 43776
import sys
M, D = map(int, input().split())

if D < 10:
    print("0")
    sys.exit()

ans = 0
for m in range(1, M+1):
    for i in range(10, D+1):
        j = int(i / 10)
        k = i % 10
        if (j > 1 and k > 1 and j*k == m):
            # print(m, i, j, k)
            ans += 1
print(ans)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    String[] sl = s.split("[\\s]+");
    long a = Long.parseLong(sl[0]);
    long b = Long.parseLong(sl[1]);
    if (b < a)
    {
      long t = a;
      a = b;
      b = t;
    }
    
    if(a == 1)
    System.out.println(b == 1 ? 1 : b - 2);
    else if(a == 2)
      System.out.println(0);
    else
      System.out.println((a - 2) * (b - 2));
  }
  
}

Measured memory_bytes: 21460
#include <iostream>
#include<bits/stdc++.h>
#include<cmath>
#include <algorithm> 
#include <unordered_map>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	if (t >= 30) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3648
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<cctype>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using std::min;
using std::max;
using std::swap;
using std::vector;
const int M=2005;
const int N=200005;
const int ZYZ=1e9+7;
typedef double db;
typedef long long ll;
#define pb(A) push_back(A)
#define pii std::pair<int,int>
#define all(A) A.begin(),A.end()
#define mp(A,B) std::make_pair(A,B)

int n,a[N],b[N];
int f[M<<1][M<<1];
int fac[M<<2],ifac[M<<2];

int getint(){
    int X=0,w=0;char ch=0;
    while(!isdigit(ch))w|=ch=='-',ch=getchar();
    while( isdigit(ch))X=X*10+ch-48,ch=getchar();
    if(w) return -X;return X;
}

int ksm(int a,int b,int ans=1){
    while(b){
        if(b&1) ans=1ll*ans*a%ZYZ;
        a=1ll*a*a%ZYZ;b>>=1;
    }return ans;
}

void init(int n){
    fac[0]=ifac[0]=1;
    for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%ZYZ;
    ifac[n]=ksm(fac[n],ZYZ-2);
    for(int i=n-1;i;i--) ifac[i]=1ll*ifac[i+1]*(i+1)%ZYZ;
}

int C(int n,int m){
    return 1ll*fac[n]*ifac[m]%ZYZ*ifac[n-m]%ZYZ;
}

signed main(){
    init(8000);
    n=getint();
    for(int i=1;i<=n;i++){
        a[i]=getint(),b[i]=getint();
        f[2001-a[i]][2001-b[i]]++;
    }
    for(int i=1;i<=4001;i++)
        for(int j=1;j<=4001;j++)
            f[i][j]=(1ll*f[i][j]+f[i-1][j]+f[i][j-1])%ZYZ;
    int ans=0;
    for(int i=1;i<=n;i++) ans=(ans+f[a[i]+2001][b[i]+2001])%ZYZ;
    for(int i=1;i<=n;i++) ans=(ans-C(a[i]+b[i]<<1,b[i]<<1)+ZYZ)%ZYZ;
    printf("%lld\n",1ll*ans*ksm(2,ZYZ-2)%ZYZ);
    return 0;
}

Measured memory_bytes: 64640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N, M, A[2020], B[2020];
vector<int> E[1010];
bool vis[1010];
int dist[1010], back[1010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    int mi = inf;
    vector<int> ans;
    rep(er, 0, M)
    {
        rep(i, 0, N) E[i].clear();
        rep(i, 0, M) if (er != i) E[A[i]].push_back(B[i]);
        int st = A[er];
        int gr = B[er];

        rep(i, 0, N) {
            vis[i] = false;
            dist[i] = 0;
        }

        queue<int> que;
        que.push(gr);
        vis[gr] = true;
        dist[gr] = 0;

        while(!que.empty()) {
            int cu = que.front();
            que.pop();
            fore(to, E[cu]) if(!vis[to]) {
                vis[to] = true;
                dist[to] = dist[cu] + 1;
                back[to] = cu;
                que.push(to);
            }
        }

        if (!vis[st]) continue;

        int len = dist[st] + 1;
        if (chmin(mi, len)) {
            ans.clear();

            int x = st;
            while(x != gr) {
                ans.push_back(x);
                x = back[x];
            }
            ans.push_back(gr);
        }
    }

    if (mi == inf) {
        cout << -1 << endl;
        return;
    }

    sort(all(ans));

    int K = ans.size();
    printf("%d\n", K);
    fore(i, ans) printf("%d\n", i + 1);
}



Measured memory_bytes: 384
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離

N,M = imn()

if N == M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 5300
#include<stdio.h>
int main(){
    int i=0, y;
    
    int array[10000]={0};
    
     while(i<10000){
         scanf("%d",&array[i]);
         if(array[i]==0) break;
         i++;
     } 
     
     for(y=0; y<i; y++){
		printf("Case %d: %d\n",y+1,array[y]);
     }
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  int ans = B + min((A + B), C) + 1;
  if ((A + B) < C) {
    ans = B + (A + B) + 1;
  } else {
    ans = B + C;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
N, M = map(int, input().split())

x_array = np.array([0] * M)
max_array = np.array([1] * N)

# print(max_array)

py_array = np.array([list(map(int, input().split())) for i in range(M)])

sorted_index = np.argsort(py_array[:, 1])
# print(sorted_index)

for i in sorted_index:
    x_array[i] = max_array[py_array[i][0] - 1]
    max_array[py_array[i][0] - 1] += 1

for x, py in zip(x_array, py_array):
    ans = str(py[0]).zfill(6) + str(x).zfill(6)
    print(ans)

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

using namespace std;
typedef long long int ll;

const int MAX = 1e5 + 10;

int main()
{
    int n; cin>>n;
    map<string,int> m;
    ll ans=0;
    for(int i=0;i<n;i++){
        string a;
        cin>>a;
        sort(a.begin(),a.end());
        if(m[a]){
            ans += m[a];
            m[a]++;
        }
        else m[a]=1;
    }
    cout<<ans;
}

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

using namespace std;

const int N = 3e3 + 3;
string s1, s2;

int n, m, ans, mx = 0;
int mem[N][N];
vector<char> v;
int solve(int i, int j)
{
	if(i >= n || j >= m)
	{
		return 0;
	}
	if(mem[i][j] != -1)	return mem[i][j];
	int opt1 = solve(i + 1, j);
	int opt2 = solve(i, j + 1);
	int opt3 = s1[i] == s2[j] ? solve(i + 1, j + 1) + 1 : 0;
	return mem[i][j] = max(opt1, max(opt2, opt3));
}
void trace(int i, int j)
{
	if(i >= n || j >= m)	return;
	
	int opt1 = solve(i + 1, j);
	int opt2 = solve(i, j + 1);
	int opt3 = s1[i] == s2[j] ? solve(i + 1, j + 1) + 1 : 0;
	
	if(opt3 > opt2 && opt3 > opt2)
	{
		cout << s1[i];
		trace(i + 1, j + 1);
		return;
	}
	else if(opt2 > opt1)
		trace(i, j + 1);
	else
		trace(i + 1, j);
	
}
int main()
{
	memset(mem, -1, sizeof mem);
	cin >> s1 >> s2;
	n = s1.size();
	m = s2.size();
	solve(0, 0);
	trace(0, 0);
	return 0;
}

Measured memory_bytes: 36096
sx, sy, tx, ty = map(int, input().split())
x = tx-sx
y = ty-sy
print('U'*y+'R'*x+'D'*y+'L'*(x+1)+'U'*(y+1)+'R'*(x+1)+'DR'+'D'*(y+1)+'L'*(x+1)+'U')


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

using namespace std;

int main() {
    int N;
    cin >> N;
    int c = 0;
    vector<int> v(N);
    for (auto& x: v) cin >> x;
    for (int i = 0; i < N; i++) {
        int mi = i;
        for (int j = i; j < N; j++) {
            if (v[j] < v[mi]) mi = j;
        }
        if (i != mi) {
            c++;
            swap(v[mi], v[i]);
        }
    }
    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << v[i];
    }
    cout << endl << c << endl;
}



Measured memory_bytes: 3120
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define DEBUG
#ifdef DEBUG
    #define IFD(...) __VA_ARGS__
    #define IFN(...)
    #define L cout<<__LINE__<<"\n";
    #define PRINT(...) __VA_ARGS__ cout<<__LINE__<" : "<<#__VA_ARGS__<<"\n"
    #define PRT(x) cout<<__LINE__<<" : "<<#x<<" = "<<x<<"\n"
#else // DEBUG
    #define IFD(...)
    #define IFN(...) __VA_ARGS__
    #define L
    #define PRINT(...) __VA_ARGS__
    #define PRT(x)
#endif // DEBUG

#define it iterator
#define rit reverse_iterator
#define mp make_pair
#define mems(a,b) memset(a,b,sizeof(a))
#define mem0(a) mems(a,0)
#define mem1(a) mems(a,1)
#define mem255(a) mems(a,255)
#define halt exit(0)
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front
#define fort0(i,a,b) for(ll i=a,i##_TO=b;i<i##_TO;i++)
#define for0(i,n) fort0(i,0,n)
#define fort1(i,a,b) for(ll i=a,i##_TO=b;i<=i##_TO;i++)
#define for1(i,n) fort1(i,1,n)
#define ford(i,a,b) for(ll i=a,i##_TO=b;i>=i##_TO;i--)

using namespace __gnu_pbds;
using namespace std;

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

const int N=1e5+100;

int p[N];

int par[N];

void init(int n)
{
  for(int i=1;i<=n;i++)
    par[i]=i;
}

int get(int x)
{
  return x==par[x]?x:par[x]=get(par[x]);
}

void un(int x,int y)
{
  x=get(x),y=get(y);
  if(x==y)
    return;
  if(rand()%2)
    par[x]=y;
  else
    par[y]=x;
}

signed main()
{
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++)
    cin>>p[i];
  init(n);
  while(m--)
  {
    int x,y;
    cin>>x>>y;
    un(x,y);
  }
  int ans=0;
  for(int i=1;i<=n;i++)
    ans+=get(i)==get(p[i]);
  cout<<ans;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define simplify ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

const int N = 1e7 + 5;
int ans[N];
int result=0;
void sieve(int n) {

    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j+=i){
            ans[j]++;
        }
        result+=ans[i]*i;
    }
    cout<<result<<endl;

}


int32_t main() {

    simplify
    int n;
    cin >> n;
    sieve(n);


    return 0;
}



Measured memory_bytes: 81736
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var nums = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var dic = new Dictionary<int, int>();
        for (var i = 0; i < num; i++)
        {
            for (var j = -1; j <= 1; j++)
            {
                if (dic.ContainsKey(nums[i] + j)) dic[nums[i] + j]++;
                else dic[nums[i] + j] = 1;
            }
        }
        WriteLine(dic.Values.Max());
    }
}


Measured memory_bytes: 23136
#include "bits/stdc++.h"
using namespace std;

int main() {
    int N,H,max=0,count=0;
    cin >> N;
    for(int i=0;i<N;i++){
      cin >> H;
      if(H>=max){
        max=H;
        count++;
      }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	s := getNextString(scanner)
	cc := makeGrid(9, 9)
	for i := 0; i < n-1; i++ {
		cc[s[i]-'0'-1][s[i+1]-'0'-1]++
	}
	p := make(permutation, 9)
	ans := make([]int, 9)
	p.dfs(0, 9, 0, ans, cc)
	for i := 0; i < 9; i++ {
		fmt.Fprint(writer, ans[i]+1)
		if i%3 == 2 {
			fmt.Fprintln(writer, "")
		}
	}
}
func makeGrid(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

var min int = math.MaxInt32

type permutation []int

func (p permutation) dfs(i, n int, used uint32, ans []int, cc [][]int) {
	if i == n {
		sum := getsum(p, cc)
		if min > sum {
			for i := 0; i < 9; i++ {
				ans[i] = p[i]
			}
			min = sum
		}
		return
	}
	for b := 0; b < 9; b++ {
		if used&(1<<uint(b)) != 0 {
			continue
		}
		p[i] = b
		p.dfs(i+1, n, used|(1<<uint(b)), ans, cc)
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func getsum(p permutation, cc [][]int) int {
	sum := 0
	for i := 0; i < 9; i++ {
		for j := 0; j < 9; j++ {
			if i == j {
				continue
			}
			sum += (abs(i/3-j/3) + abs(i%3-j%3)) * cc[p[i]][p[j]]
		}
	}
	return sum
}



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

#define int long long int
#define mp make_pair
using namespace std;

int n,k;
vector <int> v(102),w(102);
int dp[102][100002];

int fun(int pos , int value)
{
    if(value == 0){
        return 0;
    }
    if(value < 0){
        return 1e15;
    }
    if(pos == n){
        return 1e15;
    }
    if(dp[pos][value] != -1){
        return dp[pos][value];
    }
    dp[pos][value] = min(fun(pos + 1 , value) , w[pos] + fun(pos + 1 , value - v[pos]));
    return dp[pos][value];
}

int32_t main() {
    scanf("%lld", &n);
    scanf("%lld", &k);
    for (int i = 0; i < n; ++i) {
        scanf("%lld", &w[i]);
        scanf("%lld", &v[i]);
    }
    for (int i = 0; i < 102; ++i) {
        for (int j = 0; j < 100002; ++j) {
            dp[i][j] = -1;
        }
    }
    int ans= 0 ;
    for (int i = 1; i <= 100000; ++i) {
        int ans1 = fun(0 ,i);
        if(ans1 <= k){
            ans = i;
        }
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 80000
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] d = new int[10];


		for(int i = 0;i < k;i++){
			d[sc.nextInt()]++;
		}


		for(int i = n;i <= 100000;i++){
			if(judge(i,d)){
				System.out.println(i);
				return;
			}
		}



	}
	static boolean judge(int num,int[] d){

		int keta = String.valueOf(num).length();
		int waru = (int)Math.pow(10, keta-1);
		for(int i = 0;i < keta;i++){
			int value = num/waru;
			if(d[value] > 0){
				return false;				//一つでもnumのなかに嫌な数値があったらfalse
			}
			num -= value*waru;				//桁を一つずつ落としていく
			waru /= 10;
		}
		return true;





	}
}

Measured memory_bytes: 24276
from collections import deque
h, w = map(int, input().split())
A = [input() for _ in range(h)]
dist = [[-1]*w for _ in range(h)]
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
que = deque()
for i in range(h):
  for j in range(w):
    if A[i][j] == "#":
      que.append((i, j))
      dist[i][j] = 0
while que:
  y, x = que.popleft()
  for dy, dx in zip(di, dj):
    ny, nx = y+dy, x+dx
    if ny < 0 or ny >= h or nx < 0 or nx >= w:
      continue
    if dist[ny][nx] != -1:
      continue
    dist[ny][nx] = dist[y][x] + 1
    que.append((ny, nx))
ans = 0
for i in dist:
  ans = max(ans, max(i))
print(ans)

Measured memory_bytes: 87644
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		if(X2 < X1){
			X1 *= -1;
			X2 *= -1;
			for(int i=0;i<N;i++) X[i] *= -1;
		}
		if(Y2 < Y1){
			Y1 *= -1;
			Y2 *= -1;
			for(int i=0;i<N;i++) Y[i] *= -1;
		}
		
		X2 -= X1;
		for(int i=0;i<N;i++) X[i] -= X1;
		
		Y2 -= Y1;
		for(int i=0;i<N;i++) Y[i] -= Y1;
		
		var L = new List<Pair>();
		int c = 0;
		for(int i=0;i<N;i++){
			if(InRange(X[i],0,X2) && InRange(Y[i],0,Y2)){
				L.Add(new Pair(X[i],Y[i],c));
				c++;
			}
		}
		
		L.Sort((p,q) => {
			var xc = p.X.CompareTo(q.X);
			return xc == 0 ? p.Y.CompareTo(q.Y) : xc;
		});
		
		int[] dp,route;
		int[] ys = L.Select(p => (int)p.Y).ToArray();
		LIS(ys, out dp, out route);

		int max = 0;
		for(int i=1;i<dp.Length;i++){
			if(dp[i] != int.MaxValue) max = i;
		}
		
		double ans = 100.0 * ((double) X2 + (double) Y2);
		if(max < (int)Math.Min(X2,Y2) + 1){
			ans -= max * 20;
			ans += 0.5 * Math.PI * 10 * max;
			Console.WriteLine(ans);
			return;
		}
		
		max--;
		ans -= max * 20;
		ans += 0.5 * Math.PI * 10 * max;
		ans -= 20;
		ans += Math.PI * 10;
		Console.WriteLine(ans);
	}
	
	void LIS(int[] a, out int[] dp, out int[] route){
		
		int n = a.Length;
		dp = new int[n+1];
		int[] dp2 = new int[n+1];
		route = new int[n];
		dp[0] = int.MinValue;
		dp2[0] = -1;
		for(int i=1;i<=n;i++){
			dp[i] = int.MaxValue;
			dp2[i] = -1;
		}
		
		for(int i=0;i<n;i++){
			int l = 0;
			int r = n + 1;
			while(r - l > 1){
				int c = (l + r) / 2;
				if(dp[c] < a[i]){
					l = c;
				} else {
					r = c;
				}
			}
			dp[r] = a[i];
			dp2[r] = i;
			route[i] = dp2[l];
		}
	}
	
	
	bool InRange(long t, long l, long r){
		return l <= t && t <= r;
	}
	
	class Pair{
		public long X;
		public long Y;
		public int Idx;
		public Pair(long x, long y, int idx){
			X = x; Y = y; Idx = idx;
		}
	}
	
	
	long X1,Y1,X2,Y2;
	int N;
	long[] X,Y;
	public Sol(){
		
		var  d = rla();
		X1 = d[0]; Y1 = d[1]; X2 = d[2]; Y2 = d[3];
		N = ri();
		X = new long[N];
		Y = new long[N];
		for(int i=0;i<N;i++){
			d = rla();
			X[i] = d[0]; Y[i] = d[1];
		}
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 35908
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public int[,] F;
        public int[,] P;
        public int M = 10;
        public void Run()
        {

            N = Input.ReadInt();
            F = new int[N,M];
            P = new int[N, M + 1];
            {
                for (int i = 0; i < N; i++)
                {
                    var line = Input.ReadIntArray();
                    for (int m = 0; m < M; m++)
                    {
                        F[i, m] = line[m];
                    }
                }

                for (int i = 0; i < N; i++)
                {
                    var line = Input.ReadIntArray();
                    for (int m = 0; m <= M; m++)
                    {
                        P[i, m] = line[m];
                    }
                }
            }

            int B = 1 << M;
            int ret = int.MinValue;
            for (int b = 1; b < B; b++)
            {
                ret = Math.Max(Calc(b), ret);
            }

            Console.WriteLine(ret);
        }

        public int Calc(int b)
        {
            var count = new int[N];

            for (int m = 0; m < M; m++)
            {
                bool open = ((b >> m) & 1) == 1;
                if(open)
                for (int i = 0; i < N; i++)
                {
                    count[i] += F[i, m];
                }
            }

            int ret = 0;

            for (int i = 0; i < N; i++)
            {
                ret += P[i, count[i]];
            }

            return ret;
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define ranger(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define repr(i, b) for (int i = (b) - 1; i >= 0; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S>& p) {
	os << '(' << p.first << ',' << p.second << ')';
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

template<typename T>
class CumulativeSum {
	vector<T> a;
	public:
	CumulativeSum(vector<T>& x) : a(x.size() + 1,0) {
		rep(i,x.size()){
			a[i + 1] = a[i] + x[i];
		}
	}
	T get(int l, int r){ // [l, r]の区間の合計を求める
		return a[r + 1] - a[l];
	}
	T operator [] (const int i) const {
		return a[i];
	}
};

bool isOk(int mid, int m, vector<int>& a){
	int sum = 0;
	rep(i,a.size()){
		sum += distance(lower_bound(all(a), mid - a[i]), a.end());
	}
	return sum >= m;
}

int diff(int mid, int m, vector<int>& a){
	int sum = 0;
	rep(i,a.size()){
		sum += distance(lower_bound(all(a), mid - a[i]), a.end());
	}
	return sum - m;
}

signed main() {
	int n,m;
	cin>>n>>m;
	vector<int> a(n);
	cin >> a;

	sort(all(a));
	CumulativeSum<int> s(a);

	int ok = -1, ng = 1e18;
	rep(i,100){
		int mid = (ok + ng) / 2;
		if(isOk(mid, m, a)) ok = mid;
		else ng = mid;
	}

	int sum = 0;
	for(int i = n - 1; i >= 0; i--){
		int dis = distance(lower_bound(all(a), ok - a[i]), a.end());
		sum += dis * a[i];
		sum += s.get(n - dis, n - 1);
	}
	cout << sum - diff(ok, m, a) * ok  << endl;
}


Measured memory_bytes: 1792
a,b,=map(int,input().split())
def c(a, b):
    if a==2 and b==2:
        return True
    s = {4,6,9,11}
    if a in s and b in s:
        return True
    s = {1,3,5,7,8,10,12}
    if a in s and b in s:
        return True
    return False
print('Yes' if c(a,b) else 'No')

Measured memory_bytes: 3064
N=int(input())
P=list(map(int,input().split()))
Q=[]

for i in range(N):
  Q.append(1 if P[i]==i+1 else 0)
#print(Q)

cnt=0
ans=0
for i in range(N):
  if Q[i]==1:
    cnt+=1
  else:
    ans+=cnt%2+cnt//2
    cnt=0
  if i==N-1:
    ans+=cnt%2+cnt//2  
print(ans)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif


int main(){
  ll n,m; scanf("%lld%lld",&n,&m);
  ll ans=0;
  if(m>=2*n){
    ans=n; m-=2*n;
    ans+=m/4;
  }else ans=m/2;
  printf("%lld\n",ans);  
  return 0;
}


Measured memory_bytes: 256
h1, m1, h2, m2, k = map(int, input().split())

h1 *= 60
h2 *= 60
su = h1 + m1
sl = h2 + m2

ans = 0
if sl < su:
    ans = su + 1440 - sl
else:
    ans = sl - su

if ans < 0:
    print(0)
else:
    print(max(ans - k, 0))

Measured memory_bytes: 9192
import java.util.*;

public class Main {
  // inner classes

  static class Icicle implements Comparable<Icicle> {
    int t, i;

    Icicle(int t, int i) {
      this.t = t;
      this.i = i;
    }

    public int compareTo(Icicle ic) {
      return this.t - ic.t;
    }
  }

  // main
  public static final void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int l = sc.nextInt();

    int[] tis = new int[n];
    for (int i = 0; i < n; i++)
      tis[i] = sc.nextInt();

    PriorityQueue<Icicle> q = new PriorityQueue<Icicle>();
    boolean[] broken = new boolean[n];
    Arrays.fill(broken, false);

    for (int i = 0; i < n; i++)
      if ((i == 0 || tis[i] > tis[i - 1]) &&
          (i == n - 1 || tis[i] > tis[i + 1])) {
        q.add(new Icicle(l - tis[i], i));
        broken[i] = true;
      }

    int time = 0;

    while (! q.isEmpty()) {
      Icicle ic0 = q.poll();
      //System.out.println("t=" + ic0.t + ",i=" + ic0.i);

      time = ic0.t;
      tis[ic0.i] = 0;

      if (ic0.i > 0) {
        int i1 = ic0.i - 1;
        if (! broken[i1] &&
            (i1 == 0 || tis[i1] > tis[i1 - 1])) {
          q.add(new Icicle(time + l - tis[i1], i1));
          broken[i1] = true;
        }
      }

      if (ic0.i < n - 1) {
        int i2 = ic0.i + 1;
        if (! broken[i2] &&
            (i2 == n - 1 || tis[i2] > tis[i2 + 1])) {
          q.add(new Icicle(time + l - tis[i2], i2));
          broken[i2] = true;
        }
      }
    }

    System.out.println(time);
  }
}

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

int main() {
  int a,b,c,d,bmin,tmin,sum = 0;
  cin >> a >> b >> c >>d;
  bmin = min(a,b);
  tmin = min(c,d);
  sum = bmin + tmin;
  cout << sum << endl;
  return 0;
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,c,k;
    cin>>n>>c>>k;
    vl T(n);
    rep(i,n)cin>>T[i];
    Squeue Q;
    rep(i,n)Q.push(T[i]);
    ll res=0;
    while(!Q.empty()){
        ll t=Q.top()+k;
        res++;
        rep(i,c){
            if(Q.empty())break;
            ll f=Q.top();
            if(f>t||f+k<t)break;
            Q.pop();
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 5072
def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(4, n + 1, 2):
        sieve[i] = 2
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i * 2):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


def prime_factorize(n):
    result = []
    while n != 1:
        p = prime_table[n]
        e = 0
        while n % p == 0:
            n //= p
            e += 1
        result.append((p, e))
    return result


N = int(input())
A = list(map(int, input().split()))

m = 1000000007

prime_table = make_prime_table(10 ** 6)

lcm_factors = {}
for a in A:
    for p, e in prime_factorize(a):
        if p not in lcm_factors or lcm_factors[p] < e:
            lcm_factors[p] = e

lcm = 1
for p in lcm_factors:
    lcm *= pow(p, lcm_factors[p], m)
    lcm %= m

result = 0
for i in range(N):
    result += lcm * pow(A[i], m - 2, m)
    result %= m
print(result)


Measured memory_bytes: 49568