akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
int main(){
    string s;cin>>s;
    string t;cin>>t;
    int ans=0;
    For(i,3){
        if(s.at(i)==t.at(i)) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    unsigned long long int N, P;
    cin >> N;
    cin >> P;
    
    if (N==1) {
        cout << P << endl;
        return 0;
    }
    if (P==1) {
        cout << 1 << endl;
        return 0;
    }
    unsigned long long int ans = 1;
    
    unsigned long long int d = 0;
    unsigned long long int p = P;
    unsigned long long int temp;
    for(unsigned long long int i=2; pow(i, N)<=p; i++){
        temp = pow(i, N);
        while(p%temp==0){
            ans *= i;
            p = p/temp;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)

using namespace std;
using ll = __int64_t;

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

void solve(){
    int a, b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    }else if(a >= 6 && a <= 12){
        cout << b/2 << endl;
    }else{
        cout << 0 << endl;
    }
}

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

Measured memory_bytes: 256
n=int(input())
mod=10**9+7
A=list(map(int,input().split()))

from collections import Counter
C=Counter(A)
if n%2==0:
    for i in range(1,n,2):
        if C.get(i) != 2:
            print(0);exit()
else:
    if C.get(0) !=1:
        print(0);exit()
    for i in range(2,n,2):
        if C.get(i)!=2:
            print(0);exit()

n//=2
print(pow(2,n,mod))

Measured memory_bytes: 20480
n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(n):
    minj = i
    for j in range(i,n):
        if a[j] < a[minj]:
            minj = j
    if i != minj:
        cnt += 1
    tmp = a[i]
    a[i] = a[minj]
    a[minj] = tmp

print(*a)
print(cnt)



Measured memory_bytes: 5604
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e10;
const ll MOD = 1e9 + 7;

int main(){
	string s;
	ll K;
	cin >> s >> K;
	ll i, j;
	set<string> st;
	for (i = 1; i <= K; i++){
		if (i > s.length()){
			break;
		}
		for (j = 0; j < s.length() - i + 1; j++){
			st.insert(s.substr(j, i));
		}
	}
	auto itr = st.begin();
	for (i = 0; i < K - 1; i++){
		++itr;
	}
	cout << *itr << endl;


}



Measured memory_bytes: 1664
import Control.Applicative

main :: IO ()
main = do
    [a, b, c, d] <- map read . words <$> getLine
    putStrLn $ solve a b c d 

solve :: Int -> Int -> Int -> Int -> String
solve a b c d =  case compare (a+b) (c+d) of 
                 GT -> "Left"
                 EQ -> "Balanced"
                 LT -> "Right"

Measured memory_bytes: 508
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
const int mod = 1e9 + 7;
const int MX = 10000;
ll inv[MX], f[MX], invf[MX];
void calc(){
	inv[0] = inv[1] = f[0] = f[1] = invf[0] = invf[1] = 1;
	for (int i = 2; i < MX; i++){
		inv[i] = mod - mod / i * inv[mod % i] % mod;
		f[i] = f[i - 1] * i % mod;
		invf[i] = invf[i - 1] * inv[i] % mod;
	}
}
inline ll C(ll n, ll k){
	if(k < 0 || n < k) return 0;
	return f[n] * invf[k] % mod * invf[n - k] % mod;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	calc();
	int n, k; cin >> n >> k;
	for(int i = 1; i <= k; i++){
		ll ans = 0;
		//B - R - B
		ans += C(k - 1, i - 1) * C(n - k - 1, i - 2) % mod;
		//B - R or R - B
		ans += C(k - 1, i - 1) * C(n - k - 1, i - 1) * 2 % mod;
		//R - B - R
		ans += C(k - 1, i - 1) * C(n - k - 1, i) % mod;
		
		if(n == k && i == 1) ans++;
		cout << ans % mod << endl;
	}
	return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))

n = int(input())
X = []
Y = []
for i in range(n):
    x, y = inpl()
    X.append((x, i))
    Y.append((y, i))

X = sorted(X, key = lambda x: x[0])
Y = sorted(Y, key = lambda y: y[0])

G = [[] for _ in range(n)]
edges = []
for i in range(n-1):
    edges.append((X[i][1], X[i+1][1], abs(X[i][0] - X[i+1][0])))
    edges.append((Y[i][1], Y[i+1][1], abs(Y[i][0] - Y[i+1][0])))

edges = sorted(edges, key = lambda e: e[2])

tree = [[-1, 1] for _ in range(n)]

def find(i):
    if tree[i][0] == -1:
        group = i
    else:
        group = find(tree[i][0])    
    return group
  
def unite(x, y):
    px = find(x)
    py = find(y)
      
    if tree[px][1] == tree[py][1]: # rank is same
        tree[py][0] = px
        tree[px][1] += 1
    else:
        if tree[px][1] < tree[py][1]:
            px, py = py, px
        tree[py][0] = px

res = 0

for s, t, w in edges:
    if find(s) != find(t):
        unite(s, t)
        res += w
print(res)

Measured memory_bytes: 68360
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = 2 * (int)1e5 + 100;
string s;
const int BUBEN = 5;
int dp[maxN][BUBEN + 2];
int n;
const int INF = 5000000;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> s;
    n = s.size();
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j < BUBEN; j++) {
            dp[i][j] = -INF;
        }
    }
    for (int i = 0; i < min(BUBEN, n); i++) {
        dp[i][i + 1] = 1;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < BUBEN; j++) {
            if (dp[i][j] < 0) continue;
            for (int take = i + 1; take <= min(i + BUBEN, n); take++) {
                if (s.substr(i - j + 1, j) != s.substr(i + 1, take - i)) {
                    dp[take][take - i] = max(dp[take][take - i], dp[i][j] + 1);
                }
            }
        }
    }
    int best = -INF;
    for (int i = 0; i < BUBEN; i++) {
        best = max(best, dp[n - 1][i]);
    }
    cout << best;
    return 0;
}

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

