akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.141592653589793238462643383279L;
double eps=1e-10;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll gya[1000010];
ll kai[1000010];
void nckinit(ll n,ll md){
  kai[0]=1;
  kai[1]=1;
  for(int i=2;i<=n;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=md;
  }
  gya[n]=gyaku(kai[n],md);
  for(int i=n-1;i>=1;i--){
    gya[i]=gya[i+1]*(i+1);
    gya[i]%=md;
  }
  gya[0]=1;
}
ll nck(ll n,ll k,ll md){
  if(k<0)return 0;
  if(k==0||n==k)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=md;
  ret*=gya[k];
  ret%=md;
  return ret;
}
ll npk(ll n,ll k,ll md){
  if(k<0)return 0;
  if(k==0)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=md;
  return ret;
}
int popcount(ll n){
    int ret=0;
    while(n>0){
        ret+=n&1;
        n/=2;
    }
    return ret;
}
void swa(int &n,int i,int j){
    if((n&(1<<i))&&!(n&(1<<j)))n+=-(1<<i)+(1<<j);
    else if((n&(1<<j))&&!(n&(1<<i)))n+=-(1<<j)+(1<<i);
}
vector<int> dfs(int n,int a,int b){
    //cout<<n<<" "<<a<<" "<<b<<endl;
    if(n==1)return {a,b};
    int d;
    for(int i=0;;i++){
        int y=1<<i;
        int aa=a/y,bb=b/y;
        if(aa%2!=bb%2){
            d=i;
            break;
        }
    }
    swa(a,n-1,d);
    swa(b,n-1,d);
    //cout<<a<<" "<<b<<endl;
    int na=a%(1<<(n-1));
    int nb=b%(1<<(n-1));
    //cout<<na<<" "<<nb<<endl;
    vector<int> v=dfs(n-1,na,na^1);
    vector<int> w=dfs(n-1,na^1,nb);
    int u=a/(1<<(n-1));
    if(u%2)rep(i,0,v.size())v[i]^=1<<(n-1);
    else rep(i,0,w.size())w[i]^=1<<(n-1);
    rep(i,0,w.size())v.push_back(w[i]);
    rep(i,0,v.size())swa(v[i],n-1,d);
    return v;
    
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int a,b;cin>>a>>b;
    int c=a^b;
    if(popcount(c)%2==0){
        cout<<"NO"<<endl;
        return 0;
        
    }
    cout<<"YES"<<endl;
    vector<int> ans=dfs(n,a,b);
    rep(i,0,ans.size())cout<<ans[i]<<" ";
    cout<<endl;
}



Measured memory_bytes: 1648
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

int answer[12],w;

char func(int x){
	if(x == 1)return '+';
	else if(x == -1)return '-';
	else return '0';
}

void calc(int array[12],int index){

	if(index == 12){
		int sum = 0;
		for(int i=0; i < 12; i++){
			if(array[i] == 1)sum += pow(3,i);
			else if(array[i] == -1){
				sum -= pow(3,i);
			}
		}
		if(sum == w){
			for(int i=0; i < 12; i++)answer[i] = array[i];
		}
		return;
	}

	int new_array[3][12];
	for(int i = 0; i < 3; i++){
		for(int k=0; k < 12; k++)new_array[i][k] = array[k];
	}

	new_array[0][index] = 0;
	calc(new_array[0],index+1);
	new_array[1][index] = 1;
	calc(new_array[1],index+1);
	new_array[2][index] = -1;
	calc(new_array[2],index+1);

}

int main(){

	int array[12] = {0};

	scanf("%d",&w);

	calc(array,0);

	for(int i = 11; i >= 0; i--){
		if(answer[i] != 0){
			for(int k=i; k >= 0; k--){
				printf("%c",func(answer[k]));
			}
			printf("\n");
			break;
		}
	}

    return 0;
}

Measured memory_bytes: 2872
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    int dp[n+1];
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

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

int main() {
  int n;
  while(cin >> n) {
    int a[n];
    REP(i,n) cin >> a[i];
    ll g = a[0];
    REP(i,n) g=gcd(g,a[i]);
    set<int> S;
    for (int i=1; i*i<=g; ++i) {
      if (g%i==0) {
        S.insert(i);
        S.insert(g/i);
      }
    }
    FOR(it, S) cout << *it << endl;
  }
}

Measured memory_bytes: 1196
import math

N=int(input())
townX=[]
townY=[]
for j in range(N):
  x,y=map(int,input().split())
  townX.append(x)
  townY.append(y)

#print(townX,townY)

dist =0
if N==2:
  print(math.sqrt( (townX[0]-townX[1])**2 +(townY[0]-townY[1])**2 ))
