akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

int trans(int x, int y) {
	if (x > y) swap(x, y);
	return x * 1000 + y;
}

vector<int> topological_sort(int n, vector<vector<int>> graph, vector<int> indegree) {
	vector<int> res;
	queue<int> que;
	for (int i = 0; i < n; i++) if (indegree[i] == 0) que.push(i);
	while (!que.empty()) {
		int ver = que.front(); que.pop();
		res.push_back(ver);
		for (int i : graph[ver]) {
			indegree[i]--;
			if (indegree[i] == 0) que.push(i);
		}
	}
	return res;
}

vector<vector<int>> graph(1000010, vector<int>());
vector<int> deg(1000010), ans(1000010, 1);

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

	int n;
	cin >> n;
	rep(i, n) {
		vector<int> a(n - 1);
		rep(j, n - 1) {
			cin >> a[j];
			a[j]--;
		}
		rep(j, n - 2) {
			graph[trans(i, a[j + 1])].pb(trans(i, a[j]));
			deg[trans(i, a[j])]++;
		}
	}
	vector<int> order = topological_sort(1000 * n, graph, deg);
	if (order.size() != 1000 * n) {
		cout << -1 << '\n';
		return 0;
	}
	rep(i, 1000 * n) {
		for (int nxt : graph[order[i]]) {
			chmax(ans[nxt], ans[order[i]] + 1);
		}
	}
	int res = 0;
	rep(i, 1000 * n) chmax(res, ans[i]);
	cout << res << '\n';
}

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

#define int long long
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; }

#define MOD 998244353

int n;

int a[5000];

int memo[3010][3010]; 

int dp(int i, int s){
	if(i == n){
		return s == 0 ? 1 : 0;
	}

	if(memo[i][s] != -1) return memo[i][s];

	int ans = dp(i+1, s) * 2 % MOD;
	if(s >= a[i]){
		ans = (ans + dp(i+1, s-a[i])) % MOD;
	}

	return memo[i][s] = ans;
}

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

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

	memset(memo, -1, sizeof(memo));

	cout << dp(0, s) << endl;

	return 0;
}


Measured memory_bytes: 74624
use itertools::Itertools;
use proconio::input;

fn main() {
    input!(p: [(i64, i64)]);

    let smm = p.iter().map(|(x, y)| x + y).minmax().into_option().unwrap();
    let tmm = p.iter().map(|(x, y)| x - y).minmax().into_option().unwrap();
    let ans = (smm.1 - smm.0).max(tmm.1 - tmm.0);

    println!("{}", ans);
}


Measured memory_bytes: 8928
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    let (n, m) = get!(i64, i64);
    let mut ans: i64 = -1;
    let mut x = 1;
    loop {
        if x * x > m {
            break;
        }
        if m % x == 0 {
            let y = m / x;

            if ans < x && n <= y {
                ans = x;
            }
            if ans < y && n <= x {
                ans = y;
            }
        }
        x += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

//#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int A,B;
	cin >> A>>B;
	print(max(0,A-2*B));
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n,t;
	scanf("%lld%lld",&n,&t);
	ll ans=1e10;
	rep(i,0,n){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		if(y<=t)ans=min(ans,x);
	}
	if(ans==1e10)puts("TLE");
	else printf("%lld",ans);
}

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

using namespace std;

const int MaxN = 100005;
const int Mod = 1000000007;

int n, k;
int a[105];
int dp[105][MaxN], ps[105][MaxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i <= k; i++)
    {
        ps[0][i] = 1;
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        dp[i][0] = 1;
        ps[i][0] = 1;
        for (int j = 1; j <= k; j++)
        {
            dp[i][j] = (ps[i - 1][j] - (j > a[i] ? ps[i - 1][j - a[i] - 1] : 0) + Mod) % Mod;
            ps[i][j] = (ps[i][j - 1] + dp[i][j]) % Mod;
        }
    }
    cout << dp[n][k];
    return 0;
}

Measured memory_bytes: 82072
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }



long long N;
string S;
int P;

