akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 51;
int n, a[N], b[N], can[N][N];
int dp[N][N], bad[N];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        can[i][a[i]] = 1;
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    ll ans = 0;
    for (int i = N; i > 0; i--) {
        bool ok = true;
        memset(& bad, 0, sizeof(bad));
        for (int j = 0; j < n; j++) {
            memset(& dp, 0, sizeof(dp));
            for (int k = 0; k < N; k++) {
                dp[i - 1][k] = can[j][k];
            }
            for (int k = i - 1; k > 0; k--) {
                for (int l = 0; l < N; l++) {
                    dp[k - 1][l] |= dp[k][l];
                    dp[k - 1][l % k] |= dp[k][l];
                }
            }
            if (!dp[0][b[j]]) {
                bad[j] = 1;
                ok = false;
            }
        }
        if (ok) {
            continue;
        }
        if (i == N) {
            cout << -1;
            return 0;
        }
        for (int j = 0; j < n; j++) {
            for (int k = i; k < N; k++) {
                can[j][k % i] |= can[j][k];
                if (bad[j]) {
                    can[j][k] = 0;
                }
            }
        }
        ans |= (1LL << i);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <math.h>

using namespace std;

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

  string s;
  cin >> s;

  string ans;
  if (s == "A") {
    ans = "T";
  }
  else if (s == "T") {
    ans = "A";
  }
  else if (s == "C") {
    ans = "G";
  }
  else if (s == "G") {
    ans = "C";
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


N = int(input())
pt, px, py = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    d = abs(x - px) + abs(y - py)
    # print(t, d)
    if t - pt < d or (t - pt - d) % 2 != 0:
        print("No")
        sys.exit()
    pt = t
    px = x
    py = y
print("Yes")



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>


#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

struct P {
	int  i;
	int  s;
};

struct E {
	int a;
	int i;
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, m; cin >> n >> m;
	vector<P> ps(n + 1);
	FOR_LE(i, 1, n) {
		ps[i].i = i;
		cin >> ps[i].s;
	}
	vector<P> pss = ps;
	sort(ps.begin(), ps.end(), [](const auto& lhs, const auto& rhs) {
		return lhs.s < rhs.s;
	});

	vector<vector<E>> es(n + 1);
	FOR_LT(i, 0, m) {
		int a, b; cin >> a >> b;
		es[a].push_back({ b, i });
		es[b].push_back({ a,i });
	}

	vector<int> ess(m);
	vector<int> pbs(n + 1);

	FOR_LE(i, 1, n) {
		P& cp = ps[i];
		int a = cp.i;
		if (pbs[a] != 0) continue;

		bool has_peer = false;
		int  peer_i   = 0;
		int  peer_ei = -1;
		bool has_pair = false;
		for (auto& e : es[a]) {
			if (pbs[e.a] != 0) {
				has_peer = true;
				peer_i = e.a;
				peer_ei = e.i;
				break;
			}
			
			if (pss[e.a].s == cp.s) {
				has_pair = true;
				peer_i = e.a;
				peer_ei = e.i;
			}
		}

		if (!has_peer && !has_pair) {
			cout << -1 << endl;
			return 0;
		}

		if (has_peer) {
			pbs[a] = (pbs[peer_i] == 1) ? 2 : 1;
			ess[peer_ei] = cp.s;
		}
		else {
			pbs[a] = 1;
			pbs[peer_i] = 2;
			ess[peer_ei] = cp.s;
		}
	}

	FOR_LE(i, 1, n) {
		cout << (pbs[i] == 1 ? "B" : "W");
	}
	cout << endl;
	FOR_LT(i, 0, m) {
		cout << ((ess[i] != 0) ? ess[i] : 1000000000) << endl;
	}

	return 0;
}


Measured memory_bytes: 13184
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  
  bool memo[110];
  for (int i = 0; i <= 100; i++) memo[i] = false;
  memo[0] = true;
  
  for (int i = 1; i <= 100; i++) {
    if (i >= 4) memo[i] |= memo[i - 4];
    if (i >= 7) memo[i] |= memo[i - 7];
  }
  
  cout << (memo[N] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline
def one(D, S):
    d = {"A":0, "B":1, "C":2}
    ANS = []
    for a, b in S:
        x = d[a]
        y = d[b]
        if D[x] == 0 and D[y] == 0:
            print("No")
            return
        if D[x] == 0:
            D[x] += 1
            D[y] -= 1
            ANS.append(a)
        else:
            D[x] -= 1
            D[y] += 1
            ANS.append(b)
    print("Yes")
    print("\n".join(ANS))
            
def two(D,S,N):
    d = {"A":0, "B":1, "C":2}
    e = {0:"A", 1:"B",2:"C"}
    ANS = []
    for i in range(N):
        a, b = S[i]
        x = d[a]
        y = d[b]
        if D[x] == 0 and D[y] == 0:
            print("No")
            return
        if D[x] == 0:
            D[x] += 1
            D[y] -= 1
            ANS.append(a)
        elif D[y] == 0: 
            D[x] -= 1
            D[y] += 1
            ANS.append(b)
        else: #(1,1)
            if i+1 > N-1:
                D[x] += 1
                D[y] -= 1
                ANS.append(a)
                continue
            if S[i] == S[i+1]:
                D[x] += 1
                D[y] -= 1
                ANS.append(a)
                continue
            if not a in S[i+1]:
                x,y = y, x
                a, b = b,a
            D[x] += 1
            D[y] -= 1
            ANS.append(a)
    print("Yes")
    print("\n".join(ANS))
    
def main():
    N, A, B, C = map( int, input().split())
    S = [ tuple( input()) for _ in range(N)]
    d = {"A":0, "B":1, "C":2}
    D = [A,B,C]
    ANS = []
    if sum(D) == 1:
        one(D, S)
        return
    if sum(D) == 2:
        two(D,S,N)
        return
    for a, b in S:
        x = d[a]
        y = d[b]
        if D[x] == 0 and D[y] == 0:
            print("No")
            return
        if D[x] == 0:
            D[x] += 1
            D[y] -= 1
            ANS.append(a)
        elif D[x] == 1:
            if D[y] == 0:
                D[x] -= 1
                D[y] += 1
                ANS.append(b)
            else:
                D[x] += 1
                D[y] -= 1
                ANS.append(a)
        else:
            D[x] -= 1
            D[y] += 1
            ANS.append(b)

    print("Yes")
    print("\n".join(ANS))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 17304
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    int n,k;
    ll ans=0;
    cin>>n>>k;
    for(int i=k+1;i<=n;i++){
        //cout<<((n/i)*(i-k)+max(0,n-(n/i)*i-k+1))<<endl;
        //cout<<i<<" "<<((n%i?n-(n/i)*i-k+1:0)-(k==0&&(n%i!=0)?1:0))<<" "<<(n/i)*(i-k)<<endl;
        //ans+=(n/i)*(i-k)+((n%i?n-(n/i)*i-k+1:0)-(k==0&&(n%i!=0)?1:0));
        //ans+=(n/i)*(i-k)+(n%i?n-(n/i)*i-k:0);
        // ans+=(n/i)*(i-k)
        // for(int j=(n/i)*i+1;j<=n;j++){
            
        // }
        //ans+=((n%i?max(n-n/i*i-k+1,0):0)+(k==0&&(n%i?max(n-n/i*i-k+1,0):0)!=0?-1:0))+(n/i)*(i-k);
        //cout<<i<<" "<<((n%i?max(n-n/i*i-k+1,0):0)+(k==0&&(n%i?max(n-n/i*i-k+1,0):0)!=0?-1:0))<<endl;
        ans+=(n/i)*(i-k)+max(n-n/i*i-(k?k-1:k),0);
        //cout<<i<<" "<<max(n-n/i*i-(k?k-1:k),0)<<endl;
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

typedef complex<int> POINT;
template <class T>
class vevector : public vector<vector<T>>
{
public:
	using vector<vector<T>>::operator []; 
	T& operator [](const POINT &index) { return (*this)[index.real()][index.imag()]; }
};

template <class T> T read() { T t; cin >> t; return t; }
template <> POINT read<POINT>() { int x, y; cin >> x >> y; return POINT(x, y); }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vevector<T> read(int n, int m) { vevector<T> v; REP(i,n) v.push_back(read<T>(m)); return v; }
template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }

template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__

void solve();
int main() { solve(); return 0; }

vector<unsigned char> isPrime;
vector<int> primes;
void initPrimes(int n)
{
	isPrime = vector<unsigned char>(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	FOR(i, 2, n)
	{
		if (!isPrime[i]) continue;
		primes.push_back(i);
		for (int j = i * 2; j <= n; j += i)
			isPrime[j] = false;
	}
}
/// template end ///

void solve()
{
	initPrimes(10e6);
	while (true)
	{
		READ(int, a,d,n);
		if (!(a|d|n)) { break; }
		
		int c = 0;
		int x = a;
		while (true)
		{
			if (isPrime[x])
			{
				if (++c == n)
				{
					write(x);
					break;
				}
			}
			x += d;
		}
	}
}

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

//cout << setfill('0') << right << setw(4) << a;

int main(){
    ll n, m;
    ll p[100002], y[100002];
    cin >> n >> m;
    vector < vector < int > > v;
    v.resize(n);
    REP(i, m){
        cin >> p[i] >> y[i];
        v[p[i] - 1].push_back(y[i]);
    }
    REP(i, n)sort(v[i].begin(), v[i].end());
    jkl;
    ll pref, num;
    REP(i, m){
        pref = p[i];
        cout << setfill('0') << right << setw(6) << pref;
        auto tmp = lower_bound(v[p[i] - 1].begin(), v[p[i] - 1].end(), y[i]);
        num = tmp - v[p[i] - 1].begin() + 1;
        cout << setfill('0') << right << setw(6) << num;
        print("");
    }
}

Measured memory_bytes: 8576
char s[101],p[101];i;main(j){for(scanf("%s%s",s,p);i<strlen(s);i++){
	for(j=0;j<strlen(p);j++)if(s[(i+j)%strlen(s)]!=p[j])break;
	if(j==strlen(p))puts("Yes"),exit(0);
}puts("No"),exit(0);}

Measured memory_bytes: 524
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#define REP(i,n) for(LL i=0, i##_len=(n); i<i##_len; ++i)

int main() {
  LL L,R;
  std::cin >> L >> R;

  LL ans = 2018;
  for(LL i=L; i<R; i++) {
    for(LL j=i+1; j <= R; j++) {
      LL mod = (i * j) % 2019;
      if( mod < ans ) ans = mod;
      if( ans == 0 ) break;
    }
    if( ans == 0 ) break;
  }

  std::cout << ans << std::endl;

  return 0;
}



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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define rep(i, a, b) for (auto i = (a); i < (b); i++)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

int main() {
  string s, t;
  cin >> s >> t;
  cout << (s == t.substr(0, s.length()) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <functional>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <array>
#include <memory>
#include <set>

using namespace std;

#define Get(ty,...) ty __VA_ARGS__;cins(__VA_ARGS__);
#define GetArray(ty,v,n) vector<ty> v(n);cin_arr(v,n);
#define ci cin
#define co cout
#define en endl;
#define Arr(f, arr,pred) f(arr.begin(),arr.end(),pred)
#define Arr2(f, arr) f(arr.begin(),arr.end())
#define ArrExpr(f, arr,expr) f(arr.begin(),arr.end(),[](auto x){return expr;})
#define Acc(init,arr,pred) accumulate(arr.begin(),arr.end(),init,pred)

void cins(){}

template<class Head,class... Tail>
void cins(Head& head,Tail&... tail) {
	cin >> head;
	cins(tail...);
}

template<class Arr>
void cin_arr(Arr& v,int n) {
	for (int i = 0; i < n; i++)
		cin >> v[i];
}

long long  int  ggd(long long  int  m, long long  int  n) {
	long long int temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

long long  int  lcm(long long  int  number1, long long  int  number2) {
	return number1 * number2 / ggd(number1, number2);
}


int main() {
	Get(long long  int, a, b, c, d);
	long long int c_count = b / c - (a - 1) / c;
	long long  int d_count = b / d - (a - 1) / d;
	long long  int cd_count = b / (lcm(d,c)) - (a - 1) / (lcm( d,c));
	co << b - a + 1 - (c_count + d_count - cd_count) << en;
}




Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def main():
    N, M = map(int, input().split())
    MN = M/N
    divisor = make_divisors(M)
    max_gcd = 0
    for d in divisor:
        if (d<=MN) and (d>=max_gcd):
            max_gcd = d
    print(max_gcd)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

const long long MOD = 1000000007; 
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int dp[100010];
bool ok[100010];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	VE a(m); rep(i, m)cin >> a[i];
	rep(i, m) {
		ok[a[i]] = true;
	}
	dp[0] = 1;
	dp[1] = 1;
	FORR(i, 2, n) {
		if (!ok[i - 1])dp[i] += dp[i - 1];
		if (!ok[i - 2])dp[i] += dp[i - 2];
		dp[i] %= MOD;
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
using namespace std;
#define REP(i,n); for(int i = 0;i < (int)(n);i++)

int main() {
	long long ans=0;
	vector<pair<int,int>> a;
	int n,m,d=0;
	cin >> n >> m;
	a.resize(n);
	REP(i,n){
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin(),a.end());
	REP(i,n){
		ans += (long long)a[i].first*(long long)min(a[i].second, m-d);
		d += a[i].second;
		if(m <= d)break;
	}
	cout << ans;
	return(0);
}

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

const int mod = 1000000007;

int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a >= b){
        ans += a;
        a--;
    }else{
        ans += b;
        b--;
    }
    if (a >= b){
        ans += a;
        a--;
    }else{
        ans += b;
        b--;
    }
    cout << ans << endl;
}

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

namespace ConsoleApp16
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            if (N % 2 == 0)
            {
                Console.WriteLine("0.5");
            }
            else
            {
                Console.WriteLine(((double)(N+1) / (2*N)).ToString());
            }
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();

        int sec = s % 60;
        int min = (s / 60) % 60;
        int hou = (s / 60) / 60;

        System.out.printf("%d:%d:%d\n", hou, min, sec);
    }
}



Measured memory_bytes: 26368
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n = int(input())
red_points = [list(map(int,input().split())) for i in range(n)]
blue_points = [list(map(int,input().split())) for i in range(n)]

red_points.sort(key=lambda x:(x[1]*-1))
blue_points.sort()

blue_cursor = 0
pair_cnt = 0

for bx,by in blue_points:
    for i,(ax,ay) in enumerate(red_points):
        if ax < bx and ay < by:
            pair_cnt+=1
            red_points.pop(i)
            break

print(pair_cnt)

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

long long int a[100005],b[100005];

bool comp(const int& k1,const int& k2){
  return k1>k2;
}

int main(){

  int n;
  cin>>n;
  long long int h;
  cin>>h;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  sort(b,b+n,comp);
  int a_max=*max_element(a,a+n);
  long long int cnt=0;
  for(int i=0;i<n;i++){
    if(h<=0){
      cout<<cnt;return 0;
    }
    if(a_max>=b[i])break;
    h-=b[i];
    cnt++;
  }

  if(h>0){
    cnt+=(h/a_max);
    if(h%a_max!=0)
      cnt++;
  }
  cout<<cnt;
  return 0;
}

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int L, R;
  L = A + B;
  R = C + D;

  string res;
  if(L > R){
    res = "Left";
  } else if(R > L){
    res = "Right";
  } else {
    res = "Balanced";
  }

  cout << res << endl;
}


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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
  FAST();

  int s, w;
  cin >> s >> w;

  if(w >= s)
    cout << "unsafe\n";
  else
    cout << "safe\n";

  return 0;
}


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

int main(){
    int E,Y;
    int diff[]={0,1867,1911,1925,1988};
    char tag[5]="MTSH";
    cin >> E >> Y;
    if(E==0){
      for(int i=1;i<4;i++){
        if(Y<=diff[i+1]){
          cout << tag[i-1] << Y-diff[i] << endl;
          return 0;
        }
      }
      cout << "H" << Y-diff[4] << endl;
    }else{
      cout << Y+diff[E] << endl;
    }
    return 0;
}



Measured memory_bytes: 3136
import java.util.*;
import java.math.BigDecimal;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int L=sc.nextInt();
    if(L==1){System.out.println(0.0370370);}
    else if(L==2){System.out.println(0.0740740);}else{
    int M=L*L*L;
    double m=M/27;
    String X = BigDecimal.valueOf(m).toPlainString();
    System.out.println(X);}
  }
}


