akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double basePrice = sc.nextInt();
        double toppingPrice = sc.nextInt();
        int baseCalory = sc.nextInt();
        int[] calories = new int[n];
        for (int i = 0; i < n; i++) {
            calories[i] = - sc.nextInt();
        }
        Arrays.sort(calories);
        double ans = baseCalory / basePrice;
        for (int i = 0; i < n; i++) {
            if (ans < (baseCalory - calories[i]) / (basePrice + toppingPrice)) {
                baseCalory -= calories[i];
                basePrice += toppingPrice;
                ans = baseCalory / basePrice;
            } else {
                break;
            }
        }
        System.out.println((int)ans);
    }
}



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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code


int main()
{
  string s;
  int ss = INT_MAX;
  int ee = 0;
  cin>>s;
  rep(i, 0, s.length())
  {
    if(s[i] == 'A') ss = min(ss, i);
    if(s[i] == 'Z') ee = max(ee, i);
  }
  cout<<ee-ss+1<<endl;
  return 0;
}


Measured memory_bytes: 2948
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	map<int, int> mc;
	int cnt = 0;
	while (n--)
	{
		int x;
		cin >> x;
		if (x >= 3200) cnt++;
		else mc[x / 400]++;
	}
	cout << max(1, (int)mc.size()) << ' ' << mc.size() + cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,m,a[1005];
