akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

ll proinverse(ll x,ll m){
    ll res=1,M=m-2;
    while(M>0){
        if(M&1) res=res*x%m;
        x=x*x%m;
        M>>=1;
    }
    return res;
}

int main(){
    ll q,Mod=1000003; cin>>q;
    vector<ll> fac(Mod,1);
    rep(i,Mod-1) fac[i+1]=(fac[i]*(i+1))%Mod;
    rep(i,q){
        ll x,d,n; cin>>x>>d>>n;
        if(d>0){
            if(n>=Mod) cout<<0<<endl;
            else{
                ll idx=x*proinverse(d,Mod)%Mod;
                if(idx==0 || idx+n-1>=Mod) cout<<0<<endl;
                else{
                    ll ans=1,c=d;
                    rep(i,20){
                        if(n&(1LL<<i)) ans=ans*c%Mod;
                        c=c*c%Mod;
                    }
                    ans=ans*fac[idx+n-1]%Mod;
                    ans=ans*proinverse(fac[idx-1],Mod)%Mod;
                    cout<<ans<<endl;
                }
            }
        }
        else{
            ll m=1,c=x;
            rep(i,32){
                if(n&(1LL<<i)) m=m*c%Mod;
                c=(c*c)%Mod;
            }
            cout<<m<<endl;
        }
    }
}

Measured memory_bytes: 11176
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  string s;
  cin>>s;
  string A={"ACGT"};
  int ans=0;
  rep(i,s.size()){
    int a=0;
    for(int j=i;j<s.size();j++){
      int x=0;
      rep(k,4) if(s[j]==A[k]) x++;
      if(x) a++;
      else break;
    }
    if(a>ans) ans=a;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#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;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef pair< ll,ll > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);	
	string s;cin>>s;
	int len=s.length();
	int a=0,b=0;
	for (int i = 0; i < len; ++i)
	{
		if(s[i]=='A') a++;
		else b++;
	}
	if(a>0&&b>0) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
str = input().split()
N = int(str[0])
M = int(str[1])
L = []
R = []
for i in range(M):
    str = input().split()
    L.append(int(str[0]))
    R.append(int(str[1]))

mini = 1
maxi = N
    
for i in range(M):
    if mini <= L[i]:
        mini = L[i]
    if maxi >= R[i]:
        maxi = R[i]
        
if (maxi - mini) >= 0:
    print(maxi - mini+1)
else:
    print(0)

Measured memory_bytes: 11020
#include<iostream>
#include<deque>
#include<algorithm>
using namespace std;
deque<char> s;
string st,ans;
int q,opt,f,fz,len;
char c;
int main() {
 cin>>st;
 len=st.size();
 for(int i=0;i<len;i++)
  s.push_back(st[i]);
 scanf("%d",&q);
 while(q--) {
  scanf("%d",&opt);
  if(opt==1)
   fz^=1;
  else {
   scanf("%d",&f);
   cin>>c;
   if(fz^(f==1))
    s.push_front(c);
   else
    s.push_back(c);
  }
 }
 while(!s.empty()) {
  ans.push_back(s.front());
  s.pop_front();
 }
 if(fz)
  reverse(ans.begin(),ans.end());
 cout<<ans;
 return 0;
}

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

typedef long long ll;
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define rep(i,n) for(int i=0;i<(n);i++)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
#define nl cout<<endl;
#define pu push
#define pb push_back
//str.substr(pos,number)
//str.insert(str.begin()+5,'3')
//set<int> myset
//myset.insert(num)
//myset.count(i)!=0
const int maxn = 2e5 + 5;
int main(){
    fio();
	int N;
	cin>>N;
	long long int ans=0;
	for(int i=1;i<=N;i++){
		if(i%3!=0 && i%5!=0)
			ans+=i;
	}
	cout<<ans<<endl;

}














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

int main (){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<" "<<(a+b)*2<<endl;
}


Measured memory_bytes: 3100
fun main(args: Array<String>) {
    val x = readLong()
    println((x / 500)  * 1000 + (x % 500) / 5 * 5)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

Measured memory_bytes: 33644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second

using namespace __gnu_pbds;
using namespace std;
const int mod = 1e9 + 7;
// const int mod=998244353;
//const int mod=1e9+9;
//const int INF=4e18+10;
const int INF = 4e18 + 10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) \
int n;      \
cin >> n;
#define readv(x, n)   \
vector<int> x(n); \
for (auto &i : x) \
    cin >> i;

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

template <typename T1, typename T2>
void set_min(T1 &a, T2 b)
{
    a = min(a, (T1)b);
}

int multiply(int a, int b, int in_mod) { return (a * b) % in_mod; }
int mult_identity(int a) { return 1; }


auto power(auto a, int b, int in_mod)
{
    auto prod = mult_identity(a);
    auto mult = a % in_mod;
    while (b != 0)
    {
        if (b % 2)
        {
            prod = multiply(prod, mult, in_mod);
        }
        mult = multiply(mult, mult, in_mod);
        b /= 2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod - 2, in_mod);
}


int S(int x)
{
    int sm = 0;
    while(x)
    {
        sm+=x%10;
        x/=10;
    }
    return sm;
}


int mex(vector<int>a)
{
    set<int>b;
    for(auto i:a)
        b.insert(i);

    a.clear();
    for(auto i:b)
        a.pb(i);
    sort(all(a));
    for(int i =0;i<a.size();i++)
        if(i!=a[i])
            return i;
    return a.size();
}
void solve()
{
    int x, y;
    cin>>x>>y;

    if(abs(x-y)<=1)
        cout<<"Brown"<<endl;
    else
        cout<<"Alice"<<endl;
}



signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cerr.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t = 1;
    // cin >> t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<":\n";
        //cout<<"Trip #"<<test<<": ";
        // cout<<endl;
        solve();
        // solveB();

        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 3652
from bisect import bisect_left, bisect_right


class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]


