akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(k,n) for(k=0;k<n;++k)

int main() {
	long long int N;
	cin >> N;
	int i;
	long long int a=1, b=1, c=1;
	long long int mod = 1000000007;
	rep(i, N) {
		a = a * 10;
		a = a % mod;
		b = b * 8;
		b = b % mod;
		c = c * 9;
		c = c % mod;
	}
	c = (2 * c) % mod;
	if (a + b >= c) {
		cout << (a + b - c) % mod;
	}
	else {
		cout << (a + b + mod - c) % mod;
	}
	return 0;
}

Measured memory_bytes: 3624
def arg(operator):
    try:
        return elements.index(operator)
    except:
        return 100000000000000


elements = [elem if elem in ['+', '-', '*']
            else int(elem) for elem in input().split()]

while len(elements) != 1:
    if arg('+') or arg('-') or arg('*'):
        i = arg('+')
        i = min(i, arg('-'))
        i = min(i, arg('*'))

        if elements[i] == '+': r = elements[i-2] + elements[i-1]
        elif elements[i] == '-': r = elements[i-2] - elements[i-1]
        elif elements[i] == '*': r = elements[i-2] * elements[i-1]

        # i, i-1, i-2 -> one element
        elements = elements[:i-2] + [r] + elements[i+1:]
    else:
        break

print(elements[0])

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

int main()
{
  // freopen("in.txt","r",stdin); 
   int a, b;
   while (~scanf("%d%d", &a, &b))
   {
     a += b;
     a %= 24;
     printf("%d\n", a);
   }
   return 0;
}


Measured memory_bytes: 256
n = int(input())
xy = []
for _ in range(n):
    a = int(input())
    ls = []
    for _ in range(a):
        x, y = map(int, input().split())
        ls.append((x - 1, y))
    xy.append(ls)

ans = 0
for p in range(2 ** n + 1):
    candidate = 0
    friends = {}
    for i in range(n):
        if p & (1 << i) > 0:
            friends[i] = 1
        else:
            friends[i] = 0

    valid = True
    for i in range(n):
        if p & (1 << i) > 0:
            friendly = True
            for x, y in xy[i]:
                if friends[x] != y:
                    friendly = False

            if friendly:
                candidate += 1
            else:
                valid = False
                break
    if valid:
        ans = max(ans, candidate)

print(ans)


Measured memory_bytes: 45020
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	set<int> A;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (A.find(a) != A.end()) {
			cout << "NO" << "\n";
			return 0;
		}
		else A.emplace(a);
	}

	cout << "YES" << "\n";

	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
