akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
#include<complex>
#include<array>
#include<numeric>
#include<functional>
#include<random>

using namespace std;
#define ll long long
#define ull unsigned long long
#define rrep(i,m,n) for(ll (i)=(ll)(m);(i)>=(ll)(n);(i)--)
#define rep(i,m,n) for(ll (i)=(ll)(m);i<(ll)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
constexpr long double m_pi = 3.1415926535897932L;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 61;
constexpr long double EPS = 1e-10;
template<typename T> using vector2 = vector<vector<T>>;
template<typename T> using vector3 = vector<vector2<T>>;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
string operator*(const string& s, int k) {
	if (k == 0) return "";
	string p = (s + s) * (k / 2);
	if (k % 2 == 1) p += s;
	return p;
}

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

class AhoCorasick {
private:
	vector2<int> nxt;//現在のノードにchを追加した場合のノード　存在しなければsuffix linkを辿る
	vector<int> fail, end;//suffix link,そのノードに存在する文字列の数
	int root;
	int p;//ノードの数
	int maxn;//文字の合計サイズ
	vector2<int> type;
public:
	AhoCorasick(int maxn) :maxn(maxn), nxt(maxn, vector<int>(26, -1)), fail(maxn), end(maxn, 0), p(1), root(0),type(maxn,vector<int>(26,0)) {}

	inline void insert(const string& s) {
       		Array cnt(26, 0);
      		for(auto ch:s ) cnt[ch-'a']++;
		int now = root;
		REP(i, 26) {
			if (cnt[i] != 0)type[now][i]++;
		}
		for (int i = 0; i < s.size(); i++) {
			if (nxt[now][s[i] - 'a'] == -1) nxt[now][s[i] - 'a'] = p++;
			now = nxt[now][s[i] - 'a'];
			cnt[s[i] - 'a']--;
			REP(j, 26) {
				if (cnt[j] != 0)type[now][j]++;
			}
		}
		end[now]++;
	}
	
