akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    // 愚直解を書く
    // 自分の左が自分より小さければノーカンを検証
    // 移動のたびに出し入れ

    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    set<vector<int>> s;


    auto is_first = [&]() -> bool {
        vector<int> u = v;
        sort(u.begin(), u.begin() + k);
        return u != v;
    };

    int ans = 1;
//    if (is_first()) ans++;

    set<int> used;
    rep(i, k) used.insert(v[i]);

    rep(i, n - k + 1) {
        if (i == 0) continue;

        int next_in = v[i + k - 1];
        int next_out = v[i - 1];

        bool is_left_min = [&]() -> bool {
            auto it = used.begin();
            return *it == next_out;
        }();
        bool is_right_max = [&]() -> bool {
            auto it = used.end();
            it--;
            return *it < next_in;
        }();

        if ((!is_left_min) || (!is_right_max))ans++;

        used.insert(next_in);
        used.erase(used.find(next_out));
    }

    vector<int> dp(n, 1);
    rep(i, n) {
        if (i == 0) continue;
        if (v[i - 1] < v[i])dp[i] = dp[i - 1] + 1;
    }

    int uc = count(dp.begin(), dp.end(), k);
    if (uc >= 2) {
        ans -= (uc - 1);
    }


    cout << ans << endl;
}


Measured memory_bytes: 14012
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll x, y; cin>>x>>y;
  
  if(2*x<=y&&y<=4*x&&y%2==0) cout << "Yes";
  else cout << "No";
  
}

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

int main() {
  int N;
  cin >> N;
  int hun,ten,one;
  hun=N/100;
  ten=(N-100*hun)/10;
  one=N-100*hun-ten*10;
  if(hun==7 || ten==7 || one==7){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;

}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,D;
  long long ans = 0;
  cin >> N >> D;
  long long powD = D*D;
  for(long long i = 0;i < N;i++){
   long long X,Y;
   cin >> X >> Y;
   if((X*X + Y*Y) <= powD){
    ans++;
   }    
  }
  cout << ans << endl;
} 

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;
int h, w, k;
vector<string> s;

const int inf = 1e9;

int calc(int stat) {
	vector<int> group(h);

	int g = 0;
	for (int i = 0; i < h; i++) {
		group[i] = g;
		if ((stat >> i) & 1) {
			g++;
		}
	}

	int ret = 0;
	vector<int> cnt(group.size(), 0);
	for (int j = 0; j < w; j++) {
		vector<int> tmp(group.size(), 0);
		for (int i = 0; i < h; i++) {
			if (s[i][j] == '1') {
				tmp[group[i]]++;
			}
		}

		bool ok = true;
		for (int a = 0; a < group.size(); a++) {
			cnt[a] += tmp[a];
			if (cnt[a] > k ) {
				ok = false;
				ret++;
				break;
			}
		}

		if (!ok) {
			cnt = tmp;
			for (auto x: cnt) {
				if (x > k) {
					return inf;
				}
			}
		}
	}

	return ret;
}

int main() {
	cin >> h >> w >> k;

	s.assign(h, "");
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	int ans = inf;
	int limit = 1 << (h - 1);
	for (int i = 0; i < limit; i++) {
		int tmp = calc(i);
		// printf("i %d %d %d\n", i, tmp, __builtin_popcount(i));
		ans = min(ans, tmp + __builtin_popcount(i));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false);
	int n; cin >> n;
	vi v;
	int c0 = 0, c1 = 0;
	REP(i, n)
	{
		int a; cin >> a;
		if (a == 0) c0++;
		else if (a == 1) c1++;
		else v.emplace_back(a);
	}
	sort(ALL(v));

	if (v.size() > 0 && c0 > 0 && c0%2 && c1 == 0)
	{
		int t = v[0];
		v.erase(v.begin());
		REP(i, c0 - 1) v.push_back(0);
		v.push_back(t);
		v.push_back(0);
	}
	else if (c0 > 0 && c0 % 2 && c1 > 0)
	{
		REP(i, c0 - 1) v.push_back(0);
		v.push_back(1);
		v.push_back(0);
		REP(i, c1 - 1) v.push_back(1);
	}
	else
	{
		REP(i, c0) v.push_back(0);
		REP(i, c1) v.push_back(1);
	}

	ll tmp = 1;
	for (int i = v.size() - 1; i > 0; i--)
	{
		if (tmp == 1 && v[i] == 3 && v[i - 1] == 2)
		{
			swap(v[i], v[i - 1]);
			break;
		}
		else if (tmp > 1) break;
		else tmp = pow(v[i], tmp);
	}

	for (auto i : v) cout << i << endl;
	return 0;
}