typedef pair<double,long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	string s;
	cin >> s;
	ll cnt = 0,n = s.length();
	vector<ll>seq(n+1,0);
	for (ll i = 0; i < n; i++) {
		if (s[i] == '<') {
			seq[i + 1] = max(seq[i+1],seq[i] + 1);
		}
	}
	for (ll i = n; i >= 1; i--) {
		if (s[i-1] == '>') {
			seq[i-1] = max(seq[i-1], seq[i] + 1);
		}
	}
	cout << accumulate(all(seq),0LL) << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> memo(10, vector<int>(10));
  vector<int> dp(n+1);
  for(int i = 1; i <= n; i++) {
    string str = to_string(i);
    int first = str.front() - '0';
    int last = str.back() - '0';
    dp[i] = dp[i-1] + memo[last][first]*2;
    if (first == last) dp[i]++;
    memo[first][last]++;
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll add(ll a,ll b){
	return a+b;
}
struct P{
	ll x,y;
	int val;
	P() {}
	P(ll x,ll y):x(x),y(y){}
	P(ll x,ll y,int val):x(x),y(y),val(val){}
	P operator +(P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator -(P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator *(double d){
		return P(d*x,d*y);
	}
	ll dot(P p){
		return add(x*p.x,y*p.y);
	}
	ll det(P p){
		return add(x*p.y,-y*p.x);
	}
};
bool comp(const P& p,const P& q){
	if(p.x!=q.x)return p.x<q.x;
	return p.y<q.y;
}
vector<P> convex_hull(P* ps,int n){
	sort(ps,ps+n,comp);
	int k=0;
	vector<P> qs(2*n);
	for(int i=0;i<n;i++){
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<0ll)k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--){
		while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<0ll)k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}
int R,C,N;
int M;
P ps[200100];
bool used[100100];
bool Xedge(int x){
	if(x==0||x==R)return true;
	else return false;
}
bool Yedge(int y){
	if(y==0||y==C)return true;
	else return false;
}
int main(){
	cin >> R >> C >> N;
	for(int i=0;i<N;i++){
		int x1,y1,x2,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if((Xedge(x1)||Yedge(y1))&&(Xedge(x2)||Yedge(y2))){
			ps[2*M]=P(x1,y1,i+1);
			ps[2*M+1]=P(x2,y2,i+1);
			M++;
		}
	}
	M*=2;
	vector<P> ch = convex_hull(ps,M);
	assert(ch.size()==M);
	/*for(int i=0;i<ch.size();i++){
		cout << ch[i].x << ' ' << ch[i].y << ' ' << ch[i].val << endl;
 	}*/
 	stack<int> s;
 	for(int i=0;i<ch.size();i++){
 		int c = ch[i].val;
 		if(used[c]){
 			if(s.top()!=c){
 				printf("NO\n");
 				return 0;
 			}
 			s.pop();
 		}else{
 			s.push(c);
 			used[c]=true;
 		}
 	}
 	printf("YES\n");
	return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(int argc, char *argv[])
{
  char row[12];
  int i;
  int max_diff = INT_MIN;
  int min;
  int n = atoi(fgets(row, sizeof(row), stdin));

  if (n == 0) {
    printf("err\n");
    exit(1);
  }

  min = atoi(fgets(row, sizeof(row), stdin));
  for (i = 1; i < n; i++) {
    int diff;
    int x = atoi(fgets(row, sizeof(row), stdin));
    diff = x - min;
    if (max_diff < diff) {
      max_diff = diff;
    }
    if (x < min) {
      min = x;
    }
  }

  printf("%d\n", max_diff);
  return 0;
}

Measured memory_bytes: 528
import sys
import collections

input = sys.stdin.readline


def main():
    N = int(input())
    C = collections.Counter()
    for _ in range(N):
        C[int(input())] += 1

    ans = 0
    for k in C.keys():
        if C[k] & 1:
            ans += 1

    print(ans)




    

if __name__ == '__main__':
    main()



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 405;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

LL rec(int l, int r);

LL dp[SIZE][SIZE];
vector<LL> v;
vector<LL> cum;

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

    int N;
    cin >> N;
    for(int i = 0; i < N; ++i) {
        LL a;
        cin >> a;
        v.pb(a);
    }

    cum.pb(0);
    for(int i = 0; i < N; ++i) {
        cum.pb(cum[i] + v[i]);
    }

    for(int i = 0; i <= N; ++i) {
        for(int j = 0; j <= N; ++j) {
            dp[i][j] = LINF;
        }
    }

    cout << rec(0, N) - (cum[N] - cum[0]) << endl;
    return 0;
}

/*
 * [l, r) までを合体させた時の最小コスト
 */
LL rec(int l, int r) {
    if(dp[l][r] != LINF) {
        return dp[l][r];
    }

    if(l == r) {
        return 0;
    }
    if(r - l == 1) {
        return v[l];
    }

    LL res = LINF;
    for(int i = l + 1; i <= r - 1; ++i) {
        res = min(res, rec(l, i) + rec(i, r));
    }

    return dp[l][r] = res + (cum[r] - cum[l]);
}


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

using namespace std;
#define ll long long
ll A[200002],B[200002];

int main(){
    int t;
    t=1;
    while (t--) {
        ll n, m ,ms;
        cin>>n>>m>>ms;
        for(int i = 0; i < n; i++)
            cin>>A[i];
        for(int i = 0; i < m; i++)
           cin>>B[i];
        ll sum = 0;
        ll x = 0, y = 0;
        while (x < n && sum + A[x] <= ms)
            sum += A[x++];
        ll ans = x;
        while (y < m && x >= 0) {
            sum += B[y++];
            while (sum > ms && x > 0)
                sum -= A[--x];
            if (sum <= ms && ans < x + y)
                ans = x + y;
        }
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 6764
import itertools

N = int(input())
MOD = 10**9 + 7
ACGT = ["A","C","G","T"]
dp = [ [ [ [0 for l in range(4) ] for k in range(4)] for j in range(4)] for i in range(N+1)]
dp[0][-1][-1][1] = 1

for i,p,q,r,s in itertools.product(range(N),range(4),range(4),range(4),range(4)):
  if ACGT[q] + ACGT[r] + ACGT[s] not in {'AGC', 'GAC', 'ACG'} \
  and ACGT[p] + ACGT[r] + ACGT[s] != 'AGC' \
  and ACGT[p] + ACGT[q] + ACGT[s] != 'AGC':
    dp[i + 1][q][r][s] += dp[i][p][q][r]
    dp[i + 1][q][r][s] %= MOD  
print(sum(sum(sum(y) for y in x) for x in dp[N]) % MOD)

Measured memory_bytes: 40688
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<iomanip>
#include<cmath>
#include<numeric>
#include<vector>
#include<algorithm>
#include<string>
#include<deque>
#include<stack>
#include<map>
#include<random>
#include<queue>
#include<iterator>
#include<bitset>
#include<unordered_set>
#include<set>

using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
const ll integer = pow(2, 32) - 1; // 4294967295
#define N 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
void AIA() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isprime(ll n) {
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0)return 0;
	}
	return (n != 1);
}
ll gcd(ll x, ll y)
{
	return (y == 0 ? x : gcd(y, x % y));
}
ll lcm(ll x, ll y) {
	return (x * y) / gcd(x, y);
}

/*
 _____________              __                ___        ___       ___________________________     ____        ____
|             |            /\ \              |   |      |   |     |                           |    \   \      /   /
|   __________|           / /\ \             |   |      |   |     |      _____      _____     |     \   \    /   /
|  |                     / /  \ \            |   |      |   |     |     |     |    |     |    |      \   \  /   /
|  |                    / /    \ \           |   |      |   |     |     |     |    |     |    |       \   \/   /
|  |______             / /      \ \          |   |______|   |     |     |     |    |     |    |        \      /
|         |           / /        \ \         |              |     |     |     |    |     |    |         \    /
|   ______|          / /          \ \        |    ______    |     |     |     |    |     |    |          |  |
|  |                / /============\ \       |   |      |   |     |     |     |    |     |    |          |  |
|  |               / /==============\ \      |   |      |   |     |     |     |    |     |    |          |  |
|  |              / /                \ \     |   |      |   |     |     |     |    |     |    |          |  |
|  |             / /                  \ \    |   |      |   |     |     |     |    |     |    |          |  |
|__|            /_/                    \_\   |___|      |___|     |_____|     |____|     |____|          |__|

										  <<<<<<<<<<< NEVER GIVE UP !! >>>>>>>>>>>
										<<<<<<<< YOU CAN DO IT IF YOU WANT !! >>>>>>>>
										 <<<<<<<<< BELIEVE IN YOURSELF !! >>>>>>>>>

*/

int main() {
	//cout << fixed << setprecision(9);
	//freopen("Input.txt.txt", "r", stdin);
	//freopen("Output.txt.txt", "w", stdout);
	AIA();
	int n, c = 0;
	double d;
	cin >> n >> d;
	while (n--) {
		double x, y, m;
		cin >> x >> y;
		m = sqrt((x * x) + (y * y));
		if (m <= d)c++;
	}
	cout << c;
	return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
#define MAX 100000
using namespace std;

int main()
{
  fastio
  ll n;
  cin >> n;
  ll years=0, bal=100;
  while(bal<n)
  {
    bal += bal/100;
    years++;
  }
  cout << years;
  
  return 0;
}




Measured memory_bytes: 3668
#include <iostream>
#include <string>
using namespace std;
int main() {
    int a, b;
    string s;
    cin >> a >> b >> s;
    for(int i=0; i<a; i++) {
        if(!(s[i]>='0' && s[i]<='9')) {
            cout << "No" << endl;
            return 0;
        }
    }
    if(s[a]!='-') {
        cout << "No" << endl;
        return 0;
    }
    for(int i=a+1; i<=a+b; i++) {
        if(!(s[i]>='0' && s[i]<='9')) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

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

const int mod=1000000007;

int a[410],b[410],c[410],d[410],f[410][410],g[410][410],s[410][410];

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int n;scanf("%d",&n);
	for (int i=1;i<=n;i++) {scanf("%d",&a[i]);c[a[i]]=i;}
	for (int i=1;i<=n;i++) {scanf("%d",&b[i]);d[b[i]]=i;}
	for (int i=1;i<=n+1;i++)
		for (int j=1;j<=n+1;j++)
			g[i][j]=1;
	for (int i=1;i<=n;i++)
	{
		s[i][n+1]=0;
		for (int j=n;j;j--)
		{
			s[i][j]=s[i][j+1];
			if (c[b[j]]>=i) s[i][j]++;
		}
	}
	for (int k=1;k<=n/3;k++)
	{
		for (int i=n;i;i--)
	    	for (int j=n;j;j--)
	        	if (a[i]!=b[j]&&d[a[i]]>j&&c[b[j]]>i)
	            {
                	f[i][j]=g[i+1][j+1];
               		int t=s[i][j]-k*2;
                    if (t>=k) f[i][j]=ll(f[i][j])*(t-k+1)%mod; else f[i][j]=0;
                    f[i][j]=ll(f[i][j])*(2*(3*(k-1)+1)+(3*(k-1)+1)*(3*(k-1)))%mod;
			    }
			    else
			    	f[i][j]=0;
		for (int i=1;i<=n+1;i++) g[n+1][i]=0;
		for (int i=n;i;i--)
		{
			int ss=0;
			for (int j=n+1;j;j--)
			{
				ss=(ss+f[i][j])%mod;
				g[i][j]=(g[i+1][j]+ss)%mod;
			}
		}
	}
	printf("%d\n",f[1][1]);
	return 0;
}



Measured memory_bytes: 2304
n,a,b,c=map(int,input().split())
l = [int(input()) for _ in range(n)]
ans = 100000000
for i in range(4**n):
  x,y,z=0,0,0
  s,t,u=0,0,0
  for j in range(n):
    if i % 4 == 0:
      x += l[j]
      s += 1
    elif i % 4 == 1:
      y += l[j]
      t += 1
    elif i % 4  == 2:
      z += l[j]
      u += 1
    i //= 4
  if s == 0 or t == 0 or u == 0:
    continue
  k = (s + t + u - 3) * 10
  k += abs(a - x)
  k += abs(b - y)
  k += abs(c - z)
  ans = min(ans, k)
print(ans)


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
#define MOD 1000000007
int main() {
	int h = ri(), w = ri();
	std::string a[h];
	for (auto &i : a) std::cin >> i;
	int dp[h][w];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
		if (a[i][j] == '#') continue;
		if (i + 1 < h) {
			dp[i + 1][j] += dp[i][j];
			if (dp[i + 1][j] >= MOD) dp[i + 1][j] -= MOD;
		}
		if (j + 1 < w) {
			dp[i][j + 1] += dp[i][j];
			if (dp[i][j + 1] >= MOD) dp[i][j + 1] -= MOD;
		}
	}
	std::cout << dp[h - 1][w - 1] << std::endl;
	return 0;
}


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

int main(void)
{
	int n;
	cin >> n;
	vector<int>res(n);
	for (int i = 0; i < n; i++)cin >> res[i];
	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		int b, m, e;
		cin >> b >> m >> e;
		rotate(res.begin() + b, res.begin() + m, res.begin() + e);
	}
	for (int i = 0; i < n; i++)
		if (i == 0)cout << res[i];
		else cout << " " << res[i];
	cout << endl;
	return 0;
}


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

int main() {
  int n, k, a; cin >> n >> k;
  int res{0};
  for (int i = 0; i < n; ++i) {
   	cin >> a;
   	if (a >= k) {
      res++;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3164
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cinll(L);

	double l = (1.0 * L) / 3;

	cout << setprecision(7) << fixed << l * l * l << endl;

}

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



Measured memory_bytes: 256
# ref https://atcoder.jp/contests/agc025/submissions/7307839
import numpy as np

def main():
    n = int(input())
    L, R = [], []
    for i in range(n):
        l, r = map(int, input().split())
        L.append(l)
        R.append(r)
    ll = np.array(L); ll.sort(); ll = ll[::-1]
    rr = np.array(R); rr.sort()

    lll = ll.cumsum()
    rrr = rr.cumsum()

    x = (lll - rrr).max()
    y = (lll[1:] - rrr[:-1]).max()
    z = (lll[:-1] - rrr[1:]).max()

    print(2 * max(x, y, z))
if __name__ == '__main__':
    main()

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll h,w;
    cin >> h >> w;
    ll MOD = 1e9+7;
    vector<string> graph(h);
    for(i = 0;i < h;++i){
        cin >> graph.at(i);
    }
    vector<vector<ll>> dp(h,vector<ll>(w,0));
    for(i = 0;i < w;++i){
        if(graph.at(0).at(i) == '.') dp.at(0).at(i) = 1;
        else{
            for(i = i;i < w;++i){
                dp.at(0).at(i) = 0;
            }
        }
    }
    for(i = 0;i < h;++i){
        if(graph.at(i).at(0) == '.') dp.at(i).at(0) = 1;
        else{
            for(i = i;i < h;++i){
                dp.at(i).at(0) = 0;
            }
        }
    }
    for(i = 1;i < h;++i){
        for(j = 1;j < w;++j){
            if(graph.at(i).at(j) == '#') dp.at(i).at(j) = 0;
            else{
                dp.at(i).at(j) = dp.at(i-1).at(j) + dp.at(i).at(j-1);
                dp.at(i).at(j) %= MOD;
            }
        }
    }
    cout << dp.at(h-1).at(w-1) << endl;

    return 0;
}

Measured memory_bytes: 9216
using System;

public class Hello
{
    public static void Main()
    {
        var m = "abcdefghijklmnopqrstuvwxyz.?! ";
        var p = 0;
        var ct = new char[6, 5];
        for (int i = 0; i < 6; i++)
            for (int j = 0; j < 5; j++)
                ct[i, j] = m[p++];
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var s = line.Trim();
            change(ct, s);
        }
    }
    public static void change(char[,] ct, string s)
    {
        var ret = "";
        var sL = s.Length;
        if (sL % 2 == 1) { Console.WriteLine("NA"); return; }
        for (int i = 0; i < (sL + 1) / 2; i++)
        {
            var x = int.Parse(s[2 * i].ToString()) - 1;
            if (x >= 6 | x < 0) { Console.WriteLine("NA"); return; }
            var y = int.Parse(s[2 * i + 1].ToString()) - 1;
            if (y >= 5 | y < 0) { Console.WriteLine("NA"); return; }
            ret += ct[x, y];
        }
        Console.WriteLine(ret);
    }
}

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

// Caleb Faith Adnaka XI105
int main() {

    int A,B;
    cin >> A >> B;
    
    if (A == B){
        cout << "Draw\n";
    }
    else if (A > B && B != 1 || A == 1){
        cout << "Alice\n";
    }
    else if (B > A && A != 1 || B == 1){
        cout << "Bob\n";
    }

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;

int main() {
    int N, C, K;
    cin >> N >> C >> K;

    vector<int> t(N);
    
    for (int i = 0; i < N; i++) {
        cin >> t[i];

    }
    sort(t.begin(), t.end());
    int ans = 1, cnt = 0;
    int st = t[0];
    //for (int i = 0; i < N; i++)
      //  cout << t[i] << " ";
    //cout << endl;

    for (int i = 0; i < N; i++) {
        cnt++;
       // cout << "st="<<st << endl;
        if (cnt > C||t[i]-st>K) {
            ans++;
            st = t[i];
            cnt = 1;
            
        }

    }
    cout << ans << endl;
}


Measured memory_bytes: 640
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = int.Parse(Console.ReadLine());
            Console.WriteLine(r * r);
        }
    }
}