long long solve() {
    if (P == 2 || P == 5) {
        long long res = 0;
        for (int i = 0; i < N; ++i) if ((S[N-i-1]-'0') % P == 0) res += N-i;
        return res;
    }
    vector<long long> val(P, 0);
    long long tenfactor = 1;
    long long cur = 0;
    val[cur]++;
    for (int i = 0; i < N; ++i) {
        cur = (cur + (S[N-i-1]-'0') * tenfactor) % P;
        tenfactor = (tenfactor * 10) % P;
        val[cur]++;
    }
    long long res = 0;
    for (int p = 0; p < P; ++p) res += val[p] * (val[p] - 1) / 2;
    return res;
}

int main() {
    cin >> N >> P >> S;
    cout << solve() << endl;
}


















Measured memory_bytes: 640
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,d = na()
xx = []
for i in range(n):
    x = na()
    xx.append(x)

import itertools
import math

ans = 0

nums = range(n)
for a,b in itertools.combinations(nums, 2):
    c = 0
    for j in range(d):
        c += (xx[a][j]-xx[b][j])**2
    ans = ans+1 if round(math.sqrt(c))**2 == c else ans

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<int,int> P;

int dr[4] = {1,0,-1,0};
int dc[4] = {0,1,0,-1};

int r, c, m;
vector<int> t[50][50];
char brd[50][50];
int x[3][50][50];


queue<P> que;
int dist[50][50];

