akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static class Node {
		int key;
		Node left;
		Node right;
		Node parent;
		
		public Node(int key) {
			this.key = key;
		}
	}
	
	Node root;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			String s = sc.next();
			if(s.startsWith("i")) {
				insert(sc.nextInt());
			}
			else if (s.startsWith("f")) {
				Node ans = find(root, sc.nextInt());
				if(ans != null) System.out.println("yes");
				else System.out.println("no");
			}
			else if(s.startsWith("d")) {
				deleteNode(find(root, sc.nextInt()));
			}
			else{
				inorder(root);
				System.out.println();
				preorder(root);
				System.out.println();
			}
		}
		sc.close();
	}
	
	void preorder(Node u) {
		if(u == null) return;
		System.out.print(" " + u.key);
		preorder(u.left);
		preorder(u.right);
	}
	
	void inorder(Node u) {
		if(u == null) return;
		inorder(u.left);
		System.out.print(" " + u.key);
		inorder(u.right);
	}
	
	void insert (int key) {
		Node y = null;
		Node x = root;
		Node z = new Node(key);
		while (x != null) {
			y = x;
			if(z.key < x.key) {
				x = x.left;
			} else {
				x = x.right;
			}
		}
		z.parent = y;
		
		if(y == null) {
			root = z;
		} else if (z.key < y.key) {
			y.left = z;
		}else {
			y.right = z;
		}
	}
	
	Node find(Node x, int k) {
		while(x != null && k != x.key) {
			if(k < x.key) x = x.left;
			else x = x.right;
		}
		return x;
	}
	
	void deleteNode(Node z) {
		Node y;
		Node x;
		//削除する対象を節点yとする
		if(z.left == null || z.right == null) {
			y = z;		//ｚが子を持たないか、子を一つ持つ場合は入力節点のz
		}else {
			y = getSuccessor(z);	//ｚが子を二つ持つ場合はzの次節点
		}
		
		//yの子xを決める
		if(y.left != null) {
			x = y.left;
		}else {
			x = y.right;
		}
		
		if(x != null) x.parent = y.parent; //xの親の設定 
		
		if(y.parent == null)
			root = x;			//yが根の時、xを木の根とする
		else if( y == y.parent.left)
			y.parent.left = x;		//yがその親の左の子なら、その親の左の子をxとする
		else
			y.parent.right = x;		//yがその親の右の子なら、その親の右の子をxとする
		
		if( y != z)		//ｚの次節点が削除された場合
			z.key = y.key;		//yのデータをｘにコピーする
		
	}
	
	Node getSuccessor(Node x) {
		Node y;
		if(x.right != null)
			return getMinimum(x.right);
		
		y = x.parent;
		while(y != null && x == y.right) {
			x = y;
			y = y.parent;
		}
		return y;
	}
	
	Node getMinimum(Node x) {
		while(x.left != null) {
			x = x.left;
		}
		return x;
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
	
}


Measured memory_bytes: 200944
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

int main(){
	ll a, b;
	cin >> a >> b;
	b--;
	cout << ceil(1.0*b/(a-1)) << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(4);
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s == "AC") {
      vec.at(0)++;
    }
    if (s == "WA") {
      vec.at(1)++;
    }
    if (s == "TLE") {
      vec.at(2)++;
    }
     if (s == "RE") {
      vec.at(3)++;
    }
  }
  cout << "AC x " << vec.at(0) << endl;
  cout << "WA x " << vec.at(1) << endl;
  cout << "TLE x " << vec.at(2) << endl;
  cout << "RE x " << vec.at(3) << endl;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

int VMAX = 1000;
ll MAX = 10000000000000;

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

    int N;
    ll W;
    cin >> N >> W;

    vll w(N);
    vi v(N);
    for(int i=0;i<N;i++) cin >> w[i] >> v[i];

    vll dp(VMAX*N + 1, MAX);
    dp[0] = 0;

    for(int i=0;i<N;i++) {
        ll cw = w[i];
        int cv = v[i];
        for(int j=VMAX*N; j>=cv;j--) {
            dp[j] = min(dp[j], dp[j-cv] + cw);
        }
    }

    int best = 0;
    for(int i=0;i<=VMAX*N;i++) {
        if (dp[i] <= W) best = max(best, i);
    }

    cout << best << endl;


    return 0;
}