Measured memory_bytes: 3348
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

int main()
{
  int a,b;
  cin >> a >> b;

  if(a+b==15)cout << '+' << endl;
  else if(a*b==15)cout << '*' << endl;
  else cout << 'x' << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 200000 + 5;

int n;
char s[N];

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	int tmp = 0, ans = 0;
	for (int i = 1; i <= n; i++) {
		tmp = max(tmp, 0);
		tmp += (s[i] == 'S' ? 1 : -1);
		if (tmp < 0) ans++;
	}
	printf("%d\n", ans * 2);
	return 0;
}

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

int main(){
    int A,B;
    cin >> A >>B;
    long double memo,memo2,memo3=0; 
    for(int i = 1;i<1001;i++){
        memo = i * 0.08;
        memo2 = i * 0.1;
        memo = floor(memo);
        memo2 = floor(memo2);
        if(memo == A && memo2 ==B){
        cout << i;
        memo3 = 1;
        break;
        }
    }
    if(memo3 == 0) cout << -1;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;

	char buf[L], *S , *T, c;

	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}

	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}

	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	char B[45], *outs=B+40, *outr=B+40;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;

		if(!a)*--outs = '0';
		else
			while(a)
				*--outs = (a % 10) + 48, a /= 10;

		if(x)
			*--outs = x;

		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

const int MOD = 1000000007;
const int INF = 1000000010;
const int MAXN = 200010;

int n, m;
int s[MAXN], p[MAXN];

int main()
{
	
	cin >> n >> m;
	for (int i = 0; i < m; ++ i)
	{
		int k;
		cin >> k;
		s[i] = 0;
		for (int j = 1; j <= k; ++ j)
		{
			int x;
			cin >> x;
			x --;
			s[i] |= 1<<x;
		}
	}
	for (int i = 0; i < m; ++ i)
		cin >> p[i];
	
	int ans = 0;
	for (int i = 0; i < 1<<n; ++ i)
	{
		int cnt = 0;
		for (int j = 0; j < m; ++ j)
			if (__builtin_popcount(s[j]&i)%2 == p[j]) ++ cnt;
		ans += cnt == m;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
cake_limit = n//4 + 1
dough_limit = n//7 + 1
flag = True
for i in range(cake_limit):
    for ii in range(dough_limit):
        if 4*(i) + 7*(ii) == n and flag:
            print("Yes")
            flag = False
if flag:
    print("No")

Measured memory_bytes: 3060
'''
Name: Devansh
Username: singhdevansh
Github: https://github.com/Devansh3712
'''

import os
import sys
import math
from itertools import *
from io import BytesIO, IOBase
from collections import *

#<fast I/O>
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
#</fast I/O>

#<template>
mod=(10**9)+7
pi=3.14159265358979323846264338327950

def i1():	#int(input())
	return int(sys.stdin.readline())

def sf():	#input()
	return sys.stdin.readline()

def mi():	#map(int(input()))
	return map(int,sys.stdin.readline().split())

def arr():	#list(map(int,input().split()))
	return list(map(int,sys.stdin.readline().split()))

def pf(ans): #print(x)
	return sys.stdout.write(str(ans)+"\n")

def gcd(a,b):
	if a==0:
		return b
	elif b==0:
		return a
	if a>b:
		return gcd(a%b,b)
	else:
		return gcd(a,b%a)

def lcm(a,b):
	return (a*b)//gcd(a,b)
#</template>


#<solve>
def solve():
	n=i1()
	c=[]
	for i in range (n):
		a,b=mi()
		if a==b:
			c.append(1)
		else:
			c.append(0)
	flag=False
	try:
		for i in range (n):
			if c[i:i+3]==[1,1,1]:
				flag=True
				break
	except IndexError:
		pass
	if flag==True:
		print('Yes')
	else:
		print('No')
solve()
#</solve>

#<solution>
# tc=i1()
# for t in range (tc):
# 	solve()
#<solution>

Measured memory_bytes: 9508
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#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, m, n) for(int i=m; i<n; i++)
using namespace std;
typedef unsigned long ul;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    ll n, T, i, ans=0;
    cin >> n >> T;
    ll t[n];
    
    for(i=0; i<n; i++)
        cin >> t[i];
    
    for(i=1; i<n; i++) {
        if(t[i]-t[i-1]>=T) {
            ans+=T;
        }else {
            ans+=t[i]-t[i-1];
        }
    }
    cout << ans+T << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;

int main(){
    int N , M , C , res=0;
    cin >> N >> M >> C;
    int B[M],A[N][M],R[N];
    for (int i =0;i < M;i++){
        cin >> B[i];
    }
    for(int i = 0;i < N;i++){
        R[i]=C;
        for(int j = 0;j < M;j++){
            cin >> A[i][j];
            R[i] = R[i] + A[i][j]*B[j];

            }
            if(R[i]>0){
                res++;
        }

    }

    cout << res << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int Tate[101][101],Yoko[101][101];
    long long int Box[101][101];
    int n,m,l;
    int i,j,k=0;

    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&Tate[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%d",&Yoko[i][j]);
        }
    }

    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            Box[i][j]=0;
            for(k=0;k<m;k++){
                Box[i][j] += Tate[i][k]*Yoko[k][j];
            }
            printf("%lld",Box[i][j]);
            if(j!=l-1) printf(" ");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2108
// Problem : B - Making Triangle
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
using namespace std;
bool tri(lli a,lli b,lli c){
	if(a+b>c && b+c>a && c+a>b)
	return true;
	return false;
}
int main()
{
	cio;
	lli t,n,i;
	cin>>n;
	lli a[n];
	t=0;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		for(lli j=i+1;j<n;j++){
			for(lli k=j+1;k<n;k++){
				if(tri(a[i],a[j],a[k])){
					if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])
					t++;
				}
			}
		}
	}
	cout<<t;
	return 0;
}

