akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define range(i,a,b) for(int i = (a);i <= (b);i++)
#define all(A) A.begin(),A.end()
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
#define vi vector<int>
#define vl vector<long long>
#define vd vector<double>
#define vp vector<pair<int,int> >
#define ll long long
#define pi pair<int,int>
#define popcnt(x) __builtin_popcountll(x)
#define LSOne(x) ((x) & (-(x)))
#define xx first
#define yy second
#define PQ priority_queue
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prp(p) cerr << "(" << (p).first << " ," << (p).second << ")";
#define prArr(A,n,t)  cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
#define what_is(x) cerr << #x << " is " << x << endl
#define bit_lg(x) (assert(x > 0),__builtin_ffsll(x) - 1)
const double PI = acos(-1);
using namespace std;


typedef pair<ll,ll> pl;
const int MAX = 100*1000;
vi P;
bool not_prime[MAX + 1];
map<ll,pair<vl,vl> > memo;

void init(){
	for(int i = 2;i <= MAX;i++)
		if(not_prime[i] == 0){
			P.pb(i);
			for(ll j = i*1LL*i; j <= MAX;j += i)
				not_prime[j] = 1;
		}
}


pair<vl,vl> canonize(ll x) {
	if(memo.find(x) != memo.end()) return memo[x];
	vl self,anti;
	ll y = x;
	for(int p : P){
		if(p*1LL*p > x) break;
		if(x%p == 0) {
			int e = 0;
			while(x%p == 0) x /= p,e++;
			e %= 3;
			if(e == 0) continue;
			self.pb(p);
			anti.pb(p);
			if(e == 2) self.pb(p);
			else anti.pb(p);
		}
	}
	if(x > 1) {
		self.pb(x);
		anti.pb(x);
		anti.pb(x);
	}
	return memo[y] = mp(self,anti);
}