N, K, L = map(int, input().split())

uf1 = UnionFind(N)
uf2 = UnionFind(N)

for i in range(K):
    p, q = map(int, input().split())
    uf1.union(p-1, q-1)

for i in range(L):
    r, s = map(int, input().split())
    uf2.union(r-1, s-1)

uf_pair = sorted([(uf1.find(i), uf2.find(i)) for i in range(N)])

ans = []
for i in range(N):
    key = (uf1.find(i), uf2.find(i))
    ans.append(bisect_right(uf_pair, key) - bisect_left(uf_pair, key))

print(' '.join(map(str, ans)))


Measured memory_bytes: 153728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    string s;
    cin >> s;
    int a = s.length();
    if(s[a-1] == 's') cout << s + "es" << endl;
    else cout << s + "s" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <iterator>

using namespace std;

typedef long long ll;
#define mems(p) memset(p,0,sizeof(p))
#define mp make_pair

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int main(){
	int n; cin>>n;
	int arr[105],sum[105];
	mems(arr);
	mems(sum);
	for (int i = 1; i <= n; ++i)
	{
		cin>>arr[i];
		sum[i]=sum[i-1]+arr[i];
	}
	int minim=100000000;
	for (int i = 1; i < n; ++i)
	{
		minim=min(minim,abs(sum[i]-(sum[n]-sum[i])));
	}
	cout<<minim<<endl;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 105;

int n;
int a[N];

int sum (int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main() {

	FAST;

	cin >> n;
	cout << ((n % sum(n) == 0) ? "Yes\n" : "No\n");
	return 0; 
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.BitSet;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bf.readLine());
        StringBuilder sb = new StringBuilder();
        BitSet bitSet = new BitSet(33554432);
        HashSet<Integer> hashSet = new HashSet<>();
        final char[] key = new char[128];
        key['A'] = 0;
        key['C'] = 1;
        key['G'] = 2;
        key['T'] = 3;
        for (int i = 0; i < n; i++) {
            String sp = bf.readLine();
            if (sp.charAt(0) == 'i') {
                int hash = 1;
                for (int j = 7; j < sp.length(); j++) {
                    hash <<= 2;
                    hash+=key[sp.charAt(j)];
                }
                bitSet.set(hash);
            } else {
                int hash = 1;
                for (int j = 5; j < sp.length(); j++) {
                    hash <<= 2;
                    hash+=key[sp.charAt(j)];
                }
                sb.append(bitSet.get(hash) ? "yes\n" : "no\n");
            }
        }
        bf.close();
        System.out.print(sb.toString());
    }
}


