akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

void int_to_bin(int x, vector<int> &ret){
  for (int i=0; i<ret.size(); i++){
    if (x >= pow(2, ret.size() - i - 1)){
      ret[i] = 1;
      x = x - (int)pow(2, ret.size() - i - 1);
    }
    else{
		ret[i] = 0;
    }
  }
}

bool can_reach(int X, vector<int> &prg){
  bool f = true;
  for (int i=0; i<prg.size(); i++){
    if (prg[i] < X){
      f = false;
      break;
    }
  }
  return f;
}

int main(){
  int N, M, X, t;
  cin >> N >> M >> X;
  vector<vector<int>> A;
  for (int i=0; i<N; i++){
    vector<int> tmp(M + 1, 0);
    for (int j=0; j<M+1; j++){
      cin >> t;
      tmp[j] = t;
    }
    A.emplace_back(tmp);
  }
  
  int ans = -1;
  for (int i=1; i<=pow(2, N); i++){
    vector<int> bin_(N, 0);
    int_to_bin(i, bin_);
    vector<int> sums(M, 0);
    int ans_tmp = 0;
    for (int j=0; j<N; j++){
      if (bin_[j] == 1){
        for (int k=0; k<M; k++){
          sums[k] += A[j][k+1];
        }
        ans_tmp += A[j][0];
      }
    }
    
    if (can_reach(X, sums)){
      ans = (ans >= 0 ? min(ans, ans_tmp) : ans_tmp);
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 4076
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int d,x;
    cin>>d>>x;
    int ar[n];
    int sum=0;
    sum=x+n;
    int tem=d-1;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        sum+=tem/ar[i];
    }

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


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

int n;
string c;

int main()
{
  while(cin >> n, n){
    int res = 0;
    stack<string> st;
    rep(i, n){
      cin >> c;
      st.push(c);
    }
    while(st.size() > 1){
      string curr = st.top();  st.pop();
      if(!st.empty()){
        string next = st.top();
        string stat = curr + next;
        if(stat == "luru" || stat == "rulu" || stat == "ldrd" || stat == "rdld"){
          res += 1;
          st.pop();
        }
      }
    }
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using ll = long long;
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    int p[100000], y[100000];
    vector<int> yd[100001];
    rep(i, m) {
        scanf("%d%d", &p[i], &y[i]);
        yd[p[i]].push_back(y[i]);
    }
    rep(i, n) sort(yd[i + 1].begin(), yd[i + 1].end()); //ydの添字pが1スタートだから+1してる。県の数n回繰り返す。
    // %0桁数d
    // lower_bound(yd[p[0]].begin(), yd[p[0]].end(), y[0]) は、探索したい値y[0]以上が現れる最初の位置のイテレータを取得。イテレータなので+1してる
    rep (i, m) {
        printf("%012lld\n", ll(p[i]) * 1000000 + int(lower_bound(yd[p[i]].begin(), yd[p[i]].end(), y[i]) - yd[p[i]].begin()) + 1);
    }
    return 0;
}


Measured memory_bytes: 9968
AB = [[int(_) for _ in input().split()] for _ in range(3)]
count = [0] * 5
for a, b in AB:
    count[a] += 1
    count[b] += 1
if sorted(count[1:]) == [1, 1, 2, 2]:
    print('YES')
else:
    print('NO')


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

edges = [[] for i in range(N+1)]
el = []
ecol = {}

for i in range(N-1):
    a,b = map(int,input().split())
    edges[a].append(b)
    edges[b].append(a)
    el.append("{},{}".format(a,b))

# BFS
queue = [[1,0]]
while(len(queue) != 0):
    #queueから取り出し
    p = queue.pop(0)
    p_el = edges[p[0]]
    c = 1
    for v in p_el:
        key1 = "{},{}".format(p[0],v)
        key2 = "{},{}".format(v,p[0])
        #まだ色がついていなければ
        if (not(key1 in ecol)) :
            # 色被りを考慮
            if (c == p[1]):
                c += 1
            ecol[key1] = c
            ecol[key2] = c
            queue.append([v,c])
            c += 1

print(max(ecol.values()))
for i in range(N-1):
    print(ecol[el[i]])





Measured memory_bytes: 58896
H, W = map(int, input().split())
a = [input() for i in range(H)]

rows = set()
cols = set()
for j in range(W):
    for i in range(H):
        if a[i][j] == '#':
            rows.add(i)
            cols.add(j)
for j in rows:
    for i in cols:
        print(a[j][i], end='')
    print('')


Measured memory_bytes: 4468
-- ?????? a cm ?????? b cm ???????????¢?????¢?????¨??¨?????????????±???????????????°?????????????????????????????????
import           Control.Applicative
import           Text.Printf

main :: IO ()
main = do
  [a, b] <- (map read . words) <$> getLine :: IO [Int]
  let area = a * b
      zhou = 2 * a + 2 * b

  printf "%d %d\n" area zhou

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


int main(){
	int N,M,X;
	int C[12],A[12][12];
	cin >> N >> M >> X;
	for(int i=0;i<N;i++){
		cin>>C[i];
		for(int j=0;j<M;j++)cin>>A[i][j];
	}
	int ans = 1e8;
	for (int i=0;i<1<<N;i++)
	{
		int now[12]={};
		int sum=0;
		for(int j=0;j<N;j++)if(i>>j&1)
		{
			sum+=C[j];
			for(int k=0;k<M;k++)now[k]+=A[j][k];
		}
		bool flag=true;
		for(int j=0;j<M;j++)if(now[j]<X)flag=false;
		if(flag&&ans>sum)ans=sum;
	}
	cout<<(ans>1e7?-1:ans)<<endl;
}



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

void chmin(int &a, int b) { a = min(a, b); }
void chmax(int &a, int b) { a = max(a, b); }

int n;
int h, w;
string s[50];

void solve() {
	int minX[26];
	int minY[26];
	int maxX[26];
	int maxY[26];
	static int rui[26][51][51];
	int i, j, k;
	
	for (i = 0; i < 26; i++) {
		minX[i] = 114;
		minY[i] = 114;
		maxX[i] = -114;
		maxY[i] = -114;
	}
	
	for (i = 0; i < 26; i++) {
		for (j = 0; j <= h; j++) {
			for (k = 0; k <= w; k++) {
				rui[i][j][k] = 0;
			}
		}
	}
	
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if ('A' <= s[i][j] && s[i][j] <= 'Z') {
				chmin(minX[s[i][j] - 'A'], j);
				chmax(maxX[s[i][j] - 'A'], j);
				chmin(minY[s[i][j] - 'A'], i);
				chmax(maxY[s[i][j] - 'A'], i);
				rui[s[i][j] - 'A'][i + 1][j + 1]++;
			}
		}
	}
	
	for (i = 0; i < 26; i++) {
		for (j = 0; j <= h; j++) {
			for (k = 1; k <= w; k++) rui[i][j][k] += rui[i][j][k - 1];
		}
		for (j = 0; j <= w; j++) {
			for (k = 1; k <= h; k++) rui[i][k][j] += rui[i][k - 1][j];
		}
	}
	
	string chars;
	bool used[26] = {false};
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (s[i][j] == '.') continue;
			if (!used[s[i][j] - 'A']) {
				chars += s[i][j];
				used[s[i][j] - 'A'] = true;
			}
		}
	}

	vector<int> perm;
	for (i = 0; i < chars.length(); i++) { perm.push_back(i); }
	do {
		int z[26] = {0};	//??????????????????
		int j;
		for (i = 0; i < chars.length(); i++) {
			z[chars[i] - 'A'] = perm[i] + 1;
		}
		
		for (i = 0; i < chars.length(); i++) {
			int id = chars[i] - 'A';
			int area = (maxY[id] - minY[id] + 1) * (maxX[id] - minX[id] + 1);
			for (j = 0; j < 26; j++) {
				if (z[j] < z[chars[i] - 'A']) continue;
				int a = rui[j][maxY[id] + 1][maxX[id] + 1];
				int b = rui[j][maxY[id] + 1][minX[id]];
				int c = rui[j][minY[id]][maxX[id] + 1];
				int d = rui[j][minY[id]][minX[id]];
				area -= a - b - c + d;
			}
			if (area != 0) { break; }
		}
		
		if (i == chars.length()) {
			cout << "SAFE" << endl;
			return;
		}
	} while (next_permutation(perm.begin(), perm.end()));
	
	cout << "SUSPICIOUS" << endl;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h >> w;
		for (int j = 0; j < h; j++) cin >> s[j];
		solve();
	}
	return 0;
}

