akhauriyash/Code-Regression huggingface dataset:
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

int n,a,b;
ll l,r;

int main(){
	n=IN(),a=IN(),b=IN();
	if (n==1&&a!=b||a>b) return puts("0"),0;
	l=1ll*(n-1)*a+b;
	r=1ll*(n-1)*b+a;
	cout<<r-l+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t=0,m;

	cin >> n >> j;
	for(i=1;i<=n;i++)
	{
		cin >> x >> y;
		m=x*x+y*y;

		if(m<=j*j)
			t++;
	}
	cout<<t<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int x, y , z;
/**********************************************/

int main(){
    cin >> x >> y >> z;

    if(x % (y+z) >= z){
        cout << x/(y+z) << endl;
    }else{
        cout << x/(y+z) - 1 << endl;
    }
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> board(H);
  
  vector<int> dx = {-1, 1, 0, 0, -1, 1, -1, 1};
  vector<int> dy = {0, 0, -1, 1, -1, -1, 1, 1};
  
  for (int i = 0; i < H; i++) {
    cin >> board[i];
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (board[i][j] == '#') continue;
      
      int num = 0;
      for (int d = 0; d < 8; d++) {
        const int ni = i + dy[d];
        const int nj = j + dx[d];
        
        if (ni >= H || ni < 0) continue;
        if (nj >= W || nj < 0) continue;
        if (board[ni][nj] == '#') num++;
      }
      board[i][j] = char(num + '0');
    }
  }
  
  for (int i = 0; i < H; i++) cout << board[i] << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;++i) cin >> a[i];

    ll ans = 0LL;
    for(int i=0;i<n;++i) {
        for(int j=i+1;j<n;++j) {
            if(a[i] == a[j]) continue;
            for(int k=j+1;k<n;++k) {
                if(a[i] == a[k] || a[j] == a[k]) continue;
                if(a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i]) {
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		string s;cin>>s;
		if(s[0]>=97&&s[0]<=122)cout<<'a'<<endl;
		else cout<<'A'<<endl;





}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    
}

Measured memory_bytes: 5952
my $n = <STDIN>;
my $s = <STDIN>;
my @s = split(/ /,$s);
@a = split(//,$s[0]);
@b = split(//,$s[1]);
 
#print "$a $b\n";
for($i= 0;$i<$n;$i++){
  print "$a[$i]$b[$i]";
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1)%1000000007;
    }
}

/* ユークリッドの互除法 最大公約数*/
/*ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
*/


/*最小公倍数*/
/*
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
*/

/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n;
    cin>>n;
    cout<<factorial(n)%1000000007<<endl;

    

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    int N;
    vector<int> P;
    void input() {
        cin >> N;
        P.resize(N);
        REP(i, N) { cin >> P[i]; }
    }
    void output() {
        vector<int> Q(N + 1);
        REP(i, N) { Q[P[i]] = i + 1; }
        int mx = 1;
        int cnt = 1;
        FOR(i, 1, N) {
            if (Q[i] < Q[i + 1])
                ++cnt;
            else
                cnt = 1;
            mx = max(mx, cnt);
        }
        int res = N - mx;
        cout << res << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 4756
#include<bits/stdc++.h>
using namespace std;
int main(){

  int n,len=0,ans=0;
  string c,str;
  queue<int> que;
  cin >> n >> c;

  for(int i=0;i<n;i++){
    cin >> str;

    for(int j=0;j<str.size();j++){
      
      if(c[0] == str[j]){
	for(int k=j+1;k<str.size();k++){
	  if(c[1] == str[k]) que.push(k);
	}
	
	while(!que.empty()){
	  int sa = que.front()-j;
	  for(int k=j;len < c.size()&&k < str.size();k+=sa){
	    if(c[len] != str[k]) break;
	    len++;
	  }
	  if(len == c.size()){
	    ans++;
	    break;
	  }
	  len=0;
	  que.pop();
	}
	
      }
      while(!que.empty()) que.pop();
      if(len != 0){
	len=0;
	break;
      }
    }
  }
  
  cout << ans << endl;
  return (0);
}

Measured memory_bytes: 3180
MAX = 2*10**6+100
fact = [0]*MAX
inv = [0]*MAX
finv = [0]*MAX
 
def C_init():
    fact[0] = 1
    fact[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    
    for i in range(2, MAX):
        fact[i] = fact[i-1]*i%MOD
        inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
        finv[i] = finv[i-1]*inv[i]%MOD
 
def C(n, r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD

def g(r, c):
    return ((r+2)*C(c+r+2, r+2)-c-1)*inv[c+1]

r1, c1, r2, c2 = map(int, input().split())
MOD = 10**9+7
C_init()
ans = g(r2, c2)-g(r2, c1-1)-g(r1-1, c2)+g(r1-1, c1-1)
ans %= MOD

print(ans)

Measured memory_bytes: 85616
using System;
using System.Collections.Generic;
using System.Linq;

class C
{
    static void Main()
    {
#if DEBUG
        string exampleInput =
        @"4 6 10
2 4 1 86568
1 4 0 90629
2 3 0 90310
3 4 1 29211
3 4 3 78537
3 4 2 8580
1 2 1 96263
1 4 2 2156
1 2 0 94325
1 4 3 94328
";
        Console.SetIn(new System.IO.StringReader(exampleInput));
#endif

        var NMQ = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        var N = NMQ[0];
        var M = NMQ[1];
        var abcd = Enumerable.Range(0, NMQ[2]).Select(_ => Console.ReadLine().Split(' ').Select(int.Parse).ToList()).ToList();

        var result = 0L;
        for (int i0 = 1; i0 <= M; i0++)
        {
            for (int i1 = N > 1 ? i0 : M; i1 <= M; i1++)
            {
                for (int i2 = N > 2 ? i1 : M; i2 <= M; i2++)
                {
                    for (int i3 = N > 3 ? i2 : M; i3 <= M; i3++)
                    {
                        for (int i4 = N > 4 ? i3 : M; i4 <= M; i4++)
                        {
                            for (int i5 = N > 5 ? i4 : M; i5 <= M; i5++)
                            {
                                for (int i6 = N > 6 ? i5 : M; i6 <= M; i6++)
                                {
                                    for (int i7 = N > 7 ? i6 : M; i7 <= M; i7++)
                                    {
                                        for (int i8 = N > 8 ? i7 : M; i8 <= M; i8++)
                                        {
                                            for (int i9 = N > 9 ? i8 : M; i9 <= M; i9++)
                                            {
                                                var A = new int[] { i0, i1, i2, i3, i4, i5, i6, i7, i8, i9 };
                                                var r = abcd.Where(x => A[x[1] - 1] - A[x[0] - 1] == x[2]).Sum(x => x[3]);
                                                result = Math.Max(result, r);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        Console.WriteLine(result);
        Console.Out.Flush();
    }
}

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

using namespace std;

string a, b;

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

    cin >> a;

    cin >> b;

    if (a.length() > b.length()) {
        cout << "GREATER" << endl;

        return 0;
    }

    if (a.length() < b.length()) {
        cout << "LESS" << endl;

        return 0;
    }

    if (a > b) {
        cout << "GREATER" << endl;
    }

    if (a < b) {
        cout << "LESS" << endl;
    }

    if (a == b) {
        cout << "EQUAL" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;
const int MAXN=3e5+1e1;

int a[MAXN];
bool vis[MAXN];

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	int n,m,ans=0;

	scanf("%d%d",&n,&m);

	for(int i=1;i<=n;i++) a[i]=read<int>();

	for(int i=1;i<=m;i++)
	{
		int u=read<int>();
		int v=read<int>();
		if(a[u]<a[v]) vis[u]=true;
		if(a[u]>a[v]) vis[v]=true;
		if(a[u]==a[v]) vis[u]=vis[v]=true;
	}

	for(int i=1;i<=n;i++) if(!vis[i]) ++ans;

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

	return 0;

}

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

#include <stdio.h>
#include <stdlib.h>

int main() {
	int N, A, B, min, max, sa;
	cin >> N;
	cin >> A;
	cin >> B;

	min = A + B - N;
	if (min < 0) min = 0;

	if ((A-B) > 0) {
		max = B;
	} else {
	 	max = A;
	}

	printf("%d %d\n", max, min);

	return 0;

}


Measured memory_bytes: 256
import string

def main():
    n = int(input())
    t = [[0 for _ in range(n)] for _ in string.ascii_lowercase]

    for i in range(n):
        s = input()
        for c in s:
            t[ord(c) - ord('a')][i] += 1
    
    r = []
    for i, c in enumerate(string.ascii_lowercase):
        r.append(c * min(t[i]))
    
    print(''.join(r))

main()


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

int main(int argc, char const *argv[]) {
  int K, S;
	cin >> K >> S;

	int countPair = 0;
	for (int x = 0; x <= K; x++){
		for (int y = 0; y <= K; y++) {
			int z = S - x - y;
			if (z >= 0 && z <= K)
				countPair++;
		}
	}
	cout << countPair;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define INF 100000000000;
using namespace std;

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

  vector<long long int> h(n);
  long long int minGap = INF;

  for(int i = 0; i < n; i++){
    cin >> h[i];
  }

  sort(h.begin(), h.end());

  for(int i = 0; i+(k-1) < n; i++){
    if(minGap > (h[i+(k-1)] - h[i])){
      minGap = h[i+(k-1)] - h[i];
    }
  }

  cout << minGap << endl;

  return 0;

}


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

// ABCテンプレート

#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;


int main() {
  int N, ans=0;
  cin >> N;
  for (int i = 1; i<=N; i++) {
    int a;
    cin >> a;
    if(i%2==1 && a%2==1) {
      ans++;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 3616
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
Pi = 0
Qi = 0
l = [i+1 for i in range(N)]
for i, retu in enumerate(itertools.permutations(l), 1):
    if P == retu:
        Pi = i
    if Q == retu:
        Qi = i

print(abs(Pi-Qi))

Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926535898
#define ll long long
#define int long long
typedef std::pair<long long,long long> pll;
typedef std::pair<int,int> pii;
typedef std::vector<int> vi;
typedef std::vector<long long> vll;
typedef double db;
const ll mod=1e9+7;
ll powmod(ll a,ll b,ll p){ll res=1;a%=p;while(b){if(b&1) res=res*a%p;a=a*a%p;b>>=1;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
signed main()
{
    int t=1;
    //cin>>t;
    while (t--){
        int x,n;
        cin>>x>>n;
        set<int> set;
        for (int i = 0; i < n ; ++i) {
            int ni;
            cin>>ni;
            set.insert(ni);
        }
        if(n==0) {
            cout<<x<<endl;
            break;
        }
        int i=0;
        while (1){
            if(!set.count(x-i)) {
                cout<<x-i<<endl;
                break;
            }
            if(!set.count(x+i)){
                cout<<x+i<<endl;
                break;
            }
            i++;
        }

    }
}

Measured memory_bytes: 3628
n=int(input())
A=list(map(int,input().split()))
c=[0]*3
for a in A:
    if a%2!=0:
        c[0]+=1
    elif a%4==0:
        c[2]+=1
    else:
        c[1]+=1

if c[2]<c[0]-1:
    print("No")
else:
    c[2]-=(c[0]-1)
    if c[1]==0:
        print("Yes")
    else:
        if c[2]>0:
            print("Yes")
        else:
            print("No")

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


#define ll long long 

#define nax 301

double dp[nax][nax][nax];


double solve(int x, int y, int z, int n) {
    if(x < 0 || y < 0 || z < 0) return 0;
    
    if(x+y+z == 0) return 0;
    
    
    if(dp[x][y][z] > -0.9) return dp[x][y][z];
    
    
    int sum = x+y+z;
    
    double ans = n + (x*solve(x-1, y,z,n)) + (y*solve(x+1, y-1, z,n)) + (z*solve(x, y+1, z-1,n));
    return dp[x][y][z] = ans/sum;
    
}



int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin>>n;
    
    int x = 0, y= 0, z = 0;
    for(int i = 1; i<= n; i++) {
        int tmp; cin>>tmp;
        if(tmp == 1) x++;
        else if(tmp == 2) y++;
        else z++;
    }
    
    
    for(int i = 0; i < nax; i++){
        for(int j = 0; j < nax; j++){
            for(int k = 0; k < nax; k++) 
            dp[i][j][k] = -1;
        }
    }
    
    
    cout<<fixed<<setprecision(10)<<solve(x,y,z,n);
    
    
	return 0;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

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

	vi ans;
	for (int i = 1; i <= 100; ++i) {
		ans.pb(i);
	}

	vi nums, vec;

	int mn = -1, mx = -1;

	while (N) {
		if (N & 1) {
			vec.pb(1);
			--N;
		}

		if (N == 2) {
			mn = mx = 0;
			nums.pb(0);
			break;
		}

		vec.pb(0);
		N /= 2;
	}

	reverse(ALL(vec));

	for (int f : vec) {
		if (mn == -1 && mx == -1) {
			mn = mx = 0;
			nums.pb(0);
			continue;
		}

		if (f == 0) {
			nums.pb(mx + 1);
			++mx;
		} else {
			nums.pb(mn - 1);
			--mn;
		}
	}

	for (int x : nums) {
		ans.pb(x - mn + 1);
	}

	cout << ans.size() << endl;
	rep(i, ans.size()) cout << ans[i] << (i + 1 == ans.size() ? '\n' : ' ');

	return 0;
}

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

#define debi(var) "[" << (#var) << " : " << var <<"]" << " "
#define debv(v) "[" << (#v) << " : {";for(int i = 0; i < v.size() - 1; ++i)\
					cout << v[i] <<", ";cout << v.back() << "}] "
#define deba(a,n) "[" << (#a) << " : {";for(int i = 0; i < n - 1; ++i)\
					cout << a[i] << ", ";cout << a[n - 1] << "}] "
#define debp(p) "[" << (#p) << " : {" << p.first << ", " << p.second << "}] "
#define debs(s) "[" << (#s) << " : {";auto _itr = s.begin();\
					for(int k = s.size(); k > 1; --k) {cout << *_itr << ", "; ++_itr;} cout << *_itr << "}] "

typedef long long ll;
/*LETS BEGIN WITH THE NAME OF LORD MAHADEV*/
int main(){
	int n;
	cin >> n;
	bool zero = false,greater = false;
	ll ans = 1;
	while(n--){
		ll val;
		cin >> val;
		if(!val){
			zero = true;
			break;
		}
		if(val <= (ll)1e18 / ans){
			ans *= val;
		}else{
			greater = true;
		}
	}
	if(zero){
		cout << 0 << endl;
	}else if(greater){
		cout << -1 << endl;
	}else{
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 3616
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> > 
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

int is[5005];
  
void solve() {
  int n, k; cin >> n >> k;
  int P[n+5], val[n+5], score[n+5], tot[n+5];
 
  for(int i = 1; i <= n; i++) {
    cin >> P[i];
  }
  
  int ans = -INF;
  for(int i = 1; i <= n; i++) {
    cin >> val[i];
    ans = min(ans, val[i]);
  }

  for(int i = 1; i <= n; i++) {
    int x = P[i], vis[n+5] = {0};
    vis[i] = 1;
    while(vis[x] == 0) {
       vis[x] = 1;
       x = P[x];
    }

    if(x == i) {
      vector <int> cyc;
      int s = val[i];
      cyc.pb(i);
      x = P[i];
      while(x != i) {
         cyc.pb(x);
         s += val[x];
         x = P[x];
      }
      for (auto j : cyc) {
        is[j] = 1;
        score[j] = s;
        tot[j] = sz(cyc);
      }
    }
  }
  
  //int ans = -INF;

  for(int i = 1; i <= n; i++) {
    int x = P[i], t = k, res = 0;
    int vis[n+5] = {0};
    vis[i] = 1;
    while(vis[x] < 2 && t > 0) {
      t--;
      res += val[x];
      ans = max(ans, res);
      if(is[x]) { 
        int temp = res + (t/tot[x]) * score[x];
        ans = max(ans, temp);
      }
      vis[x]++;
      x = P[x];
    }
  }
  
  cout << ans << '\n';  

}

/*
  * overflow, array bounds
  * do smth instead of nothing and stay organized
*/
signed main() {   
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
   //  cout << "Case #" << i << ": ";
     solve();
  }
}    

/*

*/

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

int main(){
	int n,m;
	cin>>n>>m;
	int x[m];
	for(int i=0;i<m;i++)cin>>x[i];
	sort(x,x+m);
	if(n>=m){
		cout<<0<<endl;
	}else{
		int dist[m-1];
		for(int i=0;i<m;i++)dist[i]=x[i+1]-x[i];
		long ans=0;
		sort(dist,dist+(m-1));
		for(int i=0;i<m-n;i++)ans += dist[i];
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();
        sc.close();

        if (S.length() <= K) {
            System.out.println(S);
        } else {
            System.out.println(S.substring(0, K) + "...");
        }

        return;
    }
}


Measured memory_bytes: 38608
#include <iostream>
#include <iomanip>

#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main()
{
	double r;
	cin >> r;

	double s = r * r * M_PI;
	double l = 2 * r * M_PI;

	cout << fixed << setprecision(6) << s << " " << l << endl;
}


Measured memory_bytes: 3276
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  String a = sc.next();
  String b = sc.next();
  String c = sc.next();
  char[] p = a.toCharArray();
  char[] q = b.toCharArray();
  char[] r = c.toCharArray();
  int ans = 0;
  for(int i = 0;i < n;i++){
    if(p[i] != q[i] && q[i] != r[i] && r[i] != p[i])ans += 2;
    else if(p[i] == q[i] && q[i] == r[i]){}
    else ans++;
  }
  System.out.println(ans);
}}


Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;
template<typename T> struct edge
{
    int from, to; T cost;
    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T> using Edges = vector<edge<T>>;
template<typename T> using Gragh = vector<Edges<T>>;
int V, E;
template<typename T> vector<T> BellmanFord(Edges<T> &edges, const int &s)
{
    vector<T> dist(V, INF);
    dist[s] = 0;
    for(int i = 0; i < V; i++)
    {
        for(auto &edge : edges)
        {
            if(dist[edge.from] == INF) continue;
            dist[edge.to] = min(dist[edge.to], dist[edge.from] + edge.cost);
        }
    }
    for(auto &edge : edges)
    {
        if(dist[edge.from] == INF) continue;
        if(dist[edge.from] + edge.cost < dist[edge.to]) return vector<T>(); //閉路
    }
    return dist;
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r; cin >> V >> E >> r;
    Edges<int> G;
    for(int i = 0; i < E; i++)
    {
        int s, t, d; cin >> s >> t >> d;
        G.emplace_back(s, t, d);
    }
    vector<int> dists = BellmanFord(G, r);
    if(dists.empty()) cout << "NEGATIVE CYCLE" << endl;
    for(int &dist : dists)
    {
        if(dist == INF) cout << "INF" << endl;
        else cout << dist << endl;
    }
    return 0;
}




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

using namespace std;

int main(void){
    int N = 0;
    cin >> N;
    
    vector<int> v(N);
    for(int i=0; i<N; i++)
        cin >> v[i];
    
    reverse(v.begin(), v.end());
    
    for(int i=0; i<N; i++){
        cout << v[i];
        if(i+1 != N)
            cout << " ";
    }
    cout << endl;
    
}


Measured memory_bytes: 3076
import copy

if __name__ == '__main__':
    s = list(input())

    char_list = set(s)

    # print(char_list)


    ans = 1000
    for target_char in char_list:
        tmp_s = copy.deepcopy(s)
        tmp_ans = 0
        while True:
            if len(set(tmp_s)) == 1:
                ans = min(ans, tmp_ans)
                break

            # print(tmp_s)
            # print(target_char)
            for i in range(0, len(tmp_s) - 1):
                # print(i)
                if tmp_s[i + 1] == target_char:
                    tmp_s[i] = target_char

            tmp_s.pop(len(tmp_s) - 1)
            tmp_ans += 1


    print(ans)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 100010
#define MOD 1000000007
typedef long long  ll;

using namespace std;


int main() {
	ll N,K,S;
	cin  >> N >> K >> S;

	
	vector<ll> ans(N);
	rep(i, N) {
		if (i < K) {
			ans[i] = S;
		}
		else {
			ans[i] = S + 1;
			if (S == 1e9) ans[i] = 1;
		}
	}

	

	rep(i, N) {
		if (i == N-1) {
			cout << ans[i] << endl;
		}
		else {
			cout << ans[i] << " ";
		}
	}

	

	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <class T>
using ordered_set =
       tree <T,null_type,less <T>,rb_tree_tag,tree_order_statistics_node_update> ;
///find_by_order()
///order_of_key()

template <class T,class U>
void maximize(T &x,U y){
    if(x < y)x=y;
}
template <class T,class U>
void minimize(T &x,U y){
    if(x > y)x=y;
}
template <class T>
T Abs(T x){
    return (x < (T)0 ? -x : x);
}
template <class T>
T safe_sqrt(T x){
    return sqrt(max(x,(T)0));
}
template <class T,class U,class V>
T addmod(T x,U k,V MOD){
    return ((x+k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T submod(T x,U k,V MOD){
    return ((x-k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T mul(T x,U y,V MOD){
    return ( (x % MOD) * (y % MOD) ) % MOD;
}

#define ll long long
#define pll pair <ll,ll>
#define pii pair <int,int>
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define emp emplace_back
#define MASK(i) ((1LL)<<(i))
#define BIT(x,i) (((x)>>(i))&1)
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)((c).size())
#define fn "test"    ///FILE_NAME_HERE

/*------------------------------------------END_OF_TEMPLATE------------------------------------------*/

namespace task{

	const int N =1e5 + 5;
	vector <pii> adj[N];
	int n;
	int ans[N];

	void dfs(int u,int p,int c){
		ans[u] = c;
		for(auto v : adj[u]){
			if(v.fir ^ p){
				dfs(v.fir,u,v.sec ^ c);
			}
		}
	}

    void solve(){
    	cin>>n;
    	for(int i = 1;i < n;++i){
    		int u,v,w;
    		cin>>u>>v>>w;
    		adj[u].emp(mp(v,w & 1));
    		adj[v].emp(mp(u,w & 1));
    	}
    	dfs(1,1,0);
    	for(int i = 1;i <= n;++i){
    		cout<<ans[i]<<'\n';
    	}
    }
}

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    task::solve();
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

vector<string> s;
int Left[2100][2100], Right[2100][2100], Up[2100][2100], Down[2100][2100];

int main()
{
    int h, w; cin >> h >> w;
    s.resize(h);
    rep(i, h) cin >> s[i];

    rep(i, h)
    {
        int cur = 0;
        rep(j, w)
        {
            if (s[i][j] == '#') cur = 0;
            else cur++;
            Left[i][j] = cur;
        }
    }

    rep(i, h)
    {
        int cur = 0;
        RRep(j, w - 1, -1)
        {
            if (s[i][j] == '#') cur = 0;
            else cur++;
            Right[i][j] = cur;
        }
    }

    rep(j, w)
    {
        int cur = 0;
        rep(i, h)
        {
            if (s[i][j] == '#') cur = 0;
            else cur++;
            Up[i][j] = cur;
        }
    }

    rep(j, w)
    {
        int cur = 0;
        RRep(i, h - 1, -1)
        {
            if (s[i][j] == '#') cur = 0;
            else cur++;
            Down[i][j] = cur;
        }
    }

    int res = 0;
    rep(i, h)
    {
        rep(j, w)
        {
            if (s[i][j] == '#') continue;
            res = max(res, Left[i][j] + Right[i][j] + Up[i][j] + Down[i][j] - 3);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 72448
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Optional;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			// すべての小文字を含む集合
			Set<Character> set = new HashSet<>();
			for (char a = 'a'; a <= 'z'; a++) {
				set.add(a);
			}
			set.removeAll(scanner.nextLine().chars().distinct().collect(ArrayList<Character>::new,
					(a, b) -> a.add((char) b), ArrayList<Character>::addAll));
			Optional<Character> first = set.stream().sorted().findFirst();
			System.out.println(first.isPresent() ? first.get() : "None");
		}
	}
}


Measured memory_bytes: 28116
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N, A_0, B_0, A_G, B_G; cin >> N >> A_0 >> B_0 >> A_G >> B_G;
    string S; cin >> S;
    S = '#' + S + '#';
    bool ok = true;
    if(A_G > B_G) {// A_0 -> B_0 -> B_G -> A_G
        //b_0 -> a_g の間でおいぬき
        bool canPassing = false;
        for(int i = B_0 - 1; i < B_G; ++i) {
            if(S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') {
                canPassing = true;
                break;
            }
        }
        if(!canPassing) ok = false;
    }

    for(int i = A_0; i < A_G; ++i) {
        if(S[i + 1] == '#' && S[i] == '#') {
            ok = false;
            break;
        }
    }
    for(int i = B_0; i < B_G; ++i) {
        if(S[i + 1] == '#' && S[i] == '#') {
            ok = false;
            break;
        }
    }
    cout << ((ok) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 772
n = int(input())
ais = list(map(int, input().split()))
for i in range(n-1):
  a = ais[i]
  b = ais[i+1]
  if a < b:
    a, b = b, a
  while a > 0 and b > 0:
    a = a % b
    a,b = b,a
  ais[i+1] = a
  ais[i] = b
print(max(ais))
    

Measured memory_bytes: 14224
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int x;
    cin >> x;
    cout << (x / 500) * 1000 + ((x % 500) / 5) * 5 << '\n';
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>
#include <string.h>


struct p{
    int num;
    double time;
};

using namespace std;

bool f(p l, p r){
    return l.time<r.time;
}

int main(){
    vector<p> haisya;
    for(int roop=0; roop<3; roop++){
        vector<p> in;
        
        for(int roop2=0; roop2<8; roop2++){
            p temp;
            cin>>temp.num>>temp.time;
            in.push_back(temp);
        }
        sort(in.begin(), in.end(), f);
        cout<<in[0].num<<" "<<in[0].time<<endl;
        cout<<in[1].num<<" "<<in[1].time<<endl;
        for(int roop2=2; roop2<8; roop2++){
            haisya.push_back(in[roop2]);
        }
    }
    sort(haisya.begin(), haisya.end(), f);
    cout<<haisya[0].num<<" "<<haisya[0].time<<endl;
    cout<<haisya[1].num<<" "<<haisya[1].time<<endl;

}

Measured memory_bytes: 1320
N, K = map(int,input().split())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

ans = Base_10_to_n(N, K)
print(len(ans))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
//プロトタイプ宣言
int gcd(int , int);
void often(void);
int get_digent(int);


int main(){
  often();
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i,s.size()){
    if(('Z' - s[i]) < n){
      s[i] = ("%c",('A' + n - 1 - ('Z' - s[i])));
    }
    else{
      s[i] = ("%c",(s[i] + n));
    }
  }
  rep(i,s.size()){
    cout << s[i];
  }
}








































//以下、ライブラリ

int gcd(auto a, auto b) {
  return b ? gcd(b, a%b) : a;
}  //ユークリッドの互除法

void often(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int get_digent(int x){
  string s;
  s = to_string(x);
  int digent = s.size();
  return digent;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
template <typename T, typename U>ostream &operator<<(ostream &out, const pair<T, U> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>void print(const ContainerType<ValueType, Args...> &c){for (const auto &v : c)cout << v << ' ';cout << '\n';} void print(){cout<<'\n';}
template <typename T, typename... Args>void print(T a, Args... args){cout << a << " ";print(args...);}
lli llipower(lli x, lli y, lli p = LLONG_MAX){lli res = 1;x = x % p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}

//8====================================D
int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int count=0;
    while(b<=a){
        b*=2;
        count++;
    }
    while(c<=b){
        c*=2;
        count++;
    }
    if(count<=k) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main()
{
	 // スペース区切りの整数の入力
    int x , a;
    cin >> x >>a;
    if (x < a){
       // 出力
    	cout << 0;
    }
  	else{
      cout << 10;
    }
    return 0;
}

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

char a[100010];
bool vis[30];
int al;

int main(){
	cin>>a; al=strlen(a);
	for(int i=0;i<al;i++)
		vis[a[i]-'a']=true;
	for(int i=0;i<26;i++)
		if(vis[i]==0){
			cout<<char(i+'a')<<endl;
			return 0;
		}
	cout<<"None"<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
class Main{
  public static void main(String[]z){
    Scanner x=new Scanner(System.in);
    int i=0;
    while(x.hasNext()){
      String s=x.nextLine();
      if(s.equals(new StringBuilder(s).reverse().toString()))i++;
    }
    System.out.println(i);
  }
}

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

struct Query {
    int i;
    int j;
    int diff;
    int score;
};

int findPrev(const vector<int> &v, int idx) {
    int j = idx - 1;
    while (j >= 0 && v[j] == 0) --j;
    return (j < 0 ? 0 : v[j]);
}

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

    int N, M, Q;
    cin >> N >> M >> Q;

    vector<Query> queries;

    for (int i = 0; i < Q; ++i) {
        Query q;
        cin >> q.i >> q.j >> q.diff >> q.score;
        queries.emplace_back(move(q));
    }

    int ans = 0;
    vector<int> buf({1});

    function<void(int)> dfs = [&](int idx) {
        if (idx == N) {
            int score = 0;
            for (const auto &q : queries) {
                if (buf[q.j] - buf[q.i] == q.diff) {
                    score += q.score;
                }
            }
            ans = max(ans, score);
            return;
        }

        for (int i = buf.back(); i <= M; ++i) {
            buf.push_back(i);
            dfs(idx + 1);
            buf.pop_back();
        }
    };

    dfs(0);

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

Measured memory_bytes: 3640
import re
import sys

n = int(input())
c = list(input())

count_r = 0
for i in c:
    if i == 'R':
        count_r += 1
count_w = n - count_r
ans = min(count_r, count_w)
if ans == 0:
    print(0)
    sys.exit()

pattern = r"^R*W*$"
# print(re.fullmatch(pattern, "RRRWW"))
# print(re.search(pattern, "RRRWW"))
l = 0
r = n-1
count = 0
# while not re.match(pattern, ''.join(c)):
while l < r:
    while c[l] == 'R':
        l += 1
    while c[r] =='W':
        r -= 1
    if l >= r:
        break
    c[l] = 'R'
    c[r] = 'W'
    count += 1
    # print(c, l, r)
    

ans = min(count, ans)

print(ans)

Measured memory_bytes: 11552
import sys
from datetime import date


def solution(d):
    sp = d.split('/')
    result = date(int(sp[0]), int(sp[1]), int(sp[2]))
    if result <= date(2019, 4, 30):
        return "Heisei"
    else:
        return "TBD"

for i,line in enumerate(sys.stdin):
    if i == 0:
        print(solution(line))
# print(solution('1991/02/28'))
# print(solution('2020/02/28'))
# print(solution('2019/04/30'))


Measured memory_bytes: 3440
l = list(map(int, input().split()))
s = sum(l)
if(s == 17):
    if(l[0]==5 or l[0]==7):
        if(l[0]+ l[1] == 10 or l[0] +l[1] == 12):
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
else:
    print("NO")

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        String S = sc.next();
        sc.close();

        int[] Sn = new int[N];
        List<Integer> LengthList = new ArrayList<>();

        //連続する0、1の数を数える、0を-1で表す
        for (int i=0; i < N; i++) {

            Sn[i] = Integer.parseInt(String.valueOf(S.charAt(i)));

            if (i == 0 || Sn[i-1] != Sn[i]) {

                if(Sn[i] == 1) {

                    LengthList.add(1);
                } else {

                    LengthList.add(-1);
                }
            } else {

                if(Sn[i] == 1) {

                    LengthList.set(LengthList.size()-1, LengthList.get(LengthList.size()-1) + 1);
                } else {

                    LengthList.set(LengthList.size()-1, LengthList.get(LengthList.size()-1) - 1);
                }
            }

        }

        int sum = 0;
        int ans = 0;
        int hitZeroArray = 0;
        int i = 0;
        int j = 0;

        while ( i < LengthList.size()) {

            if (hitZeroArray < K) {

                if (LengthList.get(i) > 0) {

                    sum += LengthList.get(i);
                    i++;

                    if (i == LengthList.size()) {

                        if (ans < sum) {

                            ans = sum;
                        }
                    }
                } else {

                    sum -= LengthList.get(i);
                    hitZeroArray++;
                    i++;

                    if (i == LengthList.size()) {

                        if (ans < sum) {

                            ans = sum;
                        }
                    }
                }
            }  else {

                sum += LengthList.get(i);
                i++;

                if (ans < sum) {

                    ans = sum;
                }

                while(j < LengthList.size()) {


                    sum -= Math.abs(LengthList.get(j));

                    if (LengthList.get(j) < 0 ) {

                        hitZeroArray--;
                        j++;
                        break;
                    }

                    j++;
                }
            }
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 32444
n , k = map(int, input().strip().split())
h = input().split()
list = []
list1 = []
count = 0
for i in h:
    b = int(i)
    list.append(b)
if k>=len(list):
    print('0')
else:
    list.sort()
    for j in range(0, len(list)-k):
        list1.append(list[j])
    sum = sum(list1)
    print(sum)

Measured memory_bytes: 27560
#include <cstdio>

using namespace std;
 
int main() {
	int n;
	long base = 100000;
	float interest = 0.05f;
	long roundNum;

	scanf("%d", &n);
	
	while (n--) {
	    base = base * (1 + interest);
	    roundNum = base % 1000;
	    
	    if (roundNum != 0) base += (1000 - roundNum);
	}
	
	printf("%ld\n", base);
	
	return 0;
}

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

int N,ans;
int V[21],C[21];

int main(){
    
    cin>>N;
    
    for(int i=0; i<N; i++)cin>>V[i];
    for(int i=0; i<N; i++){
        cin>>C[i];
        C[i]=V[i]-C[i];
        if(C[i]>0)ans+=C[i];
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include <cassert>

#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int dx[4] = { 1,0,-1,0 };//D,R,U,L
int dy[4] = { 0,1,0,-1 };

int dp[202][100010];
vector<int>S;
int N, X;
signed main() {
	cin >> N >> X;
	S.resize(N);
	REP(i, N) {
		cin >> S[i];
	}
	VSORT(S);
	m0(dp[0]);
	REP(i, X + 1)dp[0][i] = i;
	//dp[0][X] = X;

	REP(i, N) {
		REP(x, X+1) {
			dp[i + 1][x] += dp[i][x % S[i]]; dp[i + 1][x] %= MOD;
			dp[i + 1][x] += dp[i][x] * i; dp[i + 1][x] %= MOD;
		}
	}
	ll ans = 0;

	print(dp[N][X]);
}

Measured memory_bytes: 157952
import scala.io.StdIn._
object Main extends App {
  val Array(n, m, c) = readLine.split(" ").map(_.toInt)
  val b = readLine.split(" ").map(_.toInt)
  println((1 to n).map{ _ =>
    readLine.split(" ").map(_.toInt).zipWithIndex.foldLeft(0) { (acc, t) =>
      acc + t._1 * b(t._2)
    } + c
  }.count(_ > 0))
}


Measured memory_bytes: 25420