akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 100005;

inline int add(int x,int y)
{
    return (x + y)%MOD;
}

inline int sub(int x,int y)
{
    return (x+MOD-y)%MOD;
}

inline int mul(int x,int y)
{
    return (ll)x*y%MOD;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vp vec(2*n);
    rep(i,n){
        int a;
        cin >> a;
        vec[i] = P(a, 0);
    }
    rep(i,n){
        int b;
        cin >> b;
        vec[n+i] = P(b,1);
    }
    sort(all(vec));
    int ans = 1;
    int sm = 0;
    rep(i,2*n){
        if(vec[i].se){
            if(sm < 0){
                ans = mul(ans, -sm);
            }
            sm++;
        }else{
            if(sm > 0){
                ans = mul(ans, sm);
            }
            sm--;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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




int main(){
    IOS;
    int n; cin >> n;
    list<int> ls;
    REP(i, n){
        string com; cin >> com;
        if(com == "insert"){
            int x; cin >> x;
            ls.push_front(x);
        }else if(com == "delete"){
            int x; cin >> x;
            for(auto itr = ls.begin(); itr != ls.end(); ++itr){
                if(*itr == x){
                    ls.erase(itr); break;
                }
            }
        }else if(com == "deleteFirst"){
            ls.pop_front();
        }else if(com == "deleteLast"){
            ls.pop_back();
        }
    }
    for(auto itr = ls.begin(); itr != ls.end(); ++itr){
        if(itr != ls.begin()) cout << " ";
        cout << *itr;
    }
    cout << "\n";
    return 0;
}



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

using namespace std;

bool find(string s, char a) {
  for (int i = 0; i < s.size(); ++i) if (s[i] == a) return true;
  return false;
}

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  int res = 0;
  for (int i = 1; i < N; ++i) {
    int cnt = 0;
    for (int j = 0; j < 26; ++j) {
      char c = 'a' + j;
      if (find(s.substr(0, i), c) && find(s.substr(i), c)) cnt++;
    }
    res = max(res, cnt);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())
A = list(map(int, input().split()))
ans1 = 0
ans2 = 0

for i in range(x):
    if i in A:
        ans1 = ans1 + 1

for i in range(x + 1, n + 1):
    if i in A:
        ans2 = ans2 + 1

print(min(ans1, ans2))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    int x = accumulate(v.begin(),v.end(), 0);
    if(x >= h){
         puts("Yes");
    }else {
        puts("No");
    }
    return 0;
}

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

int n;
int sum(int n){
 int m,mm,mmm,mmmm,mmmmm;
  m=n%10;
  mm=(n-m)%100;
  mmm=(n-m-mm)%1000;
  mmmm=(n-m-mm-mmm)%10000;
  mmmmm=(n-m-mm-mmm-mmmm)%100000;

  mm=mm/10;
  mmm=mmm/100;
  mmmm=mmmm/1000;
  mmmmm=mmmmm/10000;
  return m+mm+mmm+mmmm+mmmmm;
}

int main() {
 int a,b,ans=0;
 cin >> n >> a >> b;
   for(int i=a;i<100001;i++){
     if(sum(i)>=a && sum(i)<=b && i<=n){
       ans+=i;
     }
   }
  cout << ans << endl;
}


Measured memory_bytes: 256
/* Fennec vs Monster */

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int n,k,h;
  long ans=0;
  vector<int> H;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> h;
    H.push_back(h);
  }
  sort(H.begin(),H.end());
  for(int i=0;i<(n-k);i++){
    ans+=H[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1400
#include<iostream>

using namespace std;

int main(){
  
  long long x , happy=0;
  cin>>x;
 
  if(x>=500)
  {
    happy = x/500 * 1000 ;
     x %= 500;
  }
  happy += x/5 * 5;
  
  cout<<happy;
  
  return 0;
  
}
  
  

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



int main() {
	int N,l,r;
	int sum = 0;

	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> l >> r;
		sum += r - l+1;
	}

	cout << sum;
}

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

using namespace std;

int main() {
  const int SIZE = 200;
  vector<int> cnt(SIZE+1,0);
  for(int i = 1; i <= SIZE; i++) {
    for(int j = 1; i*j <= SIZE; j++) {
      cnt[i*j] ++;
    }
  }
  int N; cin>>N;
  int ans = 0;
  for(int i = 1; i <= N; i+=2)
    if(cnt[i] == 8) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
int dp[101010],n;
vector<int>v;
int main()
{
	cin>>n;
	for(int i=0;i<101010;i++)
	{
		dp[i]=1e9;
	}
	dp[0]=0;
	dp[1]=1;
	v.push_back(1);
	for(int i=1;i<=9;i++)
	{
		int ans=1;
		for(int j=1;j<=i;j++)
		{
			ans*=6;
		}
		v.push_back(ans);
		ans=1;
		for(int j=1;j<=i;j++)
		{
			ans*=9;
		}
		v.push_back(ans);
	}
	sort(v.begin(),v.end());
	for(int i=2;i<=101000;i++)
	{
		for(int j=0;j<v.size();j++)
		{
			if(v[j]>i)
			{
				break;
			}
			dp[i]=min(dp[i],dp[i-v[j]]+1);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n-- != 0){
			int a[] = new int[3];
			    for(int i = 0; i < 3; i++){
				    a[i]=(int)Math.pow(sc.nextInt(), 2);
			}
			System.out.println((a[0]+a[1]==a[2]||a[0]+a[2]==a[1]||a[2]+a[1]==a[0])?"YES":"NO");
		}
	}
}

Measured memory_bytes: 34444
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int[] a = new int[3];
			a[0] = cin.nextInt();
			a[1]= cin.nextInt();
			a[2] = cin.nextInt();
			if(a[0]+a[1]+a[2]==0){
				break;
			}
			Arrays.sort(a);
			double len = Math.sqrt(a[0]*a[0]+a[1]*a[1]);
			int N = cin.nextInt();
			while(N--!=0){
				int c = cin.nextInt();
				if(c*2 > len){
					System.out.println("OK");
				}
				else{
					System.out.println("NA");
				}
			}
		}
	}

}