Measured memory_bytes: 3480
n = int(input())
AB = 0
A_B = 0
A = 0
B = 0
for _ in range(n):
    s = input()
    AB += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        A_B += 1
        continue
    if s[0] == 'B':
        B += 1
    if s[-1] == 'A':
        A += 1
ans = 0
if A_B == 0:
    ans = AB + min(B, A)
else:
    if A + B:
        ans = AB + A_B + min(B, A)
    else:
        ans = AB + A_B - 1
print(ans)


Measured memory_bytes: 9084
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a,b,c) for(b=(c);b<(a);b++)
long kakuinowa(long x);
//inline long abs(long);
int main() {
	int a, b;
	cin >> a >> b;
	if ((a + b) == 15) {
		cout << '+';
	}
	else if ((a*b) == 15) {
		cout << '*';
	}
	else {
		cout << 'x';
	}
	return 0;
}

long kakuinowa(long x) {
	int y = 0;
	while (x>10)
	{
		y += x % 10;
		x /= 10;
	}
	y += x;
	return y;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

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

    ll ans = 1;
    rep(i, n){
        ans += i;
    }

    cout << ans-1 << endl;

    return 0;
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

int cnt = 0;


void solve()
{
	int n; cin >> n;
	double t, a; cin >> t >> a;
	vector<double> v(n);
	forn(i, n) cin >> v[i];
	double mn = 1e18 + 7;
	ll res = 0;
	for (int i = 0; i < n; ++i)
	{
		if (abs(t - v[i] * 0.006 - a) < mn)
		{
			mn = abs(t - v[i] * 0.006 - a);
			res = i + 1;
		}
	}
	cout << res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


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

void solve(long long X, long long Y, long long Z)
{

    swap(X, Y);
    swap(X, Z);

    cout << X << " " << Y << " " << Z << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You! use the default template now. You can remove this line by using your custom template)
int main()
{
    long long X;
    scanf("%lld", &X);
    long long Y;
    scanf("%lld", &Y);
    long long Z;
    scanf("%lld", &Z);
    solve(X, Y, Z);
    return 0;
}


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

int main(){

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll c_num, d_num, cd_num;
    c_num = b/c - a/c;
    if (a%c == 0){
        c_num += 1;
    }
    d_num = b/d - a/d;
    if (a%d == 0){
        d_num += 1;
    }

    ll temp;
    temp = (c*d)/__gcd(c, d);
    cd_num = b/(temp) - a/(temp);
    if (a%(temp) == 0){
        cd_num += 1;
    }

    ll ans = (b-a+1) - (c_num+d_num-cd_num);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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 A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int a, b;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> a >> b;
  int c = a + b, d = a - b, e = a * b;
  cout << max({c, d, e}) << endl;
  return 0;
}




Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
import bisect
import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal

INF = 1 << 50


def run():
    N, K = map(int, sysread().split())
    X = list(map(int, sysread().split()))

    best_time = INF
    for i in range(0, N-K+1):
        left = X[i]
        right =  X[i+K-1]
        if left<=0:
            if right <= 0:
                best_time = min(best_time, abs(left))
            else:
                best_time = min(abs(left) + right + min(abs(left), right), best_time)
        else:
            best_time = min(best_time, right)
            break

    print(best_time)


if __name__ == "__main__":
    run()

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

int	main()
{
	int64_t	A, B, C, K;
	cin >> A >> B >> C >> K;
	int64_t	max_sum;
	max_sum = min(A, K);
	if (K > A + B)
		max_sum -= (K - (A + B));
	cout << max_sum << endl;
}


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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;

    bool truth=true;
    for (int i = 0; i < a+b+1; i++) {
        if (i == a) {
            if (s[i] != '-') {
                truth = false;
                break;
            }
        }else{
            if (s[i] < '0' || '9' < s[i]) {
                truth = false;
                break;
            }
        }
    }

    if (truth) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 256
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 conv(a, b, b_max):
    return a*(b_max+1)+b

def main(): 
    N = II()
    # A = [[] for _ in range(N)]
    # for i in range(N):
    #     A[i] = LI()

    # print(A)
    # return

    from collections import defaultdict
    outs = defaultdict(list)
    ins = defaultdict(int)
    for i in range(N):
        # prev_v = (i+1, A[i][0]) if i+1 < A[i][0] else (A[i][0], i+1)
        a = LI()
        for j in range(1,N-1):
            # prev_v = (i+1, A[i][j-1]) if i+1 < A[i][j-1] else (A[i][j-1], i+1)
            # next_v = (i+1, A[i][j]) if (i+1 < A[i][j]) else (A[i][j] , i+1)
            # prev_v = conv(N, prev_v[0], prev_v[1])
            # next_v = conv(N, next_v[0], next_v[1])
            prev_v = (min(i+1, a[j-1]), max(i+1, a[j-1]))
            next_v = (min(i+1, a[j]), max(i+1, a[j]))
            prev_v = conv(prev_v[0]-1, prev_v[1]-1, N)
            next_v = conv( next_v[0]-1, next_v[1]-1, N)
            outs[prev_v].append(next_v)
            ins[next_v] += 1

    # print(outs, ins)
    # return

    from collections import deque
    q = deque()
    for i in range(1, N+1):
        for j in range(1, N+1):
        # j = A[i-1][0]
            if i < j and ins[conv(i-1, j-1, N)] == 0:
                q.append([conv( i-1, j-1, N), 0])

    if not q:
        print(-1)
        return

    # q = deque(v1 for v1 in range(1, N+1) if ins[v1] == 0)
    res = []
    depth_max = 0
    while q:
        v1, depth = q.popleft()
        res.append(v1)
        for v2 in outs[v1]:
            ins[v2] -= 1
            if ins[v2] == 0:
                q.append([v2, depth+1])
                depth_max = max(depth_max, depth+1)
    if len(res)!=N*(N-1)//2:
        print(-1)
        return
    else:
        print(depth_max+1)
        return

main()

Measured memory_bytes: 176872
#include<bits/stdc++.h>
#include<assert.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fo(i,s,n) for(int i=s;i<n;i++)
#define pb(x) push_back(x);
#define mod 1000000007


int main()
{
    Fast
    int n;
    cin>>n;
    vector<int>a(n),b(n),c(n);
    fo(i,0,n)
        cin>>a[i]>>b[i]>>c[i];
    int dp[n][3];
    memset(dp,-1,sizeof(dp));
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>


using namespace std;

int main() {

    int N, A, B;
    cin >> N >> A >> B;

    int counter = 0;
    for (int i = 1; i <= N; ++i) {
        string numString = to_string(i);
        int num = 0;
        for (int j = 0; j < numString.size(); ++j) {
            string sss = numString.substr(j, 1);
            num += atoi(sss.c_str());;
        }

        if (A <= num && num <= B) {
            counter += i;
        }
    }
    cout << counter << endl;
}



Measured memory_bytes: 384
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect

class Counter(dict):

    def __init__(self, l=None):
        if l is None:
            return
        for e in l:
            self[e] += 1

    def __missing__(self, key):
        self[key] = 0
        return self[key]

def make_i_list(height_list):
    i_list = [0] * len(height_list) # [0] is dummy
    for i, h in enumerate(height_list):
        i_list[i] = h + i
    i_list.pop(0) # delete dummy
    return i_list

def make_j_list(height_list):
    j_list = [0] * len(height_list) # [0] is dummy
    for j, h in enumerate(height_list):
        j_list[j] = - h + j
    j_list.pop(0) # delete dummy
    return j_list

def make_same_ij_person_dict(i_list, j_list, same_ij_person_dict):
    for key in range(1, len(i_list)): # skip 0 because dummy
        if i_list[key] == j_list[key]:
            value = i_list[key]
            same_ij_person_dict[value] += 1


if __name__ == '__main__':
    num_person = int(input())
    height_list = [0] + list(map(int, input().split())) # [0] is dummy
    i_list = make_i_list(height_list)
    j_list = make_j_list(height_list)
    i_dict = Counter(i_list) # var[value] = count
    j_dict = Counter(j_list) # var[value] = count
    # there is no person that i_list[key] == j_list[key]
    #print('i_list') # debug
    #print(i_list) # debug
    #print(i_dict) # debug
    #print('j_list') # debug
    #print(j_list) # debug
    #print(j_dict) # debug
    ans_count = 0
    for value in i_dict.keys():
        if value in j_dict.keys():
            ans_count += i_dict[value] * j_dict[value]
    print(ans_count)


    #print('\33[32m' + 'end' + '\033[0m') # debug


Measured memory_bytes: 143656
#include<stdio.h>
int main(void)
{
    int n,i,a[10000],b[10],flg,j;
	while(1){
	    scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++){
		    scanf("%d",&a[i]);
		}
		for(i=0;i<10;i++) b[i]=0;
		for(i=0;i<n;i++){
		    b[a[i]]++;
		}
		for(i=0;i<10;i++){
		    flg=0;
		    for(j=0;j<b[i];j++){
			    printf("*");
				flg=1;
			}
			if(flg==0) printf("-");
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2632
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()

dist = [0]*(M-1)
for i in range(0,M-1):
  dist[i] += X[i+1] - X[i]
  
dist.sort(reverse = True)

print(sum(dist[N-1:]))

Measured memory_bytes: 20416
s=input()
t=input()
ls=len(s)
lt=len(t)
S=''
for i in range(ls-lt+1):
    cnt=0
    for j in range(lt):
#        print(s[i+j])
        if s[i+j]==t[j]:
            cnt+=1
        elif s[i+j]=='?':
            cnt+=1
        else:
            break
    if cnt==lt:
        S=s[:i]+t+s[i+lt:]
if S=='':
    print('UNRESTORABLE')
else:
    S=list(S)
    for i in range(ls):
        if S[i]=='?':
            S[i]='a'
    print(''.join(S))


Measured memory_bytes: 3064
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()
  a=s.count('o')
  if 15-len(s)+a>=8:
    return 'YES'
  else:
    return 'NO'

print(main())


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

 int main(){
    unsigned long long int d=998244353,ans;
    unsigned long long int n,tep,ma=0;
    cin >>n;
    vector<unsigned long long int> a(n);
    vector<unsigned long long int> so(n);
    cin >> tep ;
    if(tep!=0){
        cout << 0 << endl;
        return 0;
        }
    else{
        a.at(0)++;
    }

    for(unsigned long long int i=1;i<n;i++){
        cin >> tep ;
        a.at(tep)++;
        if(tep==0){
            cout << 0 << endl;
            return 0;
        }
        if(tep>ma){
            ma=tep;
        }

    }
    so.at(1)=a.at(1);
    for(unsigned long long int i=2;i<=ma;i++){
        ans=a.at(i-1);
        for(unsigned long long int l=1;l<a.at(i);l++){
            ans*=a.at(i-1);
            ans%=d;
        }
        so.at(i)=ans%d;
    }
    ans=1;
    for(unsigned long long int l=2;l<=ma;l++){
        ans*=so.at(l);
        ans%=d;
    }
    cout << ans%d << endl;
 }

Measured memory_bytes: 1792
//59
#include<iostream>
#include<map>
#include<vector>

using namespace std;

typedef vector<vector<bool> > VVB;

VVB mul(VVB a,VVB b){
  VVB r(a.size(),vector<bool>(a.size()));
  for(int i=0;i<r.size();i++){
    for(int j=0;j<r.size();j++){
      for(int k=0;k<r.size();k++){
	r[i][j]=r[i][j]|(a[i][k]&b[k][j]);
      }
    }
  }
  return r;
}

VVB pow(VVB v,int n){
  VVB r(v.size(),vector<bool>(v.size()));
  for(int i=0;i<r.size();i++){
    r[i][i]=true;
  }
  for(;n;n>>=1){
    if(n&1){
      r=mul(r,v);
    }
    v=mul(v,v);
  }
  return r;
}

int main(){
  for(int n,m,z;cin>>n>>m>>z,n|m|z;){
    map<int,int> mp[51];
    while(m--){
      int s,t;
      cin>>s>>t;
      mp[s][t];
      mp[t][s];
    }
    int nm=1;
    typedef map<int,int>::iterator mit;
    for(int i=1;i<=n;i++){
      for(mit it=mp[i].begin();it!=mp[i].end();it++){
	it->second=nm++;
      }
    }
    VVB v(nm,vector<bool>(nm));
    for(mit i=mp[1].begin();i!=mp[1].end();i++){
      v[0][mp[i->first][1]]=true;
    }
    for(int i=1;i<=n;i++){
      for(mit j=mp[i].begin();j!=mp[i].end();j++){
	for(mit k=mp[i].begin();k!=mp[i].end();k++){
	  if(j->first!=k->first){
	    v[j->second][mp[k->first][i]]=true;
	  }
	}
      }
    }
    v=pow(v,z);
    bool r=false;
    for(mit i=mp[n].begin();i!=mp[n].end();i++){
      r|=v[0][i->second];
    }
    cout<<(r?"yes":"no")<<endl;
  }
  return 0;
}

Measured memory_bytes: 1264
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,k) = get!(usize, usize);
    let p = get!([usize]);
    let mut sums = vec![0.0f64; n+1];
    for i in 0..n {
        sums[i+1] = sums[i]+(p[i] as f64+1.0)/2.0;
    }
    let mut mx = 0.0f64;
    for i in 0..n-k+1 {
        mx = mx.max(sums[i+k]-sums[i]);
    }
    println!("{}", mx);
}


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


def calc(start, P, C, k):
    seen = {start}
    loop = 1
    pos = start
    res = 0
    maxim = -float("INF")
    for _ in range(k):
        next = P[pos]
        point = C[next]
        res += point
        pos = next
        if res > maxim:
            maxim = res
        if pos in seen:
            break
        seen.add(pos)
        loop += 1

    if res <= 0:
        return maxim
    if loop >= k + 1:
        return maxim
    residue = k - loop
    t = residue // loop
    residue %= loop
    max1 = res * t + maxim
    res *= (t+1)
    max2 = res
    for _ in range(residue):
        next = P[pos]
        point = C[next]
        res += point
        pos = next
        if res > max2:
            max2 = res

    return max(max1, max2)


def main():
    n, k = map(int, input().split())
    P = list(map(lambda x: int(x)-1, input().split()))
    C = list(map(int, input().split()))

    ans = -float("INF")
    for start in range(n):
        res = calc(start, P, C, k)
        if ans < res:
            ans = res

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 129324
using System;
using System.Text;

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			var s = "";
			while((s = Console.ReadLine()) != null)
			{
				while(!s.Contains("the") && !s.Contains("this") && !s.Contains("that"))
				{
					var sb = new StringBuilder();
					foreach(var c in s)
					{
						if(char.IsLetter(c))
						{
							if(c == 'z')
							{
								sb.Append('a');
							}
							else
							{
								sb.Append((char)(c + 1));
							}
						}
						else
						{
							sb.Append(c);
						}
					}
					s = sb.ToString();
				}
				Console.WriteLine(s);
			}
		}
	}
}