Measured memory_bytes: 69240
n,x=map(lambda x: int(x), input().split())
a=list(map(lambda x: int(x), input().split()))
a.sort()
ans=0
for i in range(n):
    x-=a[i]
    if x<0:
        ans=i
        break
if x==0:
    ans=n
elif x>0:
    ans=n-1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
using namespace std;
#define MAX_N 100
const int INF=100100100;
typedef long long ll;
typedef pair<int,int> P;
char maze[MAX_N][MAX_N];
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int h,w;
int bsf(P s){
    queue<P> que;
    int d[MAX_N][MAX_N];
    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            d[i][j]=INF;
        }
    }
    que.push(s);
    d[s.first][s.second]=0;
    int max=0;
    while(que.size()){
        P p=que.front();que.pop();
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i],ny=p.second+dy[i];
        if(nx>=0 && nx<w && ny>=0 && ny<h && maze[nx][ny]!='#' && d[nx][ny]==INF){
            que.push(P(nx,ny));

            d[nx][ny]=d[p.first][p.second]+1;
            if(d[nx][ny]>max)max=d[nx][ny];
        }
        }

    }
    return max;
}

int main(){

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




int max=0;
int t=0;
for(int j=0;j<h;j++){
    for(int i=0;i<w;i++){
        if(maze[i][j]=='#')continue;
        t=bsf(P(i,j));
        if(t>max)max=t;
        
    }
}
cout<<max<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<string>
//#include<queue>
//#include<cmath>
//#include<algorithm>
#define debug1 cout<<"?"<<endl;
#define debug2 cout<<"?"<<i<<endl;
#define PII pair<ll,ll>
typedef long long ll;
const int maxn=3e4+9;
const double pi=acos(-1);
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const double ep=1e-7;
using namespace std;
int main()
{
	int h,n,i,j,a[maxn]={0},b[maxn]={0},dp[maxn];
	memset(dp,INF,sizeof dp);
	dp[0]=0;
	scanf("%d%d",&h,&n);
	for(i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]);
	for(i=1;i<=n;i++)
	{
		for(j=a[i];j<=20000;j++)
		dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
	}
	int ans=INF;
	for(i=h;i<=20000;i++)ans=min(ans,dp[i]);
	printf("%d\n",ans);
}

Measured memory_bytes: 768
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int r = in.nextInt();
            int g = in.nextInt();
            int b = in.nextInt();

            int res = r*100+g*10+b;
            if(res%4==0){
                out.println("YES");
            }
            else{
                out.println("NO");
            }
            
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 21460
<?php
// Your code here!
$input = explode(" ",trim(fgets(STDIN)));
$price = $input[0];
$money = $input[1];
$want = $input[2];

$count = 0;
while ($count < $want && $money >= $price) {
    $money = $money - $price;
    $count++;
}