int main(){
	cin >> r >> c >> m;
	rep(i,r) rep(j,c){
		cin >> brd[i][j];
	}
	rep(i,3) rep(j,r) rep(k,c) cin >> x[i][j][k];
	P st;
	int ti = 0;
	rep(i,m){
		P en;
		cin >> en.first >> en.second;
		if(i == 0){
			st = en;
			t[st.first][st.second].push_back(ti);
			continue;
		}
		rep(j,r) rep(k,c) dist[j][k] = INF;
		dist[st.first][st.second] = 0;
		que.push(st);
		while(true){
			if(que.size() == 0) break;
			P q = que.front();
			que.pop();
			rep(i,4){
				if(0>q.first+dr[i]||q.first+dr[i]>=r) continue;
				if(0>q.second+dc[i]||q.second+dc[i]>=c) continue;
				if(brd[q.first+dr[i]][q.second+dc[i]] == '#') continue;
				if(dist[q.first+dr[i]][q.second+dc[i]] != INF) continue;
				dist[q.first+dr[i]][q.second+dc[i]] = dist[q.first][q.second]+1;
				que.push(P(q.first+dr[i],q.second+dc[i]));
			}
		}
		int rr = en.first, cc = en.second;
		while(true){
			if(dist[rr][cc] == 0) break;
			t[rr][cc].push_back(ti+dist[rr][cc]);
			rep(i,4){
				if(0>rr+dr[i]||rr+dr[i]>=r) continue;
				if(0>cc+dc[i]||cc+dc[i]>=c) continue;
				if(dist[rr+dr[i]][cc+dc[i]] == dist[rr][cc]-1){
					rr += dr[i];
					cc += dc[i];
					break;
				}
			}
		}
		ti += dist[en.first][en.second];
		st = en;
	}
	long long ans = 0;
	long long dp[2][1000];
	rep(i,r) rep(j,c){
		if(t[i][j].size() == 0) continue;
		if(t[i][j].size() == 1){
			ans += x[1][i][j]+x[2][i][j];
			continue;
		}
		rep(k,2) rep(u,1000) dp[k][u] = INF;
		rep(k,t[i][j].size()){
			if(k == 0){
				dp[0][0] = x[1][i][j]+x[2][i][j];
				dp[1][0] = x[1][i][j]+x[0][i][j]*(t[i][j][1]-t[i][j][0]);
				continue;
			}
			dp[0][k] = min(dp[0][k-1]+x[1][i][j]+x[2][i][j],dp[1][k-1]+x[2][i][j]);
			if(k != t[i][j].size()-1) dp[1][k] = min(dp[0][k-1]+x[1][i][j],dp[1][k-1])+x[0][i][j]*(t[i][j][k+1]-t[i][j][k]); 
		}
		ans += dp[0][t[i][j].size()-1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 6288
n = int(input())
L = [input() for i in range(n)]

LL = set(L)
if len(LL) != n:
    print('No')
    exit()
    
for i in range(n-1):
    if L[i][-1] != L[i+1][0]:
        print('No')
        exit()
else:
    print('Yes')

Measured memory_bytes: 9180
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderTest
{
    public class ABC163A
    {
        public static int readLineAsInt()
        {
            var line = Console.ReadLine();
            return int.Parse(line);
        }

        public static List<int> readLineAsListOfInt()
        {
            var line = Console.ReadLine();
            return line.Split(' ').Select(x => int.Parse(x)).ToList();
        }

        public static List<List<int>> readLinesAsTableOfInt(int N)
        {
            var ret = new List<List<int>>();
            for (int i=0; i<N; ++i)
                ret.Add(readLineAsListOfInt());

            return ret;
        }

        public static List<int> readLinesAsListOfIntFromColumn(int N)
        {
            var ret = new List<int>();
            for (int i = 0; i < N; ++i)
                ret.Add(readLineAsListOfInt()[0]);

            return ret;
        }

        static void Main(string[] args)
        {
            var N = readLineAsInt();
            var res = core(N);

            Console.Write(res);
        }

        static string core(int N)
        {
            var enshu = (double)(N * 2) * Math.PI;
            return enshu.ToString();
        }

    }
}


Measured memory_bytes: 18640
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
int main() {
	double a, b,t,r;
	cin >> a >> b;
	if (a < b) {
		t = a;
		a = b;
		b = t;
	}
	int x = a, y = b;
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	printf("%.0f", (a * b) / y);

	return 0;

}

Measured memory_bytes: 256
//
//  abc150_a.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll INF = 1000000007;
#define PI 3.14159265

const int MAX = 110000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i=2; i<MAX; i++) {
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll COM(int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k]* finv[n-k] % mod) % mod;
}

ll HCOM(int n, int k) {
    return (n == 0 && k == 0) ? 1 : COM(n+k-1, k);
}


int main() {
  int k, x;
  std::cin >> k >> x;
  if (k*500 >= x) {
    std::cout << "Yes" << std::endl;
  }
  else {
    std::cout << "No" << std::endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
  int a, b;
  cin >> a >> b;

  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }

  return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int N, K;
	cin >> N >> K;
	vec(A);
	fx(N) {
		vecp(A);
	}
	sorts(A);
	int ans = 0;
	fx(K) {
		ans += A[x];
	}
	ce(ans)
    return 0;
}



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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n, a = 1, b = 1, c = 1;
	cin >> n;
	f(i, 1, n) {
		a = (a % MOD * 10 % MOD) % MOD;
		b = (b % MOD * 9 % MOD) % MOD;
		c = (c % MOD * 8 % MOD) % MOD;
	}
	ll ans = (a - 2 * b + c) % MOD;
	ans = (ans + MOD) % MOD;
	cout << ans << endl;
	// read the stuff at the bottom
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* use int when constraints limits are tight
	* Time taken : global variable < pass by refernce < pass by value
	* It takes significant amt. of time in pass by value
	* Avoid Using endl
*/





























Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	ll n,k; cin >> n >> k ;
	vector<ll> a(n); rep(i,n) cin >> a[i];
	vector<ll> f(n); rep(i,n) cin >> f[i];
	SORT(a);
	SORT(f);
	reverse(f.begin(),f.end());
	ll l=-1; ll r=1e12+1;
	while(l+1<r){
		ll c = (l+r)/2;
		ll sum = 0;
		rep(i,n) sum += max(0ll,a[i]-c/f[i]);
		if(sum<=k) r=c; else l=c;
	}
	out(r);
}




Measured memory_bytes: 3328
#include <cstdio>
using namespace std;

class Point {
public:
    int x, y;
    Point(int x = 0, int y = 0) : x(x), y(y) {
    }
};

class Vector {
public:
    int x, y;
    Vector(int x = 0, int y = 0) : x(x), y(y) {
    }
};

bool isParallel( Vector v0, Vector v1 ) {
    return ( ( v0.x * v1.y - v0.y * v1.x ) == 0 );
}

