akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
import numpy as np

def solve(N: int, A: "List[int]"):
    k = (np.argsort(A)+1)
    print(*k)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 29136
#!/usr/bin/env python3
import sys
import heapq
input = lambda: sys.stdin.readline().strip()

def solve(N: int, M: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    heapq.heapify(A)
    I = sorted(list(range(M)), key=lambda i: -C[i])
    for i in I:
        while A[0] < C[i] and B[i] > 0:
            heapq.heappop(A)
            heapq.heappush(A, C[i])
            B[i] -= 1
    print(sum(A))
    

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 86688
#include <iostream>
#include <string>

using namespace std;

int main() {
    int n;  cin >> n;
    string s;
    int ans[26];
    for (int i = 0; i < 26; i++)
        ans[i] = 30;

    for (int i = 0; i < n; i++) {
        cin >> s;
        int cnt[26] = {0};
        for (int i = 0; i < s.length(); i++) {
            cnt[s[i] - 'a']++;
        }
        
        for (int i = 0; i < 26; i++) {
            ans[i] = min(cnt[i], ans[i]);
        }
    }

    string t;
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < ans[i]; j++) {
            char c = 'a' + i;
            t.push_back(c);
        }
    }

    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 200010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans, sum;
ll A[MAXN];
int fen[MAXN];
vector<ll> comp;

void add(int pos){
	for (; pos<MAXN; pos+=pos&-pos) fen[pos]++;
}
int get(int pos){
	int res=0;
	for (; pos; pos-=pos&-pos) res+=fen[pos];
	return res;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>k;
	for (int i=1; i<=n; i++){
		cin>>x;
		sum+=x;
		A[i]=sum-i*k;
	}
	for (int i=0; i<=n; i++) comp.pb(A[i]);
	sort(all(comp));
	comp.resize(unique(all(comp))-comp.begin());
	
	for (int i=0; i<=n; i++) A[i]=lower_bound(all(comp), A[i])-comp.begin()+1;
	
	for (int i=0; i<=n; i++){
		ans+=get(A[i]);
		add(A[i]);
	}
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
int test;
long long mod=1000000007ll;

long long fact(long long n){
	long long ans=1;
	for(long long i=1;i<=n;i++){
		ans*=i;
		ans%=mod;
	}
	return ans;
}

int main(){
long long n,m;
cin>>n>>m;
if(abs(n-m)>1)
cout<<0<<endl;
else{
	if(abs(n-m)==1)
	cout<<(fact(n)*fact(m))%mod<<endl;
	else{
	
	cout<<(((2ll*(fact(n)))%mod)*fact(m))%mod<<endl;
	
	}
}
return 0;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> to[100100];
    rep(i,m){
        int a,b;
        cin>>a>>b;
        --a;--b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    q.push(0);
    dist[0]=0;

    while(!q.empty()){
        int v = q.front(); q.pop();
        for(int u: to[v]){
            if(dist[u]!=INF)continue;
            dist[u]=dist[v]+1;
            pre[u]=v;
            q.push(u);
        }
    }
    cout<<"Yes"<<endl;
    rep(i,n){
        if(i==0)continue;
        cout<<pre[i]+1<<endl;
    }
    return 0;

}

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

typedef long long ll;
const int N(105), K(133333);
ll a[N], s[K];
ll dp[N][K];
int n, k;

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int j = 0; j <= k; ++j)
        dp[0][j] = 0;
    for (int j = 0; j <= n; ++j)
        dp[j][0] = 1;
    for (int i = 1; i <= n; ++i)
    {
        s[0] = 0;
        for (int j = 1; j <= k + 1; j++)
            s[j] = (s[j - 1] + dp[i - 1][j - 1]) % mod;
        for (int j = 1; j <= k; j++)
        {
            dp[i][j] = s[j + 1] - s[max(0ll, j - a[i - 1])];
            if (dp[i][j] < 0)
                dp[i][j] += mod;
            dp[i][j] = dp[i][j] % mod;
            /*
            if (dp[i][j] < 0)
                dp[i][j] += mod;
                */
        }
    }
    cout << dp[n][k];
    return 0;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int a,b;
    cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;
}

