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

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    long long N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i += 2) {
        if(enum_divisors(i).size() == 8) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
using namespace std;
int cnt;
int main()
{
  string s;
  cin>>s;
  for(int i=0;i<3;i++)
  if(s[i]=='o')
    cnt++;
  cout<<(700+100*cnt);
  return 0;
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    N = NI()
    A = LI()

    A.sort(reverse=True)

    ans = 0
    for c in range(1,N):
        ans += A[c//2]
    print(ans)



if __name__ == '__main__':
    main()

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

int main() {
    int n, even = 0;
    cin >> n;
    map<int, int> count;
    for (int i = 0, a; i < n; i++) {
        cin >> a;
        count[a]++;
    }
    for (auto& p : count) {
        if (p.second > 1) {
            if (p.second % 2 == 0) {
                even++;
            }
            n -= p.second - 1;
        }
    }
    if (even % 2 == 1) {
        n--;
    }
    cout << n;
    return 0;
}


Measured memory_bytes: 4992
# For taking integer inputs.
def inp():
    return(int(input()))


A = inp()
B = inp()
C = inp()
X = inp()
r = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            temp = i * 500 + j*100 + k * 50
            if temp == X:
                r += 1
print(r)


Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    string ss;
    cin>>ss;
    if(ss=="a" || ss=="e" || ss=="i" || ss=="o" || ss=="u"){
        cout<<"vowel"<<endl;
    }
    else cout<<"consonant"<<endl;
    return 0;
    // Your code here!
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,T,w[3010],v[3010],f[3010][2],ans,a[3010];
int main(){
	scanf("%d%d",&n,&T);
	int id=0;
	for(int i=1;i<=n;i++)
		scanf("%d%d",&w[i],&v[i]);
	for(int i=1;i<=n;i++){
		for(int j=0;j<=T;j++)a[j]=f[j][1];
		for(int j=T-1;j>=0;j--)f[j][1]=max(f[j][1],f[j][0]+v[i]);
		for(int j=T;j>=w[i];j--)f[j][1]=max(f[j][1],a[j-w[i]]+v[i]),f[j][0]=max(f[j][0],f[j-w[i]][0]+v[i]);
	}
	for(int i=0;i<=T-1;i++)
		ans=max(ans,max(f[i][0],f[i][1]));
	printf("%d\n",ans);
}

Measured memory_bytes: 256
n = gets.to_i
  x = []
  tim = 0
  judged = 1
  win = 0
  n.times do |i|
    x[i] = gets.to_i
  end
  n.times do
    judged = x[judged-1]
    if judged == 2
      tim += 1
      win = 1
      break
    else
      tim += 1
    end
  end
  if win == 1
    puts tim
  else
    puts -1
  end


Measured memory_bytes: 3144
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define debug(x) cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

int sum_digit(int n, int b){
  int res = 0;
  while(true){
    res += n%b;
    n /= b;
    if (n==0)break;
  }
  return res;
}

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

  int n,a,b;
  cin>>n>>a>>b;

  int count=0;
  REPS(i, n){
    // if (a<=sum_digit(i, 10)<=b){
    int c = sum_digit(i, 10);
    if (a<=c and c<=b){
      count+=i;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef array <int, 2> pii;
typedef vector <int> vi;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 203, M = 1e5 + 123, MOD = 1e9 + 7;
int n, x, a[N], dp[2][M];

void add(int & x, int y) {
	x += y;
	if (x >= MOD) {
		x -= MOD;
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> x;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	dp[0][x] = 1;
	for (int i = 1; i <= n; i++) {
		int p = i & 1;
		for (int j = 0; j <= x; j++) {
			dp[p][j] = 0;
		}
		for (int j = 0; j <= x; j++) {
			add(dp[p][j % a[i]], dp[p ^ 1][j]);
			add(dp[p][j], (ll)dp[p ^ 1][j] * (n - i) % MOD);
		}
	}
	int res = 0;
	for (int i = 0; i <= x; i++) {
		add(res, (ll)dp[n & 1][i] * i % MOD);
	}
	cout << res;
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	template<typename T> inline int ts(T *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 1000007;

int n,s[_];
int pre[_]={0},nex[_]={0};
int cnt[3]={0},rk[3]={0},tran[3]={0};
int stk[_]={0},top=0;

inline void pop(int x){pre[nex[x]]=pre[x],nex[pre[x]]=nex[x],cnt[s[x]]--;}

int main()
{
	n=ts(s+1);
	for(int now=n,i=((n=0),1);i<=now;i++)if(s[i]!=s[i-1])s[++n]=s[i];
	for(int i=1;i<=n;i++)s[i]-='A',pre[i]=i-1,nex[i]=i+1,cnt[s[i]]++;
	nex[0]=1,pre[n+1]=n,s[0]=s[n+1]=-1;

	rk[0]=0,rk[1]=1,rk[2]=2;
	if(cnt[rk[0]]>cnt[rk[1]])swap(rk[0],rk[1]);
	if(cnt[rk[1]]>cnt[rk[2]])swap(rk[1],rk[2]);
	if(cnt[rk[0]]>cnt[rk[1]])swap(rk[0],rk[1]);
	tran[rk[0]]=0,tran[rk[1]]=1,tran[rk[2]]=2;

	sort(cnt,cnt+3);
	for(int i=1;i<=n;i++)s[i]=tran[s[i]];

	top=0;
	for(int i=nex[0];i<=n;i=nex[i])if(s[i]==2 && s[pre[i]]!=s[nex[i]])stk[++top]=i;
	for(int i=1;i<=top && cnt[1]<cnt[2];i++)pop(stk[i]);

	top=0;
	for(int i=nex[0];i<=n;i=nex[i])if(s[i]==2 && s[pre[i]]==0 && s[nex[i]]==0)stk[++top]=i;
	for(int i=1;i<=top && cnt[1]<cnt[2];i++)pop(stk[i]),pop(nex[stk[i]]);

	top=0;
	for(int i=nex[0];i<=n;i=nex[i])if(s[i]==2 && s[nex[i]]==1)stk[++top]=i;
	for(int i=1;i<=top && cnt[0]<cnt[1];i++)
		if(s[pre[stk[i]]]!=0 || s[nex[nex[stk[i]]]]!=0)pop(stk[i]),pop(nex[stk[i]]);

	top=0;
	for(int i=nex[0];i<=n;i=nex[i])if(s[i]==2 && s[pre[i]]==1)stk[++top]=i;
	for(int i=1;i<=top && cnt[0]<cnt[1];i++)
		if(s[nex[stk[i]]]!=0 || s[pre[pre[stk[i]]]]!=0)pop(stk[i]),pop(pre[stk[i]]);
	
	for(int i=1;i<=n;i++)s[i]=rk[s[i]];
	if(cnt[0]==cnt[1] && cnt[1]==cnt[2])for(int i=nex[0];i<=n;i=nex[i])putchar('A'+s[i]);
	puts("");

	return 0;
}


Measured memory_bytes: 16128
n,k=map(int,input().split())
mod=pow(10,9)+7
# max:comb(2*n-1,n-1)

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1]
for i in range( 2, 2*n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if k>=n-1:
  print(cmb(2*n-1,n-1,mod))
else:
  ans=0
  for i in range(k+1):
    ans+=cmb(n,i,mod)*cmb(n-1,i,mod)
    ans%=mod
  print(ans)

Measured memory_bytes: 50832
program ABC152C
    implicit none
    integer::N
    integer,allocatable,dimension(:)::P
    integer::MIN,ANS=0
    integer::i
    read*,N
    allocate(P(N))
    read*,P
    MIN=P(1)
    do i=1,N
        if(MIN>=P(i))then
            MIN=P(i)
            ANS=ANS+1
        endif
    end do
    print"(i0)",ANS
end program ABC152C

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,g;
  cin >> a >> b >> c >> d;
  vector <int> e(a);
  vector <int> f(b);
  for (int i=0;i<a;i++)
    cin >> e.at(i);
  for (int i=0;i<b;i++)
    cin >> f.at(i);
  sort(e.begin(),e.end());
    sort(f.begin(),f.end());
  /*if(e.at(a)<g && g<=f.at(1) && a<g && g<=b)
    cout << "No War";
  else
    cout << "War"*/
  for (int i=c+1;i<=d;i++){
    if(e.at(a-1)<i && i<=f.at(0)){
      cout << "No War" << endl;
    break;
    }
    else if(i==d)
      cout << "War" << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;

int main() {
    abdelrahman010
    ll a , b , k;
    cin >> a >> b >> k;
    ll tmp = min(a , k);
    a -= tmp , k -= tmp;
    cout << a << " " << b - min(k , b);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1000000007;
ll const N=1e6+5;
int main() {
   
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T;T=1;
    // cin>>T;
    while(T--){
   		ll h;cin>>h;
   		ll ans=0;
   		ll k=1;
   		while(h>0){
   			h=h/2;
   			ans=ans+k;
   			k=k*2;
   		}
   		cout<<ans<<endl;
    }
    return 0;   
}
 


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

int main(){
    int n, r;
    while(cin >> n >> r, n != 0){
        vector<int> deck;
        for(int i=1;i<=n;++i)deck.push_back(i);
        for(int i=0;i<r;++i){
            int p, c;
            cin >> p >> c;
            for(int i=0;i<c;++i){
                deck.push_back(deck[n-(p-1+c)+i]);
            }
            deck.erase(deck.begin() + n-(p-1+c), deck.begin() + n-(p-1));
        }
        cout << deck.back() << endl;
    }

    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
using pld = pair<ld, ld>;
const ld INF = 1e3;

bool comp(pld a, pld b) {
	return a.second < b.second;
}

ld closest_pair(pld *a, int n) {
	if (n <= 1) return INF;
	int m = n / 2;
	ld x = a[m].first;
	ld d = min(closest_pair(a, m), closest_pair(a + m, n - m));
	inplace_merge(a, a + m, a + n, comp);
	vector<pld> b;
	for (int i = 0; i < n; i++) {
		if (abs(a[i].first - x) >= d) continue;
		for (int j = 0; j < (int)b.size(); j++) {
			ld dx = a[i].first - b[b.size() - j - 1].first;
			ld dy = a[i].second - b[b.size() - j - 1].second;
			if (dy >= d) break;
			d = min(d, sqrtl(dx * dx + dy * dy));
		}
		b.push_back(a[i]);
	}
	return d;
}

const int MAX = 1e5;

pld ps[MAX];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ps[i].first >> ps[i].second;
	}
	sort(ps, ps + n);
	cout << fixed << setprecision(8) << closest_pair(ps, n) << endl;
	return 0;
}

Measured memory_bytes: 12180
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int x, a;

int main(){
    cin >> x >> a;
    if(x < a){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    cout << n / 3 << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, A, B, M, a[100001], b[100001], c[100001], x[100001], y[100001];
	scanf("%d %d %d", &A, &B, &M);
	for (i = 1; i <= A; i++) scanf("%d", &(a[i]));
	for (i = 1; i <= B; i++) scanf("%d", &(b[i]));
	for (i = 1; i <= M; i++) scanf("%d %d %d", &(x[i]), &(y[i]), &(c[i]));
	
	int a_min = 100001, b_min = 100001, sum_min = 200001;
	for (i = 1; i <= A; i++) {
		if (a[i] < a_min) a_min = a[i];
	}
	for (i = 1; i <= B; i++) {
		if (b[i] < b_min) b_min = b[i];
	}
	for (i = 1; i <= M; i++) {
		if (a[x[i]] + b[y[i]] - c[i] < sum_min) sum_min = a[x[i]] + b[y[i]] - c[i];
	}
	
	if (a_min + b_min < sum_min) printf("%d\n", a_min + b_min);
	else printf("%d\n", sum_min);
	fflush(stdout);
	return 0;
}

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

int main() {
    string s;
    string t;
    cin >> s >>t;
    int cnt=0;
    for(int i=0;i<3;i++){
        char a = s.at(i);
        char b = t.at(i);
        if(a==b)cnt++;
    }
cout << cnt <<endl;
}


Measured memory_bytes: 256
<?php
list($n,$k)= explode(" ", trim(fgets(STDIN)));

$arr = explode(" ", trim(fgets(STDIN)));

$sum = 0;
$accum = [];

foreach ($arr as $key => $val) {
     $sum += ($val+1)/2.0;
     $accum[$key] = $sum;
}

$exp[0] = $accum[$k-1];
for ($i=1; $i < ($n -$k); $i++) {
    $exp[$i] = $accum[$i+$k] - $accum[$i];
}
echo max($exp);

Measured memory_bytes: 37356
#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
	int a, b, t;
	int cnt = 0;

	cin >> a >> b >> t;

	for(int i = 0; a*(i + 1) < t + 0.5; i++){
		cnt += b;
	}
	cout << cnt << endl; 
}

Measured memory_bytes: 384
while True:
    a, b = input().split()
    if b == 'X':
        break

    if '_' in a:
        ans = a.split('_')
    else:
        ans = []
        j = 0
        for i in range(1, len(a)):
            if a[i].isupper():
                ans.append(a[j:i])
                j = i
        ans.append(a[j:])
        
    if b == 'D':
        ans = '_'.join(map(str.lower, ans))
    else:
        ans = ''.join(map(str.capitalize, ans))
        
        if b == 'L':
            ans = ans[0].lower() + ans[1:]

    print(ans)


Measured memory_bytes: 5560
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
    l = [int(x) for x in list(str(i))]
    #print(l)
    sum = 0
    for j in l:
        sum+=j
        #print(sum)
    if a<=sum<=b:
        ans+=i
        #print("---")
        #print(ans)

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#define N 1000000
using namespace std;

bool x[N + 1];

void setn();
int cntham(int m, int n);

int main(){
	setn();
	int m, n;
	while(cin >>m){
		if(m == 0) break;
		cin >>n;
		cout <<cntham(m, n) <<endl;
	}
	return 0;
}

void setn(){
	for(int i = 1; i <= N; i *= 2){
		x[i] = true;
	}
	for(int i = 1; i <= N; ){
		if(i * 3 <= N) x[i * 3] = true;
		if(i * 5 <= N) x[i * 5] = true;
		i++;
		while(x[i] == false && i < N){
			i++;
		}
	}
}

int cntham(int m, int n){
	int cnt = 0;
	for(int i = m; i <= n; i++){
		if(x[i] == true) cnt++;
	}
	return cnt;
}

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

using namespace std;
#define int long long
#define N 666666
int arr[N];
signed main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) scanf("%lld",&arr[i]);
    int ans=0;
    int add=0;
    arr[n+1]=-1;
    for(int i=1;i<=n;i++){
    
    		ans+=max(0ll,(arr[i]-add));
			add=arr[i];
		
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 256
M=10**9+7;F=[pow(X,M-2,M)for X in range(2*10**5)];H,W,A,B=map(int,input().split());Z=C=1
for I in range(H-1):Z=C=C*(W+H-B-2-I)*F[I+1]%M
for I in range(1,H-A):C=C*(B-1+I)*F[I]*(H-I)*F[W+H-B-1-I]%M;Z=(Z+C)%M
print(Z)

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

int dp[222][111];

int Grundy(int h,int w){
  int &g=dp[h][w];
  
  if(g!=-1)return g;
  if(h==0&&w==0)return g=0;

  set<int>V;

  if(h)V.insert(Grundy(h-1,w));
  for(int i=1;i<=min(h,w);i++)V.insert(Grundy(h,w-i));
  if(w)V.insert(Grundy(h+1,w-1));

  g=0;
  while(V.count(g))++g;
  return g;
}
int main(){
  memset(dp,-1,sizeof(dp));
  int n,ans=0;
  cin>>n;
  r(i,n){
    int a,b;
    cin>>a>>b;
    ans^=Grundy(a,b);
  }
  cout<< (ans?0:1) <<endl;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

using ll = long long;
using namespace std;

int main() {
    vector<ll> v;
    ll tmp;
    REP(i, 3){
        cin >> tmp;
        v.push_back(tmp);
    }
    SORTASC(v);

    cout << setprecision(20) << v[0]+v[1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

int n,k,ans;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

inline void file() {
	freopen("ARC091F.in","r",stdin);
	freopen("ARC091F.out","w",stdout);
}

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

int main() {
//	file();
	int tt=read();
	while (tt--) {
		n=read(); k=read();
		while (n%k>0) n-=(n/k+1)*((n%k-1)/(n/k+1)+1);
		ans^=n/k;
	}
	if (ans) puts("Takahashi");
	else puts("Aoki");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, P = 0, W = 0, G = 0, Y = 0, cou = 0, i;
    string S;
    
    cin >> N;
    
    for(i = 0; i < N; i++){
    cin >> S;
    
    if(S == "P"){
        P = P + 1;
        
        if(P == 1)
        cou = cou + 1;
        
        else
        continue;
    }
    
    if(S == "W"){
        W = W + 1;
        
        if(W == 1)
        cou = cou + 1;
        
        else
        continue;
    }
    
    if(S == "G"){
        G = G + 1;
        
        if(G == 1)
        cou = cou + 1;
        
        else
        continue;
    }
    
    if(S == "Y"){
        Y = Y + 1;
        
        if(Y == 1)
        cou = cou + 1;
        
       else
       continue;
    }
    }
    if(cou == 3)
    cout << "Three" << endl;
    
    else
    cout << "Four" << endl;
}


Measured memory_bytes: 3604
#include<stdio.h>
#define MAX 500000
#define SMAX 1000000000
void merge(int *,int,int ,int);
void mergesort(int *,int,int);

int c=0;
int main(){
  int n,s[MAX],i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  mergesort(s,0,n);
  for(i=0;i<n;i++){
    printf("%d",s[i]);
    if(i<n-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",c);
  return 0;
}

void merge(int *s,int l,int m,int r){
  int n1=m-l,n2=r-m;
  int sl[n1+1],sr[n2+1];
  int i,j,k;

  for(i=0;i<n1;i++)
    sl[i]=s[l+i];
  for(i=0;i<n2;i++)
    sr[i]=s[m+i];

  sl[n1]=SMAX;
  sr[n2]=SMAX;
  
  i=0;
  j=0;
  for(k=l;k<r;k++){
    c++;
    if(sl[i]<=sr[j]){
      s[k]=sl[i];
      i++;
    }else{
      s[k]=sr[j];
      j++;
    }
  }
}

void mergesort(int *s,int l,int r){
  int m;
  if(l+1<r){
    m=(l+r)/2;
    mergesort(s,l,m);
    mergesort(s,m,r);
    merge(s,l,m,r);
  }
}



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

int main(){

    int n;cin>>n;
    int a[n];

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

    int o[n];
    for(int i=0;i<n;i++){
        o[a[i]-1]=i+1;
    }
    for(int i=0;i<n;i++){
        cout<<o[i]<<" ";
    }
    
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    int N = 0;
    while(cin >> N){
        vector<string> vs(N);
        for(auto& s : vs) cin >> s;
        int res = 0;
        for(int s=0;s<N;s++){
            bool ok = true;
            for(int j=0;j<N;j++){
                for(int k=j+1;k<N;k++){
                    if(vs[(j+s)%N][k] != vs[(k+s)%N][j]) ok = false;
                }
            }
            if(ok) res += N;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 384
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
//#include<algorithm>
//#include<iostream>
#include<cmath>
//using namespace std;
#define MAXN 100000
int n,k;
int main()
{
	scanf("%d%d",&n,&k);
	int pos,MIN=int(1e8);
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		if(MIN>a) MIN=a,pos=i;
	}
	printf("%d\n",(int)ceil((n-1)/(k-1.0)));
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>  
using namespace std;  
int main() { 	
	int a,b,c,d,e; 	
	scanf("%d %d", &a, &b); 	
	if(a-b>=0){
		printf("%d", a-b);
	}
	if(a-b<0){
		printf("0");
	}
	
} 

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

using namespace std;

int main(){
  string s;
  cin >> s;
  s=s.substr(0, s.size()-1);
  int max=0;
  for (int i=1; i<=s.size(); i++) {
    if (s.substr(0, i)==s.substr(i, i)) max=i*2;
  }

  printf("%d\n", max);
  return 0;
}

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


int main() {

  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(201);
  for (auto &i : a){
    cin >> i;
    i += 100;
  }
  for (int i=0; i<=200; i++){
    for (auto j : a){ 
      b.at(i) += (i - j) * (i - j);
    }
  }
  sort(b.begin(),b.end());
  cout << b.at(0);
  

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
  double xa,ya,xb,yb,xc,yc,xd,yd;
  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
	      &xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF){
    xb-=xa;
    yb-=ya;
    xd-=xc;
    yd-=yc;
    if(fabs(xb*xd+yb*yd)<1e-10)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main() {
  string s;
  cin >> s;
  bool ans = true;
  rep(i,s.size()){
    if(i%2==0 && s[i]=='L') ans = false;
    if(i%2!=0 && s[i]=='R') ans = false;
  }
  yn(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define sp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 
}

void out(vector<int> &v){
	for(int x : v) cout << x << " ";
}
ll h[N];
vector<pii> g[N];
void solve()
{
	int n;
	cin >> n;
	rep(i, n - 1){
		int x, y, z;
		cin >> x >> y >> z;
		g[--x].pb({--y, z});
		g[y].pb({x, z});
	}
	ll Q, k;
	cin >> Q >> k;
	int s = k - 1;
	const ll INF = 1e18;
	vector<ll> d (n, INF),  p (n);
	d[s] = 0;
	set < pair<int,int> > q;
	q.insert (make_pair (d[s], s));
	while (!q.empty()) {
		int v = q.begin()->second;
		q.erase (q.begin());
		for (size_t j=0; j<g[v].size(); ++j) {
			int to = g[v][j].first,
				len = g[v][j].second;
			if (d[v] + len < d[to]) {
				q.erase (make_pair (d[to], to));
				d[to] = d[v] + len;
				p[to] = v;
				q.insert (make_pair (d[to], to));
			}
		}
	}
	while(Q--){
		int l, r;
		cin >> l >> r;
		cout << d[l - 1] + d[r - 1] << '\n';
	}
}

 
int main()
{
	// freopen("crosses.in", "r", stdin);
	// freopen("crosses.out", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 36724
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	auto f = [&](LL x) { OUT(x); exit(0); };
	
	IN(int, n);
	vector<LL> a(n);
	cin >> a;
	if(count(ALL(a), 0) > 0) { f(0); }
	
	LL INF = 1'000'000'000'000'000'000;
	LL p = 1;
	RF(e, a) {
		if(1.0 * p * e > 2 * INF) { f(-1); }
		p *= e;
		if(p > INF) { f(-1); }
	}
	f(p);
}


Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)	
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7  ;
#define ld long double
#define MAX (int)(330)


void deal(){
	ll n , k;
	cin>>n>>k;
	vector<vector<ll> > dp(n+1, vector<ll>(k+1,0));
	vector<vector<ll> > sms(n+1, vector<ll>(k+1,0));
	dp[0][0] = 1;
	forj(k+1)
		sms[0][j] = 1;
	for(ll i =1; i<=n; i++){
		ll ai;
		cin>>ai;
		forj(k+1){
			ll dif = 0;
			if(j>=ai+1)
				dif = sms[i-1][j-ai-1];
			dp[i][j] = (sms[i-1][j] - dif + modulo)%modulo;
//			cout<<" dp["<<i<<"]["<<j<<"]  =  "<<dp[i][j]<<endl;
		}
		sms[i][0] = dp[i][0];
		for(ll j =1; j<=k; j++)
			sms[i][j] = (sms[i][j-1] + dp[i][j])%modulo;
	}
	cout<<dp[n][k];
}
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
/*
 
5 1
1 2 3 4 5


*/

Measured memory_bytes: 159088
#include<stdio.h>
#include<string.h>
 
int main(){
    char str[1000],order[8];
    char temp,rep[1000];
    int k,n;
    int a,b;
    scanf("%s",str);
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s %d %d",order,&a,&b);
        if(strcmp(order,"print")==0){
            for(int j=a;j<=b;j++){
                printf("%c",str[j]);
                if(j==b) printf("\n");
            }
        }else if(strcmp(order,"reverse")==0){
            k=(b-a)/2;
            for(int j=a;j<=a+k;j++){
                temp=str[j];
                str[j]=str[a+b-j];
                str[a+b-j]=temp;
            }
        }else if(strcmp(order,"replace")==0){
            scanf("%s",rep);
            for(int j=a,l=0;j<=b;j++,l++){                
                str[j]=rep[l];
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2704
#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(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string S,T; cin >> S >> T;
    if(S.size() < T.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    vector<string> ans;
    REP(i,S.size() - T.size()+1){
        bool ok = true;
        REP(j,T.size()){
            if(S[i+j]!='?'){
                if(S[i+j] != T[j]) ok = false;
            }
        }
        if(ok){
            string s = S;
            
            REP(j,T.size()){
                s[i+j] = T[j];
            }
            REP(k,s.size()){
                if(s[k]=='?') s[k] = 'a';
            }
            ans.push_back(s);
        }
    }
    if(ans.size() == 0){
        cout << "UNRESTORABLE" << endl;
    }else{
        sort(ALL(ans));
        cout << ans[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>

using namespace std;

using ULL = int64_t;

int field[500][500];

int N = 0;

int ope[250000][4] = {};

int main(void) {

	int H, W;
	cin >> H >> W;


	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> field[i][j];
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W - 1; j++) {
			if (field[i][j] % 2 == 1) {
				ope[N][0] = i + 1;
				ope[N][1] = j + 1;
				ope[N][2] = i + 1;
				ope[N][3] = j + 2;
				N++;
				field[i][j]--;
				field[i][j + 1]++;
			}
		}
	}
	for (int i = 0; i < H - 1; i++) {
		if (field[i][W - 1] % 2 == 1) {
			ope[N][0] = i + 1;
			ope[N][1] = W;
			ope[N][2] = i + 2;
			ope[N][3] = W;
			N++;
			field[i][W - 1]--;
			field[i + 1][W - 1]++;
		}
	}

	cout << N << endl;
	for (int i = 0; i < N; i++) {
		cout << ope[i][0] << " " << ope[i][1] << " " << ope[i][2] << " " << ope[i][3] << endl;
	}

	return 0;
}

Measured memory_bytes: 6912
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            while(true){
                String line = reader.readLine();
                if(line.equals("0")){
                    break;
               }
               char[] c = line.toCharArray();
                int sum = 0;
                for(char x:c){
                    int a = x - '0';
                    sum += a;
                }
                System.out.println(sum);
            }
        }catch(IOException e){

        }
    }
}


Measured memory_bytes: 24168
#include<stdio.h>//////////AOJ0037
                               int
i,j,w[5][5];char*p,b[1<<7];;   int
F(int(v)){scanf("%s",b);for(   p=b
;*p;++p                 ){w[   p-b
+1-v][j   +v]|=((w[p-   b][j   ]|=
(*p==49   )<<3-v)&8>>   v)>>   2;}
return(   j+=v          );/*   */}
main(){   for(   ;4-F   (0);   F(1
));for(   p=b,   i=j=   (*b=   3)^
3;i+=""   "BA"          "BC"   [*b
]-66,j=   (*b)["ABCB"]-66+j,   *++
p="ULDR   "[*b],i+j;)for((*    b+=
1)&=~4;                        !(w
[i][j]&(1<<*b));(*b+=3)&=3);return
!puts(b+1);}/*May2018,tw:@siikya*/



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

main() {
    int X; cin >> X; int ans=0;
    for(int i=2;i<=10;i++){
        for(int j=1;j<=32;j++){
            ll a=(ll)pow(j,i);
            if(X<a)continue;
            else ans=max(ans,(int)a);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
int n;
int main()
{
    scanf("%d",&n);
    ll ans=0;
    for(int i=1;i<n;i++)
    {
        int x,y;scanf("%d%d",&x,&y);
        if(x>y) swap(x,y);
        ans+=(ll)x*(n-y+1);
    }
    ll res=0;
    for(int i=1;i<=n;i++)
        res+=(ll)i*(n-i+1);
    printf("%lld\n",res-ans);
}


Measured memory_bytes: 3812
#include <iostream>

using namespace std;
 int main(){
    int n,m;
    int sum=0;
    cin >>n >>m;
    int ary[m]={0};
    for(int i=0; i<m;i++){
        cin >>ary[i];
    }
    for(int i=0; i<m;i++) sum+=ary[i];
int re=0;
re=n-sum;
if(re<0)re=-1;
cout << re <<endl;
return 0;
 }

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
long long f(long long x)
{
	if(x==1)
		return 1;
	else
		return 2*f(x/2)+1;
}
int main()
{
	long long x;
	cin>>x;
	cout<<f(x)<<endl;
	return 0;
}

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

int dp[500005][4];
char buf[500005];
int arr[500005];
int n, l, ans;

int slv(int at, int msk)
{
	if (at == l) return 0;
	if (dp[at][msk]) return dp[at][msk];
	dp[at][msk] = slv(at+1, arr[at]>(msk>>1));
	if (at > 0 && (msk&1))
	{
		dp[at][msk] = max(dp[at][msk], slv(at+1, 0)+arr[at]-(msk>>1));
		dp[at][msk] = max(dp[at][msk], slv(at+1, 1)+arr[at]-(msk>>1)-1);
	}
	if (at+1 < l && arr[at+1] > 0)
		dp[at][msk] = max(dp[at][msk], slv(at+1, 2)+arr[at]-(msk>>1));
	return dp[at][msk];
}

int main()
{
	scanf("%d%s", &n, buf);
	if (n <= 2)
	{
		printf("0\n");
		return 0;
	}
	for (int i = 0;i < n;i++) buf[i] -= '0';
	buf[n++] = 0;
	buf[n++] = 0;
	for (int i = 0;i < n;i++)
		if (buf[i]) arr[l]++;
		else if (buf[i+1]) l++;
		else
		{
			l++;
			for (int j = 0;j < l;j++) for (int k = 0;k < 3;k++) dp[j][k] = 0;
			ans += slv(0, 0);
			do arr[--l] = 0; while (l);
		}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2432
#include"bits/stdc++.h"
using namespace std;
int main(){
    char str[1202];
    memset(str,'+',sizeof(str));
    int i=0;
    str[i]=getchar();
    while(str[i]==0x20||str[i]<=122&&str[i]>=33){
        if(str[i]>=97){
            str[i]=str[i]-32;
        }
        else if(str[i]>=65){
            str[i]=str[i]+32;
        }
        cout<<str[i];
        i++;
        str[i]=getchar();
    }
    cout<<endl;
}
//Fair, later, occasionally cloudy.
//Fair, later, occasionally cloudy.

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
#define ll long long
#define     f           first
#define     s           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<long long,long long>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)

vector<ll> adj[N];
bool visited[N];
int main()
{

    int n;
    cin>>n;
    int a[100][2];
    for(int i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1];
    }
    int flag=0,ans=INT_MIN;
    for(int i=0;i<n;i++)
    {
        if(a[i][0]==a[i][1])
            flag++;
        else
            flag=0;
        ans=max(ans,flag);
    }
    if(ans>=3)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
 //getch();
    return 0;
}

Measured memory_bytes: 8324
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
list=[a,b,c,d,e]
if a%10==0 and b%10==0 and c%10==0 and d%10==0 and e%10==0:
    print(sum(list))
    exit()
min=100
for i in range(len(list)):
    if list[i]%10!=0 and list[i]%10<min:
        memo=list[i]
        min=list[i]%10
flag=0
for k in range(len(list)):
    if list[k]==memo and flag==0:
        flag=1
    else:
        while list[k]%10!=0:
            list[k]+=1
print(sum(list))


Measured memory_bytes: 3064
n = int(input())
w = list(map(int, input().split()))
l = [0]*(n - 1)
for t in range(1, n):
    s1, s2 = 0, 0
    for i in range(t):
        s1 += w[i]
    for i in range(t, n):
        s2 += w[i]
    l[t - 1] = abs(s1 - s2)
print(min(l))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,a,b;
    cin>>n>>k;
    ll maki[100001];
    memset(maki,0,sizeof(maki));
    for(int i=0;i<n;i++){
        cin>>a>>b;
        maki[a]+=b;
    }
    ll num=0;
    for(int i=1;i<=100000;i++){
        num+=maki[i];
        if(num>=k){
            cout <<i<<endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 1024
def main():

    a, b, c, d = map(int, input().split())
    #print(a, b, c, d )

    ans = a * c
    ans2 = a * d
    ans3 = b * c
    ans4 = b * d
    
    if ans2 > ans:
        ans = ans2
    
    if ans3 > ans:
        ans = ans3

    if ans4 > ans:
        ans = ans4

    print(ans)

main()

Measured memory_bytes: 9172
n = int(input())
l = [0] * (10 ** 5)
a = list(map(int, input().split()))
for i in a:
    l[i-1]+=1

ans = sum(a)

q = int(input())

for _ in range(q):
    b, c = map(int, input().split())
    l[c - 1] += l[b - 1]
    ans += (c-b)*l[b-1]
    print(ans)
    l[b-1] = 0


Measured memory_bytes: 21824
var
	u,L,i,a,c:Longint;
begin
	read(L);
	u:=L;
	while u>0 do begin
		inc(c);
		inc(a,u mod 2);
		u:=u div 2;
	end;
	writeln(c);writeln(c*2-3+a);
	a:=1;
	u:=L;
	for i:=1 to c-1 do begin
		writeln(i);
		writeln(i+1);
		writeln(0);
		writeln(i);
		writeln(i+1);
		writeln(a);
		if L mod 2>0 then begin
			writeln(i);
			writeln(c);
			u:=u-a;
			writeln(u);
		end;
		L:=L div 2;
		a:=a*2;
	end;
end.


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

const int MOD = 1000000007;
const int N = 1000005;

int n;
int a[N];

vector<int> primes[N];

bool exists[N];

void sieve() {
  for (int i = 2; i < N; ++i) {
    if (primes[i].size() > 0) continue;
    for (int j = i; j < N; j += i) {
      primes[j].push_back(i);
    }
  }
}

int gcd(int x, int y) {
  while (y) {
    int t = x;
    x = y;
    y = t % y;
  }

  return x;
}

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

  bool pairwise = true;
  int gcdall = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    gcdall = gcd(gcdall, a[i]);

    for (int p: primes[a[i]]) {
      if (exists[p]) pairwise = false;
      else exists[p] = true;
    }
  }

  if (pairwise) printf("pairwise");
  else if (gcdall == 1) printf("setwise");
  else printf("not");

  printf(" coprime\n");
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    // printf("Case #%d: ", tc+1);
    solve();
  }
  return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long H, long long A){
    cout << (H / A + (H % A == 0 ? 0 : 1)) << endl;
}

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


Measured memory_bytes: 256
var n,m,i   :integer;
    l,r,lm,rm :integer;
begin
  readln(n,m);
  lm:=0; rm:=100002;
  for i:=1 to m do 
  begin
    readln(l,r);
    if lm<l then lm:=l;
    if rm>r then rm:=r
  end;
  if lm<=rm then writeln(rm-lm+1)
  else writeln(0)
end.

Measured memory_bytes: 128
N, K = map( int, input().split() )
A = list( map(int, input().split()) )


X = 0
k = 1 << 41  # ある位置にのみbitが立っている

# 上のbitからXを求める
for _ in range(41):  # _がfor文中に使われないときに用いられるnotation
    k = k >> 1
    if X + k > K: continue  # 計算する値がKより大きい場合は答えにならない
    
    # A[i]の内kと同じ位置にbitが立っているものの数を求める
    cnt = 0
    for i in range(N):
        if A[i] & k: cnt += 1
    
    # cnt < len(A) - cnt ならばそのビットは立てた方が大きい
    if cnt < len(A)/2: X += k

ans = 0
for i in range(N):
    ans += A[i] ^ X  # 排他的論理和^
    
print( ans )

Measured memory_bytes: 14248
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin >> a >> b;
    int ans = 0;
    rep(i,2){
        if(a>b){
            ans+=a;
            a--;
        }
        else{
            ans+=b;
            b--;
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
 
	ll n,m;
	cin>>n>>m;
	ll ans=0;
	ans+=(n*(n-1))/2;
	ans+=(m*(m-1))/2;
	cout<<ans;
 
	return(0);
}

Measured memory_bytes: 256