ll ans;
vector<ll>g,h;
int main(){
	in(n);in(m);
	for(int i=0;i<n;i++)in(a[i]);
	for(int i=0;i<n;i++){
		ll tot=0;
		for(int j=i;j<n;j++){
			tot+=a[j];
			g.push_back(tot);
		}
	}
	for(int k=40;k>=0;k--){
		ll mask=(1ll<<k);
		h.clear();
		int tot=0,len=g.size();
		for(int i=0;i<len;i++){
			if(g[i]&mask)h.push_back(g[i]),tot++;
		}
		if(tot>=m){
			ans+=mask;
			g.clear();
			g=h;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

main(){
  int N, M; 
  string name;
  set<string> U;
  cin >> N;
  for ( int i = 0; i < N; i++ ){
    cin >> name;
    U.insert(name);
  }
  int state = 0;
  cin >> M;
  for ( int i = 0; i < M; i++ ){
    cin >> name;
    if ( U.find(name) == U.end() ){
      cout << "Unknown " << name << endl;
    } else {
      cout << ((state%2==0)?"Opened":"Closed") << " by " << name << endl;
      state++;
    }
  }
}

Measured memory_bytes: 1232
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,x,y = LI()
    x -= 1
    y -= 1
    c = collections.defaultdict(int)
    for i in range(n):
        xi = abs(i-x)
        for j in range(i+1,n):
            yj = abs(j-y)
            c[min(j-i, xi+yj+1)] += 1

    return JA([c[i] for i in range(1,n)], "\n")


print(main())





Measured memory_bytes: 5788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    bool flag =true;
    rep(i,n-1){
        if(a[i]==a[i+1]) flag = false;
    }
    if (flag) cout <<"YES";
    else cout <<"NO";
}

Measured memory_bytes: 1024
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
def sub(a, minus=False):
    m = 20
    inf = 10**15
    dp = [[inf]*m for _ in range(n)] # i以降、a[i]に4^jをかけたところからソート
    for j in range(m):
        dp[-1][j] = j
    for i in range(n-2, -1, -1):
        if a[i]>a[i+1]:
            v = 0
            ai = a[i]; ai1 = a[i+1]
            while ai>ai1:
                ai1 *= 4
                v += 1
            for j in range(m):
                if j+v<m:
                    dp[i][j] = j + dp[i+1][j+v]
                else:
                    dp[i][j] = j + dp[i+1][m-1] + (n-i-1)*(j+v-m+1)
        else:
            v = 0
            ai = a[i]; ai1 = a[i+1]
            while True:
                ai *= 4
                if ai<=ai1:
                    v += 1
                else:
                    break
            for j in range(m):
                dp[i][j] = j + dp[i+1][max(0, j-v)]
    if minus:
        ans = [(2*min(dp[i][j] for j in range(m))+(n-i)) for i in range(n)]
    else:
        ans = [2*min(dp[i][j] for j in range(m)) for i in range(n)]
    return ans
dp0 = sub(list(a))
dp1 = sub([item for item in a[::-1]], minus=True)[::-1]
dp0.append(0)
dp1.insert(0,0)
ans = min((dp0[i]+dp1[i]) for i in range(n+1))
print(ans)

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

#define llint long long int

using namespace std;

int main(){
    llint N;
    string S;

    cin >> N >> S;

    if(N <= 2){
        cout << 0 << endl;

        return 0;
    }
    llint N_R = 0;
    llint N_G = 0;
    llint N_B = 0;

    for(llint i = 0; i < N; i ++){
        if(S[i] == 'R'){
            N_R ++;
        }else if(S[i] == 'G'){
            N_G ++;
        }else if(S[i] == 'B'){
            N_B ++;
        }
    }
    llint ans = 0;

    ans += N_R * (N_R - 1) * (N_R - 2) / 6;
    ans += N_G * (N_G - 1) * (N_G - 2) / 6;
    ans += N_B * (N_B - 1) * (N_B - 2) / 6;

    ans += N_R * (N_R - 1) / 2 * (N_G + N_B);
    ans += N_G * (N_G - 1) / 2 * (N_R + N_B);
    ans += N_B * (N_B - 1) / 2 * (N_R + N_G);
    
    for(llint i = 3; i <= N; i += 2){
        ans += N - i + 1;
    }
    for(llint i = 1; 2 * i + 1 <= N; i ++){
        for(llint j = 0; j + 2 * i < N; j ++){
            if(S[j] == S[j + i] || S[j] == S[j + 2 * i] || S[j + i] == S[j + 2 * i]){
                ans --;
            }
        }
    }
    ans = N * (N - 1) * (N - 2) / 6 - ans;

    cout << ans << endl;
}

Measured memory_bytes: 3636
N,M=map(int, input().split())
T,F=[[]for i in range(N)],[[]for i in range(N)]
for i in range(N-1+M):
  a,b=map(int, input().split())
  a-=1
  b-=1
  T[a].append(b)
  F[b].append(a)
  
for i in range(N):
  if len(F[i])==0:
    R=i
    break
    
ans=[-1]*N
ans[R]=0

from collections import deque
q=deque([])
q.append(R)
s=set()
while q:
  now=q.popleft()
  s.add(now)
  for i in T[now]:
    if ans[i]==-1:
      c=0
      for j in F[i]:
        if j not in s:
          c=1
          break
      if c==0:
        ans[i]=now+1
        q.append(i)
        
for i in ans:
  print(i)

Measured memory_bytes: 45600
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
    int n, q;
    cin >> n >> q;
    vector<long long> a(n), sum1(n), sum2(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum1[i] = a[i];
        if(i % 2 == (n - 1) % 2) sum2[i] = a[i];
    }
    for(int i = 1; i < n; i++){
        sum1[i] += sum1[i - 1];
        sum2[i] += sum2[i - 1];
    }
    for(int i = 0; i < q; i++){
        int x;
        cin >> x;
        int l = 0, r = n + 1;
        while(r - l > 1){
            int mid = (l + r) / 2;
            int al = a[n - mid], ar = a[n - (mid + 1) / 2];
            if(abs(x - al) <= abs(x - ar)){
                l = mid;
            }else{
                r = mid;
            }
        }
        long long ans = sum1[n - 1] - sum1[n - (l + 1) / 2 - 1];
        if(n > l) ans += sum2[n - l - 1];
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define REP(i,p,n) for(int i=p;i<n;++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

int N;

int main()
{
    cin >> N;

    vector<string> S(N);
    rep (i, N) { cin >> S[i]; }

    ll ans = 0;

    ll ba = 0;
    ll b = 0;
    ll a = 0;

    rep (i, N)
    {
        const auto& s = S[i];

        for (ll j=0,n=s.size();j+1<n;++j)
        {
            if (s[j] == 'A' && s[j + 1] == 'B') { ++ans; }
        }

        const char head = s[0];
        const char last = s[s.size() - 1];

        if (head == 'B' && last == 'A') { ++ba; }
        else if (last == 'A') { ++a; }
        else if (head == 'B') { ++b; }
    }

    bool isOdd = false;

    if (a)
    {
        isOdd = true;
        --a;
    }

    while (ba)
    {
        if (isOdd) { ++ans; }
        --ba;
        isOdd = true;
    }

    while(a || b)
    {
        if (isOdd)
        {
            if (!b) { break; }

            --b;
            ++ans;
        }
        else
        {
            if (!a) { break; }

            --a;
        }

        isOdd = !isOdd;
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
    int N,color,cnt=0;
    vector<int> v;
    cin>>N;
    for(int i=0; i<N; i++) {
        cin>>color;
        v.push_back(color);
    }
    for(int i=1; i<N; i++){
        if(v[i-1]==v[i]){
            cnt++;
            if(i==N-1) { break; }
            else {i++;}
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

input=sys.stdin.readline

N,Q=map(int,input().split())
s=input()
query=[]
for i in range(Q):
    t,d=input().split()
    query.append((t,d))

def fall_left(num):
    pos=num
    for i in range(Q):
        t,d=query[i]
        pos=pos+(d=="R" and s[pos]==t)-(d=="L" and s[pos]==t)
        if pos==-1:
            return True
        elif pos==N:
            return False

    return False

def fall_right(num):
    pos=num
    for i in range(Q):
        t,d=query[i]
        pos=pos+(d=="R" and s[pos]==t)-(d=="L" and s[pos]==t)
        if pos==-1:
            return False
        elif pos==N:
            return True

    return False

ans=N
start=0
end=N-1
while end-start>1:
    test=(end+start)//2
    if fall_left(test):
        start=test
    else:
        end=test
if fall_left(end):
    ans-=(end+1)
elif fall_left(start):
    ans-=(start+1)

start=0
end=N-1
while end-start>1:
    test=(end+start)//2
    if fall_right(test):
        end=test
    else:
        start=test
if fall_right(start):
    ans-=(N-start)
elif fall_right(end):
    ans-=(N-end)

print(ans)


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

using namespace std;

#define all(c)	(c).begin(),(c).end()
#define rall(c)	(c).rbegin(),(c).rend()
#define rep(i,N)	for(int i=0;i<N;++i)
#define pb	push_back
#define eb	emplace_back

using ll = long long;

constexpr ll INF = 0x0fffffffffffffff;
constexpr int inf = 0x1fffffff;
constexpr double inf_l = 1e18;
constexpr ll MOD = 1000000007LL;
constexpr int mod = 1000000007;

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

	for (int i = 0; i < s.size() - 1; ++i) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << ' ' << i + 2 << endl;
			return 0;
		}
	}
	for (int i = 0; i < s.size() - 2; ++i) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << ' ' << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
const int mod = 1e9 + 7;

ll mpow(ll x, ll n) {
  ll res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n /= 2;
  }
  return res;
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  vl d(m + 1);
  d[m] = 1;
  for (int t = 0; t < n; ++t) {
    vl nd(d.size());
    ll s = 0;
    for (int i = m; i > 0; --i) {
      nd[i] = (i * s + d[i] * (i + 1)) % mod;
      s = (2 * s + d[i]) % mod;
    }
    d.swap(nd);
  }
  ll res = 0;
  for (int i = 0; i < d.size(); ++i) res = (res + d[i]) % mod;
  cout << res << endl;
  return 0;
}


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

int main() {
  string s, s2, s3;
  int64_t k;
  cin >> s >> k;

  int64_t ans1 = 0, tmp1 = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == s[i+1]) {
      tmp1++;
    }
    else {
      ans1 += (tmp1 + 1) / 2;
      tmp1 = 0;
    }
  }
  ans1 += (tmp1 + 1) / 2;

  int64_t ans2 = 0, tmp2 = 0;
  s2 = s + s;
  for (int i = 0; i < s2.size(); i++) {
    if (s2[i] == s2[i+1]) {
      tmp2++;
    }
    else {
      ans2 += (tmp2 + 1) / 2;
      tmp2 = 0;
    }
  }
  ans2 += (tmp2 + 1) / 2;

  int64_t ans3 = 0, tmp3 = 0;
  s3 = s + s + s;
  for (int i = 0; i < s3.size(); i++) {
    if (s3[i] == s3[i+1]) {
      tmp3++;
    }
    else {
      ans3 += (tmp3 + 1) / 2;
      tmp3 = 0;
    }
  }
  ans3 += (tmp3 + 1) / 2;

  if ((ans3 - ans2) ==  (ans2 - ans1)) {
    cout << ans1 + (ans2 - ans1) * (k - 1) << endl;
  }

  else {
    cout << ans1 + (ans2 - ans1) * (k / 2) + (ans3 - ans2) * ((k - 1) / 2) << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a + b == c || b + c == a || a + c == b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
vector<int> lj[yuzu|10];

int main(){
int i,j,n,m,q;
cin>>n>>m>>q;
for (i=1;i<=m;++i) {
  int l=read(),r=read();
  lj[l].push_back(r);
  }
for (i=1;i<=500;++i) sort(lj[i].begin(),lj[i].end());
for (i=1;i<=q;++i){
  int l=read(),r=read(),ans=0;
  for (j=l;j<=r;++j){
    ans+=upper_bound(lj[j].begin(),lj[j].end(),r)-lj[j].begin();
    }
  write(ans),pl;
  }
}


Measured memory_bytes: 4480
#include<iostream>
#include <queue>
typedef long long ll;
using namespace std;
priority_queue<int >q;
int main(){
	ll n,m,x,t,sum=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>x;
		q.push(x);
	}
	for(int i=0;i<m;i++){
		t=q.top()/2;
		q.pop();
		q.push(t);
	}
	while(!q.empty()){
		sum+=q.top();
		q.pop();
	}
	printf("%lld",sum);
	return 0;
} 

Measured memory_bytes: 892
#include<stdio.h>
int main(){
  int n,num=1,i;
  scanf("%d",&n);
  int a[n+1];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]==num)
      num++;
  }
  if(num==1)
    printf("-1\n");
  else
    printf("%d\n",n-num+1);
  return 0;
}


Measured memory_bytes: 896
N = int(input())
A = []
for i in range(2):
    array = list(map(int, input().strip().split()))
    A.append(array)



ans = 0
dp1 = 0

for i in range(N):
    dp1 += A[0][i]
    dp2 = sum(A[1][i:])
    ans = max(ans,dp1+dp2)

print(ans)

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

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

    int n, a, b;
    cin >> n >> a >> b;

    if (a > n || b > n) {
        cout << "-1\n";
        return 0;
    }
    vector<int> inc(a);
    vector<vector<int>> squeeze(a);
    iota(inc.begin(), inc.end(), n - a + 1);

    int x = 1;
    bool hit = (b == 1);
    for (int i=0; i<a; i++)
        if (x < n - a + 1)
            for (int j=0; j<b-1 && x<n-a+1; j++) {
                squeeze[i].push_back(x++);
                if (j == b - 2)
                    hit = true;
            }
    if (x < n - a + 1 || !hit) {
        cout << "-1\n";
        return 0;
    }

    for (int i=0; i<a; i++) {
        cout << inc[i] << " ";
        for (int j=(int)squeeze[i].size()-1; j>=0; j--)
            cout << squeeze[i][j] << " ";
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 11212
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

	reple(i, 1, 9)
	{
		reple(j, 1, 9)
		{
			if (n == i * j)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [int(x) for x in input().split()]


answer = []
B = 0

for i in range(N):
    U = N - i
    L = N // (U)
    if L == 1:
        answer.append(a[U-1])
    else:
        for j in range(L-1):
            t = U * (j+1)
            B += answer[-t]
        B = B % 2
        if B == a[U-1]:
            answer.append(0)
        else:
            answer.append(1)
    B = 0


k = 0



answer.reverse()
print(answer.count(1))
J = len(answer)
for i in range(J):
    if answer[i] == 1:
        print(i+1, end=' ')

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

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while(true){
		c -= b;
		if(c <= 0){
			cout << "Yes" << endl;
			break;
		}
		a -= d;
		if(a <= 0){
			cout << "No" << endl;
			break;
		}
	}
}

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

using namespace std;
typedef long long ll;

int main() {
    int x, n; cin >> x >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

    int ans = 0;
    int m = 10000100;
    for (int i = 120; i > -20; i--) {
        bool f = false;
        for (int j = 0; j < n; j++) {
            if(i == p[j]) {
                f = true;
                break;
            }
        }
        if (f) continue;
        if (m >= abs(x - i)) {
            ans = i;
            m = abs(x-i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		String stdin = "";
		while(std.hasNextLine()){
			stdin += std.nextLine();
		}
		stdin = stdin.toLowerCase();

		int num[] = new int[26];
		for(int i=0; i<stdin.length(); i++){
			if(String.valueOf(stdin.charAt(i)).matches("[a-z]")){
				num[(stdin.charAt(i)-'a')]++;
			}
		}
		for(int j=0; j<26; j++){
			System.out.println((char)(j+'a') + " : "+num[j]);
		}
	}
}

Measured memory_bytes: 29188
def multiply(num1, num2): 
    len1 = len(num1) 
    len2 = len(num2) 
    if len1 == 0 or len2 == 0: 
        return "0"
  
    # will keep the result number in vector 
    # in reverse order 
    result = [0] * (len1 + len2) 
      
    # Below two indexes are used to  
    # find positions in result. 
    i_n1 = 0
    i_n2 = 0
  
    # Go from right to left in num1 
    for i in range(len1 - 1, -1, -1): 
        carry = 0
        n1 = ord(num1[i]) - 48
  
        # To shift position to left after every 
        # multiplication of a digit in num2 
        i_n2 = 0
  
        # Go from right to left in num2 
        for j in range(len2 - 1, -1, -1): 
              
            # Take current digit of second number 
            n2 = ord(num2[j]) - 48
          
            # Multiply with current digit of first number 
            # and add result to previously stored result 
            # at current position. 
            summ = n1 * n2 + result[i_n1 + i_n2] + carry 
  
            # Carry for next iteration 
            carry = summ // 10
  
            # Store result 
            result[i_n1 + i_n2] = summ % 10
  
            i_n2 += 1
  
            # store carry in next cell 
        if (carry > 0): 
            result[i_n1 + i_n2] += carry 
  
            # To shift position to left after every 
            # multiplication of a digit in num1. 
        i_n1 += 1
          
        # print(result) 
  
    # ignore '0's from the right 
    i = len(result) - 1
    while (i >= 0 and result[i] == 0): 
        i -= 1
  
    # If all were '0's - means either both or 
    # one of num1 or num2 were '0' 
    if (i == -1): 
        return "0"
  
    # generate the result string 
    s = "" 
    while (i >= 0): 
        s += chr(result[i] + 48) 
        i -= 1
  
    return s 
  
# Driver code 
str1, str2 = input().split()
str2 = str2.replace(".", "")
# print(str1)
# print(str2)
if((str1[0] == '-' or str2[0] == '-') and 
   (str1[0] != '-' or str2[0] != '-')): 
    print("-", end = '') 
  
  
if(str1[0] == '-' and str2[0] != '-'): 
    str1 = str1[1:] 
elif(str1[0] != '-' and str2[0] == '-'): 
    str2 = str2[1:] 
elif(str1[0] == '-' and str2[0] == '-'): 
    str1 = str1[1:] 
    str2 = str2[1:]
res = multiply(str1, str2)
if len(res)>2:
    print(multiply(str1, str2)[:-2]) 
else:
    print(0)

Measured memory_bytes: 9220
/*
 * main.cpp
 *
 *  Created on: 2020/04/11
 *      Author: SkAaO
 */

#include <iostream>

using namespace std;

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

	for(int i = 1;;i++){
		int hole_num = (A - 1) * (i - 1) + 1;
		if(hole_num >= B){
			cout << i - 1 << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;
using ll = long long;
using P = pair<int,int>;

const int mod = 1000000007;
struct mint {
  ll x; 
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
 //お試し
int main() {
    int K;
    string S;
    cin>>K>>S;
    int n=S.size();
    combination c(n+K);
    mint ans=0;
    for(int i=0;i<=K;i++){
      mint now=mint(26).pow(K-i);
      now*=mint(25).pow(i);
      now*=c(i+n-1,n-1);
      ans+=now;
    }
    cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 35608
#再帰の深さが1000を超えそうなときはこれをやっておく
import sys
sys.setrecursionlimit(10**7)

n,x=map(int,input().split())
a=[0]*(n+1)
p=[0]*(n+1)
a[0]=1
p[0]=1
for i in range(n):
  a[i+1]=2*a[i]+3
  p[i+1]=2*p[i]+1
  
def func(i,x):
  if i==0:
    if x<=0:
      return 0
    elif x>=1:
      return 1
  mid=(a[i]+1)//2
  if mid==x:
    return p[i-1]+1
  elif mid>x:
    return func(i-1,x-1)
  else:
    return p[i-1]+1+func(i-1,x-mid)


print(func(n,x))  

Measured memory_bytes: 9040
def resolve():
    n = int(input())

    if n <= 6:
        return print(1)
    elif n <= 11:
        return print(2)
    else:
        c = n // 11
        MOD = 2 if n % 11 > 6 else 1
        if n % 11 == 0:
            MOD = 0
    print(c*2+MOD)

if __name__ == '__main__':
    resolve()


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   int n, x, y;
   cin>>n>>x>>y;
   x--; y--;

   vector<int> e[2000];
   rep(i, n-1){
      e[i].push_back(i+1);
      e[i+1].push_back(i);
   }
   e[x].push_back(y);
   e[y].push_back(x);

   vector<int> c(n);
   rep(i, n){
      vector<bool> mita(n);
      queue<int> q, nq;
      q.push(i);
      mita[i]=true;
      int k=1;
      while(!q.empty()){
         while(!q.empty()){
            int v=q.front(); q.pop();
            repit(it, e[v]) if(!mita[*it]){
               c[k]++;
               nq.push(*it);
               mita[*it]=true;
            }
         }
         swap(q, nq);
         k++;
      }
   }

   for(int i=1; i<=n-1; i++) cout<<(c[i]/2)<<endl;
   return 0;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  int N;
  cin >> N;
  ll ans = 1;
  REP(i, N){
    ans *= 10;
    ans %= mod;
  }
  ll sub = 1;
  REP(i, N){
    sub *= 9;
    sub %= mod;
  }
  ll add = 1;
  REP(i, N){
    add *= 8;
    add %= mod;
  }
  ans -= sub;
  ans %= mod;
  if(ans < 0){
    ans += mod;
  }
  ans -= sub;
  ans %= mod;
  if(ans < 0){
    ans += mod;
  }
  ans += add;
  ans %= mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
//package Contest081;

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            String str = sc.nextLine();
            int cnt =0;
            for(char x :str.toCharArray())
                if(x=='1')
                    cnt++;
            out.println(cnt);
        out.flush();
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << ' ' << b << ' ' << c;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF = 1e9;
#define debug(x) cout << #x << ":" << x << endl
using namespace std;
int main(){
    intl a;
    cin >> a;
    intl b;
    cin >> b;
    if(a < 10)b += 100 * (10 - a);
    cout << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#define ll long long 
using namespace std;
ll dp[105][100005];
vector<ll>value,weight;
int main()
{
ll i,j,n,W,temp1,temp2;
	cin>>n;
	cin>>W;
	for(i=0;i<n;i++)
		{
			cin>>temp1;
			cin>>temp2;
			weight.push_back(temp1);
			value.push_back(temp2);
		}
	memset(dp,-1,sizeof(dp));	
	for(j=0;j<=W;j++)
			{
				if(weight[0]<=j)	
					dp[0][j]=value[0];
				
				else
					dp[0][j]=0;	
			}
	for(i=1;i<n;i++)
		{
			for(j=0;j<=W;j++)
				{
					if(weight[i]>j)
						{
							dp[i][j]=dp[i-1][j];
						}
					else
						{
							dp[i][j] = max( ( value[i]  + dp[i-1][ (j-weight[i] ) ]) , dp[i-1][j] ) ;
						}	
				}
		}
	cout<<dp[n-1][W]<<endl;	
		
}

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

int N=10000;
vector <long long> a(N,0);

void ans() {
    long long cnt = 0;
    for (int i=0; i<N; i++) {
        while(a.at(i)%2==0) {
            a.at(i)/=2;
            cnt++;
        }
    }
    cout << cnt;
}

int main() {
    cin >> N;
    for (int i=0; i<N; i++) cin >> a.at(i);
    ans();
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    string N;
    cin >> N;
    int head,tail;
    if(N.size()<=2){
        P(0);
    }else if(N.size()>=5){
        P(1);
    }else if(N.size()==3){
        head=N[0]-'0';
        tail=(N[1]-'0')*10+N[2]-'0';
        if(tail<=head*5){
            P(1);
        }else{
            P(0);
        }
    }else if(N.size()==4){
        head=(N[0]-'0')*10+N[1]-'0';
        tail=(N[2]-'0')*10+N[3]-'0';
        if(tail<=head*5){
            P(1);
        }else{
            P(0);
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	if(n<1200) cout << "ABC" << endl;
	else if(n<2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N = in.i();
        String ans = "Three";
        for (int i = 0; i < N; i++) {
            char c = in.c();
            if (c == 'Y') {
                ans = "Four";
                break;
            }
        }
        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = read(cbuf, 0, cbuf.length);
            } catch (IOException e) {}
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                back();
                break;
            }
        }
    }

    char[] s(final int N) {
        skip();
        char[] s = new char[N];
        for (int i = 0; i < s.length; i++) {
            s[i] = next();
        }
        return s;
    }

    char c() {
        skip();
        return next();
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 32368
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,m,fa[N],di[N];
inline int ask(int x){
	if (fa[x]==x) return x;
	int t=ask(fa[x]);
	di[x]+=di[fa[x]];
	return fa[x]=t;	
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i) fa[i]=i;
	for (int id=1,x,y,z;id<=m;++id){
		scanf("%d%d%d",&x,&y,&z);
		int u=ask(x),v=ask(y),dx=di[x],dy=di[y];
		if (u!=v){
			fa[u]=v;
			di[u]=dy-dx-z;
		}else{
			if (dx+z!=dy) return puts("No"),0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n;
    cin >> n;
    int f = 0, x = n;
    while(n != 0) {
        f += n % 10;
        n /= 10;
    }
    if(x % f == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{ 
  char a;
  cin>>a;
  if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
  { 
    cout<<"vowel"<<endl;
  }
  else
  { 
    cout<<"consonant"<<endl;
  }
}

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

#define N 100009
int x,y,a,b,c,colour[3];
long long ans;
struct apple{int d,g;} app[3*N];
bool cmp(apple a,apple b){return a.d>b.d;}
bool cmp0(apple a,apple b)
{
	if(a.g==1 and b.g!=1)return 0;
	if(b.g==1 and a.g!=1)return 1;
	return(a.d>b.d);
}
bool cmp1(apple a,apple b)
{
	if(a.g==0 and b.g!=0)return 0;
	if(b.g==0 and a.g!=0)return 1;
	return(a.d>b.d);
}

int main()
{
	cin >> x >> y >> a >> b >> c;
	int cnt = 0;
	for(int i = 0,p;i<a;i++,cnt++)
	{
		cin >> p;
		app[cnt] = (apple){p,0};
	}
	for(int i = 0,p;i<b;i++,cnt++)
	{
		cin >> p;
		app[cnt] = (apple){p,1};
	}
	for(int i = 0,p;i<c;i++,cnt++)
	{
		cin >> p;
		app[cnt] = (apple){p,2};
	}
	sort(app,app+a+b+c,cmp);
	for(int i = 0;i<x+y;i++)
	{
		colour[app[i].g]++;
	}
	if(colour[0]<=x and colour[1]<=y)
	{
		for(int i = 0;i<x+y;i++)ans += app[i].d;
	}
	else if(colour[0]>x)
	{
		for(int i = 0,tot = 0;tot<x;i++)
		{
			if(app[i].g==0)
			{
				ans += app[i].d;
				tot++;
			}
		}
		sort(app,app+a+b+c,cmp1);
		for(int i = 0;i<y;i++)ans += app[i].d;
	}
	else if(colour[1]>y)
	{
		for(int i = 0,tot = 0;tot<y;i++)
		{
			if(app[i].g==1)
			{
				ans += app[i].d;
				tot++;
			}
		}
		sort(app,app+a+b+c,cmp0);
		for(int i = 0;i<x;i++)ans += app[i].d;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a+b>c+d)
        printf("Left");
    if(a+b==c+d)
        printf("Balanced");
    if(a+b<c+d)
        printf("Right");
    return 0;
}


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

int main(){
  int h, w, n;
  cin >> h >> w >> n;
  
  int ans = h*w;
  
  for(int i=0; i<=h; i++){
    for(int j=0; j<=w; j++){
      if(i*h + j*w -i*j >= n){
        ans = min(ans, i+j);
        break;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string b;
  cin>>b;
  if(b=="A"){
    cout<<"T"<<endl;
  }else if(b=="T"){
    cout<<"A"<<endl;
  }else if(b=="G"){
    cout<<"C"<<endl;
  }else if(b=="C"){
    cout<<"G"<<endl;
  }

}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define repN_1(i, n) for(int i = 0; i < (int)(n - 1); i++)
#define repM(i, n) for(int i = (int)(n - 1); i >= 0; i--)
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; }

int main()
{
	int r;

	cin >> r;

	cout << r * r << endl;

	return 0;
}

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

int main() {
  long long n,k;cin>>n>>k;
  if (!(n%k)) {
    cout << 0 << endl;
    return 0;
  } else {
    if (n > k) n %= k;
    long long n_prev = n;    
    n = abs(n_prev-k);
    if (n_prev<n) {
      cout << n_prev << endl;
      return 0;
    } else {
      cout << n << endl;
      return 0;
    }
  }
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#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 ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	ll ruisekiwa;
	ll a[n];
	FOR(i,0,n)cin >> a[i];
	ll ans1 = 0;
	if(a[0] > 0){
		ruisekiwa = a[0];
	}else{
		ans1 = 1 - a[0];
		ruisekiwa = 1;
	}
	FOR(i,1,n){
		if(ruisekiwa * (ruisekiwa+a[i]) < 0){
			ruisekiwa += a[i];
		}else if(ruisekiwa > 0){
			ans1 += (ruisekiwa+a[i])+1;
			ruisekiwa = -1;
		}else{
			ans1 += 1-(ruisekiwa+a[i]);
			ruisekiwa = 1;
		}
	}
	ll ans2 = 0;
	if(a[0] < 0){
		ruisekiwa = a[0];
	}else{
		ans2 = a[0] + 1;
		ruisekiwa = -1;
	}
	FOR(i,1,n){
		if(ruisekiwa * (ruisekiwa+a[i]) < 0){
			ruisekiwa += a[i];
		}else if(ruisekiwa > 0){
			ans2 += (ruisekiwa+a[i])+1;
			ruisekiwa = -1;
		}else{
			ans2 += 1-(ruisekiwa+a[i]);
			ruisekiwa = 1;
		}
	}
	//cout << ans1 << " " << ans2 << "\n";
	ANS(min(ans1,ans2));
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#define ll long long
using namespace std;

int main()
{
    ll n,o=0;
    cin >> n;
    vector<ll> t(n),a(n);
    vector<string> s(n);
    for (ll i = 0; i < n;i++){
        cin >> s[i] >> t[i];
        o += t[i];
        a[i] = o;
    }
    string x;
    cin >> x;
    for (ll i = 0; i < n; i++)
    {
        if(s[i]==x){
            cout << a[n - 1] - a[i] << endl;
        }
    }
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0

for ia in range(a+1):
    for jb in range(b+1):
        for kc in range(c+1):
            if(0 == (x - (ia*500 + jb*100 + kc*50))):
                count += 1

print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>

using namespace std;
		
int main(void){
	string str,search;
	int count=0;
	cin>>search;
	for(int i=0;i<search.size();i++){
		if(isupper(search[i]))
			search[i] = tolower(search[i]);
	}
	while(1){
		cin>>str;
		if(str=="END_OF_TEXT")
			break;
		for(int i=0;i<str.size();i++){
			if(isupper(str[i]))
				str[i] = tolower(str[i]);
		}

		if(str==search)
			count++;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

struct stu{
    ll rank;
    ll num;
    bool operator< (const stu &stu1) const{
        return rank < stu1.rank;
    };
};


int main(void){
    ll n; cin >> n;
    priority_queue <stu> as;
    REP(i, n){
        ll a; cin >> a;
        as.push({-1*a, i+1});
    }
    REP(i, n){
        stu s = as.top();
        as.pop();
        cout << s.num;
        if (i < n-1){
            cout << " ";
        } else {
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2544
#include <stdio.h>
int main(){
    long int X,Y;
    scanf("%ld%ld",&X,&Y);
    int count=0;
if(X>500000000){
    if(X%Y==0){
    printf("%d",-1);
    count=100;
    }else{
        printf("%ld",X);
        count=100;
    }
}else if(X%Y==0){
    printf("%d",-1);
    count=100;
}else{
    for(long int i=0;i<=10000000000;i++){
        if((X*i)%Y!=0){
            printf("%ld",X*i);
            count+=1;
            break;
        }
    }
}
if(count==0){
    printf("%d",-1);
}

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    string n; cin >> n;
    int a = n[n.size() - 1] - '0';

    if (a == 3) cout << "bon" << endl;
    else if (a == 0 || a == 1 || a == 6 || a == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	int cnt=0;
	long long ans=0;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
    	if(s[i]=='A')
    	{
    		cnt++;
		}
		else if(s[i]=='B')
    	{
        	if(s[i+1]=='C')
        	{
        		i++;
				ans+=cnt;
			}
        	else 
        	{
        		cnt=0;
			}
    	}
    	else 
    	{
    		cnt=0;
		}
	}
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N, A, B;
   cin >> N >> A >> B;
   cout << min(A * N, B) << endl;
   return 0;
}


Measured memory_bytes: 256