akhauriyash/Code-Regression huggingface dataset:
num = int(input())
nu_list = [int(v) for v in input().split()]
count = 0
#print(nu_list)
bool = True
while bool == True:
  for i in range(len(nu_list)):
    if nu_list[i] % 2 != 0:
      bool = False
      break
    else:
      nu_list[i] = nu_list[i] // 2
  if bool == True:
    count += 1 
print(count)

Measured memory_bytes: 9200
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;

    ll n;
    cin>>n;
    ll a[20],b[20];
    ll m=0;
    rep(i,n){
        cin>>a[i];
        chmax(m,a[i]);
    }
    rep(i,n){
        cin>>b[i];
        chmax(m,b[i]);
    }
    ll dp[1<<19][60];
    rep(j,60) dp[0][j]=0;
    rep2(bit,1,(1<<19))rep(j,60) dp[bit][j]=LLINF;

    rep(bit,(1ll<<n)){
        ll cnt=0;
        
        rep(i,n){
            if(bit&(1<<i)) cnt++;
        }
        rep(i,n){
            if(bit&(1<<i)) continue;
            ll add=0;
            rep(j,n){
                if(bit&(1<<j) && (j>i)){
                    add++;
                }
            }
            ll now;
            if(cnt%2==i%2) now=a[i];
            else now=b[i];
            rep(num,now+1){
                if(dp[bit][num]!=LLINF){
                    chmin(dp[bit|(1<<i)][now],dp[bit][num]+add);
                }
            }
        }
    }


    // rep(i,(1<<n)){
    //     rep(j,m+1){
    //         cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
    //     }
    //     cout<<endl;
    // }


    ll ans=LLINF;
    rep(i,60){
        chmin(ans,dp[(1<<n)-1][i]);
    }
    if(ans==LLINF) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 246016
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>

typedef long long LL;
typedef unsigned int UI;
typedef long double LD;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)
#define SWAP(x,y) 		((x!=y)&&(x^=y,y^=x,x^=y))

#define MOD  			(LL)1000000007;
#define INF  			(LL)1 << 62;

using namespace std;

typedef struct tagXY {
	int x;
	int y;
} XY;

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

int H, W;
vector<vector<char> >s;
vector<vector<int> >cost;

int bfs() {

	queue<XY>Q;
	XY wrk;

	wrk.x = 0;
	wrk.y = 0;

	Q.push(wrk);
	cost[0][0] = 0;

	while (!Q.empty()) {
		XY p = Q.front();
		Q.pop();
		if ((p.x == W - 1) && (p.y == H - 1)) {
			return cost[p.y][p.x];
		}
		for (int i = 0; i < 4; i++) {
			int Y = p.y + dy[i];
			int X = p.x + dx[i];
			if (X < 0 || W <= X || Y < 0 || H <= Y)
				continue;
			if (s[Y][X] == '#')
				continue;
			if (cost[Y][X] != -1)
				continue;
			cost[Y][X] = cost[p.y][p.x] + 1;
			wrk.x = X;
			wrk.y = Y;
			Q.push(wrk);
		}
	}

	// たどり着けない場合
	return -1;
}

int main(int argc, char* argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> H >> W;

	s.assign(H, vector<char>(W));
	cost.assign(H, vector<int>(W, -1));
	int white = 0;

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> s[i][j];
			if (s[i][j] == '.') {
				white++;
			}
		}
	}

	int min_cost = bfs();

	if (min_cost == -1) {
		cout << -1 << endl;
	}
	else {
		cout << white - (min_cost + 1) << endl;
	}

	return 0;
}



Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
	int A = stdIn.nextInt();
	int B = stdIn.nextInt();
	int t = N*A;
	if(t>B){
	    t = B;
	}
	System.out.println(t);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
const int N=200005;
using namespace std;
int n,num;
map<string,int>a;
string s;
int main(){
    cin>>n;
    for(int i=0;i<n;i++)
	{
        cin>>s;
        if(a[s]==0) num++,a[s]++;
    }
    cout<<num;
    return 0;
}

Measured memory_bytes: 19200
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    ll zero = 0;
    vector<ll> plus, minus;
    rep(i,0,N){
        if(A[i] == 0) zero++;
        else if(A[i] > 0) plus.push_back(A[i]);
        else minus.push_back(A[i]);
    }
    sort(plus.begin(), plus.end());
    sort(minus.begin(), minus.end());

    ll zero_cnt = N*(N-1)/2 - (N-zero) * (N-zero-1) / 2;
    ll lv = -1e18+1, rv = 1e18+1;
    ll nplus = plus.size(), nminus = minus.size();

    while(rv - lv > 1){
        ll mid = (rv + lv) / 2;
        ll res = 0, res2 = 0;
        rep(i,0,nplus){
            ll v = plus[i];
            if(mid >= 0){
                ll target = mid / v;
                ll pos = upper_bound(plus.begin(), plus.end(), target) - plus.begin();
                res += max(0LL, pos - (i+1));
            }
            if(mid >= 0){
                res2 += nminus;
            }else{
                ll target = - (-mid + v - 1) / v;
                ll pos = upper_bound(minus.begin(), minus.end(), target) - minus.begin();
                res2 += pos;
            }
        }

        rep(i,0,nminus){
            ll v = minus[i];
            if(mid >= 0){
                ll target = (-1) * (mid / -v);
                ll pos = lower_bound(minus.begin(), minus.end(), target) - minus.begin();
                res += min(nminus - pos, nminus - i - 1);
            }
            if(mid >= 0){
                res2 += nplus;
            }else{
                ll target = (-mid + abs(v) - 1) / abs(v);
                ll pos = lower_bound(plus.begin(), plus.end(), target) - plus.begin();
                res2 += nplus - pos;
            }

        }

        res += res2 / 2;
        if(mid >= 0) res += zero_cnt;

        if(res >= K){
            rv = mid;
        }else{
            lv = mid;
        }
    }
    print(rv);

}

