akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

priority_queue<int, vector<int>, greater<int>> pq;
vector<int> P, Q, R;
int X, Y, A, B, C;
int p, q, r;
long long sum = 0;

int main(){
  cin >> X >> Y >> A >> B >> C;

  for(int i = 0; i < A; i++){ cin >> p; P.push_back(p); }
  for(int i = 0; i < B; i++){ cin >> q; Q.push_back(q); }
  for(int i = 0; i < C; i++){ cin >> r; R.push_back(r); }

  sort(P.begin(), P.end());
  sort(Q.begin(), Q.end());
  sort(R.begin(), R.end());

  /*大きい値を指定個数分いれる*/
  for(int i = 0; i < X; i++) pq.push(P[A-1-i]);
  for(int i = 0; i < Y; i++) pq.push(Q[B-1-i]);

  int i = 0;
  while(R[C-1-i] > pq.top()){  pq.pop(); pq.push(R[C-1-i]); i++; }  //上回っている間は交換
  while(!pq.empty()){ sum += pq.top(); pq.pop(); }  //和を計算

  cout << sum << endl;
  return 0;
}


  




Measured memory_bytes: 2552
a="abcdefghijklmnopqrstuvwxyz"
s=input()
t=input()
ds={}
dt={}
for i in a:ds[i]=dt[i]=""
for i in range(len(s)):
  if ds[s[i]]=="":ds[s[i]]=t[i]
  elif ds[s[i]]!=t[i]:exit(print("No"))
  if dt[t[i]]=="":dt[t[i]]=s[i]
  elif dt[t[i]]!=s[i]:exit(print("No"))
print("Yes")

Measured memory_bytes: 3632
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =2e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
int k;
int n;
int a[MAXN];
int check(int x)
{
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		sum+=(a[i]+x-1)/x-1;
	}
	//printf("x: %lld sum:%lld \n",x,sum);
	if(sum<=k) return 1;
	else return 0;
}
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++) 
	{
	    scanf("%d",&a[i]);
	} 
	int l=1,r=1e9;
	while(r>=l)
	{
		int mid=(l+r)>>1;
		if(check(mid))
		{
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 4604
#include <cstdio>

int main(void){
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		int max, min;
		if(a > b){
				max = a;
				min = b;
		}else{
				max = b;
				min = a;
		}
		if(c > max)printf("%d %d %d\n", min, max, c);
		else if(c < min)printf("%d %d %d\n", c, min, max);
		else printf("%d %d %d\n", min, c, max);
		return 0;
}



Measured memory_bytes: 2740
while True:
    x = float(input())
    h = float(input())
    if x + h == 0: break
    S = 0
    a = ((x / 2) ** 2 + h ** 2) ** 0.5
    S += x * x
    S += (a * x * 0.5) * 4
    print(S)

Measured memory_bytes: 6796
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define prllDouble(x) cout << fixed << setprecision(10) << x
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int dp[3001][3001][3];

int solve(string& oprs)
{
    int n = oprs.length();
    memset(dp, 0, sizeof dp);
    for(int idx = n; idx > 0; idx--)
    {
        int availNums = n - idx + 1;
        for(int smol = 0; smol <= availNums; smol++)
        {
            if(oprs[idx - 1] == '>')
            {
                dp[idx][smol][0] = (availNums > 1) ? dp[idx + 1][smol - 1][1] : smol;
            }
            else
            {
                dp[idx][smol][0] = (availNums > 1) ? dp[idx + 1][smol][2] : !smol;
            }
        }

        dp[idx][0][1] = dp[idx][0][0];
        dp[idx][availNums][2] = dp[idx][availNums][0];

        for(int i = 1; i <= availNums; i++)
            dp[idx][i][1] = (dp[idx][i][0] + dp[idx][i - 1][1]) % mod;

        for(int i = availNums - 1; i >= 0; i--)
            dp[idx][i][2] = (dp[idx][i][0] + dp[idx][i + 1][2]) % mod;

    }

    ll ans  = 0;
    for(int num = 1; num <= n + 1; num++)
    {
        ans = (ans + dp[1][num - 1][0]) % mod;
    }
    return ans;
}

int main(){
    ll i,j,t,n,m,x,p,k;
    fast_io;
    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        string s;
        cin >> s;
        cout << solve(s);
    }
    return 0;
}


Measured memory_bytes: 105856
/*
	Date:2020.5.10
	Name:Aliemo
*/
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

#define int long long
#define rr register

#define MAXN 200010
#define inf 1e18

using namespace std;

inline int read(int &T) {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) {f |= ch == '-'; ch = getchar();}
	while (isdigit(ch)) {s = s * 10 + (ch ^ 48); ch = getchar();}
	return T = f ? -s : s;
}

void print(int x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) print(x / 10);
	putchar(x % 10 + '0');
}

int n, k, now, last, sum, ans;

int a[MAXN], vis[MAXN];

bool f;