bool isOrthogonal( Vector v0, Vector v1 ) {
    return ( ( v0.x * v1.x + v0.y * v1.y ) == 0 );
}


int q;

int main()
{
    Point p0, p1, p2, p3;
    Vector v0, v1;

    scanf("%d", &q);

    for ( int i = 0; i < q; i++ ) {
    scanf("%d %d", &p0.x, &p0.y);
    scanf("%d %d", &p1.x, &p1.y);
    scanf("%d %d", &p2.x, &p2.y);
    scanf("%d %d", &p3.x, &p3.y);

    v0.x = p0.x - p1.x;
    v0.y = p0.y - p1.y;
    v1.x = p2.x - p3.x;
    v1.y = p2.y - p3.y;

    if ( isParallel( v0, v1 ) ) printf("2\n");
    else if ( isOrthogonal( v0, v1 ) ) printf("1\n");
    else printf("0\n");
    }

    return 0;
}

Measured memory_bytes: 2688
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), greater<type>())
#define SORTF(a, comp) sort(ALL(a), comp)
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) (lower_bound(ALL(a), (x)) - a.begin())
#define bisect_right(a, x) (upper_bound(ALL(a), (x)) - a.begin())
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUT2(a) REPx(&x, a) INPUT(x);
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define ENDL cout << endl;

const int INF = 2e9;
// const LL INF = 9e18;
const LL MOD = 1e9+7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
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;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s, t;
  cin >> n >> s >> t;
  REP(int, i, n)
  {
    string a = "", b = "";
    REP2(int, j, i, n) a += s[j];
    REP(int, j, n-i) b += t[j];
    if (a == b)
    {
      cout << n + i << endl;
      return 0;
    }
  }
  cout << 2*n << endl;

  return 0;
}


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

int d[100005][3],s,t,n,m;
vector<int> g[100005];
queue<pair<int,int> >q;
signed main(){
	cin >> n >> m;
	for(int i = 1 ; i <= m ; i ++){
		int u,v;
		cin >> u >> v;
		g[u].push_back(v);
	}
	cin >> s >> t;
	q.push({s, 0});
	while(q.size()){
		int u = q.front().first, dis = q.front().second;
		q.pop();
		if(d[u][dis%3]) continue;
		d[u][dis%3] = 1;
		if(u == t && dis%3 == 0){
			cout << dis/3;
			return 0;
		}
		for(int v:g[u])
			if(!d[v][(dis+1)%3])
				q.push({v, dis + 1});
	}
	cout << -1;
}

Measured memory_bytes: 8704
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

struct unionfind{
  vector<int> par;
  vector<int> rank;
  unionfind(int n=1){
    init(n);
  }
  void init(int n=1){
      par.resize(n); rank.resize(n);
      for(int i=0;i<n;++i) par[i]=i,rank[i]=0;
  }
  int root(int x){
    if(par[x]==x){
      return x;
    }
    else{
      int r=root(par[x]);
      return par[x]=r;
    }
  }
  bool issame(int x,int y){
    return root(x)==root(y);
  }
  bool merge(int x,int y){
    x=root(x); y=root(y);
    if(x==y) return false;
    if(rank[x]<rank[y]) swap(x,y);
    if(rank[x]==rank[y]) ++rank[x];
    par[y]=x;
    return true;
  }
};

int main(){
  int n,m; cin >> n >> m;
  unionfind uf(n);
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    a--; b--;
    uf.merge(a,b);
  }
  map<int,int> mp;
  rep(i,n){
    mp[uf.root(i)]++;
  }
  cout << mp.size() << endl;
}

Measured memory_bytes: 5760
#include<stdio.h>
int main(){
    int s, m, h,a;
    scanf("%d", &a);
    h=a/3600;
    a=a%3600;
    m=a/60;
    s=a%60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}


Measured memory_bytes: 2048
N,M,*P = $<.read.split.map &:to_i
C = [1]*(N+1)
A = C.map {[]}
P.each_slice(2).map{|s| a,b = s; a<b ? s : [b,a]}.sort!.each{|a,b| A[a] << b}
1.upto(N) {|i|
  j = (a=A[i]).map{A[_1][-1] || _1}.max
  next  unless j &.> i
  a.each {b=A[_1]; b << j  if b[-1]!=j}
  C[j] += C[i]
}
p C.max