int main(){
 while(true){
  int N;
  cin >> N;
  
  if(N==0) break;

  int n[10] = {0};
  int m = 0;

  for(int i=0; i<100; i++){
   char c;
   cin >> c;

   n[i%N]++;

   if(c=='S'){
    m += n[i%N];
    n[i%N] = 0;
   }else if(c=='L'){
    n[i%N] += m;
    m = 0;
   }
  }

  sort(n, n+N);
  
  for(int i=0; i<N; i++){
   cout << n[i] << ' ';
  }
  cout << m << endl;
 }
 
 return 0;
}

Measured memory_bytes: 3136
#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const long long INF = 1LL << 61;

int main() {
	int A, B; cin >> A >> B;
	vector<int> nums;
	nums.push_back(A + B);
	nums.push_back(A - B);
	nums.push_back(A * B);
	cout << *max_element(nums.begin(), nums.end());
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
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; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int R, G, B;
	cin >> R >> G >> B;
	int x = R * 100 + G * 10 + B;
	YESNO(x % 4 == 0);
}

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

int main()
{
  string s;
  cin >> s;
  
  if(s[5] == '1' || s[6] >= '5'){
		cout << "TBD" << endl;
  }
  else cout << "Heisei" << endl;
  
  return 0;
}

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

int main(void){
    string s, t; cin >> s >> t;
    string ss = s;
    ss.append(s);

    int ans = 0;
    for(int i = 0; i < s.length(); i++){
        int flg = 0;
        for(int j = i; j < s.length() + i; j++){
            if(ss[j] == t[j-i]) flg++;
        }
        if(flg == t.length()){
            ans = 1;
            break;
        }
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a, b; cin >> a >> b;
    int res = n;
    for (int i = 0; i < n; ++i) {
        int t; cin >> t;
        if (a <= t && t < b) --res;
    }
    cout << res << endl;
    return 0;
}


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

is_Yes = False
if N % 4 == 0 or N % 7 == 0:
    print('Yes')
else:
    is_Yes = False
    for i in range(4, N+1, 4):
        if (N - i) % 7 == 0:
            is_Yes = True
            break
    if is_Yes:
        print('Yes')
    else:
        print('No')


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

#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define fill(a, z) memset(a, z, sizeof(a))
#define rep(i, a, b) for (i = (a); i <= (b); i++)
#define rdp(i, a, b) for (i = (a); i >= (b); i--)
#define cns(z) cout << z << ' '
#define cnl(z) cout << z << '\n'
#define M 1000000007
#define M2 998244353
#define endl "\n"
#define iip(t) \
	int t;     \
	cin >> t;
#define iip2(a, b) \
	int a, b;      \
	cin >> a >> b;
#define dip(a) \
	double a;  \
	cin >> a;
#define dip2(a, b) \
	double a, b;   \
	cin >> a >> b;
#define garr(ip)       \
	for (auto &x : ip) \
		cin >> x;
#define parr(ip)          \
	for (auto &x : ip)    \
		cout << x << " "; \
	cout << endl;
#define test   \
	int _t;    \
	cin >> _t; \
	while (_t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vp;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	iip2(n,m);
	vi ip(n);
	garr(ip);
	double sum = 0;
	for(auto it:ip)
	{
		sum += it;
	}
	sort(ip.rbegin(), ip.rend());
	sum /= 4*m;
	for(int i = 0; i < m; i++)
	{
		if(ip[i] < sum)
		{
			cnl("No");
			return 0;
		}
	}
	cnl("Yes");
}

Measured memory_bytes: 256
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

h, w, k = MAP()
s = []
p = []
q = []
for i in range(h):
    s.append(input())
    if s[i].count('#') > 0:
        p.append(i)
    else:
        q.append(i)

a = [[0]*w for i in range(h)]
num = 0
if p:
    for i in p:
        num += 1
        m = 0
        while s[i][m] == '.':
            a[i][m] = num
            m += 1
        if m < w:
            if s[i][m] == '#':
                a[i][m] = num
                m += 1
            if m < w:
                for j in range(m, w):
                    if s[i][j] == '#':
                        num += 1
                    a[i][j] = num

if q:
    for i in q:
        m = i
        while m < h and a[m][0] == 0:
            m += 1
        if m >= h:
            m = i
            while m > 0 and a[m][0] == 0:
                m -= 1
        a[i][:] = a[m][:]
for i in range(h):
    print(*a[i][:])

Measured memory_bytes: 13952
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long int gcd(long long int x,long long int y);
long long int lcm(long long int x,long long int y);
int main()
{
	int N;
	cin >> N;
    vector<long long int> T;
    for(int i=0; i<N; i++)
    {
    	long long int t;
    	cin >> t;
    	T.push_back(t);
    }
    long long int ans = 1;
    for(int i=0; i<N; i++)
    {
    	ans = lcm(ans,T[i]);
    }

    cout << ans << endl;

	return 0;
}

long long int gcd(long long int x, long long int y)
{
     if(x<y) swap(x,y);
     long long int r = x % y;
     if(r==0) return y;
     else return gcd(y,r);
}

long long int lcm(long long int x, long long int y)
{    
     long long int w = gcd(x,y);
     return (x/w)*y; 
}

Measured memory_bytes: 256
#include "stdio.h"
#include <stdlib.h>
#include <string.h>

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

int main(void){
	char S;
	int N;
	int four = 0;

	scanf("%d", &N);

	fflush(stdin);
	FOR(i, 0, N-1) {

		scanf("%c", &S);

		if(S=='Y') four = 1;

	}

	if(four) printf("Four\n");
	else printf("Three\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  string s;
  cin >> s;

  string ans = "ARC";
  if (s == "ARC") {
    ans = "ABC";
  }

  cout << ans << ln;

  return 0;
}

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

int main(){
  int a,b,c,n;

  cin>>a;
  cin>>b;
  cin>>c;
  if(b>c){
    n = b;
    b = c;
    c = n;
  }

  if(a>b){
    n = a;
    a = b;
    b = n;
  }

  if(b>c){
    n = b;
    b = c;
    c = n;
  }
  cout<<a<<" "<<b<<" "<<c<<endl;
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
/*#define F second
#define S first*/
using namespace std;
const int N=1e5+1;
int dp[101][N];
pair<int ,int> a[N];
main()
{
    int n,m;
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld",&a[i].F,&a[i].S);
    }
    //sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(j<a[i].F){
                dp[i][j]=dp[i-1][j];
            }
            else{
                dp[i][j]=max(a[i].S+dp[i-1][j-a[i].F],dp[i-1][j]);
            }
        }
    }
    printf("%lld",dp[n][m]);
}


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