else:
 for i in range(N-1):
   for j in range(i+1,N):
    dist += math.sqrt( (townX[i]-townX[j])**2 +(townY[i]-townY[j])**2 )
      
 dist=((N*(N-1)/2) -(N-2)*(N-1)/2)*dist    
 print(2*dist/(N*(N-1)))
  
#print(math.factorial(6))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cstring>


using namespace std;

struct height{
    int h;
    int next;
    bool operator<(const height &t)const {
        return h > t.h;
    }
};

typedef vector<height> v;

int main()
{
    while (true) {
        int n, m, a;
        scanf("%d %d %d ", &n, &m, &a);
        if (n == 0 && m == 0 && a == 0) break;
        a--;
        v yoko[100];
        
        for (int i = 0; i < m; i++) {
            int h, p, q;
            scanf("%d %d %d ", &h, &p, &q);
            p--, q--;
            height n;
            n.h = h, n.next = q;
            yoko[p].push_back(n);
            n.next = p;
            yoko[q].push_back(n);
        }
        for (int i = 0; i < n; i++) {
            sort(yoko[i].begin(), yoko[i].end());
        }
        int n_h = 10000;
        for (int i = a;;) {
            bool flag = false;
            v::iterator it;
            for (it = yoko[i].begin(); it != yoko[i].end(); it++) {
                if (n_h >= (*it).h) {
					//it--;
                    flag = true;
                    break;
                }
            }
            if (!flag) {
                cout << i + 1 << endl;
                break;
            } else {
                i = (*it).next;
                n_h = (*it).h - 1;
            }
			//cout << (*it).h << " " << (*it).next << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#define MAX 105
#define BLACK 0
#define WHITE 1
#define GRAY -1

void dfs();
void visit(int);

int a[MAX][MAX],n,time;
int d[MAX],f[MAX],color[MAX];

int main(){
  int i,j,m,k,l;
  

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      a[i][j]=0;
    }
  }
  
  for(i=1;i<=n;i++){
    scanf("%d%d",&m,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&l);
      a[m][l]=1;
    }
  }

  dfs();

  for(i=1;i<=n;i++){
    printf("%d %d %d",i,d[i],f[i]);
    printf("\n");
  }
  


  return 0;
}

void dfs(){
  int u;
  for(u=1;u<=n;u++){
    color[u]=WHITE;
  }
  time=0;
  for(u=1;u<=n;u++){
    if(color[u]==WHITE){
      visit(u);
    }
  }
}

void visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++time;
  for(v=1;v<=n;v++){
    if(a[u][v]==1){
      if(color[v]==WHITE){
	visit(v);
      }
    }
  }
  color[u]=BLACK;
  f[u]=++time;
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int flag=0;
	for(int i=1;i<=n;i++){
		if(n%i==0){
			if(i<=9&&n/i<=9)flag=1;
		}
	}
	if(flag==1)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
while True:
    a,b = map(int,input().split())
    if(a==0 and b==0):
        break;
    for i in range(a):
        for j in range(b):
            type='#'
            if(i%2 == 0):
                if(j%2 == 0):
                   print('#',end='')
                else:
                    print('.',end='')
            elif(i%2 == 1):
                if(j%2 == 0):
                   print('.',end='')
                else:
                    print('#',end='')
        print()
    print()



Measured memory_bytes: 7000
n = int(input())
li = list(map(int, input().split(' ')))

cnt = 0
num = 1
for i in range(len(li)):
    if li[i] != num:
        cnt += 1
    else:
        num += 1

if len(li) != cnt:
    print(cnt)
else:
    print(int(-1))


Measured memory_bytes: 74588
#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
using namespace std;

int n;
string s;

int main()
{
    cin >> s;
    if(s.length() == 6 && s[2] == s[3] && s[4] == s[5]) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <class num> struct ST {
private:
	int n;
	vector<num> node;
public:
	ST(vector<num> v) {
		int sz = v.size();
		n = 1; while (n < sz)n *= 2;
		node.resize(n * 2 - 1, INF);

		for (int i = 0; i < sz; i++)node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--)node[i] = min(node[2 * i + 1], node[2 * i + 2]);
	}
	void update(int x, num val) {
		x += (n - 1);
		node[x] = val;
		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = min(node[2 * x + 1], node[2 * x + 2]);
		}
	}
	num get(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = n;
		if (r <= a || b <= l)return INF;
		if (a <= l && r <= b)return node[k];
		return min(
			get(a, b, 2 * k + 1, l, (l + r) / 2),
			get(a, b, 2 * k + 2, (l + r) / 2, r)
		);
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	ST<ll> st(vector<ll>(n, INF));
	for (int i = 0; i < q; i++) {
		ll c, x, y;
		cin >> c >> x >> y;
		if (c == 0) {
			st.update(x, y);
		}
		else {
			cout << st.get(x, y+1) << endl;
		}
	}
}