Measured memory_bytes: 6200
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 10005;
int main(void) {
    int number,count = 1,i = 0;
    int list[maxn] = {0};
    while(1){
        scanf("%d",&list[i]);
        if(list[i] == 0)
            break;
        i++;
    }
    for(int j = 0;j < i;j++)
        printf("Case %d: %d\n",count++,list[j]);
    return 0;
}


Measured memory_bytes: 3248
import io, sys, atexit, os

import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations


def li ():
	return list (map (int, input ().split ()))


def num ():
	return map (int, input ().split ())


def nu ():
	return int (input ())


def find_gcd ( x, y ):
	while (y):
		x, y = y, x % y
	return x


mm = 1000000007



def solve ():
	t = 1
	for it in range (t):
		n,m=num()
		x=[]
		for i in range(n):
			l,r=num()
			x.append((l,r))
		x.sort()
		cc=m
		cost=0
		for i in range(n):
			cost+=x[i][0]*min(cc,x[i][1])
			cc-=min(cc,x[i][1])
		print(cost)






if __name__ == "__main__":
	solve ()

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

even, odd = 0, 0

for i in a:
    if i % 2 == 0:
        even += 1
    else:
        odd += 1

if n == even:
    if p == 0:
        print(2**n)
    else:
        print(0)

