akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}
template <typename T>inline T ModInv (T b,T m)
{
    return BMOD(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}


//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....



//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
int dx[]= {-1,1,0,0};
int dy[]= {0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
/////////////


string sa,sb,sc;

int main()
{
    cin>>sa>>sb>>sc;
    int nw=1,p1=0,p2=0,p3=0;
    while(1)
    {
        if(nw==1)
        {
            if(p1>=sa.size())
            {
                cout<<"A"<<endl;
                break;
            }
            if(sa[p1]=='a'){p1++;nw=1;}
            else if(sa[p1]=='b'){p1++;nw=2;}
            else {p1++;nw=3;}
        }
        else if(nw==2)
        {
            if(p2>=sb.size())
            {
                cout<<"B"<<endl;
                break;
            }
            if(sb[p2]=='a'){p2++;nw=1;}
            else if(sb[p2]=='b'){p2++;nw=2;}
            else {p2++;nw=3;}
        }
        else{
            if(p3>=sc.size())
            {
                cout<<"C"<<endl;
                break;
            }
            if(sc[p3]=='a'){p3++;nw=1;}
            else if(sc[p3]=='b'){p3++;nw=2;}
            else {p3++;nw=3;}
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    unordered_map<int, int> m;
    for(int i = 1;; i++){
        if(m[a*i%b]){
            break;
        }else{
            m[a*i%b]++;
        }
    }
    for(auto i: m){
        if(i.first == c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
n = int(input())

"""親情報を入れる'p'、子情報を入れる'c'、深さを記録する'd'の、3つの辞書を作成"""
p, c, d = {}, {}, {}

for i in range(n):
    num, *children = input().split()
    c[num] = children
    for j in c[num]:
        if j != '-1':
            p[j] = num

def checkdepth(num, depth):
    d[num] = depth
    for i in c[num]:
        if i != '-1':
            checkdepth(i, depth+1)

"""高さを調べる関数。heightの引数には常に0を渡す"""
def checkheight(num, height):
    if c[num][0] != '-1':
        h1 = checkheight(c[num][0], height+1)
    else:
        h1 = height
    if c[num][1] != '-1':
        h2 = checkheight(c[num][1], height+1)
    else:
        h2 = height
    return max(h1, h2)

root = (set(c) - set(p)).pop()
p[root] = '-1'
checkdepth(root, 0)

def checksibling(num):
    if p[num] != '-1':
        for i in c[p[num]]:
            if i != '-1' and i != num:
                return i
                break
    return '-1'

def checkdegree(num, degree=0):
    for i in c[num]:
        if i != '-1':
            degree += 1
    return degree

for i in range(n):
    i = str(i)
    sibling = checksibling(i)
    degree = checkdegree(i, 0)
    if p[i] == '-1':
        nodetype = 'root'
    elif degree == 0:
        nodetype = 'leaf'
    else:
        nodetype = 'internal node'
    print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(i, p[i], sibling, degree, d[i], checkheight(i, 0), nodetype))


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

int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	if(1 < a[n - 1] - a[0]){
		cout << "No" << endl;
		return 0;
	}
	if(a[n - 1] - a[0] == 0) cout << (a[0] == n - 1 || a[0] <= n / 2 ? "Yes" : "No") << endl;
	else if(a[n - 1] - a[0] == 1){
		int p = 0, q = 0;
		for(int i = 0; i < n; i++) (a[i] == a[0] ? p : q)++;
		cout << (p < a[n - 1] && 2 * a[n - 1] <= 2 * p + q ? "Yes" : "No") << endl;
	}else cout << "No" << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    char c;
    cin >> A >> c >> B;
    if (c == '+') cout << A + B << endl;
    else cout << A - B << endl;

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll K;
    cin >> K;
    queue<ll> que;
    rep(i, 10) {
        if (i == 0) continue;
        que.push(i);
    }

    ll cnt = 0;
    while (1) {
        ll now = que.front();
        que.pop();
        cnt++;
        if (cnt == K) {
            cout << now << "\n";
            return 0;
        }

        if (now % 10 != 0) que.push(now * 10 + now % 10 - 1);
        que.push(now * 10 + now % 10);
        if (now % 10 != 9) que.push(now * 10 + now % 10 + 1);
    }

    return 0;
}

Measured memory_bytes: 5088
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
int dp[25];
int main() {
    int n; cin >> n;
    int a[25][2];
    for(int i = 0; i < n; ++i) cin >> a[i][0];
    for(int i = 0; i < n; ++i) cin >> a[i][1];
    int sum = 0;
    for(int i = 0; i < n; ++i){
        if(a[i][0] > a[i][1]) sum += a[i][0] - a[i][1];
    }
    cout << sum << endl;
	return 0;
}

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

int main() {
  int a;
  cin >> a;
  if(a % 2 == 0)
    cout << (a / 2) * (a / 2) << endl;
  else
    cout << (a / 2) * (a / 2 + 1) << endl;
}

Measured memory_bytes: 256
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

class CombMod:
	def __init__(self, N):
		self.fact = [1]
		self.rfact = [1]
		for i in range(1, N+1):
			self.fact.append(self.fact[i-1]*i % mod)
			self.rfact.append(pow(self.fact[i], mod-2, mod))

	def comb(self, n, k):
		return self.fact[n]*self.rfact[k]*self.rfact[n-k] % mod

	def perm(self, n, k):
		return self.fact[n]*self.rfact[n-k] % mod

N, M = rl()
cm = CombMod(M)

ans = 0
for i in range(0, N+1):
	ans += (-1)**i * cm.perm(M, i) * (cm.perm(M-i, N-i)**2) * cm.comb(N, i)
	ans = ans % mod
print(ans)


Measured memory_bytes: 149880
import sys
def input():
	return sys.stdin.buffer.readline()[:-1]

sys.setrecursionlimit(10**7)

class SCC():
	def __init__(self, n):
		self.n = n
		self.adj = [[] for _ in range(self.n)]
		self.inv = [[] for _ in range(self.n)]
		self.post_order = []
		self.visited = [False for _ in range(self.n)]
		self.dag_v_to_num = [-1 for _ in range(self.n)]
		self.dag_num_to_v = []
		return

	def add_edge(self, u, v):
		self.adj[u].append(v)
		self.inv[v].append(u)
		return

	def dfs1(self, i):
		for j in self.adj[i]:
			if not self.visited[j]:
				self.visited[j] = True
				self.dfs1(j)
		self.post_order.append(i)
		return

	def dfs2(self, i, num):
		self.dag_num_to_v[-1].append(i)
		self.dag_v_to_num[i] = num
		for j in self.inv[i]:
			if not self.visited[j]:
				self.visited[j] = True
				self.dfs2(j, num)
		return

	def make_scc(self):
		for i in range(self.n):
			if not self.visited[i]:
				self.visited[i] = True
				self.dfs1(i)

		self.visited = [False for _ in range(self.n)]
		num = 0
		for i in range(self.n-1, -1, -1):
			if not self.visited[self.post_order[i]]:
				self.visited[self.post_order[i]] = True
				self.dag_num_to_v.append(list())
				self.dfs2(self.post_order[i], num)
				num += 1

		return self.dag_v_to_num, self.dag_num_to_v


class TwoSAT(SCC):
	"""
	node 2*i  : x_i
	node 2*i+1: not x_i
	"""
	def __init__(self, n):
		super().__init__(2*n)
		return

	def add_clause(self, i, f, j, g):
		super().add_edge(2*i + (1^f), 2*j + g)
		super().add_edge(2*j + (1^g), 2*i + f)
		return

	def satisfy(self):
		topol, _ = super().make_scc()
		res = []
		for i in range(0, self.n, 2):
			x, y = topol[i], topol[i+1]
			if x == y:
				return False, None
			elif x > y:
				res.append(False)
			else:
				res.append(True)
		return True, res

n, d = map(int, input().split())
ts = TwoSAT(n)
flags = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
	for j in range(i+1, n):
		for k in range(4):
			f, g = k//2, k%2
			if abs(flags[i][f] - flags[j][g]) < d:
				ts.add_clause(i, f, j, g)

ok, ans = ts.satisfy()
if not ok:
	print("No")
else:
	print("Yes")
	print(*[f[1^b] for f, b in zip(flags, ans)], sep="\n")

Measured memory_bytes: 10028
#include <iostream>
using namespace std;
int N, Min = 1000000005;
int A[100005];
int cnt[2];
long long sum = 0;
void Read()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
    {
        cin >> A[i];
        sum += A[i] - 1;
        Min = min(Min, A[i]);
        cnt[A[i] % 2]++;
    }
}

int GCD(int a, int b)
{
    int r = a % b;
    while(r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
void Print(int player)
{
    if(player == 0)
        cout << "First\n";
    else
        cout << "Second\n";
}
void Solve(int player)
{
    if(Min == 1)
    {
        if(sum % 2 == 1)
        {
            Print(player);
        }
        else
            Print(1 - player);
        return;
    }
    if(sum % 2 == 1)
    {
        Print(player);
        return;
    }
    if(cnt[1] > 1)
    {
        Print(1 - player);
        return;
    }
    cnt[0] = cnt[1] = 0;
    sum = 0;
    Min = 1000000005;
    int g = A[1];
    if(A[1] % 2 == 1)
        --A[1], g = A[1];
    for(int i = 2; i <= N; i++)
    {
        if(A[i] % 2 == 1)
            --A[i];
        g = GCD(g, A[i]);
    }
    for(int i = 1; i <= N; i++)
    {
        A[i] /= g;
        sum += A[i] - 1;
        Min = min(Min, A[i]);
        cnt[A[i] % 2]++;
    }
    Solve(1 - player);
}
int main()
{
    Read();
    Solve(0);
    return 0;
}


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

int main() {

  int N;
  cin >> N;


  set<int> S;
  for(int i = 0;i < N;i++) {
    int A;
    cin >> A;

    set<int>::iterator it;
    it = S.find(A);
    
    if(it == S.end()) {
      S.insert(A);
    }else {
      S.erase(A);
    }
  }

  cout << S.size() << endl;
  

}



Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
#define MAX_D 10

int d,g;
int p[MAX_D],c[MAX_D];
int ans = INF;

void DFS(int depth, int solve, int sum, int not_complete){
    if(sum >= g){
        ans = min(ans, solve);
        return;
    }
    if(depth == d){
        if(not_complete == -1) return;
        int tmp = (g - sum + 100 * (not_complete + 1) - 1) / (100 * (not_complete + 1));
        if(tmp < p[not_complete]){
            ans = min(ans, solve + tmp);
        }
        return;
    }
    DFS(depth + 1, solve + p[depth], sum + 100 * (depth + 1) * p[depth] + c[depth], not_complete);
    DFS(depth + 1, solve, sum, not_complete);
    if(not_complete == -1){
        DFS(depth + 1, solve, sum, depth);
    }
}

signed main(){
    cin >> d >> g;
    REP(i,d){
        cin >> p[i] >> c[i];
    }
    DFS(0, 0, 0, -1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define hell                         1000000007 
    #define M                            1000000007
    #define Maxi                      10000000000000000
        #define lcm(a,b)                     (a*b)/__gcd(a,b)
        #define ll                           long long

        #define vll                          vector<ll>
        #define vi                           vector<long long>
        #define pll                          vector< pair<ll,ll> >
        #define pb                           push_back
        //#define mp                           make_pair
        #define all(v)                       v.begin(),v.end()
        #define lbnd                         lower_bound
        #define ubnd                         upper_bound
        #define bs                           binary_search
        #define F                            first
        #define S                            second
        #define rep(i,a,b)                   for(i=a;i<b;i++)
        #define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
        #define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
        #define ret(x)                       return cout<<x,0;
        #define dbg(x)                       cout << #x << " is " << x << endl;
        //#define endl                           '\n'
     
     
        // Debug //
     
        #define trace(x)                 cerr << #x << ": " << x << endl;
        #define trace1(x)                cerr << #x << ": " << x << endl;
        #define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
        #define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
        #define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
        #define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
        #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;


    using namespace std;
    
    int main()
    {

          ios_base::sync_with_stdio(false);
          cin.tie(NULL);cout.tie(NULL);
        
          

           ll k,x,i;
           cin>>k>>x;
           vll v;
           v.pb(x);
           int c=1;
           for(i=x-1;i>=-1000000;i--)
           {
            if(c==k)
            {
              break;
            }
            else
            {
              v.pb(i);
              c++;
            }
           }
           c=1;
           for(i=x+1;i<=1000000;i++)
           {
            if(c==k)
            {
              break;
            }
            v.pb(i);
            c++;
           }
           sort(all(v));
           for(auto i:v)
            cout<<i<<" ";


          return 0;


  }

  

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  st s;
  cin >> s;
  cout << (s == "AAA" || s == "BBB" ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    string n;
    
    cin >> n;
    
    for(int i = 0; i < 3; i++){
        
        if(n[i] == '1') n[i] = '9';
        else if(n[i] == '9') n[i] = '1';
        
    }
    
    cout << n << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int MAX_N = 100000;

using ll = long long;

int N;
ll A[MAX_N], S[MAX_N+1];

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

  S[0] = 0;
  rep( i, N )
    scanf( "%lld", A+i );

  std::sort( A, A+N );

  rep( i, N )
    S[i+1] = S[i]+A[i];

  int ans = 0;
  for( int i = N-1; i >= 0; --i )
  {
    ++ans;
    
    if( i && 2*S[i] < A[i] )
      break;
   }

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

  return 0;
}

Measured memory_bytes: 1792
# include "cstdio"
# include "iostream"

inline int read(){
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-') w=-w;
		ch=getchar();
	}
	while(ch>='0' && ch<='9'){
		s=s*10+ch-'0';
		ch=getchar();
	}
	return s*w;
}

inline int n_lowbit(int x){ 
	int count=0;
	while(x){
		if(x&1){
			return count; 
		}
		count++; 
		x>>=1; 
	}
	return count; 
} 

int
	ans,
	N; 

int main(){
	N=read();
	while(N--){
		ans+=n_lowbit(read()); //更新答案 
	}
	printf("%d",ans); 
	return 0; 
} 

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int N;
  cin >> N;
  map< int, int > mp;
  for(int i = 0; i < (1 << N); i++) {
    int v;
    cin >> v;
    mp[-v]++;
  }
  multiset< int > sz;
  sz.emplace(1 << N);
  for(auto p : mp) {
    multiset< int > nxt;
    while(p.second--) {
      if(sz.empty()) {
        cout << "No\n";
        exit(0);
      }
      auto v = *sz.rbegin();
      sz.erase(sz.find(v));
      while(v > 1) {
        v /= 2;
        nxt.emplace(v);
      }
    }

    for(auto t : nxt) sz.emplace(t);


  }
  cout << "Yes\n";
}






Measured memory_bytes: 18688
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // int(gcd(a, b))

def solve():
    n = input()
    nums = list(map(int, input().split()))
    
    ans = 1
    for n in nums:
        ans = lcm(n, ans)
        
    print(ans)

solve()

Measured memory_bytes: 7788
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int a, b; cin >> a >> b;
	cout << max({ (a + b),(a - b),(a*b) }) << '\n';


	

}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
count=0
for i in range(max(h)):
  keep=0
  for j in range(0,n):
    if keep==0:
      if h[j]!=0:
        keep=h[j]
        count+=1
        h[j]-=1
    else:
      keep=h[j]
      if h[j]>=1:
        h[j]-=1
    
print(count)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void) {
	int A, B;
	int sum;
	char buf[128];
	
	fgets(buf,128,stdin);
	sscanf(buf,"%d %d",&A,&B);
	
	sum = A + B;
	
	if(sum >= 10) {
	 	printf("error");
	} else {
		printf("%d",sum);
	}
	printf("\n");
}

Measured memory_bytes: 128
#!/usr/bin/env python
# coding: UTF-8

import math, sys
if sys.version_info[0]<3: input=raw_input

class StandardInput:

    def stdin_string(self):
        self.s=str(input().rstrip())
        return self.s

    def stdin_integer(self):
        self.n=int(input().rstrip())
        return self.n

    def stdin_array(self):
        self.arr=input().rstrip().split()
        return self.arr

    def stdin_integer_array(self):
        self.arr=list(map(int,input().rstrip().split()))
        return self.arr

def test(arr):
    a,b,h,m=arr
    ar=2*math.pi*( h/12 + m/60/12 )
    br=2*math.pi*( m/60 )
    return math.sqrt( ( a*math.cos(ar) - b*math.cos(br) )**2 + ( a*math.sin(ar) - b*math.sin(br) )**2 )

def main():
    obj=StandardInput()
    arr=obj.stdin_integer_array()
    print(test(arr))
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 9492
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
  int N;
  cin>>N;
  int x[N],y[N],h[N];;
  for (int i=0;i<N;i++){
    cin>>x[i]>>y[i]>>h[i];
  }
  int cx,cy,H;
  int h1,h2;
  bool flag=true;
  bool flag2=true;
  int l=0;
  while (flag2) {
    if (h[l]==0){
      ++l;
    }
    else{
      flag2=false;
    }
  }
  for (int j=0;j<=100;j++){
    for (int k=0;k<=100;k++){
      flag=true;
      h1=h[l]+abs(x[l]-j)+abs(y[l]-k);
      for (int i=0;i<N;i++){
        h2=h[i]+abs(x[i]-j)+abs(y[i]-k);
        if (h2==h1&&h2>0){
          flag=flag&&true;
        }
        else if (h[i]==0&& h1-h2<0){
          flag=flag&&true;
        }
        else{
          flag=flag&&false;
        }
      }
      if (flag==true){
        cx=j;
        cy=k;
        H=h1;
      }
    }
  }
  cout<<cx<<" "<<cy<<" "<<H;
  return 0;
}


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

#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'

int main()
{
 fastIO();
	
	long long n , k , min=0 ;
	cin>>n>>k;
	long long arr[n];
	for(int i=0; i<n; i++)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n);
	
	for(int i=0; i<k; i++)
	{
		min+=arr[i];
	}
	cout<<min<<endl;
	 

return 0;
}


Measured memory_bytes: 3612
def max(a, b)
  a > b ? a : b
end
N = gets.to_i
ABC = N.times.map{gets.split.map(&:to_i)}

dp = Array.new(N){Array.new(3, 0)}

dp[0] = ABC[0]
1.upto(N - 1) do |i|
  3.times do |j|
    3.times do |nj|
      next if j == nj
      dp[i][nj] = max(dp[i][nj], dp[i - 1][j] + ABC[i][nj])
    end
  end
end
p dp[N - 1].max

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

int main(void){
        int N;
        cin >> N;
        int D[N];
        rep(i,N) cin >> D[i];
        int M;
        cin >> M;
        int T[M];
        rep(i,M) cin >> T[i];

        sort(D,D+N);
        sort(T,T+M);

        int k = 0;
        rep(i,M){
                while (D[k] < T[i]) {
                        if (k >= N) {
                                cout << "NO" << endl;
                                return 0;
                        }
                        k++;
                }

                if (D[k] == T[i]) k++;
                else if (D[k] > T[i]) {
                                cout << "NO" << endl;
                                return 0;
                }
        }

        cout << "YES" << endl;

        return 0;
}

Measured memory_bytes: 5124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}

ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){ if(b==0) return a; return gcd(b, a%b);}