Measured memory_bytes: 5672
#coding:utf-8
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
ans = 0
for it in c.items():
    if it[0] <= it[1]:
        ans += (it[1]-it[0])
    else:
        ans += it[1]
print (ans)


Measured memory_bytes: 18672
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  long long a;
  string b;
  cin>>a>>b;
  long long tb = (long long)(b[0] - '0') * 100 + (long long)(b[2] - '0') * 10 + (long long)(b[3] - '0');
  long long ans = (a * tb) / 100;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3752
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

pt = [abs(A - (T - h * 0.006)) for h in H]

# np.argsortなしで，最大値，最小値のindexを取得
ans = min(enumerate(pt), key=lambda x: x[1])[0]
print(ans + 1)

# 最大値が複数あるとき
# [i for i, v in enumerate(li) if v == max(l)]
# 計算重そう



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

ll L[52] = {};
ll P[52] = {};
void make() {
	// layers
	L[0] = 1;
	FOR(i, 1, 51) {
		L[i] = 2*L[i-1] + 3; 
	}

	// p
	P[0] = 1;
	FOR(i, 1, 51) {
		P[i] = 2*P[i-1] + 1;
	}
}

ll layers_p_x(ll i, ll x) {
	if (i==0) {
		if (x==1) {
			return 1;
		} else {
			return 0;
		} 
	}
	if (x <= L[i-1] + 1) {
		return layers_p_x(i-1, x-1);
	}
	if (L[i] == x) {
		return P[i];
	}
	//return layers_p(i) - layers_p_x(i-1, layers(i) - x - 1);
	return 1 + P[i-1] + layers_p_x(i-1, x-2-L[i-1]);
}
int main(){
	ll n,x;
	cin >> n>>x;
	make();
	cout << layers_p_x(n,x) << endl;
	return 0;
}




Measured memory_bytes: 256
h,w=map(lambda x: int(x), input().split())
s=[]
s.append('.'*(w+2))
for i in range(h):
    s.append('.'+input()+'.')
s.append('.'*(w+2))

ans='Yes'
for i in range(1, h+2):
    for j in range(1, w+2):
        if s[i][j]=='#' and s[i-1][j]=="." and s[i+1][j]=='.' and s[i][j-1]=='.' and s[i][j+1]=='.':
            ans='No'
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
const ll INF = 1<<30;

unsigned long long gcd(unsigned long long a, unsigned long long b) {
  if(a < b) return gcd(b, a);
  unsigned long long r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    ll N; cin >> N;
    vector<unsigned long long> T(N+1);
    rep(i,N) cin >> T[i];
    unsigned long long x = T[0];
    rep(i,N-1){
        x = ( x / gcd(x, T[i+1] ) * T[i+1]);
    }
    cout << x << endl;
}

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

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

  vector<int> ans(n + 1);
  for (int x = 1; x <= 100; x++)
    for (int y = 1; y <= 100; y++)
      for (int z = 1; z <= 100; z++) {
        int v = x * x + y * y + z * z + x * y + y * z + z * x;
        if (v <= n) ans[v]++;
      }

  for (int i = 1; i <= n; i++)
    printf("%d\n", ans[i]);

  return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

const int mod = 1000000007;