Measured memory_bytes: 256
// header file section
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B"
#include <iostream>
#include <cstdio>
#include <cfloat>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <numeric>
#include <algorithm>
//#include "../../segment_tree/segment_tree.hpp"
//#include "../../data_type/sum_monoid.hpp"

#ifndef SEGMENT_TREE_HPP
#define SEGMENT_TREE_HPP

#include <vector>
#include <functional>
#include <iterator>

//===
template<class Monoid>
struct SegmentTree {
    using T = typename Monoid::value_type;

    std::vector<T> tree;

    SegmentTree() = default;
    explicit SegmentTree(int n)
        :tree(n << 1, Monoid::identity()) {};

    template<class InputIterator>
    SegmentTree(InputIterator first, InputIterator last) {
        tree.assign(distance(first, last) << 1, Monoid::identity());

        int i;
        i = size();
        for (InputIterator itr = first; itr != last; itr++) {
            tree[i++] = *itr;
        }

        for (i = size() - 1; i > 0; i--) {
            tree[i] = Monoid::operation(tree[(i << 1)], tree[(i << 1) | 1]);
        }
    };

    inline int size() {
        return tree.size() >> 1;
    };

    inline T operator[] (int k) {
        return tree[k + size()];
    };

    void update(int k, const T dat) {
        k += size();
        tree[k] = dat;
        
        while(k > 1) {
            k >>= 1;
            tree[k] = Monoid::operation(tree[(k << 1)], tree[(k << 1) | 1]);
        }
    };

    // [l, r)
    T fold(int l, int r) {
        l += size(); //points leaf
        r += size();

        T lv = Monoid::identity();
        T rv = Monoid::identity();
        while (l < r) {
            if (l & 1) lv = Monoid::operation(lv, tree[l++]);
            if (r & 1) rv = Monoid::operation(tree[--r], rv);
            l >>= 1;
            r >>= 1;
        }

        return Monoid::operation(lv, rv);
    };
};
//===

#endif

#ifndef SUM_MONOID_HPP
#define SUM_MONOID_HPP

template<class T>
struct SumMonoid {
    using value_type = T;
    inline static T identity() {
        return 0;
    };
    inline static T operation(const T a, const T b) {
        return a + b;
    };
};

#endif


using llong = long long;
using namespace std;

llong n, q;
llong com, x, y;

int main() {
    cin >> n >> q;
    SegmentTree<SumMonoid<llong>> seg(n);
    for (int i = 0; i < q; i++) {
        cin >> com >> x >> y;

        if (com == 0) {
            seg.update(x - 1, seg[x - 1] + y);
        }
        else {
            cout << seg.fold(x - 1, y) << '\n';
        }
    }

    return 0;
};




Measured memory_bytes: 4324
fun main(args : Array<String>) {
    val s = readLine()!!

    var cnt = 0
    var cntMax = 0
    s.forEach { c ->
        if (c == 'R') {
            cnt++
            cntMax = Math.max(cntMax, cnt)
        } else {
            cnt = 0
        }
    }

    println(cntMax)
}

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

const int INF = 1000000000;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> key(m);
    vector<int> v(m);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        v.at(i) = a;
        for (int j = 0; j < b; j++) {
            int c;
            cin >> c;
            c--;
            key.at(i).push_back(c);
        }
    }
    
    vector<int> cost(1 << n, INF);
    cost.at(0) = 0;
    for (int i = 0; i < m; i++) {
        int mask = 0;
        for (int j = 0; j < (int)key.at(i).size(); j++) {
            mask |= 1 << key.at(i).at(j);
        }
        for (int j = 0; j < 1 << n; j++) {
            int bit = j | mask;
            cost.at(bit) = min(cost.at(bit), cost.at(j) + v.at(i));
        }
    }
    
    if (cost.at((1 << n) - 1) == INF) cout << -1 << endl;
    else cout << cost.at((1 << n) - 1) << endl;
}