int main(){
    fast_io

    int n;
    cin>>n;
    int A[20];
    int x[20][20];
    int y[20][20];
    
    rep(i,n){
        cin>>A[i];
        rep(j,A[i]){
            cin>>x[i][j]>>y[i][j];
            x[i][j]--;
        }
    }
    int ans=0;
    rep(bits, 1<<n){
        bool ok=true;
        bitset<18> bs(bits);
        rep(i,n){
            if(!bs[i])continue;
            rep(j,A[i]){
                if(bs[x[i][j]]^y[i][j]) ok=false;
            }
        }
        if(ok) ans=max(ans, (int)bs.count());
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
S = str(input())
tmp1 = "01" *100000
tmp2 = "10" *100000
count = 0
if S[0] == "0":
    for i in range(len(S)):
        if tmp1[i] != S[i]:
            count += 1
else:
    for i in range(len(S)):
        if tmp2[i] != S[i]:
            count += 1
print(count)

Measured memory_bytes: 3504
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;



int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    int A[3];
    inputArray(A,3);
    int tmp;
    sort(A,A+3);
    int cost = abs(A[1]-A[0]);
    cost += abs(A[2] - A[1]);
    printf("%d\n",cost);
    //printf("%d:%d:%d",A[0],A[1],A[2]);
}


Measured memory_bytes: 256
const N=parse(Int,readline())
const P=map(x->parse(Int,x),split(readline()))
const A=zeros(Int,N)
const nxt=zeros(Int,N+2)
const prv=zeros(Int,N+2)
function init()
	for i=1:N
		A[P[i]]=i
	end
	for i=1:N+2
		nxt[i]=min(i+1,N+2)
		prv[i]=max(i-1,1)
	end
end
init()
function main()
	ans=0
	for p=1:N-1
		i=A[p]+1
		ans+=p*((nxt[nxt[i]]-nxt[i])*(i-prv[i])+(prv[i]-prv[prv[i]])*(nxt[i]-i))
		prv[nxt[i]]=prv[i]
		nxt[prv[i]]=nxt[i]
	end
	println(ans)
end
main()

Measured memory_bytes: 117608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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;
}