Measured memory_bytes: 3956
#include <stdio.h>

int main (){
    int a,b;
    while(1){
        scanf("%d%d",&a,&b);
        if (a == 0 && b == 0) break;
        for (int i = 0; i < a; i++){
            for (int j = 0; j < b; j++){
                if (i == 0 || i == a-1 || j == 0 || j == b-1) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2520
N,M=map(int,input().split())
edges=[[] for i in range(N)]

for i in range(M):
	a,b=map(int,input().split())
	edges[a-1]+=[b-1]
	edges[b-1]+=[a-1]

low=[-1]*N
pre=[-1]*N

def dfs(u,count,p):
	pre[u] = count;
	low[u] = pre[u];
	for v in edges[u]:
		if pre[v] == -1:
			low[u] = min(low[u], dfs(v,count+1,u))
		else:
			if v == p:
				continue
			low[u] = min(low[u], low[v])
	return low[u]

count=0
dfs(0,count,-1)
res=0

for i in range(1,N):
#	print("low: ", low[i] , " pre: ", pre[i])
	res += (1 if low[i] == pre[i] else 0)

print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;
#define n_max 1000

int main()
{
    int S, K;
    int cnt = 0;

    cin >> K >> S;

    for(int x = 0; x <= K; x++){
        for(int y = 0; y <= K; y++){
            int z = S - x - y;
            if(0 <= z && z <= K) { 
                cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
ll a[100005];
int main()
{
    int n,ans;
    while(~scanf("%d",&n))
    {
        for(int i=0;i<n;i++)
            scanf("%lld",&a[i]);
        sort(a,a+n);
        ans=n;
        for(int i=0;i<n-1;i++)
        {
            if(a[i]==a[i+1])
            {
                ans-=2;
                i++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>

using namespace std;

int m,s,g;
int a[7],n[501];
int path[501][501];
int dist[501];
int main(void){
	scanf("%d",&m);
	for(int i=1;i<=6;i++)scanf("%d",&a[i]);
	scanf("%d%d",&s,&g);
	for(int i=1;i<=m;i++)scanf("%d",&n[i]);
	for(int i=1;i<=m;i++){
		dist[i]=5000000;
		for(int j=1;j<=m;j++)path[i][j]=5000000;
		path[i][i]=0;
	}
	for(int i=1;i<=m;i++){
		for(int j=1;j<=6;j++){
			for(int k=-1;k<=1;k+=2){
				int np=i+a[j]*k;
				if(np<=0 || np>m)continue;
				np+=n[np];
				if(np<=0 || np>m)continue;
				path[i][np]=min(path[i][np],1);
			}
		}
	}
	for(int k=1;k<=m;k++){
		for(int i=1;i<=m;i++){
			for(int j=1;j<=m;j++){
				path[i][j]=min(path[i][j],path[i][k]+path[k][j]);
			}
		}
	}
	int nn=s;
	while(nn!=g){
		int dis;
		scanf("%d",&dis);
		int best=0,goods=path[nn][g],nc=nn;
		for(int i=-1;i<=1;i+=2){
			int np=nn+a[dis]*i;
			if(np<=0 || np>m)continue;
			np+=n[np];
			if(np<=0 || np>m)continue;
			if(goods>path[np][g]){
				goods=path[np][g];
				best=i;
				nc=np;
			}
		}
		nn=nc;
		printf("%d\n",best);
		fflush(stdout);
	}
	return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>

//using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> w(n);
  rep(i, n) cin >> w[i];

  auto is = [&](ll lim){
    int now = 0;
    int b = 0;
    for (int i = 0; i < n; i++) {
      if(w[i] > lim) return false;
      now += w[i];
      if(now > lim){
        now = 0;
        b++;
        i--;
      }
    }
    if(now > 0) b++;
    // cout << b << endl;
    if(b <= k) return true;
    else return false;
  };

  ll ok = LLONG_MAX/2ll;
  ll ng = -1;
  while(ok - ng > 1){
    ll mid = (ok+ng) / 2ll;
    if(is(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;

}



Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    char b;cin>>b;
    char ans;
    if(b=='A')ans='T';
    if(b=='T')ans='A';
    if(b=='G')ans='C';
    if(b=='C')ans='G';
    cout<<ans<<endl;
}


Measured memory_bytes: 3576
// フェルマーの小定理
package main

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

const (
	m = 1000000007
)

func mpow(x, y int) int {
	result := 1
	for y != 0 {
		if y&1 == 1 {
			result *= x
			result %= m
		}
		x *= x
		x %= m
		y >>= 1
	}
	return result
}

var (
	fac []int
)

func mcomb(n, k int) int {
	if n == 0 && k == 0 {
		return 1
	}
	if n < k || k < 0 {
		return 0
	}
	return (fac[n] * mpow(fac[n-k], m-2) % m) * mpow(fac[k], m-2) % m
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	defer flush()

	N := readInt()
	K := readInt()

	n := max(K, N-K+1)
	fac = make([]int, n+1)
	fac[0] = 1
	for i := 0; i < n; i++ {
		fac[i+1] = fac[i] * (i + 1) % m
	}

	for i := 1; i <= K; i++ {
		println(mcomb(K-1, i-1) * mcomb(N-K+1, i) % m)
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdoutWriter, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 1856
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

#[fastout]
fn main() {
   input! {
      n:usize,
      a:[usize;n]
   }

   if n == 3 {
      println!("{} {} {}", 0, a[1], a[2]);
      return;
   }

   let mut left = vec![0];
   let mut right = vec![0];
   for i in 0..n {
      let buf = *left.last().unwrap();
      left.push(buf ^ a[i]);
   }
   for i in (0..n).rev() {
      let buf = *right.last().unwrap();
      right.push(buf ^ a[i]);
   }
   for i in 0..n {
      print!("{} ", left[i] ^ right[n - i - 1]);
   }
   println!("");
}


Measured memory_bytes: 9512
#include<stack>
#include<iostream>
#include<stdlib.h>

using namespace std;

int main(){
	stack<int> S;
	int a, b, c;
	string s;

	while (cin >> s){
		if (s[0] == '+'){
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a + b);
		}
		else if (s[0] == '-'){
			b = S.top(); S.pop();
			a = S.top(); S.pop();
			S.push(a - b);
		}
		else if (s[0] == '*'){
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a*b);
		}
		else{
			S.push(atoi(s.c_str()));
		}
	}
	cout << S.top() << endl;
	return 0;
}

Measured memory_bytes: 3160
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793

int main(){
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	int answer;
	if(a*b>c*d){
		answer = a*b;
	}
	else answer = c*d;
	printf("%d\n", answer);

	return 0;
}

Measured memory_bytes: 128
import math,sys
sys.setrecursionlimit(20000000)
N = int(input())
memo = [-1 for i in range(110000)]
def calculate(n):

    if n == 0:
        memo[n] = 0
        return 0

    if memo[n] != -1:
        return memo[n]

    res = n

    pow6Num = 1
    while pow6Num*6 <= n:
        pow6Num = pow6Num * 6
        res = min(res, calculate(n - pow6Num) + 1)


    pow9Num = 1
    while pow9Num*9 <= n:
        pow9Num = pow9Num * 9
        res = min(res, calculate(n - pow9Num) + 1)

    memo[n] = int(res)
    return int(res)



result = calculate(N)
print(memo[N])

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


int main() {
    long long K,N;
    cin >> K >> N;
    vector<long long> V(N);
    for(int i=0;i<N;i++){
        cin >> V.at(i);
    }
    
    long long Max=abs(V.at(0)+K-V.at(N-1));
    for(int i=1;i<N;i++){
        long long cal;
        cal=abs(V.at(i)-V.at(i-1));
        if(cal>Max) Max=cal;
    }

    long long ans=K-Max;

    cout << ans << endl;

    
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int Pow(int n, int m);
int Max(int N[], int n);
int Min(int N[], int n);
int Sum(int N[], int n);




int main()
{
	int N = 0, M = 0, X = 0, Y = 0;
	scanf("%d%d%d%d", &N, &M, &X, &Y);

	int x[100] = { 0 };
	int y[100] = { 0 };

	for (int i = 0; i < N; i++) {
		scanf("%d", &x[i]);
	}

	for (int i = 0; i < M; i++) {
		scanf("%d", &y[i]);
	}

	if (Max(x, N) < Min(y, M) && Max(x, N) < Y && X + 1 < Min(y, M)) printf("No War");
	else printf("War");

	return 0;

}

int Pow(int n, int m) {
	int ret = 1;

	for (int i = 0; i < m; i++) {
		ret *= n;
	}

	return ret;
}

int Max(int N[], int n) {
	int max = N[0];

	for (int i = 0; i < n; i++) {
		max = max < N[i] ? N[i]: max;
	}

	return max;
}

int Min(int N[], int n) {
	int min = N[0];

	for (int i = 0; i < n; i++) {
		min = min > N[i] ? N[i] : min;
	}

	return min;
}

int Sum(int N[], int n) {
	int sum = 0;

	for (int i = 0; i < n; i++) {
		sum += N[i];
	}

	return sum;
}

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

typedef unsigned long long ll;

const int MAX_N=3e5+10;
const int MAX_D=65;
const ll MOD=1e9+7;

ll a[MAX_N],N,ans=0ll;
ll sum[MAX_N][MAX_D];
ll d[MAX_N][MAX_D];

int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++) scanf("%lld",&a[i]);
	for(int i=0;i<N;i++) for(int j=0;j<63;j++){
		ll now=(1ll<<j);
		ll flag=ll(a[i])&now;
		if(flag) d[i][j]=1;
		else d[i][j]=0;
	}
	for(int i=N-1;i>=0;i--) for(int j=0;j<63;j++){
		sum[i][j]+=sum[i+1][j];
		sum[i][j]+=d[i][j];
	}
	for(int i=0;i<N-1;i++){
		for(int j=0;j<63;j++){
			ll now=(1ll<<j);
			now%=MOD;
			if(d[i][j]){
				ans=(ans+(ll(N-1ll-i-sum[i+1][j])*now)%MOD)%MOD;
			}
			else{
				ans=(ans+ll(sum[i+1][j]*now)%MOD)%MOD;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

/*
2
1 8796093022208
*/

Measured memory_bytes: 307328
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s;int cnt=0;
	cin>>s;
	for(int i=0;i<s.size()/2;i++) 
		if(s[i]!=s[s.size()-i-1])
			cnt++;
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 256
//
// Created by sark2 on 23-10-2019.
//

#include "bits/stdc++.h"

using namespace std;
#define PB push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)
#define MP make_pair

using ll = long long;
using ld = long double;

ll mod = 1e9 + 7;



int fun(vector<int>& a, int n, int val){
    int lo = 0, hi = n;

    while(hi-lo > 1){
        int tm = (lo+hi)/2;
        if(a[tm] < val){
            lo = tm;
        }else{
            hi = tm-1;
        }
    }

    if(a[hi] < val)
        return hi;
    else if(a[lo] < val)
        return lo;
    else
        return -1;
}

int main() {
    IOS

   int n; cin>>n;

   vector<int>l(n);
   for(int i = 0; i < n; i++)cin>>l[i];

   sort(l.begin(), l.end());


   int ans = 0;
   for(int i = 0; i < n-2; i++){
       //cout<<"@@"<<i<<" : ";
       for(int j = i+1; j < n-1; j++){
        //   cout<<j<<" : ";
           int add= fun(l, n, l[i]+l[j]);
          // cout<<"$"<<add<<"\n";
               if (add != -1 && add > j) {
                   if(add == n)
                       ans += (add-j-1);
                   else
                    ans += (add - j);
               }
           }
       //cout<<endl;
       }


   cout<<ans;

/* cout<<fun(l, n, 2);*/


}


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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll a; cin >> a;
  double b; cin >> b;
  ll bb = b * 100 + 0.1;
  a *= bb;
  cout << a / 100 << endl;

  return 0;
}



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

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  rd(int, n, x);
  V<int> m(n);
  rep(i, n) cin >> m[i];
  wt((x - accumulate(all(m), 0)) / *min_element(all(m)) + n);
}


Measured memory_bytes: 3604
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    L = list(map(int, input().split()))

    L.sort()
    count = 0
    for j in range(1, N - 1):
        for i in range(j):
            if L[i] == L[j]:
                break
            t = L[i] + L[j]
            for k in range(j + 1, N):
                if L[j] != L[k]:
                    if t > L[k]:
                        count += 1
                    else:
                        break

    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9196
#include <iostream>

using namespace std;

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int dx = x2 - x1;
    int dy = y2 - y1;

    int x3 = x2 - dy;
    int y3 = y2 + dx;
    int x4 = x3 - dx;
    int y4 = y3 - dy;

    cout << x3 << " " << y3 << " "
         << x4 << " " << y4 << endl;
}


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

int N = 0;//?£?????±±??????????????°
int h[100], m[100];
int M = 0;//?¶´??¶?????????????????°
int k[100], g[100];
vector<int> L;

void timetable() {
	for (int i = 0; i < N; i++) {
		L.push_back(60 * h[i] + m[i]);
	}
	for (int i = N; i < N + M; i++) {
		L.push_back(60 * k[i - N] + g[i - N]);
	}
	sort(L.begin(), L.end());
	L.erase(unique(L.begin(), L.end()), L.end());
}


int main()
{
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> h[i] >> m[i];
	}

	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> k[i] >> g[i];
	}

	timetable();

	for (int i = 0; i < L.size(); i++) {

		if (L[i] % 60 < 10) {
			cout << L[i] / 60 << ':' << '0' << L[i] % 60;
		}
		else {

			cout << L[i] / 60 << ':' << L[i] % 60;
		}
		if (i < L.size() - 1) {
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int n;
  map<string, int> mp;
  string s;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    mp[s]++;
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> s;
    mp[s]--;
  }
  int max = 0;
  for (auto itr : mp) {
    if (itr.second > max) {
      max = itr.second;
    }
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

const double PI = 3.1415926;

int main()
{
	double R;
	cin >> R;

	cout << 2.0 * PI * R << endl;

	return 0;
}

Measured memory_bytes: 3788
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    p = LI()

    ans = 0
    min_now = p[0]

    for i in range(N):
        if p[i] <= min_now:
            ans += 1
            min_now = p[i]

    print(ans)


main()


Measured memory_bytes: 103428
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int N;
long A[300000];
long B[300000];
long ans;

long sub(long n){
  long x=n;
  long k=1;
  while (x>1){
    x=x>>1;
    k*=2;
  }
  return k-(n-k);
}

int sub2(long n,long X[300000],long Y[300000],int p,int q){
  int r;
  while (p<=q){
    r=(p+q)/2;
    if (n==X[r]){
      break;
    }
    else if (n<X[r]){
      q=r-1;
    }
    else{
      p=r+1;
    }
  }
  if (n==X[r]){
    int s = r;
    while (n==X[s] && s<=q){
      if (Y[s]==1){
        Y[s]=0;
        return 1;
      }
      s++;
    }
    s=r;
    while (n==X[s] && s>=p){
      if (Y[s]==1){
        Y[s]=0;
        return 1;
      }
      s--;
    }
  }
  return 0;

}

int main(){
  cin >> N;
  for (int i=1;i<=N;i++){
    cin >> A[i];
    B[i]=1;
  }
  ans = 0;
  for (int i=1;i<=1000;i++){
}
  sort(A+1,A+N+1);
  for (int i=N;i>=2;i--){
    long foo = sub(A[i]);
    if (B[i]==1){
      ans+=sub2(foo,A,B,1,i-1);
    }
  }

  cout << ans << endl;

}



Measured memory_bytes: 3840
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, i, j, c;
  int a, b, t;
  cin >> a >> b >> t;
  n = 0;
  i = 1;
  while (true) {
    if (0 <= t - a) {
      t -= a;
      n += b;
      //   cout << "D:" << n << endl;
    } else {
      break;
    }
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define all(v) v.begin(),v.end()

ll M = 998244353;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

const int N = 3005;
ll dp[N][N];

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	IOS;
	 
    int n,s; cin>>n>>s;
    dp[0][0] = 1;
    ll a[n+1]; forn1(i,n) cin>>a[i];
    forn1(i,n)
    {
        for(ll j=0;j<=s;j++)
        {
            dp[i][j] = (dp[i-1][j]*2)%M;
            if(j>=a[i])
            {
                dp[i][j] = ( dp[i][j] + dp[i-1][j-a[i]] )%M;
            }
            //cout<<i<<' '<<j<<' '<<dp[i][j]<<endl;
        }
    }
    cout<<dp[n][s];
	
	return 0;
}


Measured memory_bytes: 74092
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i++)
typedef long long ll;
#define repran(i, a,b) for (int i = a; i<b;i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using LP = pair<ll,ll>;
using P = pair<int,ll>;
int n;
ll inf = 1e18;

int main()
{
    int n ,q;
    cin >> n >> q;
    vector<vector<int>> G(n, vector<int>());
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        --a;--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<ll> ans(n, 0);
    rep(i, q){
        int p; ll x;
        cin >> p >>x;
        --p;
        ans[p] += x;
    }
    //dfs
    deque<int> deq;
    deq.push_back(0);
    vector<int> parent(n, -1);
    while(!deq.empty()){
        int node = deq.back();deq.pop_back();
        for (int v : G[node]){
            if(v == parent[node]) continue;
            parent[v] = node;
            ans[v] += ans[node];
            deq.push_back(v);
        }

    }
    rep(i, n) cout << ans[i] << endl;

}

Measured memory_bytes: 18132
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
 int K,A,B;
 cin >> K >> A >> B;
  int largest;
  largest = (B/K)*K;
  if(largest >= A){
  	cout << "OK" << endl;
  }else{
  	cout << "NG" << endl;
  }
}

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

int main(){
	int N, K;
	cin >> N >> K;
	int h[N];
	int ans = 0;
	for(int i=0;i<N;i++){
		cin >> h[i];
		if(h[i] >= K)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const int N = 100005;
#define ll long long
int cmp(int a,int b){
	return a>b;
}	
int gcd(int x, int y)
{
    while(y^=x^=y^=x%=y);
    return x;
}
int a[200004];
int n,num=0;

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
		num^=a[i];
	}	
	for(int i=0;i<n;i++){
		cout << (num^a[i]) <<" ";
	}
	return 0;
}





Measured memory_bytes: 4332
dice1 = map(int, raw_input().split())
dice2 = map(int, raw_input().split())
  
def rolling(inst, dice):
    if inst == 'E':
        dice[5], dice[2], dice[0], dice[3] = dice[2], dice[0], dice[3], dice[5]
    elif inst == 'W':
        dice[5], dice[3], dice[0], dice[2] = dice[3], dice[0], dice[2], dice[5]
    elif inst == 'N':
        dice[5], dice[4], dice[0], dice[1] = dice[4], dice[0], dice[1], dice[5]
    elif inst == 'S':
        dice[5], dice[1], dice[0], dice[4] = dice[1], dice[0], dice[4], dice[5]
  
def dice_matching():
    if dice1[1] == dice2[1]:
        for i in range(4):
            if dice1 == dice2:
                return 1
                break
            rolling('E', dice2)
        return 0
    else:
        return 0
 
count = 0
while(1):
    if dice_matching() == 1:
        print "Yes"
        break
    else:
        if count < 3:
            rolling('N', dice2)
            count += 1
        elif 7 > count and count >= 3:
            if count == 3:
                rolling('E', dice2)
            rolling('N', dice2)
            count += 1
        else:
            print "No"
            break

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

    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var input = new List<int>();
            for(var i = 0;i<N;i++)
            {
                input.Add(int.Parse(Console.ReadLine()));
            }
            var sum = input.Sum();
            if(sum%10!=0)
            {
                Console.WriteLine(sum);
                return;
            }
            var noZero = input.Where(x => x % 10 != 0).ToList();
            if(!noZero.Any())
            {
                Console.WriteLine(0);
                return;
            }
            Console.WriteLine(sum-noZero.Min());
        }
    }

Measured memory_bytes: 11348
def main():
    while True:
        n = int(input())
        m = int(input())
        if n == 0:
            break

        lof = [list(map(int, input().split())) for _ in range(m)]
        lof.sort(key=lambda x: x[0])

        friend = [False] * (n + 1)
        friend_of_friend = [False] * 501 * (n + 1)
        no = 0
        while True:
            a, b = lof[no]
            if a == 1:
                friend[b] = True
                no += 1
            else:
                break

        for i in range(no, m):
            a, b = lof[i]
            if friend[a] and not friend[b]:
                if friend_of_friend[b] == False:
                    friend_of_friend[b] = True
                    no += 1
            elif friend[b] and not friend[a]:
                if friend_of_friend[a] == False:
                    friend_of_friend[a] = True
                    no += 1

        print(no)


if __name__ == '__main__':
    main()




Measured memory_bytes: 9880
#B - 754
S = list(map(int,input()))

minimam = 987
for i in range(len(S)-2):
    X = 100*S[i] + 10*S[(i+1)] + S[(i+2)]
    if abs(X - 753)<minimam:
        minimam = abs(X - 753)
print(minimam)

Measured memory_bytes: 9164
#include<stdio.h>

#define MAX 500000


typedef struct work{
    int time,line;
}work;

int partition(work A[], int n, int p, int r){
    int i,j;
    int x;
    work t;
    x=A[r].line;
    i=p-1;
    for(j=p;j<r;j++){
        if(A[j].line<=x){  //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;
}

void quickSort(work A[], int n, int p, int r){
    int q;
    if(p<r){
        q=partition(A,n,p,r);
        quickSort(A,n,p,q-1);
        quickSort(A,n,q+1,r);
    }
}


int main(void){
    int n,i,sum=0;
    scanf("%d",&n);
    work A[n];
    for(i=0;i<n;i++){
        scanf("%d%d",&A[i].time,&A[i].line);
    }
    
    quickSort(A,n,0,n-1);
    
    for(i=0;i<n;i++){
        //printf("%d %d ",A[i].time,A[i].line);
        sum+=A[i].time;
        if(sum>A[i].line){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}




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

int main(){
	int n, m;
  	cin >> n >> m;
  	vector<pair<int, int>> p(m);
  	rep(i, m) cin >> p[i].first >> p[i].second;
  	rep(x, 1000){
    	int keta = 1;
      	int nx = x /10;
      	vector<int> d(1, x % 10);
      	while(nx){
        	keta++;
          	d.push_back(nx % 10);
          	nx /= 10;
        }
        reverse(d.begin(), d.end());
      	if(keta != n) continue;
      
      	bool ok = true;
      	rep(i, m){
        	if(d[p[i].first - 1] != p[i].second) ok = false;
        }
      
      	if(ok){
        	cout << x << endl;
          	return 0;
        }
    }
  	
  	cout << -1 << endl;
}

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

using namespace std;

int main()
{
    int i,a,b,n,k;
    cin>>a>>b;
    int c[3];
    c[0]=1;
    c[1]=2;
    c[2]=3;
    for(i=0;i<3;i++)
    {
        if(a!=c[i])
        {
            if(b!=c[i])
            {
                k=c[i];
            }
        }
    }
    cout<<k;

}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by codoge on 2017/6/11.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
            if (min > a[i])
                min = a[i];
            if (max < a[i])
                max = a[i];
        }
        System.out.println(max - min);
    }
}


Measured memory_bytes: 21716
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

ll N;
char S[112345];
int counter[32] = {};

ll memo[32];

ll f(int n = 26) {
	if (n == 0) return 1;
	if (memo[n] >= 0) return memo[n];
	return memo[n] = (f(n - 1) * counter[n - 1] + f(n - 1)) % 1000000007;
}

int main() {

	rep(i, 32) memo[i] = -1;

	scanf("%lld", &N);
	scanf("%s", S);

	rep(i, N) {
		++counter[S[i] - 'a'];
	}
	/*
		int t = 1 << 26;
		ll ans = 0;

		rep(i, t) {
			if (!i) continue;
			ll sub = 1;
			rep(j, 26) {
				if ((i >> j) & 1) {
					sub *= counter[j];
					sub %= 1000000007;
				}
			}
			ans += sub;
			ans %= 1000000007;
		}*/

	printf("%lld\n", f() - 1);

	return 0;
}


Measured memory_bytes: 384
/*
 * Matheus Oliveira
 * 09:00:59 17/05/2020
 * a.cpp
*/

#include <bits/stdc++.h>
using namespace std;

#define EPS
#define INF
#define MAXN 10000
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define sc(x) scanf("%d", &x);
#define sc2(x, y) scanf("%d %d", &x, &y);
#define sc3(x, y, z) scanf("%d %d %d", &x, &y, &z);
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, bg, ed) printf("%s: ", #x); for(int i = bg; i < ed; i++) printf("%d%c", x[i], (i == ed-1) ? '\n' : ' ');

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

char n[MAXN];

int main() {
	int sz;
	scanf("%s", n);
	sz = strlen(n);
	
	if(n[sz-1] == '3') printf("bon\n");
	else {
		if(n[sz-1] == '0' or n[sz-1] == '1' or n[sz-1] == '6' or n[sz-1] == '8') printf("pon\n");
		else printf("hon\n");
	}

	return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>

int de(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}



int main(){

    int n,i,j;
    int a[200100];
    int flag = 0;
    
    scanf("%d",&n);
    for(i = 0 ; i < n ; i++){
        scanf("%d",&a[i]);
    }
    int b[n];

    for(i = 0; i < n ; i++){
        b[i] = a[i];
    }

    qsort(b,n,sizeof(int),de);

    for(i = 0; i < n ; i++){
        flag = 0;
        for(j = 0 ; j < n ; j++){
            if(b[j] == a[i] && flag == 0){
                flag = 1;
            }else if(b[j] == a[i] && flag == 1){
                printf("%d\n",b[j]);
                break;
            }else{
                printf("%d\n",b[j]);
                break;
            }
        }
    }

    return 0;
}

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

int main() {
  string s;
  cin >> s;

  if (s.at(0) == s.at(1) && s.at(1) == s.at(2)) {
    cout << "No" << endl;
  }else {
    cout << "Yes" << endl;
  }
  
}


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

int main(){
  string S;
  cin >> S;
  bool a=false;
  for(char C='a';C<='z';C++){
    int count=0;
    for(int i=0;i<S.size();i++){
      if(S.at(i)==C){
        count++;
      }
    }
    if(count%2==1){
      a=true;
    }
  }
  if(!a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
} 

Measured memory_bytes: 3496
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <bitset>

using namespace std;
using ll = long long;
using ull = unsigned long long;

struct C1 {
    ll G_{};
    ll D_{};
    vector<ll> num_solved{};
    vector<ll> P_{};
    vector<ll> C_{};
    ll min_solved_{INT64_MAX};
    explicit C1(ll G, vector<pair<ll,ll>> v) : G_(G) {
        D_ = v.size();
        num_solved.resize(D_, 0);
        P_.reserve(D_);
        C_.reserve(D_);
        for (auto&&p : v) {
            P_.emplace_back(p.first);
            C_.emplace_back(p.second);
        }
    }
    // return the score received by the dim or greater dims
    void find_answer(ll dim, ll current_score, ll current_num_solved) {
        auto&& solved = num_solved[dim];
        for(solved=0; solved <= P_[dim]; ++solved) {
            ll score_here = solved * (dim+1)*100 + (solved == P_[dim] ? C_[dim] : 0);
            ll score = current_score + score_here;
            ll solved_count = current_num_solved + solved;
            if (dim < D_-1) {
                find_answer(dim+1, score, solved_count);
            } else {
                if (current_score+score_here >= G_) {
                    min_solved_ = min(min_solved_, solved_count);
                }
            }
        }
    }
    ll resolve() {
        for(ull l=0; l < 1 << D_; ++l) {
            bitset<10> solved_problems{l};
            int other_bit{-1};
            for(int j=0; j <= solved_problems.size(); j++) {

                if (j == solved_problems.size()) {
                    other_bit = -1;
                } else if (solved_problems[j]) {
                    other_bit = j ;
                } else {
                    continue;
                }

                ll solved_score_other_than_one = 0;
                ll solved_count_other_than_one = 0;
                for(int i=0; i < solved_problems.size(); ++i) {
                    if (i == other_bit) {
                        continue;
                    }
                    if (solved_problems[i]) {
                        solved_score_other_than_one += (i+1) * 100 * P_[i] + C_[i];
                        solved_count_other_than_one += P_[i];
                    }
                }
                for(ll num_solved = 0; num_solved <= (other_bit >=0 ? P_[other_bit] : 0); num_solved++) {
                    if (solved_score_other_than_one + (other_bit+1)*100*num_solved >= G_) {
                        min_solved_ = min(min_solved_, solved_count_other_than_one + num_solved);
                        break;
                    }
                }
            }
        }
        return min_solved_;
    }
};

int main() {
    ll D, G;
    cin >> D >> G;
    vector<pair<ll, ll>> v{};
    for (int i=0; i < D; ++i) {
        ll p, c;
        cin >> p >> c;
        v.emplace_back(p,c);
    }
    C1 c{G, move(v)};
    cout << c.resolve() << endl;
    return 0;
}


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

int main(){
  ll a;
  long double b;
  cin >> a >> b;
  ll ans = a * b;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3728
#include<stdio.h>

void trace(int A[], int N){
	int i;
	for (i = 0; i < N; i++) {
		if(i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N) {
	int j, i, v;
	for (i = 1; i < N; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}

int main() {
	int N, i, j;
	int A[100];

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	trace(A, N);
	insertionSort(A, N);

	return 0;
	
}


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


int main(){
    ll N, M; cin >> N >> M;
    ll N2 = pow(2, N);
    vector<vector<ll>> DP(M+1, vector<ll>(N2));
    for(int i = 0; i < M+1; i++){
        for(int j = 0; j < N2; j++){
            if(j == 0) DP[i][j] = 0;
            else DP[i][j] = 1e9;
        }
    }
    for(int i = 1; i < M+1; i++){
        ll a, b; cin >> a >> b;
        bitset<12> C;
        for(int j = 0; j < b; j++) {
            ll c; cin >> c; c--;C.set(c);
        }
        for(int j = 0; j < N2; j++){
            bitset<12> B = j;
            ll temp = (C|B).to_ullong();
            DP[i][j] = min(DP[i-1][j], DP[i][j]); // unused
            DP[i][temp] = min(DP[i][temp], DP[i-1][j]+a); // used
            
        }
    }
    if(DP[M][N2-1] == 1e9) cout << -1 << endl;
    else cout << DP[M][N2-1] << endl;

}

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

int number(vector<int> c, int d){
    int count = 1;
    rep(i,c.size()){
        if(c.at(i)!=0 && c.at(i)<d)
        count++;
    }
    return count;
}

int dictio(int n){
    int N = 1;
    rep(i,n) N *= i+1;
    return N;
}

int main(){
    int n; cin>>n;
    vector<int> p(n),q(n);
    rep(i,n) cin>>p.at(i);
    rep(i,n) cin>>q.at(i);

    int a = 0;
    int b = 0;
    rep(i,n){
        int asort = number(p,p.at(i));
        int bsort = number(q,q.at(i));
        p.at(i)=0;
        q.at(i)=0;
        a += (asort-1)*dictio(n-1-i);
        b += (bsort-1)*dictio(n-1-i);
    }
    if(a-b>0)
    cout << a-b << endl;
    else
    cout << b-a << endl;
}

Measured memory_bytes: 256
n,T = map(int,input().split())
ct = sorted([list(map(int,input().split())) for i in range(n)],key = lambda x:x[0])
flag = 0
for i in range(n):
    if ct[i][1] <= T:
        flag = 1
        print(ct[i][0])
        break
if flag == 0:
    print("TLE")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ll,ii>


int n,m,k;
int arr[100005];
int brr[100005];

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	
	cin>>n>>m>>k;
	
	for (int x=1;x<=n;x++) cin>>arr[x];
	for (int x=1;x<=m;x++) cin>>brr[x];

	int ans=1000000000;
	
	int a,b,c;
	while (k--){
		cin>>a>>b>>c;
		ans=min(ans,arr[a]+brr[b]-c);
	}
	sort(arr,arr+n+1);
	sort(brr,brr+m+1);
	
	ans=min(ans,arr[1]+brr[1]);
	
	cout<<ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
main(){
  int x;
  cin>>x;
  int ans=1;
  for(int i=2;i<=x;i++){
    int temp=i;
    while(i*temp<=x){
      temp*=i;
      ans=max(ans,temp);
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define LL long long
#define ULL unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<LL,int>
#define PLL pair<LL,LL>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<LL,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();
    string s;
    cin >> s;
    if(s.back() == 's')cout << s << "es";
    else cout << s << "s";
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0,ans=0;
bool graph[8][8];

 int main(){
     ll k;  cin >> k;

     vector<int> a(k+1);
    

     for(int i=1;i<=k;i++){
         for(int j=i;j<=k;j+=i){
             a[j]++;
         }
     }

     for(ll i=1;i<=k;i++){
         ans+=i*a[i];
     }
     cout << ans << endl;
    }

Measured memory_bytes: 42300