akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

a, b, c, d = map(int, input().split())

ans = max(a * c, a * d, b * c, b * d)

if ans < 0 and (a <= 0 <= b or c <= 0 <= d):
    print(0)
else:
    print(ans)


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A*A%MOD, N/2);
  else return Pow(A*A%MOD, N/2) * A % MOD;
}

int N;
ll fac[int(2e5+5)], rev[int(2e5+5)];
vector <int> Graph[int(2e5+5)];

int Dist[int(2e5+5)], Have[int(2e5+5)];
int Parent[int(2e5+5)];
int Calc_Dist(int start){
  Dist[start] = 1;
  queue <int> que; que.push(start);
  while (!que.empty()){
    int Q = que.front(); que.pop();
    for (int v:Graph[Q]){
      if (Dist[v] > 0) {
        Parent[Q] = v; continue;
      }
      Dist[v] = Dist[Q] + 1;
      que.push(v);
    }
  }
  return 0;
}

int Calc_Child(int num){
  if (Have[num] > 0) return Have[num];
  int ans = 1;
  for (int v:Graph[num]){
    if (Dist[num] > Dist[v]) continue;
    ans += Calc_Child(v);
  }
  return Have[num] = ans;
}

ll DP[int(2e5+5)];
bool visited[int(2e5+5)];
ll Calc_DP(int num){
  if (visited[num]) return DP[num];
  visited[num] = true;
  ll ans = fac[Have[num] - 1];

  for (int v:Graph[num]){
    if (Dist[num] > Dist[v]) continue;
    ans *= Calc_DP(v); ans %= MOD;
    ans *= rev[Have[v]]; ans %= MOD;
  }
  return DP[num] = ans;
}


ll DP2[int(2e5+5)];
ll Calc_DP2(int num){
  if (visited[num]) return DP2[num];
  visited[num] = true;
  if (Parent[num] == 0) return DP2[num] = 1;

  ll ans = fac[N - Have[num] - 1];
  ans *= Calc_DP2(Parent[num]); ans %= MOD;
  ans *= rev[N - Have[Parent[num]]]; ans %= MOD;

  ans *= DP[Parent[num]]; ans %= MOD;
  ans *= rev[Have[Parent[num]]-1]; ans %= MOD;
  ans *= fac[Have[num]]; ans %= MOD;
  ans *= Pow(DP[num], MOD-2); ans %= MOD;

  return DP2[num] = ans;
}