signed main() {
	n = read(n);
	k = read(k);
	for (rr int i = 1; i <= n; i++) a[i] = read(a[i]);
	now = 1;
	vis[now]++;
	while (k--) {
		now = a[now];
		// cout << now;
		if (vis[now] == 1 && !f) {
			// ans++;
			vis[now]++;
			f = 1;
			int t = now;
			t = a[t];
			ans++;
			while (vis[t] != 2) {
				t = a[t];
				ans++;
			}
			// cout << ans << " ";
			k %= ans;
		}
		vis[now]++;
	}
	cout << now;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> ar(n);
	map<int, int> mp[2];
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		mp[i & 1][a]++;
	}
	int mx[2][2] = {{0, -1}, {-2, -3}};
	int cnt[2][2] = {};
	for (int i = 0; i < 2; ++i) {
		for (auto& it: mp[i]) {
			if (it.second > cnt[i][0]) {
				cnt[i][1] = cnt[i][0];
				cnt[i][0] = it.second;
				mx[i][1] = mx[i][0];
				mx[i][0] = it.first;
			} else if (it.second > cnt[i][1]) {
				cnt[i][1] = it.second;
				mx[i][1] = it.first;
			}
		}
	}
	int mn = n;
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 2; ++j) {
			if (mx[0][i] == mx[1][j]) continue;
			mn = min(mn, n / 2 - cnt[0][i] + n / 2 - cnt[1][j]);
		}
	}
	cout << mn << endl;
}