Measured memory_bytes: 13140
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i)

hash = {}
s = 0
hash[s] = 1
a_arr.each do |a|
  s += a
  hash[s] ||= 0
  hash[s] += 1
end

result = 0
hash.each do |k, v|
  result += v * (v - 1) / 2
end

puts result


Measured memory_bytes: 39576
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var d = new Dictionary<int, int>();
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        for (int i = 0; i < n; i++)
            if (d.ContainsKey(a[i])) d[a[i]]++;
            else d[a[i]] = 1;
        var count = 0;
        foreach (var x in d)
            if (x.Key > x.Value) count += x.Value;
            else if (x.Key < x.Value) count += x.Value - x.Key;
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 25440
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	int h = sc.nextInt();
    	int m = sc.nextInt();
    	double minutesHand = m * 6;
    	double hourHand = h * 30 + m * 0.5;
    	double longth = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(minutesHand - hourHand)));
    	System.out.println(longth);
    }
}


Measured memory_bytes: 27188
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c;
    cin>>a>>b>>c;
    int d=b/a;
    cout<<min(d,c)<<endl;

    return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

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

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

signed main(){
    int X;
    cin >> X;
    if(X == 7 || X == 5 || X == 3) PRINT("YES");
    else PRINT("NO");
    return 0;
}

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