struct mint{
  ll x;
  mint(ll x = 0):x((x % mod + mod) % mod){};
  mint pow(ll y) const {
    mint res(1);
    mint a(x);
    while(y>0){
      if(y&1) res *= a;
      a *= a;
      y >>= 1;
    }
    return res;
  }
  mint inv() const{ return pow(mod-2); }
  mint& operator+= (const mint a) noexcept {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-= (const mint a) noexcept {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*= (const mint a) noexcept {
    (x *= a.x) %= mod;
    return *this;
  }
  mint& operator/= (const mint a) noexcept {
    return (*this) *= a.inv();
  }
  mint operator+ (const mint a) const noexcept {
    mint res(*this);
    return res += a;
  }
  mint operator- (const mint a) const noexcept {
    mint res(*this);
    return res -= a;
  }
  mint operator* (const mint a) const noexcept {
    mint res(*this);
    return res *= a;
  }
  mint operator/ (const mint a) const noexcept{
    mint res(*this);
    return res /= a;
  }
};

ostream& operator<<(ostream& stream, const mint& n){
  stream << n.x;
  return stream;
};

struct comb{
  vector<mint> fact, ifact;
  comb(int n): fact(n+1), ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k) const noexcept{
    if(k < 0 || n < k) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
  }
};

int main(void){
  ll n, k;
  cin >> n >> k;
  mint ans = 0;
  FORe(i, k, n+1){
    ll mn = i*(i-1)/2;
    ll mx = i*(n + (n-i+1))/2;
    ans += mx-mn+1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
    int a,b,c,n;
    scanf("%d %d %d",&a,&b,&c);
     if(a<=b&&c<=b)
        n=a+c;
     if(a<=c&&b<=c)
        n=a+b;
     if(c<=a&&b<=a)
        n=b+c;
     printf("%d\n",n);
     return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a; cin >> a;
  int ans = a + a*a + a*a*a;
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
using namespace std;


int main () {
    int N, a = 0, b = 0;

    cin >> N;

    vector<int> data(N);

    for(int i = 0; i < N; i++) cin >> data.at(i);

    sort(data.begin(), data.end(), greater<int>());

    for(int i = 0; i < N; i++){
        (i % 2 == 0) ? a += data.at(i) : b += data.at(i);
    }
    cout << a-b << endl;
}

Measured memory_bytes: 256
s=int(input())
a=[s]
i=0
while True:
    if a[i]%2==0:
        temp=a[i]//2
        if temp in a:
            ans=i+2
            break
        a.append(temp)
    else:
        temp=3*a[i]+1
        if temp in a:
            ans=i+2
            break
        a.append(temp)
    i+=1

print(ans)

Measured memory_bytes: 9132
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll x;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>x;
	for(ll i=-2000; i<=2000; i++){
		for(ll j=-2000; j<=2000; j++)
			if(pow(i,5)-pow(j,5)==x) {
				cout<<i<<" "<<j;
				return 0;
			}
	}
	return 0;
}

Measured memory_bytes: 4260
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>


int main(){
  long N;
  std::cin >> N;
  long L[100];
  for(long i=0; i<N; i++){
    std::cin >> L[i];
  }
  long count=0;
  for(long i=0; i<N; i++){
    for(long j=i+1; j<N; j++){
      for(long k=j+1; k<N; k++){
        if(L[i]<L[j]+L[k] &&L[j]<L[i]+L[k] && L[k]<L[i]+L[j] && L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i]){
          count++;
        }
      }
    }
  }  
  std::cout << count << std::endl;
  return 0;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x ,int y){return (x%mod + y%mod)%mod;}
inline int submod(int x ,int y){return (x%mod - y%mod + mod)%mod;}
inline int mulmod(int x ,int y){return (x%mod *1LL* y%mod)%mod;}
inline int nextSubMask(int i , int mask) {return (i-1)&mask;} /// returns next smallest submask

void we_r_done(){cout<<"NO"; exit(0);}

void debug(bool ok , string mssg)
{
    if(ok)return;
    cout<<mssg;
    exit(0);
}


int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    FastIO;

    int n,m;
    cin>>n>>m;
    vector<pii>v;



    for(int i=0; i<n; i++){
        int a,b;
        cin>>a>>b;

        v.pb({a,b});
    }

    sort(atoz(v));


    lli ans = 0;
    priority_queue<int>pq;
    int now = 0;

    for(int i=1; i<=m+1; i++){

        for( ; now<n; now++){
            if(v[now].fi < i) pq.push(v[now].se);
            else break;
        }
        if(pq.size()){
                ans += pq.top();
            pq.pop();
        }
    }
    cout<<ans;

    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?



Measured memory_bytes: 1908
use std::io;
use std::collections::VecDeque;


fn main() {
    let n = read_one::<usize>();
    let mut t = vec![Vec::new(); n];
    for _ in 1..n {
        let (a, b) = {
            let i = read::<usize>();
            (i[0] - 1, i[1] - 1)
        };
        t[a].push(b);
        t[b].push(a);
    }
    let fen = bfs(0, &t);
    let snu = bfs(n - 1, &t);

    let mut cnt = 0;
    for i in 0..n {
        if fen[i] <= snu[i] { cnt += 1; }
    }
    if cnt > n - cnt { println!("Fennec"); }
    else { println!("Snuke"); }
}

fn bfs(s: usize, g: &Vec<Vec<usize>>) -> Vec<usize> {
    let mut que = VecDeque::new();
    let mut dist = vec![std::usize::MAX; g.len()];
    dist[s] = 0;
    que.push_back(s);
    while let Some(v) = que.pop_front() {
        for &u in &g[v] {
            if dist[u] <= dist[v] { continue; }
            dist[u] = dist[v] + 1;
            que.push_back(u);
        }
    }
    dist
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

using namespace std;

#define     watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define     all(a) (a).begin(), (a).end()
#define     fi first
#define     se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e6;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif

    long double a;
    long double b;
    cin >> a >> b;
    unsigned long long result = floor(a * b);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;


void solve(long long N){
    double res;
    res = 1.0 - (double)(N/2)/(double)N;
    cout << setprecision(10) << res << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz size()
#define pb push_back
#define bg begin()
#define ed end()
#define fi first()
#define se second()
using namespace std;
using ll = long long;
using vint = vector<int>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template <typename T>
T sq(T x) {
  return x * x;
}
ll mod = 1e9 + 7;
ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a % b);
  }
}
// cでもc++でも
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