Measured memory_bytes: 12000
#include <stdio.h>
#define N 100
#define INF 2100000000

int main(){
  int M,i,j,k,n,l,p[N+1],m[N+1][N+1];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&p[i-1],&p[i]);
  }

  for(i=1;i<=n;i++) m[i][i] = 0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i+l-1;
      m[i][j] = INF;
      for(k=i;k<=j-1;k++){
	M = m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(M < m[i][j]) m[i][j] = M;
      }
    }
  }

  printf("%d\n",m[1][n]);

  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,m;
	cin>>n>>m;
	int ans=0;
	ll x=__gcd(n,m);
		for(ll i=2;i*i<=x;i++){
			if(x%i==0){
				ans++;
				while(x%i==0){
					x/=i;
				}
			}
		}
		if(x>1) ans+=2;
		else ans++;
		cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////
	vector<int> vec[100005]{};
	int n;
int black;
int white;
int can;
int p[100005];
int len;
int path[100005];
int pp[100005];
int cnt;
int r,s;

void ne(int a,int d){
p[a]=1;

for(int j=0;j<vec[a].size();j++){
if(p[vec[a][j]]==0){
	if(vec[a][j]==n){
can=1;
p[n]=1;
len=d+1;
path[len]=n;
path[d]=a;
return ;
	}
	if(can) break;
ne(vec[a][j],d+1);
}
}

if(can && path[d]==0 ){
	path[d]=a;
}

}

void count(int k){
for(int i=0;i<vec[k].size();i++){
if(pp[vec[k][i]]==0 &&vec[k][i]!=r && vec[k][i]!=s){
cnt++;
pp[vec[k][i]]=1;
count(vec[k][i]);
}
}
}






int main() {
black=0;
white=0;
can=0;
len=-1;
cnt=1;
	cin>>n;

rep(i, n){
	p[i]=0;
	pp[i]=0;
	path[i]=0;
}
path[0]=0;

rep(i, n-1){
	int a,b;
	cin>>a>>b;
	vec[a].push_back(b);
	vec[b].push_back(a);
}

ne(1,0);

r=path[len/2];
s=path[len/2+1];

int fenek=0;
int snuke=0;
count(r);
fenek=cnt;
cnt=1;
count(s);
snuke=cnt;

if(fenek>snuke){
	cout<<"Fennec"<<endl;
}
else{cout<<"Snuke"<<endl;}
return 0;




}