Measured memory_bytes: 5376
#include <iostream>
#include <fstream>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <list>
#include <array>
#include <cstdlib>
#include <stack>
#include <string>
#include <queue>
#include <chrono>
#include <functional>
#include <limits>
#include <cmath>
#include <algorithm>
#include <random>
#include <regex>
#include <tuple>
#include <numeric>
#include <cassert>
#include <utility>
#include <bitset>
#include <complex>
#include <iomanip>
#include <ostream>
#include <sstream>
#include <ctime>
using namespace std;
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define index INDEX
#ifndef ONLINE_JUDGE
#define print(x) PRINT(x, #x)
template<typename T> void PRINT(T VARIABLE, const string& NAME) {
	cerr << NAME << " = " << fixed << VARIABLE << "\n";
}
#else
#define print(x) 0 
#endif
int generate_random() {
	const int MAX_RANDOM = (int)1e6;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	return uniform_int_distribution<int>(0, MAX_RANDOM)(rng);
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll INFLL = 2 * (ll)1e18 + 100;
#define int ll
#ifdef int 
const int INFINT = INFLL;
#else
const int INFINT = 2 * (int)1e9 + 100;
#endif
const double PI = atan(1) * 4;
const double EPS = 1e-6;
const int SEED = (int)1e3 + 7;
const int MOD = (int)1e9 + 7;
const int NMAX = (int)1e6 + 5;

int dp[2][NMAX];

int32_t main() {
#ifndef ONLINE_JUDGE
	double START_PROGRAM = clock();
#endif
	srand(time(NULL));
	cout << setprecision(20) << fixed;
	FASTIO;
    int n, w;
    cin >> n >> w;
    ll mmax = 0;
    for1(i, n)
    {
        int weight, value;
        cin >> weight >> value;
        int cur = i & 1;
        int prev = cur ^ 1;
        for(int wcur = 0; wcur <= w; wcur++)
        {
            if(wcur + weight <= w)
                dp[cur][wcur + weight] = max(dp[prev][wcur + weight], dp[prev][wcur] + value);
            dp[cur][wcur] = max(dp[cur][wcur], dp[prev][wcur]);
        }
        for(int wcur = 0; wcur <= w; wcur++)
            mmax = max(mmax, dp[cur][wcur]);
    }
    cout << mmax;
    







#ifndef ONLINE_JUDGE
	double END_PROGRAM = clock();
	double ELAPSED_TIME = (END_PROGRAM - START_PROGRAM) / CLOCKS_PER_SEC;
	cerr << "\n\nElapsed Time: " << ELAPSED_TIME * 1000 << "\n";
#endif
	return 0;
}







Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

int n,l;

main()
{
    cin>>n;

    vi v(n);
    ll sum=0;
    each(&it,v)
    {
        cin>>it;
        sum+=it;
    }

    ll snuke=v[0],bear=sum-v[0];
    ll ans=abs(snuke-bear);
    rep2(i,1,n)
    {
        ans=min(ans,abs(snuke-bear));
        //cout<<ans<<endl;
        snuke+=v[i];
        bear-=v[i];

    }

    cout<<ans<<endl;

}

Measured memory_bytes: 1024
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main(int argc, char *argv[]) {
	int a, b, c, k, cnt = 0;
	cin >> a >> b >> c >> k;
	while (b <= a) {
		++cnt;
		b *= 2;
	}
	while (c <= b) {
		++cnt;
		c *= 2;
	}
	string ans = cnt <= k ? "Yes" : "No";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        if(a[i]%2==0){
            if(a[i]%3==0||a[i]%5==0) continue;
            else {
                cout<<"DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;
    return 0;
}


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

typedef double f64;
typedef long long i64;
typedef int i32;
typedef pair<i32, i32> pi32;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef vector<i32> vi32;
typedef deque<i32> di32;

#define all(c) (c).begin(), (c).end()
#define REP(i, a, b) for (auto i = a; i < b; i++)
#define REPA(i, a, b, acc) for (auto i = a; i < b; i += acc)
#define PB push_back
#define PF push_front
#define PRINT(x) cout << #x ": " << (x) << endl;
#define TR(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); (it)++)
#define MAX_PRECISION cout << setprecision(numeric_limits<double>::max_digits10);

i32 main() {
  ios::sync_with_stdio(false);  // Makes IO faster, remove this line if C style scanf/printf needed.

  string s;
  cin >> s;

  i32 ret = 1e6;
  vector<char> c = {'1', '0'};
  REP(i, 0, 2) {
    char cur = c[i];
    i32 localRet = 0;
    TR(s, it) {
      if (*it != cur) localRet++;
      cur = cur == '1' ? '0' : '1';
    }
    ret = min(localRet, ret);
  }

  cout << ret << endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        LinkedList<Character> strbf = new LinkedList<Character>();

        for(int i = 0 ; i < str.length() ; i++){
            strbf.addLast(str.charAt(i));
        }

        int q = sc.nextInt();

        boolean flipped = false;

        for(int i = 0 ; i < q ; i++){
            int t = sc.nextInt();
            if(t == 1){
                flipped = !flipped;
            }else{
                int f = sc.nextInt();
                char c = sc.next().charAt(0);

                if((f == 1 && !flipped) || (f == 2 && flipped)){
                    strbf.addFirst(c);
                }else{
                    strbf.addLast(c);
                }
            }
        }

        StringBuilder stb = new StringBuilder();
        while(!strbf.isEmpty()){
            if(!flipped){
                stb.append(strbf.removeFirst());
            }else{
                stb.append(strbf.removeLast());
            }
        }

        System.out.println(stb.toString());
    }
}


Measured memory_bytes: 165488
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;

  cin >> A >> B >> C >> D;

  int diff = (A + B)- (C + D);

  if (diff > 0) {
    cout << "Left" << endl;
  } else if (diff == 0) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main(void){

	char a[1000];
    int n;
	cin >> a;
	n = strlen(a);

	for(int i=0;i<n;i++){
        a[i]-=3;
        if(a[i]=='>')a[i]='X';
        if(a[i]=='?')a[i]='Y';
        if(a[i]=='@')a[i]='Z';
	}

    cout<<a<<endl;


	return 0;
}

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

using namespace std;

int main(){
	char c[2];
	scanf("%s", c);
	if (c[0] == 'a' || c[0] == 'e'|| c[0] == 'i'|| c[0] == 'o' || c[0] == 'u')
		puts("vowel");
	else 
		puts("consonant");
	return 0;
}


Measured memory_bytes: 256
from sys import stdin

n, m = (int(x) for x in stdin.readline().rstrip().split())
lr = [stdin.readline().rstrip().split() for _ in range(m)]
l = max([int(i[0]) for i in lr])
r = min([int(i[1]) for i in lr])

if l <= r:
    print(r-l+1)
else:
    print(0)

Measured memory_bytes: 36196
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a) for(int i=(a);;++i)
#define REP(i,n)  FOR(i,0,n)
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(int argc, const char * argv[]) {
    int Tate,Yoko;
    while(true){
        cin >> Tate >> Yoko;
        if(Tate==0 && Yoko==0) break;
        FOR(vert, 0, Tate){
            if (vert%2==0) {
                FOR(hori, 0, Yoko){
                    if (hori%2==0) cout << '#';
                    else cout << '.';
                }
                cout << endl;
            }
            else{
                FOR(hori, 0, Yoko){
                    if (hori%2==0) cout << '.';
                    else cout << '#';
                }
                cout << endl;
            }
        }
        cout << endl;
    }
}



Measured memory_bytes: 3104
#include <stdio.h>

int main(void) {
	int x[5];
	int i;
	for (i = 0; i < 5; i++) {
		if (scanf("%d", &x[i]) != 1) return 1;
	}
	for (i = 0; i < 5; i++) {
		if (x[i] == 0) {
			printf("%d\n", i + 1);
			return 0;
		}
	}
	puts("error");
	return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

void solve(long long N, vector<long long> a){
  long long ans = 0;
  sort(a.begin(), a.end());
  vector<long long> c(N+1, 0);
  c[N] = a[0]%2;
  ans ^= (c[N] * N);
  for (int i = 1; i < N; i++) {
    c[N-i] = (a[i] - a[i-1])%2;
    ans ^= (c[N-i] * (N-i));
  }
  if (ans > 0) {
    std::cout << "first" << std::endl;
  } else {
    std::cout << "second" << std::endl;
  }
}

int main(){
  long long N;
  scanf("%lld",&N);
  vector<long long> a(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&a[i]);
  }
  solve(N, a);
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int a[222222], b[222222];
int main() {
	int n, q;
	cin >> n;
	rep(i, n)cin >> a[i];
	cin >> q;
	while (q--) {
		int k;
		cin >> k;
		cout << lower_bound(a, a + n, k) - a <<" "<< upper_bound(a, a + n, k) - a << endl;
	}
	return 0;
}


Measured memory_bytes: 3440
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;
typedef long long ll;
double *dp;




void solve(){
	
	long long N, A, B;
	cin >> N >> A >> B;
	if (A < B) {
		long long tmp = A;
		A = B;
		B = tmp;
	}
	if (A == B) {
		cout << 1<<endl;
	}
	else if ((A - B) % 2 == 0) {
		long long ans = (A - B) / 2;
		cout << ans << endl;
	}
	else {
		long long ans1 = B + (A - B - 1) / 2;
		long long ans2 = N - A + 1 + (A - B - 1) / 2;
		if (ans1 < ans2) {
			cout << ans1 << endl;
		}
		else {
			cout << ans2 << endl;
		}
	}
	
}


int main() {
	solve();

}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n-1):
    a.append(list(map(int, input().split())))
for i in range(n-1):
    total = a[i][1]
    for j in range(i, n-1):
        total = max(a[j][1], total)
        total += (a[j][2] - total%a[j][2])%a[j][2]
        total += a[j][0]
    print(total)
print(0)
        

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


int main() {
  string s; cin >> s;
  if (s[0] != s[1] && s[0] != s[2] && s[1] != s[2]) cout << "Yes";
  else cout << "No";
  cout << endl;
}


Measured memory_bytes: 256
package main

import(
  "fmt"
)

func main(){
  var g , h , gj , sum , pat int
  fmt.Scan( &g , &h , &gj , &sum )

  for loop1 := 0 ; loop1 <= g ; loop1++ {
    for loop2 := 0 ; loop2 <= h ; loop2++ {
      for loop3 := 0 ; loop3 <= gj ; loop3++ {
        if ( loop1 * 500) + ( loop2 * 100 ) + (loop3 * 50 ) == sum {
          pat++
        }
      }
    }
  }

  fmt.Print( pat )
}


Measured memory_bytes: 512
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(b>a){
	cout<<b+b-1;
	}
	else if(a==b){
		cout<<2*a;
	}
	else if(a>b){
		cout<<a+a-1;
	}
	
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,M,R;
int dis[2][210][210];
int z[1010];
int dp[1010][210];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  while (cin >> N >> M, N) {
    MINF(dis);
    REP(i,M) {
      int x,y,t;
      char c;
      cin >> x >> y >> t >> c;
      x--; y--;
      CHMIN(dis[c!='L'][x][y],t);
      CHMIN(dis[c!='L'][y][x],t);
    }
    cin >> R;
    REP(i,R) cin >> z[i], z[i]--;
    REP(_,2) REP(i,N) dis[_][i][i] = 0;
    REP(_,2) REP(k,N) REP(i,N) REP(j,N) {
      CHMIN(dis[_][i][j],dis[_][i][k]+dis[_][k][j]);
    }
    MINF(dp);
    dp[0][z[0]] = 0;
    using P = tuple<int,int,int>;
    priority_queue<P,vector<P>,greater<P>> que;
    que.emplace(0,0,z[0]);
    while (!que.empty()) {
      P p = que.top(); que.pop();
      int dd,id,v;
      tie(dd,id,v) = p;
      if (dp[id][v] < dd) continue;
      if (id+1 < R && CHMIN(dp[id+1][v],dp[id][v]+dis[0][z[id]][z[id+1]])) {
        que.emplace(dp[id+1][v],id+1,v);
      }
      for (int nv = 0; nv < N; nv++) {
        if (id+1 < R && CHMIN(dp[id+1][nv],dp[id][v]+dis[0][z[id]][v]+dis[1][v][nv]+dis[0][nv][z[id+1]])) {
          que.emplace(dp[id+1][nv],id+1,nv);
        }
      }
    }
    cout << *min_element(dp[R-1],dp[R-1]+N) << endl;
  }

  return 0;
}