Measured memory_bytes: 384
#include <functional>
#include <queue>
#include <vector>
#include <iostream>
#include <cstdint>
#include <cstring>
using namespace std;

int main()
{
	int n;
	char* s;
	int cnt = 0;

	cin >> n;

	s = new char[n];

	cin >> s;

	for (int i = 1; i < n; i++)
	{
		if (s[i - 1] != s[i])
		{
			cnt++;
		}
	}
	cnt++;

	cout << cnt;

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
#include<cstring>
struct edge { int to, cap, rev; };
vector<edge> G[100000];
bool used[100000];
void add_edge(int from, int to, int cap) {
	G[from].push_back(edge{ to, cap, (int)G[to].size() });
	G[to].push_back(edge{ from, 0, (int)G[from].size() - 1 });
}
int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < (int)G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, MOD);
		if (f == 0)return flow;
		flow += f;
	}
}
int main() {
	int n, A, B, C, D,i,j;
	int a[100], b[100], c[100], d[100];
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> A >> B;
		a[i] = A; b[i] = B;
		add_edge(2 * n, i, 1);
	}
	for (i = 0; i < n; i++) {
		cin >> C >> D;
		c[i] = C; d[i] = D;
		add_edge(n + i, 2 * n + 1, 1);
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (a[i] < c[j] && b[i] < d[j]) {
				add_edge(i, n+j, 1);
			}
		}
	}
	cout << max_flow(2*n, 2*n+1) << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}


Measured memory_bytes: 2816
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn get_bothside_poses(v: &Vec<i64>, start: i64) -> Vec<Option<i64>>{
    let bin_res = v.binary_search(&start);
    let west_pos: Option<i64> = match bin_res{
        Ok(_) => Some(start),
        Err(index) => if 0 < index{
            Some(start -v[index-1])
        }else{
            None
        }
    };

    let east_pos: Option<i64> = match bin_res{
        Ok(_) => Some(start),
        Err(index) => if index < v.len(){
            Some(v[index] - start)
        }else{
            None
        }
    };

    vec![west_pos, east_pos]
}

fn main(){
    let line = read_as_vec::<usize>();
    let (a, b, q) = (line[0], line[1], line[2]);

    let mut s: Vec<i64> = Vec::new();
    for _ in 0..a{
        s.push(read_as_vec()[0]);
    }
    
    let mut t: Vec<i64> = Vec::new();
    for _ in 0..b{
        t.push(read_as_vec()[0]);
    }

    for _ in 0..q{
        let start: i64 = read_as_vec()[0];
        let mut v: Vec<Option<i64>> = vec![None;4];
        let shrines = get_bothside_poses(&s, start);
        let temples = get_bothside_poses(&t, start);
        
        let mut costs: Vec<Option<i64>> = Vec::new();
        for i in 0..2{
            for j in 0..2{
                if shrines[i].is_none() || temples[j].is_none(){
                    //costs.push(None);
                    continue;
                }else if i%2 != j%2{
                    costs.push(
                        Some(shrines[i].unwrap() + temples[j].unwrap() +
                            cmp::min(shrines[i].unwrap(), temples[j].unwrap()))
                    );
                }else{
                    costs.push(Some(cmp::max(shrines[i].unwrap(), temples[j].unwrap())));
                }
            }
        }
        println!("{:?}", costs.iter().min().unwrap().unwrap());
    }
 }


Measured memory_bytes: 7420
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1e9+7;
using namespace std;