int main(){
  cin >> N;
  fac[0] = 1; rev[0] = 1;
  for (ll i = 1; i <= N; i++){
    fac[i] = fac[i-1] * i % MOD;
    rev[i] = Pow(fac[i], MOD-2);
  }

  for (int i = 0; i < N - 1; i++){
    int A, B; cin >> A >> B;
    Graph[A].push_back(B);
    Graph[B].push_back(A);
  }
  Calc_Dist(1); Calc_Child(1); Calc_DP(1);

  fill(visited, visited + N + 1, false);

  for (int i = 1; i <= N; i++){
    if (!visited[i]) Calc_DP2(i);
  }

  for (int i = 1; i <= N; i++){
    ll ans = fac[N-1];
    ans *= DP[i]; ans %= MOD;
    ans *= rev[Have[i]-1]; ans %= MOD;
    ans *= DP2[i]; ans %= MOD;
    ans *= rev[N-Have[i]]; ans %= MOD;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 24480
#include <bits/stdc++.h>
using namespace std;
string s[105];
map<string,int>mapp1,mapp2;
int main()
{
    int n,m;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        cin>>s[i];
        mapp1[s[i]]++;
    }
    scanf("%d",&m);
    for(int i=0;i<m;i++)
    {
        string t;
        cin>>t;
        mapp2[t]++;
    }
    int sum=0;
    for(int i=0;i<n;i++){
        sum=max(sum,mapp1[s[i]]-mapp2[s[i]]);
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve(std::vector<long long> A){
    if (A[0]+A[1]+A[2] <= 21){
        std::cout << "win" << std::endl;
    } else {
        std::cout << "bust" << std::endl;
    }
}

int main(){
    std::vector<long long> A(3);
    for(int i = 0 ; i < 3 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(std::move(A));
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq

n = int(input())
h = [0] + list(map(int, input().split()))+[0]

INF = 10**15

dp = [INF]*(n+5)
dp[0] = 0
dp[1] = 0

for i in range(1,n):
    a = dp[i] + abs(h[i+1]-h[i])
    dp[i+1] = min(dp[i+1], a)
    a = dp[i] + abs(h[i + 2] - h[i])
    dp[i+2] = min(dp[i+2], a)

print(dp[n])


Measured memory_bytes: 21532
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int K = sc.nextInt();
      int A = sc.nextInt();
      int B = sc.nextInt();
      String ans = "NG";
      int ak = A / K;
      for(int i = ak; i * K <= B; i++){
        int ik = i * K;
        if(A <= ik && ik <= B){
          ans = "OK";
          break;
        }
      }
      System.out.println(ans);
    } 
}

Measured memory_bytes: 35744
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        a: isize,
        b: isize,
        c: isize,
        k: isize,
    }

    if k <= a {
        println!("{}", k);
    } else if k <= a + b {
        println!("{}", a);
    } else {
        println!("{}", a - (k - a - b));
    }
}


Measured memory_bytes: 2160
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v) {os << " [" << i++ << "]" << x; if (i % 10 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp) {os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

ll gcd(ll a, ll b)
{
  while (b > 0) {
    a = a % b;
    std::swap(a, b);
  }
  return a;
}

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

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

  ll A, B, C;
  std::cin >> A >> B >> C;

  bool judge = false;
  for (ll i = 1; i <= B; i++) {
    if ((A * i + C) % B == 0) judge = true;
  }
  if (judge) print("YES");
  else print("NO");

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

ll N, M;
vector<pair<ll, ll>> AB;

void _main() {
  cin >> N >> M;
  rep(i, 0, N) {
    int a, b;
    cin >> a >> b;
    AB.push_back({a, b});
  }
  sort(AB.begin(), AB.end());

  ll cnt = 0;
  ll ans = 0;
  rep(i, 0, N) {
    ll more = M-cnt;
    ll buy = min(AB[i].second, more);
    ans += AB[i].first * buy;
    cnt += buy;
    if (cnt == M) break;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, i, j, k, v, ans=0; long W, a, b, c, d, w, z[4]={};
cin >> N >> W; vector< pair<long, int> > A;
for(i=0; i<N; i++){ cin >> w >> v; A.push_back(make_pair(w, -v)); }
sort(A.begin(), A.end());
vector< vector<int> > V(4); V[0]={0}; V[1]={0}; V[2]={0}; V[3]={0};
z[0]=A[0].first; V[0].push_back(-A[0].second);
for(k=0, i=1; i<N; i++){ 
 if(A[i].first>A[i-1].first){ k++; z[k]=A[i].first; }
 V[k].push_back(-A[i].second);
}
for(i=0; i<4; i++){ for(j=1; j<V[i].size(); j++){ V[i][j]=V[i][j-1]+V[i][j]; } }

for(a=0; a<V[0].size(); a++){ for(b=0; b<V[1].size(); b++){
for(c=0; c<V[2].size(); c++){ for(d=0; d<V[3].size(); d++){ 
if(a*z[0]+b*z[1]+c*z[2]+d*z[3]<=W){ ans=max(ans, V[0][a]+V[1][b]+V[2][c]+V[3][d]); }
}}}}
cout << ans << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1);
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
inline double ABS(double a){return max(a,-a);}
struct Pt {
	double x, y;
	Pt() {}
	Pt(double x, double y) : x(x), y(y) {}
	Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
	Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
	Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }
	Pt operator-() const { return Pt(-x, -y); }
	Pt operator*(const double &k) const { return Pt(x * k, y * k); }
	Pt operator/(const double &k) const { return Pt(x / k, y / k); }
	double ABS() const { return sqrt(x * x + y * y); }
	double abs2() const { return x * x + y * y; }
	double arg() const { return atan2(y, x); }
	double dot(const Pt &a) const { return x * a.x + y * a.y; }
	double det(const Pt &a) const { return x * a.y - y * a.x; }
};
double tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }
pair<Pt,Pt> tCP(Pt a, double r, Pt b) {
	double d2 = (b - a).abs2();
	double x = sqrt(max(d2 - r * r, 0.0));
	Pt h = a + (b - a) * (r * r / d2);
	Pt w = (b - a) * Pt(0, 1) * (x * r / d2);
	return make_pair(h - w, h + w);
}
double dLP(Pt a, Pt b, Pt c) {
	return ABS(tri(a, b, c)) / (b - a).ABS();
}
double x[60];
double y[60];
double r[60];
double m[60];
vector<pair<Pt,Pt> > p;
void add(Pt a,double ar,Pt b,double br){
	Pt p1=(a*br+b*ar)/(ar+br);
	pair<Pt,Pt> q1=tCP(a,ar,p1);
	p.push_back(make_pair(p1,q1.first));
	p.push_back(make_pair(p1,q1.second));
	if(sig(ar-br)){
		Pt p2=(b*ar-a*br)/(ar-br);
		pair<Pt,Pt> q2=tCP(a,ar,p2);
		p.push_back(make_pair(p2,q2.first));
		p.push_back(make_pair(p2,q2.second));
	}else{
		Pt v=(b-a)*Pt(0,1);
		double ks=v.ABS();
		v=v/ks*ar;
		p.push_back(make_pair(a+v,b+v));
		p.push_back(make_pair(a-v,b-v));
	}
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			scanf("%lf%lf%lf%lf",x+i,y+i,r+i,m+i);
		}
		if(a==1){
			printf("1\n");continue;
		}
		p.clear();
		for(int i=0;i<a;i++){
			for(int j=i+1;j<a;j++){
				add(Pt(x[i],y[i]),r[i],Pt(x[j],y[j]),r[j]);
				add(Pt(x[i],y[i]),r[i]+m[i],Pt(x[j],y[j]),r[j]);
				add(Pt(x[i],y[i]),r[i],Pt(x[j],y[j]),r[j]+m[j]);
				add(Pt(x[i],y[i]),r[i]+m[i],Pt(x[j],y[j]),r[j]+m[j]);
			}
		}
		int ret=0;
		for(int i=0;i<p.size();i++){
			int val=0;
			for(int j=0;j<a;j++){
				double d=dLP(p[i].first,p[i].second,Pt(x[j],y[j]));
				if(d+EPS>r[j]&&d-EPS<r[j]+m[j])val++;
			}
			ret=max(ret,val);
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 2204
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;
// const double PI = M_PI;

int H, W, K;
char c[7][7];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> H >> W >> K;
  rep(i, H) {
    rep(j, W) { cin >> c[i][j]; }
  }

  int ans = 0;
  for (int i = 0; i < (1 << H); i++) {
    for (int j = 0; j < (1 << W); j++) {
      int cnt = 0;
      for (int k = 0; k < H; k++) {
        for (int l = 0; l < W; l++) {
          if ((i & (1 << k)) == 0 && (j & (1 << l)) == 0 && c[k][l] == '#') {
            cnt++;
          }
        }
      }
      if (cnt == K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  string s, t;
  cin >> s;
  cin >> t;

  int ssize = (int)s.size(), tsize = (int)t.size();
  int ans = tsize;

  rep(i, ssize) {
    if (ssize - tsize - i < 0) break;

    int cnt = 0;
    rep(j, tsize) {
      if (s[i+j] != t[j]) {
        cnt++;
      }
    }

    if (cnt < ans) ans = cnt;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <cmath>
#include <cstring>
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define pb push_back
using namespace std;

const int INF=10000000;
int V;
int d[2][111][111];

void wf(){
    FOR(k,0,V+1)FOR(i,0,V+1)FOR(j,0,V+1){
        d[0][i][j]=min(d[0][i][j],d[0][i][k]+d[0][k][j]);
        d[1][i][j]=min(d[1][i][j],d[1][i][k]+d[1][k][j]);
    }
}

int main(){
    int n;
    while(1){
        cin>>n>>V;
        if(!(n||V)) break;
        FOR(i,0,V+1)FOR(j,0,V+1){
            d[0][i][j]=d[1][j][i]=INF;
        }
        FOR(i,0,n){
            int a,b,m,t;cin>>a>>b>>m>>t;
            d[0][a][b]=d[0][b][a]=m;
            d[1][a][b]=d[1][b][a]=t;
        }
        wf();
        int k;cin>>k;
        FOR(i,0,k){
            int p,q,r;cin>>p>>q>>r;
            cout<<d[r][p][q]<<endl;
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,0,n) cin >> a.at(i);
    rep(i,0,n){
        a.at(i)--;
    }
    int now = 0;
    int cnt = 0;
    while(now!=1&&cnt<=n){
        now = a.at(now);
        cnt++;
    }
    cout << ((now==1) ? cnt : -1) << endl;
}

Measured memory_bytes: 3728
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC168B
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            if (S.Length <= K) Console.WriteLine(S);
            else
            {
                string ans = S.Substring(0, K)+"...";
                Console.WriteLine(ans);
            }



            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 17608
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
typedef long long ll;
using namespace std;

string s;
ll ans = 0;

void solve(int k, ll c, ll sum){
  if(k == s.length()){
    ans += (c+sum);
  }else{
    solve(k+1, s[k]-'0', c+sum);
    solve(k+1, c*10+s[k]-'0', sum);
  }
}

int main(){
  cin >> s;
  
  solve(1, s[0]-'0', 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
long long mod = 1000000007;
using namespace std;
int main()
{
	long long n, m;
	cin >> n >> m;
	long long x[n], y[m], h = 0, w = 0;
	for (int i = 1; i <= n; i++) cin >> x[i];
	for (int j = 1; j <= m; j++) cin >> y[j];
	for (int l = 1, r = n; l < r; ++l, --r) w = (w + (x[r] - x[l]) * (r - l) % mod) % mod;
	for (int l = 1, r = m; l < r; ++l, --r) h = (h + (y[r] - y[l]) * (r - l) % mod) % mod;
	cout << h * w % mod;
	return 0;
}

Measured memory_bytes: 5128
def answer(n: int, k: int) -> int:
    current_num = 1
    for _ in range(n):
        current_num = min(current_num * 2, current_num + k)

    return current_num


def main():
    n =int(input())
    k = int(input())
    print(answer(n, k))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9132
//                          VIVEK UPADHYAY
//                         MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<endl ;
#define ok cout<<"ok\n" ;
typedef long long ll;
const int MAXN = 1e5 + 10 ;
const int MAX = 1e6 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;
ll mod = 1e9 + 7 ;

int main() {
    int N ;
    cin >> N ;
    double T , A ;
    cin >> T >> A ;
    double H[N] ;
    for(int i=0;i<N;i++)    cin>> H[i] ;
    double c = 1e12 ;
    int pos = -1 ;
    for(int i=0;i<N;i++){
        double v = T-H[i]*.006 ;
        if(abs(A-c) > abs(A-v)){
            c = v ;
            pos = i + 1;
        }
    }
    cout<<pos<<endl;
    return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main(void){
  int N,K;
  scanf("%d%d",&N,&K);
  int d[K+1];
  int treat = 0;
  bool sunuke[N+1];
  for(int i=1;i<=N;i++){
  	sunuke[i] = false;
  }
  
  for(int i=1;i<=K;i++){
  	scanf("%d",&d[i]);
    int A[d[i]+1];
    for(int j=1;j<=d[i];j++){
    	scanf("%d",&A[j]);
        sunuke[A[j]] = true;
    }
  }
  
  for(int i=1;i<=N;i++){
  	if(sunuke[i] == true) treat++;
  }
 
  printf("%d",N - treat);
  
  return 0;
}

Measured memory_bytes: 1728
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 


vector<int> graph[NMAX];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int n,x,y;
	cin >> n >> x >> y;
	x--;
	y--;
	vector<int> sol(n);
	for(int i =0 ;i< n; ++i)
	{
		for(int j = i+ 1; j< n; ++j)
		{
			int mini = min(j - i,abs(x-i) + 1 + abs(y-j));
			sol[mini]++;
		}
	}

	for(int i = 1; i< n; ++i)
	{
		cout << sol[i] << '\n';
	}

	

    return 0;
}

Measured memory_bytes: 23680
inner_product (ax,ay) (bx,by) = ax * bx + ay * by
vabs (ax,ay) = sqrt (ax*ax+ay*ay)
vmul a (ax,ay) = (a*ax,a*ay)
vadd (ax,ay) (bx,by) = (ax+bx,ay+by)
vsub (ax,ay) (bx,by) = (ax-bx,ay-by)

vatan (x,y) = atan2 y x
vnorm (x,y) = x*x+y*y

ans p0 p1 p2 p3 
  | (abs ip) < 0.00000000001 = 1
  | ((abs ip) > 0.99999999999) && ((abs ip) < 1.00000000001) = 2
  | otherwise = 0
--  = ip
  where s1 = vsub p1 p0
        s2 = vsub p3 p2
        ip = (inner_product s1 s2) / (vabs s1) / (vabs s2)

main = do
  getLine
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Double]]
      o = map (\ [xp0,yp0,xp1,yp1,xp2,yp2,xp3,yp3] -> ans (xp0,yp0) (xp1,yp1) (xp2,yp2) (xp3,yp3) ) i
  mapM_ print o

Measured memory_bytes: 5280
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16000000")
using namespace std;

const int Maxn = 14;
const int Maxm = 200005;

int pw[Maxn];
int n;
int T;
char str[Maxm];
int sum[Maxm];
int res[5000005];

void Solve(int b, const vector <int> &cur, const vector <int> &quer)
{
    if (b >= n || cur.empty()) return;
    vector <int> C[3], Q[3];
    int my[3] = {0, 1, 2};
    int lst = 0;
    for (int i = 0; i < quer.size(); i++) {
        if (sum[quer[i]] % 2 != sum[lst] % 2) swap(my[1], my[2]);
        Q[my[2]].push_back(quer[i]);
        int tmp = my[2]; my[2] = my[1]; my[1] = my[0]; my[0] = tmp;
        lst = quer[i];
    }
    if (sum[T] % 2 != sum[lst] % 2) swap(my[1], my[2]);
    int inv[3];
    for (int i = 0; i < 3; i++)
        inv[my[i]] = i;
    for (int i = 0; i < cur.size(); i++) {
        int val = cur[i] / pw[b] % 3;
        C[val].push_back(cur[i]);
        res[cur[i]] += pw[b] * inv[val];
    }
    for (int i = 0; i < 3; i++)
        Solve(b + 1, C[i], Q[i]);
}

int main()
{
    pw[0] = 1;
    for (int i = 1; i < Maxn; i++)
        pw[i] = pw[i - 1] * 3;
    scanf("%d", &n);
    scanf("%s", str + 1);
    T = strlen(str + 1);
    vector <int> quer;
    for (int i = 1; i <= T; i++) {
        if (str[i] == 'R') str[i] = 'S';
        else str[i] = 'R';
        sum[i] = sum[i - 1] + (str[i] == 'R');
        if (str[i] == 'S') quer.push_back(i);
    }
    vector <int> cur;
    for (int i = 0; i < pw[n]; i++)
        cur.push_back(i);
    Solve(0, cur, quer);
    for (int i = 0; i < pw[n]; i++)
        printf("%d%c", res[i], i + 1 < pw[n]? ' ': '\n');
    return 0;
}


Measured memory_bytes: 14768
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	if(n==1) {
		print(1);
		print(0);
		return 0;
	}
	if(n==2) {
		print(2);
		print(0);
		print(11);
		return 0;
	}
	print(n-1);
	for(int i=0;i<=n-2;i++) {
		std::string s(i,'0');
		print('1'+s+'1');
	}
	return 0;
}



Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, l, t;
    cin >> n >> l >> t;
    vl x(n), w(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> w[i];
    }
    deque<ll> pos;
    for (int i = 1; i < n; ++i) {
        if (w[i] != w[0]) {
            if (w[0] == 1)
                pos.push_back(x[i] - x[0]);
            else
                pos.push_front(l - (x[i] - x[0]));
        }
    }
    deque<ll> p = pos;
    for (auto &v : pos) {
        p.push_back(v + l);
    }
    ll cnt = t / l * p.size();
    ll lft = t % l;
    for (auto &v : p) {
        if (v < lft * 2)
            cnt++;
    }

    ll idx = w[0] == 1 ? (cnt) % n : ((-cnt) % n + n) % n;
    vl ret;
    ll id = -1;
    for (int i = 0; i < n; ++i) {
        ll curr = x[i] + (w[i] == 1 ? t : (-t % l + l) % l);
        curr %= l;
        ret.push_back(curr);
        if (i == 0)
            id = curr;
    }
    sort(ret.begin(), ret.end());
    int posidx;
    if (w[0] == 1)
        posidx = lower_bound(ret.begin(), ret.end(), id) - ret.begin();
    else
        posidx = upper_bound(ret.begin(), ret.end(), id) - ret.begin() - 1;
    for (int i = 0; i < n; ++i) {
        ret.push_back(ret[i]);
    }
    vl r(n);
    for (int i = 0; i < n; ++i) {
        r[(idx + i) % n] = ret[(posidx + i) % n];
    }
    for (auto &rr : r) {
        cout << rr << "\n";
    }
    return 0;
}

Measured memory_bytes: 6392
n=int(input())
arr=list(map(int,input().split()))
xors = 0
for val in arr: #あらかじめすべての要素のxorを求めておく
 xors^=val #(ai xor aj = bi xor bj)となるのですべてのxorを合わせると、b0^b1^b2^...^bn
ans=[]
for i in range(n): #各aiについて、ai xor (すべての要素のxor)がi番目に書かれた値に等しい
 ans.append(xors^arr[i])
print(*ans)

Measured memory_bytes: 31740
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a[10],i=0,n;
	while(scanf("%d",&n)==1){
		if(n!=0){
			a[i]=n;
			i++;
		}
		else{
			i--;
			cout<<a[i]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1208
s = input()
P = input()
e = s + s
x = len(P)
m = 0
count = 0
for i in range(len(s)):
    if P == e[m:x]:
        count += 1
    m += 1
    x += 1
if count >= 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7472
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//
		int n = sc.nextInt();
		int sum = 0;
		for(int i=0; i<n; i++){
			sum += -(sc.nextInt() - sc.nextInt()) + 1;
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 39700
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	public static void main(String[] args) throws IOException {
		//??????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while ((str = br.readLine()) != null){
			String[] num = str.split(" ", 0);
			//?????°?¨????
			BigDecimal d = new BigDecimal(num[3]);
			BigDecimal e = new BigDecimal(num[4]);
			BigDecimal f = new BigDecimal(num[5]);

			//?¨????
			BigDecimal ce = new BigDecimal(num[2]);
			ce = ce.multiply(e);
			BigDecimal bf = new BigDecimal(num[1]);
			bf = bf.multiply(f);
			BigDecimal ae = new BigDecimal(num[0]);
			ae = ae.multiply(e);
			BigDecimal bd = new BigDecimal(num[1]);
			bd = bd.multiply(d);
			BigDecimal cd = new BigDecimal(num[2]);
			cd = cd.multiply(d);
			BigDecimal af = new BigDecimal(num[0]);
			af = af.multiply(f);

			BigDecimal x_numer = new BigDecimal(ce.toPlainString());
			x_numer = x_numer.subtract(bf);
			BigDecimal x_denom = new BigDecimal(ae.toPlainString());
			x_denom = x_denom.subtract(bd);
			BigDecimal x = new BigDecimal("0.000");
			x = x.add(x_numer);
			x = x.divide(x_denom, 3, BigDecimal.ROUND_HALF_UP);

			BigDecimal y_numer = new BigDecimal(cd.toPlainString());
			y_numer = y_numer.subtract(af);
			BigDecimal y_denom = new BigDecimal(bd.toPlainString());
			y_denom = y_denom.subtract(ae);
			BigDecimal y = new BigDecimal("0.000");
			y = y.add(y_numer);
			y = y.divide(y_denom, 3, BigDecimal.ROUND_HALF_UP);

			//??????
			System.out.println(x + " " + y);
		}
	}

}

Measured memory_bytes: 24388
#pragma GCC optimize("O3")
//#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mod=1e9+7;
int N,K;
vector<int> v;
bool memo[100010][2];
bool vis[100010][2];
bool sol(int p,bool t){
  //cout<<p<<" "<<t<<endl;
  if(p==0)return t;
  if(vis[p][t])return memo[p][t];
  vis[p][t]=1;
  if(t==0){
    bool s=0;
    for(int i=0;i<N;i++){
      if(p>=v[i])s|=sol(p-v[i],1);
    }
    return memo[p][t]=s;
  }
  bool s=1;
  for(int i=0;i<N;i++){
    if(p>=v[i])s&=sol(p-v[i],0);
  }
  return memo[p][t]=s;
}
int main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
		cin>>N>>K;
		for(int i=0;i<N;i++){
      int a;
      cin>>a;
      v.push_back(a);
		}
		if(sol(K,0))cout<<"First";
		else cout<<"Second";
    return 0;
}

Measured memory_bytes: 6912
N, K = map(int, input().split())
D = list(map(int, input().split()))

can_use = []
for i in range(10):
    if (i in D):
        continue
    else:
        can_use.append(i)


while True:
    str_N = str(N)
    flag = True
    for i in range(len(str_N)):
        if int(str_N[i]) in D:
            N += 1
            flag = False
            break
        else:
            continue
    if flag:
        break

print(N)


Measured memory_bytes: 9176
#include <stdio.h>

int main(void) {
	int n, sum;
	scanf("%d %d", &n, &sum);
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= n - i; j++)
		{
			if (i * 10000 + j * 5000 + (n - i - j) * 1000 == sum)
			{
				printf("%d %d %d", i, j, n - i - j);
				return 0;
			}
		}
	}
	printf("-1 -1 -1");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ALL(a) (a.begin(), a.end())
using ll = long long;
template<typename T> void Out(T x) { cout << x << endl; }

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  char aa = '0' + a;
  char bb = '0' + b;
  string resa;
  string resb;
  for (int i = 0; i < b; i++) resa += aa;
  for (int i = 0; i < a; i++) resb += bb;

  if (resa < resb) {
    Out(resa); return 0;
  } else {
    Out(resb); return 0;
  }

}


Measured memory_bytes: 256
#include<stdio.h>
const long mod = 1e9 + 7;
int N, A, B[1<<17], c;
long ans = 1;
int main(){
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		scanf("%d", &A);
		if(A){
			ans *= B[A-1];
			B[A-1]--;
			ans %= mod;
		}else c++;
		B[A]++;
	}
	for(int i=0; i<c; i++)ans *= 3-i;
	printf("%ld\n", ans%mod);
	return 0;
}

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

#define int long long

using namespace std;

bool used[10001];

 main () {   
 	string s;
 	cin >> s;
 	char fi = ' ';
 	for (char x = 'a';x <= 'z';x ++) {
 		bool ok = 0;
 		for (int i = 0;i < s.size ();i ++) {
 			if (s[i] == x) ok = 1;
 		}
 		if (!ok) {
 			fi = x;
 			break;
 		}
 	}
 	if (fi != ' ') {
 		cout << s << fi;
    	return 0;
    }	
    if (s == "zyxwvutsrqponmlkjihgfedcba") {
    	cout << -1;
    	return 0;
    }
    char mn = 'z';
    int id = 0;
    for (int i = s.size () - 1;i >= 0;i --) {
    	used[s[i]] = 1;
    	if (i == 0 || s[i - 1] < s[i]) {
			id = i - 1;
			break;
    	}                        
    }           
    for (char x = s[id] + 1;x <= 'z';x ++) {
		if (used[x]) {
			s[id] = x;
			break;
    	}
    }
    for (int i = 0;i <= id;i ++) cout << s[i];
    return 0;           		
}

Measured memory_bytes: 256
def main():
    n = int(input())
    X = list(map(int, input().split()))

    X_sorted = list(X)
    X_sorted.sort()
    middle = X_sorted[(n+1)//2]
    middle_l = X_sorted[(n+1)//2-1]
    for i in range(n):
        if middle_l==middle:
            print(middle)
        else:
            if X[i]>=middle:
                print(middle_l)
            else:
                print(middle)


if __name__ == '__main__':
    main()


Measured memory_bytes: 93780
#pragma region Include
#include <bits/stdc++.h>
// #include <algorithm>
// #include <bitset>
// #include <climits>
// #include <cmath>
// #include <iostream>
// #include <iterator>
// #include <map>
// #include <queue>
// #include <sstream>
// #include <stack>
// #include <string>
// #include <unordered_map>
// #include <unordered_set>
// #include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(4) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

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

#pragma endregion

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll H, N;
  cin >> H >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  rep(i, N) { cin >> A[i] >> B[i]; }
  ll dp[100010];
  rep(i,100010){
    dp[i]=INF;
  }
  dp[0]=0;
  rep2(hp,1,H+1){
    rep(mg,N){
      //dump(dp[hp]);
      //dump(dp[max(hp-A[mg],(ll)0)]+B[mg]);
      dp[hp]=min(dp[hp],dp[max(hp-A[mg],(ll)0)]+B[mg]);
    }
  }
  out(dp[H]);
  return 0;
}

Measured memory_bytes: 1024
N,M=map(int, input().split())
H=list(map(int, input().split()))

ans = [True]*N
ctr = 0

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] >= H[b]: ans[b] = False
    if H[a] <= H[b]: ans[a] = False

for i in range(N):
    if ans[i]:
        ctr += 1

print(ctr)


Measured memory_bytes: 20144
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,X;
    cin >> N >> X;
    
    
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    }
    
    int sum = 0;
    int min =1000;
    
    for(int j = 0;j<N;j++){
        sum = sum + vec.at(j);
    }
    
    for(int k = 0;k<N;k++){
        if(vec.at(k)<=min) min=vec.at(k);
    }
    
    int count =0;
    count = N + (X - sum)/min;

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <unordered_set>

using namespace std;
const int MAXN = 100001;
int A[MAXN];
int B[MAXN];
int main()
{
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> A[i];
    B[0] = 0;
    for(int i = 1; i < n; i++)
    {
        int best = 1000000000;
        for(int j = 1; j <= k && i-j>=0; j++) best = min(best,B[i-j]+abs(A[i]-A[i-j]));
        B[i] = best;
    }
    cout << B[n-1];
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int):
    print((Y // X).bit_length())


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)


if __name__ == '__main__':
    main()


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

long long int solve(long long int a, vector<long long int>& side_b, long long int m){
  int left = 0, right = side_b.size() - 1;
  while(right - left > 1){
    int middle = (right + left) / 2;
    if(side_b[middle] + a <= m){ left = middle; }
    else{ right = middle; }
  }
  return a + side_b[left];
}


int main(void){
  while(true){
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0){ break; }

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

    vector<long long int> side_a;
    for(int i = 0; i < n; i++){
      side_a.push_back(input[i]);
      for(int j = 0; j < n; j++){
        side_a.push_back(input[i] + input[j]);
      }
    }
    sort(side_a.begin(), side_a.end());
    side_a.push_back(side_a[side_a.size() - 1]);

    long long int ans = 0;
    for(size_t i = 0; i < side_a.size(); i++){
      long long int a = side_a[i];
      long long int tmp = solve(a, side_a, m);
      if(tmp <= m){ ans = max(ans, tmp); }
    }
    
    cout << ans << endl;
  }

  return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	bool flag = false;
	int i;
	int lo=1, hi=50000, mid;
	while(lo<=hi){
	    mid = (lo+hi)/2;
	    if(int(mid*1.08)==n){
	        flag = true;
	        break;
	    }
	    else if(int(mid*1.08)>n){
	        hi = mid-1;
	    }
	    else{
	        lo = mid+1;
	    }
	}
	if(flag){
	    cout << mid << endl;
	}
	else{
	    cout << ":(" << endl;
	}
	return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
#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++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

//---------------------------

string func(string s, int c, int l){
    if(c >= 0) return s.substr(c,l);
    else return "N/A";
}

int main(){
    string s, t="";
    cin >> s;
    
    int cnt = s.size() - 1;
    bool flag = true;
    while(s != t && flag){
        if(func(s,cnt-4,5)=="dream"){
            t = "dream" + t;
            cnt -= 5;
        }else if(func(s,cnt-4,5)=="erase"){
            t = "erase" + t;
            cnt -= 5;
        }else if(func(s,cnt-6,7)=="dreamer"){
            t = "dreamer" + t;
            cnt -= 7;
        }else if(func(s,cnt-5,6)=="eraser"){
            t = "eraser" + t;
            cnt -= 6;
        }else{
            flag = false;
        }
    }

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 512
s = input()

def is_month(n):
    if 1 <= int(n) <= 12:
        return True

if is_month(s[:2]) and is_month(s[2:]):
    print("AMBIGUOUS")
elif is_month(s[:2]) and not is_month(s[2:]):
    print("MMYY")
elif not is_month(s[:2]) and  is_month(s[2:]):
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <bitset>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>



int R, G, B, N;

int main(int argc, char **argv) {
    std::cin >> R >> G >> B >> N;

    long long ret = 0;
    for (int i = 0; i <= N / R; i++) {
        for (int j = 0; j <= N / G; j++) {
            int cur = i*R + j*G;
            if (cur <= N && (N - cur) % B == 0) {
                ret++;
            }
        }
    }

    std::cout << ret << std::endl;


    return 0;
}

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

#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define pii pair<int,int>
#define UMP(x,y) unordered_map<x,y>
#define MP(x,y) map<x,y>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define inf 1e18
#define endl "\n"
#define coutd(n) cout << fixed << setprecision(n)
#define watch(x) cout<<#x<<" = "<<x<<endl;
typedef double db;
typedef long double ld;	
const int mod = 1000000007;

using namespace std;

int32_t main(){
    fast
    	
    //int t;
	//cin>>t;
	//rep(_,0,t){
		
	//}
	int k,a,b;
	cin>>k>>a>>b;
	string str = "NG";
	rep(i,a,b+1){
		if(i%k == 0){
			str = "OK";
			break;
		}
	}
	cout<<str<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

ll dp[51][51][2501];
//何番目まで見たか、何個選んだか、合計

int main(){
	int n,a; cin >> n >> a;
	vector<int> x(n);
	dp[0][0][0]=1;
	for(int i=0;i<n;i++){
		cin >> x[i];
		for(int j=0;j<50;j++){
			for(int k=0;k<2501;k++){
				if(dp[i][j][k]){
					dp[i+1][j][k]+=dp[i][j][k];
					dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
				}
			}
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		ans+=dp[n][i][i*a];
	}
	cout << ans << endl;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();
			
			Console.WriteLine((firstLine[0] + firstLine[1]) % 24);
        }
	}
}


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

vector<int> p;
int f(int x) { return x == p[x] ? x : p[x] = f(p[x]); }

int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int comp = n;
  p.resize(n + 1);
  iota(p.begin(), p.end(), 0);
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    int fu = f(u), fv = f(v);
    if (fu != fv) {
      comp--;
      p[fu] = fv;
    }
  }
  cout << comp - 1 << endl;
  return 0;
}



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

#define F first
#define S second
#define PB push_back
#define all(x) x.begin(), x.end()

typedef long long ll; 
typedef long double ld;

const int N = 1000 * 100 + 10, M = 210; 
const int mod = 1000 * 1000 * 1000 + 7;

int dp[M][N];
int a[M];

int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n, k;
	cin>> n >> k;
	for(int i = 0; i < n; i++) cin>> a[i];
	sort(a, a + n);
	for(int i = 0; i <= k; i++) dp[0][i] = i % a[0];
	for(int i = 1; i < n; i++) for(int j = 0; j <= k; j++)
	{
		dp[i][j] = 1ll * dp[i - 1][j] * i % mod + dp[i -1][j % a[i]];
		dp[i][j] %= mod;
	}
	cout<< dp[n-1][k] << endl;
}