Measured memory_bytes: 12160
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

unordered_map<ll, ll> mp;


int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = unordered_map<ll, ll>();
#pragma clang diagnostic pop
#endif
        ll x, y;
        cin >> x >> y;
        ll ans = 1;
        while (x * 2 <= y) {
            x *= 2;
            ans++;
        }
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
using namespace std;
const int maxn=100000;
int n,f[maxn+10][2];
vector<int> g[maxn+10];
void dfs(int x,int fa){
	int now=1e9;
	for(int i=0;i<g[x].size();++i){
		int e=g[x][i]; if(e==fa) continue;
		dfs(e,x); f[x][0]+=f[e][1]; now=min(now,f[e][1]-f[e][0]);
	}
	f[x][1]=max(f[x][0],f[x][0]-now+1);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;++i){
		int l,r; scanf("%d%d",&l,&r);
		g[l].push_back(r); g[r].push_back(l);
	}
	dfs(1,0); if(f[1][1]*2==n) printf("Second"); else printf("First");
}

Measured memory_bytes: 6656
h,w = gets.chomp.split(" ").map(&:to_i)
s = h.times.map{gets.chomp.split("")}
for i in 0..h-1
  s[i].unshift("0") << "0"
end
s.unshift(Array.new(w+1,"0")) << Array.new(w+1,"0")
for i in 1..h
  for j in 1..w
    if s[i][j] == "."
      s[i][j] = 0
    end
    for k in -1..1
      for l in -1..1
        if s[i][j] != "#" && s[i+k][j+l] == "#"
          s[i][j] += 1
        end
      end
    end
  end
end
for i in 1..h
  for j in 1..w
    print s[i][j]
  end
  print "\n"
end

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Distinct or Not
            if (IsDoubled())
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }            
        }

        static bool IsDoubled()
        {
            int N = int.Parse(Console.ReadLine());
            var A = ReadLine();

            var dic = new Dictionary<int, int>();

            foreach (var a in A)
            {
                if (dic.ContainsKey(a))
                {
                    return false;
                }
                else
                {
                    dic.Add(a, 1);
                }
            }

            return true;
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 38608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<" "<<#x<<"="<<x

#define bit(k) (1LL<<(k))

typedef long long ll;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    sort(all(A));
    //積がX未満の数がK個未満かどうか
    auto check = [&](ll X){
        ll res = 0;
        vector<ll> cnt(N,0);
        rep(i,N){
            if(A[i] > 0){
                // 昇順の単調性
                int l = -1;
                int r = N;
                while(r - l > 1){
                    //cerr<<l<<" "<<r<<endl;
                    int mid = (l + r) / 2;
                    if(A[i] * A[mid] < X)l = mid;
                    else r = mid;
                }
                if(i <= l)l--;
                cnt[i] += l+1;
            }
            else{
                
                //降順の単調性
                int l = -1;
                int r = N;
                while(r - l > 1){
                    //cerr<<l<<" "<<r<<endl;
                    int mid = (l + r) / 2;
                    if(A[i] * A[mid] < X)r = mid;
                    else l = mid;
                }
                if(r <= i)r++;
                cnt[i] += N - r;
            }
            res += cnt[i];
        }
        
        //cerr<<X<<"未満の数は"<<res/2<<"個"<<endl;
        //print(cnt);
        return res/2 < K;
    };
    ll ok = -INFLL - 1;
    ll ng = INFLL + 1;
    while(ng - ok > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid))ok = mid;
        else ng = mid;
    }
    //print(A);
    cout<<ok<<endl;
}

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

string S;
int cur = 0;

int digit() {
  return S[cur++] - '0';
}

int number() {
  int n = digit();
  while(cur < S.size() && isdigit(S[cur])) n = n * 10 + digit();
  return n;
}

int expression();

int factor() {
  if(S[cur] != '(') return number();
  cur++;
  int n = expression();
  cur++;
  return n;
}

int term() {
  int n = factor();
  while(cur < S.size() && (S[cur] == '*' || S[cur] == '/')) {
    char op = S[cur++];
    if(op == '*') n *= factor(); else n /= factor();
  }
  return n;
}