int main(){
    int n; cin >> n;
    REP(i, n){
        string s; cin >> s;
        if(s == "Y"){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  int A, B;
  cin >> A >> B;
  
  cout << (A%3==0 || B%3==0 || (A+B)%3==0 ? "Possible" : "Impossible" ) << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB = sorted(AB, key=lambda x: x[0])  # sort by days

import heapq
que = []
heapq.heapify(que)

ans = 0
i = 0
for day in range(1, M+1):
    while i < len(AB) and AB[i][0] <= day:
        heapq.heappush(que, (-1)*AB[i][1])
        i += 1
    if que:
        ans += (-1)*heapq.heappop(que)
print(ans)

Measured memory_bytes: 31960
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

int f(int n){
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(n % i == 0) cnt++;
    }
    return cnt;
}


void solve(){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i += 2){
        if(f(i) == 8) cnt++;
    }
    cout << cnt;
}


int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}
// vse dolzhny vyiti v internet po hhtp


Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
   
typedef long long ll;
const int N = 100010;
int num[40];
ll a[N];

int main()
{
    int n;
    ll k;
    scanf("%d %lld", &n, &k);
    for (int i = 1; i <= n; ++i) {
        scanf("%lld", &a[i]);
    }
    for (int i = 0; i <= 39; ++i) {
        for (int j = 1; j <= n; ++j) {
            if ((a[j] >> i) & 1) {
                ++num[i];
            }
        }
    }
    ll ret = 0, ans = 0, now = 0;
    for (int i = 39; i >= 0; --i) {
        ll tmp1 = ret, tmp2 = now;
        now += (ll)num[i] * (1LL << i);
        for (int j = i - 1; j >= 0; --j) {
            if ((ret | (1LL << j)) > k) {
                now += (ll)num[j] * (1LL << j);
            } else {
                now += (ll)max(num[j], n - num[j]) * (1LL << j);
                if (n - num[j] > num[j]) ret += (1LL << j);
            }
        }
        ans = max(ans, now);
        ret = tmp1, now = tmp2;
        if ((k >> i) & 1) {
            ret += (1LL << i);
            now += (ll)(n - num[i]) * (1LL << i);
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;cin>>n;
  int i,j,k;
  vector<int> v;
  for(i=0;i<n;i++){
    cin >> k;
    v.push_back(k);
  }
  for(j=0;j<n;j++) cout << v[j] << (j==n-1?'\n':' ');
  for(i=1;i<n;i++){
    for(j=0;j<i;j++){
      if(v[j]>v[i]){
    k=v[i];
    v.erase(v.begin()+i);
    v.insert(v.begin()+j,k);
    break;
      }
    }
    for(j=0;j<n;j++) cout << v[j] << (j==n-1?'\n':' ');
  }
  return 0;
}


Measured memory_bytes: 3104
import sys,heapq
input = sys.stdin.buffer.readline

n,m,s = map(int,input().split())
if s >= 2500:
    s = 2499

dg = 2500
INF = 10**15

dist = [INF]*(n*dg)

edge = [[] for i in range(n)]
a = [0]*m
b = [0]*m

for i in range(m):
    u,v,aa,bb = map(int,input().split())
    a[i] = aa
    b[i] = bb
    edge[u-1].append( (i,v-1))
    edge[v-1].append( (i,u-1) )


c = [0]*n
d = [0]*n

for i in range(n):
    cc,dd = map(int,input().split())
    c[i] = cc
    d[i] = dd

tank = [(0,s)]
nonused = [True]*(n*dg)


while tank:
    tim,fr = heapq.heappop(tank)
    if dist[fr] != INF:
        continue
    dist[fr] = tim
    pos,mon = divmod(fr,dg)

    for idx,go in edge[pos]:
        if mon >= a[idx] and dist[go*dg + mon-a[idx]] == INF:
            heapq.heappush(tank,(tim + b[idx] ,go*dg + mon-a[idx] ))
    if mon + c[pos] < dg and dist[fr + c[pos]] == INF:
        heapq.heappush(tank,(tim + d[pos] ,fr + c[pos] ))

for i in range(1,n):
    res = INF
    for j in range(dg):
        if dist[i*dg+j] < res:
            res = dist[i*dg+j]
    print(res)



Measured memory_bytes: 89652
/**
 *      ABC 64 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-05 03:26:27
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int a[N];
    for (int i = 0; i < N; ++i) {
        cin >> a[i];        
    }
    sort(a, a + N);
    cout << a[N - 1] - a[0] << endl;

    return 0;
}


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

int main(){
    int n, m;
    string s;
    map<string, int> mp;
    
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> s;
        if(mp.count(s) == 0){
            mp[s] = 1;
        }else{
            mp[s]++;
        }
    }
    
    cin >> m;
    for(int i=0; i<m; i++){
        cin >> s;
        if(mp.count(s) == 0){
            mp[s] = -1;
        }else{
            mp[s]--;
        }
    }

    int ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        ans = max(ans, (*itr).second);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int W = sc.nextInt(), B = sc.nextInt(); 
    char ans[][] = new char[105][105]; 
    for(int i = 0; i<=49; i++){
      for(int j = 0; j<100; j++){
        ans[i][j] = '#';
      }
    }
    for(int i = 50; i<=99; i++){
      for(int j = 0; j<100; j++){
        ans[i][j] = '.'; 
      }
    }
    W--; 
    B--;
    for(int i = 0; i<=49; i++){
      for(int j = 0; j<100; j++){
        if(i%2 == 0 && j%2 == 0 && W > 0){
          ans[i][j] = '.'; 
          W--; 
        }
      }
    }
    for(int i = 99; i>=50; i--){ 
      for(int j = 0; j<100; j++){ 
        if(i%2 == 1 && j%2 == 0 && B > 0){
          ans[i][j] = '#';
          B--;
        }
      }
    }
    System.out.println(100 + " " + 100);
    for(int i = 0; i<100; i++){
      for(int j = 0; j<100; j++){
        System.out.print(ans[i][j]); 
      }
      System.out.println();
    }
  }
}

Measured memory_bytes: 29824
N, K = map(int, input().split())
d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

sunuke = [0] * N
for i in range(K):
    for j in range(d[i]):
        sunuke[A[i][j] - 1] += 1

ans = 0
for i in range(N):
    if sunuke[i] == 0:
        ans += 1

print(ans)


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

#define int long long

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int n;scanf("%lld",&n);
    int cnt[3]={};
    rep(i,n){
        int a;scanf("%lld",&a);cnt[a%3]++;
    }

    if(cnt[0]==n){
        cout<<1<<endl;
        return 0;
    }


    int ans=cnt[0];
    if(abs(cnt[1]-cnt[2])<=3)ans+=cnt[1]+cnt[2];
    else{
        ans+=min(cnt[1],cnt[2])*2+3;
    }
    cout<<ans<<endl;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    int K;
    Scd2(N,K);
    vector<int> V(N);

    V.resize(N);

    Rep(i,N){
        Scd(V[i]);
    }

    int ans = 0;
    Repe(i,N+1,1){
        if( i > K ) break;
        Rep(j,i+1){
            int tmp = 0;
            priority_queue<int, vector<int>, greater<int> > p;
            Rep(l,j){
                p.push(V[l]);
                // printf ("%d ", l);
            }
            Rep(r,i-j){
                p.push(V[N-r-1]);
                // printf ("%d ", N-1-r);
            }
            int t = 0;
            Rep(k,K-i){
                if( p.empty() ) break;
                if( p.top() > 0 ) break;
                p.pop();
                t++;
            }
            while( !p.empty() ){
                tmp += p.top();
                p.pop();
            }
            // printf ("!%d %d : %d\n", i,j, tmp );
            ans = max( tmp, ans );
        }
    }

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

    return 0;
}



Measured memory_bytes: 256
while 1:
    n,m=map(int,input().split())
    if n==0:break
    e=['']*n;b=['']*n;w=['']*n
    for i in range(n):e[i],b[i],w[i]=input().split()
    b=list(map(int,b));w=list(map(int,w))
    for _ in range(m):
        q=int(input())
        for i in range(n):
            if w[i]-b[i]<q<=w[i]:print(e[i],b[i]-w[i]+q);break
        else:print('Unknown')

Measured memory_bytes: 7908
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	double r; cin >> r;
	double ans = r * 6.2831853;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3796
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=105,inf=1e9;
int mn,n,a[maxn],sum;
int main(){
	scanf("%d",&n); mn=inf;
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
		if (a[i]%10!=0){
			mn=min(a[i],mn);
		}
	}
	if (sum%10==0){
		if (mn==inf) puts("0");
			else printf("%d\n",sum-mn);
	}else{
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#define _GLIBCXX_DEBUG

#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define endl '\n'
#define fcout cout << fixed << setprecision(15)

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

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

using ll    = long long;
using ld    = long double;
using Pii   = pair<int, int>;
using Pll   = pair<ll, ll>;

constexpr ll MOD       = (int)1e9 + 7;
constexpr int INF_int   = (int)(1 << 30);
constexpr ll INF_ll     = (ll)1e18 + 1;
constexpr ld PI         = 3.141592653589793L;

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

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*追加部分*/



/*main関数*/

signed main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }

    ll ans_0 = 1, ans_1 = 1, ans_2 = 1;
        for(int i = 0; i < n; i++){
                ans_0 = ans_0 * 10 % MOD;
                ans_1 = ans_1 * 9 % MOD;
                ans_2 = ans_2 * 8 % MOD;
        }


    ll ans = ans_0 - ans_1 * 2 + ans_2 + MOD * 2;
    cout << ans % MOD << endl;

return 0;
}