Measured memory_bytes: 80128
#!/usr/bin/env python3
import sys


def solve(S: str):
    for i in reversed(range(1, len(S) // 2)):
        if S[:i] == S[i:2 * i]:
            print(2 * i)
            return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sca=new Scanner(System.in);
		String s=sca.next();
		int i=0,j=0;
		int count1=0;
		int count2=0;
		
		for(i=0;i<s.length();i++){
			if(s.charAt(i)=='A'){
				count1=i;
				break;
			}
		}
		for(i=count1;i<s.length();i++){
			if(s.charAt(i)=='Z'&&count2<i-count1){
				count2=i-count1;
			}
		}
		
		System.out.print(count2+1);
		

	}

}

Measured memory_bytes: 26296
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    nums = string_to_int(inputs[0])
    max_num = max(nums)
    sum_num = sum(nums)

    count = 0
    while sum_num % 3 != 0 or (sum_num // 3) < max_num:
        count += 1
        sum_num += 2
    return count


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


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

const long long MOD = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s, t;
    cin >> n >> s >> t;
    long long ans = 1;
    for(int i = 0; i < n; i++){
        if(s[i] == t[i]){
            if(i == 0) ans *= 3;
            else if(s[i-1] == t[i-1]) ans *= 2;
        }
        else{
            if(i == 0) ans *= 6;
            else{
                if(s[i-1] == t[i-1]) ans *= 2;
                else ans *= 3;
            }
            i++;
        }
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a,b;
  cin >> a >> b;
  if(n == 1) puts("Hello World");
  else cout << a+b << endl;
  return 0;
}


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

int main(){
  int r,g;
  cin>>r>>g;
  cout<<g-r+g<<endl;
  return 0;
}

Measured memory_bytes: 256