	inline int solve(const string& s) {
		int now = root;
		for (int i = 0; i < s.size() - 1; i++)now = nxt[now][s[i] - 'a'];
		return type[now][s.back() - 'a'] - 1;
	}
};

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

	ll n;
	cin >> n;
	vector<string> s(n);
	map<pair<string, char>, ll> mp;
	REP(i, n)cin >> s[i];
	sort(all(s), [](string a, string b) {return a.size() < b.size(); });
	AhoCorasick ac(1010101);
	REP(i, n) {
		reverse(all(s[i]));
		ac.insert(s[i]);
	}
	ll ans = 0;
	REP(i, n) ans += ac.solve(s[i]);
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 285580
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
// #define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    ll ans = 0;
    REP(i, N-1) {
        if (A[i] <= A[i+1]) {
            continue;
        } else {
            ans += A[i] - A[i+1];
            A[i + 1] = A[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4808
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

const long long MAX_V = 200000;
const long long INF = 1LL << 60;
typedef long long ll;

struct edge
{
    long long to, cost;
};
typedef pair<long long, long long> P;

long long d[MAX_V];
long long prevnode[MAX_V];
bool visited[MAX_V];
long long n, m, t;

vector<edge> G[MAX_V];

void dijkstra(long long s, vector<edge> G[])
{
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + MAX_V, INF);
    fill(prevnode, prevnode + MAX_V, -1);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty())
    {
        P p = que.top();
        que.pop();
        long long v = p.second;
        if (d[v] < p.first)
            continue;
        for (long long i = 0; i < G[v].size(); i++)
        {
            edge e = G[v][i];
            if (not(visited[e.to]) and d[e.to] > d[v] + e.cost)
            {
                d[e.to] = d[v] + e.cost;
                prevnode[e.to] = v;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

vector<long long> get_path(ll t)
{
    vector<ll> path;
    for (; t != -1; t = prevnode[t])
        path.push_back(t);
    reverse(path.begin(), path.end());
    return path;
}

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

    REP(i, n - 1)
    {
        long long a, b, c;
        cin >> a >> b;
        c = 1;
        a--;
        b--;
        edge e;
        e.to = b;
        e.cost = c;
        G[a].push_back(e);

        edge e2;
        e2.to = a;
        e2.cost = c;
        G[b].push_back(e2);
    }
    fill(visited, visited + MAX_V, false);
    dijkstra(0, G);

    vector<ll> tmp = get_path(n - 1);
    /*
    for (auto i : tmp)
    {
        cout << i + 1 << endl;
        
    }
    */
    fill(visited, visited + MAX_V, false);
    visited[0] = visited[n - 1] = true;

    for (int i = tmp.size() / 2 + tmp.size() % 2; i < tmp.size(); i++)
    {
        visited[tmp[i]] = true;
    }

    dijkstra(0, G);
    long long num = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if (d[i] != INF)
        {
            num++;
        }
    }

    fill(visited, visited + MAX_V, false);
    visited[0] = visited[n - 1] = true;
    for (int i = 0; i < tmp.size() / 2 + tmp.size() % 2; i++)
    {
        visited[tmp[i]] = true;
    }
    dijkstra(n - 1, G);
    long long num2 = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if (d[i] != INF)
        {
            num2++;
        }
    }

    if (num > num2)
    {
        cout << "Fennec" << endl;
    }
    else
    {
        cout << "Snuke" << endl;
    }
}

Measured memory_bytes: 14072
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	A
# CreatedDate:  2020-08-29 20:57:54 +0900
# LastModified: 2020-08-29 21:01:15 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    D, T, S = map(int, input().split())
    if T*S >= D:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 9148
from itertools import combinations

N = int(input())

def int_len(n):
    return len(str(n))

a = i = 1
list = []
while a <= N:
    if N % i == 0:
        b = N // i
        c = N // b
    list.append(max(int_len(b), int_len(b)))
    
    i += 1
    a = i ** 2

ans = min(list)
print(ans)

Measured memory_bytes: 3864
if __name__ == '__main__':
    n = int(input())
    arr = list(map(int, input().split()))
    arr.sort(reverse=True)
    halfway = len(arr)//2 + 1
    otherhalf = n-halfway
    total = 0
    for i in range(1, halfway+2):
        if i == 1:
            total += arr[0]
        else:
            if i < halfway:
                total += min(arr[0], arr[i-1])
            if otherhalf >= 1:
                total += min(arr[0], arr[i-1])
                otherhalf -= 1
    print(total)



Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for( int i=a; i<b; i++)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<pii>vpi;
vi A(101);
vector<vector<int>> dp(1e5+1,vector<int>(2,-1));
int n,k;
int ans;
bool solve(int k){
    for(int i = 0;i<=k;i++){
        for(int j=0;j<2;j++){
            dp[i][j] = 1-j;
            for(int ind=0;ind<n && A[ind]<=i;ind++){
                // cout<<"entered:"<<i<<" "<<j<<"\n";
                // cout<<A[ind]<<":::"<<i<<"\n";
                if(dp[i-A[ind]][1-j]==j){    // player with turn j selects A[ind]
                    dp[i][j] = j;
                    break;
                }
            }
        }
    }
    // for(ll i =0;i<=k;i++){
    //     cout<<dp[i][0]<<" "<<dp[i][1]<<"\n";
    // }
    return dp[k][0];
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    sort(A.begin(),A.begin()+n);
    ans = solve(k);
    cout<<(ans==0 ? "First" : "Second")<<"\n";
}

Measured memory_bytes: 8556
#include<bits/stdc++.h>
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define mp make_pair
#define pb push_back
#define tp make_tuple
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr(a) printf("%lld\n",a)
using namespace std;
#define mod 1000000007

bool chk_bit(ll n,ll k) // check whether 0 or 1
{
    return n & (1LL << k);
}

int main()
{
    ll n,i,j,x=0,y=0,d;

    cin>>n;

    ll a[n+5];

    for(i=0; i<n; i++)cin>>a[i];

    ll sum=0;

    for(i=0; i<64; i++)
    {

        x=0,y=0;

        for(j=0; j<n; j++)
        {

            if(chk_bit(a[j],i))x++;
            else y++;
        }

        d=(x*y)%mod;

        ll dd=(1LL << i)%mod;

        ll kk=(d*dd)%mod;

        sum+=kk;

        sum=sum%mod;
    }

    cout<<sum%mod<<endl;


}

Measured memory_bytes: 5968
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B,C,D;
  string a,b,c;
  cin >>A>>B;
  Out((A+B)%24);
}


Measured memory_bytes: 256
q = int(input())
ab = [tuple(map(int, input().split())) for _ in range(q)]



for a, b in ab:
    if a > b:
        large = a
        small = b
    elif a < b:
        large = b
        small = a
    else:
        print(2* a - 2)
        continue


    # 最大のxを探す
    low_x = 0 
    upper_x = large - small + 1

    while upper_x- low_x> 1:
        mid_x = (low_x + upper_x ) //2

        # a * bを満たすかチェック
        is_ok = True
        for i in range(mid_x // 2 -2, mid_x //2 +3) :
            if i< 0 and b -a < i:
                continue
            if (small + i) * (small + mid_x - i) >= large* small:
                is_ok = False
                break

        if is_ok:
            low_x = mid_x
            x = mid_x
        else:
            upper_x = mid_x
            x= mid_x


    print(2 * small -2  + low_x)



Measured memory_bytes: 3064
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;


public class Main {
    static int gcd(int x, int y) {
        /*if (x > y) {
            int temp = x;
            x = y;
            y = temp;
        }
        List<Integer> cand = new ArrayList();
        int ans = 1;
        for (int i = 1; i < Math.sqrt(x); i++) {
            if (x % i == 0) {
                cand.add(i);
                cand.add(x/i);
            }
        }
        Collections.sort(cand);
        for (int i = cand.size()-1; i > 0; i--) {
            if (y % cand.get(i) == 0) {
                ans = cand.get(i);
                break;
            }
        }
        return ans;*/
        
        int tmp;
        while ((tmp = x % y) != 0) {
            x = y;
            y = tmp;
        }
        return y;
    }
    
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] sa = br.readLine().split(" ");
        int[] a = new int[sa.length];
        
        for (int i = 0; i < a.length; i++) {
            a[i] = Integer.parseInt(sa[i]);
        }
        
        int[] l = new int[n];
        int[] r = new int[n];
        
        l[0] = a[0];
        for (int i = 1; i < n; i++) {
            l[i] = gcd(l[i-1], a[i]);
        }
        
        r[0] = a[n-1];
        for (int i = 1; i < n; i++) {
            r[i] = gcd(r[i-1], a[n-1-i]);
        }
        
        int max = 1;
        for (int i = 0; i < n; i++) {
            int num;
            if (i == 0) {
                num = r[n-2];
            }
            else if (i == n-1) {
                num = l[n-2];
            }
            else num = gcd(l[i-1], r[n-2-i]);
            if (num > max) max = num;
        }
        
        System.out.println(max);
        //System.out.println(gcd(6,12));
    }
}





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