Measured memory_bytes: 3568
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        int max = Integer.MAX_VALUE;
        FastScanner sc = new FastScanner(System.in);
        int d = sc.nextInt();
        long g = sc.nextLong();
        long[] p = new long[d];
        long[] c = new long[d];
        for(int i = 0; i < d; i++){
            p[i] = sc.nextLong();
            c[i] = sc.nextLong();
        }
        long ans = Long.MAX_VALUE;
        for(int i = 0; i < (2 << d); i++){
            long tmp = 0;
            long now = 0;
            int maxUseLess = -1;
            for(int j = 0; j < d; j++){
                if((i >> j) % 2 == 0){
                    maxUseLess = j;
                }else{
                    tmp += p[j];
                    now += c[j]+(j+1)*100*p[j];
                }
            }
            if(maxUseLess != -1){
                if(g <= now){
                    ans = Math.min(ans,tmp);
                }else if((g-now) > (maxUseLess+1) * p[maxUseLess] * 100){
                    continue;
                }else{
                    tmp += (long)Math.ceil((g-now)/(double)((maxUseLess+1) *100));
                    ans = Math.min(ans,tmp);
                }
            }else{
                if(g <= now){
                    ans = Math.min(ans,tmp);
                }
            }
        }
        System.out.println(ans);
    }
}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 23252
from heapq import heappush,heappop 
from math import sqrt
inf=float("inf")