using namespace std;
#define int long long
const int MOD = 1000000007;
int bit(int a) {
	int res = 0;
	while (a > 0) {
		res++;
		a >>= 1;
	}
	return res;
}
int C(int a, int b) {
	int k = a + b;
	if (k == 0) return 1;
	int B = ((int)1 << (bit(k) - 1));
	if (a < B && b < B) {
		return 0;
	}
	if (a >= B) {
		return C(a - B, b);
	}
	return C(a, b - B);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// for (int i = 0; i < 10; i++) {
	// 	for (int j = 0; j < 10; j++) {
	// 		cerr << C(i, j);
	// 	}
	// 	cerr << endl;
	// }
	// return 0;
	int N;
	cin >> N;
	string S;
	cin >> S;
	vector<int> X(N);
	bool have1 = false;
	for (int i = 0; i < N; i++) {
		X[i] = S[i] - '1';
		if (X[i] == 1) {
			have1 = true;
		}
	}
	int res = 0;
	if (have1) {
		for (int i = 0; i < N; i++) {
			X[i] %= 2;
		}
	} else {
		for (int i = 0; i < N; i++) {
			X[i] /= 2;
		}
	}
	for (int i = 0; i < N; i++) {
		if (C(N - 1 - i, i) == 1 && X[i] == 1) {
			res ^= 1;
		}
	}
	if (!have1) {
		res *= 2;
	}

	cout << res << endl;
}