Measured memory_bytes: 3612
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
ll n;
int cnt=0;
deque<int> v;
void solve(ll n)
{
    if(n==1) return;
    if(n&1) {solve(n-1); v.push_front(++cnt);}
    else
    {
        solve(n>>1);
        v.push_back(++cnt);
    }
}
int main()
{
    scanf("%lld",&n);solve(n+1);
    printf("%d\n",2*cnt);
    for(auto x:v) printf("%d ",x);
    for(int i=1;i<=cnt;i++) printf("%d ",i);
    puts("");
    return 0;
}



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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

template<typename T> void ckmin(T& a, const T& b) { a = min(a, b); }
template<typename T> void ckmax(T& a, const T& b) { a = max(a, b); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N;
    cin >> N;
    N = 2 * N - 1;

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

    int ans = 1;
    for (int lo = 2, hi = N; lo <= hi; ) {
        int mi = (lo + hi) / 2;
        auto seq = [&](int i) { return a[i] >= mi; };

        int mid = N / 2, l = mid, r = mid;
        while (l > 0 && seq(l - 1) != seq(l))
            l--;
        while (r + 1 < N && seq(r + 1) != seq(r))
            r++;

        int res;
        if (l == 0 && r == N - 1) res = seq(0);
        else if (l == 0) res = seq(r);
        else if (r == N - 1) res = seq(l);
        else res = mid - l < r - mid ? seq(l) : seq(r);

        if (res) { ans = mi; lo = mi + 1; }
        else hi = mi - 1;
    }

    cout << ans << endl;

    return 0;
}



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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin >>s>>t;
	int ans = 0;
	for(int i = 0; i<s.length();i++)
	{
		if(s[i] != t[i])
			ans++;
	}
	cout <<ans<<endl;

}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

struct Node {
    int key = INT_MAX;
    Node* left = NULL;
    Node* right = NULL;
    Node() {}
    Node(int key) : key(key) {}
    void preprint() {
        cout<<" "<<this->key;
        if (left != NULL) {
            left->preprint();
        }
        if (right != NULL) {
            right->preprint();
        }
    }
    void inprint() {
        if (left != NULL) {
            left->inprint();
        }
        cout<<" "<<this->key;
        if (right != NULL) {
            right->inprint();
        }
    }
    void insert(int key) {
        if (key < this->key) {
            if (left == NULL) left = new Node(key);
            else left->insert(key);
        }
        else {
            if (right == NULL) right = new Node(key);
            else right->insert(key);
        }
    }
};

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

    int n;
    cin>>n;
    Node root = Node();
    rep(i, n) {
        string ins;
        cin>>ins;
        if (ins == "print") {
            root.inprint();
            cout<<endl;
            root.preprint();
            cout<<endl;
            continue;
        }

        int key;
        cin>>key;
        if (root.key == INT_MAX) {
            root.key = key;
            continue;
        }
        root.insert(key);
    }
}