Measured memory_bytes: 62576
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))

cnt = []
pos_c = 0
for pos_b in range(n):
    while pos_c < n and c[pos_c] <= b[pos_b]:
        pos_c += 1
    cnt.append(n - pos_c)

sum_cnt = [0] * (n+1)
sum_cnt[n-1] = cnt[n-1]
for i in range(n-2, -1, -1):
    sum_cnt[i] = sum_cnt[i+1] + cnt[i]

res = 0
pos_b = 0
for pos_a in range(n):
    while pos_b < n and b[pos_b] <= a[pos_a]:
        pos_b += 1
    res += sum_cnt[pos_b]

print(res)

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

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    int r = 0;
    int w = 0;
    for (char i : s) {
        if (i == 'R') r++;
        else w++;
    }
    int bad_stone = 0;
    for (int i = 0; i < r; ++i) {
        if (s[i] == 'W') bad_stone++;
    }
    cout << bad_stone << endl;
}


Measured memory_bytes: 3736
from operator import itemgetter
N = int(input())
P = list(map(int, input().split()))

# とりあえずBを決定しておいて、Aを良い感じに決める
# BはN間隔にすると良い感じになる
A = [-1] * N
B = [N * i for i in range(1, N + 1)][::-1]

for i, p in enumerate(P):
    p -= 1
    if i == 0:
        A[p] = (p + 1) * N
        AB = A[p] + B[p]
        continue
    A[p] = AB - B[p] + 1
    AB = A[p] + B[p]

print(*A)
print(*B)


Measured memory_bytes: 6340
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=100005;
int n;
int a[MAXN];
int b[MAXN],c[MAXN],d[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int ans=n;
	for(int i=1;i<=n;i+=2)
		b[a[i]]++;
	for(int i=2;i<=n;i+=2)
	{
		c[a[i]]++;
		d[a[i]]++;
	}
	for(int i=99999;i>=1;i--)
		c[i]=max(c[i+1],c[i]);
	for(int i=2;i<=100000;i++)
		d[i]=max(d[i],d[i-1]);
	ans=min(n-b[1]-c[2],n-b[100000]-d[99999]);
	for(int i=2;i<=99999;i++)
		ans=min(ans,n-b[i]-max(c[i+1],d[i-1]));
	printf("%d\n",ans);
}

Measured memory_bytes: 1664
N, M = map(int, input().split())
E = []
for _ in range(M):
    a, b = map(int, input().split())
    E.append((a, b))

E = sorted(E)

P = -1

def unionFind(E):
    parent = [i for i in range(N+1)]
    def root(a):
        p = a
        while parent[p] != p:
            p = parent[p]
        parent[a] = p
        return p
        
    for a, b in E:
        pa = root(a)
        pb = root(b)
        if pa < pb:
            parent[pb] = pa
        elif pa > pb:
            parent[pa] = pb

    for i in range(1, N+1):
        root(i)
    return max(parent)

def main():
    bridge = 0
    if M == 1:
        print(1)
    else:
        for i in range(0, M):
            if unionFind(E[:i]+E[i+1:]) != 1:
                bridge += 1
        print(bridge)
main()


Measured memory_bytes: 3064
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++) 
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 3e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
vi vertices[sze];
vi visit(sze, 0);
vc used(sze, false);
vi arr(sze, 0);
int n, m, k;
int A, B;
int cnt = 0;

int dp[10010][110];
int dpe[10010][110][2];


signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("stars.in", "r", stdin);
	freopen("stars.out", "w", stdout);*/

	string s;
	cin >> s >> m;
	n = SZ(s);

	for (int i = 1; i <= 9; i++)
	{
		dp[1][i % m] ++;
	}

	for (int i = 2; i < n; i++)
	{
	for (int j = 0; j < m; j++)
	{
	for (int z = 0; z <= 9; z++)
	{
		int y = (j + z) % m;
		dp[i][y] = (dp[i - 1][j] + dp[i][y]);
		if (dp[i][y] >= mod)
			dp[i][y] -= mod;
	}
	}
	}

	int ans = 0;
	for (int i = 1; i < n; i++)
	{
		ans = (ans + dp[i][0]);
		if (ans >= mod)
			ans -= mod;
	}

	for (int i = 1; i < s[0] - '0'; i++)
	{
		dpe[0][i % m][0]++;
	}
	dpe[0][(s[0] - '0') % m][1]++;

	for (int i = 1; i < n; i++)
	{
	for (int z = 0; z < m; z++)
	{
		for (int a = 0; a < s[i] - '0'; a++)
		{
			int y = (z + a) % m;
			dpe[i][y][0] = (dpe[i][y][0] + dpe[i - 1][z][1]);
			if (dpe[i][y][0] >= mod)
				dpe[i][y][0] -= mod;
		}

		for (int a = 0; a <= 9; a++)
		{
			int y = (z + a) % m;
			dpe[i][y][0] = (dpe[i][y][0] + dpe[i - 1][z][0]);
			if (dpe[i][y][0] >= mod)
				dpe[i][y][0] -= mod;
		}

		int x = s[i] - '0';
		int y = (z + x) % m;
		dpe[i][y][1] = (dpe[i][y][1] + dpe[i - 1][z][1]);
		if (dpe[i][y][1] >= mod)
			dpe[i][y][1] -= mod;
	}
	}

	for (int b = 0; b < 2; b++)
	{
		ans = (ans + dpe[n - 1][0][b]);
		if (ans >= mod)
			ans -= mod;
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 38144
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] arr = sc.next().toCharArray();
		int[] counts = new int[26];
		for (char c : arr) {
		    if (c != '+') {
		        counts[c - 'a']++;
		    }
		}
		Arrays.sort(counts);
		int prev = counts[25];
		int cnt = 1;
		int total = 0;
		if (prev == 1) {
		    prev = 0;
		    total += 2;
		}
		for (int i = 24; i >= 0 && counts[i] > 0; i--) {
		    if (prev == counts[i]) {
		        cnt++;
		    } else {
		        if (prev == 0) {
		            total += 2;
		        } else {
		            if (cnt >= 2) {
		                total += 4 + cnt * 2;
		            } else {
		                total += 4;
		            }
		            cnt = 1;
		            if (counts[i] == 1) {
		                prev = 0;
		                total += 2;
		            } else {
		                prev = counts[i];
		            }
		        }
		    }
		}
		if (prev != 0) {
            if (cnt >= 2) {
                total += 4 + cnt * 2;
            } else {
                total += 4;
            }
		}
		System.out.println(total - 1);
	}
}



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