else:
    print(2**(n-1))

Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
  let s = read::<String>();
  let t = read::<String>();

  let mut s_str = s.chars().collect::<Vec<char>>();
  let t_str = t.chars().collect::<Vec<char>>();
  let s_len = s_str.len();
  let mut ok = false;

  for i in 0..s_len {
    let si = s_str.pop().unwrap();
    s_str.insert(0, si);

    // println!("{:?}", s_str);
    if t_str == s_str {
      ok = true;
      break;
    }
  }

  if ok {
    println!("Yes");
  } else {
    println!("No");
  }
  // println!(
  //   "{}",
  //   tasks.iter().max().unwrap() - tasks.iter().min().unwrap()
  // );
}



Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>

using namespace std;

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

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

	int *a;

	a = new int[n];

	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	qsort(a, n, sizeof(int), compare_int);
	bool flag = 0;
	for (int i = 0; i < n - 1; ++i) {
		if (a[i] == a[i + 1]) {
			flag = 1;
			break;
		}
	}

	if (!flag) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}

	return 0;
}


Measured memory_bytes: 1788
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())


    
n,m=mi()
a=li()
x=[]
c=1
k=0
m1={}
m1[1]=k
k+=1
x1=0
while(1):
    if a[c-1] in m1:
        x1=a[c-1]
        break
    m1[a[c-1]]=k
    k+=1
    c=a[c-1]
