akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(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()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

using ld=long double;

void solve(){

	static const ld pi = 3.141592653589793;

	ld a,b,h,m;
	cin>>a>>b>>h>>m;
	ld aa=h*pi/180.0L*30.0L + 30.0L*m/60.0L*pi/180.0L;
	ld bb=m*pi/180.0L*6.0L;
	if(aa<bb) swap(aa,bb);
	ld th=aa-bb;
	if(th>pi) th = pi*2.0L-th;

	cout<<fixed<<setprecision(12)<<sqrt(a*a+b*b-a*b*2.0L*cos(th))<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

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

using namespace std;

typedef long long int lli;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forr(i,m,n) for(int i=m;i<n;i++)
#define read(n) lli n;cin>>n;
#define testcase int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl "\n"
#define print(v) forr(i,0,v.size())cout<<v[i]<<" ";cout<<endl;
#define MOD 998244353


int main() {
    fastio
    read(n); vector<int> v(n), cost(n); int ans=0;
    forr(i,0,n) cin>>v[i];
    if(n<=2){
        ans+=abs(v[0]-v[1]);
        cout<<ans<<endl;
    }
    else{
        cost[n-1]=0;
        cost[n-2] = abs(v[n-2]-v[n-1]);
        for(int i=n-3;i>=0;i--){
            int tt=min(abs(v[i]-v[i+2])+cost[i+2], abs(v[i]-v[i+1])+cost[i+1]);
            cost[i]=tt;
        }
        // print(cost);
        cout<<cost[0]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
    int N = 0;
    int A[210];
    cin >> N;
    for (int i = 0; i< N; ++i) cin>>A[i];

    int res = 0;

    while (true){
        bool exist_odd = false;
        for (int i = 0; i < N; ++i){
            if (A[i] % 2 != 0) exist_odd = true;
        }

        if (exist_odd) break;

        for (int i = 0; i < N; ++i){
            A[i] /= 2;
        }
        ++res;
    }

    cout << res<< endl;
}

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

int main() {
  int N, a, b, c;
  cin >> N;
  
  a = N / 100;
  b = N / 10 - 10 * a;
  c = N - (100 * a + 10 * b);
  
  if(N == 100 * c + 10 * b + a){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 384
#include<cstdio>

int main(){
    unsigned N, K, R, S, P;
    scanf("%u %u\n%u %u %u\n", &N, &K, &R, &S, &P);
    char T[N+1];
    scanf("%s", T);
    bool win[N];
    unsigned answer = 0;
    for (size_t i = 0; i < K; i++){
        win[i] = true;
        if(T[i] == 'r') answer += P;
        else if(T[i] == 's') answer += R;
        else answer += S;
    }
    for (size_t i = K; i < N; i++){
        win[i] = (T[i] != T[i - K]) || !win[i - K];
        if(win[i]){
            if(T[i] == 'r') answer += P;
            else if(T[i] == 's') answer += R;
            else answer += S;
        }
    }
    printf("%u\n", answer);
	return 0;
}

Measured memory_bytes: 384
//
//  main.cpp
//  ABC093
//
//  Created by hiroaki on 2019/03/18.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

//~~A~~
int main(){
    string s;
    cin >> s;
    if(s=="abc"||s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba"){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
"use strict"
const input = require('fs').readFileSync('/dev/stdin','utf8');
const x = parseInt(input);

let ans = '';
for (let i = 1; i <= x; i++) {
	if (i % 3 === 0 || i % 10 === 3 || include3(i)) {
		ans += ' ' + i;
	}
}
console.log(ans);

function include3(x) {
	while (x > 0) {
		x = parseInt(x / 10);
		if (x % 10 === 3) return true;
	}
	return false;
}


Measured memory_bytes: 18108
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

template <class Integer>
auto boost_irange(Integer last) { return boost::irange(static_cast<Integer>(0), last); }
template <class Integer>
auto boost_irange(Integer first, Integer last) { return boost::irange(first, last); }

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }
};

int main()
{
    input in;
    output out;

    int N = in.read<int>();
    std::vector<int> a(N), b;
    in.read(a.begin(), N);
    b = a;
    std::sort(a.begin(), a.end());

    int c = 0;
    for (int i : boost_irange(N)) {
        if (a[i] != b[i]) ++c;
    }

    out << ((c < 3) ? "YES" : "NO");

    return 0;
}


Measured memory_bytes: 256
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)


def main():
    N, K, Q = map(int, input().split())
    L_2 = [int(input()) for _ in range(Q)]

    N_points = [0 for _ in range(N)]

    for i in L_2:
        N_points[i - 1] += 1

    for i in N_points:
        if i - (Q - K) > 0:
            print("Yes")
        else:
            print("No")

            
    
if __name__ == "__main__":
    main()


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

int main(void) {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;

    int n = s.length();
    int i = 0, j = n - 1;
    int ans = 0;
    while (i < j) {
        if (s[i] == s[j]) {
            ++ i;
            -- j;
        } else {
            if (s[i] == 'x') ++ i;
            else if (s[j] == 'x') -- j;
            else break;
            ++ ans;
        }
    }
    if (i < j) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int main()
{
	int n, num = 0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		scanf("%d", a + i);
	}
	for(int i = 1; i < n; i++){
		if(a[i] - 1 == a[i + 1]){
			swap(a[i], a[i + 1]);
		}else if(a[i] - 2 >= a[i + 1]){
			num = 1;
		}
	}
	if(num == 1){
		printf("No\n");
	}else
		printf("Yes\n");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
vector<vector<int>> adj;
pair<ll,ll> dfs(int node,int pere){
  ll black = 1,white = 1;
  for(int i : adj[node]){
    if(i == pere) continue;
    ll black_i,white_i;
    tie(black_i,white_i) = dfs(i,node);
    black = (black*white_i)%mod;
    white = (white*(black_i+white_i))%mod;
  }
  return {black,white};
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,u,v;
  cin >> n;
  adj.resize(n+1);
  for(int i = 1; i < n; ++i){
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  auto pr = dfs(1,-1);
  cout << (pr.first+pr.second)%mod;
  return 0;
}

Measured memory_bytes: 15580
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

vector<pair<int, int>> G[100001];
int dist[100001];
bool used[100001];

bool dfs(int x, int d) {
    if (used[x]) return d == dist[x];

    dist[x] = d;
    used[x] = true;
    for (auto p : G[x]) {
        if (!dfs(p.first, d + p.second))
            return false;
    }
    return true;
}

int main() {
    int N, M, L, R, D;
    cin >> N >> M;
    REP(i, M) {
        cin >> L >> R >> D;
        G[L].push_back({R, D});
        G[R].push_back({L, -D});
    }

    FOR(i, 1, N + 1) {
        if (!used[i] && !dfs(i, 0)) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 11136
N=int(input())
t=[0]*N
r=set(range(N))
for _ in[0]*N:
 x,y,z=list(map(int,input().split()))
 t[x]=[y,z,0,0,(y!=-1)+(z!=-1),0,0]
 r-={y,z}
def f(i,p,s,d):
 if i<0:return-1
 l,r=t[i][:2]
 t[i][2:]=[p,s,t[i][4],d,max(f(l,i,r,d+1),f(r,i,l,d+1))+1]
 return t[i][-1]
f(r.pop(),-1,-1,0)
for i in range(N):
 print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(i,*t[i][2:],'root'if not t[i][5]else'internal node'if t[i][4]else'leaf'))


Measured memory_bytes: 5608
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

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

int ans = -1;

void solve(vector<int> v, vector<int> c, int cost, int i, int n)
{
    if(i == n) { ans = max(ans, cost); return; }
    
    solve(v, c, cost, i+1, n);
    solve(v, c, cost + v[i] - c[i], i+1, n);
}

int main() 
{
    int n; cin>>n;
    vector<int> v(n), c(n);

    rep(i,n) { cin >> v[i]; } 
    rep(i,n) { cin >> c[i]; }

    solve(v,c,0,0,n);
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define N 100010
vector<pair<int,int> > p[N];
int vis[N];
void dfs(int x,int y)
{
    int i,j,k;
    pair<int,int> d;
    k=p[x].size();
    for(i=0;i<k;i++)
    {
        d=p[x][i];
        if(vis[d.first]!=-1)
            continue;
        j=(y+d.second)%2;
        if(j)
            vis[d.first]=1;
        else
            vis[d.first]=0;
        dfs(d.first,j);
    }
}
int main()
{
    int i,j,k,n,u,v,w;
    scanf("%d",&n);
    for(i=1;i<n;i++)
    {
        scanf("%d%d%d",&u,&v,&w);
        p[u].push_back(pair<int,int>{v,w});
        p[v].push_back(pair<int,int>{u,w});
    }
    memset(vis,-1,sizeof(vis));
    vis[1]=0;
    dfs(1,0);
    for(i=1;i<=n;i++)
        printf("%d\n",vis[i]);
    return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  ll d=abs(a-b),e=abs(b-c),f=abs(c-a);
  ll ans=d+e+f-max({d,e,f});
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

const int INF = 100000;

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> ab;
    vector<vector<int>> to(n, vector<int>(n, INF));
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        ab.push_back(make_pair(a, b));
        to[a][b] = 1;
        to[b][a] = 1;
    }
    rep(i, n) to[i][i] = 0;
    
    int ans = 0;
    rep(e, m){
        vector<vector<int>> d = to;
        d[ab[e].first][ab[e].second] = INF;
        d[ab[e].second][ab[e].first] = INF;
        rep(k, n)rep(i, n)rep(j, n){
            d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
        bool connect = true;
        rep(i, n){
            for(int j = i + 1; j < n; j++){
                if(d[i][j] == INF) connect = false;
                if(!connect) break;
            }
            if(!connect) break;
        }
        if(!connect) ans++;
    }

    cout << ans << endl;    
}

Measured memory_bytes: 256
//  Created by conan1024hao on 2019/11/24.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //------------------------------
    int n;
    cin>>n;
    
    string s;
    cin>>s;
    string s1,s2;
    int m=s.length();
    for(int i=0;i<m;i++){
        if(s[i]+n>'Z')
            s[i]+=n-26;
        else
            s[i]+=n;
            
    }
    cout<<s<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
N , M = (map(int , input().split()))
X = list(map(int , input().split()))
sorted_x = sorted(X)
total_kukann = 0
kukann_kyori = []
a = N-1
for i in range(len(sorted_x)-1):
    kukann_kyori.append(sorted_x[i + 1] - sorted_x[i])
    total_kukann += sorted_x[i + 1] - sorted_x[i]
kukann_kyori.sort()
if N >= M:
    total_kukann = 0
else:
    for j in range(1,a+1):
        total_kukann -= kukann_kyori[-j]
print(total_kukann)

Measured memory_bytes: 13960
H, W = map(int, input().split())
C = [list(input()) for _ in range(H)]

# bfs 
C[0][0] = 0
pre_list = [(0,0)]
count = 0
 
while C[H-1][W-1] == '.' and len(pre_list) > 0:
    count += 1
    next_list = []
    for y,x in pre_list:
        for i,j in ((1,0),(0,-1),(0,1),(-1,0)):
            if y+i < 0 or x+j < 0 or y+i >= H or x+j >= W:
                continue
            if C[y+i][x+j] == '.':
                C[y+i][x+j] = count
                next_list.append((y+i,x+j))
    pre_list = next_list

if C[H-1][W-1] == '.':
    print(-1)
else:
    black = 0
    for h in C:
        for v in h:
            if v == "#":
                black += 1
    print(H*W-black-count-1)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> h(n,0);
  for(int i=0;i<n;i++) cin>>h[i];

  int ma=0;
  int ans=0;
  for(int i=0;i<n;i++){
    if(ma<=h[i]) ans++;
    ma=max(ma,h[i]);
  }
  cout<<ans<<endl;

  return 0;
}


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

using namespace std;
using LL = long long;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

    int k;
    cin >> k;
    vector<LL> a(k);
    REP(i, k) cin >> a[i];

    LL ans1 = 2, ans2 = 2;
    for(int i = k-1; i >= 0 ; i--){
        if(ans1 % a[i] != 0 && ans1 + a[i] - (ans1 % a[i]) > ans2){
            cout << -1 << endl;
            return 0;
        }
        ans1 = ceil(1.0 * ans1 / a[i]) * a[i];
        ans2 = floor(1.0 * ans2 / a[i]) * a[i] + a[i] - 1;
    }
    
    cout << ans1 << " " << ans2 << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

const int N = 51;

bool can(ll ans, const vector<int>& a, const vector<int> &b) {
  vector<vector<int>> g(N, vector<int>(N, 0));
  for (int i = 0; i < N; i++) {
    g[i][i] = 1;
    for (int j = 1; j < N; j++) {
      if (ans & (1LL << j)) {
        g[i][i % j] = 1;
      }
    }
  }

  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        g[i][j] |= g[i][k] & g[k][j];
      }
    }
  }

  for (int i = 0; i < (int)a.size(); i++) {
    if (!g[a[i]][b[i]]) {
      return false;
    }
  }
  return true;
}


int main() {
#ifdef LOCAL
  freopen("c.in", "r", stdin);
  freopen("c.out", "w", stdout);
#endif

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

  ll ans = (1LL << N) - 1;

  if (!can(ans, a, b)) {
    printf("-1\n");
    return 0;
  }

  for (int i = N - 1; i >= 0; i--) {
    if (can(ans - (1LL << i), a, b)) {
      ans -= 1LL << i;
    }
  }

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

  return 0;
}


Measured memory_bytes: 256
console.log((args=>{
  const c = args.trim().split`\n`.map(r=>r.split` `.map(v=>v|0));
  for ( let i = 1; i < 3; i++ ) {
    for ( let j = 1; j < 3; j++ ) {
      if ( c[i][j] - c[i][j-1] !== c[i-1][j] - c[i-1][j-1] ) return 'No';
      if ( c[j][i] - c[j][i-1] !== c[j-1][i] - c[j-1][i-1] ) return 'No';
    }
  }
  return 'Yes';
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 29608
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		List<String> nList = new ArrayList<String>();
		List<String> mList = new ArrayList<String>();

		final int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			nList.add(sc.next());
		}
		final int m = sc.nextInt();
		for (int j = 0; j < m; j++) {
			mList.add(sc.next());
		}

		HashMap<String, Integer> resultList = new HashMap<String, Integer>();
		for (final String nItem : nList) {
			if (resultList.containsKey(nItem)) {
				final int point = resultList.get(nItem);
				resultList.put(nItem, point + 1);
			} else {
				resultList.put(nItem, 1);
			}
		}
		resultList.put("99999999999", 0);
		for (final String mItem : mList) {
			if (resultList.containsKey(mItem)) {
				final int point = resultList.get(mItem);
				resultList.put(mItem, point - 1);
			} else {
				resultList.put(mItem, -1);
			}
		}

		int result = resultList.get("99999999999");
		for (final String key : resultList.keySet()) {
			final int resultPoint = resultList.get(key);
			if (result < resultPoint) {
				result = resultPoint;
			}
		}
		System.out.print(result);

	}

}


Measured memory_bytes: 22100
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    string a;
    cin >> a;
    
    
    int i=0;
    int cnt = 0;
    for (i=0; i<a.size(); i++){
        if(a[i] == '1') cnt++;
    }
    
    cout << cnt;
    

    return 0;
    
}


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

int main(){
    int a,b,c,d;
    cin >>a >> b >> c >> d;
    if((a+b)>(c+d)) cout << "Left" << endl;
    else if((a+b)==(c+d)) cout << "Balanced" << endl;
    else cout << "Right" << endl;
}


Measured memory_bytes: 256
N,M = list(map(int,input().split()))
war = [list(map(int,input().split())) for _ in range(M)]


war = sorted(war,key=lambda x:x[1])
a = 0
ans = 0
for i in range(M):
    if a <= war[i][0]:
        a= war[i][1]
        ans +=1
    else:
        continue
print(ans)

Measured memory_bytes: 29848
def resolve():
    N = int(input())
    a_list = list(map(int,input().split()))

    count = 1
    ans = 0
 
    for i in range(N):
        if a_list[i] != count:
            ans += 1
        else:
            count += 1
 
    if ans == N:
        print(-1)
    else:
        print(ans)
    
 
if __name__ == "__main__":
    resolve()

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

public class Main {

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

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      Graph graph = new Graph(n);
      int[] ajacent;
      String[] vInfo;
      int id,degree;

      for(int i=0,v=0; i<n; i++) {
        vInfo  = br.readLine().split(" ");
        id     = Integer.parseInt(vInfo[0]);
        degree = Integer.parseInt(vInfo[1]);
        ajacent = new int[degree];
        for(int j=0; j<degree; j++) {
          ajacent[j] = graph.convIdToIndex( Integer.parseInt(vInfo[j+2]) );
        }
        graph.setVertex(id, ajacent);
      }

      graph.vertexSearch();

      graph.dispReport();
    }
    catch (IOException e) {
      System.err.println(e);
    }
  }

  class Graph {

    Vertex[] vertices;
    int time;

    public Graph(int size ) {
      vertices  = new Vertex[size];
      time = 0;
    }

    public void setVertex(int id) {
      vertices[convIdToIndex(id)] = new Vertex(id);
    }
    public void setVertex(int id, int[] ajacent) {
      setVertex(id);
      setAjacent(id, ajacent);
    }
    public void setAjacent(int id, int[] ajacent) {
      vertices[convIdToIndex(id)].ajacent = ajacent;
    }
    public void vertexSearch() {
      for (Vertex v : vertices) {
        if(v.state == Vertex.WHITE)
          depthFirstSearch(v.index);
      }
    }
    public void dispReport() {
      StringBuilder buf = new StringBuilder();

      for (Vertex v : vertices) {
          buf.append(v.id).append(" ")
             .append(v.findTime).append(" ")
             .append(v.doneTime).append("\n");
      }

      System.out.print(buf);
    }
    public int convIdToIndex(int id) {
      return id-1;
    }

    private void depthFirstSearch(int index) {
      vertices[index].state = Vertex.GRAY;
      vertices[index].findTime = ++time;
      
      for(int ajcIndex: vertices[index].ajacent) {
        if(vertices[ajcIndex].state == Vertex.WHITE)
          depthFirstSearch(ajcIndex);
      }
      vertices[index].state = Vertex.BLACK;
      vertices[index].doneTime = ++time;
    }

    class Vertex {

      static final int WHITE = 0;
      static final int GRAY  = 1;
      static final int BLACK = 2;
      int id;
      int index;
      int state;
      int[] ajacent;
      int findTime;
      int doneTime;

      public Vertex(int id) {
        this.id = id;
        index = id-1;
        state = WHITE;
      }
    }
  }
}


Measured memory_bytes: 24432
program main
      implicit none
      integer(4) :: n, m, i
      integer(4) :: a, b, c, d 

      read *, a, b, c, d

      i = 1
      do
        if ( mod(i,2) == 0 ) then
          a = a - d
          if ( a <= 0 ) then
            print *, 'No'
            exit
          end if
        else
          c = c - b
          if ( c <= 0 ) then
            print *, 'Yes'
            exit
          end if
        end if
        i = i + 1
      end do

end program main


Measured memory_bytes: 2852
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <complex>
#include <iomanip>
#include <queue>
#include <bitset>
#include <numeric>
using namespace std;

int main() {
  long long taka, aoki, loop = 0;
  cin >> taka >> aoki >> loop;
  
  
  if(taka >= loop) {
        taka -=loop;
    } else {
        loop -=taka;
    	taka = 0;
        aoki -= loop;
    }

  if(aoki < 0)aoki = 0; 
   
  cout << taka << " " << aoki << endl;
   return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using data = pair<string, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<data> d(n);
    map<data, int> mp;
    for (int i = 0; i < n; i++)
    {
        string s;
        int p;
        cin >> s >> p;
        d[i] = make_pair(s, -p);
        mp[d[i]]= i+1;
    }
    sort(ALL(d));
    for (int i = 0; i < n; i++)
    {
        cout << mp[d[i]] << endl;
    }
}

Measured memory_bytes: 256
#include "atcoder/segtree"
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using namespace atcoder;
int op(int a, int b) { return max(a, b); };
int e() { return 0; }

int main() {
  int n, k;
  cin >> n >> k;
  segtree<int, op, e> tree(3000005);
  for(int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    tree.set(tmp, tree.prod(max(tmp - k, 0), min(tmp + k + 1, 3000000)) + 1);
  }
  cout << tree.all_prod() << endl;
  return 0;
}

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


obj = input().strip().split(' ')
N, K, Q = map(int, obj)

win_count = [0] * N
for _ in range(Q):
    A_i = int(input().strip())
    win_count[A_i - 1] += 1

is_ok = [True if Q - cnt < K else False for cnt in win_count]

for i in range(N):
    if is_ok[i]:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 5484
#include<bits/stdc++.h>
using namespace std;
int x;
char a[16],b[16]={'C','O','D','E','F','E','S','T','I','V','A','L','2','0','1','6'};
int main(){
	cin>>a;
	for(int i=0;i<16;i++){
		if(a[i]!=b[i]){
			x++;
		}
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>

using namespace std;


void Solution()
{
    float n;
    
    while (cin>>n)
    {
        if(n <= 48) cout<<"light fly";
        else if(n <= 51) cout<<"fly";
        else if(n <= 54) cout<<"bantam";
        else if(n <= 57) cout<<"feather";
        else if(n <= 60) cout<<"light";
        else if(n <= 64) cout<<"light welter";
        else if(n <= 69) cout<<"welter";
        else if(n <= 75) cout<<"light middle";
        else if(n <= 81) cout<<"middle";
        else if(n <= 91) cout<<"light heavy";
        else cout<<"heavy";
        
        cout<<endl;
    }
}

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

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

using namespace std;

const int mod = (int)1e9 + 7;

int n;
bool a[30][30];
int dp[(1 << 21)];
int last[(1 << 21)];
int j;

vector<int>v[22];
vector<int>bits[(1 << 21)];

int main()
{
  cin >> n;
  for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
      cin >> a[i][j];
  for(int i = 0; i < (1 << n);i++) {
    for(int j = 0; j < n; j++) {
      if(i & (1 << j)) {
        bits[i].push_back(j);
      }
    }
    v[bits[i].size()].push_back(i);
  }
  last[0] = 1;
  for(int i = 0; i < n; i++) {
    for(auto lol : v[i + 1]) {
      for(int j = 0; j <= i; j++){
        int ion = bits[lol][j];
        if(a[i][ion])
          dp[lol] = (dp[lol] + last[lol - (1 << ion)]) % mod;
      }
      last[lol] = dp[lol];
    }
  }
  cout << dp[(1 << n) - 1] << "\n";
  return 0;
}


Measured memory_bytes: 225720
import sys
N,M=map(int,input().split())
p=[]
for i in range(M):
    arr=list(map(int,input().split()))
    p.append(arr)

for i in range(1000):
    d=[i%10]
    nx=int(i/10)
    while nx:
        d.append(nx%10)
        nx=int(nx/10)
    if len(d) != N:
        continue
    else:
        d.reverse()
        flag=1
        for j in range(M):
            if d[p[j][0]-1] !=  p[j][1]:
                flag=0
        if flag == 1:
            print(i)
            sys.exit()
print(-1)
            

Measured memory_bytes: 9224
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d%d",&n,&m);
	if(m%n==0)
	{
		printf("%d",n+m);
	}
	else
	{
		printf("%d",m-n);
	}
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dish = [a,b,c,d,e]
ans = 0
maxtime = []
remain = []
for i in dish:
    maxtime.append((i+9) // 10 * 10)
for i in range(5):
    remain.append(maxtime[i] - dish[i])
ans = sum(maxtime) - max(remain)
print(ans)

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

AB = list(input().rstrip().split())
A = int(AB[0])
# print(AB)
B1, B0 = map(int, AB[1].split("."))
# B1 = int(B1s); B0 = int(B0s)
ans = A*B1 + A*B0//100
print(ans)

Measured memory_bytes: 61708
#import<atcoder/all>
#define f(i)std::cout<<i<<' ';
int n,f;main(){auto&c=std::cin>>n>>f;atcoder::scc_graph g(n);for(;c>>n>>f;)g.add_edge(n,f);f(size(g.scc()))for(auto i:g.scc()){f(size(i))for(int j:i)f(j)}}

Measured memory_bytes: 40076
N, M = map(int, input().split())
c = [list(map(int, input().split())) for i in range(M)]
c.sort()
r = 0
bridge = N
for i in range(M):
  a, b = c[M-1-i]
  if(a > bridge or bridge >= b):
    r += 1
    bridge = a
print(r)

Measured memory_bytes: 27888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll A[N];
  ll inf = 1000000000000000000;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = 1;
  for (int i = 0; i < N; i++) {
    if (ans > inf / A[i]) {
      cout << -1 << endl;
      return 0;
    } else {
      ans *= A[i];
    }
  }
  if (ans <= inf) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 4420
def main() :
    n = int(input())
    cards = [Card(*input().split()) for i in range(n)]
    stableCards = sorted(cards[:], key=lambda c: c.number)
    quickSort(cards, 0, n - 1)
    print(isStable(cards, stableCards, n))
    list(map(lambda i : i.print_card(), cards))

def quickSort(cards, p, r) :
    if p < r:
        q = partion(cards, p, r)
        quickSort(cards, p, q - 1)
        quickSort(cards, q + 1, r)

def partion(cards, p, r) :
    x = cards[r]
    i = p
    for j in range(p, r + 1) :
        if int(cards[j].number) <= int(x.number) :
            cards[i], cards[j] = cards[j], cards[i]
            i += 1
    return i - 1

def isStable(a, b, n):
    for i in range(n):
        if a[i].prefix != b[i].prefix:
            return 'Not stable'

    return 'Stable'

class Card():
    def __init__(self, prefix, number):
        self.prefix = prefix
        self.number = number

    def print_card(self):
        print(self.prefix, self.number)

if __name__ == '__main__':
    main()



Measured memory_bytes: 31580
import scala.io.StdIn._
import scala.annotation.tailrec
   
object Main {
  @tailrec
  def binarySearch(f: Int => Int, l: Int, r: Int): Int = {
    if(r-l<=1)f(l)
    else if(f((l+r)/2) < 1)binarySearch(f,(l+r)/2,r)
    else binarySearch(f,l,(l+r)/2)
  }
  
  def main(args: Array[String]): Unit = {
    val n = readInt
    val list = readLine.split(" ").map(_.toInt)
   
    val f = (ar: Seq[Int], a: Int) => (x: Int) => ar(x)-a
   
    val q = readInt
    val qlist = readLine.split(" ").map(_.toInt)
    val res = for(e <- qlist)yield binarySearch(f(list,e),0,n)
    println(res.count(_ == 0))
  }
}

Measured memory_bytes: 87612
n=int(input())
a=list(map(int,input().split()))
sum_a=sum(a)
x=0
i=0
while x<sum_a/2:
    x+=a[i]
    i+=1
if n%2==0:
    print(min(x-(sum_a-x),sum_a-(x-a[i-1])*2))
else:
    print(x-(sum_a-x))

Measured memory_bytes: 31656
/*
ID: lit20182
TASK: beads
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define fi first
#define si second
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) vector<ll> ft(1, 1LL);rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define int ll


ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
/*_____________________________________________________________________________________________________*/





vector<int> arr[2000001];
signed main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
    next :
	while(t--){
        int n, m;
        cin >> n >> m;
        int arr[n+1];
        int c = 0, s = 0;
        rep(i, 0, n){
            cin >> arr[i];
            s += arr[i];
        }
        rep(i, 0, n){
            if(arr[i] >= (double)s/(4.0*m))c++;
        }
        if(c >= m)cout << "Yes";
        else cout << "No";
    }
} 









Measured memory_bytes: 47104
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 2e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
vi v[N],e[2];int n,ans[N],cnt[3];bool vis[N],use[N];
queue<int>q;
void solve()
{
	for(int i=0;i<n;i++)ans[i]=vis[i]=0;
	q.push(0);
	q.push(0);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		int move=q.front();q.pop();
		vis[now]=true;
		move%=2;
		e[move].pb(now);
		for(int i=0;i<v[now].size();i++)
		{
			int to=v[now][i];
			if(!vis[to])
			{
				vis[to]=true;
				q.push(to);
				q.push(move+1);
			}
		}
	}
}
int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--,b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	solve();
	if(e[0].size()>e[1].size())swap(e[0],e[1]);
	int x0=(n/3),x1=(n+1)/3,x2=(n+2)/3;
	if(e[0].size()>=x2)
	{
		for(int i=0;i<e[0].size();i++)if(cnt[2]+2<=n)ans[e[0][i]]=cnt[2]+2,cnt[2]+=3;
		for(int i=0;i<e[1].size();i++)if(cnt[1]+1<=n)ans[e[1][i]]=cnt[1]+1,cnt[1]+=3;
		for(int i=0;i<n;i++)
		if(!ans[i]){
			if(cnt[0]+3<=n)ans[i]=cnt[0]+3,cnt[0]+=3;
			else ans[i]=cnt[1]+1,cnt[1]+=3;
		}
	}else{
		for(int i=0;i<e[0].size();i++)
			ans[e[0][i]]=cnt[0]+3,cnt[0]+=3,use[cnt[0]]=true;
		int Cnt=1;
		for(int i=0;i<n;i++)
		{
			if(!ans[i])
			{
				ans[i]=Cnt;
				Cnt++;
				if(use[Cnt])Cnt++;
			}
		}
	}
	for(int i=0;i<n;i++)cout<<ans[i]<<" ";
	return 0;
}

Measured memory_bytes: 16756
s = list(input())
s = [int(i+j) for (i,j) in zip(s[::2],s[1::2])]

if 1 <= s[0] <= 12:
  if 1 <= s[1] <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= s[1] <= 12:
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 9136
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main()
{
	long long N, K, minattack = 0;
	cin >> N >> K;
	int *arrA;
	arrA = new int[N];
	for (int i = 0; i < N; i++)
	{
		cin >> arrA[i];
	}
	sort(arrA, arrA + N);

	for (int i = N-1-K ; i >= 0; i--)
		minattack += arrA[i];
	cout << minattack << endl;

	/*if (Common_Raccoon(H, arrA, size,0, 0))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;*/

}

Measured memory_bytes: 1024
#include <iostream>
#define int long long
using namespace std;

int n;
int a[80];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) { cin >> a[i]; }
	
	int ans = 1000;
	for (i = 0; i < n - 1; i++) {
		if (a[i] < a[i + 1]) {
			ans = ans % a[i] + (ans / a[i]) * a[i + 1];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;


char S[13][13];
int H,W;
vector<P> ps;
bool us[13];
bool g();
bool f(){
#if 0
	if(ps.size()>10){
		for(auto p:ps){
			cerr << p.first << ", " << p.second << endl;
		}
		exit(0);
	}
#endif
	int t=0;
	while(us[t]){
		t++;
	}
	//cerr << t << ", " <<  H << endl;
	if(t==H){
		return g();
	}
	us[t]=true;
	int cnt=1;
	for(int s=t+1;s<H;s++){
		if(us[s])continue;
		us[s]=true;
		cnt++;
		ps.push_back(P(t,s));
		if(f()){
			//cerr << "f " << t << ", " << s << endl;
			return true;
		}
		ps.pop_back();
		us[s]=false;
	}
	if(cnt%2){
		ps.push_back(P(t,t));
		if(f()){
			//cerr << "f " << t << endl;
			return true;
		}
		ps.pop_back();
	}
	us[t]=false;
	return false;
}
bool g(){
	bool vs[13]={};
	bool single=W%2?true:false;
	for(int i=0;i<W;i++){
		if(vs[i])continue;
		bool ok=false;
		for(int j=i+1;j<W;j++){
			if(vs[j])continue;
			ok=true;
			for(auto p:ps){
				if(S[p.first][i]!=S[p.second][j]||
					S[p.first][j]!=S[p.second][i]){
					ok=false;
					break;
				}
			}
			if(ok){
				vs[j]=true;
				break;
			}
		}
		if(!ok&&single){
			ok=true;
			for(auto p:ps){
				if(S[p.first][i]!=S[p.second][i]){
					ok=false;
					break;
				}
			}
			if(ok){
				single=false;
			}
		}
		if(!ok)return false;
	}
	
	return true;
}
int main() {
	cin >> H >> W;
	for(int i=0;i<H;i++){
		cin >> S[i];
	}
	if(f()){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
int n, k;
int a[20];
signed main() {
	cin >> n >> k;
	rep(i, k)cin >> a[i];
	rep(i, (1 << k)) {
		int ans = 0;
		vector<int>v;
		rep(j, n) {
			if ((i >> j) & 1) {
				ans += (1 << a[j]);
				v.push_back(a[j]);
			}
		}
		if (ans == 0)puts("0:");
		else {
			cout << ans << ":";
			for (int x : v)cout << " " << x;
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3144
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i, j;
		int[] mountain = new int[10];
		for (i = 0; i < 10; i++) {
			mountain[i] = sc.nextInt();
		}
		Arrays.sort(mountain);
		System.out.println(mountain[9]);
		System.out.println(mountain[8]);
		System.out.println(mountain[7]);
	}
}

Measured memory_bytes: 17164
'use strict';
// 最小公倍数を求める式（https://www.w3resource.com/javascript-exercises/javascript-math-exercise-10.phpからの貰い物コード）
function lcm_two_numbers(x, y) {
   if ((typeof x !== 'number') || (typeof y !== 'number')) 
    return false;
  return (!x || !y) ? 0 : Math.abs((x * y) / gcd_two_numbers(x, y));
}

function gcd_two_numbers(x, y) {
  x = Math.abs(x);
  y = Math.abs(y);
  while(y) {
    var t = y;
    y = x % y;
    x = t;
  }
  return x;
}

function main(input) {
  let numArr = input[0].split(" ").map(x => x * 1);
  console.log(lcm_two_numbers(numArr[0],numArr[1]));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))

  

Measured memory_bytes: 11468
#include<stdio.h>
int main(){
    int i, j, k, n, m, l;
    int a[100][100];
    int b[100][100];
    long c[100][100]={0};
    scanf("%d %d %d", &n, &m, &l);
    for(i=0; i<n; i++)for(j=0; j<m; j++)scanf("%d", &a[i][j]);
    for(i=0; i<m; i++)for(j=0; j<l; j++)scanf("%d", &b[i][j]);
    for(i=0; i<n; i++)for(j=0; j<l; j++)for(k=0; k<m; k++)c[i][j]+=a[i][k]*b[k][j];
    for(i=0; i<n; i++)for(j=0; j<l; j++){
            if(j!=l-1)printf("%ld ", c[i][j]);
            else printf("%ld\n", c[i][j]);
        }
    return 0;
}



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

int main(){
    string S,T;
    cin>>S;
    cin>>T;
    int s=S.length(), t=T.length();
    string A="";
    for(int i=0; i<t; ++i) A+=T[i];
    for(int i=0; i<s; ++i) A+=S[i];
    cout<<A<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,a,b,s=0; cin>>n>>a>>b;
  for(int i=1; i<=n; i++){
    int c=0;
    for(int j=i; j>0; j/=10) c+=j%10;
    if(a<=c&&c<=b) s+=i;
  }
  cout<<s;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> List = new ArrayList<>();
        int N = sc.nextInt();
        for(int a=0;a<N;a++) List.add(sc.nextInt());
        int max = Collections.max(List);
        int num = List.indexOf(max);
        List.remove(num);
        int sum=0;
        for(int a=0;a<List.size();a++) sum+=List.get(a);

        if(sum>max) System.out.println("Yes");
        else System.out.println("No");
    }
}

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

int main(){
    ll n,a,b; cin >> n >> a >> b;
    if(a > b) {cout << 0 << endl; return 0;}
    if(n == 1 && a != b) {cout << 0 << endl; return 0;}
    cout << (a+b*(n-1)) - (b+a*(n-1)) + 1 << endl;
    return 0;
}

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

int main(){
    int k; cin >> k;
    string s; cin >> s;
    int n = s.size();
    if(n <= k) cout << s << endl;
    else cout << s.substr(0,k) << "..." << endl;
}

Measured memory_bytes: 3628
#include<iostream>
 
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int A[n];
    long long ans = 0;
    for (int i = 0; i < n;i++){
        cin >> A[i];
    }
    for (int i = 1; i < n;i++){
        if(A[i]<A[i-1]){
 
            ans += A[i - 1]-A[i];
            A[i] = A[i - 1];
        }
 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4296
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

map<int, int> prime_factors(int n) {
	map<int, int> res;
	if (n == 1) { // n=1 の素因数分解は n^1
		res[n] = 1;
		return res;
	}
	for (int i = 2, _n = n; i*i <= _n; ++i) {
		while (n % i == 0) {
			++res[i]; // 素数i^{res[i]}
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

const ll p = (1e+9) + 7;

ll add(ll a, ll b) {
	return (a + b) % p;
}

ll sub(ll a, ll b) {
	return (a + p - b) % p;
}

ll mul(ll a, ll b) {
	return ((a%p)*(b%p)) % p;
}

ll power(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	else if (b == 1) {
		return a % p;
	}
	else if (b % 2 == 0) {
		ll c = power(a, b / 2);
		return (c*c) % p;
	}
	else {
		ll c = power(a, b / 2);
		return (((c*c) % p)*a) % p;
	}
}

ll divi(ll a, ll b) {
	return mul(a, power(b, p - 2));
}



int main() {
	int N, M;
	cin >> N >> M;
	if (M == 1) {
		cout << 1;
		return 0;
	}
	ll g[200000], inv_g[200000];
	REP(i, 200000) {
		if (i == 0) {
			g[i] = 1;
		}
		else {
			g[i] = mul(i, g[i - 1]);
		}
		inv_g[i] = divi(1, g[i]);
	}


	ll ans = 1;
	map<int, int> res = prime_factors(M);
	for (map<int, int>::iterator it = res.begin(), end = res.end(); it != end; ++it) {
		ans = mul(ans, mul(mul(g[N - 1 + it->second], inv_g[it->second]), inv_g[N - 1]));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328