int main() {
	ll a, b, n, ans = 0;	cin >> n >> a >> b;
	ans = n / (a + b);
	ans = ans * a;
	ll temp = n % (a + b);
	if (temp < a) {
		cout << ans + temp << endl;
	}	else {
		cout << ans + a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
struct UnionFind {
    vector<int> par, w;
    
    UnionFind(int n) : par(n, -1), w(n, 0) { }
    void init(int n) { par.assign(n, -1); w.assign(n, 0); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) {
            ++w[x];
            return false;
        }
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        w[x] += w[y];
        ++w[x];
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
 
    int wei(int x) {
        return w[root(x)];
    }
};

void _main()
{
    int N;
    cin >> N;
    vector<ll> x(N), y(N);
    map<pair<ll, ll>, int> m;
    rep(i, 0, N)
    {
        cin >> x[i] >> y[i];
        m[make_pair(x[i], y[i])] = i;
    }

    if (N == 1)
    {
        cout << 1 << endl;
        return;
    }

    int ans = 1 << 30;
    rep(i, 0, N)
    {
        rep(j, 0, N)
        {
            if (i == j) continue;

            const ll p = x[j] - x[i];
            const ll q = y[j] - y[i];

            UnionFind uf(N);
            rep(k, 0, N)
            {
                const ll xx = x[k] + p;
                const ll yy = y[k] + q;

                auto it = m.find(make_pair(xx, yy));

                if (it == m.end()) continue;

                uf.merge(k, it->second);
            }

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

            chmin(ans, static_cast<int>(s.size()));
        }
    }
    
    cout << ans << endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n;
	cin >> n;
	vector<int> a(n + 1, 0);
	for(int i = 1; i <= n; ++i)
	{
		cin >> a[i];
	}

	// 1は考えなくていい
	// 半分以降は決まり：倍数が1つだけ
	// 前半の半分について考える
	bitset<200000 + 1> ball;
	for(int i = n / 2 + 1; i <= n; ++i)
	{
		ball[i] = a[i];
	}

	for(int i = n / 2; i >= 1; --i)
	{
		int next_b = a[i];
		for(int j = i * 2; j <= n; j += i)
		{
			next_b ^= ball[j];
		}
		ball[i] = next_b;
	}

	cout << ball.count() << endl;
	for(int i = 1; i <= n; ++i)
	{
		if (ball[i]) cout << i << " ";
	}

}

int main()
{
	fastio;
	solve();

	return 0;
}

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

int main() {
	// your code goes here
	char c;
	cin>>c;
	if(c>='a'&&c<='z')
	{
	    cout<<'a'<<endl;
	}
	else
	{
	    cout<<'A'<<endl;
	}

}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <numeric>
using namespace std;
#define ll long long int
#define ld long double
#define vi vector<ll>
#define di deque<ll>
#define vvi vector<vi>
#define vs vector<string>
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define fs first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
#define mxn (ll)1e5
#define INF = 1e18L + 5;
int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;

    ll sum = 0;
    if(k>a){
        k -= a;
        sum += a;
        k -= b;
        if(k){
            sum -= k;
        }
    }
    else{
        sum += k;
    }

    cout<<sum<<endl;

}

Measured memory_bytes: 3192
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int n;
int x, y;
int tm = 0;

int main() { 

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    int xx, yy, tt;
    scanf("%d %d %d", &tt, &xx, &yy);
    int dist = abs(xx - x) + abs(yy - y);
    int timeDiff = tt - tm;
    if (timeDiff < dist) {
      puts("No");
      return 0;
    }
    timeDiff -= dist;
    if (timeDiff > 0 && (timeDiff & 1)) {
      puts("No");
      return 0;
    }
    x = xx; y = yy;
    tm = tt;
  }

  puts("Yes");

  return 0;
}


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