signed main() {
  ll n;
  cin >> n;
  vector<ll> t(n);
  ll ans = 0;
  rep(i, n) {
    cin >> t.at(i);
    if (i == 0) {
      ans = t.at(0);
    } else {
      ans = std::lcm(ans, t.at(i));
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
double a[1005];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lf",&a[i]);
    }
	while(n>1){
		sort(a,a+n);
		double b;
		b=(a[0]+a[1])/2;
		a[0]=b;
		for(int i=1;i<n-1;i++){
			a[i]=a[i+1];
		}
		n--;
	}
	printf("%lf\n",a[0]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define INF 3000000000000001 // 3e15
#define ll_max 9000000000000000000
#define PI 3.14159265358979323846L
#define fill(a, n, x) for(int i = 0; i < n; i++) a[i] = x;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
ll mod = 1000000007;
const ll N = 1000001;
const ll M = 1;

struct point
{
    ll x, y;
};

void debug(stringstream &s) {}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cerr << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x,ll n)
{
    if(n == 0) return 1;
    ll ans = 1;
    if( n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         ans = ans * ans % mod;
    }
    else ans = fast_exp(x, n - 1) * x % mod;
    return ans;
}

ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

vector<ll> p;
void SoE(ll n)
{
    bool Primes[n + 1];
    Primes[0] = Primes[1] = 0;
    for(ll i = 2; i < n + 1; i++)
        Primes[i] = 1;
    for(ll i = 2; i * i <= n; i++)
    {
       if(Primes[i] == 1)
       {
           for(ll j = i; i * j <= n; j++)
           {
               Primes[i * j] = 0;
           }
       }
    }
    for(ll i = 2; i < n + 1; i++)
    {
        if(Primes[i])
        {
            p.push_back(i);
        }
    }
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    int test = 0;
    while(_--)
    {
        test++;
        ll n, m, x, y, ans = 0, k;
        cin >> n;
        vector<int> v[2][2];
        for(int i = 0; i < n; i++)
        {
            cin >> x >> y;
            v[0][0].pb(-x - y);
            v[1][0].pb(x - y);
            v[0][1].pb(-x + y);
            v[1][1].pb(x + y);
        }
        sort(all(v[0][0]));
        sort(all(v[0][1]));
        sort(all(v[1][0]));
        sort(all(v[1][1]));
        ans = max(v[0][0].back() + v[1][1].back(), v[1][0].back() + v[0][1].back());
        cout << ans << "\n";
    }
    return 0;
}


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

int main (void){
	int n, l, r;
	while(cin>>n>>l>>r, n+l+r){
		int ans = 0;
		vector<int> a(n+1);
		for(int i = 1; i <= n; ++i){
			cin >> a[i];
		}
		for(int y = l; y <= r; ++y){
			int i = 1;
			while(i <= n && y % a[i] != 0) i++;
			if(i==n+1){
				if(n%2==0){
					ans++;
				}
			}else{
				if(i%2==1){
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 2988
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;
ll a[N] , p[N] , n ;
bool ok(ll x) {
	if (x > n || x < 0) return 0 ;
	ll po = 1 ;
	ll s = 0; 
	while (po <= n && 2 * a[x] >= a[po]) {
		s += a[po] ;
		po ++ ;
	}
	while (po <= n) {
		if (s * 2 < a[po]) return false ;
		s += a[po] ;
		po ++ ;
	}
	return 1 ;
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    cin >> n ;
    for (int i = 1 ; i <= n ; i ++) cin >> a[i] ;
	sort(a + 1 , a + n + 1) ;
	p[1] = a[1] ;
	for (int i = 2 ;i  <= n ;i ++) p[i] = p[i - 1] + a[i] ;
	ll l = 0 , h =n + 1 ,  m; 
	while (h - l > 1) {
		m = (h + l) >> 1 ;
		if (ok(m)) h = m ;
		else l = m ;
	}
    if (ok(l)) h = l;
    for (int i = 0 ; i < 4 ; i ++) {
    //cout << i << ' ' << ok(i) << endl;
	}
    cout << n - h+ 1; 
    return (0) ;
}

Measured memory_bytes: 1792
#include <iostream>
#define llint long long
#define inf 1000000000000000000

using namespace std;

llint n, K;
llint a[100005];
llint s[65][2];
llint dp[65][2];

int main(void)
{
	cin >> n >> K;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	int keta = 0;
	for(llint t = K; t; t/=2) keta++;
	keta = 60;
	
	for(int i = 0; i < keta; i++){
		llint cnt0 = 0, cnt1 = 0;
		for(int j = 1; j <= n; j++){
			if(a[j] & (1LL<<i)) cnt1++;
			else cnt0++;
		}
		s[i][1] = cnt0 * (1LL<<i);
		s[i][0] = cnt1 * (1LL<<i);
	}
	
	for(int i = 0; i <= keta; i++) dp[i][0] = dp[i][1] = -inf;
	dp[keta][0] = 0;
	
	for(int i = keta; i > 0; i--){
		for(int j = 0; j < 2; j++){
			for(int k = 0; k < 2; k++){
				int nj = j;
				if(dp[i][j] <= -inf) continue;
				if((K&(1LL<<(i-1)))==0 && k == 1 && j == 0) continue;
				if((K&(1LL<<(i-1))) && k == 0) nj = 1;
				dp[i-1][nj] = max(dp[i-1][nj], dp[i][j] + s[i-1][k]);
			}
		}
	}
	
	llint ans = 0;
	for(int i = 1; i <= n; i++) ans += a[i];
	ans = max(ans, max(dp[0][0], dp[0][1]));
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, *A = map(int, read().split())

cnt = 0
for i, a in enumerate(A, 1):
    if (i % 2 == 1) & (a % 2 == 1):
        cnt += 1
print(cnt)


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

int main(){
  int T;
  cin >> T;
  for(int i=0; i<T; i++){
    int64_t n, m, a, b;
    cin >> n >> m >> a >> b;
    cout << floor_sum(n,m,a,b) << endl;
  }
}

Measured memory_bytes: 3664
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;


void solve()
{
    string s;
    cin >> s;
    f(i,1,sz(s))
        cout << "x";
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

int main(){
  ll n,c,k;
  cin >> n >> c >> k;
  vector<ll> t(n);

  rep(i,n){
    cin >> t.at(i);
  }

  sort(all(t));

  ll ans = 0,time = t.at(0),count = 1;

  for(int i=1;i<n;i++){
    count++;
    if(t.at(i)>time+k || count > c){
      time=t.at(i);
      count=1;
      ans++;
    }
  }

  if(count) ans++;

  cout << ans << endl;
}


Measured memory_bytes: 4004
n=gets.to_i
h=gets.split.map &:to_i
(n-1).downto(1) do |i|
  if h[i-1]-h[i]>1
    puts "No"
    exit
  elsif h[i-1]-h[i]==1
    h[i-1]-=1
  end
end
puts "Yes"

Measured memory_bytes: 8580
#include <stdio.h>
int main(){
  long a = -1e9;
  long b = 2e9;
  int i, n, r;
  scanf("%d", &n);
  for(; i < n; i++){
    scanf("%d", &r);
    if(r-b > a) a = r-b;
    if(b > r) b = r;
  }
  printf("%d\n", a);
  return 0;
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define vvv(type, c, m, n, l, i) vector<vector<vector<type>>> c(m, vector<vector<type>>(n, vector<type>(l, i)));
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	string s;
	while(true) {
		cin >> s;
		if(s == "0") break;
		int sum = 0;
		rep(i, 0, len(s)) sum += s[i] - '0';
		P(sum);
	}
	return 0;
}

Measured memory_bytes: 3140
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    int N;
    long double T,A,H;
    cin >> N >> T >> A;
    int ans;
    long double min=10000000;
    long double tmp;
    int i;
    for(i=0;i<N;i++){
      cin >> H;
      tmp=fabs(T-H*0.006-A);
      if(min>tmp){
        min=tmp;
        ans=i+1;
      }
    }
    cout <<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b,h,m;cin >>a>>b>>h>>m;
    double x1 = (PI/30)*m,x2 = (PI/6)*h + (PI/360)*m,ans;
    ans = (a*a + b*b - 2*a*b*cos(x1-x2));
    cout << setprecision(27) << sqrt(ans);
}

Measured memory_bytes: 4164
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

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

ll N, W;
std::vector<std::pair<ll,ll>> p;

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::cin >> N >> W;
  p.resize(N); rep(i,N) std::cin >> p[i].first >> p[i].second;
  
  std::unordered_map<ll, int> L;
  rep(i,N) L[p[i].first]++;

  std::vector<std::pair<ll,int>> LL(4);
  int cnt = 0;
  for(auto&& itr : L) LL[cnt] = {itr.first, itr.second}, cnt++;

  std::vector<ll> C[4];
  rep(i,N) {
    int j = 0; 
    for(j=0; j<4; j++) if ( LL[j].first == p[i].first ) break;
    C[j].push_back( p[i].second );
  }

  rep(i,4) std::sort( all(C[i]) , std::greater<>() );
  rep(i,4) rep(j,sz(C[i])) if ( j != 0 ) C[i][j] += C[i][j-1];

  ll ans = -1; 
  for(ll i1=0; i1<=LL[0].second; i1++) 
  for(ll i2=0; i2<=LL[1].second; i2++) 
  for(ll i3=0; i3<=LL[2].second; i3++) 
  for(ll i4=0; i4<=LL[3].second; i4++) {
    ll weight = i1*LL[0].first + i2*LL[1].first + i3*LL[2].first + i4*LL[3].first;
    ll cost   = (i1 != 0) ? C[0][i1-1] : 0;
       cost  += (i2 != 0) ? C[1][i2-1] : 0;
       cost  += (i3 != 0) ? C[2][i3-1] : 0;
       cost  += (i4 != 0) ? C[3][i4-1] : 0;
    if ( weight <= W ) ans = std::max(ans, cost);
  }
  std::cout << ans << std::endl;

  return 0;
}


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



int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);


    string s;
    cin>>s;
    int p=0;
    int count=0;
    int max=0;
    for(int i=0;i<s.size();i++){
      if(s[i]=='R'){
        count++;
        if(count>max){
      max=count;
    }
      }
      else if(s[i]=='S'){
        count=0;
       
        
      }
    }
  cout<<max<<endl;

  return 0;
}

Measured memory_bytes: 3588
def f(n):
    res = 0
    for i in range(1, 1000):
        m = n + i * (i - 1) // 2
        r = int((m * 2) ** 0.5)
        if r * (r + 1) // 2 == m and r > i:
            res += 1
            # print(i, m, r)
    return res

while 1:
    n = int(input())
    if n == 0:
        break
    print(f(n))


Measured memory_bytes: 5684
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;

vector<vector<ll>> field(3, vector<ll>(3, 0));
vector<ll> coord1 = {0, 4, 8};
vector<ll> coord2 = {2, 4, 6};
void Main(){
    rep(i, 3){
        rep(j, 3){
            sll(field[i][j]);
        }
    }
    ll N, b;
    cin >> N;
    set<ll> ps;
    rep(i, N){
        sll(b);
        rep(i, 3){
            rep(j, 3){
                if(field[i][j] == b){
                    ps.insert(i*3+j);
                    break;
                }
            }
        }
    }

    bool is_ok = false;
    bool naname1_ok = true;
    bool naname2_ok = true;
    rep(i, 3){
        bool this_ok = true;
        bool tate_ok = true;
        rep(j, 3){
            this_ok = this_ok && ps.find(i*3+j) != ps.end();
            tate_ok = tate_ok && ps.find(j*3+i) != ps.end();
        }
        is_ok = is_ok || this_ok;
        is_ok = is_ok || tate_ok;
        naname1_ok = naname1_ok && ps.find(coord1[i]) != ps.end();
        naname2_ok = naname2_ok && ps.find(coord2[i]) != ps.end();
    }
    if(is_ok || naname1_ok || naname2_ok){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
    

}

int main(){
    Main();
}

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

int main(){
	string s;
	while(getline(cin, s), s != "."){
		int flg = 1;
		stack<char> word;
		for(int i=0 ; i < s.size() ; i++){
			if(s[i]=='[') word.push('[');
			if(s[i]=='(') word.push('(');
			if(s[i]==']'){
				if(!word.empty()&&word.top()=='[') word.pop();
				else{
					flg = 0;
				}
			}
			if(s[i]==')'){
				if(!word.empty()&&word.top()=='(') word.pop();
				else{
					flg = 0;
				}
			}
		}
			
			if(flg==1&&word.empty()) cout << "yes" << endl;
			else cout << "no" << endl;
		}
			return 0;
	}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,K; cin>>N>>K;
    vint cnt(N);
    REP(i,N){
        int a; cin>>a;
        cnt[a-1]++;
    }
    sort(ALL(cnt));

    int ans=0;
    REP(i,N-K){
        ans+=cnt[i];
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1792
using System;

public class Hello
{
    public static int MOD = 1000000007;
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, a);
    }
    static void getAns (int n, int[] a)
    {
        var w = new int[n +1];
        w[0] = 3;
        var ans = 1L;
        for (int i = 0; i < n; i++)
        {
            var t = a[i];
            if (w[t] != 0)
            {
                ans *= w[t];
                ans %= MOD;
                w[t]--;
                w[t + 1]++;
            }
            else { Console.WriteLine(0); return; }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 19168
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n := getNextString()
	sum := 0
	for _, a := range n {
		digit, _ := strconv.Atoi(string(a))
		sum += digit
	}

	if sum%9 == 0 {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}
}

const (
	maxBufSize = 1024 * 1024
)

var (
	scanner = getScanner(os.Stdin)
	out     = bufio.NewWriter(os.Stdout)
)

func abs(x int64) int64 {
	if x > 0 {
		return x
	} else {
		return -x
	}
}

func min(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func max(x, y int64) int64 {
	if x < y {
		return y
	}
	return x
}

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString() string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt() int {
	i, _ := strconv.Atoi(getNextString())
	return i
}

func getNextInt64() int64 {
	i, _ := strconv.ParseInt(getNextString(), 10, 64)
	return i
}

func getNextUint64() uint64 {
	i, _ := strconv.ParseUint(getNextString(), 10, 64)
	return i
}

func getNextFloat64() float64 {
	i, _ := strconv.ParseFloat(getNextString(), 64)
	return i
}


Measured memory_bytes: 2212
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long double a=0,b=0;
    string x;
    long double z;
    for (int i = 0; i < n; ++i) {
        cin>>z;
        cin>>x;
        if(x=="JPY")
            a+=z;
        else
            b+=z;
    }
    a+=(b*380000.0);
    cout<<a;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a == b) {
			System.out.println("Draw");
		} else if(b != 1 && (a == 1 || a > b)) {
			System.out.println("Alice");
		} else {
			System.out.println("Bob");
		}
	}

}


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

using namespace std;

const long long MOD = (long long) 1e9 + 7;

class Dsu {
public:
  int n;
  vector<int> par, rnk;

  Dsu (int _n) : n(_n) {
    par = rnk = vector<int> (n, 0);
    iota(par.begin(), par.end(), 0);
  }

  int getPar (int a) {
    return par[a] == a ? a : par[a] = getPar(par[a]);
  }

  void unite (int a, int b) {
    int x = getPar(a), y = getPar(b);
    if (x == y) return;
    if (rnk[x] > rnk[y]) swap(x, y);
    par[x] = y;
    if (rnk[x] == rnk[y]) rnk[y]++;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  Dsu dsu(n);
  vector<int> bad(n, 0);
  int tot = 0;
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    if (num == -1) {
      bad[i] = 1;
      tot++;
    } else {
      num--;
      dsu.unite(i, num);
    }
  }
  vector<vector<int>> parts(n);
  for (int i = 0; i < n; i++) {
    int x = dsu.getPar(i);
    parts[x].push_back(i);
  }
  vector<pair<int, int>> dat;
  vector<int> cycs;
  cycs.reserve(n);
  dat.reserve(n);
  int mnn = 0;
  for (int i = 0; i < n; i++) {
    int sz = parts[i].size();
    if (!sz) continue;
    int cur = 0;
    for (int pos : parts[i]) {
      if (bad[pos]) cur++;
    }
    dat.emplace_back(sz, cur);
    if (cur) cycs.push_back(sz);
    mnn += sz - 1;
  }
  int sz = dat.size();
  vector<long long> pows(tot + 1);
  pows[0] = 1;
  for (int i = 1; i <= tot; i++) {
    pows[i] = (pows[i - 1] * (n - 1)) % MOD;
  }
  long long ans = (pows[tot] * mnn) % MOD;
  for (int i = 0; i < sz; i++) {
    for (int j = 0; j < sz; j++) {
      if (i == j) continue;
      if (dat[i].second)
        (ans += (pows[tot - 1] * dat[j].first) % MOD) %= MOD;
    }
  }
  sz = cycs.size();
  vector<vector<long long>> dp(sz + 1, vector<long long> (sz + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < sz; i++) {
    for (int j = 0; j <= sz; j++) {
      (dp[i + 1][j] += dp[i][j]) %= MOD;
      if (j + 1 <= sz) (dp[i + 1][j + 1] += (dp[i][j] * cycs[i]) % MOD) %= MOD;
    }
  }
  long long fact = 1;
  for (int i = 2; i <= sz; i++) {
    ans -= (pows[tot - i] * ((fact * dp[sz][i]) % MOD)) % MOD;
    if (ans < 0) ans += MOD;
    (fact *= i) %= MOD;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 199352
#include<iostream>
#include<cstring>
using namespace std;
char s[10000000];
int main()
{
	cin>>s;
	for(int i=0;i<strlen(s);i++)
	{
		if(s[i]=='1')
		s[i]='9';
		else if(s[i]=='9')
		s[i]='1';
	}
	cout<<s<<endl;
 } 

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    //code goes 
	long i,n,j;
	scanf("%ld",&n);
	long c[n],s[n],f[n],tot=-1;
	for(j=0;j<(n-1);++j)
	    scanf("%ld %ld %ld",&c[j],&s[j],&f[j]);     
    for(i=0;i<n;++i){
        tot=0;
        for(j=i;j<(n-1);++j){
            if(tot<s[j])            tot=s[j];
            else if(tot%f[j])       tot=((tot/f[j])+1)*f[j];    
            tot+=c[j];
        }
        printf("%ld\n",tot);
    }
	return 0;
}



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

int main()
{
	int n, t, count=0;
	cin>>n;
  
  	for(int i=1; i<=n; i++)
    {
        cin>>t;
        if(i%2 && t%2)
            count++;
    }
    cout<<count;
}

Measured memory_bytes: 3616