echo $count;
?>


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
const int inf=0x7FFFFFFF;

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t n;
	cin>>n;
	int ans=inf,tmp;
	for(int64_t i=1;i*i<=n;++i){
		if(n%i==0){
			string a=to_string(i),b=to_string(n/i);
			tmp=max(a.size(),b.size());
			ans=min(ans,tmp);
		}
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
    }

    int ans = 111;
    for(int aa=101; aa>=0; aa--){
        int cnt = 0;
        for(int i=0; i<n; i++){
            if(aa != p[i]) cnt++;
        }
        if(cnt == n){
            if(abs(aa-x) <= abs(ans-x)){
                ans = aa;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define dupli(a)     unique(all(a)),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " is " << x << endl;
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define f first
#define s second


#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;



int main(){

    
    
    char x;
    cin>>x;
    if(x>=97) pt("a");
    else pt("A");


    

    

}


/*

// 

*/

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int k = sc.nextInt();
        int x = sc.nextInt();
        for(int i=x-k+1; i<x+k; i++){
            System.out.print(i + " ");
        }
        System.out.println("");
    }



    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

}



Measured memory_bytes: 22996
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n; cin >> n;
	string s; cin >> s;
	for (int i = 0; i < s.size(); ++i)
		cout << (char)((s[i] - 'A' + n) % 26 + 'A');
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    string s;
    cin>>s;
    int n=s.size();
    int memo=3;
    if(s[0]!='A'){
        memo--;
    }
    int k=0;
    int b;
    for(int i=2;i<n-1;i++){
        if(s[i]=='C'){
            k++;
            b=i;
        }
    }
    if(k!=1){
        memo--;
    }

    for(int i=1;i<n;i++){
        if(i==b){
            continue;
        }
        if(isupper(s[i])){
            memo--;
        }
    }

    if(memo==3){
        cout<<"AC"<<endl;
    }
    else{
        cout<<"WA"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n)
const int MAXN = 1000000;

int p[MAXN];

int main()
{
    p[0] = p[1] = 1;
    REP(MAXN)if(!p[i])for(int j=i*2;j<MAXN;j+=i)p[j]=1;

    int n, ans;
    while(cin >> n)
    {
        ans = 0;
        REP(n + 1) ans += !p[i];
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

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

typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x; cin>>x;
    int cnt=0;
    fo(i,1,x){
        int y,z; cin>>y>>z;
        if(y==z){
            cnt++;
            if(cnt==3){
                cout<<"Yes";
                return 0;
            }
        }else{
            cnt=0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int x, y, z, k;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> x >> y >> z >> k;
	vector<long long> a(x), b(y), c(z);

	for (int i = 0; i < x; ++i)
		cin >> a[i];

	for (int i = 0; i < y; ++i)
		cin >> b[i];

	for (int i = 0; i < z; ++i)
		cin >> c[i];

	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	sort(c.rbegin(), c.rend());

	// vector<int> idx1(x);
	vector<vector<int> > idx2(x, vector<int>(y));

	priority_queue<pair<long long, int> > pq;
	vector<priority_queue<pair<long long, int> > > ps(x);

	for (int i = 0; i < x; ++i) {
		pq.push(make_pair(a[i] + b[0] + c[0], i));
		for (int j = 0; j < y; ++j)
			ps[i].push(make_pair(b[j] + c[0], j));
	}

	long long ans;

	for (int tt = 0; tt < k; ++tt) {

		ans = pq.top().first;
		cout << ans << endl;
		if (tt == k-1)
			break;

		int i = pq.top().second;
		pq.pop();

		int j = ps[i].top().second;
		ps[i].pop();

		++idx2[i][j];
		int k = idx2[i][j];
		if (k < z)
			ps[i].push(make_pair(b[j] + c[k], j));
		
		if (!ps[i].empty())
			pq.push(make_pair(a[i] + ps[i].top().first, i));
	}

	return 0;
}

Measured memory_bytes: 20352
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 1010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

struct Edge {
    int u, v, c;
    Edge(int u = 0, int v = 0, int c = 0) : u(u), v(v), c(c) {}
};

vector<Edge> res;
vector<int> hs;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int L;
    cin >> L;
    int bits = 32 - __builtin_clz(L);
    int bot = 1;
    int now = 0;
    int g = 1;
    FORE(i,bits-2,0) {
        bot++;
        int u = bot - 1, v = bot;
        g = g * 2;
        res.emplace_back(Edge(u, v, 0));
        res.emplace_back(Edge(u, v, 1));
        hs.emplace_back(2);
        hs.emplace_back(1);
        if (L & (1<<i)) {
            res.emplace_back(Edge(1, v, g));
            hs.emplace_back(1);
            g++;
        }
    }
    g = 1;
    FORE(i,SZ(res)-1,0) {
        res[i].c = res[i].c * g;
        g = g * hs[i];
    }
    cout << bot << " " << SZ(res) << "\n";
    FOR(i,0,SZ(res)-1) cout << res[i].u << " " << res[i].v << " " << res[i].c << "\n";
    return 0;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    let answer = 0;
    
    if(N === 1 && M === 1) {
        answer = 1;
    } else if(N === 1) {
        answer = M - 2;
    } else if(M === 1) {
        answer = N - 2;
    } else {
        answer = (N - 2) * (M - 2);
    }
    
    // 桁溢れ対策  original (id: macco さん)
    if (answer > Number.MAX_SAFE_INTEGER) {

    const multi_biggerInt = (a, b) => {
      const num1 = String(a).split('').map(n => Number(n)).reverse();
      const num2 = String(b).split('').map(n => Number(n)).reverse();

      let ans = [...Array(num1.length + num2.length)].fill(0);

      const checkCarry = () => {
        for (let i = 0; i < ans.length; i++) {
          if (ans[i] >= 10) {
            const upper = Number(String(ans[i]).split('')[0]);
            const lower = Number(String(ans[i]).split('')[1]);

            ans[i - 1] += upper;
            ans[i] = lower;
          }
        }
      }

      for (let i = 0; i < num1.length; i++) {
        for (let j = 0; j < num2.length; j++) {
          const pro   = num1[i] * num2[j];
          const digit = ans.length - (i + j) - 1;

          ans[digit] += pro;
          checkCarry();
        }
      }

      for (let i = 0; i < ans.length; i++) {
        if (ans[i] !== 0) {
          ans = ans.slice(i);
          break;
        }
      }

      return ans.join('');
      }

      answer = multi_biggerInt(Math.abs(N - 2), Math.abs(M - 2));
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

ll fastPow(ll a, ll b) {
	ll ret = 1;
	while(b) {
		if(b & 1) ret = ret * a % MOD;
		b >>= 1;
		a = a * a % MOD;
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int n;
	cin >> n;
	cout << (ll(MOD) * 5 + fastPow(10, n) - 2 * fastPow(9, n) + fastPow(8, n)) % MOD << '\n';
}



Measured memory_bytes: 3696
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;
typedef long long llong;
int main() {
	string s; cin >> s;
	stack<char>v;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'S')v.push(s[i]);
		else {
			if (v.empty()||v.top()=='T')v.push(s[i]);
			else v.pop();
		}
	}
	cout << v.size() << endl;
	//string s, m = "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss";
	//cin >> s;
	//if (s.substr(0, s.length() / 2) == m.substr(0, s.length())) {
	//	cout << 0 << endl;
	//	return 0;
	//}
	//bool f = true, f8 = false, f6 = false, f4 = false;
	//while (f&&s.size()) {
	//	f = false;
	//	int a = s.length() - 1;
	//	if (a + 1 > 7)f8 = true;
	//	if (a + 1 > 5)f6 = true;
	//	if (a + 1 > 3)f4 = true;
	//	for (int i = 0; i < a; i++) {
	//		if (f8 && (s[i] == 'S'&&s[(i + 1)] == 'S'&&s[i + 2] == 'S'&&s[i + 3] == 'S'&&s[i + 4] == 'T'&&s[i + 5] == 'T'&&s[i + 6] == 'T'&&s[i + 7] == 'T')) {
	//			s.erase(i, 8);
	//			f = true;
	//			a -= 8;
	//		}
	//		if (f6 && (
	//			(s[i] == 'S'&&s[(i + 1)] == 'S'&&s[i + 2] == 'S'&&s[i + 3] == 'T'&&s[i + 4] == 'T'&&s[i + 5] == 'T') ||
	//			(s[i] == 'S'&&s[(i + 1)] == 'T'&&s[i + 2] == 'S'&&s[i + 3] == 'T'&&s[i + 4] == 'S'&&s[i + 5] == 'T')
	//			)) {
	//			s.erase(i, 6);
	//			f = true;
	//			a -= 6;
	//		}
	//		if (f4 && ((s[i] == 'S'&&s[(i + 1)] == 'S'&&s[i + 2] == 'T'&&s[i + 3] == 'T') || (s[i] == 'S'&&s[(i + 1)] == 'T'&&s[i + 2] == 'S'&&s[i + 3] == 'T'))) {
	//			s.erase(i, 4);
	//			f = true;
	//			a -= 4;
	//		}
	//		if (s[i] == 'S'&&s[(i + 1)] == 'T') {
	//			s.erase(i, 2);
	//			f = true;
	//			a -= 2;
	//		}
	//	}
	//}

	//cout << s.length() << endl;
	return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;

int g[15][15];

int main() {
    int n;
    cin >> n;
    rep(i,n) rep(j,n) g[i][j] = -1;
    rep(i,n) {
        int a;
        cin >> a;
        rep(j,a) {
            int x, y;
            cin >> x >> y;
            --x;
            g[i][x] = y;
        }
    }
    int ans = 0;
    rep(i,1<<n) {
        vector<int> d(n);
        rep(j,n) if((i>>j) & 1) {
            d[j] = 1;
        }
        bool ok = true;
        rep(j,n) {
            if(d[j]) {
                rep(k,n) {
                    if(g[j][k] == -1) continue;
                    if(g[j][k] != d[k]) ok = false;
                }
            }
        }
        if(ok) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int k;
    cin>>k;
    ll ans=0;
    rep(i,k){
        rep(j,k){
            rep(l,k){
                ans+=__gcd(__gcd(i+1,j+1),l+1);
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

long long int is_gcd(long long int a, long long int b);

int main(void){
  long long int a,b,c,d;
  scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
  long long int lcm;
  long long int left, right;
  long long int c_num, d_num, cd_num;
  
  lcm = c*d/is_gcd(c,d);


  left = a/c; right = b/c;
  c_num = right - left + 1;
  if(a%c != 0)
    c_num--;    
  //printf("%ldで割り切れるのは%ld個\n",c,c_num);
  
  left = a/d; right = b/d;
  d_num = right - left + 1;
  if(a%d != 0)
    d_num--;
  //printf("%ldで割り切れるのは%ld個\n",d,d_num);
  
  left = a/lcm; right = b/lcm;
  cd_num = right - left + 1;
  if(a%lcm != 0)
    cd_num--;
  //printf("%ldで割り切れるのは%ld個\n",lcm,cd_num);

  long long int num = b - a + 1;
  
  printf("%ld\n",num - (c_num + d_num - cd_num) );

  return 0;
}


long long int is_gcd(long long int x, long long int y){
  long long int tmp,z;
  if(x<y){
    tmp = x;
    x = y;
    y = tmp;
  }
  z = x % y;
  while(z != 0){
    x = y;
    y = z;
    z = x % y;
  }
  return y;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string player1, player2;
	int i, n;
	int point1 = 0, point2 = 0;

	cin >> n;

	for (i = 0; i < n; i++){
		cin >> player1 >> player2;
		if (player1 > player2)
			point1 += 3;
		else if (player1 < player2)
			point2 += 3;
		else{
			point1 += 1;
			point2 += 1;
		}
	}

	cout << point1 << " " << point2 << endl;
	return 0;
}

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

#define show(x) cout << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

int main()
{
    int N;
    cin >> N;
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    const ll DIFF = B - A;
    ll left = -D * (N - 1);
    for (int i = 0; i < N; i++) {
        const ll right = left + (N - 1) * (D - C);
        if (left <= DIFF and DIFF <= right) {
            cout << "YES" << endl;
            return 0;
        }
        left += (C + D);
    }
    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
Std = [tuple(map(int, input().split())) for _ in range(N)]
Chp = [tuple(map(int, input().split())) for _ in range(M)]
INF = 10e9
Arrv = []
Mdist = lambda x,y,u,v:abs(x-u)+abs(y-v)
for s in Std:
    close = INF
    for i in range(M):
        dist = Mdist(*s,*Chp[i])
        if dist < close:
            close = dist
            arrv = i+1
    Arrv.append(arrv)
for ar in Arrv:
    print(ar)    

Measured memory_bytes: 9156
import sys
input = sys.stdin.readline


def main():
    S = input().rstrip()
    count = 0
    ans = 0
    for s in S:
        if s == "S":
            count += 1
        if s == "T":
            count -= 1
        if count < 0:
            ans += 1
            count = 0

    print(ans+count)


if __name__ == "__main__":
    main()


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


signed main(){
    int a[4];
    cin >> a[0] >> a[1] >> a[2] >> a[3] ;
    sort(a,a+4);
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)cout << "YES";
    else cout <<"NO";

 



    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		scanner.close();
		if (x == 2) {
			System.out.println(2);
			return;
		}
		if (x % 2 == 0)
			x++;
		boolean isPrime;
		while (true) {
			isPrime = true;
			for (int i = 3; i * i <= x; i += 2) {
				if (x % i == 0) {
					isPrime = false;
					break;
				}
			}
			if (isPrime) {
				System.out.println(x);
				return;
			}
			x += 2;
		}
	}

}


Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int k =sc.nextInt();
		int a[]= new int[n];
		int kazu[]= new int[n];
		for(int i=0;i<n;i++) {
			kazu[i]=0;
		}

		for(int i=0;i<n;i++) {
			a[i] =sc.nextInt();
			kazu[a[i]-1]++;
		}

		mergeSort(kazu,0,n);
		int shiguma =0;

		for(int i=0;i<n-k;i++) {
			shiguma =shiguma+ kazu[i];
		}


		System.out.print(shiguma);



	}
	public static void mergeSort(int[] kazu, int start, int end) {
		int middle = (start+end)/2;
		if(end-start>1) {
			mergeSort(kazu, start,middle);
			mergeSort(kazu, middle,end);
			int[] temp = new int[end-start];
			for(int i=start;i<end;i++) {
				temp[i-start]=kazu[i];
			}
			int a = start;
			int b = middle;
			for(int i=start;i<end;i++) {
				if(a<middle&&(b>=end||temp[a-start]<temp[b-start]) ) {
					kazu[i]=temp[a-start];
					a=a+1;
				}
				else{
					kazu[i]=temp[b-start];
					b=b+1;
				}
			}
		}
	}

}

Measured memory_bytes: 67236
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<tuple<int, int ,int>> c(M);
    for (int m = 0; m < M; m++) {
        int p, y;
        cin >> p >> y;
        c[m] = make_tuple(m, p, y);
    }
    sort(c.begin(), c.end(), [](const auto& a, const auto& b) { return get<2>(a) < get<2>(b); });

    vector<int> counter(N);
    vector<string> res(M);
    for (auto a: c) {
        int p = get<1>(a);
        counter[p - 1] += 1;
        ostringstream s;
        s << setfill('0') << setw(6) << p;
        s << setfill('0') << setw(6) << counter[p - 1];
        res[get<0>(a)] = s.str();
    }

    for (auto s: res) cout << s << endl;

    return 0;
}


Measured memory_bytes: 10676
#include <stdio.h>
#include <math.h>
int main(int argc, char *argv[])
{
	int n,num,count=0,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&num);
		for(j=2;j<=sqrt(num);j++)
		if(num%j==0)
		break;		
		if(j>sqrt(num))
		count++;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main(){
    int n, m, a, total = 0;
    cin >> n >> m;
    for(int i=0; i<m; i++){
        cin >> a;
        total += a;
    }
    cout << max(n-total, -1);
    return 0;
}

Measured memory_bytes: 3536
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
typedef long long LL;
const int maxn=110;
int ans[maxn*2];
int main()
{
    LL n;
    cin>>n;
    n++;
    int tot=0;
    int w=0;
    while((n>>w)>1)w++;
    int cnt=0;
    while(w>0)
    {
        ans[++tot]=++cnt;
        w--;
        if((n>>w)&1)
        {
            ++tot;
            for(int i=tot;i>1;i--) ans[i]=ans[i-1];
            ans[1]=++cnt;
        }
    }
    printf("%d\n",cnt*2);
    for(int i=1;i<=cnt;i++) printf("%d ",i);
    for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);
    return 0;
}


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  bool win=false;
  for(int i=0;;i++){
    c-=b;
    if(c<=0){
      win=true;break;
    }
    a-=d;
    if(a<=0){
      break;
    }
  }
  if(win){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3604
import math
d, g = map(int, input().split())
p = []
c = []
for _ in range(d):
    tp, tc = map(int, input().split())
    p.append(tp)
    c.append(tc)

ans = 1000
for i in range(2**d):
    score = 0
    num = 0
    r = -1
    for j in range(d):
        if i>>j & 1:
            score += 100 * (j+1) * p[j] + c[j]
            num += p[j]
        else:
            r = j
    if score < g:
        tmp = math.ceil((g-score) / (100*(r+1)))
        if tmp >= p[r]:
            continue
        num += tmp
    ans = min(ans, num)
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main() {
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k) cout<<k<<endl;
    else if(a+b>=k) cout<<a<<endl;
    else cout<<a+(k-(a+b))*(-1)<<endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n;
ll a;
ll b[300005];
bool k=false;
int main(void){
    cin>>n;
    for(int i=0;i<300005;i++){
        b[i]=-1;
    }
    for(int i=1;i<=n;i++){
        cin>>a;
        if(i%2==0){
            if(n%2==0){
                b[150000-i/2]=a;
            }else{
                b[150000+i/2]=a;
            }
        }else{
            if(n%2==0){
                b[150000+i/2]=a;
            }else{
                b[150000-i/2]=a;
            }
        }
    }
    for(int i=0;i<300005;i++){
        if(b[i]>=0){
            if(k) cout<<" ";
            cout<<b[i];
            k=true;
        }
    }
    cout<<endl;
    
}


Measured memory_bytes: 5932
#include "bits/stdc++.h" 
using namespace std; 


int main(){
	string s;
	cin>>s;
int ind =-1,ans=1;
for(int i=0;i<3;i++) {
	if(s[i]=='R'){
		if(ind==-1) ind=i;
		else if(ind==(i-1)) ans++, ind=i;
	}
}
	cout<<(ind==-1?0:ans);
	
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<vector<int>> V(n, vector<int>(3,0));
    rep(i,n){
        cin >> V[i][0] >> V[i][1] >> V[i][2];
    }
    vector<vector<int>> dp(n, vector<int>(3,0));
    dp[0][0]=V[0][0],dp[0][1]=V[0][1],dp[0][2]=V[0][2];
    for(int date=1; date <=n-1; date++){
        dp[date][0] = max(dp[date-1][1],dp[date-1][2])+V[date][0];
        dp[date][1] = max(dp[date-1][0],dp[date-1][2])+V[date][1];
        dp[date][2] = max(dp[date-1][0],dp[date-1][1])+V[date][2];
    }
    // rep(i,n){
    //     rep(j,3) cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
    return 0;
}

Measured memory_bytes: 11152
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    while (true) {
        int n, a, b;
        scan(n,a,b);
        if (!n) return;
        auto p = iota(n).map!(i => readln.chomp.to!int).array;
        solve(n,a,b,p);
    }
}

void solve(int n, int a, int b, int[] p) {
    int difmax, ans;

    foreach (i ; a .. b + 1) {
        if (difmax <= p[i-1] - p[i]) {
            difmax = p[i-1] - p[i];
            ans = i;
        }
    }

    writeln(ans);
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 2844