akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
using namespace std;

#define i64 long long int
#define ran 101101

int n, W;
i64 dp[ran];

int main() {
	scanf("%d%d", &n, &W);
	dp[0] = 0;
	for(int i=0;i<n;i++) {
		int w, v;
		scanf("%d%d", &w, &v);
		for(int j=W-w; j>=0; j--)
			dp[j+w] = max(dp[j+w], dp[j]+v);
	}
	i64 ans = 0;
	for(int i=0;i<=W;i++)
		ans = max(ans, dp[i]);
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<int, int>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define PI acos(-1.0)
using namespace std;
int n;
double a[3030], Dp[3030][3030];

double Solve(int i, int H)
{
    if (i == n){
        if (H > n-H) return 1.0;
        return 0.0;
    }

    double &ret = Dp[i][H];
    if (ret != 2) return ret;

    double C1 = Solve(i+1, H + 1)   * a[i];
    double C2 = Solve(i+1, H)       * (1.00 - a[i]);

    return ret = C1 + C2;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    for (int i=0 ; i<3000; i++)
        for (int j =0; j<3000; j++)
            Dp[i][j] = 2.0;

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

    double Answer = Solve(0, 0);

    cout << fixed << setprecision(10) << Answer << '\n';
    return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int32 N;
vector<int64> A;
vector<int32> G[5050];
vector<int32> sz;
vector<vector<int64>> dp[2];

void init(int32 v, int32 p){
	REP(i, G[v].size()){
		if(G[v][i] == p) continue;
		init(G[v][i], v);
		sz[v] += sz[G[v][i]];
	}
}

void dfs(int32 v, int32 p){
	REP(i, G[v].size()){
		if(G[v][i] == p) continue;
		dfs(G[v][i], v);
	}
	vector<vector<int64>> dp2(2, vector<int64>(N+1, INF_LL));
	if(A[v] > 0)
		dp2[0][0] = A[v];
	dp2[1][0] = A[v];
	int32 now = 1;
	REP(i, G[v].size()){
		if(G[v][i] == p) continue;
		vector<vector<int64>> dp3(2, vector<int64>(N+1, INF_LL));
		int32 u = G[v][i];
		REP(l, 2){
			if(l == 0 && A[v] < 0) continue;
			REP(j, sz[G[v][i]]){
				REP(k, now){
					if(dp[0][u][j] != INF_LL)
						chmin(dp3[l][k+j], dp2[l][k]+dp[0][u][j]);
					if(dp[1][u][j] != INF_LL)
						chmin(dp3[l|1][k+j], dp2[l][k]+dp[1][u][j]);
					if(dp[1][u][j] < 0)
						chmin(dp3[l][k+j+1], dp2[l][k]);
					if(dp[0][u][j] != INF_LL){
						chmin(dp3[l][k+j+1], dp2[l][k]);
					}
				}
			}
		}
		swap(dp2, dp3);
		now += sz[u];
	}
	REP(i, sz[v]){
		dp[0][v][i] = dp2[0][i];
		dp[1][v][i] = dp2[1][i];
	}
}

int main(void){
	cin >> N;
	A.resize(N);
	sz.resize(N, 1);
	REP(i, 2)
		dp[i] = vector<vector<int64>>(N+1, vector<int64>(N+1, INF_LL));
	REP(i, N) cin >> A[i];
	REP(i, N-1){
		int32 u, v;
		cin >> u >> v;u--;v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	init(0, -1);
	dfs(0, -1);
	REP(i, N+1){
		if(dp[1][0][i] < 0 || dp[0][0][i] != INF_LL){
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 394240
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int n,m;(n=s.nextInt())>=0;)System.out.println(3130-(m=Math.min(10,n-=Math.min(10,n)))*125+Math.min(10,n-=m)*20-n*160);}}

Measured memory_bytes: 12000
# Problem: https://atcoder.jp/contests/abc085/tasks/abc085_b
# Python 3rd Try

import sys
from collections import Counter,deque
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def solver(riseSetQue):
    result = 0
    riseCounter = Counter(riseSetQue)
    result = len(riseCounter)
    return result
if __name__ == "__main__":
    N = II()
    riceSet = deque()
    for j in range(0, N, +1):
        riceSet.append(II())
    print("{}".format(solver(riceSet)))


Measured memory_bytes: 3316
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <bitset>
#include <array>
#include <set>
#include <string>

#include <iterator>
#include <algorithm>
#include <numeric>

#include <ios>
#include <sstream>
#include <iostream>
#include <fstream>
#include <climits>

#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define range(i,m,n) for(int i=m; i<n;i++)
#define each(i,n) for(auto i:n)
#define all(i) i.begin(),i.end()

#define makevv(i,j,k,l,m) vector<vector<i>> j(k,vector<i>(l,m))

using ll=long long;

using vi=std::vector<int>;
using vvi=std::vector<vi>;
using pii=std::pair<int,int>;
using pll=std::pair<ll,ll>;


template <typename T>
std::string printItr(T b, T e, std::string delim=" ")
{
    std::stringstream ss;
    std::ostream_iterator<decltype(*b)> out_it(ss, delim.c_str());
    std::copy(b,e - 1, out_it);
    ss<<*(e-1);
    return ss.str();
}
using namespace std;

int main(void){
    ll ans=LLONG_MAX;
    int n,k;
    cin>>n>>k;
    vector<pll> p(n);
    rep(i,n){
        cin>>p[i].first>>p[i].second;
    }
    sort(all(p));
    vector<ll> yp(n);
    rep(i,n)yp[i]=p[i].second;
    rep(i,n){
        range(j,i+1,n){
            if(j-i+1<k)continue;
            ll x=p[j].first-p[i].first,y=LLONG_MAX;
            vector<ll> tmp;
            range(l,i,j+1){
                tmp.push_back(yp[l]);
            }
            sort(all(tmp));
            rep(l,j-i+1-k+1){
                y=min(y,tmp[l+k-1]-tmp[l]);
            }
            ans=min(ans,x*y);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int n,m;
  cin >> n >> m;
  int l = 0;
  int r = 100005;
  rep(i,m){
    int li,ri;
    cin >> li >> ri;
    chmax(l,li);
    chmin(r,ri);
    if(l>r){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << r - l + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
from fractions import gcd
n, m = map(int, input().split())
a = [int(i) // 2 for i in input().split()]

def pow2(n):
    cur, res = n, 0
    while cur:
        if cur % 2 == 0:
            cur //= 2
            res += 1
        else:
            return res

def lcm(a, b):
    return a * (b // gcd(a, b))

b = [pow2(i) for i in a]
if (min(b) != max(b)):
    print(0)
    exit(0)
l = 1
for i in range(n):
    l = lcm(l, a[i])
print(m // l - m // (2 * l))

Measured memory_bytes: 89580
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int n,m,q;
int a[100],b[100],c[100],d[100];
int dfs(int N,int M,vector<int>v){
  if(N == 0){
    int ans = 0;
    rep(i,q)if(v[b[i] - 1] - v[a[i] - 1] == c[i])ans += d[i];
    return ans;
  }
  v.push_back(M);
  int res = 0;
  REP(i,1,min(11,m + 1)){
    if(i < M)continue;
    res = max(res,dfs(N - 1,i,v));
  }
  return res;
}
int main(){
  cin >> n >> m >> q;
  rep(i,q)cin >> a[i] >> b[i] >> c[i] >> d[i];
  int ans = 0;
  REP(i,1,m + 1){
    vector<int>v;
    ans = max(ans,dfs(n,i,v));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define N 10000
using namespace std;
int n,ans[N];

int main(){
  cin>>n;
  int maxv=0,idx=1,in;
  for(int i=2;i<=n;i++){
    cout.flush()<<"? "<<1<<" "<<i<<endl;
    cin>>in;
    if(maxv<in){
      maxv=in;
      idx=i;
    }
  }
  ans[0]=idx;
  for(int i=1;i<=n;i++){
    if(i==idx)continue;
    cout.flush()<<"? "<<idx<<" "<<i<<endl;
    cin>>in;
    ans[in]=i;
  }
  cout.flush()<<"! ";
  for(int i=0;i<n;i++){
    if(i)cout.flush()<<' ';
    cout.flush()<<ans[i];
  }
  cout.flush()<<endl;
  return 0;
}

Measured memory_bytes: 3556
import java.io.*;
import java.util.*;
import java.lang.ArrayIndexOutOfBoundsException;
import java.math.BigInteger;

/**
 * @author yoshikyoto
 */
class Main extends MyUtil{
	public static void main(String[] args) throws Exception{
		while (true) {
			// 入力は独自クラスを使っている
			int[] in = readIntMap();
			if(in[0] + in[1] == 0) break;
			cnt = 0;
			max = 0;
			check(10, in[0], in[1], 0, "");
			if(cnt == 0){
				System.out.println("error");
			}else if (cnt > 1){
				System.out.println("rejected");
			}else{
				System.out.println(max + " " + ans);
			}
		}
	}
	
	static int cnt = 0;
	static int max = 0;
	static String ans = "";
	static void check(int i, int t, int num, int sum, String buf){
		if(num < i){
			sum += num;
			buf = num + buf;
			if(max < sum && sum <= t){
				max = sum;
				ans = buf;
				cnt = 1;
			}else if(max == sum){
				cnt++;
			}
			return;
		}
		
		// iで分断しない場合
		// System.out.println(num + " を分断しない");
		check(i*10, t, num, sum, buf);
		
		// iで分断する場合
		int next_num = num / i;
		int bundan = num % i;
		int next_sum = sum + bundan;
		// System.out.println(num + " を " + next_num + " と分断");
		check(10, t, next_num, next_sum, " " + bundan + buf);
	}
}

// --- ここから下はライブラリ ----------
/**
 * MyUtil
 * @author yoshikyoto
 */
class MyUtil {
	public static int toInt(boolean[] a){
		int pow = 1, ret = 0, l = a.length;
		for(int i = 0; i < l; i++){
			if(a[i]) ret += pow;
			pow *= 2;
		}
		return ret;
	}
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	public static int ins[];
	public static int[] readIntMap() throws IOException{return parseInt(readLine().split(" "));}
	public static int readIntMap(int i) throws Exception{
		if(i == 0) ins = readIntMap();
		return ins[i];
	}
	public static int[][] readIntMap(int n, int m) throws IOException{
		int[][] ret = new int[n][];
		for(int i = 0; i < n; i++) ret[i] = readIntMap();
		return ret;
	}
	public static int[] readIntToMap(int n) throws IOException{
		int[] ret = new int[n];
		for(int i = 0; i < n; i++) ret[i] = readInt();
		return ret;
	}
	public static int[] readNoDistIntMap() throws IOException{
		String[] strs = readLine().split("");
		int l = strs.length;
		int[] ret = new int[l-1];
		for(int i = 1; i < l; i++)
			ret[i-1] = parseInt(strs[i]);
		return ret;
	}
	public static String readLine() throws IOException{return br.readLine();}
	public static int readInt() throws IOException{return Integer.parseInt(br.readLine());}
	public static int[] parseInt(String[] arr){
		int[] res = new int[arr.length];
		for(int i = 0; i < arr.length; i++)res[i] = Integer.parseInt(arr[i]);
		return res;
	}
	public static double[] parseDouble(String[] arr){
		double[] res = new double[arr.length];
		for(int i = 0; i < arr.length; i++)res[i] = Double.parseDouble(arr[i]);
		return res;
	}
	public static boolean[] parseBool(String[] arr){
		int[] t = parseInt(arr);
		boolean[] res = new boolean[t.length];
		for(int i = 0; i < t.length; i++){
			if(t[i] == 1){res[i] = true;
			}else{res[i] = false;}
		}
		return res;
	}
	public static int parseInt(Object o){
		return Integer.parseInt(o.toString());
	}
}

Measured memory_bytes: 17564
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for ia, a in enumerate(L):
    for ib, b in enumerate(L[ia+1:], ia):
        ans += bisect_left(L, a+b) - ib - 2

print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long
namespace yspm{
	inline int read()
	{
		int res=0,f=1; char k;
		while(!isdigit(k=getchar())){if(k=='-') f=-1;}
		while(isdigit(k)){res=res*10+k-'0'; k=getchar();}
		return res*f;
	}
	const int N=2e3+10;
	int n,m,T,sum1[N][N],g[N][N];
	int lin[N][N],row[N][N],sum2[N][N];
	char s[N];
	signed main()
	{
		n=read(); m=read(); T=read();
		for(int i=1;i<=n;++i)
		{
			scanf("%s",s);
			for(int j=1;j<=m;++j) g[i][j]=s[j-1]-'0';
		}
		for(int i=1;i<=n;++i)
		{
			for(int j=1;j<=m;++j)
			{
				sum1[i][j]=sum1[i-1][j]+sum1[i][j-1]-sum1[i-1][j-1];
				sum2[i][j]=sum2[i-1][j]+sum2[i][j-1]-sum2[i-1][j-1];
				if(g[i][j]) ++sum2[i][j];
				row[i][j]=row[i][j-1]; lin[i][j]=lin[i-1][j];
				if(g[i][j])
				{
					if(g[i-1][j]) ++sum1[i][j],++row[i][j];
					if(g[i][j-1]) ++sum1[i][j],++lin[i][j];
				}
			}
		}
		int x1,y1,x2,y2;
		while(T--)
		{
			x1=read(); y1=read(); x2=read(); y2=read();
			int tmp=sum1[x2][y2]-sum1[x2][y1-1]-sum1[x1-1][y2]+sum1[x1-1][y1-1];
			tmp-=lin[x2][y1]-lin[x1-1][y1];
			tmp-=row[x1][y2]-row[x1][y1-1];
			int ans=sum2[x2][y2]-sum2[x2][y1-1]-sum2[x1-1][y2]+sum2[x1-1][y1-1]-tmp;
			printf("%lld\n",ans);
		}
		return 0;
	}
}
signed main()
{
	yspm::main();
	return 0;
}

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

const int nmax = 8;
int N, M;
bool pass[nmax][nmax] = {0};

int dfs(int v, bool visited[nmax]) {
    bool all_visited=true;
    for(int i=0; i<N; i++) if(visited[i]==false) all_visited=false;
    if(all_visited) return 1;


    int ret = 0;
    for(int i=0; i<N; i++) {
        if(!pass[v][i]) continue;
        if(visited[i]) continue;
        visited[i]=true;
        ret += dfs(i, visited);
        visited[i]=false;
    }
    return ret;
}

int main() {
    cin >> N >> M;
    for(int i=0; i<M; i++) {
        int a, b;
        cin >> a >> b;
        pass[a-1][b-1]=pass[b-1][a-1]=true;
    }

    bool visited[nmax];
    for(int i=0; i<N; i++) visited[i]=false;
    visited[0]=true;
    cout << dfs(0, visited) << endl;
    return 0;
}


Measured memory_bytes: 256
# 092_a
# """
#  あなたは、電車とバスを乗り継いで旅行をする計画を立てました。
#  電車は旅程に沿って通常のきっぷを買うと A円かかり、
#  乗り放題きっぷを買うとB円かかります。
#  バスは旅程に沿って通常のきっぷを買うと C円かかり、
#  乗り放題きっぷを買うと D円かかります。
#
# 電車およびバスについて通常の切符を買うか乗り放題きっぷを買うかをうまく選んだときの、運賃の合計の最小値を求めてください。
# """

A = int(input())
B = int(input())
C = int(input())
D = int(input())
if (1 <= A & A <= 1000) & (1 <= B & B <= 1000) & (1 <= C & C <= 1000) & (1 <= D & D <= 1000):
    print((min(A, B)) + (min(C, D)))


Measured memory_bytes: 9176
import Control.Monad
import qualified Data.List as L

main :: IO ()
main = do
  [n, m] <- getNums <$> getLine
  as <- replicateM n getLine
  bs <- replicateM m getLine
  let msg = if (solve as bs (n, m)) then "Yes" else "No"
  putStrLn msg
  
getNums :: String -> [Int]
getNums = map read . words

solve :: [String] -> [String] -> (Int, Int) -> Bool
solve as bs (n, m) = _solve as bs 0 0
  where
    _solve :: [String] -> [String] -> Int -> Int -> Bool
    _solve as bs x y = if matrixEquals ass bs
                       then True
                       else if x + 1 > n
                            then if y + 1 > n
                                 then False
                                 else _solve as bs 0 (y+1)
                            else _solve as bs (x+1) y
                       where
                         ass = getSubMatrix m x y (n, m) as     

getSubMatrix :: Int -> Int -> Int -> (Int, Int) ->  [String] -> [String]
getSubMatrix size x y (n, m)as =
  map _getSubMatrix ass
  where
    ass = if size + x > n || size + y > n
          then ["a"]
          else (take size . drop x) as
    _getSubMatrix ls
      | null ls = "a"
      | otherwise = (take size . drop y) ls

matrixEquals :: [String] -> [String] -> Bool
matrixEquals as bs = all (\(a, b) -> a == b) $ zip as bs 


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

ll solve(vector<vector<ll>>& dp, vector<ll> a,int l, int r){
	if(dp[l][r]) return dp[l][r];
	if(l==r) return 0;
	ll fans = 1e18;
	for(int i=l; i<r; i++){
		fans = min(fans,solve(dp,a,l,i)+solve(dp,a,i+1,r));
	}
	return dp[l][r] = fans + a[r]-a[l-1];

}

int main(){
	int N;
	cin >> N;
	vector<ll> a(N+1);
	for(int i=1; i<=N; i++) cin >> a[i];
	for(int i=1; i<=N; i++){
		a[i] += a[i-1];
	}
	vector<vector<ll>> dp(N+1,vector<ll>(N+1));
	solve(dp,a,1,N);

	cout << dp[1][N] << endl;
	return 0;

}



Measured memory_bytes: 7236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
  int r,d,x2000;
  cin >> r >> d >> x2000;
  
  int x[10];
  x[0] = r * x2000 - d;
  for(int i = 1; i < 10; i++){
    x[i] = r * x[i-1] - d;
  }
  
  rep(i,10){
    cout << x[i] << endl;
  }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define long long long int
using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    int s = 0;
    for (int i = 0; i < m; i++) {
        int x; cin >> x; s += x;
    }
    if (s > n) {
        cout << -1;
    } else {
        cout << n - s;
    }

    return 0;
}

Measured memory_bytes: 3572
#include<stdio.h>
#include<string.h>
int main()
{
    char a[26];
    int i,j,t=0;
    gets(a);
    for(i=0;i<strlen(a);i++)
    {
         for(j=i+1;j<strlen(a);j++)
        if(a[i]==a[j]) t=1;
    }
    if(t==1) printf("no");
    else printf("yes");
}

Measured memory_bytes: 128
import sys

a, b, c, k = map(int, sys.stdin.readline().split())

sumi = 0


sumi += min(a, k)
k -= min(a, k)
if k > 0:
  k -= min(b, k)
if k > 0:
  sumi -= min(c, k)
  k -= min(c, k)

print(sumi)

Measured memory_bytes: 9212
H_1, M_1, H_2, M_2, K = map(int, input().split())

if M_2 >= M_1:
    H = H_2 - H_1
    M = M_2 - M_1
else:
    H = H_2 - H_1 - 1
    M = 60 - M_1 + M_2

time = 60 * H + M
ans = time - K

print(str(ans))


Measured memory_bytes: 9168
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
const int N = 1e6 + 5;
int vis[N];
int cnt[N];
// void factors(ll x){
//         cnt[x]++;
//         for(ll i = 2; x*i<N; i++){
//             cnt[i*x]++;
//         }
// }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        for(ll j = 1; j <= n; j++){
            if(n - (i * j) <= 0){
                break;
            }
            ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll n;
	cin >> n;
	
	ll ans = 0LL;
	while( ans * (ans + 1LL) / 2LL < n ) {
		ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3532
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int ans=0;
    int num=a[0];
    int count=0;
    for(int j=0;j<=n;j++){
        if(j==n){
            if(num<count){
                ans=ans+count-num;
            }else if(num>count){
                ans=ans+count;
            }
        }else if(num==a[j]){
            count++;
        }else{
            if(num<count){
                ans=ans+count-num;
            }else if(num>count){
                ans=ans+count;
            }
            num=a[j];
            count=1;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
n,x,m=map(int,input().split())

logn = (10**10).bit_length()
doubling = []
sumd = []
for _ in range(logn):
  tmpd = [-1] * m
  doubling.append(tmpd)
  tmps = [0] * m
  sumd.append(tmps)

for i in range(m):
  doubling[0][i] = i * i % m
  sumd[0][i] = i

for i in range(1,logn):
  for j in range(m):
    doubling[i][j] = doubling[i-1][doubling[i-1][j]]
    sumd[i][j] = sumd[i-1][j] + sumd[i-1][doubling[i-1][j]]

now = x
pos = 0
result = 0
while n:
  if n & 1:
    result += sumd[pos][now]
    now = doubling[pos][now]
  n = n >> 1
  pos += 1

print(result)


Measured memory_bytes: 118184
def gcd(x, y):
    if x == 0:
        return y
    else:
        return gcd(y % x, x)


def lcm(x, y):
    return x * y // gcd(x, y)


n = int(input())
ans = 1
for _ in range(n):
    t = int(input())
    ans = lcm(ans, t)
print(ans)

Measured memory_bytes: 3060
// https://beta.atcoder.jp/contests/abc091
// status:

#define SUBMIT
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 200005;
int a[MAX_N];
int b[MAX_N];

long solve(int N) {
    auto ans = 0;
    for (int v = (1 << 28); v; v >>=1) {
        for (int i = 0; i < N; ++i) a[i] &= 2 * v - 1;
        for (int i = 0; i < N; ++i) b[i] &= 2 * v - 1;
        sort(a, a + N); sort(b, b + N);

        long t = 0;
        for (int i = 0; i < N; ++i) {
            long t1_to_t2 = upper_bound(b, b + N, 2 * v - a[i] - 1) - lower_bound(b, b + N, 1 * v - a[i]);
            long t3_to_t4 = upper_bound(b, b + N, 4 * v - a[i] - 1) - lower_bound(b, b + N, 3 * v - a[i]);
            t += t1_to_t2 + t3_to_t4;
            t &= 1;
        }
        if (t) ans += v;
    }

    return ans;
}

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(1
0
0
)");
#endif
    int N;
    stream >> N;
    for (int i = 0; i < N; ++i) stream >> a[i];
    for (int i = 0; i < N; ++i) stream >> b[i];
    auto ans = solve(N);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
/*	                           
							 * * 
						   *     * 
						 *	       * 
					   *	         * 
                     *     _ooOoo_     * 
                   *      o8888888o      * 
                 *        88" . "88        * 
                *         (| -_- |)         * 
               *       *  0\  =  /0  *       * 
               *       *__0/`---'\0__*       * 
               *     .'  \\|     |//  `.     * 
                *   /  \\|||  :  |||//  \   * 
                 * /  _||||| -:- |||||-  \ * 
                   |   | \\\  -  /// |   |
                   | \_|  ''\---/''  |   |
                   \  .-\__  `-`  ___/-. /
                 ___`. .'  /--.--\  `. . __
              ."" '<  `.___\_<|>_/___.'  >'"".
             | | :  `- \`.;`\ _ /`;.`/ - ` : | |
             \  \ `-.   \_ __\ /__ _/   .-` /  /
        ======`-.____`-.___\_____/___.-`____.-'======
                           `=---='
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                   佛祖保佑       永无BUG
                        author：Richie 
*/

#include<stdio.h>
#include<string.h>	
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define LOCAL
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long
#define N 500001
#define mod 1000000007

int cmp(const void *a,const void *b);
void print_array(int *a,int n);
void read_array(int *a,int n);
void init();
ll fast(ll x);
ll exgcd(ll a,ll b,ll *x,ll *y);
ll getInv(int a);
ll gcd(ll a,ll b);

int main(){
    ll x,k,d;
    scanf("%lld %lld %lld",&x,&k,&d);
    if(x<0)x*=-1;
	ll t=x/d;
	if(t==0){
		if(k%2==1)printf("%lld",llabs(x-d));
		else printf("%lld",llabs(x));
	}
	else{
		if(k<=t)printf("%lld",x-k*d);
		else{
		   	x-=t*d;
		   	k-=t;
		   	if(k%2==0)printf("%lld",x);
			else if(x==0)printf("%lld",d);
			else printf("%lld",llabs(x-d));
		}		
	}

	return 0;
}



ll gcd(ll a,ll b){
	int t;
	while(b!=0){
		t=a%b;
		a=b;
		b=t;
	}
	return a;
}

ll fast(ll x){									//逆元 费马小定理/欧拉定理 适用范围：一般在mod是个素数的时候用
	int y=mod-2;
	ll res=1;
	while(y){
		if(y&1)res=res*x%mod;
		x=x*x%mod; 
		y>>=1;
	}
	return res;
}

ll exgcd(ll a,ll b,ll *x,ll *y)					//扩展欧几里得算法 
{
    if(b==0)
    {
        *x=1,*y=0;
        return a;
    }
    ll ret=exgcd(b,a%b,y,x);
    *y-=a/b*(*x);
    return ret;
}
ll getInv(int a)						//求a在mod下的逆元，不存在逆元返回-1 
{
    ll x,y;
    ll d=exgcd(a,mod,&x,&y);
    return d==1?(x%mod+mod)%mod:-1;
}

void init(void){
	#ifdef LOCAL
		freopen("P2678_2.in","r",stdin);
		freopen("data.txt","w",stdout);
	#endif
}

int cmp(const void *a,const void *b){
	return *(int*)a-*(int*)b;					//升序排列 
} 

void print_array(int *a,int n){
	FOR(i,1,n){
		if(i!=n)printf("%d ",a[i]);
		else printf("%d",a[i]);
	}
} 

void read_array(int *a,int n){
	FOR(i,1,n)scanf("%d",&a[i]);
}




Measured memory_bytes: 1732
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
K = int(input())
s = 0
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      s+=gcd(a,b,c)
      
      
print(s)
      
  

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

using namespace std;

int main(){
  int N,D,X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int count=0;
  for(int i=0;i<N;i++){
    for(int j=1;j<=D;j+=A.at(i)){
      count++;
    }
  }

  cout << count+X << endl;
  
  return 0;
}

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

public class Main {
    String fileName = "";


    public void solve() throws IOException {
        int n = nextInt();
        int k = nextInt();
        long s = 0;
        for (int i = 0; i < n; i++) {
            int x = nextInt();
            s += Math.min(x, k - x);
        }
        out.println(2 * s);
    }

    public void run() {
        try {
            if ("".equals(fileName)) {
                br = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                br = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Main().run();
    }

}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int ans=0;
  vector<int>h(n);
  for(int i=0;i<n;i++){
    cin>>h.at(i);
  }
  while(1){
    int l,r,mini;
    for(int i=0;i<n;i++){
      if(h.at(i)!=0){
        if(i==n-1){
          cout<<ans+h.at(n-1)<<endl;
          return 0;
        }
        l=i;
        mini=h.at(l);
        break;
      }
      if(i==n-1){
        cout <<ans<<endl;
        return 0;
      }
    }
    for(int i=l+1;i<n;i++){
      if(h.at(i)!=0){
        mini=min(mini,h.at(i));
      }
      if(h.at(i)==0){
        r=i;
        break;
      }
      if(i==n-1){
        r=n;
      }
    }
    for(int i=l;i<r;i++){
      h.at(i)-=mini;
    }
    ans+=mini;
  }
}

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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    
    if (a + b == 15) cout << "+";
    else if (a * b == 15) cout << "*";
    else cout << "x";
    cout << endl;
    
    return 0;
}

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

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	string ans = "No";
	if (4 * a * b < (c - a - b)*(c - a - b) && c - a - b > 0) ans = "Yes";
	cout << ans << endl;
}

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

bool IsPrime(int n, int *prime, int pl)
{
	for(int i = 0; i < pl; ++i)
	{
		if(n % prime[i] == 0)
		{
			return false;
		}
	}
	
	prime[pl++] = n;
	return true;
}

int main()
{
	int N;
	cin >> N;
	cout << N << ":";
	
	int prime[100000], pl = 1, n = N;
	prime[0] = 2;
	while(n % prime[0] == 0)
	{
		cout << " " << prime[0];
		n /= prime[0];
	}
	
	for(int i = 3; i * i <= N && i <= n; i += 2)
	{
		if(IsPrime(i, prime, pl))
		{
			while(n % prime[pl] == 0)
			{
				cout << " " << prime[pl];
				n /= prime[pl];
			}
		}
	}
	
	if(n != 1)
	{
		cout << " " << n;
	}
	
	cout << endl;

    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define INF (1LL << 30)
#define int long long
#define pii pair<long long, long long>
#define MOD 1000000007
#define print(x) cout << (x) << endl
using namespace std;
typedef long long ll;

vector<int> A(1e5+1);
int N,M;


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

signed main(){
    cin>>N>>M;

    // uf?
    UnionFind uf(100003);
    rep(i,M){
        int x,y,z;
        cin>>x>>y>>z;
        // written 1 or 2
        --x;--y;
        z %= 2;
        uf.unite(x,y);
    }

    set<int> s;
    rep(i,N)s.insert(uf.root(i));

    cout<<s.size()<<endl;

    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define MOD 1000000007
#define int long long
#define vi vector<long long int>
#define pb push_back
#define rep(i,a,n) for (int i=(a);i<(n);++i)
using namespace __gnu_pbds;
using namespace std;
// its godfather
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int>vec;
long long power(long long a, long long b, long long m)
{
   long long res = 1;
   while (b > 0)
   {
      if (b & 1)
         res = res * a % m;
      a = a * a % m;
      b >>= 1;
   }
   return res;
}
signed main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(0);

#ifndef ONLINE_JUDGE
   if (fopen("INPUT.txt", "r"))
   {
      freopen("INPUT.txt", "r", stdin);
      freopen("OUTPUT.txt", "w", stdout);
   }
#endif
   int t;
   // cin>>t;
   t=1;
   while(t-->0){
      int a,b;
      cin>>a>>b;
      if(b%2==1 || b<2*a || b>4*a ){
         cout<<"No"<<endl;
      }else cout<<"Yes"<<endl;
   }
}

Measured memory_bytes: 3632
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n = lread();
    long[] l = aryread();

    long max_side = 0;
    long sum_side = 0;
    foreach (e; l)
    {
        max_side = max(e, max_side);
        sum_side += e;
    }

    (max_side < sum_side - max_side ? "Yes" : "No").writeln();
}

Measured memory_bytes: 256
#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 print(x)cout<<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 x,y;
  cin >> x>>y;
  rep(i,1000){
    rep(j,1000){
      if((i+j) == x){
        if(i*2 + j*4 == y){
          cout<<"Yes"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int N, M; cin >> N >> M;
	vector<int> X(M, 0);
	rep (i, M){
		cin >> X[i];
	} // end rep

	if (N >= M){
		cout << 0 << endl;
		return 0;
	} // end if

	sort(ALL(X));

	vector<int> diff(M-1);
	for (int i = 0; i < M - 1; ++i){
		diff[i] = (X[i+1] - X[i]);
	} // end for

	sort(ALL(diff));

	rep (i, M - 1){
		cerr << diff[i] << ' ';
	} // end ep
	cerr << endl;

	ll res = 0LL;
	rep (i, M - N){
		res += (ll)diff[i];
	} // end rep

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <stdlib.h>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <queue>
#include<unordered_map>
#define mod 1000000007
typedef unsigned long long int ll;
using namespace std;
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    if((b-1)%(a-1)==0)
    cout<<(b-1)/(a-1)<<"\n";
    else
    {
        cout<<(b-1)/(a-1)+1<<"\n";
    }
    
    return 0;
}
 

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

static const int MAX = 100;
static const int INFTY = 1 << 21;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
	int u, minv;
	int d[MAX], p[MAX], color[MAX];

	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}

	d[0] = 0;
	while (true) {
		minv = INFTY;
		u = -1;
		for (int i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1)break;
		color[u] = BLACK;
		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK && M[u][v] != INFTY) {
				if (d[v] > M[u][v]) {
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
		
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] != -1)sum += M[i][p[i]];
	}
	return sum;
}

int main() {
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> M[i][j];
			if (M[i][j] == -1)M[i][j] = INFTY;
		}
	}
	cout << prim() << '\n';
	return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

using Data = ll;
const Data INF = 1000000000;

vector<Data> lis(const vector<Data>& a) {
  const int n = a.size();
  if (n == 0) return vector<Data>(0);
  vector<Data> A(n, INF);
  vector<int> id(n);
  for (int i = 0; i < n; i++) {
    id[i] = distance(A.begin(), lower_bound(A.begin(), A.end(), a[i]));
    A[id[i]] = a[i];
  }
  int m = *max_element(id.begin(), id.end());
  vector<Data> res(m + 1);
  for (int i = n - 1; i >= 0; i--)
    if (id[i] == m) res[m--] = a[i];
  return res;
}

int main()
{
  ll x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  if(x1>x2) {
    swap(x1,x2);
    swap(y1,y2);
  }
  ll n;
  cin>>n;
  map<ll,ll> mp;
  for(auto&& i:irange(0l,n)) {
    ll x,y;
    cin>>x>>y;
    if(x<x1||x>x2||y<min(y1,y2)||y>max(y1,y2)) continue;
    mp[x] = y;
  }
  vector<Data> vec;
  for(auto&& p:mp) {
    vec.push_back(p.second);
  }
  if(y1>y2) {
    boost::reverse(vec);
    swap(y1,y2);
  }
  auto len=lis(vec).size();
  ll diffmin=min(x2-x1,y2-y1);
  double ans = 100.0*(x2-x1+y2-y1);
  if (len == diffmin+1) {
    ans -= (len-1) * (2.0 - asin(1.0)) * 10.0;
    ans += (acos(-1.0) - 2.0) * 10.0;
  } else {
    ans -= len * (2.0 - asin(1.0)) * 10.0;
  }
  cout<<fixed<<setprecision(10)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 18160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,s;cin >> n >> s;
	if(n == s){
		cout << n + 1 << endl;
		return 0;
	}
	if(s > n){
		cout << -1 << endl;
		return 0;
	}
	ll ans = -1;
	for(ll i = 2; i * i <= n; i++){
		ll sum = 0, k = n;
		while(k > 0){
			sum += k % i;
			k /= i;
		}
		if(sum == s){
			ans = i;
			break;
		}
	}
	if(ans != -1){
		cout << ans << endl;
		return 0;
	}
	for(ll i = pow(n, 0.5); i >= 1; i--){
		if((n - s) % i == 0){
			ll sum = 0, k = n, m = (n - s) / i + 1;
			while(k > 0){
				sum += k % m;
				k /= m;
			}
			if(sum == s){
				ans = m;
				break;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
s = [int(c) for c in input()]
c = 0

for i in range(len(s)-1):
    if s[i] == 1 and s[i+1] == 1:
        s[i+1] = 0
        c += 1
    elif s[i] == 0 and s[i+1] == 0:
        s[i+1] = 1
        c += 1

print(c)


Measured memory_bytes: 3956
N = int(input())
room = [[[0 for j in range(10)] for i in range(3)] for k in range(4)]
s = "####################"

for i in range(N):
    b,f,r,v = [int(i) for i in input().split()]
    room[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" {}".format(room[i][j][k]),end = "")
            if k == 9:
                print()
    if i != 3:
        print(s)



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

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

   if (N/1000==N%1000/100 && N/1000==N%100/10 && N/1000==N%10){
    cout<<"Yes"<<endl;
  }
  else if (N/1000==N%1000/100 && N/1000==N%100/10) {
    cout<<"Yes"<<endl;
  } 
  else if (N%1000/100==N%100/10 && N%1000/100==N%10){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

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

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

  int n, m; cin >> n >> m;
  vector<tuple<int, int, int> > t(m);
  rep(i, m) {
    ll p, y; cin >> p >> y;
    t[i] = make_tuple(p, y, i);
  }
  sort(t.begin(), t.end());
  vector<pair<int, int> > ans(m);
  vector<int> cnt(101010);
  rep(i, m) {
    ll p, y, idx;
    tie(p, y, idx) = t[i];
    cnt[p]++;
    ans[idx] = make_pair(p, cnt[p]);
  }

  rep(i, m) {
    cout << setw(6) << setfill('0') << ans[i].first;
    cout << setw(6) << setfill('0') << ans[i].second << '\n';
  }
}


Measured memory_bytes: 3968
import java.util.Scanner;
class Main {

	public void range() {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();

		int b = sc.nextInt();

		int c = sc.nextInt();

		if(a < b ) {

			if(a < c) {

				if(b < c) {

					System.out.println("Yes");

				} else {
 
					System.out.println("No");

				}

			} else {
 
				System.out.println("No");

			}

		} else {
 
			System.out.println("No");

		}

	}

	public static void main(String[] args) {

		new Main().range();

	}

}

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

using namespace std;

const int inf = 1000000;

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

	int n;
	cin >> n;

	vector<pair<int, int> > a;
	vector<pair<int, int> > b;

	for(int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		int pre = 0;
		int mn = 0;
		for(char c : s) {
			if(c == '(') {
				++pre;
			} else {
				--pre;
			}
			mn = min(mn, pre);
		}
		a.emplace_back(mn, pre);
	}
	
	sort(a.begin(), a.end(), [&] (auto x, auto y) {
		return min(x.first, x.second + y.first) > min(y.first, y.second + x.first);
	});

	int cur = 0;
	for(auto o : a) {
		if(cur + o.first < 0) {
			cout << "No" << '\n';
			exit(0);
		}
		cur += o.second;
	}

	if(cur == 0) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}

	return 0;
}

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

#define forn(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define MAX(a,b,c) max(max(a,b),c)
#define SumInRange(a,b) ((b*(b+1))/2)-(((a-1)*(a))/2)
#define Different_Random srand(time(NULL))
#define Random(a,b) (rand()%((b+1)-a))+a
#define __delete(v,n) v.erase(remove(v.begin(),v.end(),n),v.end())

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define newline cout << "\n";

#define read(x)    freopen(#x, "r", stdin)
#define write(x)   freopen(#x, "w", stdout)

#define all(x)     x.begin(), x.end()
#define dbg(args...)    {string sss(#args);sss+=',';cerr<<"-->";debugger::call(all(sss), args);cerr<<"\n";}
#define dbgA(A, n)      {cerr<<"-->"<<#A<<"=(";forn(i, n)cerr<<A[i]<<" ";cerr<<")\n";}
#define dbgA2(A, n, m)  {cerr<<"-->"<<#A<<"=\n";forn(i, n){forn(j, m){cerr<<setw(4)<<A[i][j]<<" ";}cerr<<"\n";}cerr<<"\n";}

struct debugger{
    typedef string::iterator si;
    static void call(si it, si ed) {}
    template<typename T, typename ... aT>
    static void call(si it, si ed, T a, aT... rest) {
        string b;
        for(; *it!=','; ++it) if(*it!=' ')b+=*it;
        cerr << b << " = " << a << " ";
        call(++it, ed, rest...);
    }
};

template<typename T>
T Max(T a) {return a;}

template<typename T, typename... Args>
T Max(T a, Args... args){ return a > Max(args...)? a : Max(args...);}

template<typename T>
T Min(T a) {return a;}

template<typename T, typename... Args>
T Min(T a, Args... args){ return a < Min(args...)? a : Min(args...);}


//int dx[] = {1, -1, 0, 0, -1, 1, -1, 1};
//int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
//int knight_x[] = {2, 2, -2, -2, 1, 1, -1, -1};
//int knight_y[] = {1, -1, 1, -1, 2, -2, 2, -2};

/*
cout.precision(x);
cout << fixed;
*/

typedef long long int ll;
typedef unsigned long long int ull;
const double GOLD = (1.0 + sqrt(5.0))/2.0;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI = 3.141592653589793;
const double E = 2.718281828459045;

ll expo(ll a, ll n)
{
    ll result = 1;
    while(n)
    {
        if(n%2) result*=a;
        a*=a; n/=2;
    }
    return result;
}

ll mod_expo(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    #ifdef TarekHasan
        read(input.txt);
    #endif // TarekHasan
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    int a,b,c,k; cin >> a >> b >> c >> k;

    int counter = 0;
    while(a>=b)
    {
        b*=2;
        counter++;
    }

    while(b>=c)
    {
        c*=2;
        counter++;
    }

    if(counter<=k)
        cout << "Yes\n";
    else
        cout << "No\n";


    cerr << "time = " << clock() << " ms" << '\n';
    return 0;
}



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

int main() {
	int n, a[100] = { 0 }, mi = 1000000000, ma = 0;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		mi = min(mi, a[i]);
		ma = max(ma, a[i]);
	}
	cout << ma - mi << endl;
	return 0;
}

Measured memory_bytes: 256