Measured memory_bytes: 18832
using System;


public class B{
	
	public static void Main(){
	
		string str = Console.ReadLine();
		
		bool result = true;
		int cIndex = str.IndexOf("C");
		if( cIndex < 2 || cIndex > str.Length - 2 || str[0] != 'A' ){
			result = false;
			
		}else{
			for( int i = 1; i < str.Length; i++ ){
				if( char.IsUpper(str[i]) ){
					if( i != cIndex ){
						result = false;
						break;
					}
				}
			}
			
		}
		
		Console.WriteLine( result ? "AC" : "WA" );
		
	}

}

Measured memory_bytes: 13280
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define For(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int h, a; cin >> h >> a;
    int ans = 0;
    while(h > 0){
        h -= a;
        ans++;
    }

    cout << ans << endl;

return 0;
}

Measured memory_bytes: 3604
S = input()
N = len(S)
f = True
for i in range((N-1)//2):
  #print(i,(N-1)//2-i-1)
  if S[i] != S[(N-1)//2-i-1]:
    f = False
for i in range((N-1)//2):
  #print((N-1)//2+1+i,(N-1)//2+1+(N-1)//2-i-1)
  if S[(N-1)//2+1+i] != S[(N-1)//2+1+(N-1)//2-i-1]:
    f = False
for i in range(N):
  if S[i] != S[N-1-i]:
    f = False
print('Yes' if f else 'No')


Measured memory_bytes: 38256
/* - - - - - - - - - - - - - - -
	User : 		VanishD
	problem :
	Points : 	
- - - - - - - - - - - - - - - */
# include <bits/stdc++.h>
# define 	ll 		long long
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read(){
	int tmp = 0, fh = 1; char ch = getchar();
	while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
	return tmp * fh;
}
int num[11000];
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	int n = read();
	for (int i = 1; i <= n; i++)
		num[i] = read();
	sort(num + 1, num + n + 1);
	printf("%d\n", num[n] - num[1]);
	return 0;
}


Measured memory_bytes: 256
N=int(input())
rest_list = []
for i in range(N):
  Si, Pi = input().split()
  Pi = int(Pi)
  rest_list.append((i+1,Si,Pi))
  
for i in range(N-1):
  for j in range(i+1,N):
    ii,Si,Pi = rest_list[i]
    jj,Sj,Pj = rest_list[j]
    
    if Si > Sj or (Si == Sj and Pi < Pj):
      rest_list[i], rest_list[j] = (jj,Sj,Pj),(ii,Si,Pi)
      
for i in range(N):
  i,Si,Pi = rest_list[i]  
  print(i)
      

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,R,T;
int P[100];

int pos[100];
int f[1000],e[1000];

signed main(){
    cin>>N>>R>>T;
    rep(i,N)cin>>P[i];

    rep(t,T){
        rep(i,N){
            pos[i]=(pos[i]+P[i])%R;
            if(f[pos[i]])f[pos[i]]--;
            if(t)e[pos[i]]++;
        }
        rep(i,R){
            f[i]+=e[i];
            e[i]=0;
        }
    }

    int ans=0;
    rep(i,R)ans+=f[i];
    cout<<ans+N<<endl;
    return 0;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(' ');
                decimal a = decimal.Parse(temp[0]);
                decimal b = decimal.Parse(temp[1]);
                int n = int.Parse(temp[2]);

                decimal d = a / b;
                int sum = 0;

                for (int i = 0; i < n; i++)
                {
                    d *= 10;
                    d %= 10;
                    sum += (int)d;
                }
                sb.AppendLine(sum.ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9240
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N,K;
    string S;
    cin >> N >> K;
    cin >> S;
    vector<int> l;
    int i=0,tmp=0;
    while(i<N){
        tmp=0;
        if(S[i]=='1'){
            while(S[i]=='1'){
                tmp++;
                i++;
            }
        }else{
            while(S[i]=='0'){
                tmp++;
                i++;
            }
        }
        l.push_back(tmp);
    }
    int hp;
    int ans=0;
    for(int i=0; i<(int)l.size(); i++){
        tmp =0;
        hp = K;
        
        if((S[0]=='1' && i%2==0) || (S[0]=='0' && i%2==1)){
            hp = hp *2 + 1;
            hp = min(hp, (int)l.size()-i);
            for(int j=i; j<i+hp; j++){
                tmp += l[j];
            }
        }else{
            if(i==0){
                hp = hp *2;
                hp = min(hp, (int)l.size()-i);
                for(int j=i; j<i+hp; j++){
                    tmp += l[j];
                }
            }
        }
        ans = max(ans,tmp);
        if(ans == N){
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++)
    {
        cin>>vec.at(i);
    }
    int k=0;
    for (int i = 0; i < n; i++)
    {
        if (vec.at(i)%2==1&&i%2==0)
        {
            k++;
        }
      
        
    }
    cout<<k<<endl;

    

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  ll result = 1;
  for (int i = 1; i <= N; i++) {
    result *= i;
    result %= 1000000007;
  }
  
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
s = input()
s_len = len(s)
sa_len = int((s_len-1)/2)
sk_len = int((s_len + 3)/2)

ans = 'No'
if s == s[::-1]:
  szen = s[:sa_len]
  if szen == szen[::-1]:
    skou = s[sk_len-1:]
    if skou == skou[::-1]:
      ans = 'Yes'

print(ans)

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

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      long N = Long.parseLong(br.readLine());
      long ans = 0;
      for(long i = 1; i <= N; i++){
        if(i%3 != 0 && i%5 != 0){
          ans += i;
        }
      }
      System.out.println(ans);
    }catch(Exception e){
    }
  }
}

Measured memory_bytes: 32472
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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 int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


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

    string s;
    cin>>s;
    int n=s.length();
    vi ans(n,0);
    vi rl(n,INF);
    vi point;
    vi minp(n);
    for(int i=0;i<n-1;i++){
        if(s[i]=='R'&&s[i+1]=='L'){
            rl[i]=0;
            rl[i+1]=0;
            minp[i]=i;
            minp[i+1]=i+1;
            point.push_back(i);
        }
    }
    for(int i=0;i<point.size();i++){
        int t=point[i]-1;
        while(t>=0&&rl[t]>rl[t+1]&&s[t]=='R'){//left
            rl[t]=rl[t+1]+1;
            minp[t]=point[i];
            t--;
        }
        t=point[i]+2;
        while(t<n&&rl[t-1]+1<rl[t]&&s[t]=='L'){
            rl[t]=rl[t-1]+1;
            minp[t]=point[i]+1;
            t++;
        }
    }
    // rep(i,n)cout<<rl[i]<<" ";
    // cout<<endl;
    // rep(i,n)cout<<minp[i]<<" ";
    // cout<<endl;
    for(int i=0;i<n;i++){
        if(rl[i]%2==0){
            ans[minp[i]]++;
        }
        else{
            if(s[i]=='R'){
                ans[minp[i]+1]++;
            }
            else{
                ans[minp[i]-1]++;
            }
        }
    }
    rep(i,n-1)cout<<ans[i]<<" ";
    cout<<ans[n-1]<<endl;




//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 2000
n=int(input())
if n<10:
    print(n)
elif n>=10 and n<100:
    print(9)
elif n>=100 and n<1000:
    print(9+n-99)
elif n>=1000 and n<10000:
    print(909)
elif n>=10000 and n<100000:
    print(909+n-9999)
else:
    print(90909)


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

#ifdef ONLINE_JUDGE
#define freopen \
  if (0) freopen
#define cerr \
  if (0) cerr
#endif

#define fi first
#define se second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)

#define sqr(a) ((a)*1ll * (a))
#define sz(a) (int)a.size()
#define len(a) (int)a.length()
#define all(a) a.begin(), a.end()
#define nl '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pi;

const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

int n, d, q;
int x[100010];
int dp[100010][20];
int a, b;

void solve() {
  cin >> n;
  rep(i, 1, n)
    cin >> x[i];
  cin >> d;

  rep(i, 1, n) {
    int l = i + 1, r = n + 1;
    while (l < r) {
      int m = (l + r) >> 1;
      if (x[m] - x[i] <= d) {
        l = m + 1;
      } else {
        r = m;
      }
    }
    dp[i][0] = l - 1;
  }

  rep(k, 1, 17) {
    rep(i, 1, n) {
      dp[i][k] = dp[dp[i][k - 1]][k - 1];
    }
  }

  cin >> q;
  rep(i, 0, q - 1) {
    cin >> a >> b;
    if (a > b) swap(a, b);
    int days = 0;

    per(k, 17, 0) {
      if (dp[a][k] < b) {
        days += (1<<k);
        a = dp[a][k];
      }
    }

    a = dp[a][0];
    days++;

    cout << days << nl;
  }
}

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

  freopen(".in", "r", stdin);

  solve();

  return 0;
}

Measured memory_bytes: 11860
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
using vc = vector<char>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int n;
  string s;
  cin >> n >> s;
  vector<long> cnt(26,0);
  rep(i,n){
    cnt.at(s.at(i)-'a')++;
  }
  long ans = 1;
  rep(i,26){
    ans *= cnt.at(i)+1;
    ans %= MOD;
  }
  cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<map>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
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 mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////   
/////////////////////////

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

  double  ar[n+2];

  double sum = 0;
  for(int i = 1;i<=n;i++){
      cin>>ar[i];
      sum += ar[i];
  }
  sort(ar + 1, ar + n+1);
  reverse(ar + 1, ar +n+1);

    bool fl = 0;
  for(int i = 1;i<=m;i++){
      double x = ((double)sum)/ ((double)m * 4.0);
      if(ar[i] < x)fl = 1;
  }
if(fl)cout<<"No"<<endl;
else cout<<"Yes"<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bitset>
using namespace std;
#define inf 1000000007
#define MOD 1000000007
#define x first
#define y second
#define ll long long
#define ii pair<ll, ll>
#define vi vector<ll>
#define vii vector<ii>
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N = 4e6 + 5;
ll n, k;
bitset<N> bit;
/*
    for every bitmask ( eg 100101 ) of the array , if its sum is greater than s/2, then its 
    compliment exists such that its sum is less than s/2.
    as 00000 is not allowed so ans will be just greater than s/2, if s/2 doesn't exists
    else s/2.
*/


int main()
{
 //   ios
 //   freopen("in.txt", "r", stdin);
 //   freopen("out.txt", "w", stdout);
    ll i ,j , sum=0, a,  c, d,b, p=0,z;
    cin>>n;
    bit[0]= 1;
    for(i=1; i<=n; i++){
        cin>>a;
        sum+= a;
        bit |= bit<<a;
    }
    for(i=(sum+1)/2; ; i++)
        if(bit[i]){
            cout<<i;
            return 0;
        }
}

Measured memory_bytes: 1664
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

const int MOD = 1000000007;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> m(N + 1, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    int cand1 = ((N + 1) + A[i]) / 2;
    int cand2 = ((N + 1) - A[i]) / 2;
    if (cand1 == cand2) {
      m[cand1]++;
      continue;
    }
    m[cand1]++, m[cand2]++;
  }
  ll res = N % 2;
  for (int i = 1; i <= N; i++) {
    int x = m[i];
    if (x != 2) {
      if (res == 1 && x == 1) {
        res--;
      } else {
        cout << 0 << endl;
        return 0;
      }
    }
  }
  ll ans = 1;
  for (int i = 1; i <= N / 2; i++) {
    ans = ans * 2 % MOD;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int,int> P;
#define MAX_D 64
#define MOD ((ll)1e9 + 7)
ll N,dp[MAX_D][3],res;int nxt;

int main() 
{	
	scanf("%lld",&N);
	dp[MAX_D-1][0]=1;
	for(int i=MAX_D-1;i>0;i--) 
	    for(int j=0; j <= 2; j++)
		    for(int dv=0;dv<=2;dv++) 
			{
		        nxt=j*2+((N>>(i-1))&1)-dv;
		        if (nxt<0) continue;
		        nxt=nxt>2?2:nxt;
		        (dp[i-1][nxt]+=dp[i][j])%=MOD;
		    }
	res=0;
	for (int i=0;i<=2;i++) (res+=dp[0][i])%=MOD;
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def prime_factorize(n):
    a = defaultdict(int)
    while n % 2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n] += 1
    return a


def main():
    N = int(readline())
    a = prime_factorize(N)

    ans = 0
    for power in a.values():
        tmp = power
        for j in range(1, power + 1):
            if tmp >= j:
                tmp -= j
                ans += 1
            else:
                break

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9476
import 'dart:io';
import "dart:math";

void main() {
  List input =
      stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();
  int a = input[0];
  int b = input[1];
  int c = input[2];
  int x = input[3];
  int y = input[4];
  List sumList = [];
  int kkMax = (x < y) ? x : y;
  // print(kkMax);
  for (int kk = 0; kk <= 100000; kk++) {
    int sum;
    sum = max(0, x - kk) * a + max(0, y - kk) * b + (kk * c * 2);

    sumList.add(sum);
  }
  // print(sumList);
  List sortedS = sumList..sort((a, b) => a.compareTo(b));
  print(sortedS[0]);
}


Measured memory_bytes: 15008
import sys
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
 
H,W = map(int,input().split())
 
table = [[0]*(W+1) for i in range(H+1)]
 
for row in range(H):
    work = list(map(int,input().split())) #★★直にtableに代入すると、列数が変わってしまう!!!★★★
    for col in range(W):
        table[row][col] = work[col]
 
 
for row in range(H):
    for col in range(0,W):
        table[row][W] += table[row][col]
 
 
for col in range(0,W+1):
    for row in range(0,H):
        table[H][col] += table[row][col]
 
 
for row in range(0,H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end = "")
    print()


Measured memory_bytes: 6220
#include <bits/stdc++.h>
#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 rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
//const int MAX=;

int N;
int C[18][2];
void input(){
    cin>>N;
    rep(i, N){
        cin>>C[i][0];
    }
    rep(i, N){
        cin>>C[i][1];
    }
}

void solve(){
    int ans = 5000;
    rep(bit, 1<<N){
        int bs = 0;
        rep(i, N) bs += (1 & (bit >> i));
        if(bs & 1 == 1) continue;
        vi bak[51];
        rep(i,N){
            bak[C[i][(1 & (bit >> i))]].pb(i);
        }
        int tmp = 0;
        bool ok= true;
        vi order(N);
      	
        rep1(j, 50){
            int now = tmp + sz(bak[j]);
            int odd, even;
            int to, te;
            if(tmp % 2 == 0){
                to = tmp +1;
                te = tmp;
                odd = (now-tmp) / 2;
                even = now - tmp - odd;
            }
            else{
                to = tmp;
                te = tmp + 1;
                even = (now - tmp)/2;
                odd = now - tmp - even; 
            }
          	vi xx[2];
          	rep(k, sz(bak[j])){
              	int ch = (bak[j][k] + (1 & (bit >> bak[j][k]))) % 2;
                xx[ch].pb(bak[j][k]);
            }

            if(sz(xx[0])!= even || sz(xx[1])!= odd){
                ok = false;
                break;
            }
            rep(k, sz(xx[0])){
                order[xx[0][k]] = te;
                te += 2;
            }
            rep(k, sz(xx[1])){
                order[xx[1][k]] = to;
                to += 2;
            }            
            tmp = now;
        }
        if(!ok) continue;
        int rev = 0;
        rep(i, N)rep(j, N)if(i<j){
            if(order[i]>order[j]) rev++;
        }
        ans = min(ans ,rev);
    }
  	if(ans == 5000) cout<<-1<<endl;
  	else cout<<ans<<endl;
}

void output(){
  
}

int main(){
  input();
  if(N == 1){
      cout<<0<<endl;
  }
  else{
      solve();
  }
  output();
}

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

int main(void) {
	int n, q, k;
	vector<int> v;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &k);
		v.push_back(k);
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d", &k);
		printf("%d %d\n", distance(v.begin(), lower_bound(v.begin(), v.end(), k)),
			distance(v.begin(), upper_bound(v.begin(), v.end(), k)));
	}
}


Measured memory_bytes: 3536
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		int N = sc.nextInt();
		String S = sc.next();
		
		long rCount = 0;
		long gCount = 0;
		long bCount = 0;

		for (int i = 0; i < S.length(); i++) {
			if (S.charAt(i) == 'R') rCount++;
			if (S.charAt(i) == 'G') gCount++;
			if (S.charAt(i) == 'B') bCount++;
		}
		long total = rCount * gCount * bCount;
		
		int count = 0;
		for (int i = 1; i <= N-2; i++) {
			for (int j = i+1; j <= N-1; j++) {
				int k = j + (j - i);
				if (k > N) {
					continue;
				}
				if (S.charAt(i-1) != S.charAt(j-1) &&
					S.charAt(j-1) != S.charAt(k-1) &&
					S.charAt(k-1) != S.charAt(i-1)) {
					count++;
				}
			}
		}
		// 結果の出力
		System.out.println(total - count);

		sc.close();
	}
}