Measured memory_bytes: 5628
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define INF 1000000000007
#define MOD 1000000007
#define ARRAY_MAX 3005

int dp[ARRAY_MAX][ARRAY_MAX];


int main(){

    int n,m;
    string s,t;
    cin >> s >> t;
    n = s.size();
    m = t.size();

    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
            }else{
                dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]); 
            }
        }
    }
    string str;
    int s_len = n;
    int t_len = m;
    while(s_len > 0 && t_len > 0){
        if(s[s_len-1] == t[t_len-1]){
            str.push_back(s[s_len-1]);
            s_len--;
            t_len--;
        }else if(dp[s_len][t_len] == dp[s_len-1][t_len]){
            s_len--;
        }else{
            t_len--;
        }
    }
    reverse(str.begin(),str.end());
    cout << str << endl;

    return 0;
}

Measured memory_bytes: 35456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String wk = "";

		try {
			scanner = new Scanner(System.in);
			wk = scanner.next();

			System.out.println(wk.replaceAll(",", " "));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numK = 0;
		int s = 0;

		try {
			scanner = new Scanner(System.in);
			numK = scanner.nextInt();
			s = scanner.nextInt();

			int startK = 0;
			if (numK <= s / 3) {
				startK = numK;
			}
			int res = 0;
			for (int i = 0; i <= numK; i++) {
				for (int j = 0; j <= numK; j++) {
					if (s - i - j < 0) {
						break;
					} else if (s - i - j <= numK) {
						res++;
					}
					//					startK = s - i - j;
					//					for (int k = startK; k <= numK; k++) {
					//						if (i + j + k == s) {
					//							res++;
					//							break;
					//						}
					//					}
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

int main() {
  
  int X, Y;
  
  cin >> X >> Y;
  
  for(int i = 0; i <= X; i++){
    if(2 * i + 4 * (X - i) == Y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

}


Measured memory_bytes: 3620
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

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

    int A, B, C, D, E, F; 
    cin >> A >> B >> C >> D >> E >> F;

    // 100A*i + 100B*j + C*k + D*l <= F
    // (C*k+D*l)/(100A*i+100B*j) <= E/100
    
    const int JMAX = F / (100 * B);
    const int IMAX = F / (100 * A);
    const int KMAX = F / C;
    const int LMAX = F / D;

    int ansWt = 100 * A, ansSg = 0;
    REP(j,JMAX+1) {
        REP(i,IMAX+1) {
            int water = 100 * A*i + 100 * B*j;
            if (water > F) continue;

            REP(l,LMAX+1) {
                REP(k,KMAX+1) {
                    int sugar = C * k + D * l;

                    if (water + sugar <= F &&
                        (100+E)*(sugar) <= E*(water+sugar)){

                        // sugar/(water+sugar) > ansSg/(ansWt+ansSg)
                        if (sugar*(ansWt+ansSg) > ansSg*(water+sugar)) {
                            ansWt = water;
                            ansSg = sugar;
                        }
                    }
                }
            }
        }
    }

    cout << ansWt + ansSg << " " << ansSg << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
struct BIT{
private:
  vector<ll> v;
  int n;
public:
  BIT(int siz){
    v.resize(siz+1,0);
    n=siz+1;
  }
  void add(ll i,ll x){
    while(i<=n){
      v[i]+=x;
      i+=i&(-i);
    }
  }
  ll sum(int i){
    int s=0;
    while(i>0){
      s+=v[i];
      i-=i&(-i);
    }
    return s;
  }
  ll bsearch(int g){
    ll l=1,r=n+1;
    while(r-l>1){
      ll mid=(l+r)/2;
      if(sum(mid)<=g) l=mid;
      else r=mid;
    }
    return l;
  }
};
struct segtree{
private:
  ll siz;
  vector<P> node;
public:
  segtree(ll n){
    siz=1;
    while(siz<=n) siz*=2;
    node.resize(siz*2+1,P(174417441744,174417441744));
  }
  void upd(ll p,ll x){
    int p2=p;
    p+=siz-1;
    node[p]=P(x,p2);
    while(p>0){
      p=(p-1)/2;
      node[p]=min(node[2*p+1],node[2*p+2]);
    }
  }
  P max_v(ll a,ll b,ll p,ll l,ll r){
    if(a<=l&&r<=b) return node[p];
    if(r<=a||b<=l) return P(174417441744,174417441744);
    ll mid=(l+r)/2;
    return min(max_v(a,b,2*p+1,l,mid),max_v(a,b,2*p+2,mid,r));
  }
  P max_q(ll a,ll b){
    return max_v(a,b,0,0,siz);
  }
};
int main(){
  string s;
  cin>>s;
  int n=s.length();
  int k;
  cin>>k;
  segtree seg=segtree(s.length()+5);
  BIT bit=BIT(s.length()+5);
  for(int i=1;i<=s.length();i++){
    seg.upd(i,(int)(s[i-1]-'a'));
    bit.add(i,1);
  }
  string ans;
  for(int i=0;i<s.length();i++){
    int kps=bit.bsearch(min(k+1,(int)s.length()));
    P seg_ans=seg.max_q(0,kps+1);
    ans.push_back((char)(seg_ans.first+'a'));
    int pos=seg_ans.second;
    seg.upd(pos,(ll)174417441744);
    k-=bit.sum(pos)-1;
    bit.add(pos,-1);
    //cout<<i<<" "<<k<<endl;
    if(k<=0) break;
  }
  //cout<<ans<<endl;
  for(int i=1;i<=n;i++){
    if(bit.sum(i)-bit.sum(i-1)==1){
      ans.push_back(s[i-1]);
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 13288
#include <iostream>
#include <cmath>

using namespace std;

bool check_prime(int x){

    if (x == 2) return true;

    for (int i=2;i<int(sqrt(x));i++){
        if (x % i == 0) return false;
    }

    return true;
}

int main(){
    int X, Y;
    cin >> X;
    Y = X;
    int log2 = 0;
    while(Y > 1) {
        Y /= 2;
        log2++;
    }
    int Z = pow(2, log2+1);
    for(int i=X;i<Z;i++){
        if(check_prime(i)){
            cout << i << endl;
            return 0;
        }
    }

}

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

int main() {
    int p, q,r;
    cin >> p >> q >> r;

    int a,b,c,ans;
    a = p + q;
    b = p + r;
    c = r + q;
    ans = min(min(a,b),c);
    cout << ans << endl;

}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
ans=0
f=1
m=max(l)
for j in range(m):
    for i in range(n):
        if l[i]==0:
            f=1
        elif f==0:
            l[i]-=1
        else:
            ans+=1
            l[i]-=1
            f=0
    f=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

vector<int> to[200010];
vector<ll> c(200010,0);
vector<ll> x(200010,0);

void dfs(int n, ll xx, int p){
    c[n] += xx;
    c[n] += x[n];
    for(int i = 0; i < to[n].size(); i++){
        if(to[n][i] == p) continue;
        dfs(to[n][i],xx+x[n], n);
    }
}

int main(){
    int n,q;
    cin >> n >> q;
    for(int i = 0; i < n-1; i++){
        int a,b;
        cin >> a >> b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    for(int i = 0; i < q; i++){
        int p,xx;
        cin >> p >> xx;
        x[p] += xx;
    }
    dfs(1, 0, 0);

    for(int i = 1; i <= n; i++){
        if(i != 1) cout << " ";
        cout << c[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 32128
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;
ll n,q,m,k,l,ans;
string s;
vll a,b;
map<ll, vll> bits;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    
    cin >> n;
    double pi = 3.1415926535;
    cout << (2*n*pi) << endl;
    return 0;
}

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

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define int ll
//int INF = 1e9;
const long long INF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template<class T> inline void chmax(T& a, T b) { if (a < b) a = b; }
template<class T> inline void chmin(T& a, T b) { if (a > b)  a = b; }

const int MAX_N = 110;
const int MAX_V = 100100;
int N;
int W, weight[MAX_N], value[MAX_N]; 
int dp[MAX_N][MAX_V];

signed main() {
	ios::sync_with_stdio(false);
	cin >> N >> W;
	for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];
	for (int i = 0; i < MAX_N; ++i) for (int j = 0; j < MAX_V; ++j) dp[i][j] = INF;
	dp[0][0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
			if (sum_v - value[i] >= 0) chmin(dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
			chmin(dp[i + 1][sum_v], dp[i][sum_v]);
		}
	}
	long long res = 0;
	for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
		if (dp[N][sum_v] <= W) res = sum_v;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 86272
#include <bits/stdc++.h>
#define reg register
#define ll long long
#define vi vector<int>
#define SZ(x) (int) x.size()
#define pb push_back
using namespace std;
const int MAXN = 5010;
char s[MAXN];
int n, cnt[MAXN];
ll ans;
void work() {
  scanf("%d%s", &n, s + 1);
  for(reg int i = 1; i <= n; ++i) ++cnt[s[i] - 'A'];
  ans = 1ll * cnt['R' - 'A'] * cnt['G' - 'A'] * cnt['B' - 'A'];
  for(reg int i = 1; i <= n; ++i) {
    int j = i - 1, k = i + 1;
    while(j && k <= n) {
      if(s[j] != s[k] && s[k] != s[i] && s[i] != s[j]) ans--;
      j--, ++k;
    }
  }
  printf("%lld\n", ans);
}
int main() {
  int _ = 1;
  // scanf("%d", &_);
  while(_--) work();
  return 0;
}


Measured memory_bytes: 3816
#include <iostream>
#include <string>
using namespace std;
int main(void){
     
    //変数：入出力文字「 ioString 」, 最初の4文字「 fastString 」, 残りの文字「 restString 」と置く
    string ioString, fastString, restString;
    //変数：交換回数「 m 」、交換場所を「 h 」と置く
    int m, h;
     
    cin >> ioString;
 
     
    while(1){
        if( ioString == "-") break;
        cin >> m;
        for(int i = 0; i < m; i++){
            cin >> h;
            //初期化：交換文字をクリアしている
            fastString.clear();
            restString.clear();
            //分割：入出力文字を分割している
            fastString.insert(0,ioString.substr(0,h));
            restString.insert(0,ioString.substr(h,ioString.size()-h));
            //初期化・入替文字代入している
            ioString.clear();
            ioString = restString + fastString;
        }
        cout << ioString << endl;
        cin >> ioString;
    }
     
}


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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 1;
    rep(i, n) {
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
        if (a[i] > 1000000000000000000 / ans) {
            cout << -1 << endl;
            return 0;
        } else {
            ans *= a[i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

namespace ConsoleApp15
{
    class Class390
    {
        static void Main()
        {
            var NX = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NX[0], X = NX[1];
            var L = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var D = new int[N + 1];
            for (int i = 0; i < N; i++)
            {
                D[i + 1] = D[i] + L[i];
            }

            int count = 0;
            for (int i = 0; i < N+1; i++)
            {
                if (D[i] <= X) count++;
                else break;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
a,b,k = list(map(int,input().split()))
c= 1
d=0
if b < a:
    a,b=b,a
while True:
    d = b%a
    if d == 0:
        c=a
        break
    else:
        b = a
        a = d
e = 0
for i in range(1,c+1):
    if c%i == 0:
        e +=1
        if e == k:
            print(int(c/i))
            break

Measured memory_bytes: 3064
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn calc(abcdv: &Vec<Vec<u32>>, v: &mut Vec<u32>, ans: &mut u32) {
    let mut tmp = 0;

    for i in 0..abcdv.len() {
        let a = abcdv[i][0] as usize;
        let b = abcdv[i][1] as usize;
        let c = abcdv[i][2];
        let d = abcdv[i][3];

        if v[b] - v[a] == c {
            tmp += d;
        }
    }

    if tmp > *ans {
        *ans = tmp;
    }
}

fn rec(n: usize, m: u32, abcdv: &Vec<Vec<u32>>, v: &mut Vec<u32>, ans: &mut u32) {
    if n == 0 {
        calc(abcdv, v, ans);
    } else {
        let l = v[v.len() - 1];
        for tmp in l..m + 1 {
            v.push(tmp);
            rec(n - 1, m, abcdv, v, ans);
            v.pop();
        }
    }
}

fn main() {
    let nmq: Vec<u32> = read_vec();
    let n = nmq[0] as usize;
    let m = nmq[1];
    let q = nmq[2] as usize;

    let abcdv: Vec<Vec<u32>> = read_vec2(q);

    let mut v = vec![1];

    let mut ans = 0;

    rec(n, m, &abcdv, &mut v, &mut ans);

    println!("{}", ans);
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> s(n, string(n, '.'));
  auto f3 = [&](int i, int j) {
    s[i][j] = s[i][j + 1] = 'a';
    s[i + 1][j + 2] = s[i + 2][j + 2] = 'b';
  };
  auto f4 = [&](int i) {
    s[i + 0] = s[i + 0].substr(0, i) + "aacd" + s[i + 0].substr(i + 4);
    s[i + 1] = s[i + 1].substr(0, i) + "bbcd" + s[i + 1].substr(i + 4);
    s[i + 2] = s[i + 2].substr(0, i) + "cdaa" + s[i + 2].substr(i + 4);
    s[i + 3] = s[i + 3].substr(0, i) + "cdbb" + s[i + 3].substr(i + 4);
  };
  if (n == 3) {
    f3(0, 0);
  } else if (n % 4 == 0) {
    for (int i = 0; i < n; i += 4) {
      f4(i);
    }
  } else if (n >= 6 and n % 4 == 2) {
    f4(0);
    s[2] = s[2].substr(0, 2) + "..aa" + s[2].substr(6);
    s[3] = s[3].substr(0, 2) + "..bb" + s[3].substr(6);
    s[4] = s[4].substr(0, 2) + "aacd" + s[4].substr(6);
    s[5] = s[5].substr(0, 2) + "bbcd" + s[5].substr(6);
    for (int i = 6; i < n; i += 4) {
      f4(i);
    }
  } else if (n % 4 == 1) {
    s[0] = "cde.." + string(n - 5, '.');
    s[1] = "cde.." + string(n - 5, '.');
    s[2] = "aabcc" + string(n - 5, '.');
    s[3] = "b.bdd" + string(n - 5, '.');
    s[4] = "baaee" + string(n - 5, '.');
    for (int i = 5; i < n; i += 4) {
      f4(i);
    }
  } else if (n % 4 == 3) {
    s[0] = ".cde..." + string(n - 7, '.');
    s[1] = ".cde..." + string(n - 7, '.');
    s[2] = "abbaa.." + string(n - 7, '.');
    s[3] = "a...bcc" + string(n - 7, '.');
    s[4] = "b...bdd" + string(n - 7, '.');
    s[5] = "b...aee" + string(n - 7, '.');
    s[6] = "aabba.." + string(n - 7, '.');
    for (int i = 7; i < n; i += 4) {
      f4(i);
    }
  } else {
    cout << -1 << '\n';
    return 0;
  }
  for (auto e : s) {
    cout << e << '\n';
  }
}


Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef ll Weight;
typedef vector<vector<Weight>> Graph;
void add_edge(vector<vector<Weight>>& g, Weight from, Weight to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

template<class T> inline bool chmax(T& a, T b) { if (a <= b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

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

  ll l, r, d; cin >> l;

	ll ans = 0;
	rep(i, l) {
	  int a;
		 cin >> a;
		 if (i % 2 == 0 && a % 2 == 1) ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>

typedef long long int li;
typedef long double ld;


using namespace std;

int main(){
    ld a,x,y;
    cin >> a;
    x=2*a*3.141592653589;
    y=pow(a,2.0)*3.141592653589;
    cout << fixed << setprecision(5) << y << " " << x << endl;
    return 0;
}



Measured memory_bytes: 3292
import Data.List

main = do
    let toInt = (read :: String -> Int) 
    xs <- getLine >>= return . map toInt . words
    let lx = xs !! 0
    let ln = xs !! 1
    if ln == 0
        then
          print lx
        else 
          do
            pn <- getLine >>= return . take ln . map toInt . words
            let an = map fst $ sortBy (\x y -> compare (snd x) (snd y)) $ map (\x -> ((lx - x), abs (lx - x))) pn
            let minAbsDiff = head $ filter (\x -> notElem x an || notElem (-1 * x) an) [0..]
            let neg = elem (lx - minAbsDiff) pn
            print $ if neg then (lx + minAbsDiff) else (lx - minAbsDiff)



Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	//freopen("in.txt","r",stdin);
	int n,r;
	scanf("%d%d",&n,&r);
	if(n>=10) printf("%d\n",r);
	else printf("%d\n",r+100*(10-n));
	return 0;
}


Measured memory_bytes: 256
#template
def inputlist(): return [int(k) for k in input().split()]
def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)
#template
S = input()
ans = 0
n = len(S)
for i in range(2**(n-1)):
    k = base10to(i,2)
    tmp = S[0]
    if len(k)<n-1:
        for j in range(n-1-len(k)):
            k = '0'+k
    for l in range(1,n):
        if k[l-1] == '0':
            tmp+= S[l]
        else:
            ans += int(tmp)
            tmp = S[l]
    ans += int(tmp)
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define mod 924844033
multiset<int>S; int n,M;
int main()
{
	cin >> n;
	for(int i=0;i<n;i++){
		int a; cin >> a;
		M = max(M,a); S.insert(a);
	}
	int cur = M,zan = M+1;
	while(zan){
		for(int i=0;i<min(2,zan);i++){
			if(S.find(cur) == S.end()){
				puts("Impossible"); return 0;
			}
			else S.erase(S.find(cur));
		}
		zan -= min(2,zan);
		cur--;
	}
	for(multiset<int>::iterator it = S.begin();it != S.end();++it){
		int x = *it;
		if(!(cur+2 <= x && x <= M)){
			puts("Impossible"); return 0;
		}
	}
	puts("Possible");
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll func(ll A, ll B){
  ll ret = 0, div = 1;

  while((A / div > 0) || (B / div > 0)){
    div *= 10;
    ret++;
  }

  return ret;
}

int main(){
  ll N;
  cin >> N;

  ll sqN = (ll)ceil(sqrt(N));
  ll ans = (ll)pow(10, 9);

  rep2(i, 1, sqN + 1){
    if(N % i == 0){
      ans = min(ans, func(i, N / i));
    }
  }

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

Measured memory_bytes: 256
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(l[K-1])

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

int main() {
    int S;
    cin >> S;
   
    int h, s, m;
    m = S / 60;
    s = S % 60;
    h = m / 60;
    m = m % 60;
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    char S;
    cin >> S;
    cout << char(S + 1) << endl;
}



Measured memory_bytes: 764
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<complex>
#include<list>
#include<cstdio>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)


using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




const int INF = 1e9+7;


/******************************************************************************************/

int cnt[2000005];

int main() {

	cin.tie(0);
	//ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int n;
	cin >> n;
	vector<int> a(n);
	cin.clear();
	char st[100];
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		cnt[a[i]]++;
	}
	
	for (int i = 0; i < 2000005; i++)
	{
		if (i + 1 < 2000005) {
			cnt[i + 1] += cnt[i];
		}
	}

	vector<int> ans(n + 10, 0);
	
	for (int i = 0; i < a.size(); i++){
		ans[cnt[a[i]] - 1] = a[i];
		cnt[a[i]]--;
	}

	for (int i = 0; i < n; i++)
	{
		if (i)cout << " ";
		cout << ans[i];
	}
	cout << endl;
	
	


	return 0;
}


Measured memory_bytes: 26176
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll=long long;

#define PRI(n) cout << n <<endl;
#define PRI2(n, m) cout << n << " " << m << endl;
#define PRI3(n, m, o) cout << n << " " << m<< " " << o << endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REPInv(i, n)  for(int i = n-1; i >= 0; --i)

#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)
#define FORInv(i, t, n)  for(int i = t; i >= (int)n; --i)

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) FORInv (j, min(i, r), 1)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}

int N, K;
int D[10];

int main() {
    cin >> N >> K;
    REP(i, K) {
        int x;
        cin >> x;
        D[x] = 1;
    }
    FOR(i, N, 10 * N) {
        string s = to_string(i);
        bool flag = true;
        REP(j, s.length()) {
            REP(k, 10) {
                if (D[k]){
                   // PRI2(s[j],k)
                    if (s[j] - '0' == k){
                        flag = false;
                        break;
                    }
                }
            }
            if(!flag)break;
        }
        if(flag){
            PRI(s);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256