Measured memory_bytes: 9244
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N, ans;
  cin >> N;
  ans=0;
  vector<int> V(N);
  for (int i=0; i<N; i++) {
    cin >> V.at(i);
  }
  vector<int> C(N);
  for (int j=0; j<N; j++) {
    cin >> C.at(j);
  }
  vector<int> D(N);
  for (int k=0; k<N; k++) {
    D.at(k)=V.at(k)-C.at(k);
  }
  for (int l=0; l<N; l++) {
    ans=ans+max(D.at(l),0);
  }
  cout << ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    set<string> set;
    string stg;
    cin >> stg;
    set.insert(stg);
    char ec = stg[stg.size()-1];
    bool flag = true;
    for(int i = 1; i < n; i++)
    {
        cin >> stg;
        if ((stg[0]) == ec) {
            set.insert(stg);
            ec = stg[stg.size()-1];
        }
        else
        {
            flag = false;
        }
    }
    if (flag && set.size() == n) {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

struct toUpper {
  char operator () (char c) {
    return toupper(c);
  }
};

int main()
{
  string str;
  getline(cin , str);
  
  transform(str.begin(), str.end(), str.begin(), toUpper());
  cout << str << endl;
}

Measured memory_bytes: 0
#include <iostream> 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define MAX 1000001
ll prime[MAX];
#define FAST           ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007

ll rec(vector<vector<ll> >& dp,vector<ll>& arr,int n,int i,int k,int w)
{
  ll ans=0;
  if(i>=n)
    return 0;

  if(dp[i][k]!=-1)
    return dp[i][k];


  if(k!=0)
  ans=max(rec(dp,arr,n,i+1,w,w),arr[i]+rec(dp,arr,n,i+1,k-1,w));
  else
  ans=max(rec(dp,arr,n,i+1,k,w),rec(dp,arr,n,i+1,w,w));

  return dp[i][k]=ans;

}

//ll t[400008];
// void build(vector<ll>& a, int v, int tl, int tr) {
//     if (tl == tr) {
//         t[v] = a[tl];
//     } else {
//         int tm = (tl + tr) / 2;
//         build(a, v*2, tl, tm);
//         build(a, v*2+1, tm+1, tr);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }

// ll maxi(int v, int tl, int tr, int l, int r) {
//     if (l > r) 
//         return 0;
//     if (l == tl && r == tr) {
//         return t[v];
//     }
//     int tm = (tl + tr) / 2;
//     return max(maxi(v*2, tl, tm, l, min(r, tm)) ,maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
// }



// void update(int v, int tl, int tr, int pos, ll new_val) {
//     if (tl == tr) {
//         t[v] = new_val;
//     } else {
//         int tm = (tl + tr) / 2;
//         if (pos <= tm)
//             update(v*2, tl, tm, pos, new_val);
//         else
//             update(v*2+1, tm+1, tr, pos, new_val);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }


int main() { 

 string s;
 cin>>s;
 ll ans=0;
 for(int i=0;i<s.size();i++)
  ans+=(s[i]-'0');

if(ans%9==0)
cout<<"Yes";
else
cout<<"No";


return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
#define mod 998244353
#define maxn 200010
#define LL long long
using namespace std;
LL fact[maxn],inv[maxn],ans,t[maxn],p;
int n,m,k,nm;
LL quick_pow(LL a,LL b){//a^b
	LL ans=1;
	while(b){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans%mod;
}
void init(){
	int i;
	scanf("%d%d%d",&n,&m,&k);
	nm=n,nm=max(nm,m),fact[0]=1;
	for(i=1;i<=nm;i++)fact[i]=fact[i-1]*i%mod;//fact[i]代表i!
	inv[nm]=quick_pow(fact[nm],mod-2);
	for(i=nm-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;//inv[i]代表i!的乘法逆元
}
LL C(LL a,LL b){//组合数计算
	return fact[a]*inv[a-b]%mod*inv[b]%mod;
}
int main(){
	int i;
	init();
	ans=0,p=quick_pow(m-1,n-k-1);
	for(i=n-k;i<=n;i++){
		ans=(ans+m*p%mod*C(n-1,i-1)%mod)%mod;//C(n-1,i-1)隔板法
		p=p*(m-1)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4860
#include<iostream>
#include<algorithm>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=15;
const int maxm=101;
int a,b;
int d[maxn][maxn],e[maxm][maxm];
int main(){
	scanf("%d%d",&a,&b);
	for(register int i=1;i<=a;i++){
		for(register int j=1;j<=b;j++)
			scanf("%d",&d[i][j]);
	}
	for(register int i=0;i<maxm;i++){
		for(register int j=0;j<maxm;j++){
			for(register int x=1;x<=a;x++){
				for(register int y=1;y<=b;y++){
					e[i][j]=max(e[i][j],d[x][y]-i*x-j*y);
				}
			}
		}
	}
	for(register int x=1;x<=a;x++){
		for(register int y=1;y<=b;y++){
			int tmp=maxm;
			for(register int i=0;i<maxm;i++){
				for(register int j=0;j<maxm;j++){
					tmp=min(tmp,e[i][j]+i*x+j*y);
				}
			}
			if(tmp!=d[x][y]){
				cout<<"Impossible"<<endl;
				return 0;
			}
		}
	}
	cout<<"Possible"<<endl;
	cout<<2*maxm<<' '<<2*(maxm-1)+maxm*maxm<<endl;
	for(register int i=1;i<maxm;i++){
		printf("%d %d X\n",i,i+1);
		printf("%d %d Y\n",maxm+i,maxm+i+1);
	}
	for(register int i=0;i<maxm;i++){
		for(register int j=0;j<maxm;j++){
			printf("%d %d %d\n",i+1,2*maxm-j,e[i][j]);
		}
	}
	printf("1 %d\n",2*maxm);
}

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

typedef long long lint;
typedef pair<int, int> pint;
#define x first
#define y second

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

int n, a[100004];

bool judge() {
	int even = 0, odd = 0, last = 1;
	for (int i=0; i<n; i++) {
		if (a[i]&1) odd++, last = a[i];
		else even++;
	}
	if (even&1) return 1;
	else if (odd>1 or last==1) return 0;
	else {
		for (int i=0; i<n; i++) if (a[i]&1) a[i]--;
		int g = a[0];
		for (int i=1; i<n; i++) g = gcd(g, a[i]);
		for (int i=0; i<n; i++) a[i] /= g;
		return !judge();
	}
}

int main()
{
	scanf("%d", &n);
	for (int i=0; i<n; i++) scanf("%d", a+i);
	puts(judge() ? "First" : "Second");
}


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

int main() {
  int A, B;

  cin >> A >> B;

  if (A > 5 && A < 13) {
    cout << B / 2;
  }
  else if (A <= 5) {
    cout << 0;
  }
  else {
    cout << B;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <vector> 
using namespace std;
#define maxn 100000
#define maxm
#define MOD 
#define INF 0x3f3f3f3f
int N,M;
int a[310][310];
int num[310] = {0};
int v[310];


int main()
{
	scanf("%d%d",&N,&M);
	for(int i =0;i < N;i++)
		for(int j = 0;j < M;j++)
			scanf("%d",&a[i][j]);
	for (int i = 1; i <= M; i++) {
		v[i] = 1;
	}
	int ans = N, cnt = 0;
	while (1) {
		memset(num, 0, sizeof num);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				if (v[a[i][j]]) {
					num[a[i][j]]++;
					break;
				}
			}
		}
		int mx = num[1];
		for (int i = 1; i <= M; i++) {
			mx = max(mx, num[i]);
		}
		for (int i = 1; i <= M; i++) {
			if (num[i] == mx) {
				v[i] = 0;
				cnt++;
			}
		}
		ans = min(ans, mx);
		if (cnt == M) break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()

int main() {
    int X;
    cin >> X;
    int x = X;
    int cnt = 0;
    for(int i=1; i<=X; i++){
      cnt++;
      x -= i;
      if(x <= 0) break;
    }
    cout << cnt << ln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define int long long int
#define mpp make_pair
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define F first
#define S second
#define MOD 1000000007
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
const int MAXN = 1e6+1;
#define MAXI 2e18+3
#define all(v) v.begin(), v.end()
#define endl "\n"
# define PI 3.14159265358979323846


signed main(){
 
    fast;
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int k, a, b, i;
    cin>>k>>a>>b;
    for(i=a;i<=b;i++){
    	if(i%k==0){
    		cout<<"OK"<<endl;
    		return 0;
    	}
    }
    cout<<"NG"<<endl;
}

Measured memory_bytes: 3652
s = input()

if 1 <= int(s[:2]) <= 12 and 1 <= int(s[2:]) <= 12:
    print("AMBIGUOUS")
elif 1 <= int(s[2:]) <= 12:
    print("YYMM")
elif 1 <= int(s[:2]) <= 12:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 2940
#include<stdio.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const char letters[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
int diff[62];char pw[129],query[129];
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline int ask(void){printf("? %s\n",query);fflush(stdout);return IN();}
int main(void)
{
  int l=0,len=0,mid=0,r=0,total=0;
  rep(i,62){rep(j,128){query[j]=letters[i];}query[128]=0;diff[i]=128-ask();total+=diff[i];}
  rep(i,62)
  {
    if(len==0){len=diff[i];rep(j,diff[i])pw[j]=letters[i];}
    else
    {
      l=0;
      for(int k=diff[i];k>=1;k--)
      {
        r=len;
        while(l<r)
        {
          mid=(l+r+1)/2;
          rep(j,mid)query[j]=pw[j];
          rep(j,k)query[mid+j]=letters[i];
          query[mid+k]=0;
          if(ask()==total-mid-k)l=mid;else r=mid-1;
        }
        len++;rep(j,len-l){pw[len-j]=pw[len-j-1];}pw[l]=letters[i];
      }
    }
  }
  pw[len]=0;return printf("! %s\n",pw),0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



long long f(long long n) {
  long long res = 0;
  while (n > 0) {
	res += n%10;
	n /= 10;
  }
  return res;
}

double g(long long n) {
  return (double)(n)/f(n);
}


int main() {
  /*
  for (long long i = 1; i <= 10000; ++i) {
	if (i % 100 != 99) continue;
	cout << i << ": " << g(i) << endl;
  }
  */


  vector<long long> res;
  long long base = 1;
  for (int i = 0; i < 15; ++i) {
	for (int j = 1; j < 200; ++j) {
	  res.push_back(base * (j+1) - 1);
	}
	base *= 10;
  }
  sort(res.begin(), res.end());
  res.erase(unique(res.begin(), res.end()), res.end());

  //COUT(res);
  //COUT(res.size());
  
  for (long long i = 0; i < res.size(); ++i) {
	for (long long j = i+1; j < res.size(); ++j) {
	  if (g(res[i]) > g(res[j])) {
		res.erase(res.begin() + i--);
		break;
	  }
	}
  }
  //COUT(res);

  long long K;
  cin >> K;
  for (long long i = 0; i < K; ++i) {
	cout << res[i] << endl;
  }
}




























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

int main() {
	int S;

	cin >> S;

	int kami = S / 100;
	int simo = S % 100;

	if (1 <= kami && kami <= 12) {
		if (1 <= simo && simo <= 12) {
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "MMYY" << endl;
		}
	}
	else {
		if (1 <= simo && simo <= 12) {
			cout << "YYMM" << endl;
		}
		else {
			cout << "NA" << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val){
		fill((T *)array, (T *)(array + N), val);
	}
	
	const ll INF = 1e16;
	const ll MOD = 1e9 + 7;

	//int dx[4] = {1,0,-1,0};
	//int dy[4] = {0,1,0,-1};
	//ll pas[51][52];
	ll gcd(ll a, ll b) {
		if (b == 0)return a;
		return gcd(b, a % b);
	}
	signed main(){
		IOS;
		int n;
		cin >> n;
		vec<ll> a(n);
		REP(i, n)cin >> a[i];
		ll sum = 0;
		for(int i = 0;i < n - 1;i++){
			sum += a[i] / 2;
			if(a[i] % 2 && a[i + 1] > 0){
				a[i + 1]--;
				sum++;
			}
		}
		sum += a[n - 1] / 2;
		dump(sum);
	}

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

std::vector<std::pair<int, int>> v;
std::stack<int> s;

int r, c, n;

bool on_border(int x, int y) {return !x || x == r || !y || y == c;}
int pos(int x, int y) {
	if (!x) return y;
	if (y == c) return x + 2e8;
	if (x == r) return c - y + 4e8;
	return r - x + 6e8;
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> r >> c >> n;
	for (int i = 0; i < n; ++i) {
		int x, y, X, Y; std::cin >> x >> y >> X >> Y;
		if (on_border(x, y) && on_border(X, Y))
			v.emplace_back(pos(x, y), i), v.emplace_back(pos(X, Y), i);
	}
	std::sort(v.begin(), v.end());
	for (auto p : v)
		if (s.size() && s.top() == p.second) s.pop();
		else s.push(p.second);
	std::cout << (s.size() ? "NO" : "YES") << '\n';
	return 0;
}

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

int main() {
  int n, a;
  cin >> n >> a;
  
  if (n % 500 <= a) {
    cout << "Yes" << endl;
  }
  if (n % 500 > a) {
    cout << "No" << endl;
  }
  

}

Measured memory_bytes: 3588
use std::io::*;
use std::str::FromStr;
   
fn read<T: FromStr>() -> T {
	let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
     
fn main() {
    let n: u32 = read();
	let mut d: Vec<u32> = Vec::new();
	for _i in 0..n {
		d.push(read());
	}

	let mut result = 0;
	for i in 0..n {
		for j in i+1..n {
			result += d[i as usize] * d[j as usize];
		}
	}
	println!("{}", result);
}

Measured memory_bytes: 4352
import collections
num = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,34,35,36,37]
N = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
ans = 0    
a = prime_factorize(N)
cor = collections.Counter(a)
for v in cor.values():
    tmp = 0
    for nn in num:
        v -= nn
        if v >= 0:
            ans += 1
        else:
            break
print(ans)

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c,x,y,ret=INT_MAX; cin>>a>>b>>c>>x>>y;
	for (int ab=0; ab<=2*max(x,y); ab+=2)
		ret=min(ret,ab*c+max(0,x-ab/2)*a+max(0,y-ab/2)*b);
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
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;
}

int main(){
    int x;cin>>x;
    if(x>=400&x<600){
        cout<<8<<endl;
    }
    if(x>=600&x<800){
        cout<<7<<endl;
    }
    if(x>=800&x<1000){
        cout<<6<<endl;
    }
    if(x>=1000&x<1200){
        cout<<5<<endl;
    }
    if(x>=1200&x<1400){
        cout<<4<<endl;
    }
    if(x>=1400&x<1600){
        cout<<3<<endl;
    }
    if(x>=1600&x<1800){
        cout<<2<<endl;
    }
    if(x>=1800&x<2000){
        cout<<1<<endl;
    }
}

Measured memory_bytes: 3592
#include <stdio.h>
int main ()
{
	char str[101][101];
	int n,i,j=0,t,m,k=0;
	scanf ("%d%d\n",&n,&m);
	for (i=0;i<n;i++)
	{
		for (j=0;j<m;j++)
		{
			scanf ("%c",&str[i][j]);
		}
		getchar ();
	}
	for (i=0;i<n;i++)
	{
		if (i==0)
		{
			for (j=0;j<m+2;j++)
			if (j!=m+1) printf ("#");
			else printf ("#\n");
		}
		printf ("#");
		for (k=0;k<m;k++)
		{
			 printf ("%c",str[i][k]);
		}
		printf ("#\n");
		if (i==n-1)
		{
			for (j=0;j<m+2;j++)
			if (j!=m+1) printf ("#");
			else printf ("#\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

/*
 * 1: (b/2 + c/2), (a/2 + c/2), (a/2 + b/2)
 * 2: (a/2 + b/4 + c/4), (b/2 + a/4 + c/4), (c/2 + a/4 + b/4)
 * 3: (a/4 + 3b/8 + 3c/8), 
 *
 */

int main()
{
	int a, b, c;
	int ans = 0;
	scanf("%d %d %d", &a, &b, &c);

	if (!(a & 1 || b & 1 || c & 1) &&
			a == b && b == c) {
		printf("-1\n");
		return 0;
	}

	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		int aa = a;
		int bb = b;
		int cc = c;

		a = bb / 2 + cc / 2;
		b = aa / 2 + cc / 2;
		c = aa / 2 + bb / 2;

		ans++;
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 128