if(m<k):
    for i in m1.keys():
        if m1[i]==m:
            print(i)
            break
else:
    m-=k
    m1={}
    m1[x1]=0
    k=1
    c=a[c-1]
    while(1):
        if a[c-1] in m1:
            break
        m1[a[c-1]]=k
        k+=1
        c=a[c-1]
    m%=k
    for i in m1.keys():
        if m1[i]==m:
            print(i)
            break
    
    
    
    
    

Measured memory_bytes: 126216
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD 1000000007
void bulk(){}template<class H,class...T>void bulk(H&h,T&...t){cin>>h;bulk(t...);}
#define get(...) int __VA_ARGS__; bulk(__VA_ARGS__);
int main(){
	get(n,m);
    vvi p(n,vi(2));
    vvi q(m,vi(2));
    rep(i,n)cin>>p[i][0]>>p[i][1];
    rep(i,m)cin>>q[i][0]>>q[i][1];
    for(auto a:p){
        int dist=INF,id=0;
        rrep(i,m){
            int d=abs(a[0]-q[i][0])+abs(a[1]-q[i][1]);
            if(d<=dist){
                dist=d; id=i+1;
            }
        }
        cout<<id<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r,D,x;
  cin >> r >> D >> x;
int i = 0; // カウンタ変数
while (i < 10) {
  x =r*x-D;
  cout << x << endl;
  i ++;
}
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int N = 1e5 + 5 ;
using namespace std ;

int n, e, lnk[N], nxt[N << 1], ter[N << 1] ;

void add(int x, int y) {
	ter[++ e] = y, nxt[e] = lnk[x], lnk[x] = e ;
}

int dfs(int p, int las) {
	int cnt = 0 ;
	for (int i = lnk[p] ; i; i = nxt[i]) if (ter[i] != las) {
		cnt += dfs(ter[i], p) ;
	}
	if (cnt == 0) return 1 ; else
	  if (cnt > 1) return 2 ; else return 0 ;
}

int main() {
	for ( ; scanf("%d", &n) != EOF ; ) {
		rep(i, 1, n) lnk[i] = 0 ;
		rep(i, 1, e) nxt[i] = 0 ; e = 0 ;
		int x, y ;
		rep(i, 1, n - 1) {
			scanf("%d%d", &x, &y) ;
			add(x, y), add(y, x) ;
		}
		if (!dfs(1, 0)) printf("Second\n") ; else printf("First\n") ;
	}
	return 0 ; 
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#define N 36
#define M 1000
using namespace std;

int main(){
  int n,m,q,ans[N][M],a;
  string s[M],b[M],sw,li;
  vector<int> on,off,k,koff;
  while(1){
    cin>>n>>m>>q;
    if(!n&&!m&&!q) break;
    for(int i=0;i<q;i++) cin>>s[i]>>b[i];
    for(int i=0;i<N;i++)
      for(int j=0;j<M;j++) ans[i][j]=1;
    for(int i=0;i<n;i++) sw+='0';
    for(int i=0;i<m;i++) li+='0';
    for(int i=0;i<q;i++){
      for(int j=0;j<n;j++){
	if(sw[j]=='1'&&s[i][j]=='0') k.push_back(j);
	if(sw[j]=='0'&&s[i][j]=='1') on.push_back(j);
	if(sw[j]=='1'&&s[i][j]=='1') off.push_back(j);
	if(sw[j]=='0'&&s[i][j]=='0') koff.push_back(j);
      }
      for(int j=0;j<m;j++){
	if(li[j]=='1'&&b[i][j]=='1'){
	  for(int l=0;l<on.size();l++) ans[on[l]][j]=0;
	  for(int l=0;l<off.size();l++) ans[off[l]][j]=0;
	  for(int l=0;l<koff.size();l++) ans[koff[l]][j]=0;
	}
	if(li[j]=='1'&&b[i][j]=='0'){
	  for(int l=0;l<on.size();l++) ans[on[l]][j]=0;
	  for(int l=0;l<k.size();l++) ans[k[l]][j]=0;
	  for(int l=0;l<koff.size();l++) ans[koff[l]][j]=0;
	}
	if(li[j]=='0'&&b[i][j]=='1'){
	  for(int l=0;l<k.size();l++) ans[k[l]][j]=0;
	  for(int l=0;l<koff.size();l++) ans[koff[l]][j]=0;
	  for(int l=0;l<off.size();l++) ans[off[l]][j]=0;
	}
	if(li[j]=='0'&&b[i][j]=='0'){
	  for(int l=0;l<on.size();l++) ans[on[l]][j]=0;
	  for(int l=0;l<k.size();l++) ans[k[l]][j]=0;
	  for(int l=0;l<off.size();l++) ans[off[l]][j]=0;
	}
      }
      k.clear();
      koff.clear();
      on.clear();
      off.clear();
      for(int j=0;j<n;j++)
	if(s[i][j]=='1') sw[j]=='0'?sw[j]='1':sw[j]='0';
      for(int j=0;j<m;j++) li[j]=b[i][j];
    }
    for(int i=0;i<m;i++){
      a=-1;
      for(int j=0;j<n;j++)
	if(ans[j][i]==1){
	  if(a==-1) a=j;
	  else{
	    a=-1;
	    break;
	  }
	}
      if(a==-1) cout<<'?';
      else{
	if(a<=9) cout<<a;
	else cout<<(char)('A'+a-10);
      }
    }
    cout<<endl;
    sw="";
    li="";
  }
  return 0;
}

Measured memory_bytes: 2652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}
	int count = 0;
	int tmp_total;
	for (int i = 0; i < N; i++) {
		tmp_total = C;
		for (int j = 0; j < M; j++) {
			tmp_total += A[i][j] * B[j];
		}
		if (tmp_total > 0) {
			count++;
		}
	}

	cout << count;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
long long a[100001];
int main()
{
	long long n, k, m, x = 0, total = 0;
	scanf("%lld%lld", &n, &k);
	for(long long i = 0; i < n; scanf("%lld", &a[i++])){}
	for(long long i = 40, count = 0; i >= 0; --i, count = 0)
	{
		for(long long j = 0; j < n; ++j)
		{
			if(a[j] & (1ll << i))
			{
				++count;
			}
		}
		if(count >= n - count)
		{
			total += (1ll << i) * count;
		}
		else
		{
			if(x + (1ll << i) <= k)
			{
				total += (1ll << i) * (n - count);
				x += (1ll << i);
			}
			else
			{
				total += (1ll << i) * count;
			}
		}
	}
	printf("%lld\n", total);
}

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

int main () {
  int  N ;
  string S , T ;
  cin >> N >> S >> T ;
  for(int i = 0 ; i < N ; i ++ ){
    bool can = true ;
    for(int j = 0 ; j < N - i  ; j++ ){
      if(S[i+j]!=T[j]) can = false ;
    }
      if(can) {
        cout << N + i << endl ;
        return 0 ;
      }
    }
  cout << 2 * N << endl ;
}

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

int main(){
  int N,M,sum;
  sum=0;
  M=0;
  cin >> N;
  int L[N];
  for(int i=0; i<N; ++i){
    cin >> L[i];
    sum += L[i];
    M=max(M,L[i]);
  }
  if(sum>2*M) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.buffer.readline


def sss(A, N):
    A.sort()
    while A[0] == 0:
        A.remove(0)
    for i in range(1, len(A)):
        A[i] = A[i] % A[0]
    if A[0] == sum(A):
        print(sum(A))
    else:
        return sss(A, N)


def main():
    N = int(readline())
    A = list(map(int, readline().split()))

    sss(A, N)


main()


Measured memory_bytes: 12496
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#define mp make_pair
#define mpp(AA, BB, CC) mp( mp(BB, CC) , AA )
#define F first
#define S second
#define mod ((ll)(1e9+7))
#define ll long long int

using namespace std;

int main()
{
    ll n, a;
    cin >> n;
    vector < ll > v;
    for(ll i = 0 ; i < n ;i++){
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    vector < ll > e;
    ll i = 1;
    if(n%2 == 1){
        e.push_back(0);
        i++;
    }
    for(; i < n ; i += 2){
        e.push_back(i);
        e.push_back(i);
    }
    if(e != v) cout << 0;
    else{
        ll res = 1;
        for(i = 0 ; i < (n/2) ; i++){
            res = (res*2)%mod;
        }
        cout << res;
    }
    return 0;
}










Measured memory_bytes: 2548
N = int(input())
if(N == 1):
	answer = 1
else:
	answer = 0
max_count = 0
for val in range(N+1):
    tmp = val
    count = 0
    while (tmp % 2 == 0):
        if(tmp == 0):
            break
        tmp /= 2
        count += 1
    if(max_count < count):
        answer = val
        max_count = count

print(answer)


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c;
  if(a*c<=b){
    d=c;
  }else{
    d=b/a;
  }
  cout<<d<<endl;
  
  
  
 
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
import sys
sys.setrecursionlimit(10**6)
L=[set() for i in range(n)]
for i in range(m):
    a, b =  map(int, input().split())
    L[a-1] |= {b}
    L[b-1] |= {a}
Y = {range(1, n+1)}
Z = [0]*(n-1) 
S = {1}
def f(X):
    global S, Z
    X_next = set()
    for j in X:
        R = L[j-1]-S
        S |= L[j-1]
        X_next |= R
        for k in R:
            Z[k-2] += j
    if X_next == set():
        print("Yes")
        print('\n'.join(map(str, Z)))
    else:
        return  f(X_next)
f({1})

Measured memory_bytes: 182888
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s, t string
	fmt.Scanf("%s", &s)
	fmt.Scanf("%s", &t)

	if strings.HasPrefix(t, s) {
		fmt.Print("Yes\n")
	} else {
		fmt.Print("No\n")
	}
}


Measured memory_bytes: 1820
X = int(input())

if 400<=X<=599:
    print(8)
if 600<=X<=799:
    print(7)
if 800<=X<=999:
    print(6)
if 1000<=X<=1199:
    print(5)
if 1200<=X<=1399:
    print(4)
if 1400<=X<=1599:
    print(3)
if 1600<=X<=1799:
    print(2)
if 1800<=X<=1999:
    print(1)


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

int gcd(int a, int b){

int p,q,r;

if(a<b){p=b;b=a;a=p;

}

   while((r=b%a)!=0){
  q=b/a;
  b=a;
  a=r;
  }
  return a;
  
}

int main(void)
{    int a, b;
   while(cin >> a >> b) {
     int lcm = a/gcd(a,b)*b;
     cout << gcd(a,b) << " " << lcm << endl;
   }
   return 0;
}


Measured memory_bytes: 2996
S = input()
N = len(S)
  
cnt = 0

Srev = ""
for i in range(1, N + 1):
  Srev += S[-1*i]
if S == Srev:
  cnt += 1
  
S1 = S[0:(N - 1)//2]
S1rev = ""
for i in range(1, len(S1) + 1):
  S1rev += S1[-1*i]
if S1 == S1rev:
  cnt += 1
  
S2 = S[(N + 3)//2 - 1:N + 1]
S2rev =""
for i in range(1, len(S2) + 1):
  S2rev += S2[-1*i]
if S2 == S2rev:
  cnt += 1

if cnt == 3:
  print("Yes")
else:
  print("No") 

Measured memory_bytes: 9084
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int N=505;
int a[N][N],n,m;
int cnt=0;
int b[N*N*100][4];
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
cin >>n>>m;
for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
		scanf("%d",&a[i][j]);
for(int i=1;i<=n;i++)
	{
	for(int j=1;j<=m;j++)
		{
		if(a[i][j]%2==0)
			continue;
		if(i==n&&m==j)continue;
		if(j==m)
			{
			cnt++;
			b[cnt][0]=i,b[cnt][1]=j,b[cnt][2]=i+1,b[cnt][3]=j;
			a[i][j]--;
			a[i+1][j]++;
			}
		else 
			{
			cnt++;
			b[cnt][0]=i,b[cnt][1]=j,b[cnt][2]=i,b[cnt][3]=j+1;
			a[i][j]--;
			a[i][j+1]++;
			}
		}
	}
cout <<cnt<<endl;
for(int i=1;i<=cnt;i++)
	{
	printf("%d %d %d %d\n",b[i][0],b[i][1],b[i][2],b[i][3]);
	}
return 0;
}


Measured memory_bytes: 6272
# class Solution:
#     def solve(self, a, b, c, s):
#         return str(a + b + c) + " " + s


def main():
    inp = lambda: [int(x) for x in input().split()]
    s = input()
    n = (len(s)) // 2
    is_paliny = lambda a: a == a[::-1]
    ans = "Yes" if is_paliny(s) and is_paliny(s[:n]) else "No"
    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 38256
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

n = int(input())
print(str.lower(num2alpha(n)))

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

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

	for(string s; cin >> s && s != "0";) {
		int ans = 0;
		array<int, 11> dp;
		dp.fill(0);

		for(int i = 0; i < static_cast<int>(s.size()); ++i) {
			if(s[i] != '0') ++dp[0];

			array<int, 11> tmp;
			tmp.fill(0);
			for(int j = 0; j < 11; ++j) {
				tmp[(j * 10 + s[i] - '0') % 11] += dp[j];
			}

			ans += tmp[0];
			dp.swap(tmp);
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1316
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19
constexpr static double EPS = 1e-10;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a - b)) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;
 
 
int main (void)
{
    int h, w;
    int i, j;
 
    while (scanf("%d %d", &h, &w) != EOF && h != 0 || w != 0){
        for (i=0; i<h; i++){
            for (j=0; j<w; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
 
 
    return 0;
}

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

using namespace std;

int main () {
    int n = 0, m = 0, x = 0;
    cin >> n >> m >> x;
    int count_to0 = 0, count_ton = 0;
    for (int i=0; i<m; i++) {
        int buf = 0;
        cin >> buf;
        if (buf < x) count_to0++;
        else count_ton++;
    }
    cout << min(count_to0, count_ton) << endl;
    return 0;
}


Measured memory_bytes: 256