int main(){
	#ifdef HOME
		freopen("in.in", "r", stdin);
	#endif
	init();
	map<vl,vl> toAnti;
	map<vl,int> cnt;
	int n; scanf("%d",&n);
	int cubes = 0;
	loop(i,n) {
		ll x; scanf("%lld",&x);
		pair<vl,vl> tmp = canonize(x);
		vl self = tmp.xx, anti = tmp.yy;
		if(self.empty()) {
			cubes++;
			continue;
		}
		cnt[self]++;
		toAnti[self] = anti;
	}

	int ans = cubes > 0;
	while(!cnt.empty()) {
		vl self = cnt.begin()->xx;
		assert(toAnti.find(self) != toAnti.end());
		vl anti = toAnti[self];
		ans += max(cnt[self],cnt[anti]);
		cnt.erase(self);
		cnt.erase(anti);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 53776
n,m=map(int,input().split())


a=[]
for i in range(m):
    a.append(list(map(int,input().split())))


if m==0:
    if n==1:
        print(0)
    elif n==2:
        print(10)
    else:
        print(100)
    exit()

for i in range(m-1):
    for j in range(i+1,m):
        if a[i][0]==a[j][0]:
            if a[i][1]!=a[j][1]:
                print(-1)
                exit()

a.sort()
a1=10
a2=10
a3=10
if n==3:
    for i in range(m):
        if a[i][0]==1:
            a1=a[i][1]
        if a[i][0]==2:
            a2=a[i][1]
        if a[i][0]==3:
            a3=a[i][1]
    if a1==0:
        print(-1)
        exit()
    if a1==10:
        a1=1
    if a2==10:
        a2=0
    if a3==10:
        a3=0
    if (a1%10)*100+(a2%10)*10+(a3%10)==0:
        print(-1)
    else:
        print((a1%10)*100+(a2%10)*10+(a3%10))

elif n==2:
    for i in range(m):
        if a[i][0]==1:
            a1=a[i][1]
        if a[i][0]==2:
            a2=a[i][1]
    if a1==0:
        print(-1)
        exit()
    if a1==10:
        a1=1
    if a2==10:
        a2=0

    if (a1%10)*10+(a2%10)==0:
        print(-1)
    else:
        print((a1%10)*10+(a2%10)*1)

else:
    for i in range(m):
        if a[i][0]==1:
            a1=a[i][1]
    
    print(a1%10)

Measured memory_bytes: 38512
//file_name:ABC72_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


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


    int ans = max(0,n-t);

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<stdio.h>   

int main(){
    int n,m = 0;
    scanf("%d",&n);
    int j = n;
    for(int i = 1;;i++){
        m += j % 10;
        j /= 10;
        if(j == 0) break;
    }
    if(n % m == 0) printf("Yes\n");
    else printf("No\n");

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

ll gcd(ll A,ll B){
    if(B==0){return A;}
    return gcd(B ,A%B);
}



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

    ll a,b;
    cin >> a >> b;
    ll n = gcd(a,b);
    vector<pair<ll,int>> res;
    for(ll i=2;i*i<=n;++i){
        if(n%i != 0) continue;
        res.emplace_back(i,0);
        while(n%i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n!=1) res.emplace_back(n,1);
    int ans = res.size() + 1 ; 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define stop(x) {cout<<x<<endl;exit(0);}
#define all(x) x.begin(),x.end()
#define szz(s) int(s.size())
#define endl '\n'
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
typedef long long ll;
using namespace std;
void file(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
}


int main(){//file();


    char a ;
    cin >> a ;
    a++;
    cout << a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

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

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

map<ll, ll> primeFactorize(ll n, map<ll, ll>& PF) {
	while (n % 2 == 0) {
		PF[2]++;
		n /= 2;
	}
	for (ll p = 3; p * p <= n; p += 2) {
		while (n % p == 0) {
			PF[p]++;
			n /= p;
		}
	}
	if (n != 1) {
		PF[n]++;
	}
	return PF;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    map<ll,ll> m;
    primeFactorize(n,m);
    ll ans = 0;
    for(auto &x: m){
        ll p = x.second;
        debug(x.first,p);
        ll c = 0;
        while(c<p){
            c++;
            p -= c;
        }
        ans += c;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3664
#include <iostream>

using namespace std;

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    if ((a.substr((a.size() - 1), 1) == b.substr(0, 1)) && (b.substr((b.size() - 1), 1) == c.substr(0, 1)))
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
    return 0;
}

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

#define X first
#define Y second
#define rep(i, n) for(int i = 0; i < n; i ++)
#define LEFT 0
#define RIGHT 1
#define TOP 2
#define BOTTOM 3

using namespace std;

const pair<int, int> PATTERN[4] = 
{make_pair(-1, 0), make_pair(0, -1), make_pair(1, 0), make_pair(0, 1)};

int main(void){
	for(int n, edge[4]; cin >> n, n; cout << edge[RIGHT] - edge[LEFT] + 1 << " " << edge[TOP] - edge[BOTTOM] + 1 << endl){
		rep(i, 4) edge[i] = 0;
		vector<pair<int, int> > squairs(n);
		
		rep(i, n){
			if(!i){ squairs[i] = make_pair(0, 0); continue; }
			int index, d; cin >> index >> d;
			squairs[i] = make_pair(squairs[index].X + PATTERN[d].X, squairs[index].Y + PATTERN[d].Y);
			if(squairs[i].X < edge[LEFT]) edge[LEFT] = squairs[i].X;
			else if(squairs[i].X > edge[RIGHT]) edge[RIGHT] = squairs[i].X;
			else if(squairs[i].Y < edge[BOTTOM]) edge[BOTTOM] = squairs[i].Y;
			else if(squairs[i].Y > edge[TOP]) edge[TOP] = squairs[i].Y;
		}
	}

	return 0;
}

Measured memory_bytes: 1196
N = int(input())
if N <= 1000:
  print(1000-N)
elif N <= 2000:
  print(2000-N)
elif N <= 3000:
  print(3000-N)
elif N <= 4000:
  print(4000-N)
elif N <= 5000:
  print(5000-N)
elif N <= 6000:
  print(6000-N)
elif N <= 7000:
  print(7000-N)
elif N <= 8000:
  print(8000-N)
elif N <= 9000:
  print(9000-N)
elif N <= 10000:
  print(10000-N)

Measured memory_bytes: 9204
#include<iostream>
#include<string>
#include <stdio.h>
#include <math.h>
#include <cctype>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
double a,b,c,d,e,f,x,y;
int main(){
	while(cin>>a>>b>>c>>d>>e>>f){
		x=(c*e-f*b)/(a*e-d*b);
		y=(c-a*x)/b;
		printf("%.3f %.3f\n",x+(1e-10),y+(1e-10));
	}
	return 0;
	
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
#define ll          long long
#define pll         vector< pair<ll ,ll> >
#define vll         vector<ll>
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb          push_back
#define F           first
#define S           second
#define mp          make_pair
#define all(v)      v.begin(), v.end()
#define lb          lower_bound  //value not less than(>=)
#define ub          upper_bound  //value greater than(>)
#define bs          binary_search
#define pcont(v)    for(auto it:v) cout<<it<<" ";cout<<endl
#define ret(x)      return cout << x,0;
#define pi          pair<ll,pair<ll,ll> >

ll const MAX = 1e5+5;
using namespace std;

ll dp[101][MAX];
ll w[101],v[101];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

    ll N,W;
    cin >> N >> W;
    rep(i,1,N+1) cin >> w[i] >> v[i];

    rep(i,1,N+1) {
        rep(j,1,W+1) {
            if(w[i]>j) {
                dp[i][j]=dp[i-1][j];
            }
            else {
                dp[i][j]=max(dp[i-1][j], v[i]+dp[i-1][j-w[i]]);
            }
        }
    }
    ret(dp[N][W]);

}


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


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

    for(int m = 0; m <= N-1; m++){
        if( m*C - (N-1-m)*D <= B-A && B-A <= m*D - (N-1-m)*C){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct drink {
  int    price;
  int    count;
};
int main() {
    int N,M;
    cin >> N >> M;
    vector<drink> drinks(N);
    for (int i=0; i<N; i++) {
        cin >> drinks[i].price >> drinks[i].count;
    }
    sort(drinks.begin(), drinks.end(),
        [](const drink& x, const drink& y) { return x.price < y.price;});
    long long cost=0;
    int count=0;
    for (int i=0; i<N; i++) {
        for (int j=0; j<drinks[i].count; j++) {
            cost += drinks[i].price;
            count++;
            if (count >= M) break;
        }
        if (count >= M) break;
    }
    cout << cost << endl;
    return 0;
}


Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc168/tasks/abc168_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "complex"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ld A, B, H, M;
  cin >> A >> B >> H >> M;

  ld pi = acos(-1);
  complex<ld> a = polar(A, 2 * pi * (H + M / 60) / 12);
  complex<ld> b = polar(B, 2 * pi * M / 60);
  ld dist = abs(a - b);

  cout << fixed << setprecision(20) << dist << endl;
}


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

int main() {
    int N;
    cin >> N;

    long long int ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
package main

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

func solve(N int, L []int) {
	num := 0
	sort.Sort(sort.Reverse(sort.IntSlice(L)))
	for i := 0; i < 2*N; i += 2 {
		num += L[i+1]
	}
	fmt.Println(num)
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var sn, sl string
	if sc.Scan() {
		sn = sc.Text()
	}
	if sc.Scan() {
		sl = sc.Text()
	}
	n, _ := strconv.Atoi(sn)
	ls := strings.Split(sl, " ")
	l := []int{}
	for _, s := range ls {
		i, _ := strconv.Atoi(s)
		l = append(l, i)
	}
	solve(n, l)
}


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

using namespace std;
int main() {
    int N;
    cin >> N;
    if (N < 10) {
        cout << N;
        return 0;
    }
    if (N < 100) {
        cout << 9;
        return 0;
    }
    if (N <= 999) {
        cout << N - 90;
        return 0;
    }
    if (N < 10000) {
        cout << 909;
        return 0;
    }
    if (N <= 99999) {
        cout << N - 9090;
        return 0;
    }
    cout << 90909;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef pair<string,string> ps;

int main()
{
    while(1)
    {
        int n,m,q;
        cin >>n >>m >>q;
        if(n==0) break;

        //now active switch
        int act[36]={0};
        //i-th bulb may be controled by j-th switch
        bool sw[1000][36];

        fill(sw[0],sw[1000],true);

        rep(Q,q)
        {
            string s,b;
            cin >>s >>b;

            //update active state
            rep(i,n)
            {
                if(s[i]=='1') act[i] = !act[i];
            }

            rep(i,m)
            {
                if(b[i]=='0')
                {
                    //not active
                    //now active switches have nothing to do with
                    rep(j,n)
                    {
                        if(act[j]) sw[i][j]=false;
                    }
                }
                else
                {
                    //active
                    //now inactive switches have nothing to do with
                    rep(j,n)
                    {
                        if(!act[j]) sw[i][j]=false;
                    }
                }
            }
        }

        //answer
        rep(i,m)
        {
            int ans=-1;
            int ct=0;

            rep(j,n)
            {
                if(sw[i][j])
                {
                    ans=j;
                    ++ct;
                }
            }

            if(ct==1)
            {
                if(ans<10) printf("%d",ans);
                else printf("%c",ans-10+'A');
            }
            else printf("?");
        }
        printf("\n");
    }
    return 0;
}

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

int main() {
    int sx, sy, gx, gy;  cin >> sx >> sy >> gx >> gy;
    string ans = string();
    ans += string(gy - sy, 'U') + string(gx - sx, 'R');
    ans += string(gy - sy, 'D') + string(gx - sx, 'L');
    ans += 'L' + string(gy - sy + 1, 'U') + string(gx - sx + 1, 'R') + 'D';
    ans += 'R' + string(gy - sy + 1, 'D') + string(gx - sx + 1, 'L') + 'U';
    cout << ans << endl;
}


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

using i64 = int64_t;

int main(){
    i64 n;
    cin >> n;
    vector<pair<i64, i64>> v;
    i64 lmax = 0, rmin = 2e9;
    for(int i=0;i<n;++i){
        i64 l, r;
        cin >> l >> r;
        r++;
        v.emplace_back(l, r);
        lmax = max(lmax, l);
        rmin = min(rmin, r);
    }

    i64 ans = 0;
    for(auto e: v){
        ans = max(ans, max((i64)0, rmin-lmax)+e.second-e.first);
    }

    for(auto &e: v){
        i64 l = e.first, r = e.second;
        e.first = max((i64)0, r - lmax);
        e.second = max((i64)0, rmin - l);
        e.second = -e.second;
    }
    sort(v.begin(), v.end());
    i64 rmin_l = -v[0].second;
    for(int i=0;i<n-1;++i){
        rmin_l = min(rmin_l, -v[i].second);
        ans = max(ans, rmin_l+v[i+1].first);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int f[100005],n,a[100005],pp[100005];
vector<int> v[100005];
queue<int> lj;
void dfs(int w,int p){
	if(pp[w])return;
	a[p]=w;pp[w]=1;
	if(w==n){
		for(int i=1;i<=p;i++)lj.push(a[i]);
		return;
	}
	for(int i=0;i<v[w].size();i++){
		dfs(v[w][i],p+1);
	}
}
int ans;
void df(int p){
	if(f[p]==2||pp[p])return;
	f[p]=1;pp[p]=1;
	ans++;
	for(int i=0;i<v[p].size();i++){
		df(v[p][i]);
	}
}
int main(){
	cin>>n;
	int x,y;
	for(int i=1;i<n;i++){
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1,1);
	int t=lj.size();
	for(int i=0;i<(t+1)>>1;i++){
		f[lj.front()]=1;lj.pop();
	}
	for(int i=0;i<lj.size();i++){
		f[lj.front()]=2;lj.pop();
	}
	memset(pp,0,sizeof(pp));
	df(1);
	if(ans>n/2)cout<<"Fennec";
	else cout<<"Snuke";
	return 0;
}

Measured memory_bytes: 15104
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
LL gcd(LL a, LL b) {
	return b ? gcd(b, a%b) : a;
}
int A[100000];
int main() {
	int N, K;
	cin >> N >> K;
	int M = 0;
	rep(i, N) cin >> A[i], M = max(M, A[i]);
	int g = A[0];
	REP(i, 1, N) g = gcd(g, A[i]);
	if (K <= M&&K%g == 0) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b >= c ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
	string s, t;
	cin >> s >> t;

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	bool check = false;

	int size = min(s.size(), t.size());

	for(int i=0;i<size;i++) {
		if(s.at(i) < t.at(i)) check = true;
	}

	bool check2 = true;

	if(check) {
		cout << "Yes" << endl;
	} else {
		for(int i=0;i<size;i++) {
			if(s.at(i) != t.at(i)) check2 = false;
		}

		if(check2 && s.size()<t.size()) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(void){
  int n;
  cin>>n;
  int a(1),i(1);
  while(a<=n){
    i++;
    a=pow(i,2);
  }
  ulong b=pow(i-1,2);
  cout<<b<<endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{

  int n ,a;
  cin >> n >> a;
  cout << n*n - a << LF;

  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main() {
  int j, n, m;
  while (scanf("%d %d", &n, &m) != EOF) {
    int d = 1, i; n += m;
    for (i = 1; n / d >= 10; i ++) d *= 10;
    printf("%d\n", i);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n,q;
	while(cin>>n>>q and n>0){
		int sum[100]={};
		int day;
		rep(i,n){
			int m; cin>>m;
			rep(j,m){
				cin>>day;
				sum[day]++;
			}
		}
		int ans=0,num=0;
		rep(i,100){
			if(num<=sum[99-i]){
				ans=99-i;
				num=sum[99-i];
			}
		}
		if(num<q) ans=0;
		cout<<ans<<endl;
	}
	return 0;
}



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

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

typedef long long ll;

#ifdef LOCAL
  #define debug_echo(e) cin << "L" << __LINE__ << ": " << e
  #define debug_repr(e) cin << "L" << __LINE__ << ": " << #e << " = " << e
#else
  #define debug_echo(e)
  #define debug_repr(e)
#endif

int main() {
  string a, b; cin >> a >> b;
  if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

int main(){
  int q;
  cin >> q;
  vector<bool> primes(100000,true);
  for(int i=2;i<317;i++){
    for(int j=2;i*j<=100000;j++){
      primes[i*j]=false;
    }
  }
  primes[0]=false;
  primes[1]=false;
  vector<int> a(100000,0);
  for(int i=1;i<100000;i+=2){
    if(primes[i]&&primes[(i+1)/2]){
      a[i] = 1;
    }
  }

  vector<int> b(100000);
  b[0] = 0;
  for(int i=1;i<100000;i++){
    b[i] = b[i-1]+a[i];
  }

  for(int i=0;i<q;i++){
    int l,r;
    cin >> l >> r;
    cout << b[r]-b[l-1] << endl;
  }
}


Measured memory_bytes: 1408
N=int(input())
W = list(map(int, input().split()))
total = 0
for i in range(N):
    total += W[i]
    

ans = total
sumi = 0
loop = True
i = 0
while loop:
    sumi += W[i]
    if abs(sumi - (total - sumi)) > ans:
        print(ans)
        loop = False
    else:
      ans = abs(sumi - (total - sumi))
      i += 1

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve()
{
  string s;
  cin >> s;
  int N = s.size();
  vector<int> p(N);
  iota(p.begin(), p.end(), 0);
  for (int i = 0; i < N; i++) {
    int pos = p[i];
    for (int j = 0; j < 10; j++) {
      if (s[pos] == 'R')
        pos++;
      else
        pos--;
    }
    p[i] = pos;
  }
  dump(p);
  vector<vector<int>> jp(105, vector<int>(N));
  for (int i = 0; i < N; i++) {
    jp[0][i] = p[i];
  }
  for (int k = 1; k <= 4; k++) {
    for (int i = 0; i < N; i++) {
      int pos = jp[k - 1][i];
      for (int j = 1; j < 10; j++) {
        pos = jp[k - 1][pos];
      }
      jp[k][i] = pos;
    }
  }
  vector<int> ans(N);
  for (int i = 0; i < N; i++) {
    ans[jp[4][i]]++;
  }
  dump(ans);
  for (int i = 0; i < N; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 42568
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
typedef long long ll; 
ll pre[200005], suf[200005], ans = 1e18; 
int arr[200005], pos[200005], n;
inline ll calc(int a, int b, int c)
{
	if (a < 0 || a >= b || b >= c || c >= n - 1)
		return 1e18; 
	// printf("%d %d %d\n", a, b, c);
	ll val[] = {pre[a], pre[b] - pre[a], pre[c] - pre[b], pre[n - 1] - pre[c]};
	std::sort(val, val + 4); 
	return val[3] - val[0]; 
}
int main()
{
	// freopen("ARC100-D.in", "r", stdin); 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
	{
		scanf("%d", arr + i); 
		pre[i] = (i ? pre[i - 1] : 0) + arr[i]; 
	}
	for (int i = 0, j = 0; i < n; i++)
	{
		while (j <= i && pre[j] << 1 <= pre[i])
			j++; 
		pos[i] = j - 1; 
	}
	for (int i = n - 1; i >= 0; i--)
		suf[i] = suf[i + 1] + arr[i]; 
	for (int i = n - 2, j = n - 2; i >= 0; i--)
	{
		while (j >= i && suf[j + 1] << 1 <= suf[i + 1])
			j--;
		for (int x = 0; x < 2; x++)
		{
			for (int y = 0; y < 2; y++)
				ans = std::min(ans, calc(pos[i] + x, i, j + y)); 
		}
	}
	printf("%lld\n", ans);
	return 0; 
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N; cin >> N;
  ll A[N], B[N]; rep(i,N) cin >> A[i] >> B[i];
  sort(A,A+N); sort(B,B+N);
  ll result = 0;
  if (N%2==0) result = (B[N/2-1]+B[N/2]) - (A[N/2-1]+A[N/2]) + 1;
  else result = B[N/2] - A[N/2] + 1;
  cout << result << endl;
  return 0;
}

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

using namespace std;

class Fibonacci{
private:
  vector<int64_t> fibstore;
public:
  Fibonacci(int num){
    for(int i=0;i<=num;i++){
      fibstore.push_back(0);
    }
    if(num>0){
      fibstore.at(0)=1;
      fibstore.at(1)=1;
    }
  }

  int64_t fibcalc(int num){
    if(fibstore.at(num)!=0) return fibstore.at(num);
     int64_t fib1;
     if(fibstore.at(num-1)==0) fibstore.at(num-1)=fibcalc(num-1);
     fib1=fibstore.at(num-1);

     int64_t fib2;
     if(fibstore.at(num-2)==0) fibstore.at(num-2)=fibcalc(num-2);
     fib2=fibstore.at(num-2);
    return fib1+fib2;
  }
};
int main(void){
  int num;
  cin>>num;
  Fibonacci fib(num);
  cout<<fib.fibcalc(num)<<endl;
  return 0;
}



Measured memory_bytes: 3160
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;


class Program
{
    internal static void Main(string[] args)
    {
        int[] inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        Array.Sort(inp);
        int cnt = inp[2] - inp[1];
        inp[1] += cnt;
        inp[0] += cnt;

        while (inp[0] < inp[2]) {
            inp[0] += 2;
            cnt++;
        }

        if (inp[0] > inp[1]) {
            cnt++;
        }
        WriteLine(cnt);
    }
}


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

using namespace std;

// 多次元 mul_array<int, 1, 2, 3> a
template <typename T, std::size_t... Ns>
struct index_reverse_for_array;
template <typename T, std::size_t N, std::size_t... Ns>
struct index_reverse_for_array<T, N, Ns...> { using type = std::array< typename index_reverse_for_array<T, Ns...>::type, N>; };
template <typename T, std::size_t N>
struct index_reverse_for_array<T, N> { using type = std::array<T, N>; };
template <class T, std::size_t... Ns> using mul_array = typename index_reverse_for_array<T, Ns...>::type;

using u32 = uint32_t;
using s32 = uint32_t;
using u64 = uint64_t;
using s64 = uint64_t;

constexpr static u64 m = 1000000007;

constexpr u64 per(u64 k) {
    if (k == 1) return 1;
    return (k * per(k - 1)) % m;
}
constexpr u64 ppow(u64 k, u64 i) {
    if (i == 0) return 1;
    u64 a = 1;
    if (i % 2 != 0)
        a = k;
    u64 b = ppow(k, i >> 1);
    return (a * ((b * b) % m)) % m;
}

int main() {
    //cout << fixed << setprecision(10);

    u64 n, k;
    cin >> n >> k;

    vector<u64> p(n + 1), q(n + 1);
    p[0] = q[0] = 1;
    for (u64 i = 1; i <= n; i++) {
        p[i] = per(i);
        q[i] = ppow(p[i], m-2);
    }

    //cout << endl;
    u64 b = k - 1;
    u64 r = n - k - 1;

    for (u64 i = 0; i < k; i++) {
        u64 i1 = i-1, i2 = i, i3 = i+1;
        u64 bCi = 0;
        u64 rCi1 = 0, rCi2 = 0, rCi3 = 0;
        if (i <= b) {
            bCi = ((((p[b] * q[i]) % m) * q[b - i]) % m);
            if (i1 <= r && i1 >= 0)
                rCi1 = ((((p[r] * q[i1]) % m) * q[r - i1]) % m);
            if (i2 <= r && i2 >= 0)
                rCi2 = ((((p[r] * q[i2]) % m) * q[r - i2]) % m);
            if (i3 <= r && i3 >= 0)
                rCi3 = ((((p[r] * q[i3]) % m) * q[r - i3]) % m);
        }
        u32 a = 0;
        if (i + 1 <= n - k + 1)
            a = ((((p[(n - k + 1)] * q[i + 1]) % m) * q[(n - k + 1) - (i + 1)]) % m);

        cout << ((bCi * a) % m) << endl;
        //cout << " " << bCi << " " << a << endl;
        //cout << " " << bCi << " " << rCi1 << " " << rCi2 << " " << rCi3 << endl;
    }

    return 0;
}





Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			string[] s = new string[n];
			for (int i = 0; i < n; i++) {
				s[i] = cin.Next();
			}

			int cnt = 0;
			for (int k = 0; k < n; k++) {
				bool ok = true;
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < n; j++) {
						if (i == j) {
							continue;
						}

						if (s[i][(j + k) % n] != s[j][(i + k) % n]) {
							ok = false;
							break;
						}
					}

					if (ok == false) {
						break;
					}
				}

				if (ok) {
					cnt++;
				}
			}

			Console.WriteLine(cnt * n);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 13268
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n; sc(n)
    int T[n], A[n];
    REP(i, n){
        sc(T[i])
        sc(A[i])
    }
    ll ans1 = T[0], ans2 = A[0], tmp = 0;
    for (int i = 0; i < n; i++){
        if (ans1 % T[i] == 0 && ans2 % A[i] == 0){
            tmp = max(ans1 / T[i], ans2 / A[i]);
        }else if (ans1 % T[i] == 0){
            tmp = max(ans1 / T[i], ans2 / A[i] + 1ll);
        }else if (ans2 % A[i] == 0){
            tmp = max(ans1 / T[i] + 1ll, ans2 / A[i]);
        }else tmp = max(ans1 / T[i] + 1ll, ans2 / A[i] + 1ll);
        ans1 = T[i] * tmp;
        ans2 = A[i] * tmp;
    }
    cout << ans1 + ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define setnow clock_t tStart=clock();
#define time (double)(clock() - tStart)/CLOCKS_PER_SEC;
#define setin(x) ifstream cin(x);
#define setout(x) ofstream cout(x);
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
 #define mod 1000000007

const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;

int main(){
           lli n;
           cin >> n;
           lli ans =1;
           for(int i=1;i<=n;i++)
                ans = (ans * i) % mod;
           cout<<ans;
}


Measured memory_bytes: 256
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy

N = int(input())

ans = 0
for n in range(3, 10):
    for l in it.product(["7", "5", "3"], repeat=n):
        if "7" not in l or "5" not in l or "3" not in l:
            continue
        M = int("".join(l))
        if M <= N:
            dump(M, ans)
            ans += 1
dump(N)
print(ans)


Measured memory_bytes: 83204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(long long K){
    vl 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};
    cout<<a[K-1]<<endl;
}

int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

string str;
unsigned long long int ans=0;
int l;

void dfs(int d, unsigned long long int sum, unsigned long long int n){
	if(d==l){
		ans+=sum+n;
	}else{
		dfs(d+1, sum+n, str[d+1]-'0');

		dfs(d+1, sum, n*10+(str[d+1]-'0'));
	}

}

int main(){
	cin>>str;
	l=str.length()-1;
	dfs(0, 0, str[0]-'0');
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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

vector<int> dh = {1,0,-1,0};
vector<int> dw = {0,1,0,-1};

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

    int H,W;cin >> H >> W;
    vector<vector<char>> ban(H,vector<char>(W));
    for(int i = 0;i<H;i++) for(int j = 0;j<W;j++) cin >> ban.at(i).at(j);
    queue<pair<pair<int,int>,int>> Q;
    //白マスが漆黒に染まるまでの時間
    vector<vector<int>> darkTime(H,vector<int>(W));
    for(int i = 0;i<H;i++){
        for(int j = 0;j<W;j++){
            if(ban.at(i).at(j) == '#'){
                Q.push(make_pair(make_pair(i,j),0));
                darkTime.at(i).at(j) = 0;
            }
            else{
                darkTime.at(i).at(j) = 100100100;
            }
        }
    }
    //BFS
    while(!Q.empty()){
        pair<pair<int,int>,int> p = Q.front();Q.pop();
        int nowH = p.first.first,nowW = p.first.second,dist = p.second;
        for(int i = 0;i<4;i++){
            int nh = nowH+dh.at(i),nw = nowW+dw.at(i);
            if(nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            if(darkTime.at(nh).at(nw) != 100100100) continue;
            Q.push(make_pair(make_pair(nh,nw),dist+1));
            darkTime.at(nh).at(nw) = dist+1;
        }
        //cout << nowH << " " << nowW << endl;
    }
    int ans = 0;
    for(int i = 0;i<H;i++){
        for(int j = 0;j<W;j++){
            ans = max(ans,darkTime.at(i).at(j));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 20240
#include<iostream>
#include<cstring>
#include<cstdio> 
#define INF 0x3f3f3f3f
 
using namespace std;
 
const int N=25;
int c[N];
int n,m,x;
int a[N][N];
int ans=INF;
int main()
{
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<(1<<n);i++){
		int sum=0; 
		int res[N]; 
		memset(res,0,sizeof(res));
		for(int j=0;j<n;j++){
			if(i&(1<<j)){
				for(int k=1;k<=m;k++){
					res[k]+=a[j+1][k];
				}
				sum+=c[j+1];
			}
		}
		bool flag=0;
		for(int j=1;j<=m;j++){
			if(res[j]<x){
				flag=1;
				break;
			}
		}
		if(!flag) ans=min(sum,ans);
	}
	if(ans==INF) puts("-1");
	else cout<<ans<<endl;	
	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;

int main(){
  int n,m;
  cin >> n >> m;
  vector<bool> ok(n+1,true);
  for (int i = 0;i < m;i++){
    int a; cin >> a;
    ok[a] = false;
  }

  vector<long long>dp(n+1);
  dp[0] = 1;

  for (int i = 0;i < n;i++){
    for (int next = i+1;next <= min(n,i+2);next++){
      if (ok[next]){
        dp[next] += dp[i];
        dp[next] %= mod;
      }
    }
  }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  string S;
  cin >> S;
  string T=S;
  int s=S.size();
  int a=0;
  reverse(T.begin(),T.end());
  for(int i=0;i<s;i++){
    if(S[i]=='d' && T[i]=='b'){a+=0;}
    else if(S[i]=='b' && T[i]=='d')a+=0;
    else if(S[i]=='p' && T[i]=='q')a+=0;
    else if(S[i]=='q' && T[i]=='p')a+=0;
    else{cout << "No" << endl; return 0;}
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << a + b + c  - max(a,max(b,c)) << endl;
}



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

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		if (n % 2 == 0)
			System.out.println(n / 2);
		else
			System.out.println((n / 2) + 1);
	}
}


Measured memory_bytes: 20692
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int N;
  cin>>N;

  ll a[3*N];

  rep(i,3*N){
    cin>>a[i];
  }

  ll ansa[N+1],ansb[N+1];
  ll suma=0;
  ll sumb=0;
  priority_queue<ll> queb;
  priority_queue<ll, vector<ll>, greater<ll>> quea;

  rep(i,N){
    quea.push(a[i]);
    suma+=a[i];
    queb.push(a[3*N-i-1]);
    sumb+=a[3*N-i-1];
  }

  ansa[0]=suma;
  ansb[0]=sumb;

  rep(i,N){
    ll aa=a[N+i];
    quea.push(aa);
    suma=suma+aa-quea.top();
    ansa[i+1]=suma;
    quea.pop();
  }
  rep(i,N){
    ll bb=a[2*N-i-1];
    queb.push(bb);
    sumb=sumb+bb-queb.top();
    ansb[i+1]=sumb;
    queb.pop();
  }

  ll ans=-INF;
  rep(i,N+1){
    ans=max(ans,ansa[0+i]-ansb[N-i]);
  }

  cout<< ans<<"\n";
}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 5996