akhauriyash/Code-Regression huggingface dataset:
n, m, k = map(int, input().split())
a = [0] + list(map(int,input().split()))
b = [0] + list(map(int,input().split()))

for i in range(1, n+1):
    a[i] += a[i -1]

for i in range(1, m+1):
    b[i] += b[i -1]

b_cnt = m
ans = 0

for a_cnt in range(n+1):
    if a[a_cnt] <= k:
        while a[a_cnt] + b[b_cnt] > k:
            b_cnt -= 1
    else:
        break

    ans = max(ans, a_cnt + b_cnt)

print(ans)


Measured memory_bytes: 40008
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const long long INF = 1LL << 60;
const double PI = 3.14159265358979323846;
typedef long long ll;

int main(void) {
  int X, Y;
  cin >> X >> Y;
  bool exist = false;
  for (int i = 0; i <= X; i++) {
    int j = X - i;
    if (2 * i + 4 * j == Y) {
      exist = true;
      break;
    }
  }
  cout << (exist ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int ans;

void solve(char a[][15], int x, int y){
    a[x][y] = '0';
    if(a[x + 1][y] == '1')
        solve(a, x + 1, y);
    if(a[x - 1][y] == '1')
        solve(a, x - 1, y);
    if(a[x][y + 1] == '1')
        solve(a, x, y + 1);
    if(a[x][y - 1] == '1')
        solve(a, x, y - 1);

}

int main(){
    string inp;
    char map[15][15] = {0};
    while(scanf("%s",map[0]) == 1){
        ans = 0;
        range(i, 1, 12){
            scanf("%s", map[i]);
        }
        rep(i, 12){
            rep(j, 12){
                if(map[i][j] == '1'){
                        ans++;
                        solve(map, i, j);
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    pair<ll,ll> f[n];
    for (i=0;i<n;i++)
        cin>>f[i].ff>>f[i].ss;
    ll x=f[0].ff,y=f[0].ss;
    ll tx,ty;
    for (i=1;i<n;i++)
    {
        tx=x/f[i].ff;
        while (tx*f[i].ff<x)
            tx++;
        ty=y/f[i].ss;
        while (ty*f[i].ss<y)
            ty++;
        x=max(tx,ty)*f[i].ff;
        y=max(tx,ty)*f[i].ss;
    }
    cout<<x+y<<endl;
}

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

int main(){
	int a[4],b[4];
	while(true)
	{
		for(int i=0;i<=3;i++)cin >> a[i];
		if(cin.eof())break;
		for(int i=0;i<=3;i++)cin >> b[i];
		int hit=0,blow =0;
		for(int i=0;i<=3;i++)
		{
			for(int j=0;j<=3;j++)
				if(a[i]==b[j])
					if(i==j)hit++;
					else blow++;
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int N, p;
string s;
int f() {
	if (s[p]=='[') {
		p++;
		vector<int> t;
		while (s[p]!=']') t.push_back(f());
		p++;
		sort(t.rbegin(), t.rend());
		return accumulate(t.begin()+t.size()/2, t.end(), 0);
	}
	int t = 0;
	while (isdigit(s[p])) {
		t = t*10+(s[p++]-'0');
	}
	return (t+1)/2;
}
int main() {
	cin >> N;
	while (N--) {
		cin >> s;
		p = 0;
		cout << f() << endl;
	}
}


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

namespace ABC142
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var dic = new Dictionary<int, int>();
            for (int i = 0; i < N; i++)
            {
                dic.Add(A[i], i + 1);
            }

            var dic2 = dic.OrderBy(x => x.Key);

            foreach (var v in dic2)
            {
                Console.Write(v.Value + " ");
            }
        }
    }
}


Measured memory_bytes: 35420
#include <bits/stdc++.h>
using namespace std;
int main()
{
   long long a,b,c,k,sum=0;
   cin>>a>>b>>c>>k;
  for(long long i=0;i<k;i++)
  {
  	if(a!=0)
	  {
	  	sum+=1;
	  	a--;
	  }
  	else
  	{
  	if(b!=0)
	  {
	  sum+=0;
	  b--;
	  }
  	else
  	sum-=1;	
	  }
  
  }
  cout<<sum;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <stdio.h>
using namespace std;
int main(){
  int a,b,d,r;
  double f;
  cin >> a >> b;
  d=a/b;
  r=a%b;
  f=(double)a/b;
  printf("%d %d %.5f\n",d,r,f);

}



Measured memory_bytes: 3208
#include <string>
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
 
using namespace std;
  
int main(){
	int ball[256] = {0};
	ball['A'] = 1;

	char cup[2];
	while(~scanf("%c,%c", &cup[0], &cup[1])){
		swap(ball[cup[0]], ball[cup[1]]);
	}

	for(int i = 'A'; i <= 'C'; i++){
		if(ball[i]){
			cout << (char)i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] sd = sc.next().split("");
		String[] t = sc.next().split("");
		boolean r = true;
		boolean u = false;
		int start = 0;
		int end = 0;
		for (int i = 0; i <= sd.length - t.length; i++) {
			r = true;
			for (int j = 0; j < t.length; j++) {
				if (!t[j].equals(sd[i + j]) && !sd[i + j].equals("?")) {
					r = false;
					break;
				}
			}
			if (r) {
				start = i;
				end = i + t.length;
				u = true;
			}
		}
		if (u) {
			String[] s = new String[sd.length];
			for (int i = 0; i < start; i++) {
				s[i] = (sd[i].equals("?"))? "a" : sd[i];
			}
			for (int i = start; i < end; i++) {
				s[i] = t[i - start];
			}
			for (int i = end; i < s.length; i++) {
				s[i] = (sd[i].equals("?"))? "a" : sd[i];
			}
			for (int i = 0; i < s.length; i++) {
				System.out.print(s[i]);
			}
			System.out.println("");
		}
		else
			System.out.println("UNRESTORABLE");
	}
}

Measured memory_bytes: 21844
n, m = map(int, input().split())
p = list(map(int, input().split()))
g = [[] for _ in range(n+1)]
for _ in range(m):
    x, y = map(int, input().split())
    g[x].append(y)
    g[y].append(x)
s = [0] * (n+1)
ans = 0
for i, j in enumerate(p, 1):
    q = [i]
    for k in q:
        if s[k]: continue
        s[k] = i
        q.extend(g[k])
    ans += (s[i] == s[j])
print(ans)


Measured memory_bytes: 28260
#include<bits/stdc++.h>
using namespace std;
const int N = 6e5+5;
int lps[N][32][2];
int a[N];
int b[N];
int c[N][32][2];
void solve(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int s = 0;s<2;s++){
        for(int i=0;i<n;i++){
            for(int j=0;j<31;j++){
                if(a[i]&(1ll<<j))c[i][j][s] = 1;
                else c[i][j][s] = 0;
            }
        }
        for(int j=0;j<31;j++)c[n][j][s] = -1;
        for(int i=0;i<n;i++){
            for(int j=0;j<31;j++){
                if(b[i]&(1ll<<j))c[n+1+i][j][s] = 1-s;
                else c[i+n+1][j][s] = s;
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<31;j++){
                if(b[i]&(1ll<<j))c[n+n+1+i][j][s] = 1-s;
                else c[n+i+n+1][j][s] = s;
            }
        }
        int m = n+n+n+1;
        for(int j=0;j<31;j++){
            int k = 0;
            for(int i=1;i<m;i++){
                while(k>0 and c[i][j][s]!=c[k][j][s])k = lps[k-1][j][s];
                if(c[i][j][s]==c[k][j][s])k++;
                lps[i][j][s] = k;
            }
        }
    }
    /*
    for(int j=0;j<31;j++){

        for(int i=0;i<n+n+n+1;i++){
            cout<<c[i][j][0]<<" ";
        }
        cout<<endl;
        for(int i=0;i<n+n+n+1;i++){
            cout<<lps[i][j][0]<<" ";
        }
        cout<<endl;
        for(int i=0;i<n+n+n+1;i++){
            cout<<c[i][j][1]<<" ";
        }
        cout<<endl;
        for(int i=0;i<n+n+n+1;i++){
            cout<<lps[i][j][1]<<" ";
        }
        cout<<endl;
        cout<<"----------------------"<<endl;
    }
    */
    for(int i=0;i<n;i++){
        int cnt = 0;
        for(int j=0;j<31;j++){
            if(lps[i+n+n][j][0]==n or lps[i+n+n][j][1]==n)cnt++;
        }
        if(cnt==31){
            cout<<i<<" "<<(a[0]^b[i])<<endl;
        }
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 308096
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    int N;cin >> N;
    string S;cin >> S;
    int K;cin >> K;
    char C = S.at(K-1);
    for(int i = 0;i<N;i++){
        if(S.at(i) != C) S.at(i) = '*';
    }
    cout << S << endl;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

ll GCD(ll a, ll b)
{
	if (a%b == 0)
	{
		return(b);
	}
	else
	{
		return(GCD(b, a%b));
	}
}

ll maxn = 1e6;
vector<bool> isprime(maxn + 1);
vector<ll> pnums;


int main() {
	ll a, b;
	cin >> a >> b;
	ll x = GCD(a, b);

	FOR(i, 2, maxn) {
		isprime[i] = true;
	}
	FOR(i, 2, maxn) {
		if (isprime[i]) {
			pnums.push_back(i);
			for (int j = 2 * i; j <= maxn; j += i) {
				isprime[j] = false;
			}
		}
	}

	ll cnt = 1;
	FOR(i, 0, SZ(pnums)-1) {
		ll p = pnums[i];
		if (x%p == 0) {
			cnt++;
			while (x%p == 0) {
				x /= p;
			}
		}
	}
	if (x != 1)cnt++;
	pv(cnt)
	return(0);
}

Measured memory_bytes: 1528
import math
N, K = input().split(" ")
N, K = int(N), int(K)
P = 0
if (N < K):
  for n in range(1,N+1):
    P += 1/(N*pow(2,math.ceil(math.log2(K)-math.log2(n))))
else:
  for n in range(1, K+1):
    P += 1/(N*pow(2,math.ceil(math.log2(K)-math.log2(n))))
  P += (N-K)/N
print(P)

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

int main()
{
  ll n, m; cin >> n >> m;
  if (n>1) n-=2;
  if (m>1) m-=2;
  cout << n*m << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (100000)
#define MOD (998244353)


// 優先度付きキュー Priority Queue
// 最大を保持
// 二分ヒープで実装
typedef struct 
{
    int64_t pri;
    int64_t val;
}que;
que pq[MAXN+1];
int pq_size=0;

void PQadd(int64_t pri, int64_t val)
{
    pq_size++;
    pq[pq_size].pri = pri;
    pq[pq_size].val = val;
    int i = pq_size;
    while( (i>1) && (pq[i].pri > pq[i/2].pri))
    {
        que temp;
        temp = pq[i];
        pq[i] = pq[i/2];
        pq[i/2] = temp;
        i /= 2;
    }
}

que PQget(void)
{
    que ret;
    ret = pq[1];
    pq[1] = pq[pq_size];
    pq_size--;

    int i = 1;
    while(i*2 <= pq_size) // 葉ならやめる
    {
        int j;
        if(i*2 == pq_size) //左の子しかいない
        {
            j = i*2;
        }else
        {
            j = pq[i*2].pri > pq[i*2+1].pri ? i*2 : i*2+1;
        }

        if(pq[i].pri < pq[j].pri)
        {
            que temp;
            temp = pq[i];
            pq[i] = pq[j];
            pq[j] = temp;
            i = j;
        }else break;
    }
    return ret;
}

int main(void)
{
    int n,m;
    scanf("%d %d",&n,&m);

    PQadd(0,0);
    for(int i=0;i<n;i++)
    {
        int a;
        scanf("%d", &a);
        PQadd(a,0);
    }

    int i =0;
    while(1)
    {
        que q;
        q = PQget();
        int a = q.pri;
        while(a >= pq[1].pri)
        {
            a /= 2;
            i++;
            if(i==m) break;
        }
        PQadd(a,0);
        if(i==m) break;
    }
 
    int64_t ans = 0;
    for(int i=0;i<n;i++)
    {
        que q;
        q = PQget();
        ans += q.pri;
    }

    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int a[500][500];

int main() {
#ifdef LOCAL
  freopen("b.in", "r", stdin);
  freopen("b.out", "w", stdout);
#endif

  int n, m;
  while (scanf("%d%d", &n, &m) == 2) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        scanf("%d", &a[i][j]);
        a[i][j]--;
      }
    }
    for (int ans = 1; ; ans++) {
      vector<int> count(m);
      vector<int> ptr(n);
      for (int i = 0; i < n; i++) {
        count[a[i][0]]++;
      }
      while (true) {
        int id = max_element(count.begin(), count.end()) - count.begin();
        if (count[id] <= ans) break;
        count[id] = -1;
        for (int i = 0; i < n; i++) {
          if (count[a[i][ptr[i]]] != -1) continue;
          while (ptr[i] < m && count[a[i][ptr[i]]] == -1) {
            ptr[i]++;
          }
          if (ptr[i] < m) {
            count[a[i][ptr[i]]]++;
          }
        }
      }
      if (*max_element(count.begin(), count.end()) != -1) {
        printf("%d\n", ans);
        break;
      }
    }
  }

  return 0;
}


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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 1, inf = 1000111222;

int main()
{
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    cout << "ABC" << n;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const int intinf = 1 << 30;
const long long mod = 1e9 + 7;

int n;

int partition(vector<int> &A, int p, int r) {
    int x = A[r];
    int i = p - 1;
    for(int j = p; j < r; j++) {
        if(A[j] <= x) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

int main() {
    cin >> n;
    vector<int> A(n);
    rep(i, n) { cin >> A[i]; }

    int q = partition(A, 0, n - 1);

    rep(i, n) {
        if(i == q)
            cout << "[" << A[i] << "]";
        else
            cout << A[i];
        cout << (i == n - 1 ? "\n" : " ");
    }
}



Measured memory_bytes: 3092
X, K, D = map(int, input().split())
X = abs(X)

tmp = (X // D)
if X <= K * D:
  if K % 2:
    if tmp % 2:
      print(X % D)
    else:
      x = (X % D) + D
      x = min(abs((X % D) - D), x)
      print(abs(x))
  else:
    if tmp % 2:
      x = (X % D) + D
      x = min(abs((X % D) - D), x)
      print(abs(x))
    else:
      print(X % D)

else:
  print(X - (K * D))

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d});   
}

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

long long dp[101][21] = {0};
int main() {
	int n;
	cin >> n;
	int t[100];
	for(int i = 0; i < n; i++)
		cin >> t[i];
		
	dp[1][t[0]] = 1;
	for(int i = 1; i < n - 1; i++){
		for(int j = 0; j <= 20; j++){
			int plus = j + t[i];
			int minus = j - t[i];
			if(plus <= 20 && plus >= 0)
				dp[i + 1][plus] += dp[i][j];
			if(minus <= 20 && minus >= 0)
				dp[i + 1][minus] += dp[i][j];
		}
	}
	
	cout << dp[n - 1][t[n - 1]] << endl;
	return 0;
}

Measured memory_bytes: 1172
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        k: usize,
        s: usize,
    }

    let mut ans = 0;
    for i in 0..s+1 {
        for j in i..s+1 {
            let x = i;
            let y = j-i;
            let z = s-j;
            if x>k || y>k || z>k {
                continue;
            } else {
                ans += 1;
            }
        }
    }

    println!("{}", ans);

}


Measured memory_bytes: 2140
package main

import "fmt"

type block struct {
	left, right, num int
}

func main() {
	var S string
	fmt.Scan(&S)
	N := len(S)

	B := make([]block, N)

	M := 0
	B[0].left = 0
	for i := 1; i < N; i++ {
		if S[i] != S[i-1] {
			B[M].right = i - 1
			B[M].num = B[M].right - B[M].left + 1
			M++
			B[M].left = i
		}
	}
	B[M].right = N - 1
	B[M].num = B[M].right - B[M].left + 1
	M++

	ans := make([]int, N)
	for i, b := range B[:M] {
		if i%2 == 0 {
			ans[b.right] += (b.num / 2) + (b.num % 2)
			ans[b.right+1] += b.num / 2
		} else {
			ans[b.left] += (b.num / 2) + (b.num % 2)
			ans[b.left-1] += b.num / 2
		}
	}

	for _, a := range ans {
		fmt.Printf("%d ", a)
	}
	fmt.Printf("\n")
}


Measured memory_bytes: 4992
x,y=map(int,input().split())
if x==1 and y==1:print(1000000)
else:
  if x==1:
    if y==2:print(500000)
    elif y==3:print(400000)
    else:print(300000)
  elif x==2:
    if y==1:print(500000)
    elif y==2:print(400000)
    elif y==3:print(300000)
    else:print(200000)
  elif x==3:
    if y==1:print(400000)
    elif y==2:print(300000)
    elif y==3:print(200000)
    else:print(100000)
  else:
    if y==1:print(300000)
    elif y==2:print(200000)
    elif y==3:print(100000)
    else:print(0)

Measured memory_bytes: 38256
s = gets.to_s
s = s.split("")
s1 = (s[0] + s[1]).to_i
s2 = (s[2] + s[3]).to_i

year = (0..99).to_a
month = (1..12).to_a

if month.include?(s1) && month.include?(s2)
  puts "AMBIGUOUS"
elsif year.include?(s1) && month.include?(s2)
  puts "YYMM"
elsif month.include?(s1) && year.include?(s2)
  puts "MMYY"
else
  puts "NA"
end


Measured memory_bytes: 3836
import math
a,b,x = map(int, input().split()) 
if x>=a*a*b/2:
    AA=2*(a*a*b-x)/a**3
    atan = math.degrees(math.atan(AA))
else:
    BB=a*b*b/(2*x)
    atan = math.degrees(math.atan(BB))
print(atan)



Measured memory_bytes: 2940
//BISMILLAHIR RAHMANIR RAHIM
//SOTO MEAW
//SOTO SONDESH
#include<bits/stdc++.h>

#define ls ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define __ <<" "<<
#define loop(m,n) for(m=0;m<n;m++)
#define rloop(m,n) for(m=n-1;m>=0;m--)
#define case(z) "Case " << z++ << ": "
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define newline cout<<endl
#define quit return 0

using namespace std;

bool isprime(int n)
{
    for (int i = 2; i <= n/2; i++)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

void showmyDS(set<int> ds)
{
    set<int> ::iterator it;
    for (it=ds.begin();it!=ds.end();it++)
    {
        cout << *it << endl ;
    }
    cout << endl;
}
int main()
{
    ls
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //int t,l=1;cin>>t;while(l>0){
        int n;
        cin>>n;
        int num,k,i,j,l,r;
        int c[10][10]={0};
        for(i=1;i<=n;i++)
        {
            r=i%10;
            num=i;
            while(num!=0)
            {
                k=num%10;
                num/=10;
            }
            l=k;
            c[l][r]++;
        }
        ll int total = 0;
        loop(i,10){
            loop(j,10){
                total+=(c[i][j]*c[j][i]);
            }
        }
        cout<<total;
        newline;
    //t--;}

    quit;
}


Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
static HashMap<Integer,Integer> set=new HashMap<>();
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		HashMap<Integer, ArrayList<Integer>> hmap = new HashMap<>();
		HashMap<Integer, ArrayList<Integer>> weights = new HashMap<>();

		for (int i = 0; i < n-1; i++) {
			int u = scn.nextInt();
			int v = scn.nextInt();
			int w = scn.nextInt();
			if (hmap.containsKey(u)) {
				ArrayList<Integer> al=hmap.get(u);
				ArrayList<Integer> w1=weights.get(u);	
				w1.add(w);
				weights.put(u, w1);
				al.add(v);
				hmap.put(u,al);
			} else {
				ArrayList<Integer> al=new ArrayList<>();
				al.add(v);
				ArrayList<Integer> w1=new ArrayList<>();	
				w1.add(w);
				weights.put(u, w1);
				hmap.put(u,al);
			}
			if (hmap.containsKey(v)) {
				ArrayList<Integer> al=hmap.get(v);
				al.add(u);
				ArrayList<Integer> w1=weights.get(v);	
				w1.add(w);
				weights.put(v, w1);
				hmap.put(v,al);
			} else {
				ArrayList<Integer> al=new ArrayList<>();
				al.add(u);
				ArrayList<Integer> w1=new ArrayList<>();	
				w1.add(w);
				weights.put(v, w1);
				hmap.put(v,al);
			}
		}
		HashSet<Integer> visited =new HashSet<>();
		for(int i=1;i<=n;i++) {
			if(!visited.contains(i)) {
				solve(hmap,weights,visited,i,0);
			}
		}
		for(int x=1;x<=n;x++) {
			System.out.println(set.get(x));
		}
	}
	
	public static void solve(HashMap<Integer, ArrayList<Integer>> hmap,HashMap<Integer, ArrayList<Integer>> weights, HashSet<Integer> visited, int ele, int color) {
		visited.add(ele);
		set.put(ele, color);
		//System.out.println(color+" "+ele);
		ArrayList<Integer> a=hmap.get(ele);
		ArrayList<Integer> w=weights.get(ele);
		for(int i=0;a!=null &&i<a.size();i++) {
			if(!visited.contains(a.get(i))) {
				if(w.get(i)%2==0)
					solve(hmap,weights,visited,a.get(i),color);
				else
					solve(hmap,weights,visited,a.get(i),color==1?0:1);
				
				//System.out.println("ret "+ele);
			}
		}
	}

}


Measured memory_bytes: 144528
using System;

namespace A___Three_letter_acronym
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var s1 = input[0];
            var s2 = input[1];
            var s3 = input[2];
            Console.WriteLine($"{Char.ToUpper(s1[0])}{Char.ToUpper(s2[0])}{Char.ToUpper(s3[0])}");
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    string s, t;
    cin >> s >> t;
    map<char, vector<int>> index;
    REP(i, s.size()) index[s[i]].push_back(i);
    ll i = -1, a = 0;
    for (char c : t) {
        if (index.count(c) == 0) {
            cout << -1 << endl;
            return 0;
        }
        auto j = lower_bound(ALL(index[c]), i);
        if (j == index[c].end()) {
            a++;
            i = index[c][0];
        } else {
            i = *j;
        }
        i++;
    }
    cout << (ll) s.size() * a + i << endl;
}

Measured memory_bytes: 1228
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 100050
char str[N];
int head[N],to[N<<1],nxt[N<<1],a[N],c[N],cnt,siz[N],f[N],g[N],si[N],d[N],n,ans;
inline void add(int u,int v) {
	to[++cnt]=v; nxt[cnt]=head[u]; head[u]=cnt;
}
void dfs(int x,int y) {
	int i;siz[x]=1; si[x]=c[x];
	for(i=head[x];i;i=nxt[i]) {
		if(to[i]!=y) {
			dfs(to[i],x); siz[x]+=siz[to[i]]; si[x]+=si[to[i]];
			if(si[to[i]]!=siz[to[i]]) d[to[i]]++,d[x]++;
		}
	}
}
void dfs2(int x,int y) {
	int i;
	int mx1=0,mx2=0;
	if(d[x]==1&&y) {f[x]=a[x],g[x]=-1<<30; return ;}
	for(i=head[x];i;i=nxt[i]) {
		if(to[i]!=y&&siz[to[i]]!=si[to[i]]) {
			dfs2(to[i],x);
			ans=max(ans,f[to[i]]+mx2+a[x]);
			ans=max(ans,g[to[i]]+mx1+a[x]);
			mx1=max(mx1,f[to[i]]);
			mx2=max(mx2,g[to[i]]);
		}
	}
	f[x]=mx1+a[x]; g[x]=mx2+a[x];
}
int main() {
	scanf("%d",&n);
	int i,x,y;
	for(i=1;i<n;i++) {
		scanf("%d%d",&x,&y); add(x,y); add(y,x);
	}
	scanf("%s",str+1);
	int rt=0;
	for(i=1;i<=n;i++) {
		c[i]=(str[i]=='B');
		if(!c[i]) rt=i;
	}
	if(rt) dfs(rt,0);
	else {
		puts("0"); return 0;
	}
	int sum=0;
	for(i=1;i<=n;i++) {
		if(siz[i]==si[i]) continue;
		sum+=d[i];
		if((d[i]+c[i])%2==0) sum++,a[i]=2;
	}
	dfs2(rt,0);
	printf("%d\n",sum-ans);
}

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

int N, M;
vector<int> P;
vector<vector<bool> > G;

int main(void) {
	cin >> N >> M;
	vector<bool> v;
	v.resize(N + 1, false);
	G.resize(N + 1, v);
	for (int i = 1; i <= M; ++i) {
		int a, b;
		cin >> a >> b;
		G[a][b] = true;
		G[b][a] = true;
	}

	int ans = 0;
	P.resize(N - 1);
	for (int i = 2; i <= N; ++i)
		P.push_back(i);
	do {
		int s = 1;
		bool flag = true;
		for (int i = 0; i <= N - 2; ++i) {
			int t = P[i];
			if (G[s][t] != true) {
				flag = false;
				break;
			}
			s = t;
		}
		if (flag)
			++ans;
	} while (next_permutation(P.begin(), P.end()));

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int n,m;
	cin >>n >> m;
	cout << (n%m == 0 ? n/m : n/m + 1)<< endl;
	
}


Measured memory_bytes: 256
#include<set>
#include<queue>
#include<cstdio>

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

using namespace std;

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

struct data{
	int S;
	int x,y;
	bool operator<(const data &D)const{
		if(S!=D.S) return S<D.S;
		if(x!=D.x) return x<D.x;
		return y<D.y;
	}
};

int n;

data next_state(int S,int x,int y){
	S|=1<<y*n+x;
	int T=0;
	rep(i,n) rep(j,n) {
		int cnt=0;
		rep(k,8){
			int yy=i+dy[k],xx=j+dx[k];
			if(0<=yy && yy<n && 0<=xx && xx<n && S&(1<<yy*n+xx)) cnt++;
		}
		if(S&(1<<i*n+j)){
			if(cnt==2 || cnt==3) T|=1<<i*n+j;
		}
		else{
			if(cnt==3) T|=1<<i*n+j;
		}
	}
	T&=~(1<<y*n+x);
	return (data){T,x,y};
}

int main(){
	for(;scanf("%d",&n),n;){
		data ini={};
		rep(i,n){
			char s[6]; scanf("%s",s);
			rep(j,n){
				if(s[j]=='#') ini.S|=1<<(i*n+j);
				if(s[j]=='@') ini.x=j, ini.y=i;
			}
		}

		int ans=-1;
		set<data> Vis;
		queue< pair<int,data> > Q; Q.push(make_pair(0,ini));
		while(!Q.empty()){
			int t=Q.front().first;
			data D=Q.front().second; Q.pop();

			if(t>10) break;

			if(Vis.count(D)>0) continue;
			Vis.insert(D);

			if(D.S==0){ ans=t; break; }

			rep(k,8){
				int yy=D.y+dy[k],xx=D.x+dx[k];
				if(0<=yy && yy<n && 0<=xx && xx<n && (D.S&(1<<yy*n+xx))==0){
					Q.push(make_pair(t+1,next_state(D.S,xx,yy)));
				}
			}
		}

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

	return 0;
}

Measured memory_bytes: 0
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        a: usize, b: usize, c: usize
    };

    let set = vec![a, b, c].into_iter().collect::<HashSet<_>>();
    let res = if set.len() == 2 { "Yes" } else { "No" };
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2248
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();
		String[] ss = s.split("");
		int[] a = new int[ss.length];
		int onecounter = 0;
		for(int i =0;i<ss.length;i++) {
			a[i]= Integer.parseInt(ss[i]);
			if(a[i]==1)onecounter++;
		}
		int smaller = onecounter-1;
		if(smaller==-1) {
			smaller =1;
		}
		boolean check  =false;
		if(smaller==0) {
			smaller = 1;
			check  =true;
		}

		int[] plusAma = new int[n];
		int[] minusAma = new int[n];
		plusAma[0]= 1%(onecounter+1);
		minusAma[0] = 1%(smaller);
		for(int i=1;i<n;i++) {
			plusAma[i] = plusAma[i-1]*2%(onecounter+1);
			minusAma[i] = minusAma[i-1]*2%(smaller);
		}

		int zanteiplus = 0;
		int zanteiminus = 0;
		for(int i =0;i<ss.length;i++) {
			if(a[i]==1) {
				zanteiplus += plusAma[ss.length-1-i];
				zanteiplus = zanteiplus%(onecounter+1);
				zanteiminus += minusAma[ss.length-1-i];
				zanteiminus = zanteiminus%(smaller);
			}
		}


		int[] ans = new int[Math.min(n, 2*100000)];
		ans[0]=0;
		for(int i=1;i<ans.length;i++) {
			int aa = i;
			int c = 1;
			while(aa>1) {
				c+=aa%2;
				aa=aa/2;
			}
			ans[i]=ans[i%c]+1;
		}

		for(int i=0;i<n;i++) {
			int p =0;
			if(a[i]==1) {
				p= zanteiminus-minusAma[ss.length-1-i];
				if(p<0)p+=smaller;
				if(check) {
					System.out.println(0);
				}else {
					System.out.println(ans[p]+1);
				}

			}else {
				p=zanteiplus+plusAma[ss.length-1-i];
				p=p%(onecounter+1);
				System.out.println(ans[p]+1);
			}
		}
	}

	static long yuclid(long a, long b) {
		long ans;
		if(a<b) {
			long aa = a;
			a=b;
			b=aa;
		}
		while(true) {
			if(b%a==0) {
				ans = a;
				break;
			}else {
				long aa =a;
				a= b%a;
				b=aa;
			}
		}
		return ans;
	}


	static long divn(int target, int times) {//10_9+7のあまり累乗版
		int sqtimes = (int)Math.sqrt(times);
		long ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans * target)%(bignum);
		}
		long holder = ans;
		ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans*holder)%(bignum);
		}
		for(int i=0;i<times - sqtimes*sqtimes;i++) {
			ans = (ans * target)%(bignum);
		}
		return ans;
	}

	static long div(long a) {//10_9+7のあまり
		if(a<0)a+=bignum;
		return a%(bignum);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 72800
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
#define MAX_P 200010
int fact[MAX_P]; //n! mid p

int extgcd(int a, int b, int &x, int &y)
{
    int d = a;
    if (b != 0)
    {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    else
    {
        x = 1;
        y = 0;
    }
    return d;
}
int mod_inverse(int a, int m)
{
    int x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}
//n! = a p^e -> a mod p
void make_fact()
{
    fact[1] = 1;
    for (int i = 2; i < MAX_P; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    return;
}
int mod_fact(int n, int p, int &e)
{
    e = 0;
    if (n == 0)
        return 1;
    int res = mod_fact(n / p, p, e);
    e += n / p;
    if (n / p % 2 != 0)
        return res * (p - fact[n % p]) % p;
    return res * fact[n % p] % p;
}
//nCk mod p
int mod_comb(int n, int k, int p)
{
    if (n < 0 || k < 0 || n < k)
        return 0;
    int e1, e2, e3;
    int a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
    if (e1 > e2 + e3)
        return 0;
    return a1 * mod_inverse(a2 * a3 % p, p) % p;
}

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

    int n, k;
    cin >> n >> k;
    make_fact();
    for (int i = 1; i <= k; i++)
    {
        int x = k - 1, y = i - 1, z = n - k + 1, w = i;
        int a = mod_comb(x, y, mod);
        int b = mod_comb(z, w, mod);
        cout << (a * b) % mod << endl;
    }
}

Measured memory_bytes: 1792
def solve(string):
    n = int(string)
    dp = [[0] * 4 for _ in range(n)]
    dp[0] = [1] * 4
    for i in range(1, n):
        base = sum(dp[i - 1])
        for j in range(4):
            dp[i][j] = base
        # "AGC", "ACG", "GAC"
        if i >= 2:
            dp[i][1] -= dp[i - 2][0] + dp[i - 2][2]
            dp[i][2] -= dp[i - 2][0]
        # "AG{}C", "A{}GC"
        if i >= 3:
            dp[i][1] -= dp[i - 3][0] * 3
            dp[i][2] += dp[i - 3][2]

    return str(sum(dp[n - 1]) % (10**9 + 7))


if __name__ == '__main__':
    print(solve(input()))


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

int		main(void)
{
	int		a;
	cin >> a;
	long long	sum = 0;
	for (int i = 1; i <= a; i++)
	{
		if (i % 3 != 0 && i % 5 != 0 )
			sum += i;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3624
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    REP(i, n) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(ALL(a), greater<int>());
    
    REP(i, n) {
        int x;
        if(b[i]==a[0]) x = a[1];
        else x = a[0];
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
const int N=5005;
struct zh
{
	int h,p;
	bool operator<(const zh k)const
	{
		return h+p<k.h+k.p;
	}
}a[N];
int dp[N][N],n,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].h,&a[i].p);
	sort(a+1,a+n+1);
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			if(dp[i-1][j-1]>a[i].h)
				dp[i][j]=dp[i-1][j];
			else
			{
				dp[i][j]=min(dp[i-1][j],dp[i-1][j-1]+a[i].p);
				ans=max(ans,j);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 98176
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (a, b, c) = readListOfString()

    println(if(a.last() == b.first() && b.last() == c.first()) "YES" else "NO")
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }


// Extensions
fun<T> List<T>.toBuckets(bucketKeys: List<T>): Map<T, Int> {
    val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()
    this.forEach { t ->
        buckets[t] = buckets[t]!! + 1
    }
    return buckets
}

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)

// Util Functions
fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 37848
import java.util.Scanner;

public class Main {

	private static Scanner s;

	public static void main(String[] args) {
		s = new Scanner(System.in);
		
		int a = s.nextInt();
		int b = s.nextInt();
		int h = s.nextInt();
		
		System.out.println((a+b)*h/2);
	}	
}


Measured memory_bytes: 9804
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
	int t;
	unsigned long long x[6];
	for (t = 0; t < 6; t++)
		cin >> x[t];

	unsigned long long mini = x[1];
	unsigned long long minit = 1;
	for (t = 1; t < 6; t++) {
		if (mini > x[t]) {
			mini = x[t];
			minit = t;
		}
	}
	unsigned long long total = 4 + (x[0] / x[minit]);
	unsigned long long  amari;
	amari = x[0] % x[minit];
	if (amari != 0)
		total += 1;
	std::cout << total << std::endl;
}

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

int main() {
  int N; cin >> N;
  long long base = 1, ret = 0;
  while (base < N) {
    for (int i = base; i < N; i++) {
      if (base*i<N) {
        ret += (base==i) ? 1 : 2;
      } else {
        break;
      }
    }
    base++;
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 3632
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, t = rm()
min_ = inf
flag = False
for _ in range(n):
  a, b = rm()
  if b <= t:
    min_ = min(min_, a)
    flag = True
if flag:
  print(min_)
else:
  print('TLE')










Measured memory_bytes: 27160
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;

ll mod = 1000000000 + 7;
int main(){
    string S;
    int A, B, C, D;
    cin >> S;

    A = S.at(0) - '0';
    B = S.at(1) - '0';
    C = S.at(2) - '0';
    D = S.at(3) - '0';
    vi op = {1, -1};
    vector<char> opp = {'+', '-'};

    for(int i=0; i<=1; i++){
        for (int j = 0; j <=1; ++j) {
            for (int k = 0; k <=1 ; ++k) {
                if(A+op.at(i)*B+op.at(j)*C+op.at(k)*D == 7){
                    cout << A << opp.at(i) << B << opp.at(j) << C << opp.at(k) << D << '=' << 7 << endl;
                    return 0;
                }
            }

        }
    }


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define _GLIBCXX_DEBUG

int f(int x){
    int ret=0;
    while(x%2==0){
        x/=2;
        ret++;
    }
    return ret;
}

signed main(){
    int N;cin>>N;
    int ans=0;
    REP(i,N){
        int a;cin>>a;
        ans+=f(a);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include <time.h>
#include<vector>

using namespace std ;

int main()
{
  int N ,c,a,n ;
  vector< int > ans;
  cin >> N ;
  ans.assign( N, 0) ;
  for( int i = 0 ; i < N ; ++i )
  {
    cin >> c >> a >> n ;
    if(c <= a && c <= n)
    {
      ans[i] += c ;
      c = 0 ;
    }
    else if(a > n && c > n)
    {
      ans[i] += n ;
      c -= n ;
      a -= n ;
    }
    else if( n > a && c > a )
    {
      ans[i] += a ;
      c -= a ;
      a = 0 ;
    }
    if(a != 0)
    {
      if(a <= c / 2)
      {
        ans[i] += a ;
        c -= a * 2 ;
      }
      else
      {
        ans[i] += c / 2 ;
        c = 0 ;
      }
    }
    ans[i] += c / 3 ;
    cout << ans[i]<<endl;
  }
  return 0 ;
}

Measured memory_bytes: 1196
N = int(input())

a = 0
for i in range(1, N+1):
    if 1 <= i and i < 10:
        a += 1
    elif 100 <= i and i < 1000:
        a += 1
    elif 10000 <= i and i < 100000:
        a += 1

print(a)

Measured memory_bytes: 2940
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
set<string> st;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++) {
    string si;
    cin >> si;
    st.insert(si);
  }

  int ans = st.size();
  cout << ans << endl;
  return 0;
}

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

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll i = 0;
    while(true){
        if(i % 2 == 0){
            c -= b;
            if(c <= 0){
                cout << "Yes" << endl;
                break;
            }
        }else{
            a -= d;
            if(a <= 0){
                cout << "No" << endl;
                break;
            }
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second
 
const int MOD = 1e9 + 7;
 
void setIO() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}
 
//ctrl q is comment
//ctrl b is run
//ctrl s is compile
//alt r is search & replace
//alt d is delete a line

int main(){
    setIO();
    int n; cin >> n;
    int amt[10001];
    fill(amt, amt + 10001, 0);
    for(int i = 1; i <= 100; ++i){
        for(int j = 1; j <= 100; ++j){
            for(int k = 1; k <= 100; ++k){
                int cur = i * i + j * j + k * k + i * j + j * k + k * i;
                if(cur <= 10000){
                    ++amt[cur];
                }
            }
        }
    }
    for(int i = 1; i <= n; ++i){
        cout << amt[i] << "\n";
    }
}

Measured memory_bytes: 3608