Measured memory_bytes: 1152
import numpy as np

N = int(input())

T = np.array([int(i) for i in input().split()])

M =int(input())

PX = np.ones([M,2])

for i in range(M):
    PX[i][0],PX[i][1] = [int(i) for i in input().split()]
    
ans_pre = sum(T)

ans = np.ones(M)

for i in range(M):
    ans[i] = ans_pre - T[int(PX[i][0])-1] + PX[i][1]
    print(int(ans[i]))


Measured memory_bytes: 12452
A = 0
left = []
Lake = []
s = input()
for i in range(len(s)):
    if s[i] == "\\":
        left.append(i)
    elif s[i] == "/":
        if len(left) > 0:
            w = left.pop()
            goukei = i - w
            A += goukei
            for i in range(len(Lake)-1,-1,-1):
                if Lake[i][0] > w:
                    x = Lake.pop()
                    goukei += x[1]
            Lake.append([w, goukei])
print(A)
if len(Lake) == 0:
    print(0)
else:
    print(len(Lake),end=" ")
for i in range(len(Lake)):
    if i == len(Lake) - 1:
        print(Lake[i][1])
    else:
        print(Lake[i][1],end=" ")

Measured memory_bytes: 8120
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void OUT(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void OUT(T t,Ts... ts){cout<<t<<" ";OUT(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type FILL(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type FILL(T&t,const V&v){for(auto &e:t)FILL(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int N;
	cin>>N;
	auto a = mv(N);
	cin>>a;
	int ans = 0;
	REP(i,N)ans+=a[i]-(i+1);
	OUT(ans);
}


Measured memory_bytes: 3620
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <bitset>

using namespace std;


string S;
unsigned length;
unsigned bits;

int main()
{
	unsigned long long sum = 0;

	cin >> S;
	length = S.length();

	while (bits < (1 << (length - 1)))
	{
		unsigned long long tmp = S[0] - '0';
		// ビットをGET
		auto bit = bitset<16>(bits);

		for (size_t i = 0; i < (length - 1); i++)
		{
			// 足す記号
			if(bit[i])
			{
				sum += tmp;
				tmp = S[i + 1] - '0';
			}
			// 足す記号がない
			else
			{
				tmp = tmp * 10 + S[i + 1] - '0';
			}
		}
		sum += tmp;

		bits++;
	}

	cout << sum << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b; cin >> a >> b;
    for (int i = 1; i < 4; i++)
    {
        if ((a*b*i)%2 != 0)
        {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define PI 3.14159265358

int main(void){
    double a, b, hour, min, radh, radm, rad, ans;
    scanf("%lf %lf %lf %lf", &a, &b, &hour, &min);
    radh = 2*PI * (hour + min / 60) / 12;
    radm = 2*PI * min / 60;
    rad = (radh - radm < PI) ? radh - radm : radm - radh;
    ans = sqrt(a*a + b*b - 2*a*b*cos(rad));
    printf("%.10lf", ans);
    return 0;
}


Measured memory_bytes: 2580
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;
const ll MOD = 1000000007;

int main(void){
    ll res;
    for(int n, t; cin >> n >> t; cout << res << endl){
        res = 1;

        vi level(n);
        rep(i, n){
            cin >> level[i];
        }
        
        sort(all(level));

        rep(i, n){
            int ways = i + 1 - (lower_bound(all(level), level[i] - t) - level.begin());

            if(ways != 0) (res *= ways) %= MOD;
        }
    }

	return 0;
}

Measured memory_bytes: 1268
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
struct edge{int f,t,l;}w[N];
int n,nxt[N],head[N];
void add(int f,int t,int l){
    static int cnt=0;
    w[++cnt]=(edge){f,t,l};
    nxt[cnt]=head[f];
    head[f]=cnt;
}
bool tp;
int up[N],size[N],big[N],root;
long long ans;
void dfs(int x,int fa){
    size[x]=1;
    for (int i=head[x];i;i=nxt[i]){
        int v=w[i].t;
        if (v==fa) continue;
        up[v]=w[i].l;
        dfs(v,x);
        size[x]+=size[v];
        big[x]=max(big[x],size[v]);
    }
    ans+=2ll*up[x]*min(size[x],n-size[x]);
    if (size[x]*2==n) tp=1,ans-=up[x];
    if (size[x]*2>=n&&big[x]*2<=n) root=x;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++){
        int u,v,l;
        scanf("%d%d%d",&u,&v,&l);
        add(u,v,l);add(v,u,l);
	}
	dfs(1,0);
	if (!tp){
        int Min=1e9;
        for (int i=head[root];i;i=nxt[i]) Min=min(Min,w[i].l);
        ans-=Min;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 15
#define MAXM 15
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 0;
int N, M, tmp, num[MAXM];
vi K, S[MAXM]; 
bool P[MAXM], flag;


void solve(){
    for(int i = 0; i < (1 << N); i++) {
        fill(num, num+M, 0);
        flag = true;

		for(int j = 0; j < N; j++) {
			if(i & (1 << j)){
                rep(k, S[j].size()){
                    num[S[j][k]]++;
                }
            };
		}

        rep(k, M){
            if(num[k] % 2 != P[k]) flag = false;
        }

        if(flag){
            ans++;
            // cout << bitset<10>(i) << endl;
        } 
    }

    cout << ans << endl;
}

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

    K.resize(M);

    rep(i, M){
        cin >> K[i];
        rep(j, K[i]){
            cin >> tmp;
            tmp--;
            S[tmp].push_back(i);
        }
    }

    rep(i, M) cin >> P[i];

    solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int k,x;
    cin >> k >> x;
    for(int i=x-k+1;i<x+k;i++) {
        if(i<-1000000 || i>1000000) continue; 
        cout << i << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <cassert>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = n % k;
    ans = min(ans, k - ans);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream> 
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
using namespace std; 
typedef long long int ll;

void solve(){
    int x;cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t=1;
  //cin>>t;
  while (t--)	
  solve();
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdlib>
using namespace std;

int N,T,A;
int main () {
    cin >> N >> T >> A;
    int pos = 0;
    int d = 999999999;
    for(int i=0; i<N; i++) {
        int h;
        cin >> h;
        int te = abs((T * 1000 - h * 6) - A * 1000);
        if( te < d ) {
             d = te;
             pos = i;
        }
    }
    cout << pos + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(1, n - 1):
  if p[i] > p[i - 1] and p[i] < p[i + 1]:
    count += 1
  elif p[i] < p[i - 1] and p[i] > p[i + 1]:
    count += 1

print(count)    

Measured memory_bytes: 3060
#表計算を行うプログラムを作成。

r,c=gets.split(" ").map(&:to_i)
h = Array.new(r+1).map{Array.new(c+1,0)} 

for i in 0..r-1                                       # 変数 i を1からr-1まで増やして繰り返し処理する。(arrayゼロから始めるから)
    
a= gets.split.map(&:to_i)
    for j in 0..c-1                                   # 変数 i を0からc-1回まで増やして繰り返し処理する。
    h[i][j] =  a[j]                                   # array のループひとつづつ足していく
    h[i][c] += a[j]
    h[r][j] += a[j]
    h[r][c] += a[j]
    end
end
for i in 0..r                                       #本ループをくりかえす   row 
    for j in 0..c                                   #本ループをくりかえす   column
      print " " unless j == 0
      print h[i][j]                                 #全体結果
    end
    print "\n"
  end




Measured memory_bytes: 7048
#include<stdio.h>

int main(){
  int n=0;
  int ans=0;
  int L[2000];
  
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&L[i]);
  }
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(L[i]<L[j]+L[k] && L[j]<L[k]+L[i] && L[k]<L[i]+L[j])
          ans++;
      }
    } 
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
import sys
import numpy as np

N, M = [int(i) for i in sys.stdin.readline().split()]
edges = [[] for _ in range(N)]
for l in sys.stdin.readlines():
  a, b = [int(i)-1 for i in l.strip().split()]
  edges[a].append(b)
  edges[b].append(a)

def search(p, current_paths):
  #print(current_paths)
  finished_paths = [path for path in current_paths if p in path and len(path) == N]
  unfinished_paths = [tuple(list(path) + [p]) for path in current_paths if p not in path]
  if not unfinished_paths:
    return finished_paths

  paths = []
  for target in edges[p]:
    new_paths = search(target, unfinished_paths)
    paths += new_paths
  paths += finished_paths
  return set(paths + finished_paths)
  
res = search(0, [()])
print(len(res))

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

int main() {
	int n, m;
	string s;
	cin >> n >> m;
	cin >> s;
	int count = 0;
	bool flag = true;
	for (int i = 0; i < s.length(); i++) {
		count++;
		if (i < n&&s[i] == '-')flag = false;
		if (i == n&&s[i] != '-')flag = false;
		if (i > n&&s[i] == '-')flag = false;
	}
	if (n + m + 1 != count)flag = false;
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main(){
    int n,i;
    cin>>n;
    string w;
    set<string> st;
    char c;
    for(i=0;i<n;i++){
        cin>>w;
        if(i!=0 && w[0]!=c) break;
        if(st.count(w)) break;
        st.insert(w);
        c=w[w.size()-1];
    }
    cout<<(i==n?"Yes":"No")<<endl;
    return 0;
}

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

#include <set>
#include <map>
#include <iomanip>

using namespace std;

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

using ll = long long;

int main()
{
	const int M = 'z' - 'a' +1;
	vector<int> range(M, -1);

	string s, t;
	cin >> s >> t;

	int N = s.size();
	s.append(s);

	vector<vector<ll>> pos_mp(M);

	rep(i, s.size())
	{
		pos_mp[s[i] - 'a'].push_back(i);
	}

	ll ans = 0;
	rep(i, t.size())
	{
		int p = t[i] - 'a';

		if (pos_mp[p].size() == 0)
		{
			cout << -1 << endl;
			return 0;
		}
		
		ll now = ans % N;
		ll next = (*lower_bound(all(pos_mp[p]), now)) + 1;

		ans += next - now;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy";
    else if(s=="Cloudy") cout<<"Rainy";
    else cout<<"Sunny";
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define MAX_N 200000

struct UF {
	int par[MAX_N],rank[MAX_N];
	
	void init(int n){
		for(int i = 0; i < n; i++){
			par[i] = i;
			rank[i] = 0;
		}
	}
	
	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}
	
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = par[x];
			if(rank[x] == rank[y]) rank[y]++;
		}
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int n, m;
int l[MAX_N];
int main(){
	mset(l, -1);
	cin>>n>>m;
	UF uf;
	uf.init(n);
	rep(i, n){
		int k;
		cin>>k;
		rep(j, k){
			int t;
			cin>>t;
			if(l[t]<0) l[t] = i;
			else uf.unite(l[t], i);
		}
	}
	bool ok = true;
	rep(i, n) if(!uf.same(0, i)) ok = false;
	cout<<(ok?"YES":"NO")<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
const int INF=INT_MAX;
vvll con(15,vll(15,-1));//con[i][j]=人iが人jを正直/不親切と思っている

int main(){
  int n,count=0;
  cin>>n;
  
  REP(i,n){
    int a;cin>>a;
    REP(j,a){
      int x,y;cin>>x>>y;
      con[i][x-1]=y;
    }
  }
  REP(i,1<<n){
    bool ok=true;
    bitset<15> a(i);int t=bitset<32>(i).count();
    if(t<=count){continue;}
    REP(j,n){
      if(a.test(j)){
        for(int k=0;k<n;k++){
          if(con[j][k]==-1){continue;}
          else{
            if(a[k]!=con[j][k]){ok=false;break;}
          }
        }
      }
    }
    if(ok){count=t;}
  }
  cout<<count<<endl;
}

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

using namespace std;
typedef long long ll;

#define MAX (200000 + 5)

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> h[MAX];
  for (int i=0; i<m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    h[a].push_back(b);
  }

  for (int next: h[1]) {
    for (int last: h[next]) {
      if (last == n) {
        printf("POSSIBLE\n");
        return 0;
      }
    }
  }
  printf("IMPOSSIBLE\n");
}


Measured memory_bytes: 8576
import java.util.Scanner;

public class Main {
	static void quick_sort(int[] d, int left, int right) {
		if (left >= right) {
			return;
		}
		int p = d[(left + right) / 2];
		int l = left, r = right;
		int tmp;
		while (l <= r) {
			while (d[l] < p) {
				l++;
			}
			while (d[r] > p) {
				r--;
			}
			if (l <= r) {
				tmp = d[l];
				d[l] = d[r];
				d[r] = tmp;
				l++;
				r--;
			}
		}
		quick_sort(d, left, r); // ピボットより左側をクイックソート
		quick_sort(d, l, right); // ピボットより右側をクイックソート
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int address[] = new int[N];
		for (int i = 0; i < N; i++) {
			address[i] = sc.nextInt();
		}
		if (N == 1) {
			System.out.println(0);
		} else {

			quick_sort(address, 0, N - 1);
			int sum = 0;
			int min = 0;
			for (int i = 0; i < N; i++) {
				min += address[i] * address[i];
			}

			for (int i = 1; i <= 100; i++) {
				for (int j = 0; j < N; j++) {
					sum += (address[j] - i) * (address[j] - i);
				}
				if (sum < min) {
					min = sum;
				}
				sum = 0;
			}

			System.out.println(min);
		}
	}
}


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

using namespace std;

bool isPrime[55000];
vector<int> prime;

void primeCalc()
{
	for(int i = 0; i < 55000; ++i)
	{
		isPrime[i] = true;
	}
	isPrime[0] = isPrime[1] = false;
	for(int i = 2; i < 55000; ++i)
	{
		if(isPrime[i])
		{
			prime.push_back(i);
			for(int j = 2 * i; j < 55000; j += i)
			{
				isPrime[j] = false;
			}
		}
	}
}

void solve()
{
	primeCalc();
	int n;
	while(cin >> n)
	{
		int pos = 0;
		while(true)
		{
			if(prime[pos] >= n)
			{
				cout << prime[pos - 1] << " ";
				break;
			}
			++pos;
		}
		if(prime[pos] == n)
		{
			cout << prime[pos + 1] << endl;
		}
		else
		{
			cout << prime[pos] << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1324
/*
 * Author : Sadi
 * Thu 09/07/2020
 *  0:01:23.58
 */
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

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

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

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

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

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



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

    int a, b;
    cin >> a >> b;
    int plugs = 1;
    int ans = 0;
    while(plugs < b) {
    	plugs--;
    	plugs += a;
    	ans++;
    }
    cout << ans << endl;
    return 0;	
}


Measured memory_bytes: 3604
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007
#A
def A():
    t,x = LI()
    print(t/x)

#B
def B():
    n = I()
    a = LI()
    m = max(a)
    if m >= sum(a)-m:
        print("No")
    else:
        print("Yes")

#C
def C():
    n,m = LI()
    x = LI()
    x.sort()
    l = [x[i+1]-x[i] for i in range(m-1)]
    l.sort()
    l = l[::-1]
    ans = sum(l[max(n-1,0):])
    print(ans)
#D
def D():
    n,k = LI()
    a = LI()
    k = list(map(int,list(bin(k)[2:])))
    l = len(k)
    for i in range(n):
        a[i] = list(map(int,list(bin(a[i])[2:])))
        l = max(l,len(a[i]))
    for i in range(n):
        for j in range(l-len(a[i])):
            a[i].insert(0,0)
    for j in range(l-len(k)):
        k.insert(0,0)
    s = [[0,0] for i in range(l)]
    pow2 = [1 for i in range(l)]
    for i in range(l-1)[::-1]:
        pow2[i] = pow2[i+1]*2
    for i in a:
        for j in range(l):
            s[j][0] += pow2[j]*i[j]
            s[j][1] += pow2[j]*(not i[j])
    dp = [0 for i in range(l+1)]
    small = False
    for i in range(l):
        if not small:
            if not k[i]:
                dp[i+1] += dp[i]+s[i][0]
            else:
                if s[i][0] >= s[i][1]:
                    dp[i+1] += dp[i]+s[i][0]
                    small = True
                else:
                    dp[i+1] += dp[i]+s[i][1]
        else:
            dp[i+1] += dp[i]+max(s[i])
    print(dp[l])

#E
if __name__ == "__main__":
    D()

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 116768
#include<bits/stdc++.h>
  #define ll long long
  const ll mod=1e9+7;
  using namespace std;
  ll power(ll a,ll c)
{

   ll ans=1,b=c;
  if(b==0)
  cout<< 1<<endl;
  while(b!=1)
{
    if(b%2==1)
    ans=ans*a%mod;

    a=a*a%mod;
   b=b/2;

  }
  cout<<ans*a%mod<<endl;



  }

  int main()
  {
    ll a,b;
    cin>>a>>b;
    power(a,b);

return 0;

  }



Measured memory_bytes: 3100
// ※※※ 解答不能 ※※※
// 解き直し.
// tourist氏.
// https://atcoder.jp/contests/arc103/submissions/3296203
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

int main(){

    int N;
    scanf("%d", &N);
    vector<LL> d(N);
    vector<int> weight(N, 1);
    map<LL, int> mp;
    for(int i = 0; i < N; i++){
        scanf("%lld", &d[i]);
        mp[d[i]] = i;
    }
    
    vector<pair<int, int>> res;
    for(int itt = 0; itt < N - 1; itt++){
        auto it = mp.rbegin();
        int i = it->second;
        LL want = d[i] - (N - weight[i]) + weight[i];
        if(mp.find(want) == mp.end() || mp[want] == i){
            printf("%d\n", -1);
            return 0;
        }
        int j = mp[want];
        res.emplace_back(i, j);
        weight[j] += weight[i];
        mp.erase(--mp.end());
    }
    
    vector<LL> real_dist(N, -1);
    real_dist[0] = 0;
    vector<vector<int>> g(N);
    for(auto &p : res){
        g[p.first].push_back(p.second);
        g[p.second].push_back(p.first);
    }
    
    vector<int> que(1, 0);
    for(int b = 0; b < (int)que.size(); b++){
        for(int j : g[que[b]]){
            if(real_dist[j] == -1){
                que.push_back(j);
                real_dist[j] = real_dist[que[b]] + 1;
            }
        }
    }
    if(accumulate(real_dist.begin(), real_dist.end(), 0LL) != d[0]){
        printf("%d\n", -1);
        return 0;
    }
    
    for(auto &p : res) printf("%d %d\n", p.first + 1, p.second + 1);

    return 0;

}

Measured memory_bytes: 10488
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    long long int A,B;
    char op;
    cin >> A >> op >> B;
    if(op=='+'){
        cout << A + B; 
    }
    else{
        cout << A - B;
    }
}

Measured memory_bytes: 256
import math

N = int(input())

prime = []
for i in range(2, 55556):
    flag = True
    for j in range(2, int(math.sqrt(i)) + 1):
        if i % j == 0:
            flag = False
            break
    if flag and i % 5 == 1:
        prime.append(i)

print(" ".join(map(lambda x: str(x), prime[:N])))


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

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

    vector<int_fast64_t> a(N);
    vector<vector<int_fast64_t>> ans(N, vector<int_fast64_t>(N));
    for(auto& i : a)scanf("%lld", &i);

    for(auto i = 0; i < N; ++i)
        ans[i][i] = a[i] * (N & 1 ? 1 : -1);


    for(auto i = 1; i < N; ++i)
        for(auto j = 0; i + j < N; ++j)
            ans[j][i + j] = (i ^ N) & 1 ? max(ans[j][i + j - 1] + a[i + j], ans[j + 1][i + j] + a[j]) : min(ans[j][i + j - 1] - a[i + j], ans[j + 1][i + j] - a[j]);

    cout << ans[0][N - 1] << endl;

    return 0;
}

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

int main(){
	int *array = new int[3];
	int ans=0;

	for(int i=0;i<3;i++)cin >>array[i];

	sort(array,array+3);

	while(array[0]!=array[1]||array[1]!=array[2]||array[0]!=array[2]){
		if(array[2]>array[1]){
			array[1]++;
			array[0]++;
		}
		else array[0]+=2;
		if(array[2]<array[0])sort(array,array+3);
		ans++;
	}
	cout<<ans<<endl;
	return 0;	
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 1000001



int partition(int *A, int p,int r){
    int i,j,x,t;
    x = A[r];
    i = p-1;
    for(j = p;j<r;j++){
        if(A[j] <= x){
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t =A[i+1]; A[i+1] = A[r]; A[r] =t;
    return i+1; 
}

int main(){
    int A[MAX];
    int n;
    int q =0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    q = partition(A,0,n-1);
    for(int i=0;i<n;i++){
        if(i != 0)putchar(' ');
        if(i == q) putchar('[');
        printf("%d",A[i]);
        if(i == q)putchar(']');
    
    }
    putchar('\n');
    return 0;
}


Measured memory_bytes: 3584
n = int(input())
 
cnt_2 = 0
if n < 105:
    print(0)
else:
    for i in range(105,n+1,2):
        cnt = 0
        for j in range(1,i+1):
            if i % j == 0:
                cnt += 1
        if cnt == 8:
            cnt_2 += 1
    print(cnt_2)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
string str;
int main(){
	cin >> str;
	for(int i = 0 ; i + 1 < str.size() ; ++i){
		if(str[i] == 'A' && str[i + 1] == 'C'){
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}

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

using I = long long;

int main() {
  I X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<I> A(X), B(Y), C(Z);
  for(auto& v: {&A, &B, &C}) for(auto& i: *v) cin >> i;

  vector<I> sum;
  for(auto a: A) for(auto b: B) sum.emplace_back(a+b);
  sort(begin(sum), end(sum), greater<I>());

  sort(begin(C), end(C), greater<I>());

  priority_queue<I, vector<I>, greater<I>> q;
  for(auto i=0; i<min<I>(K,sum.size()); ++i) {
    auto s = sum[i];
    for(auto c: C) {
      if(q.size() < K) {
        q.emplace(s+c);
      } else {
        if(s+c <= q.top()) break;
        q.emplace(s+c);
        q.pop();
      }
    }
  }

  vector<I> v;
  while(!q.empty()) {
    v.emplace_back(q.top());
    q.pop();
  }
  reverse(begin(v), end(v));
  for(auto i: v) cout << i << endl;
}


Measured memory_bytes: 10608
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,a,ans;
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a>=m)ans++;
    }
    cout<<ans<<endl;
}


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

int main() {
    int n; cin >> n;
    long long k; cin >> k;
    vector<long long> a(n);
    long long sum_a = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum_a += a[i];
    }
    set<long long> factors;
    for (int i = 1; i * i <= sum_a; i++) {
        if (sum_a % i == 0) {
            factors.insert(i);
            factors.insert(sum_a / i);
        }
    }
    for (auto it = factors.rbegin(); it != factors.rend(); it++) {
        long long i = *it;
        if (sum_a % i != 0) continue;
        vector<long long> r(n);
        for (int j = 0; j < n; j++) {
            r[j] = a[j] % i;
        }
        sort(r.begin(), r.end());
        long long total = accumulate(r.begin(), r.end(), 0LL);
        int l = n - total / i;
        long long count = accumulate(r.begin(), r.begin() + l, 0LL);
        if (count <= k) {
            cout << i << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		System.out.println(N * N);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21716
while 1:
    try:
        a, b, c = map(int, input().split())
        x = a * 10000 + b * 100 + c

        if x <= 18680907:
            print('pre-meiji')
        elif 18680908 <= x and x <= 19120729:
            print('meiji', (a-67) % 100, b, c)
        elif 19120730 <= x and x <= 19261224:
            print('taisho', (a-11) % 100, b, c)
        elif 19261225 <= x and x <= 19890107:
            print('showa', (a-25) % 100, b, c)
        else:
            print('heisei', (a - 88) % 100, b, c)
    except:
        break



Measured memory_bytes: 5596
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

int main(int argc, char **argv){
	int a, b, c;
	int cnt = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		if (c % i == 0) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B+C || B==A+C || C==A+B){
  cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       N: usize,
       X:usize,
       T:usize,
    }

    let mut ans: usize = ((N + X - 1) / X) * T;

    echo!(ans);
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll A, B;
ll i, j, k;
int main(){
    scanf("%lld%lld", &A,&B);
    fornum(i,0,100000){
        ll a = i * 8 / 100;
        ll b = i * 10 / 100;
        if(a==A&&b==B){
            break;
        }
    } 
    if(i!=100000){
        printf("%lld", i);
    }else{
        printf("-1");
    }
    return 0;
}

Measured memory_bytes: 256
from string import ascii_lowercase


def answer(s: str) -> str:
    not_in_s = list(set(ascii_lowercase) - set(s))
    if not not_in_s:
        return 'None'
    not_in_s.sort()

    return not_in_s[0]


def main():
    s = input()
    print(answer(s))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9920
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char ch[3][3];
int main(){
	int i,j;
	for(i=0;i<3;i++){
		scanf("%s",ch[i]);
	}
	printf("%c%c%c\n",ch[0][0],ch[1][1],ch[2][2]);
	return 0;
} 

Measured memory_bytes: 128
N,M,Q= list(map(int, input().split()))
LR = [list(map(int, input().split())) for _ in range(M)]
PQ = [list(map(int, input().split())) for _ in range(Q)]

import numpy as np
from itertools import combinations

trains = [[0]*N for _ in range(N)]

for l, r in LR:
  trains[l-1][r-1] +=1
  
trains = np.array(trains)

# 二次元累積和
row_sum = trains.cumsum(axis=1)
matrix_sum = row_sum.cumsum(axis=0)

answer = {}

for p,q in PQ:
  if (p,q) not in answer:
    if p==1:
      answer[(p,q)] = matrix_sum[q-1, q-1]
    else:
      answer[(p,q)] = matrix_sum[q-1,q-1] - matrix_sum[p-2,q-1]
  print(answer[(p,q)])

Measured memory_bytes: 89848
M,D=map(int, input().split())

seki=0
for m in range(1,M+1):
    for d in range(1,D+1):
        str_d = str(d)
        if len(str_d)==2:
            d10 = int(str_d[0])
            d1  = int(str_d[1])
            if d10 >= 2 and d1 >= 2 and d10*d1 == m:
                seki+=1
print(seki)

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
		ll N,A,B;
	cin >> N>>A>>B;
	vecl(H);
	fx(N) {
		vecpl(H);
	}
	A -= B;
	ll left = 0, right = 2000000000;
	ll mid;
	while(right-left>1) {
		mid = (left + right ) / 2;
		ll k = mid;
		fy(N) {
			if (H[y] >mid*B) {
				//ll tmp = (H[y] - mid * B);
				//k -= (tmp + A - 1) / A;
				k -= ((H[y] - mid * B) + A - 1) / A;
			/*	if ((H[y]-mid*B)%A==0) {
					k -= ((H[y] - mid * B) + A - 1) / A;
					//doublece((H[y] - mid * B) / A, ((H[y] - mid * B) + A - 1) / A)
				}
				else {
					k -= ((H[y] - mid * B) + A - 1) / A;
					//doublece((H[y] - mid * B) / A + 1, ((H[y] - mid * B) + A - 1) / A)
				}*/
			}
		}

		if (k >= 0) {
			right = mid;
		}
		else {
			left = mid;
		}
	}
	//doublece(left,right)
	ce(right)
	

    return 0;
}



Measured memory_bytes: 1400
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int max = Math.max(a+b,a-b);
        max = Math.max(max,a*b);
        System.out.println(max);

    }
}

Measured memory_bytes: 23636
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

k = INT()
l =[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
]
print(l[k-1])



Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
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; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

ll N;
vll A(300000, -1*INF);
vll even(300000, 0), odd(300000, 0);
vll esum(300000, 0), osum(300000, 0);
vll dp(300000, -1*INF); //dp.at(i)は最初からi桁目まで
vvll dp2(300000, vll(2, -1*INF));

int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    if(i%2==0) even.at(i) = A.at(i);
    else odd.at(i) = A.at(i);
  }
  for(int i = 0; i < N; i++){
    esum.at(i+1) = esum.at(i) + even.at(i);
    osum.at(i+1) = osum.at(i) + odd.at(i);
  }
  //偶数桁まで
  dp2.at(2).at(0) = A.at(0);
  dp2.at(2).at(1) = A.at(1);
  for(int i = 2; i < N; i+=2){
    dp2.at(i+2).at(0) = dp2.at(i).at(0) + A.at(i);
    dp2.at(i+2).at(1) = max(dp2.at(i).at(0) + A.at(i+1), dp2.at(i).at(1) + A.at(i+1));
  }
  for(int i = 2; i <= N; i+=2){
    dp.at(i) = max(dp2.at(i).at(0), dp2.at(i).at(1));
  }
  
  dp.at(1) = 0;
  dp.at(3) = max(A.at(0), max(A.at(1), A.at(2)));
  for(int i = 3; i <= N; i+=2){
    dp.at(i+2) = max(dp.at(i+1), dp.at(i) + A.at(i+1));
  }
  cout << dp.at(N) << endl;
}

Measured memory_bytes: 33428