Measured memory_bytes: 28228
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int ary[1010][1010]={};
int mwri(int y,int x){
	int cnt=0;
	if(ary[y-1][x-1]==0)cnt++;
	if(ary[y-1][x]==0)cnt++;
	if(ary[y-1][x+1]==0)cnt++;
	if(ary[y][x-1]==0)cnt++;
	if(ary[y][x+1]==0)cnt++;
	if(ary[y+1][x-1]==0)cnt++;
	if(ary[y+1][x]==0)cnt++;
	if(ary[y+1][x+1]==0)cnt++;
	return cnt;
}

int main(){
	int H,W,cnt,are,ax,ay;
	char tmp;
	bool isen;
	set<int> *sew,*sew2;
	set<int> se,se2,se3;
	set<int>::iterator it,it2;
	cin>>H>>W;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin>>tmp;
			if(tmp=='.') ary[i][j]=0;
			else ary[i][j]=tmp-'0';
		}
	}

	//???????????¨??¢?´¢
	isen=true;
	for(int i=1;i<H-1;i++){
		for(int j=1;j<W-1;j++){
			if(ary[i][j]!=0&&mwri(i,j)>=ary[i][j]){
				se3.insert(i*W+j);
				se.insert(i*W+j-1);
				se.insert(i*W+j+1);
				se.insert(i*W+j+W-1);
				se.insert(i*W+j+W);
				se.insert(i*W+j+W+1);
				se.insert(i*W+j-W-1);
				se.insert(i*W+j-W);
				se.insert(i*W+j-W+1);
				isen=false;
				//cout<<"cc "<<i<<" "<<j<<endl;//
			}
		}
	}
	if(isen){
		cout<<0<<endl;
		return 0;
	}
	it=se3.begin();
	while(se3.end()!=it){
		ay=*it/W;
		ax=*it%W;
		ary[ay][ax]=0;
		it++;
	}

	cnt=0;
	//cout<<"nnn"<<endl;//
	while(1){
	se3.clear();
	cnt++;
	isen=true;
	if(cnt%2==1){
		sew=&se;
		sew2=&se2;
	}
	else{
		sew=&se2;
		sew2=&se;
	}
	(*sew2).clear();
	it=(*sew).begin();
	
	while(it!=(*sew).end()){
		are=*it;
		ay=are/W;
		ax=are%W;
		if(ary[ay][ax]!=0&&mwri(ay,ax)>=ary[ay][ax]){
			se3.insert(ay*W+ax);
			(*sew2).insert(ay*W+ax-1);
			(*sew2).insert(ay*W+ax+1);
			(*sew2).insert(ay*W+ax+W-1);
			(*sew2).insert(ay*W+ax+W);
			(*sew2).insert(ay*W+ax+W+1);
			(*sew2).insert(ay*W+ax-W-1);
			(*sew2).insert(ay*W+ax-W);
			(*sew2).insert(ay*W+ax-W+1);
			isen=false;
			//cout<<"ccc "<<ay<<" "<<ax<<endl;//
		}
		it++;
	}
	if(isen){
		cout<<cnt<<endl;
		return 0;
	}
	it2=se3.begin();
	while(se3.end()!=it2){
		ay=*it2/W;
		ax=*it2%W;
		ary[ay][ax]=0;
		it2++;
	}
	//cout<<"aaa"<<endl;//
	}

}

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

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

  for (int i = 1; i < 1010; i++)
  {
    if (i*8/100 == A && i/10 == B){
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

char s[105];
char t[105];

int main() {

	int N;

	scanf("%d",&N);

	scanf("%s",s);
	scanf("%s",t);

	int i, j;

	int ans = 2 * N;

	for (i = 0; i < N; i++) {
		int cnt = 0;
		for (j = 0; j < N; j++) {
			if (i + j < N) {
				if (s[i + j] == t[j]) { cnt++; }
				else {
					cnt = 0;
					break;
				}
			}
		}
		if (cnt > 0) {
			printf("%d\n", ans - cnt);
			return 0;
		}
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 128