xs,ys,xt,yt=map(int,input().split())
n=int(input())

q=[]
l=[(xs,ys,0),(xt,yt,0)]+[tuple(map(int,input().split())) for _ in range(n)]

sizeV=len(l)
rests=set(range(sizeV))
cost=[inf]*sizeV
cost[0]=0
heappush(q,(0,0))

while q:
  c1,i=heappop(q)
  if c1>cost[i]:continue

  rests.remove(i)
  if not rests:break

  xi,yi,ri=l[i]
  for j in rests:
    xj,yj,rj=l[j]
    d=max(0.0,sqrt((xj-xi)**2+(yj-yi)**2)-ri-rj)
    c2=c1+d
    if c2<cost[j]:
      cost[j]=c2
      heappush(q,(c2,j))

print(cost[1])

Measured memory_bytes: 92636
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstring>
#include <iomanip>
#include <utility>
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

ll n;
vector<bool> r;
deque<int> ans;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n;
	n++;

	while (n > 1) {
		if (n & 1) {
			r.push_back(1);
			n--;
		}
		else {
			r.push_back(0);
			n /= 2;
		}
	}

	int x = 1;
	for (int i = r.size() - 1; i >= 0; i--) {
		if (r[i]) ans.push_front(x++);
		else ans.push_back(x++);
	}

	cout << 2 * ans.size() << endl;

	for (int v : ans) cout << v << ' ';
	for (int i = 1; i < x; i++) cout << i << ' ';

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int X = int.Parse(strs[0]);
            int N = int.Parse(strs[1]);
            var hash = new HashSet<int>();
            if (N == 0)
            {
                Console.WriteLine(X);
            }
            else
            {
                line = Console.ReadLine();
                strs = line.Split(' ');
                for (int i = 0; i < N; i++)
                {
                    hash.Add(int.Parse(strs[i]));
                }
                for(int i = 0; i < 101; i++)
                {
                    //X - iがあいてる
                    if (X - i >= 0 && !hash.Contains(X - i))
                    {
                        Console.WriteLine(X - i);
                        break;
                    }

                    //X + iがあいてる
                    if (X + i <= 101 && !hash.Contains(X + i))
                    {
                        Console.WriteLine(X + i);
                        break;
                    }
                }
            }
        }
    }
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int A,B,m;
    cin >> A>>B>>m;
    vector<int> a(A),b(B);
    int inf = 10000000;
    int amin=inf, bmin=inf;
    REP(i, A){
        cin >> a[i];
        amin = min(amin, a[i]);
    }
    REP(i, B)
    {
        cin >> b[i];
        bmin = min(bmin, b[i]);
    }
    vector<int> x(m), y(m),c(m);
    REP(i, m) { cin >> x[i]>>y[i]>>c[i]; }
    int ans=1000000;

    REP(i,m){
        int p;
        p=a[x[i]-1] + b[y[i]-1] - c[i];
        ans = min(p, ans);
    }
    ans = min(ans, amin + bmin);

    cout<< ans << "\n";

    return 0;
}