int main(){
	int n;
	vector<int> vi , vi2;
	while(cin >> n){
		vi.clear();
		vi2.clear();
		if(n == 0) break;
		for(int i = 0; i < n; i++){
			int j;
			cin >> j;
			vi.push_back(j);
		}
		int counter = -1;
		do{
			vi2.clear();
			copy(vi.begin(), vi.end(), back_inserter(vi2));
			for(int i = 0; i < n; i++){
				vi[i] = count(vi2.begin(), vi2.end(), vi[i]);
			}
			counter++;
		}while(!equal(vi.begin(), vi.end(), vi2.begin()));
		cout << counter << endl;
		for(int i = 0; i < vi.size(); i++){
			if(i != 0) cout << " ";
			cout << vi[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int main() {
 
  int64_t N,m=-10,ans=0;
  cin>>N;
  vector<int64_t> A(N);
  for(int i=0; i<N; i++){
    
    cin>>A[i];
    if(m>A[i]){ans+=m-A[i];
    // cout<<m-A[i]<<endl;
    }
    m=max(A[i],m);
    }
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){
  //   for(int j=0; j<M; j++){
  //       cin>>A[i][j];
  //   }
  // }
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << ans << endl;
}

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

int main() {
	int n;
	cin>>n;
	vector<int> A(n);
	for(int i=0;i<n;i++)cin>>A[i];
	
	vector<int> dp(n);
	dp[n-1]=0;
	dp[n-2]=abs(A[n-1]-A[n-2]);
	for(int i=n-3;i>=0;i--)
	dp[i]=min(
		abs(A[i]-A[i+1])+dp[i+1],
		abs(A[i]-A[i+2])+dp[i+2]
		);
	cout<<dp[0]<<endl;
}

Measured memory_bytes: 4056
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while (cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while (1) {
    if (cur == nil) break;
    if (isf++ > 0) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if (t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deletekKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main() {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for (i = 0; i < n; i++) {
    scanf("%s%d", com, &key);
    if (com[0] == 'i') {
      insert(key);
      np++;
      size++;
    } else if (com[0] == 'd') {
      if (strlen(com) > 6) {
        if (com[6] == 'F') deleteFirst();
        else if (com[6] == 'L') deleteLast();
      } else {
        deletekKey(key);
        nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}


Measured memory_bytes: 33836
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

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

  vector<string> str(n);
  map<string, ll> ans;

  for(int i=0; i<n; ++i){
    cin >> s;
    sort(s.begin(), s.end());
    ans[s]++;
  }
  ll sum = 0;

  for(auto e:ans){
    ll tmp = e.second*(e.second-1)/2;
    sum += tmp;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 12032
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
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 bin_out(aa):
    bb = [format(a, "b") for a in aa]
    print(bb)

def main():
    h, w = MI()
    aa = LLI(h)
    bb = LLI(h)
    max_val=6400
    zero = 1 << max_val
    dp = [0] * w
    dp[0] = zero
    #bin_out(dp)
    for i, (ar, br) in enumerate(zip(aa, bb)):
        for j, (a, b) in enumerate(zip(ar, br)):
            d = abs(a - b)
            if j > 0: dp[j] |= dp[j - 1]
            dp[j] = dp[j] << d | dp[j] >> d
        #bin_out(dp)
    goal = dp[-1]
    for ans in range(max_val + 1):
        if goal & zero << ans or goal & zero >> ans:
            print(ans)
            break

main()


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

int main(){
  
  string a, b, c;
  
  cin >> a >> b >> c;
  
  if (a.at(a.size() - 1) == b.at(0) && b.at(b.size() - 1) == c.at(0)){
   cout << "YES" << endl;
    
  }else{
    
    cout << "NO" << endl;
    
  }
  
}

Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			String S = scan.next();
			
			int N = S.length();
			
			String[]n = new String[N-1];
			
			long ans = 0;
			
			for(int i = 0;i<(int)Math.pow(2, N-1);i++) {
				Arrays.fill(n, "");
				for(int j = 0;j<N-1;j++) {
					if((1&i>>j)==1) {
						n[j] = "+";
					}
				}
				
				StringBuffer sb = new StringBuffer();
				char[]s = S.toCharArray();
				sb.append(s[0]);
				for(int j = 0;j<N-1;j++) {
					sb.append(n[j]);
					sb.append(s[j+1]);
				}
				//System.out.println(sb.toString());
				
				String H = sb.toString();
				long goukei = 0;
				int start = 0;
				
				for(int j = 0;j<H.length();j++) {
					String B = H;
					if(H.substring(j, j+1).equals("+")) {
						goukei+=Long.valueOf(B.substring(start, j));
						start = j+1;
					}else if(j==H.length()-1) {
						goukei+=Long.valueOf(B.substring(start, j+1));

					
				}
				}
				
				ans+=goukei;
				/*
				System.out.print(goukei);
				System.out.print(" ");
				
				System.out.println(H);
				
				*/
				
				
				
				
			}
			
			
			
			
			System.out.println(ans);
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  string s, ss;
  cin >> s >> ss;
  int a = s.size();
  rep(i, 0, a){
    if(s[i] != ss[i]){
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
}

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

using namespace std;

typedef long long ll;

string s;
int main()
{
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> s;

    if (s[2] == s[3] && s[4] == s[5]){
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
 
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int dp[105][105];
char G[105][105];
int main() {
	int H, W;
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; ++i) scanf("%s", G[i]);
	dp[0][0] = G[0][0] == '#';
	for (int i = 0; i < H; ++i)
		for (int j = 0; j < W; ++j) {
			if (!i && !j) continue;
			dp[i][j] = INT_MAX;
			if (i) {
				dp[i][j] = min(dp[i][j], dp[i - 1][j] + (G[i][j] == '#' && G[i - 1][j] == '.'));
			}
			if (j) {
				dp[i][j] = min(dp[i][j], dp[i][j - 1] + (G[i][j] == '#' && G[i][j - 1] == '.'));
			}
		}
	printf("%d\n", dp[H - 1][W - 1]);
}


Measured memory_bytes: 256