int expression() {
  int n = term();
  while(cur < S.size() && (S[cur] == '+' || S[cur] == '-')) {
    char op = S[cur++];
    if(op == '+') n += term(); else n -= term();
  }
  return n;
}

int main() {
  int n;
  cin >> n;
  for(int i = 0;i < n;i++) {
    cur = 0;
    cin >> S;
    S.erase(S.size() - 1);
    cout << expression() << endl;
  }
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],b[100009];
	for(int i=0;i<100009;i++) b[i]=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		for(int j=a[i];j<a[i]+3;j++) b[j]++;
	}
	sort(b,b+100009);
	cout<<b[100008];
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  ll ans=0;
  for(auto& p:mp){
    int s=p.second;
    ans+=(ll)s*(s-1)/2;
  }
  cout<<ans;
  return 0;
}

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

using namespace std;

#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define ll long long int

int INF = 1e9+5;

int main() {
int N;
cin>>N;
vector<int> v(N);
vector<int> dp(N,INF);
for(auto& x: v)
    cin>>x;
dp[0] = 0;
for(int i=0;i<N;i++) {
    for(int j: {i+1,i+2}) {
        if(j<N) {
            dp[j] = min(dp[j],dp[i]+abs(v[i]-v[j]));
        }
    }
}
cout<<dp[N-1]<<endl;
return 0;
}


Measured memory_bytes: 1024
n = int(input())
n_100 = int(n / 100)
n_10 = int((n - n_100*100) / 10)
n_1 = int(n-n_100*100-n_10*10)

if n_100 == 7 or n_10 ==7 or n_1 ==7:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9172
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <stack>
#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
#define ll long long int
using namespace std;

bool flag;
int i, pos;
string s, ara[] = {"dream", "dreamer", "erase", "eraser"};

int main()
{
        cin >> s;
        reverse(s.begin(), s.end());
        for (i = 0; i < 4; i++) reverse(ara[i].begin(), ara[i].end());
        while (pos < s.size()) {
            flag = true;
            for (i = 0; i < 4; i++) {
                if (s.substr(pos, ara[i].size()) == ara[i]) {
                    pos += ara[i].size();
                    flag = false;
                    break;
                }
            }
            if (flag) break;
        }
        if (flag) pf("NO\n");
        else pf("YES\n");
    
    return 0;
}

Measured memory_bytes: 512
import sys

def solve():
    N, K = map(int, input().split())

    cnt = [0]*(10**5 + 1)

    for i in range(N):
        ai, bi = map(int, sys.stdin.readline().split())
        cnt[ai] += bi

    tot = 0

    for i, cnti in enumerate(cnt):
        tot += cnti

        if tot >= K:
            print(i)
            return

if __name__ == '__main__':
    solve()

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

#define ll long long
#define s second
#define f first

int main()
{
	ll n;
	cin >> n;
	
	double x,y;
	
	vector<ll> v;
	
	for(int i=0;i<n;i++)
	{
		v.push_back(i);
	}
	
	vector<pair<double,double>> vc;
	for(int i=0;i<n;i++)
	{
		cin >> x >> y;
		vc.push_back({x,y});
	}
	
	double sum=0;
	do
	{
		double sm=0, dist;
		for(int i=0;i<n-1;i++)
		{
			dist= (vc[v[i]].f-vc[v[i+1]].f) * (vc[v[i]].f-vc[v[i+1]].f) + (vc[v[i]].s-vc[v[i+1]].s)*(vc[v[i]].s-vc[v[i+1]].s);
			dist=sqrt(dist);
			
			sm+=dist;
		}
		
		sum+=sm;
	}while(next_permutation(v.begin(),v.end()));
	
	ll fact=1;
	for(int i=1;i<=n;i++)
	{
		fact=fact*i;
	}
	
	cout << fixed << setprecision(10) << sum/fact << endl;
	
	return 0;
}


Measured memory_bytes: 768
n, q = gets.split.map(&:to_i)
s = gets.chomp
lr = q.times.map { gets.split.map(&:to_i) }
prev = ""
arr = Array.new(n, 0)
sum = 0
(0..n-1).each do |i|
  if prev == "A" && s[i] == "C"
    sum += 1
  end
  arr[i] = sum
  prev = s[i]
end
puts lr.map{ |m| arr[m[1]-1] - arr[m[0]-1] }