Measured memory_bytes: 2176
my @arr = <STDIN>;
@arr = map { chomp; [ split(/\s+/, $_) ] } @arr;
print main(@arr);

sub main {
    my ($h1, $m1, $h2, $m2, $k) = shift->@*;
    (60 * ($h2 - $h1)) + ($m2 - $m1) - $k;
}

Measured memory_bytes: 4848
#include <stdio.h>
#include <string.h>

char arr[1000000];

int main() {
    scanf("%s", arr);

    char *p = arr;

    while (*p == 'W') p++;

    char *s = p;

    long long t = 0, n = 0;
    while (*s != '\0') {
        if (*s == 'W') {
            t += s - p;
            n++;
        }

        s++;
    }

    printf("%lld\n", t - n * (n - 1) / 2);
}

Measured memory_bytes: 384
from collections import defaultdict


def create_tuple(x):
    a = x % 10
    b = int(str(x)[0])
    return (a, b)


N = int(input())
mp = defaultdict(int)
ans = 0

for i in range(1, N + 1):
    p = create_tuple(i)
    mp[p] += 1

for i in range(1, N + 1):
    p = create_tuple(i)
    q = (p[1], p[0])
    ans += mp[q]

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;

int main() {

	long a, b, n;
	cin >> a >> b >> n;

	if (a == b) {
		long x = a - 1;
		cout << (a * x) / b - a * (x / b) << endl;
		return 0;
	}
	if (a > b) {
		long x = min(b-1,n);
		cout << (a * x) / b - a * (x / b) << endl;
		return 0;
	}
	else {
		long x = min(b-1,n);
		cout << (a * x) / b - a * (x / b) << endl;
		return 0;
	}

	return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int A, B;
    cin >> A >> B;
    if(A > 9 || B > 9)
        cout << -1 << endl;
    else
        cout << A * B << endl;
    return 0;
}