int mod = 100000007;
struct mint {
    ll x;
    mint(ll x=0):x( (x%mod + mod) % mod ) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ( (x += a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ( ( x += mod - a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        ( x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator() (int n, int k) {
        if ( k < 0 || k > n ) return 0;
        return fact[n] * ifact[k] * ifact[n-k];
    }
};



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

  vector< vector<mint> > dp(3005, vector<mint>(3005, 0) );
  vector<mint> p(3005 * 3005, 0), p2(3005, 0), f(3005, 0);
  combination c(3005);
  p[0] = 1, p2[0] = 2;
  for(int i = 1; i < 3005 * 3005; ++i) p[i] = mint(2) * p[i-1];
  for(int i = 1; i < 3005; ++i) p2[i] = p2[i-1] * p2[i-1];

  dp[0][0] = 1;
  for (int n = 1; n < 3005; ++n) {
    for (int k = 0; k <= n; ++k) {
      dp[n][k] += dp[n-1][k];
      if (k-1>=0) dp[n][k] += dp[n-1][k-1];
      dp[n][k] += mint(k) * dp[n-1][k];
    }
  }

  rep(k, n+1) {
    rep(x, k+1) {
      f[k] += dp[k][x] * p[(n - k) * x];
    }
    f[k] *= p2[n - k];
  }

  mint ans = 0;
  rep(k, n + 1) {
    if (k%2 == 0) {
      ans += c(n,k) * f[k];
    } else {
      ans -= c(n,k) * f[k];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 144516
#include <iostream>
#include <fstream>

#define INF 1000000001
using namespace std;

int counter =0;

void merge(int *a, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int *l = new int[n1+1];
    int *r = new int[n2+1];
    for(int i=0;i<n1;i++) l[i] = a[left+i];
    for(int i=0;i<n2;i++) r[i] = a[mid+i];
    l[n1] = r[n2] = INF;
    int i=0,j=0;
    for(int k= left;k<right;k++){
        if(l[i] <= r[j]){
            a[k] = l[i];
            i++;
        }else{
            a[k] = r[j];
            j++;
        }
        counter++;
    }

    delete [] l;
    delete [] r;
}

void mergeSort(int *a, int left, int right){
    if(left+1 < right){
        int mid = (left + right) /2;
        mergeSort(a,left,mid);
        mergeSort(a,mid,right);
        merge(a,left,mid,right);
    }
}

int main(){

    int n;
    cin >> n;
    int *s = new int[n];
    for(int i=0;i<n;i++) cin >> s[i];
    mergeSort(s,0,n);
    for(int i=0;i<n;i++){
        cout << s[i];
        if(i!=n-1){
            cout << " ";
        }
    }
    cout << endl;
    cout << counter << endl;

    delete [] s;
    return 0;
}



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

int main(void) {
    int a[10];
    int i;
    for (i = 0; i < 10; i++) {
        cin >> a[i];
    }
    sort(a, a + 10);
    for(i = 0; i < 3; i++) {
        cout << a[9 - i] << endl;
    }
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

void solve()
{
	int n, q;
  cin >> n >> q;

  BIT<ll> bit(n * 2);

  int c, x, y;
  for(int i = 0; i < q; ++i)
  {
    cin >> c >> x >> y;
    if (c == 0)
    {
      bit.add(x, y);
    }
    else
    {
      cout << bit.sum(x, y + 1) << endl;
    }
  }
}

int main()
{
	fastio;
	solve();

	return 0;
}


Measured memory_bytes: 4412
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(N,M);
    vector<int> a(N+1,0),ans(N+1,0);
    rep(i,M){
        Cini(obj);
        a[obj] = 1;
    }
    ans[0] = 1;
    rep(i,N){
        if(a[i]==0) (ans[i+1] += ans[i])%=MOD;
        if(i>=1 and a[i-1]==0) (ans[i+1] += ans[i-1])%=MOD;
    }
    cout << ans[N] << nn;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;
constexpr lint M = 3234566667;

vector<lint> v;

void dfs(lint t){
    if(t > M) return;
    v.push_back(t);
    int d = t % 10;
    for(int i=max(0, d-1); i<=min(9, d+1); ++i){
        dfs(t*10 + i);
    }
}

int main(){
    int K;
    scanf("%d", &K);
    For(i, 1, 10) dfs(i);
    sort(v.begin(), v.end());
    printf("%lld\n", v[K-1]);
}

Measured memory_bytes: 1400
import itertools

n = int(input())
s = input().strip()
ls = []
prev = 'W'
index = 0
count = 0
while index <= len(s):
    if index == len(s):
        ls.append(count)
        break
    c = s[index]
    if c == prev:
        count += 1
    else:
        ls.append(count)
        count = 1
        prev = s[index]
    index += 1
accw = list(itertools.accumulate(ls[::2]))
acce = list(itertools.accumulate(ls[1::2][::-1]))[::-1]

res = float('inf')
for w, e in zip([0] + accw, acce + [0]):
    res = min(res, w + e)
print(res)

Measured memory_bytes: 11552
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long n,m;
	string s,t;
	cin>>n>>m>>s>>t;
	long long lcm=1LL*n*m;
	for (long long i=0;i<lcm;i+=m)
	{
		if (i%n==0 && t[i/n]!=s[i/m])
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<lcm/__gcd(n,m)<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>

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

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,x,y=0;
  scanf("%d %d %d",&a,&b,&c);
  for(x=a;x<=b;x++){
    if(c%x==0){
      y=y+1;
    }
  } printf("%d\n",y);
  return 0;
}
    
  

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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

#define MAX_N 100'000

ll dp[MAX_N+1];

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

    int N;
    cin>>N;
    map<int, vector<pair<int, int>>> edges;
    for (int n = 1; n < N; n++) {
        int a, b, c;
        cin>>a>>b>>c;
        edges[a].push_back(make_pair(b, c));
        edges[b].push_back(make_pair(a, c));
    }
    fill(begin(dp), end(dp), inf);

    int Q, K;
    cin>>Q>>K;
    dp[K] = 0;
    queue<int> q;
    q.push(K);
    while (!q.empty()) {
        int v = q.front();
        q.pop();

        for (auto to : edges[v]) {
            if (dp[to.first] != inf) continue;
            dp[to.first] = dp[v] + to.second;
            q.push(to.first);
        }
    }

    for (int q = 0; q < Q; q++) {
        int x, y;
        cin>>x>>y;
        cout<<dp[x] + dp[y]<<endl;
    }
    return 0;
}

Measured memory_bytes: 14196
#include "bits/stdc++.h"
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<3;i++)
		if(s[i]==s[i+1])
		{
			cout<<"Bad"<<endl;
			return 0;
		}
	cout<<"Good"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 1e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
const ll INF = (1ll)<<60;
const int MOD = 998244353;

int n,k; 
int a[maxN];
ll c[maxN];
unordered_map<int,int> mp1;
unordered_map<int,int> mp2;
int main()
{
	scanf("%d%d",&n,&k);
	int ans = n-k+1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    string a, b;
    cin >> a >> b;
    swap(a, b);
    int n = a.size();
    if (a == string(n, '0')) {
        cout << (b == string(n, '0') ? 0 : -1) << '\n';
        return 0;
    }

    vi cl(n), cr(n);
    forn(i, n) {
        for (int j = i; a[j] != '1'; j = (j + n - 1) % n) {++cl[i];}
        for (int j = i; a[j] != '1'; j = (j + 1) % n) {++cr[i];}
    }

    int ans = 1e9;
    forn(d, n) {
        string ta = a;
        rotate(ta.begin(), ta.begin() + d, ta.end());
        int changes = 0;
        pii p;
        vi h(n);
        forn(i, n) if (b[i] != ta[i]) uax(h[cl[i]], cr[i]), ++changes;
        int ch = 0, cost = min(n + d, n + (n - d) % n);
        ford(j, n) {
            forn(k, 2) forn(l, 2) {
                int fin1 = k ? ch : -j, fin2 = l ? d : d - n;
                int res = j + ch + (k ? j : ch) + abs(fin1 - fin2);
                uin(cost, res);
            }
            uax(ch, h[j]);
        }
        uin(ans, changes + cost);
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */

using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;
 
#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, u64 b,Num id=1) {
  if(b==0)return id;
  Num x = id;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

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

  std::string s;
  std::cin>>s;

  i64 mod=0;

  for(const auto& e:s){
    mod=(mod+e-'0')%9;
  }

  if(mod==0)std::cout<<"Yes\n";
  else std::cout<<"No\n";
  
  return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long n) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    ll ans = (n) * (n - 1) / 2;
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);

    func(N);

    return 0;
}


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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const ll _INF = 1e18+7;

int main(){
	setIO();
	string s; cin >> s;
	if (s.back() != 's') cout << s << "s\n";
	else cout << s << "es\n";
}

Measured memory_bytes: 3568
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

const int MSQ = sqrt(N) + 5;

std::vector<int> wa;
bool  y[1000005];
void sieve(){
	for(int i=2;i<=1000000;i++){
		if(y[i])continue;
		wa.pb(i);
		for(int j=i;j<=1000000;j+=i){
			y[j]=1;
		}
	}
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	
	int n,k;

	scanf("%d %d",&n,&k);
	set<int>s;
	for(int i=0,x;i<k;i++)scanf("%d",&x),s.insert(x);

	for(int i=n;;i++){
		int x = i;
		bool ok = true;
		while(x)ok&=(s.count(x%10)==0),x/=10;
		if(ok)return !printf("%d\n",i ); 
	}
}		



Measured memory_bytes: 256
import numpy as np
import itertools
n,m = map(int, input().split())
sw = [[int(i) - 1 for i in input().split()] for _ in range(m)]
p = np.array([int(i) for i in input().split()])
x = np.full_like(p, -1)

s_l = itertools.product(np.array([True,False]), repeat = n)
ans = 0
for si in s_l:
    si = np.array(si)
    for mi in range(m):
        x[mi] = si[sw[mi][1:]].sum() % 2
    if np.all(p == x):
        ans += 1
print(ans)

Measured memory_bytes: 27288
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int MOD=1000000007;
const int nmax=501234;

int n,a[17][17],bt[17],flg[1<<17];
ll dp[1<<17],dp2[1<<17];
queue<int> q2;

int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
    {
        bt[i]=1<<i-1;
        for(int j=1; j<=n; ++j)
            scanf("%d",&a[i][j]);
    }
    bt[n+1]=1<<n;
    for(int i=2,l=0,r=0; i<=n; ++i)
    {
        for(int j=1,tmp=0; j<i; ++j)
        {
            tmp=bt[i]|bt[j];
            dp[tmp]=a[j][i];
            flg[tmp]=1;
            q2.push(tmp);
        }
        while(!q2.empty())
        {
            int tmp=q2.front();
            q2.pop();
            for(int j=1,tmp2=0; j<i; ++j)
            {
                tmp2=tmp|bt[j];
                if(tmp2!=tmp && flg[tmp2]==0)
                {
                    dp[tmp2]=dp[tmp]+a[j][i];
                    flg[tmp2]=1;
                    q2.push(tmp2);
                }
            }
        }
    }
    for(int i=2; i<=n; ++i)
        for(int j=bt[i]+1; j<bt[i+1]; ++j)
            dp[j]+=dp[j^bt[i]];
    for(int i=2; i<=n; ++i)
        for(int i2=bt[i]+1,j2=0; i2<bt[i+1]; ++i2)
        {
            int s=i2;
        do{
            ll tmp3=dp[s]+dp2[s^i2];
            if(dp2[i2]<tmp3)
                dp2[i2]=tmp3;
            s=i2&(s-1);
        }while(s>=bt[i]);
        }
    printf("%lld",dp2[(1<<n)-1]);
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<long long>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define couta(x) for(auto iter : x) p(iter)
#define yes(x) x ? cout << "Yes" << endl : cout << "No" << endl;
using namespace std;
typedef long long lint;
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef vector<long long> VLL;
typedef vector<vector<int> > VVI;
typedef vector<vector<long long> > VVLL;
typedef vector<vector<bool> > VVB;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
using UnweightedGraph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
const long long INF = 2000000000ll;
const long double PI = acosl(-1);
const long double EPS = 1e-7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



long long power(long long a, long long b) {return b?power(a*a,b/2)*(b%2?a:1):1;}
long long perm(long long N, long long K){
    long long x=1;
    for(long long i=1;i<=K;i++)
    {
        x=x*(N-i+1);
    }
    return x;
}
long long factorial(long long N) {return perm(N,N);}
long long comb(long long N,long long K) {return factorial(N)/factorial(K)/factorial(N-K);}
long long hcomb(long long N, long long K) {return comb(N+K-1, N-1);}

int dtoi(double d) {return round(d);}

bool isprime(int n) {
    if (n < 2) return false;
    for (int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return false;
    }
    return true;
}

long long mystoll(string s){
    long long ans = 0;
    for (int i = (int) s.length()-1; i >= 0; i--){
        ans += (s[i]-'0') * power(10,s.length()-1-i);
    }
    return ans;
}

template<class T>
long long SUM(T a) {
    long long sum = 0;
    for(auto itr : a) sum += itr;
    return sum;
}

void solve(int64_t R) {
    p((LD)R*PI*2);
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int64_t R;
    cin >> R;
    solve(R);
    return 0;
}


Measured memory_bytes: 3872
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
	priority_queue<int> pq;
	for(int i=0,x;i<10;i++)
		cin>>x,pq.push(x);
	for(int i=0;i<3;i++,pq.pop())
		cout<<pq.top()<<endl;
	return 0;
}

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

using namespace std;

int main(){ string S; cin >> S;
    int a = 0;  int b = 0; int c = 0;
    for(int i = 0; i < (int) S.size(); i++){
      if( S[i] == 'a'){ a++;} if( S[i] == 'b'){ b++;} if( S[i] == 'c'){ c++;}}
           
           int M = max( a, max( b,c)); int m = min( a, min( b, c));
           
           if( M - m <= 1){ cout << "YES" << endl; } else{ cout << "NO" << endl;}
           return 0;}

Measured memory_bytes: 512
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans=0
k=int(input())
for i in range(1,k+1):
  for j in range(1,k+1):
    for l in range(1,k+1):
      ans+=gcd(i,j,l)
print(ans)

Measured memory_bytes: 74728
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		long[][] a=new long[n][];
		long ans=0;
		for(int i=0;i<n;i++){a[i]=sc.La;}
		Array.Sort(a,ca);
		for(int i=0;i<n;i++){
			ans+=i%2==0?a[i][0]:-a[i][1];
		}
		Console.WriteLine("{0}",ans);
	}
	static int ca(long[] a,long[] b){
		if(a[0]+a[1]<b[0]+b[1]){return 1;}
		else if(a[0]+a[1]>b[0]+b[1]){return -1;}
		else{return 0;}
	}
}

class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
}

Measured memory_bytes: 22336
#include <stdio.h>
#include<math.h>

int main()
{
	long N,a,walk,walkmini,j;
	scanf("%ld", &N);
	walkmini = N-1;
		for (long i = 1; i <= sqrt(N); i++)
		{
			a = N % i;
			if (a == 0)
			{
				j = N / i;
				walk = (i - 1) + (j - 1);
				if (walkmini > walk)
				{
					walkmini = walk;
				}
			}
		}
		printf("%ld", walkmini);
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int pality = n%2;
    deque<int> dq;
    rep(i,n){
        int ai;
        cin >>ai;
        if(i%2!=pality)
            dq.push_front(ai);
        else
            dq.push_back(ai);
    }
    for(auto v : dq) cout << v <<" ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3072
import java.util.LinkedList;
import java.util.Scanner;
//import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int i = 0; i < totalVertex; i++) {
			tmp = adjList.poll();
			for(int j = 0; j < totalVertex; j++) {
				if(tmp.contains(j)) {
					adjMatrix[i][j] = 1;
				} else {
					adjMatrix[i][j] = 0;
				}
			}
		}
		for(int i = 0; i < totalVertex; i++) {
			for(int j = 0; j < totalVertex; j++) {
				System.out.print(adjMatrix[i][j]);
				if(j < totalVertex - 1) {
					System.out.print(" ");
				}
			}
			System.out.println();
		}
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


Measured memory_bytes: 34732
n=int(input())
S=[int(input().replace(' ',''),2) for _ in range(n)]
C=[list(map(int,input().split())) for _ in range(n)]
A=[]
for i in range(1,2**10):
    ans=0
    for j in range(n):
        cnt=bin(S[j]&i).count('1')
        ans+=C[j][cnt]
    A.append(ans)
print(max(A))       

Measured memory_bytes: 3188
import math
import bisect
n, h = map(int, input().split())
x = []
y = []
for i in range(n):
	a = list(map(int, input().split()))
	x.append(a[0])
	y.append(a[1])
c = sum(y)
d = max(x)
y.sort()
e = bisect.bisect_left(y,d)
f = sum(y[e:])
g = sorted(y[e:], reverse= True)
#print (g)
y.sort(reverse=True)
cnt = 0
if h <= f:
	for i in g:
		h -= i
		cnt += 1
		if h <= 0:
			print (cnt)
			exit()
else:
	h -= f
	cnt += len(g)
	cnt += math.ceil(h/d)
	print (cnt)

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

int main(){
  int n,m;
  string s;
  cin>>n>>m>>s;
  vector<int> vec;
  reverse(s.begin(),s.end());
  int now=0;
  while(now<n){
    for(int i=min(m,n-now);i>0;i--){
      if(s[now+i]=='0'){
        vec.push_back(i);
        now+=i;
        break;
      }
      if(i==1){
        cout<<-1<<endl;
        return 0;
      }
    }
  }
  reverse(vec.begin(),vec.end());
  for(int i=0;i<vec.size();i++){
    cout<<vec.at(i)<<" ";
  }
  cout<<endl;
  return 0;
}

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

using namespace std;

vector<int> vv[11111];
int n;
int a[11111];
int ans = 0;

void dfs(int x, int ss){
    if(x == n) {
        if(ss % 2 == 0){
            ans ++;
        }
        return;
    }
    dfs(x + 1, ss * vv[x][0]);
    dfs(x + 1, ss * vv[x][1]);
    dfs(x + 1, ss * vv[x][2]);
}

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
        vv[i].push_back(a[i] - 1);
        vv[i].push_back(a[i]);
        vv[i].push_back(a[i] + 1);
    }
    dfs(0, 1);
    printf("%d\n", ans);
}