int main(){
    int i,j;
    int a,b;
    while(1){
        cin>>a>>b;
        if(a==0) break;
        int n;
        cin>>n;
        VVI v(20,VI(20,1));
        VVI ans(20,VI(20,0));
        for(i=0;i<n;i++){
          int x,y;
          cin>>x>>y;
          v[x][y]=0;  
        }
        ans[1][1]=1;
        for(i=1;i<=a;i++){
            for(j=1;j<=b;j++){
                if(v[i][j]) {
                    ans[i][j]+=ans[i-1][j];
                    ans[i][j]+=ans[i][j-1];
                }
            }
        }
        cout<<ans[a][b]<<endl;

    }

}


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

int main(){
  int N, w_num = 0, ans = 0;
  cin >> N;
  
  string C;
  cin >> C;
  
  for (int i = 0; i < N; i++){
	if (C.at(i) == 'W'){
      w_num++;
    }
  }
  
  for (int i = N - 1; i >= N - w_num; i--){
    if (C.at(i) == 'R'){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3760
#include<stdio.h>

int search(int array[],int count,int k1);

int main(){
  int i,count;


  
  scanf("%d",&count);
  int array[10000+1];


  for(i=0;i<count;i++){
    scanf("%d",&array[i]);
  }

 

  int k;
  scanf("%d",&k);
  int k1;
  int sum=0;
  for(i=0;i<k;i++){

    scanf("%d",&k1);
  
    if(search(array,count,k1)){
     
      sum++;} 



  }


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






int search(int a[],int c,int k){
  int i=0;
  a[c]=k;

  while(a[i]!=k){i++;}

  return i!=c;
  

}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vpair t(n);
    rep(i, n) cin >> t[i].se >> t[i].fi;
    sort(all(t));
    int now = 0;
    rep(i, n) {
        now += t[i].se;
        if (now > t[i].fi) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 1792
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){
  string a, b;
  cin >> a;
  cin >> b;
  if (a == b){
    cout << "EQUAL";
  } else if (len(a) > len(b)){
    cout << "GREATER";
  } else if (len(a) < len(b)){
    cout << "LESS";
  } else {
    if (a > b){
      cout << "GREATER";
    } else {
      cout << "LESS";
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
322123


n - 1
0 ... (n-1) [res ... res] S - (n-1) ... S


 */

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define S str[ima]
using namespace std;
string str;
int ima;

int formula(int p,int q,int r) {
  int val;
  int val2;
    while(S=='0'||S=='1'||S=='2'||S=='P'||S=='Q'||S=='R'||S=='('||S=='-') {
    if(S=='('){
      ima++;
      val = formula(p,q,r);

      if(S == '+'){
	ima++;
	val2 = formula(p,q,r);
	if(val==2 || val2==2) val = 2;
	else if(val==1 || val2==1) val = 1;
	else val = 0;
      }
      else if(S == '*') {
	ima++;
	val2 = formula(p,q,r);
	if(val==0 || val2==0) val = 0;
	else if(val==1 || val2==1) val = 1;
	else val = 2;
      }
      ima++;
    }
    
    else if(S=='0'||S=='1'||S=='2'||S=='P'||S=='Q'||S=='R'){
      val = S-'0';
      if(S=='P')val = p;
      else if(S=='Q') val = q;
      else if(S=='R') val = r;
      ima++;
    }
    else if(S == '-'){
      ima++;
      val2 = formula(p,q,r);
      //cout <<"-"<<val2<<endl;
      if(val2 == 0) val = 2;
      else if(val2==2)val = 0;
      else val = 1;
    }
     
    }

  return val;    
    
}
  
int main(){

  while(1) {
    cin >> str;
    if(str == ".") break;
    
    int ans = 0;
    for(int i=0;i<3;i++)
      for(int j=0;j<3;j++)
	for(int k=0;k<3;k++){
	  ima =0;
	  int res = formula(i,j,k);
	  //  cout<<i<<" "<<j<<" "<<k<<" " << res <<endl;
	  //cout << str.size()<<" "<<ima<<endl;
	  if(res == 2) ans++;
	}
    cout << ans <<endl;
  }

  
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=0,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int n,m,l=0,k,c,min1=10000000000000,max2=-100;
    cin>>n;
  for(i=1;i*i<=n;i++)
  {
  if(n%i==0)
  {
    if((n/i)<=9&&i<=9)
    {cout<<"Yes";
      break;
    }
  }
  }
  if(i*i>n)
    cout<<"No";
 return 0;
}


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

int n,m,a,b;
map<int,int> M[220000];

int main(){
    cin >> n >> m;

    for(int i=0;i<m;i++){
        cin >> a >> b;
		M[a][b]=1;
		M[b][a]=1;
    }
    
	for(int i=2;i<=n-1;i++){
        if(M[1][i]==1 && M[i][n]==1){
			cout << "POSSIBLE" << endl;
			return 0;
		}
    }
    
	cout << "IMPOSSIBLE" << endl;

    return 0;
}



Measured memory_bytes: 38656
#include<stdio.h>
#include<math.h>

int main(void){
        int a,b,c,d,e;

        scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
        if(a==0)
{
        printf("1");
}
        else if(b==0)
{
        printf("2");
}
        else if(c==0)
{
        printf("3");
}
        else if(d==0)
{
        printf("4");
}
        else if(e==0)
{
        printf("5");
}
        return 0;
}

Measured memory_bytes: 1600
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

ll n,k; vector<ll> a;

bool check(ll x){
  ll m=0;
  for(int i=0;i<n;i++)
    m+=(a[i]-1)/x;
  return m<=k;
}

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

  ll l=1, r=1e9+5;
  while(l<r){
    int m=(r-l)/2+l;
    if(check(m))
      r=m;
    else
      l=m+1;
  }
  cout<<l<<"\n";
  return 0;
}

Measured memory_bytes: 4752
import sys
import math

A, B, H, M = [int(i) for i in input().split()]
thetaA = (H + M / 60) * (math.pi / 6)
thetaB = 2 * math.pi * (M / 60)
print(math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(thetaB - thetaA)))

Measured memory_bytes: 9568
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;
 
int main()
{
    ll N;
    cin >> N;
    set<string> s;
    ll n = 3;
    s.insert("357");
    s.insert("375");
    s.insert("537");
    s.insert("573");
    s.insert("735");
    s.insert("753");
    while(n != 10) {
        for(auto str : s) {
            if (str.size() == n) {
                rep(i, n) {
                    string tmp = str;
                    tmp.insert(i, "3");
                    s.insert(tmp);
                    tmp = str;
                    tmp.insert(i, "5");
                    s.insert(tmp);
                    tmp = str;
                    tmp.insert(i, "7");
                    s.insert(tmp);
                }
            }
        }
        n++;
    }
    ll cnt = 0;
    for(auto str : s) {
        ll tmp = stoll(str);
        if (N >= tmp) cnt++;
    }
    print(cnt);
    return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

vec ans;
ll N;
string T;

void ask (vector<ll> &a) {
    cout << "? ";
    Rep (i, 2*N) {
        if (a[i] == 1) {
            cout << i+1 << " ";
        }
    }
    cout << endl;
    cin >> T;
    if (T == "Red") {
        ans.push_back(1);
    } else if (T == "Blue") {
        ans.push_back(0);
    }
    return;
}

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

    cin >> N;

    vec balls(2*N, -1);
    ll ok = 0, ng = N;
    vec check(N+1, -1);
    vec prepare(2*N, 0);
    Rep (i, N) {
        prepare[i] = 1;
    }

    ask(prepare);

    check[ok] = ans.back();
    check[ng] = 1 - ans.back();

    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        prepare.assign(2*N, 0);
        for (ll i = mid; i < mid + N; i++) {
            prepare[i] = 1;
        }
        ask(prepare);
        check[mid] = ans.back();
        if (check[ok] == check[mid]) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    balls[ok] = check[ok];
    balls[ok+N] = check[ng];

    for (ll i = 0; i < 2*N; i++) {
        if (ok <= i && i <= ok+N) continue;
        prepare.assign(2*N, 0);
        prepare[i] = 1;
        for (ll j = ok + 1; j <= ok + N - 1; j++) {
            prepare[j] = 1;
        }
        ask(prepare);
        balls[i] = ans.back();
    }

    for (ll i = 0; i < 2*N; i++) {
        if (i <= ok || ok + N <= i) continue;
        prepare.assign(2*N, 0);
        for (ll j = 0; j < 2*N; j++) {
            if (ok <= j && j <= ok+N) continue;
            prepare[j] = 1;
        }
        prepare[i] = 1;
        ask(prepare);
        balls[i] = ans.back();
    }

    cout << "! ";
    Rep (i, 2*N) {
        if (balls[i] == 1) {
            cout << 'R';
        } else {
            cout << 'B';
        }
    }
    cout << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 99999999999999

    /*Solve*/

int main(){
    ll n,m;
    cin >> n >> m;
    ll x[200010];
    ll def[200010];
    ll len=0;
    rep(i,m){
        cin >> x[i];
    }
    sort(x,x+m,greater<>());
    rep(i,m){
        if(i>0){
            def[i-1]=abs(x[i]-x[i-1]);
            len+=def[i-1];
        }
    }
    sort(def,def+m,greater<>());
    ll ans=len;
    rep(i,n-1){
        ans-=def[i];
    }
    cout << ans;
}

Measured memory_bytes: 2944
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=100005;
 
int N;
vector<int> adj[MAXN];
int col[MAXN];
 
bool dfs(int u,int f)
{
    if(adj[u].size()==1U)
    {
        col[u]=0;
        return false;
    }
    int cnt[2]={0};
    for(int i=0;i<(int)adj[u].size();i++)
    {
        int v=adj[u][i];
        if(v==f)
            continue;
        if(dfs(v,u))
            return true;
        cnt[col[v]]++;
    }
    if(cnt[0]>=2||(int)adj[u].size()==cnt[1])
        return true;
    else if(cnt[0])
        col[u]=1;
    else
        col[u]=0;
    return false;
}
 
int main()
{
    scanf("%d",&N);
    for(int i=1;i<N;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    if(N==2)
        puts("Second");
    else
    {
        bool ans;
        for(int i=1;i<=N;i++)
            if(adj[i].size()>1U)
            {
                ans=dfs(i,0);
                break;
            }
        puts(ans?"First":"Second");
    }
 
    return 0;
}


Measured memory_bytes: 6144
fun gcd(x: Int, y: Int): Int = when(y) {
  0 -> x
  else -> gcd(y, x % y)
}

fun main(args: Array<String>) {
  val (x,y) = readLine()!!.split(' ').map(String::toInt)
  val ans = gcd(x,y)
  println(ans)
}



Measured memory_bytes: 32140
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
# print(k)
print(a[k-1])

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

signed main(){
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a);
    vector<int> q(b);
    vector<int> r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];

    sort(p.begin(),p.end(),greater<int>());
    sort(q.begin(),q.end(),greater<int>());
    sort(r.begin(),r.end(),greater<int>());

    priority_queue<int,vector<int>, greater<int> > que;

    rep(i,x){
        que.push(p[i]);
    }
    rep(i,y){
        que.push(q[i]);
    }
    


    //sort(eat.begin(),eat.end());

    rep(i,c){
        int temp=que.top();
        if(r[i]>temp){
            que.pop();
            que.push(r[i]);
        }
        else break;
    }
    ll ans =0;
    while(!que.empty()){
        int temp=que.top();
        que.pop();
        ans+=temp;
    }
    cout << ans << endl;
    
    
}

Measured memory_bytes: 4724