int main(){
	string s;
	cin >> s;
	int a=0,b=0;
	int n=s.length();
	rep(i,n){
		if(s[i] == '0'){
			a++;
		}else b++;
	}
	int res = min(a,b) * 2;
	cout << res << endl;
	return 0;
}




Measured memory_bytes: 512
"use strict"

let n, m, graph, list, visited

//https://abc075.contest.atcoder.jp/tasks/abc075_c
//グラフは隣接行列表現＝二次元配列で表現
//深さ優先探索で 辺を削除後に全部のポイントを訪問できるか

const dfs = v => {
  visited[v] = true
  for (let v2 = 0; v2 < n; v2++) {
    if (visited[v2] || graph[v][v2] == false) continue
    dfs(v2)
  }
}

function main(input) {
  input = input.split(/\n/).map(v => v.split(" ").map(v => ~~v))
  n = input[0][0]
  m = input[0][1]

  list = input.slice(1, input.length)
  graph = Array.apply(null, { length: n }).map(v =>
    Array.apply(null, { length: n }).map(v => false)
  )
  // graphをマーク
  for (let i = 0; i < m; i++) {
    let p1 = list[i][0] - 1
    let p2 = list[i][1] - 1
    graph[p1][p2] = true
    graph[p2][p1] = true
  }

  let ans = 0

  //隣接行列表現を探索
  for (let i = 0; i < n; i++) {
    //訪問済みを初期化
    for (let j = 0; j < n; j++) {
      ///
      visited = Array.apply(null, { length: n }).map(v => false)
      if (graph[i][j] == true) {
        // 辺を見つけたら
        graph[i][j] = graph[j][i] = false
        dfs(i)
        //全点訪問できなかったら == every=(v)=v==true = false
        //橋をカウント
        if (visited.every(v => v == true) != true) ans++
        graph[i][j] = graph[j][i] = true
      }
    }
  }
  console.log(ans / 2) //隣接行列は右上と左下が対象になるので半分にする = ans / 2
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21448
#include <iostream>
using namespace std;
 
int N,p[5000],memo[5001],result[4];
 
int main() {
  cin>>N;
  for (int i=0;i<N;i++){
    cin>>p[i];
  }
  for(int i=0;i<=3;i++){
    memo[0]=i;
    for(int j=1;j<N+1;j++){
      memo[j]=p[j-1]-memo[j-1];
      if(memo[j]<0){
        memo[j]=0;
      }
    }
    result[i]=memo[0];
    for (int j=1;j<N;j++){
      result[i]+=memo[j]*2;
    }
    result[i]+=memo[N];
  }
  int min=result[0];
  for(int i=1;i<=3;i++){
    if(min>result[i]){
      min=result[i];
    }
  }
  cout<<min<<endl;
  return 0;
}


Measured memory_bytes: 3148
import java.io.*;

class Main {
    BufferedReader bf;
    PrintWriter writer;
    StringBuilder sb;
    static boolean local_system = false;

    void run() throws IOException {
        writer.println(getInt() >= 30 ? "Yes" : "No");
    }

    public static void main(String[] args) throws IOException {
        long start_time = System.currentTimeMillis();
        Main obj = new Main();
        obj.run();
        long end_time = System.currentTimeMillis();
        if (local_system) obj.writer.println("Time : " + (end_time - start_time));
        obj.close();
    }

    public Main(){
        writer = new PrintWriter(System.out);
        bf = new BufferedReader(new InputStreamReader(System.in));
        sb = new StringBuilder();
    }

    public int getInt() throws IOException {
        return Integer.parseInt(bf.readLine());
    }

    public long getLong() throws IOException {
        return Long.parseLong(bf.readLine());
    }

    public int[] ints() throws IOException {
        String[] data = bf.readLine().split(" ");
        int[] send = new int[data.length];
        for (int i = 0, h = data.length; i < h; i++) send[i] = Integer.parseInt(data[i]);
        return send;
    }

    public long[] longs() throws IOException {
        String[] data = bf.readLine().split(" ");
        long[] send = new long[data.length];
        for (int i = 0, h = data.length; i < h; i++) send[i] = Long.parseLong(data[i]);
        return send;
    }

    public void close() throws IOException{
        writer.flush();
        writer.close();
        bf.close();
    }
}




Measured memory_bytes: 25412
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int t[100];
int d[100];
int rec(int n, int index)
{
  if (index == n) {
    int pre = 0;
    int ans = INF;
    REP(i,24) {
      if (t[i]) {
        chmin(ans, i - pre);
        pre = i;
      }
    }
    chmin(ans, 24 - pre);
    return ans;
  }
  int res = 0;
  if (t[d[index]] == 1) {
  }
  else
  {
    t[d[index]] = 1;
    chmax(res, rec(n, index+1));
    t[d[index]] = 0;
  }
  int hoge = 24 - d[index];
  if (t[hoge] == 0) {
    t[hoge] = 1;
    chmax(res, rec(n, index+1));
    t[hoge] = 0;
  }
  return res;
}

int solve(int n) {
  inputs(d, n);
  int cnt[13] = {};
  REP(i,n) {
    cnt[d[i]]++;
    if (cnt[d[i]] == 3) {
      return 0;
    } else if (cnt[d[i]] == 2 && d[i] == 12)
      return 0;
    else if (cnt[d[i]] == 1 && d[i] == 0)
      return 0;
  }
  return rec(n, 0);
}

int main() {
  int n;
  while(cin >> n) {
    cout << solve(n) << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int ans = 100000;
	int i;

	scanf("%d", &n);

	for (i = 0; i < n; i++){
		ans *= 1.05;
		ans += 999;
		ans /= 1000;
		ans *= 1000;
	}

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

	return (0);
}

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

using namespace std;

int main(){
  long long N;

  cin >> N;

  long long N1 = N;

  long long tmp = 0;

  while(true){
    tmp += (N % 10);
    //cout << tmp << endl;
    N /= 10;
    if (N == 0) break;
  }
  if ((N1 % tmp) == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


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

# define pb push_back
# define sz(x) ((int)(x).size())
# define whole(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
const int INF = (int)1e9 + 7;
const int N = (int)2e5 + 7;

int n;
int main(){
    cin >> n;
    int ac = 0, wa = 0, tle = 0, re = 0;
    for (int i = 1; i <= n; ++i) {
        string s;
        cin >> s;
        if (s == "AC")
            ++ac;
        else if (s == "WA")
            ++wa;
        else if (s == "TLE")
            ++tle;
        else
            ++re;
    }
    printf ("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ac, wa, tle, re);
    return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

const ll mod = 1000000007;
const ll INF = 100000000000010000;

ll kai[100010];
ll bit[700010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

/*ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= 700005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
}

ll n, m;
ll a[100010];
ll sum[100010];
ll ans, cir, res;

void solve() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < n; i++) {
		ll S = a[i], G = a[i + 1];
		if (S > G) {
			if (G + m - S < 2) continue;
			sum[1] += m - S;
			sum[2] += 1 + S - m;
			sum[G + 1] -= m + G - S;
			sum[G + 2] += m + G - S - 1;
		}
		else {
			sum[G + 1] -= G - S;
			sum[G + 2] += G - S - 1;
		}
		if (a[i] <= m - 2) sum[S + 2]++;
	}
	for (int i = 1; i < n; i++) {
		if (a[i] > a[i + 1]) cir++;
	}
	ans += a[n] + cir * m - a[1];
	rep(i, 2) {
		for (int j = 1; j < m; j++) {
			sum[j + 1] += sum[j];
		}
	}
	res = INF;
	for (int i = 1; i <= m; i++) {
		res = min(ans - sum[i], res);
	}
	cout << res << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}
////////////////////////////////////////////////////////////////////////////////////////////jagfhaoi;sd;joi;asdfjzasdi;lfjoi;ernjsdoivcnoizvdfnvdfnon/////////////////////////////////////////////////////////
////////////////////jgoiadhsjgoi;vsjvgfonhjasoivhoivhno

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include <set>

#define DIV 1000000007
using namespace std;
using ll = long long;

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

    if (K <= 9)
        cout << K << endl;

    else {
        ll temp;
        ll cnt = 0;
        queue<ll> q;
        for (ll i = 1; i <= 9; i++) {
            q.push(i);
        }

        cnt = 9;
        while (cnt != K) {
            ll a = q.front() % 10;
            for (ll i = max((ll)0, a - 1); i <= min((ll)9, a + 1); i++) {
                temp = 10 * q.front() + i;
                //cout << "temp=" << temp << endl;
                q.push(temp);
                cnt++;
                if (cnt == K) {
                    cout << temp << endl;
                    break;
                }
            }
            if (cnt == K) {
                break;
            }
            if(!q.empty())q.pop();
        } 

    }
}


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

int main()
{
	vector<int> tab;
	for (int i=1;i<=3;i++)
	{
		int n;
		cin>>n;
		tab.push_back(n);
	}
	sort(tab.begin(),tab.end());
	cout<<(tab[0]==tab[1] ? tab[2] : tab[0])<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(A*B, C*D) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	for(int id=1; (a>0 && c>0); id++){
		if(id&1) c-=b;
		else a-=d;
	}
	if(a>0) cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 3636
n=int(input())
s=[]
for i in range(n):
    s.append(input())
m=int(input())
t=[]
for j in range(m):
    t.append(input())
s1=set(s)
a=[]
for k in s1:
    a.append(s.count(k)-t.count(k))
if max(a)>=0:
    print(max(a))
else:print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdlib>
#define INF 10e7
using namespace std;

int cost[100][100];

int main(void){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		int cards=0,ace=0;
		char list[2];
		char table[8];
		for(int j=0;j<2;j++)
			cin >> list[j];

		for(int j=0;j<8;j++)
			cin >> table[j];

		for(int j=0;j<2;j++){
			if(list[j]=='A')
				cards+=11,ace++;
			else if(isdigit(list[j]))
				cards+=(list[j]-'0');
			else
				cards+=10;
		}
		if(cards >21&&ace)
			cards-=10,ace--;

		if(cards==21){
			cout << "blackjack" << endl;
			continue;
		}else if(cards >17){
			cout << cards << endl;
			continue;
		}else if(cards==17&&!ace){
			cout << cards << endl;
			continue;
		}
		for(int j=0;j<8;j++){
			if(table[j]=='A')
				cards+=11,ace++;
			else if(isdigit(table[j]))
				cards+=(table[j]-'0');
			else
				cards+=10;
			if(cards >21&&ace)
				cards-=10,ace--;
			
			if(cards > 21){
				cout << "bust" << endl;
				break;
			}else if(cards>17){
				cout << cards << endl;
				break;
			}else if(cards==17&&!ace){
				cout << cards << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1164
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BDigitalGifts solver = new BDigitalGifts();
        solver.solve(1, in, out);
        out.close();
    }

    static class BDigitalGifts {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int t = in.nextInt();
            double ans = 0, x = 0, fac;
            String u;
            while (t-- > 0) {
                x = Double.parseDouble(in.next());
                u = in.next();
                if (u.equals("JPY"))
                    fac = 1.0;
                else
                    fac = 380000.0;
                ans += x * fac;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main(void){
        string s,t;
        int n,i;
        cin >> n;
        cin >> s >> t;
        for(i=0;i<n;i++){
                cout << s[i] << t[i];
                if (i==n-1){
                        cout << endl;
                }
        }
        return 0;
}

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

int main(){
  
    int N;
    cin>>N;
    vector<int> A(26,100);
    for(int i=0;i<N;i++){
        string S;cin>>S;
        vector<int> B(26);
        for(int j=0;j<S.size();j++){
            B[S[j]-'a']++;
        }
        for(int j=0;j<26;j++){
            A[j]=min(A[j],B[j]);
        }
    }
    for(int i=0;i<26;i++){
        while(A[i]>0){
            char x=i+'a';
            cout<<x;
            A[i]--;
        }
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;
const long long MODMOD = 998244353;
const double PI = acos(-1);

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
  vector<int> p;
  vector<int> s;
  void init(int n) {
    p.resize(n, -1);
    s.resize(n, 1);
  }
  int find(int n) {
    if(p[n] == -1) return n;
    else return find(p[n]);
  }
  int size(int n) {
    return s[find(n)];
  }
  void unite(int n, int m) {
    int pn = find(n);
    int pm = find(m);
    if(pn == pm) return;
    if(s[pn] > s[pm]) {
      s[pn] = s[pn] + s[pm];
      p[pm]= pn;
    } else {
      s[pm] = s[pm] + s[pn];
      p[pn] = pm;
    }
  }
};

long long gcd(long long a, long long b) {
  if(a % b == 0) return b;
  else return gcd(b, a % b);
}
int main() {
  int h, w;
  cin >> h >> w;
  vector<P> black;
  vector<vector<char>> g(h+2, vector<char>(w+2));
  rep(i, h) rep(j, w) {
    cin >> g[i+1][j+1];
    if(g[i+1][j+1] == '#') black.emplace_back(make_pair(i+1, j+1));
  }
  vector<vector<int>> depth(h+2, vector<int>(w+2, 100100100));
  queue<P> que;
  rep(i, black.size()) que.emplace(black[i]);
  while(!que.empty()) {
    P p = que.front();que.pop();
    int r = p.first, c = p.second;
    if(g[r][c] == '#') depth[r][c] = 0;
    int d = depth[r][c];
    if(g[r+1][c] == '.' && depth[r+1][c] > d + 1) {
      depth[r+1][c] = d + 1;
      que.emplace(make_pair(r+1, c));
    }
    if(g[r-1][c] == '.' && depth[r-1][c] > d + 1) {
      depth[r-1][c] = d + 1;
      que.emplace(make_pair(r-1, c));
    }
    if(g[r][c+1] == '.' && depth[r][c+1] > d + 1) {
      depth[r][c+1] = d + 1;
      que.emplace(make_pair(r, c+1));
    }
    if(g[r][c-1] == '.' && depth[r][c-1] > d + 1) {
      depth[r][c-1] = d + 1;
      que.emplace(make_pair(r, c-1));
    }
  }
  int ans = 0;
  rep(i, h) rep(j, w) chmax(ans, depth[i+1][j+1]);
  cout << ans << endl;
}


Measured memory_bytes: 21224
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG_ARR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]<<" "; cerr<<endl;
#define DEBUG_STR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]; cerr<<endl;


using namespace std;

typedef long long ll;
typedef unsigned long long llu;

struct Point {
	int x;
	int y;
};

int main() {
	FIO;
	int h,w;
	cin>>h>>w;
	
	vector<string> grid(h);
	for(int i=0; i<h; i++)
		cin>>grid[i];
	
	int dx[] = {0,1};
	int dy[] = {1,0};
	
	int cost[h][w];
	
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cost[i][j] = INT_MAX;
		}
	}
	
	if(grid[0][0] == '#') {
		cost[0][0] = 1;
	} else {
		cost[0][0] = 0;
	}
	
	queue<Point> q;
	
	q.push(Point{0,0});
	
	while(!q.empty()){
		Point p = q.front();
		int x = p.x;
		int y = p.y;
		q.pop();
		
		int nx,ny;
		
		for(int i=0; i<2; i++){
			ny = y + dy[i];
			nx = x + dx[i];
			
			if(ny >= h || nx >= w) continue;
			if(cost[y][x] >= cost[ny][nx]) continue;
			
			int tmpCost = cost[y][x];
			
			if(grid[y][x] == '.' && grid[ny][nx] == '#') tmpCost++;
			
			cost[ny][nx] = tmpCost;
			
			q.push(Point{nx, ny});
			
		}
	}
	
	cout<<cost[h-1][w-1];
	
	return 0;
}


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

int main() {
int n; cin >> n;
map<int, int> M;
int num;
for(int i=0; i<n-1; i++){
cin >> num;
M[num]++;
}

for(int i=1; i<=n; i++)
cout << M[i] << "\n";

return 0;
}

Measured memory_bytes: 12884
N, L = map(int, input().split())

res = 0

a = [(abs(L + i - 1), L + i - 1) for i in range(1, N + 1)]
a.sort()
min_a = a[0][1]

for i in range(1, N + 1):
    res += L + i - 1
        
res -= min_a

print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

int a, b;

int main(){
	cin >> a >> b;
	if(a <= 0 && 0 <= b){
		puts("Zero");
		return 0;
	}
	b = min(b, -1);
	int cnt = b - a + 1;
	if(cnt > 0 && abs(cnt) % 2){
		puts("Negative");
	}
	else{
		puts("Positive");
	}
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    set<vector<int>> st;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        vector<int> a(3);
        cin >> a[0] >> a[1] >> a[2];
        sort(a.begin(), a.end());
        st.insert(a);
    }
    cout << n - st.size() << '\n';
    return 0;
}


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

int main() {
  int x,a,b;
  cin >> x >> a >> b;
  int ans = x-a;
  ans = ans%b;
  cout << ans << endl;
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,n) for(ll i=0;i<n;i++)
#define nforn(i,n) for(ll i=n-1;i>=0;i--)
#define forne(i,n) for(ll i=1;i<=n;i++)
#define forse(i,s,e) for(ll i=s;i<e;i++)
#define all(v) v.begin(),v.end()
#define MOD 1000000007
#define d1(x) cerr <<"> "<<#x<<" = "<<x<<'\n'
#define d2(x, y) cerr <<"> "<<#x<<" = "<<x<<' '<<#y<<" = "<<y<<'\n'
#define d3(x, y, z) cerr <<"> "<<#x<<" = "<<x<<' '<<#y<<" = "<<y<<' '<<#z<<" = "<<z<<'\n'
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
	// cin>>t;
	while(t--){
		ll h;
		cin>>h;
		ll cnt = 0;
		while(h!=1){
			h >>= 1;
			cnt++;
		}
		cnt++;
		cout<<(1ll<<cnt)-1<<"\n";
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 105
#define INF 2147483647

int M[MAX][MAX];

void mCO(int p[],int n){
  int i,j,k,temp[100],min;
  for(i=1;i<n;i++){
    for(j=1;j<=(n-i);j++){
      for(k=j;k<(j+i);k++){
	temp[k]=M[j][k]+M[k+1][j+i]+p[j-1]*p[k]*p[j+i];
      }
      min=INF;
      for(k=j;k<(j+i);k++)  if(temp[k]<min) min=temp[k];
      M[j][j+i]=min;
    }				   
  }
}

int main(){
  int n,i,p[MAX],temp;
  scanf("%d",&n);
  for(i=0;i<n-1;i++){
    M[i][i]=0;
    if(i==0) scanf("%d%d",&p[i],&p[i+1]);
    scanf("%d%d",&temp,&p[i+2]);
  }
  mCO(p,n);
  printf("%d\n",M[1][n]);
  return 0;
}



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

int main(){
  int A,B;cin>>A>>B;
  if(A<=0 && B>=0) cout<<"Zero"<<endl;
  else if((B-A)%2==0 && B<0) cout<<"Negative"<<endl;
  else cout<<"Positive"<<endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main()
{
string a;
cin>>a;
a[3]=('8');
cout<<a;
return 0;
}


Measured memory_bytes: 256
s = input()
t = input()

idx = -1
count = 0

if set(t) <= set(s):
    for i in t:
        idx = s.find(i, idx+1)
        if idx == -1:
            idx = s.find(i)
            count += 1
    pdc = count * len(s)
    total_idx = (idx + 1) + pdc 
    print(total_idx)
else:
    print(-1)


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
       Scanner scan= new Scanner(System.in);

       int n=scan.nextInt();

       for(int i=1;i<=n;i++){
           if(i%3==0){
               System.out.print(" "+i);
           }else{
               int x=i;
               while(x>1){
                   if(x%10==3){
                       System.out.print(" "+i);
                       break;
                   }
                   x/=10;
               }

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



Measured memory_bytes: 28516
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#define swap(a,b) ((a != b) && (a += b,b = a - b,a -= b))
using namespace std;

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

int f(int a){
    if(a%2){
        return 3*a+1;
    }
    return a/2;
}

int main()
{
    int sum=0;
    int max=0;

    int n;
    cin >> n;


    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(a>max)max=a;
        sum+=a;
    }
    sum-=max;
    sum+=max/2;



    cout<<sum<<endl;
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

using namespace std;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, l; cin >> n >> l;
    vector<string> v(n);
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    for ( auto x: v ) cout << x;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3620
L = [2,1]
N = int(input())
if N == 0:
    print(2)
elif N == 1:
    print(1)
else:
    for i in range(2,N+1):
        L_i = L[i-1]+L[i-2]
        L.append(L_i)
    print(L[-1])

Measured memory_bytes: 3060
while True:
    m, f, r = [int(i) for i in input().split()]

    if m == f == r == -1:
        break

    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')
        
    elif total < 50 and r < 50:
        print('D')
        
    elif total < 65:
        print('C')
        
    elif total < 80:
        print('B')
        
    else:
        print('A')

Measured memory_bytes: 7680
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, m, a, b;
	for (int h = 0; h < 5; h++) {
		int c = 0, sum = 0; int test[123456] = { 0 };
		cin >> n >> m;
		if (n == 0 && m == 0) {
			cin >> n; return 0;
		}
		for (int i = 0; i < n; i++) {
			cin >> a;
			test[i] = a;
		}
		for (int i = 0; i < m; i++) {
			cin >> b;
			sum += b;
			sum += test[sum];
			if (sum >= n - 1 && c == 0) {
				cout << i + 1 << endl;
				c++;
			}
		}
	}
	cin >> n;
}


Measured memory_bytes: 3496
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main():
    s = SI()
    t = SI()

    # そこまでの最大の長さ
    dp_table_2 = [[0 for _ in range(len(s))] for _ in range(len(t))]
    # init:
    ume = 0
    for i in range(len(s)):
        if t[0] == s[i]:
            ume = 1
        dp_table_2[0][i] = ume
    ume = 0
    for i in range(len(t)):
        if t[i] == s[0]:
            ume = 1
        dp_table_2[i][0] = ume

    # dp:
    for i in range(1, len(t)):
        for j in range(1, len(s)):
            if t[i] == s[j]:
                dp_table_2[i][j] = max(dp_table_2[i-1][j], dp_table_2[i][j-1], dp_table_2[i-1][j-1]+1)
            else:
                dp_table_2[i][j] = max(dp_table_2[i-1][j], dp_table_2[i][j-1])

    # print(dp_table_2)

    # print(dp_table_2[len(t)-1][len(s)-1])

    # 復元
    i = len(t) - 1
    j = len(s) - 1
    ans = ''
    while i >= 0 and j >= 0:
        if i == 0 and j == 0:
            if dp_table_2[0][0] > 0:
                ans += s[0]
            break
        if j == 0:
            if dp_table_2[i][j] != dp_table_2[i-1][j]:
                ans += t[i]
            i -= 1
            continue
        if i == 0:
            if dp_table_2[i][j] != dp_table_2[i][j-1]:
                ans += s[j]
            j -= 1
            continue
        if dp_table_2[i][j] != dp_table_2[i][j-1] and dp_table_2[i][j] != dp_table_2[i-1][j]:
            ans += t[i]
            i -= 1
            j -= 1
        elif dp_table_2[i][j] != dp_table_2[i][j-1]: 
            i -= 1
        elif dp_table_2[i][j] != dp_table_2[i-1][j]: 
            j -= 1
        else:
            j -= 1

    print(ans[::-1])

main()

Measured memory_bytes: 119644
import sys
input = sys.stdin.readline

n, m = map(int, input().split())

# INF = float("inf")
INF = 10 ** 8
dp = [INF] * ((1<<n) + 1)
dp[0] = 0

for i in range(m):
    a, b = map(int, input().split())
    c = sum(1<<(ci-1) for ci in map(int, input().split()))

    for j in range(1<<n):
        # if dp[j] + a < dp[j | c]:
        #     dp[j | c] = dp[j] + a
        jc = j | c
        dp[jc] = min(dp[j] + a, dp[jc])

if dp[(1<<n) - 1] == INF:
    ans = -1
else:
    ans = dp[(1<<n) - 1]

print(ans)


Measured memory_bytes: 3188
import sys
n = int(input())
dic=[]
for i in range(n):
    inp = input()
    if inp in dic:
        print("No")
        sys.exit()
    else:
        if len(dic) > 0 and inp[0] != dic[-1][-1]:
            print("No")
            sys.exit()
        dic += [inp]
print("Yes")

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

int main() {
    int n, k, q;
    cin >> n >> k >> q;

    int a_point[100001];
    //int a[100001];
    //string A[100001];
    for(int i = 0; i < n; i++) {
        a_point[i] = k-q;
    }


    for(int i = 0; i < q; i++) {
        int win;
        cin >> win;
        a_point[win-1]++;
    }

    for(int i = 0; i < n; i++) {
        if(a_point[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 1024