Measured memory_bytes: 11772
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int
#define Vec vector
template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N,Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	
	Vec<int> ac(N);
	for(int i=1;i<N;i++) if(S[i-1] == 'A' && S[i] == 'C') ac[i] = 1;
	Vec<int> sum(N+1);
	for(int i=0;i<N;i++) sum[i + 1] = sum[i] + ac[i];
	for(int i=0;i<Q;i++){
		int l, r;
		scanf("%d %d", &l, &r);
		l--; r--;
		printf("%d\n", sum[r + 1] - sum[l + 1]);		
	}
	
    return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int dp[301][301];

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> ans;
    while(true){
        int N; cin >> N; if(N == 0) break;
        vector<int> W(N); rep(i, N) cin >> W[i];
        memset(dp, 0, sizeof(dp));
        for(int haba = 1; haba <= N; haba++){
            for(int left = 0; left + haba <= N; left++){
                int res = 0;
                int right = left + haba;
                if(right-left >= 2){
                    if(abs(W[left]-W[right-1]) <= 1 && dp[left+1][right-1] == right-left-2) res = dp[left+1][right-1]+2;
                    else res = dp[left+1][right-1];
                }
                for(int boarder = left+1; boarder < right; boarder++){
                    res = max(res, dp[left][boarder] + dp[boarder][right]);
                }
                dp[left][right] = res;
            }
        }
        ans.push_back(dp[0][N]);
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


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

#define INF INT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

int main() {

    int n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1;i < n;i++){
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())

def pow(a,n,p):
  if n==1:
    return a%p
  elif n%2==1:
    return a*pow(a,n-1,p)
  else:
    return (pow(a,n//2,p)**2)%p
  
from math import factorial as f

def nCr(n,r,p):
  r=min(r,n-r)
  if r==0:
    return 1
  x,y=1,1
  for i in range(r):
    x=x*(n-i)%p
    y=y*(i+1)%p
  return x*pow(y,p-2,p)%p

def main():
  p=10**9+7
  print((pow(2,n,p)-1-nCr(n,a,p)-nCr(n,b,p))%p)

if __name__=='__main__':
  main()

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

int main() {
    ll N, A, B; cin >> N >> A >> B;
    vector<ll> X(N);

    for( auto &k : X ){
        cin >> k;
    }

    ll allfatigue = 0;
    for( int i = 0; i < N - 1; i++ ){
        ll distance = X[i+1] - X[i];
        allfatigue += min(distance * A, B);
    }

    cout << allfatigue << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ii, ii> iii;
ll MOD = 1e9 + 7;
const ld E = 1e-7;
#define null NULL
#define ms(x) memset(x, 0, sizeof(x))
#ifndef LOCAL
#define endl "\n"
#endif
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _read(x) freopen(x, "r", stdin)
#define _write(x) freopen(x, "w", stdout)
#define files(x) _read(x ".in"); _write(x ".out")
#define filesdatsol(x) _read(x ".DAT"); _write(x ".SOL")
#define output _write("output.txt")
#define input _read("input.txt")
#define mod % MOD
#define y1 hello_world
unsigned char ccc;
bool _minus = false;
template<typename T>
inline T sqr(T t) {
	return (t * t);
}
inline void read(ll &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n')
			break;
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
}
inline void read(int &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n')
			break;
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
}
char wwww[19];
int kkkk;
inline void write(ll y) {
	long long x = y;
	kkkk = 0;
	if (!x)
		++kkkk, wwww[kkkk] = '0';
	else
		while (x) {
			++kkkk;
			wwww[kkkk] = char(x % 10 + '0');
			x /= 10;
		}
	for (int i = kkkk; i >= 1; --i)
		putchar(wwww[i]);
	putchar('\n');
}

#ifdef LOCAL
//#define DEBUG
#endif


int main() {
	srand(time(NULL));
	cout.precision(10);
	cout << fixed;
	sync;
#ifdef LOCAL
	input;
#else

#endif

	int n;
	cin >> n;
	vector<ii> v;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		v.push_back(make_pair(a, i));
	}
	sort(v.begin(), v.end());
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(i % 2 != v[i].second % 2)
			ans++;
	}
	assert(ans % 2 == 0);
	ans /= 2;
	cout << ans << endl;
}


Measured memory_bytes: 1400
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
typedef long long lint;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<typename T=lint> T in(){
    return *istream_iterator<T>(cin);
}
int main(){
    lint n,W;
    cin>>n>>W;
    vector<vector<lint>> dp(n+1,vector<lint>(W+1,0));
    vector<lint> v(n),w(n);
    rep(i,n)cin>>v[i]>>w[i];
    repi(i,1,n+1)repi(j,1,W+1){
        if(j-w[i-1]>=0)dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
        else dp[i][j]=dp[i-1][j];
    }
    cout<<dp[n][W]<<endl;
}


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

long long power(long long a, long long b) {
    //a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
    }
   
    
   int binomial(int n, int k)  
{  
    // Base Cases  
    if (k == 0 || k == n)  
        return 1;  
  
    // Recur  
    return binomial(n - 1, k - 1) + binomial(n - 1, k);  
}   

bool Sieve(ll int n) 
{ 
    
    bool prime[n+100000]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    return prime[n];
}
  
    
vector<long long> factor;  
vector<long long>prime(long long n) {
 for (long long d = 2; d * d <= n; d++) {
     while (n % d == 0) {
         factor.push_back(d);
            n /=d;
        }
    }
 if (n > 1)
    factor.push_back(n);
    return factor;
}




//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}


  
int main() {
     int a[5];
     int k=0;
     for(int i=0;i<5;i++)
     {
         cin>>a[i];
         if(a[i]==0)
         {
             k=i+1;
         }
     }
     cout<<k<<endl;
     
}


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

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

	string a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	cout << (char)(a1[0]-32) << (char)(a2[0]-32) << (char)(a3[0]-32);
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

int ad_num[110];
vector<int> ad[110];
int t=0;
int d[110];
int f[110];

void dfs(int v){
    t++;
    if(d[v]==-1) d[v]=t;
    //if(ad_num[v]==0) return;
    for(auto e: ad[v]){
        //t++;
        if(d[e]==-1) dfs(e);
    }
    t++;
    if(f[v]==-1) f[v]=t;
}

void solve(){

    int n;
    cin >> n;
    rep(i,n){
        int trash;
        cin >> trash;
        cin >> ad_num[i];
        rep(j,ad_num[i]){
            int tmp;
            cin >> tmp;
            tmp--;
            ad[i].emplace_back(tmp);
        }
    }
    rep(i,n){
        d[i]=-1;
        f[i]=-1;
    }
    dfs(0);
    rep(i,n){
        if(d[i]==-1) dfs(i);
    }

    rep(i,n){
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }

}

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



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

int main(){
  int i,j,n,a[8][8];
  a[1][2] = a[2][1] = 300;
  a[2][3] = a[3][2] = 350;
  a[6][7] = a[7][6] = a[1][3] = a[3][1] = 500;
  a[4][5] = a[5][4] = a[3][4] = a[4][3] = 250;
  a[2][4] = a[4][2] = 450;
  a[5][6] = a[6][5] = a[2][5] = a[5][2] =  a[1][4] = a[4][1] = 600;
  a[3][5] = a[5][3] = 400;
  a[5][1] = a[1][5] = 700;
  a[4][6] = a[6][4] = 850;
  a[3][6] = a[6][3] = 1000;
  a[5][7] = a[7][5] = a[2][6] = a[6][2] = 1150;
  a[3][7] = a[7][3] = a[1][6] = a[6][1] = 1350;
  a[4][7] = a[7][4] = 1300;
  a[2][7] = a[7][2] = 1500;
  a[1][7] = a[7][1] = 1650;

  while(1){
    int ic[2],h[2],m[2],t[2],ans,ans2;
    cin >> ic[0];
    if(ic[0] == 0) break;
    cin >> h[0] >> m[0];
    cin >> ic[1];
    cin >> h[1] >> m[1];

    ans = a[ic[0]][ic[1]];
    for(i=0;i<2;i++){
      if(h[i] == 17 && m[i] >= 30 || h[i] == 18 || h[i] == 19 && m[i] <= 30){
	if(ic[0] == 1 && ic[1] == 6 || ic[0] == 6 && ic[1] == 1);
	else if(ic[0] == 1 && ic[1] == 7 || ic[0] == 7 && ic[1] == 1);
	else if(ic[0] == 2 && ic[1] == 7 || ic[0] == 7 && ic[1] == 2);
	else if(ic[0] == 3 && ic[1] == 7 || ic[0] == 7 && ic[1] == 3);
	else{
	ans /= 2;
	ans2 = ans;
	while(ans2 > 50) ans2 -= 50;
	ans += 50 - ans2;
	break;
	}
      }
    }

    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
#define pb push_back
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}
const int maxn = 100000+5;

int n;
pair<int, int> co[120];
ll ht[120];

int main(){
    //freopen("input.txt", "r", stdin);
    fastio();

    cin>>n;
    int si = -1;
    for(int i = 0; i < n; ++i){
        int x,y;
        ll h;
        cin>>x>>y>>h;
        co[i] = make_pair(x,y);
        ht[i] = h;
        if(ht[i] > 0) si = i;
    }

    for(int cx = 0; cx <= 100; ++cx){
        for(int cy = 0; cy <= 100; ++cy){
            int flag = 1;

            ll H = ht[si] + abs(co[si].ft - cx) + abs(co[si].sd - cy);

            for(int i = 0; i < n; ++i){
                if(ht[i] > 0 && H != ht[i] + abs(co[i].ft - cx) + abs(co[i].sd - cy))
                    flag = 0;
                if(ht[i] == 0 && H - abs(co[i].ft - cx) - abs(co[i].sd - cy) > 0)
                    flag = 0;
            }

            if(flag){
                cout<<cx<<" "<<cy<<" "<<H<<endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x);
#define CMIN(m, x)  m = min(m,x);
#define itn int
typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    string s;
    cin >> s;
    if(s == "ABC")
        cout << "ARC" << endl;
    else
    {
        cout << "ABC" << endl;
    }
    
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int p;
    int c[n + 1] = {};
    for(int i = 1; i < n + 1; i++)
    {
        cin >> p;
        if(i == p)
        {
            c[i] = 1;
        }
        else
        {
            c[i] = 0;
        }
    }
    int x = 0;
    int t = 0;
    for(int k = 1; k < n + 1; k++)
    {
        if(c[k-1] == 1 && c[k] == 1 && t % 2 == 1)
        {
            t = t + 1;
        }
        else if(c[k-1] == 1 && c[k] == 1 && t % 2 == 0)
        {
            t = t + 1;
            x = x + 1;
        }
        else if(c[k-1] == 0 && c[k] == 1)
        {
            t = t + 1;
            x = x + 1;
        }
        else
        {
            t = 0;
        }
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 640
package main

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

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

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

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

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

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	s := getNextString(scanner)

	n := len(s)
	rr := make([]rune, 0)
	ii := make([]int, 0)
	for i := 0; i < n; i++ {
		if s[i] == 'x' {
			continue
		}
		rr = append(rr, rune(s[i]))
		ii = append(ii, i)
	}

	ans := -1
	if isPalindrome(rr) {
		ans = 0
		l := -1
		r := n
		for l < r {
			l++
			r--
			if s[l] == s[r] {
				continue
			}
			if s[l] == 'x' {
				for s[l] == 'x' {
					l++
					ans++
				}
				continue
			}
			for s[r] == 'x' {
				r--
				ans++
			}
		}
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}

func isPalindrome(rr []rune) bool {
	n := len(rr)

	if n == 0 {
		return true
	}

	l := -1
	r := n
	for l < r {
		l++
		r--
		if rr[l] != rr[r] {
			return false
		}
	}

	return true
}


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

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

    if(b%2==1)
	cout << "No" << endl;
    else if(2*a<=b && b<=4*a)
	cout << "Yes" << endl;
    else
	cout << "No" << endl;
} 




Measured memory_bytes: 3620
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

X = int(stdin.readline())

# tmp = (10 ** 9) ** (1/5)
# print(tmp)

for i in range(-300, 300):
    for j in range(-300, 300):
        if (i**5) - (j**5) == X:
            print(i, j)
            exit()

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n,p;
    cin >> n >> p;

    vector<int> a(n);

    rep(i, n){
        cin >> a[i];
    }

    vector<vector<ll>> dp(n + 1, vector<ll>(2));

    dp[0][0] = 1;

    for(int i = 0; i < n; i++){
        if(a[i] % 2 == 0){
            dp[i + 1][0] = dp[i][0] * 2;
            dp[i + 1][1] = dp[i][1] * 2;
        }else{
            dp[i + 1][0] = dp[i][0] + dp[i][1];
            dp[i + 1][1] = dp[i][0] + dp[i][1];
        }
    }

    cout << dp[n][p] << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        
        int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int K = a[0];
        int A = a[1];
        int B = a[2];
        long num = 1;
        int i = 1;
        bool flag = false; //A枚を1円に交換したらfalseにする
        while(i <= K)
        {
            
            if(B - A < 2)
            {
                num ++;
                i++;
                
            }
            else if(B - A >= 2)
            {
                
                if(num >= A && i <= K-1)
                {
                    num -= A;
                    num += B;
                    i += 2;
                    
                    
                }
                else
                {
                    num++;
                    i++;
                
                }
            }
        }
        
        Console.WriteLine(num);
    }
}



Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define   vpll   vector<pll >
#define   all(x) x.begin(),x.end()
#define   present(c,x)    ((c).find(x) != (c).end())
#define   dbg(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){
  std::cerr << name << " = " << arg1 << "\n";
}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
#define   sz(a)  a.size()
#define   vll vector<int>
#define   pll pair<int,int>
#define   ff  first
#define   ss  second
#define   br  cout<<"\n";
#define   ld  long double
#define   int  long long int
const int  INF = 1e18+7;
const int  MAX = 1234567;
const int  MOD = 1000000007;



void solve(){
    int n ;
  	cin >> n ;
  	int h1 = (n / 500) * 1000 ;
  	int rem = ( n % 500 ) ;
   	h1 += ( rem / 5 ) * 5 ;
  	cout << h1 ;
}
int32_t main(){
    int t;
    t=1;
    cin.sync_with_stdio(0), cin.tie(0);
    //cin>>t;
    while(t--){
        solve();
        br;
    }
    return 0;
}
 
 
 
 
 
 

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

f n hs
  | (length . group . binMap subtract . tail) hs == 1 = head hs
  | (length . group . binMap subtract . init) hs == 1 = last hs
  | otherwise = let d = (last hs - head hs) `div` (n-1) in let g (x:xs@(y:_)) = if x+d/=y then y else g xs in g hs

main = do
    n <- getInt
    unless (n==0) $ f n <$> getInts >>= print >> main


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

int main(){
    char c;
    cin >> c;

    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
        cout << "vowel";
    }else{
        cout << "consonant";
    }
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) cin >> e;
  int x = 0;
  int y = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == i + 1) continue;
    if (a[i] < i + 1) x++;
    if (a[i] > i + 1) y++;
  }
  if ((x == 0 && y == 0) || (x == 1 && y == 1)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int n;
ll k;
vector<int>a,b;
map<int,int>c;

int main() {
	cin>>n>>k;
	a.resize(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]--;
	}
	
	c[0]=0;
	b.push_back(0);
	int p=0;
	ll i=0;
	while(true){
		i++;
		if(i==k){
			cout<<a[p]+1;
			return 0;
		}
		
		if(c.count(a[p])){
			int pos=c[a[p]];
			int m=(k-pos)%(b.size()-pos);
			cout<<b[pos+m]+1;
			return 0;
		}
		
		c[a[p]]=i;
		b.push_back(a[p]);
		p=a[p];
		
	}

	
	return 0;
}

Measured memory_bytes: 12040
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    int n,a[1000],i;
    char token[1000]={};
    fgets(token, sizeof(token), stdin);n=atoi(token);
    fgets(token, sizeof(token), stdin);
    a[0]=atoi(strtok(token, " "));
    for (i=1; i<n; i++) a[i]=atoi(strtok(NULL, " "));
    for (i=0; i<n; i++) {
        if (a[i]%2==0) {
            if (a[i]%3!=0&&a[i]%5!=0){
                printf("DENIED");
                return 0;
            }
        }
    }
    printf("APPROVED");
    return 0;
}


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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int H, W;
	cin >>H >>W;
	for (int i=0; i<H; i++) {
		string S;
		cin >>S;
		cout <<S <<endl;
		cout <<S <<endl;
	}
	return 0;
}



Measured memory_bytes: 256