Measured memory_bytes: 512
n=gets.chomp.to_i
array = gets.chomp.split.map(&:to_i)
newarray = array.sort
lower = newarray[n / 2 - 1]
higher = newarray[n / 2 ]
k = 0
n.times do
  if array[k] <= lower
    puts higher
  else
    puts lower
  end
  k += 1
end


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

int main() {
    int D;
    cin >> D;
    vector<int> c(26);
    for (int i = 0; i < 26; i++)
        cin >> c[i];
    vector<vector<int>> s(D, vector<int>(26));
    for (int i = 0; i < D; i++)
        for (int j = 0; j < 26; j++)
            cin >> s[i][j];
    
    vector<int> t(D);
    vector<int> last(26, 0);
    for (int i = 1; i <= D; i++) {
        int mx = -1000000000, ti = 0;
        for (int k = 0; k < 26; k++) {
            int sd = s[i-1][k];
            for (int l = 0; l < 26; l++) {
                if (l == k)
                    continue;
                sd -= c[l] * (i - last[l]);
            }
            if (sd > mx) {
                mx = sd;
                ti = k;
            }
        }
        last[ti] = i;
        t[i-1] = ti;
    }
    
    int score = 0;
    vector<int> last2(26, 0);
    for (int i = 1; i <= D; i++) {
        score += s[i-1][t[i-1]];
        last2[t[i-1]] = i;
        for (int j = 0; j < 26; j++)
            score -= c[j] * (i - last2[j]);
    }
    
    int m = 100000;
    mt19937 mt((int)time(0));
    for (int i = 0; i < m; i++) {
        int d = mt() % D + 1, q = mt() % 26 + 1;
        int p = t[d-1] + 1;
        int diff = 0;
        diff -= s[d-1][p-1];
        diff += s[d-1][q-1];
        int lp = 0, rp = D+1, lq = 0, rq = D+1;
        for (int i = 1; i <= D; i++) {
            if (i < d) {
                if (t[i-1] == p)
                    lp = i;
                if (t[i-1] == q)
                    lq = i;
            }
            if (d < i) {
                if (rp == D+1 && t[i-1] + 1 == p)
                    rp = i;
                if (rq == D+1 && t[i-1] + 1 == q)
                    rq = i;
            }
        }
        int cp = c[p-1] * (d-lp) * (rp-d);
        int cq = c[q-1] * (d-lq) * (rq-d);
        diff -= cp;
        diff += cq;
        if (diff > 0) {
            t[d-1] = q - 1;
            score += diff;
        }
    }
    
    for (int i = 0; i < D; i++)
        cout << t[i]+1 << endl;
    
    //cout << "score:" << score << endl;
    
    return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(a,n) rep(i,0,n){ cout<<(i ? " ":"")<<a[i]; }cout<<endl;
const int mod = 1e9+7;
const int size=1e5;
const int INF=1e9;
vector<vector<pair<int,int>>> g(10);
int d[10];
void dijkstra(int a){//O(E+NlogN)
    priority_queue<pair<int,int>> pq;
	rep(i,0,10){
		d[i]=INF;
		pq.push({-d[i],i});
	}
	d[a]=0;pq.push({0,a});
	int v;int temp;
	while(!pq.empty()){
		v=pq.top().second;
		pq.pop();
        int u;
		for(int i=0;i<g[v].size();i++){
            u=g[v][i].first;
			temp=d[v]+g[v][i].second;
			if(d[u]>temp){
				d[u]=temp;
				pq.push({-d[u],u});
			}
		}
	}return;
}
int main(){
	int H,W;cin>>H>>W;
	int c;
	rep(i,0,10)rep(j,0,10){
		cin>>c;
		if(i!=j) g[j].push_back({i,c});
	}dijkstra(1);
	int a;long sum=0;
	rep(i,0,H)rep(j,0,W){
		cin>>a;
		if(a==-1) continue;
		sum+=d[a];
	}cout<<sum<<endl;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
A = []
for i in range(h):
    A.append(list(map(int,input().split())))
visit = [[0]*w for i in range(h)]
d = [(1,0),(-1,0),(0,1),(0,-1)]
cnt=0
yx = []
for i in range(h):
    for j in range(w):
        visit[i][j]=1
        if A[i][j] %2==1:
            for dy,dx in d:
                if 0<=i+dy<h and 0<=j+dx<w:
                    if visit[i+dy][j+dx] ==0:
                        A[i][j] -=1
                        A[i+dy][j+dx] +=1
                        cnt+=1
                        yx.append((i+1,j+1,i+dy+1,j+dx+1))
                        break
print(cnt)
for i in range(cnt):
    print(*yx[i])


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

int main(){
  long long a, b, k, n;
  cin >> k;
  n = 50;
  a = k / n;
  vector<long long> c(n, n - 1 + a);
  b = k % n;
  for(long long i = 0; i < b; i++){
    k = n - 1;
    sort(c.begin(), c.end());
    while(c[k] > 1e16 + 500)
      k--;
    for(long long j = 0; j < n; j++){
      if(j == k)
        c[j] += n;
      else
        c[j]--;
    }
  }
  cout << n << endl;
  for(int i = 0; i < n; i++)
    cout << c[i] << ' ';
  cout << endl;
}


Measured memory_bytes: 256