Measured memory_bytes: 256
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//動的計画法で役に立つ関数
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; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    string N;
    cin >> N;
    cout << "ABC" + N << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

std::string solve(const std::string& s, const std::string& t)
{
  return t.substr(0, s.size()) == s ? "Yes" : "No";
}

int main()
{
  std::string s, t;
  std::cin >> s >> t;

  std::cout << std::setprecision(20);
  std::cout << solve(s, t) << std::endl;
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 30;
const int MOD = 1000000007;

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

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

    vector<ll> sum(n+1);
    for(int i = 0; i < n; ++i){
        sum[i+1] += (sum[i] + w[i]);
    }

    ll ans = INF64;
    for(int i = 1; i <= n; ++i){
        ll left = sum[i];
        ll right = sum[n] - sum[i];
        ans = min(ans, abs(right-left));
    }
    cout << ans << endl;
    return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	string s;
    	cin>>s;
    	if(s=="AAA"||s=="BBB")
    		cout<<"No";
    	else
    		cout<<"Yes";
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	g := make([][]int, n)
	for i := range g {
		g[i] = make([]int, n)
	}
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		a--
		b--
		g[a][b] = 1
		g[b][a] = 1
	}

	o := make([]int, n-1)
	for i := range o {
		o[i] = i + 1
	}

	var cnt int
	for {
		ok := true
		i := 0
		for _, v := range o {
			if g[i][v] != 1 {
				ok = false
				break
			}
			i = v
		}
		if ok {
			cnt++
		}

		if !nextPermutation(sort.IntSlice(o)) {
			break
		}
	}
	fmt.Println(cnt)
}

func nextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}


Measured memory_bytes: 640
N = int(input())
alist = list(map(int, input().split()))
blist = []
alen = len(alist)

n = 0
i = 1

for a in alist:
    if a == i:
        i += 1
    else:
        blist.append(a)
        n += 1

if len(blist) == len(alist):
    print(-1)
else:
    print(n)

Measured memory_bytes: 26012
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n; cin>>n;
  VI a(n), b(n), c(n);
  rep(i,n) cin>>a[i]>>b[i], c[i]=a[i]+b[i];
  sort(RALL(c));
  ll x=0;
  rep(i,n) x-=b[i];
  // int cnt;
  // if(n%2) cnt=n/2+1; else cnt=n/2;
  rep(i,n) if(!(i%2)) x+=c[i];

  cout << x << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    int n;
    cin>>n;
    vi a(n);
    REP(i,n){
        cin>>a[i];
    }
    sort(all(a),greater<int>());
    int ans=0;
    int turn=1;
    REP(i,n){
        ans+=turn*a[i];
        turn*=-1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int odd = 0;
    int even= 0;

    for(int i=1;i<=k;i++){
      if(i%2==0){
        even++;
      }else{
        odd++;  
      }
    }
    System.out.print(even*odd);
  }
}

Measured memory_bytes: 21844
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************


int main(){

    int N;
    cin >> N;

    vi A(N + 1, 0);

    ll MAX = sqrt(N) + 1;
    FOR(x, 1, MAX) FOR(y, 1, MAX) FOR(z, 1, MAX){
        ll n = (x*x + y*y + z*z + x*y + y*z + z*x);
        if (n <= N) A[n]++;
    }

    FOR(i, 1, N + 1){
        cout << A[i] << endl;
    }

    return 0;
}


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

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


Measured memory_bytes: 3648