Measured memory_bytes: 21332
import sys

import numpy as np
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
"""dd = [(-1, 0), (0, 1), (1, 0), (0, -1)];
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)];
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""

def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  # SingleInt
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  # HeightString
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  # MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  # NumberGrid
def grid(n): return [s_list() for _ in range(n)]


def main():
    a,b,c,x,y = map(int,input().split())

    ans = 0
    if a + b >= c*2:
        ans += 2*c*min(x,y)
    else:
        ans += (a + b)*min(x,y)

    if x <= y:
        if b <= 2*c:
            ans += b*(y-x)
        else:
            ans += 2*c*(y-x)
    else:
        if a <= 2*c:
            ans += a*(x-y)
        else:
            ans += 2*c*(x-y)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 13416
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    int y;
    cin >> n >> y;
    
    int max_10000 = min(y/10000,n) ;
    int max_1000 = min(y/1000,n);
 
    bool valid = true;
 
    for(int i=0;i<=max_10000;i++){
        for(int j=0;j<=max_1000;j++){
            if(n-i-j<0){
                break;
            }
            if(10000*i+1000*j+5000*(n-i-j)==y){
                cout << i << " " << n-i-j << " " << j << endl;
                //cout << 10000*i+1000*j+5000*(n-i-j) << endl;
                valid = false;
                return 0;
            }
        }
    }
    if(valid){
        cout << "-1 -1 -1" << endl;
        return 0;
    }    
}

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

int main(){
ll n;
cin >> n;
ll ans = 0;
for(ll i = 1; i<= n; i++){
     ll m = floor( (double)(n/i));
      ans += i*m*(m+1) / 2;
  }
cout << ans <<endl;
 return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std ;

int main()
{
	short n[ 101 ] ;
	for( int i = 0 ; i < 12 ; i++ )
		cin >> n[ i ] ;
	sort( n ,n + 12 ) ;
	short a = n[ 0 ] ,b = n[ 4 ] ,c = n[ 8 ] ;
	short ans = 0 ;
	for( int i = 0 ; i < 4 ; i++ )
	{
		if( a == n[ i ] )
			ans++ ;
		if( b == n[ i + 4 ] )
			ans++ ;
		if( c == n[ i + 8 ] )
			ans++ ;
	}
	if( ans == 12 )
		puts( "yes" ) ;
	else
		puts( "no" ) ;
	return 0 ;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);

int k;
vll vec;
const ll X = 3234566667LL;

void dfs(string x){
    int size = x.size();
    if (size && stoll(x) > X) return;
    if (size) vec.push_back(stoll(x));
    rep(i, 10){
        if (size == 0){
            if (i != 0) dfs(x + to_string(i));
        }
        else if (abs((x[size - 1] - '0') - i) <= 1) dfs(x + to_string(i));
    }
}

int main() {
    cin >> k;
    dfs("");
    sort(all(vec));
    cout << vec[k - 1] << endl;
}

Measured memory_bytes: 4372
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b;cin>>a>>b;
  vector<ll>c(a);
  rep(i,a)cin>>c[i];
  sort(c.begin(),c.end());
  ll d=0;
  rep(i,b)d+=c[i];
  cout<<d;
}


Measured memory_bytes: 27072
package main

import (
        "fmt"
)

var paper [10][10]int

func main() {
        var x, y, s int
        for {
                _, err := fmt.Scanf("%d,%d,%d", &x, &y, &s)
                if err != nil {
                        break
                }

                fill(x, y, s)
        }
        var d, z int
        for i := 0; i < 10; i++ {
                for j := 0; j < 10; j++ {
                        if paper[i][j] == 0 {
                                z += 1
                        }
                        if paper[i][j] > d {
                                d += 1
                        }
                }
        }
        fmt.Printf("%d\n%d\n", z, d)
}

func fill(x int, y int, s int) {
        paper[x][y] += 1
        if x > 0 {
                paper[x-1][y] += 1
        }
        if x < 9 {
                paper[x+1][y] += 1
        }
        if y > 0 {
                paper[x][y-1] += 1
        }
        if y < 9 {
                paper[x][y+1] += 1
        }

        if s >= 2 {
                if x > 0 && y > 0 {
                        paper[x-1][y-1] += 1
                }
                if x > 0 && y < 9 {
                        paper[x-1][y+1] += 1
                }
                if x < 9 && y > 0 {
                        paper[x+1][y-1] += 1
                }
                if x < 9 && y < 9 {
                        paper[x+1][y+1] += 1
                }
        }

        if s > 2 {
                if x > 1 {
                        paper[x-2][y] += 1
                }
                if x < 8 {
                        paper[x+2][y] += 1
                }
                if y > 1 {
                        paper[x][y-2] += 1
                }
                if y < 8 {
                        paper[x][y+2] += 1
                }
        }
}



Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
int n,x;
int a[100005];
int cnt1 = 0, cnt2 = 0;

int main(int argc, char** argv) {
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&x);
		if(x % 4 == 0)cnt1++;
		else if(x % 2 == 0)cnt2++;
	}	
	if(cnt2 == 0) {
		int t = n / 2;
		if(cnt1 >= t)puts("Yes");
		else puts("No");
	}else {
		int t = (n - cnt2 + 1) / 2;
		if(cnt1 >= t)puts("Yes");
		else puts("No");
	}
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const ll mod  = 1e9+7;
const db eps  = 1e-9 ;
const ll maxn = 1e5+1;
const ll inf = LLONG_MAX;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cout << #x << " " << x << endl

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
    #endif


        db pi = 3.1415926;
        db r;
        cin >> r;   
        cout << setprecision(5) << fixed <<(db)2*pi*r;

    return 0;
} 

Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
 
 
const int INF = 1000000;
 

const int MAX_N = 4010;
const int MAX_M = 4010;





int main(){
	priority_queue<int> q;
	string s;
	int n;
	while(cin>>s){
		if(s=="end") break;
		if(s =="insert"){
			cin>>n;
			q.push(n);
		}
		else{
			cout<<q.top()<<endl;
			q.pop();
		}
	}
}

Measured memory_bytes: 6772
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=1e16;
int dx[]={0,1,0,-1,0,2,0,-2};
int dy[]={1,0,-1,0,2,0,-2,0};
int main(){
	int n=3;
	vi in(n);
	rep(i,n)cin>>in[i];
	sort(all(in));
	if(in[0]+in[1]==in[2])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}







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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())

string s;
int n;

int check(int k) {
	int open = 0;
	REP(i, SIZE(s)) {
		int now = (s[i]-'0' + open) % 2;
		if (now) {
			if (i + k <= n) {
				open ^= 1;
				continue;
			}
			if (i < k) return 0;
		}
	}
	return 1;
}

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

	cin >> s;
	n = SIZE(s);

	int l = 0, r = n + 1;
	while (r - l > 1) {
		int m = (l + r) / 2;
		if (check(m)) l = m; else r = m;
	}
	cout << l << '\n';

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int dp[101][100001];
int main(void){
	int n,w;
	int i,j;
	cin>>n>>w;
	int we,va;
	for(i=0;i<=n;i++){
		for(j=0;j<=100000;j++){
			dp[i][j]=INT_MAX;
		}
	}
	dp[0][0]=0;
	for(i=0;i<n;i++){
		cin>>we>>va;
		for(j=0;j<=100000;j++){
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
			if(dp[i][j]!=INT_MAX&&dp[i][j]+we<=w){
				dp[i+1][j+va]=min(dp[i+1][j+va],dp[i][j]+we);
			}
		}
	}
	/* for(i=0;i<=n;i++){
		for(j=0;j<=100000;j++){
			if(dp[n][j]==INT_MAX);
			else cout<<dp[n][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl */;
	int MAX=-1;
	int sum;
	
	for(i=0;i<=100000;i++){
		if(dp[n][i]!=INT_MAX){
			sum=i;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 39680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll a, b, c, k; cin >> a >> b >> c >> k;
    ll cnt=0;
    if(0<b && 0<c){
        while(b<=a){
            b *= 2;
            cnt++;
        }
        while(c<=b){
            c *= 2;
            cnt++;
        }
    }
    //cout << cnt << ' ' << k << endl;
    if(cnt<=k) cout << "Yes" << endl;
    else cout << "No" << endl;
}



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

using namespace std;

int main(void) {
  int n, ans = 0; cin >> n;
  
  int ba = 100000;
  for (int i = 0; i < n-1; i++) {
    int bb = ba; cin >> ba;
    ans += min(ba, bb);
  }
  ans += min(ba, 100000);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
def read_input():
    x, y = map(int, input().split())

    return x, y


def submit():
    x, y = read_input()

    group1 = [2]
    group2 = [4, 6, 9, 11]
    group3 = [1, 3, 5, 7, 8, 10, 12]

    if x in group1 and y in group1:
        print('Yes')
        return

    if x in group2 and y in group2:
        print('Yes')
        return

    if x in group3 and y in group3:
        print('Yes')
        return

    print('No')



if __name__ == '__main__':
    submit()

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;
using ll = long long;

vector<pair<ll, ll> > prime_factorize(ll n) {
    vector<pair<ll, ll> > res;
    for (ll p = 2; p * p <= n; p++) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

int main() {
    ll a, b; cin >> a >> b;
    vector<pair<ll, ll> > p = prime_factorize(gcd(a, b));
    cout << p.size() + 1 << endl;
}


Measured memory_bytes: 256
A, B, M= [int(i) for i in input().split(' ')]
AA = [int(i) for i in input().split(' ')]
BB = [int(i) for i in input().split(' ')]

XYC = []
for _ in range(M):
    XYC.append([int(i) for i in input().split(' ')])

min_a , min_b = min(AA),min(BB)
min_ab = min_a + min_b

for x,y,c in XYC:
    cost = AA[x-1] + BB[y-1] - c
    min_ab = min(cost,min_ab)

print(min_ab)

Measured memory_bytes: 32496
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

const int MAXN = 1e6 + 10;
const ll MOD = 1e9 + 7;

ll QuickPow(ll a, ll b)
{
	ll res = 1;
	while ( b ) {
		if ( b & 1 ) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;  
	}

	return res;
}

int main()
{
	ll n;
	ll res = 0;
	cin >> n;
	res = (QuickPow(10, n) % MOD - QuickPow(9, n) * 2 % MOD + QuickPow(8, n) % MOD + MOD) % MOD;
	cout << res << endl;
	
	return 0;
}          

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

using namespace std;

const int mod = 1e9 + 7;

void add_self (int &a, int &b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W;
  cin >> H >> W;
  vector<vector<char>> sq(H+1, vector<char>(W+1));
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> sq[i][j];
    }
  }
  vector<vector<int>> dp(H+1, vector<int>(W+1));
  dp[1][1] = 1;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      for ( int r : { i, i + 1}) {
        int c = j;
        if (r == i) {
          c = j + 1;
        }
        if ( r <= H && c <= W && sq[r][c] == '.') {
          add_self(dp[r][c], dp[i][j]);
        }
      }
    }
  }
  cout << dp[H][W] << '\n';
  return 0;
}

Measured memory_bytes: 8188
#include<math.h>
#include<time.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
//这是求最大公约数的递归函数
int gcd(int x,int y)
{
	int i;
	//如果x>=y,则x,y的最大公约数=y,x%y的最大公约数
	if(x==0)
		return y;
	if(y==0)
		return x;
	if(x>=y)
		x%=y;
	else
		y%=x;
	i=gcd(x,y);
	return i;
}
int main()
{
	int a,b,n;
	scanf("%d %d",&a,&b);
	n=gcd(a,b);
	printf("%d\n",n);
	return 0;
}


Measured memory_bytes: 2116
n = int(input())
ans_list = [ 1 for i in range(n) ]

color_list = [ -1 for i in range(2*(10**5))] 
for i in range(n):
    color = int(input()) - 1

    if color_list[color] not in [-1,i-1]:
        ans_list[i] = ans_list[i-1] + ans_list[color_list[color]]
    else:
        ans_list[i] = ans_list[i-1]
    ans_list[i] %= 10**9+7

    color_list[color] = i
print(ans_list[-1])

Measured memory_bytes: 57576
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        int N = S.length();
        String T = sc.next();
        int M = T.length();

        String NOT = "UNRESTORABLE";

        if (M > N) {
            System.out.println(NOT);
            return;
        }

        NEXT: for (int i = 0; i <= N - M; i++) {
            int end = N - 1 - i;
            for (int j = 0; j < M; j++) {
                if (S.charAt(end - j) == '?' || S.charAt(end - j) == T.charAt(M - 1 - j)) continue;
                continue NEXT;
            }

            StringBuilder sb = new StringBuilder();
            for (int k = 0; k < N; k++) {
                if (k <= end && k >= end - M + 1) {
                    sb.append(T.charAt(k - (end - M + 1)));
                } else {
                    if (S.charAt(k) == '?') {
                        sb.append('a');
                    } else {
                        sb.append(S.charAt(k));
                    }
                }
            }
            System.out.println(sb.toString());
            return;
        }

        System.out.println(NOT);
    }
}

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

int main() {
    long long N; cin >> N;
    vector<long long>A(N);
    for (long long i = 0; i < N; i++) cin >> A.at(i);
    long long ans = 0;
    for (long long i = 1; i < N; i++) {
        if (A.at(i - 1) > A.at(i)) {
            ans += A.at(i - 1) - A.at(i);
            A.at(i) = A.at(i - 1);
        }
    }
    cout << ans << endl;
}

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

int collision_detection(double x1, double y1, double x2, double y2, double r1, double r2){
	double d = ((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
	double sr = ((r1+r2)*(r1+r2));
	double dr = ((r1-r2)*(r1-r2));
	if( d > sr ){
		return 0;
	}else if( d <= sr && dr <= d){
		return 1;
	}else if(dr > d){
		return (r1>r2)? 2 : -2;
}
}

int main(){
	int n, ans;
	double xa, ya, ra, xb, yb, rb;

	cin >> n;
	for(int i=0 ; i<n ; i++){
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		ans = collision_detection( xa, ya, xb, yb, ra, rb);
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
n=int(input())
import math 
lim=math.floor(n**(1/2))
ans=1000000000
for i in range (1,lim+1):
  if n%i==0:
    a=len(str(int(n/i)))
    b=len(str(int(i)))
    f=max(a,b)
    ans=min(f,ans)
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
// Euclidean Algorithm
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int main(){
  int N; cin >> N;
  int ans = lcm(360,N)/N;
  cout << ans << endl;
  return 0;
}

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

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

lint lcm(lint x, lint y) { return abs(x-y)/gcd(x,y); }


int main() {
  int n,m; cin >> n >> m;
  int ans=pow(2,m)*(1900*m+100*(n-m));
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;

const int MAX_SIZE = 2e5 + 5;

int freq[MAX_SIZE];

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i)
	{
		int temp;
		scanf("%d", &temp);
		++freq[temp];
	}
	std::vector<int> v;
	v.reserve(MAX_SIZE);
	for (int i = 0; i < MAX_SIZE; ++i)
	{
		if (freq[i])
		{
			v.push_back(freq[i]);
		}
	}
	std::sort(v.begin(), v.end());
	ll ans = 0;
	int end = v.size() - k;
	for (int i = 0; i < end; ++i)
	{
		ans += v[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4804
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
using namespace std;

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

	int x,y;

	cin >> x >> y;
	bool flg = false;
	if (y % 2 == 1) {
		cout << "No\n";
		return 0;
	}
	for (int i = 0; i <= x; i++) {
		for (int j = 0; j <= x - i; j++) {
			if (i + j == x && i * 2 + j * 4 == y) {
				flg = true;
				break;
			}
		}
		if (flg == true) {
			break;
		}
	}

	if (flg == true) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}


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


    class Program
    {


        static void Main(string[] args)
        {
            Solve();
        }

        static void Solve()
        {
        Scan sc = new Scan();

        var p1 = sc.longarr;
        long n = p1[0];
        var p2 = sc.longarr;
        long k = p2[0];

        n %= 500;
        if (n - k <= 0) Console.WriteLine("Yes");
        else Console.WriteLine("No");

            
        }
    }


    class Scan
    {
    public string str => Console.ReadLine();

    public string[] strarr => str.Split(' ');

    public long[] longarr => strarr.Select(long.Parse).ToArray();

   
    }


Measured memory_bytes: 13268
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))


sum=0

for i in range(N):
    sum = sum + B[A[i]-1]
    if i > 0 and (A[i]-1) == A[i -1]:
        sum = sum + C[A[i]-2]

print(sum)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

#define yes printf("Yes\n")
#define Yes printf("YES\n")
#define no printf("No\n")
#define No printf("NO\n")

struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7, inf = 1e16;
const string sp = " ";
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = max(a, b);
		return true;
	}
	return false;
}
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = min(a, b);
		return true;
	}
	return false;
}

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

int a, b, c, ans;
set<int>st;
signed main() {
	cin >> a >> b;
	c = gcd(a, b);
	for (int i = 1; i * i <= c; ++i) {
		if (c % i == 0) {
			st.insert(i);
			st.insert(c / i);
		}
	}
	for (int i : st) {
		if (pri(i)) ans++;
	}
	cout << ans + 1 << endl;
}


Measured memory_bytes: 512