akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int n;
const int MAXN = 205;
int d[MAXN][MAXN];

vector<int> G[MAXN];
int color[MAXN];

bool is_bip(int v, int c) {
  color[v] = c;
  for (int i = 0; i < G[v].size(); i++) {
    if (color[G[v][i]] == c) return false;
    if (color[G[v][i]] == 0 && !is_bip(G[v][i],-c)) return false;
  }
  return true;
}

void warshall_froyd() {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }
}

int main () {
  cin >> n;

  rep(i,n)rep(j,n) d[i][j] = INF;
  rep(i,n) d[i][i] = 0;

  rep(i,n) {
    string s;
    cin >> s;
    rep(j,n) {
      if (s[j] == '1') {
        G[i].pb(j);
        d[i][j] = 1;
      }
    }
  }

  if (!is_bip(0,1)) {
    cout << -1 << endl;
    return 0;
  }

  warshall_froyd();

  int mx = 0;
  rep(i,n)rep(j,n) {
    mx = max(mx,d[i][j]);
  }

  cout << mx+1 << endl;
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    map<pair<int, string>, int> x;
    for(int i=0; i<n; ++i){
        string s;
        int a;
        cin >> s >> a;
        x[make_pair(s.size(), s)] += a;
    }

    for(map<pair<int, string>, int>::iterator it=x.begin(); it!=x.end(); ++it)
        cout << it->first.second << ' ' << it->second << endl;

    return 0;
}

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

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

use std::collections::VecDeque;

fn main() {
    let n: usize = read();
    let m: usize = read();
    let h: Vec<usize> = (0..n).map(|_| read()).collect();
   
    let mut rinsetsu: Vec<VecDeque<usize>> = vec![VecDeque::new(); n];
    for _ in 0..m {
        let ai: usize = read();
        let bi: usize = read();
        rinsetsu[ai-1].push_back(bi-1);
        rinsetsu[bi-1].push_back(ai-1);
    }

    let mut ans: usize = 0;
    // let mut c: Vec<bool> = vec![true; m];
    // let mut d: Vec<bool> = vec![true; n];

    for i in 0..n {
        ans += 1;
        for p in &rinsetsu[i] {
            if h[i] <= h[*p] {
                ans -= 1;
                break;
            }
        }
    }

    println!("{}", ans);
}



Measured memory_bytes: 11284
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;

ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
ll fact[800005],rfact[800005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
ll dp[1000005];
ll ans_table[1000005];
char s[500005];

ll solve(ll num){
    //numの倍数を列挙し、その２つの積の総和
    ll sum = 0;
    ll square = 0;
    for(int i=1;i*num <= 1000000;i++){
        ll tmp = i * num;
        if(!dp[tmp])continue;
        ll cnt = dp[tmp];
        square += (((tmp * tmp) % mod) * cnt) % mod;
        sum += (tmp * cnt) % mod;
        square %= mod;
        sum %= mod;
    }
    ll last = sum * sum;
    last %= mod;
    last += mod - square;
    last %= mod;
    last *= 499122177ll;
    last %= mod;
    return last;
}

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        dp[a]++;
    }
    for(int i=1000000;i>=1;i--){
        ans_table[i] = solve(i);
        for(int j=2;j*i<=1000000;j++){
            ans_table[i] += mod - ans_table[i*j];
            ans_table[i] %= mod;
        }
        if(ans_table[i]){
            //pe(i);p(ans_table[i]);
        }
        ans += ans_table[i] * rui(i, mod - 2);
        ans %= mod;
    }
    p(ans);
    

    return 0;

}


















Measured memory_bytes: 30208
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B;
  cin >> A >> B;
  if ((A+B)%3 == 0 || A%3 == 0 || B%3 == 0){
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <cmath>
using namespace std;
int main(){
	long long Q, H, S, D;
	int n;
	cin >> Q >> H >> S >> D;
	cin >> n;
	Q *= 4;
	H *= 2;
	S = min(S, Q);
	S = min(S, H);
	long long ans = n * S;
	long long cur = n / 2;
	cur *= D;
	if(n & 1) cur += S;
	cout << min(cur, ans) << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 {
		fmt.Println("Possible")
	} else {
		fmt.Println("Impossible")
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

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

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (auto &i : a) {
        cin >> i;
        if (!i) {
            cout << "0\n";
            rr;
        }
    }
    int ans = 1, x;
    for (int i = 0; i < n; i++) {
        x = a[i];
        __float128 g = ans;
        __float128 b = x;
        g *= b;
        if (g > LINF) {
            cout << "-1\n";
            rr;
        }
        ans *= x;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define vv(type)		vector<vector<type>>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define db(x) 			cout<<x<<" "
#define db1(x) 			cout<<x<<'\n'
#define db2(x,y) 		cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) 		cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) 		for(int i=0;i<(n);++i)
#define repA(i,a,n) 	for(int i=a;i<=(n);++i)
#define repD(i,a,n) 	for(int i=a;i>=(n);--i)
#define so(a) 			sort(a.begin(),a.end())
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
// to find all local maximaa and minima in O(n)
//	 for (int i=1;i<=n;i++)
//        {
//            if (i==1 || i==n || (p[i-1]<p[i])!=(p[i]<p[i+1]))
//           ans.push_back(p[i]);
//        }
int dx[] = { -1, 1, -1, 0, 0, -1, 1, 1 };
int dy[] = { -1, -1, 1, -1, 1, 0, 0, 1 };
int gcd(int a, int b)
{
	if (!b)
		return a;
	return gcd(b, a % b);
}
int modular_expo(int x, int y, int m)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans % m * x % m) % m;
		x = (x % m * x % m) % m;
		y /= 2;
	}
	return ans % m ;
}
int power(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x);
		x *= x;
		y /= 2;
	}
	return ans;
}
int dp[402][402];
int sum[402] = {0};
int ways(vi &a, int i, int j)
{
	if (i == j)	return 0;
	if (dp[i][j] != -1)
		return dp[i][j];
	dp[i][j] = inf;
	for (int k = i; k < j; k++)
		dp[i][j] = min(dp[i][j], sum[j + 1] - sum[i] + ways(a, i, k) + ways(a, k + 1, j));
	return dp[i][j];
}

void solve()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n, k;
	cin >> n;
	memset(dp, -1, sizeof(dp));
	vi a(n);
	rep(i, n)
	{
		cin >> a[i];
		sum[i + 1] += (sum[i] + a[i]);
	}
	db1(ways(a, 0, n - 1));
}
int32_t main()
{
	solve();
	return 0;
}


Measured memory_bytes: 4960
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let h = Scanf.sscanf (read_line ()) "%d" (
        fun h -> 
                h
)

let rec f h =
        if h = 1 then
                1
        else
                2 * (f (h / 2)) + 1

let () =
        f h
        |> Printf.printf "%d\n"


Measured memory_bytes: 3072
n = int(input())
s = input()

a = []
count = 0

for i in range(n):
    if s[i] == "W":
        a.append(count)
    else:
        count += 1
        a.append(count)

num = 10**6

for i in range(n):
    if i == 0:
        num = a[n-1] - a[0]
    else:
        num = min(num, (a[n - 1] - a[i]) + (i - a[i - 1]))


print(num)

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

#define fi first
#define se second

const int N = 200200;

using namespace std;

int n;
int cur[N];
pair < int, int > a[N];

long long solve()
{
        int res = 1e9;
        vector < pair < int, int > > v;
        for(int i = 1; i <= n; i++){
                v.push_back({a[i].fi, i});
                v.push_back({a[i].se, i});
        }
        sort(v.begin(), v.end());
        multiset < int > S;
        int cnt = 0;
        for(auto p: v){
                if(cur[p.se]){
                        S.erase(S.find(cur[p.se]));
                } else{
                        cnt += 1;
                }
                cur[p.se] = p.fi;
                S.insert(p.fi);
                if(cnt == n){
                        res = min(res, p.fi - *S.begin());
                }
        }
        return res;
}

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> n;
        for(int i = 1; i <= n; i++){
                cin >> a[i].fi >> a[i].se;
                if(a[i].fi > a[i].se){
                        swap(a[i].fi, a[i].se);
                }
        }
        int A, B, C, D;
        A = B = a[1].fi;
        C = D = a[1].se;
        for(int i = 2; i <= n; i++){
                A = min(A, a[i].fi);
                B = max(B, a[i].fi);
                C = min(C, a[i].se);
                D = max(D, a[i].se);
        }
        long long res = (B - A) * 1ll * (D - C);

        cout << min(res, (D - A) * 1ll * solve()) << "\n";
}


Measured memory_bytes: 16108
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
	YYMM = False
	MMYY = False
	s = input()
	a = int(s[0:2])
	b = int(s[2:4])
	if 1 <= b and b <= 12:
		YYMM = True
	if 1 <= a and a <= 12:
		MMYY = True
	
	if YYMM and MMYY:
		print('AMBIGUOUS')
	elif YYMM:
		print('YYMM')
	elif MMYY:
		print('MMYY')
	else:
		print('NA')

if __name__ == '__main__':
	import sys
	sys.exit(main())


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

s_dict = {}

for i in range(N):
    s = input()
    if s in s_dict:
        s_dict[s] += 1
    else:
        s_dict[s] = 1

M = int(input())

t_dict = {}

for i in range(M):
    t = input()
    if t in t_dict:
        t_dict[t] += 1
    else:
        t_dict[t] = 1

maximum = 0

for s_key, s_value in s_dict.items():
    if s_key in t_dict:
        maximum = max(0, s_value - t_dict[s_key], maximum)
    else:
        maximum = max(s_value, maximum)
        
print(maximum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int>p(n);
  int cnt = 0;
  for(int i = 0; i < n; i++)
    cin >> p.at(i);
  for(int i = 0; i < n - 1; i++){
    if(p.at(i) == i + 1){
      swap(p.at(i),p.at(i+1));
      cnt++;
    }
  }
  if(p.at(n-1) == n) cnt++;
  cout << cnt;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;
using boost::math::gcd;
using boost::math::lcm;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){cin.tie(nullptr);ios::sync_with_stdio(false);}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

template<class T> void show_(const T& t) {cout<<t;}
template<class T> void show_(const vector<T>& v) {cout<<joined(v);}
void show_(bool b) {cout<<(b?"Yes":"No");}
void show_(double d) {cout<<fixed<<setprecision(12)<<d;}
template<class T, class... TS> void show_(const T& t, TS... ts) {show_(t);cout<<' ';show_(ts...);}
template<class T> void show(const T& t) {show_(t);cout<<LN;}
template<class T, class... TS> void show(const T& t, TS... ts) {show_(t, ts...);cout<<LN;}

int main() {
    int A, B;
    cin >> A >> B;
    set<int> s = { 1, 2, 3 };
    s.erase(A);
    s.erase(B);
    show(*s.begin());
}


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

int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  int result = 0;
  result += min(a, k);
  k = max(0, k-a);

  k = max(0, k-b);
  result -= min(c, k);

  cout << result << endl;
}

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

using namespace std;

int main() {
	//std::cout << std::fixed << std::setprecision(10)
	int N, M,k,u,ans=0;
	cin >> N >> M;
	vector<vector<int>> s(M,vector<int>(N));//M個の電球に対し，Nこのスイッチのうちどれが対応してるか調べる
	vector<int>p(M),chp(M);
	//入力
	for (size_t i = 0; i < M; i++)
	{
		cin >> k;
		for (size_t j = 0; j < k; j++)
		{
			cin >> u;
			u--;
			s.at(i).at(u)=1;
		}
	}
	for (size_t i = 0; i < M; i++)
	{
		cin >> p.at(i);
	}
	//以下，全探索
	for (size_t i = 0; i < (1<<N); i++)//ビットの移動ループ	
	{
		bitset<10> chk(i);
		for (size_t j = 0; j < N; j++)//それぞれのビットを読むループ
		{
			if (chk.test(j))
			{
				for (size_t k = 0; k < M; k++)//それぞれの電球に対し，対応するスイッチを見てやるループ
				{
					if (s.at(k).at(j) == 1)chp.at(k)++;
				}
			}
		}
		for (size_t i = 0; i < M; i++)
		{
			if (p.at(i) != (chp.at(i) % 2))break;
			if (i == M - 1) ans++;
		}
		for (size_t i = 0; i < M; i++)
		{
			chp.at(i) = 0;
		}
	}
	cout <<ans;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	long long int K,T,N,M,P,Q,i,j,a,b,c,ans=0;
	cin>>N>>K;
	
	long int A[K];
	for(i=0;i<K;i++) A[i]=0;
	for(i=1;i<=N;i++) A[i%K]++;
	
	for(i=0;i<K;i++) 
	{
		if((2*i)%K==0)
		{
			a=i;b=i;c=i;
			ans+=(A[i]*A[i]*A[i]);
		}
	}
	
	cout<<ans<<endl;
    
    
    return (0);
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
  int a,b,n,train,taxi;
  scanf("%d %d %d",&n,&a,&b);

  train=a*n;
  taxi=b;

  if(train>taxi){
    printf("%d",taxi);
  }
  else if(taxi>=train){
    printf("%d",train);
  }

  return 0;
}


Measured memory_bytes: 128
/*Flamenco Sketches*/
#include<bits/stdc++.h>
using namespace std;
 
#define NL '\n'
#define xx first
#define yy second
#define ll long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define async() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 
//#define FayeValentine 
void dbg(){cerr<<NL;}template<typename H,typename... T> void dbg(H h,T... t){cerr<<' '<<h;dbg(t... );}
#ifdef  FayeValentine
#define debug(...) cerr<<"("<<#__VA_ARGS__<<"):",dbg(__VA_ARGS__)
#else
#define debug(...) 
#endif


const int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};


void absinthe() {
	int n, f = 1; cin >> n;
	const int MOD = 1e9+7;
	for(int i = 0; i < 168; i++) {
		if(primes[i] > n) break;
		ll p = primes[i], cnt = 0;
		while(p <= n){
			cnt += n/p;
			p *= primes[i];
		}
		f = ((f%MOD) * ((cnt+1)%MOD)) % MOD;
	}
	cout << f << NL;
}
 
 
int main(){
  //freopen("input.txt", "r", stdin);
  async();
  int __t = 1; //cin >> __t;
  for(int __c = 1; __c <=__t; __c++) {
    //cout << "Case #" << __c << ": "; 
    absinthe();
  }
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int r;
  cin >> r;
  cout << 3 * r * r << endl;

  return 0;
}

Measured memory_bytes: 256
s=int(input())
k=s%100
l=(s-k)/100
k=int(k)
l=int(l)
if k<=12 and k>=1:
    if l>=1 and l<=12:
        ans='AMBIGUOUS'
    else:
        ans='YYMM'
elif l>=1 and l<=12:
    ans='MMYY'
else:
    ans='NA'
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

class UnionFind {
  public:
    int n;
    vector<int> rank;
    vector<int> par;

    UnionFind(int N) {
      n = N;
      rank = vector<int>(n);
      par = vector<int>(n);
      for (int i = 0; i < n; ++i) {
        rank[i] = 1;
        par[i] = i;
      }
    }

    int find(int x) {
      if (par[x] == x) {
        return x;
      } else {
        return find(par[x]);
      }
    }

    void unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x == y) return;

      if (rank[x] < rank[y]) {
        par[x] = y;
      } else {
        par[y] = x;
        if (rank[x] == rank[y]) {
          rank[x]++;
        }
      }
    }

    bool same(int x, int y) {
      return find(x) == find(y);
    }
};

int main() {
  int n, k, l;
  cin >> n >> k >> l;
  UnionFind u1 = UnionFind(n+1);
  UnionFind u2 = UnionFind(n+1);
  for (int i = 0; i < k; ++i) {
    int p, q;
    scanf("%d", &p);
    scanf("%d", &q);
    u1.unite(p, q);
  }
  for (int i = 0; i < l; ++i) {
    int p, q;
    scanf("%d", &p);
    scanf("%d", &q);
    u2.unite(p, q);
  }
  vector<int> ans(n+1, 1);
  map<pair<int,int>,int> mp;
  for (int i = 1; i <= n; ++i) {
    mp[make_pair(u1.find(i), u2.find(i))]++;
  }
  for (int i = 1; i <= n; ++i) {
    printf("%d ", mp[make_pair(u1.find(i), u2.find(i))]);
  }
  printf("\n");
}


Measured memory_bytes: 15872
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long h=sc.nextLong();
        long w=sc.nextLong();
        long res1=0,res2=0;
        if(h==1||w==1){
            System.out.println(1);
            return;
        }
        res1=((w+1)/2)*((h+1)/2);
        res2=(w/2)*(h/2);
        System.out.println(res1+res2);
    }
}

Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>

using namespace std;

int count_bits(int n)
{
  int cnt = 0;
  while (n) {
    if (n & 1) ++cnt;
    n >>= 1;
  }
  return cnt;
}

int main()
{
  int n; cin >> n;
  
  int a[16]; int x[16][15]; int y[16][15];
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    for (int j = 1; j <= a[i]; ++j) cin >> x[i][j] >> y[i][j];
  }
  
  int ans = 0;
  int limit = (1 << n);
  for (int i = 0; i < limit; ++i) {
    bool f = true;
    for (int j = 1; j <= n; ++j)
      if ((i >> (j-1)) & 1)
        for (int k = 1; k <= a[j]; ++k)
          if (((i >> (x[j][k]-1)) & 1) != y[j][k]) f = false;
    if (f) ans = max(ans, count_bits(i));
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>

using namespace std;

int
main() {
  int a, b, c;
  cin>>a>>b>>c;

  if (a+b+c >= 22) 
    cout<<"bust"<<endl;
  else
    cout<<"win"<<endl;
 
  return 0;
}



Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+10],b[n+10],c[n+10],d[n+10];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int l=0;
		for(int j=0;j<=i;j++)
		l+=a[j];
		for(int m=i;m<n;m++)
		l+=b[m];
		ans=max(ans,l);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,no,sum=0;

cin>>no;
int p = no;
while(no>0)
{
a=no%10;
no=no/10;
sum=sum+a;
}
//cout << sum;
 if(p % sum == 0){
	cout << "Yes"<<endl;
}
else if(p % sum != 0)
{
	cout << "No"<<endl; 
}
return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define Pi 3.14159265

int main(void) {
  int a, b, x;
  scanf("%d%d%d", &a, &b, &x);
  if(x <= a * a * b / 2) printf("%lf", atan((double)b * b * a / (x * 2.0)) / Pi * 180.0);
  else printf("%lf", atan(((double)a * a * b - x) * 2.0 / (double)a / a / a) / Pi * 180.0);
  return 0;
}

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

int main(){

    int a[3][3];
    bool b[3][3];

    rep(i,3){
        rep(j,3){
            cin >> a[i][j];
            b[i][j]=false;
        }
    }

    int n;
    cin >> n;
    vector<int> c(n);
    rep(i,n){
        cin >> c[i];
        rep(j,3){
            rep(k,3){
                if(c[i]==a[j][k]){
                    b[j][k]=true;
                }
            }
        }
    }

    // rep(i,3){
    //     rep(j,3){
    //         cout << b[i][j] << " ";
    //     }cout << endl;
    // }

    rep(i,3){
        bool t=true,y=true,n1=true,n2=true;
        rep(j,3){
            if(b[i][j]==false){
                y=false;
            }
            if(b[j][i]==false){
                t=false;
            }
            if(b[j][j]==false){
                n1=false;
            }
            if(b[j][2-j]==false){
                n2=false;
            }
        }

        if(t||y||n1||n2){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}

////////////////////////////////////////

int main(){
    ll n,k;cin>>n>>k;
    ll ans=0;
    if(k%2==1){
        ll t=n/k;
        ans=(ll)pow(t,3);
    }else{
        ll t=n/k;
        ll s=(n+k/2)/k;
        ans=(ll)pow(t,3)+(ll)pow(s,3);
    }
    cout<<ans<<endl;
    return 0;
}

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

#define int long long

int32_t main() {
    int t = 1;
    while(t--)
    {
    	int n, W;
    	cin >> n >> W;
    	int w[n], v[n];
    	for(int i = 0; i < n; i++)
    	    cin >> w[i] >> v[i];
    	int dp[n+1][W+1];
    	for(int i = 0; i <= n; i++)
    	{
    	    for(int j = 0; j <= W; j++)
    	    {
    	        if(i == 0 || j == 0)
    	            dp[i][j] = 0;
    	        else
    	        {
    	            int op1 = dp[i-1][j];
    	            int op2 = (j >= w[i-1]) ? (dp[i-1][j-w[i-1]] + v[i-1]) : -1e9;
    	            dp[i][j] = max(op1, op2);
    	        }
    	    }
    	}
    	cout << dp[n][W];
    }
	return 0;
}

Measured memory_bytes: 82540
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define N 10000000
ll primes[N];

//int seive()
//{
//	ll i,j,t=0,sq;
//	bool flag[N];
//	for(i=2;i<=N;i++) flag[i]=1;
//	sq=sqrt(N)+1;
//	for(i=2;i<sq;i++)
//		if(flag[i])
//			for(j=i;j*i<=N;j++)
//				flag[i*j]=0;
//	for(i=2;i<=N;i++)
//		if(flag[i])
//			primes[t++]=i;
//	return t;
//}

//     for(i=0;i<n;i++)
//     for(j=0;j<n;j++)

//int GCD(ll a, ll b)
//{
//    if(a==0)return b;
//    if(b==0)return a;
//    else return GCD(b,a%b);
//}




int main()
{
    ll i,j,k,m,n,q,t,a,b,c,r,x;
    cin>>a>>b>>c;
    x=a-b;
    r=c-x;
    if(r>0)
    cout<<r<<endl;
    else
    cout<<'0'<<endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  sort(A.begin(), A.end());
  int count = 0;
  for (int i = N-1; i >= 0; i--) {
    if (A.at(i) * 4 * M >= sum) {
      count++;
    } else {
      break;
    }
  }
  if (count >= M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3656
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int h = int.Parse(input[0]);
		int w = int.Parse(input[1]);
    long[,] matrix = new long[h,w];//行列
      
    for(int i = 0; i < h; i++)//それぞれの行
    {
    	long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    	for(int j = 0; j < w; j++) matrix[i,j] = 1-nums[j];//行の全ての成分
    }

		Console.WriteLine(LargestRectangleArea(matrix));
	}

  static long LargestRectangleArea(long[,] uses)
  {//長方形上で1の書かれたマスだけを用いた長方形の最大面積をO(HW)で返す
    long answer = 0;
    int h = uses.GetLength(0);
    int w = uses.GetLength(1);
    long[] heights = new long[w];
    for(int i = 0; i < h; i++)
    {
      for(int j = 0; j < w; j++)
      {
        if(uses[i,j] == 1) heights[j]++;
        else heights[j] = 0;
      }
      //Console.WriteLine(LargestRectangle(heights)+"a");
      answer = Math.Max(answer,LargestRectangle(heights));
    }

    return answer;
  }

  static long LargestRectangle(long[] lengths)
  {//x軸に接する底辺1、高さlengthsの長方形を繋げた時、最大長方形の面積をO(n)で返す
    if(lengths.Length == 0) return 0;
    long answer = lengths[0];
    int n = lengths.Length;
    var rectangleStack = new Stack<long[]>();//x座標と高さ
    rectangleStack.Push(new long[2]{0,lengths[0]});
    long[] topMemo = new long[2];
    
    for(int i = 1; i < n; i++)
    {
      if(rectangleStack.Count() > 0) topMemo = rectangleStack.Peek();
      
      if(topMemo[1] < lengths[i]) rectangleStack.Push(new long[2]{i,lengths[i]});
      else if(topMemo[1] > lengths[i])
      {
        long memo = 0;
        while(rectangleStack.Count() > 0)
        {
          if(rectangleStack.Peek()[1] > lengths[i])
          {
            answer = Math.Max(answer, rectangleStack.Peek()[1]*(i-rectangleStack.Peek()[0]));
            memo = rectangleStack.Peek()[0];
            
            if(rectangleStack.Count() == 1)
            {
              rectangleStack.Pop();
              rectangleStack.Push(new long[2]{memo, lengths[i]});
              break;
            }
            else rectangleStack.Pop();
          }else
          {
            rectangleStack.Push(new long[2]{memo, lengths[i]});
            break;
          }
        }
      }

      if(i == n-1 && rectangleStack.Count() > 0)
      {
        while(rectangleStack.Count() > 0)
        {
          answer = Math.Max(answer, rectangleStack.Peek()[1]*(i-rectangleStack.Peek()[0]+1));
          rectangleStack.Pop();
        }
      }
    }

    return answer;
  }
  
}


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

int h, w;
int T[1400][1400], dp[1400][1400];

class Tile {
public:
	int maxw;

	Tile() {
		maxw = 0;
		for (int i = 0; i < h; i++)	{
			dp[i][0] = T[i][0] ? 0 : 1;
			maxw |= dp[i][0]; //????????????????????§?????????????????°???
		}
		for (int j = 1; j < w; j++)	{
			dp[0][j] = T[0][j] ? 0 : 1;
			maxw |= dp[0][j];
		}
	}

	int largestSquare() { //???????????????????????????????????§????????£?????¢????????¨?¨????????°??????¢???
		for (int i = 1; i < h; i++)	{
			for (int j = 1; j < w; j++) {
				if (T[i][j]) dp[i][j] = 0;
				else dp[i][j] = min(min(dp[i - 1][j - 1], dp[i - 1][j]), dp[i][j - 1]) + 1;
				maxw = max(maxw, dp[i][j]);
			}
		}
		return maxw * maxw;
	}

};

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++)	{
		for (int j = 0; j < w; j++) {
			cin >> T[i][j];
		}
	}
	Tile t = Tile();

	cout << t.largestSquare() << endl;
	return 0;

}

Measured memory_bytes: 16472
s = input()
n = len(s)
mod = 10 ** 9 + 7
dp = [[0] * 4 for i in range(n + 1)]
dp[0][0] = 1

for i in range(n):
    if s[i] == "A":
        dp[i + 1][1] = dp[i + 1][1] + dp[i][0]
        dp[i + 1][0] += dp[i][0]
        dp[i + 1][1] += dp[i][1]
        dp[i + 1][2] += dp[i][2]
        dp[i + 1][3] += dp[i][3]
    elif s[i] == "B":
        dp[i + 1][2] = dp[i + 1][2] + dp[i][1]
        dp[i + 1][0] += dp[i][0]
        dp[i + 1][1] += dp[i][1]
        dp[i + 1][2] += dp[i][2]
        dp[i + 1][3] += dp[i][3]
    elif s[i] == "C":
        dp[i + 1][3] = dp[i + 1][3] + dp[i][2]
        dp[i + 1][0] += dp[i][0]
        dp[i + 1][1] += dp[i][1]
        dp[i + 1][2] += dp[i][2]
        dp[i + 1][3] += dp[i][3]
    else:
        for j in range(4):
            dp[i + 1][j] += 3 * dp[i][j]
        dp[i + 1][1] += dp[i][0]
        dp[i + 1][2] += dp[i][1]
        dp[i + 1][3] += dp[i][2]
    for j in range(4):
        dp[i + 1][0] %= mod
        dp[i + 1][1] %= mod
        dp[i + 1][2] %= mod
        dp[i + 1][3] %= mod

print(dp[n][3] % mod)

Measured memory_bytes: 27580
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	int a,b,c;cin>>a>>b>>c;
	int x,y;cin>>x>>y;
	if(c*2<=a+b){
		cout<<min(max(x,y)*c*2,min(x,y)*c*2+(max(x,y)-min(x,y))*(x<y?b:a))<<endl;
	}
	else{
		cout<<a*x+b*y<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	vector<ll> ans(10001);
	for (int x = 1; x <= 10000; ++ x) {
		for (int y = x; ; ++ y) {
			int n1 = x*x + y*y + x*y;
			if (n1 > 10000) break;
			for (int z = y; ; ++ z) {
				int n = n1 + z*z + y*z + z*x;
				if (n > 10000)  break;
				if (x == y && y == z) ans[n] += 1;
				else if (x == y || x == z || y == z) ans[n] += 3;
				else ans[n] += 6;
			}
		}
	}
	int N;
	cin >> N;
	for (int i = 1; i <= N; ++ i) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
 int n;
 cin >> n;
 
    vector<int> d(n);
    rep(i,n) {
     cin >> d.at(i);
    }
    
    sort(d.begin(),d.end());
    int mid = d.at(n/2-1);
    
    if(d.at(n/2) == mid) {
     cout << 0;
    }
    else {
        cout << d.at(n/2) - d.at(n/2-1);
    }
}

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

int main() {
    int n;
    long long k;
    cin >> n >> k;
    vector<long long> a(n), b(n), c(n);
    for (auto& e : a) cin >> e;
    for (auto& e : b) cin >> e;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), greater<long long>());
    for (int i = 0; i < n; i++) c[i] = a[i] * b[i];
    
    auto f = [&] (long long m) {
        long long cnt = 0;
        for (int i = 0; i < n; i++) {
            long long d = max(0LL, c[i]-m);
            cnt += ((d + b[i] - 1) / b[i]);
        }
        return cnt <= k;
    };
    
    long long ok = 1e18, ng = -1;
    while (abs(ok - ng) > 1) {
        long long x = (ok + ng) / 2;
        if (f(x)) ok = x;
        else ng = x;
    }
    
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 4992
n = int(input())
b = list(map(int, input().split()))
a = []
while b != []:
  best_match = -1
  for i in range(1, len(b)+1):
    if b[i-1] == i:
      best_match = i
  if best_match == -1:
    print(-1)
    exit(0)
  else:
    a.append(best_match)
    del b[best_match-1]
for num in a[::-1]:
  print(num)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin >> s;
    
    int a = 0, b = 0;
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0 && char(s[i]) == '1') a++;
        if (i % 2 == 1 && char(s[i]) == '0') a++;
    }
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0 && char(s[i]) == '0') b++;
        if (i % 2 == 1 && char(s[i]) == '1') b++;
    }
    
    cout << min(a, b) << endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;

namespace at
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());            
            int h = int.Parse(Console.ReadLine());
            int w = int.Parse(Console.ReadLine());         
            int x = 0;
            int b = 0;

            if(h>1)
            {
                int z = n - h;
                x = z + 1;
            }
            if(w>1)
            {
                int a = n - w;
                b = a + 1;
            }
            if(w==1)
            {
                b = n/w;
            }
            if(h==1)
            {
                x = n/h;
            }

            Console.WriteLine( x * b );
        }
    }
}


Measured memory_bytes: 11092
n = int(input())
H = list(map(int, input().split()))

out = "Yes"

now_height = H[0]
if now_height > 0:
    now_height -= 1

for i in range(1, n):
    if now_height <= H[i] - 1:
        now_height = H[i] - 1
    elif now_height <= H[i]:
        now_height = H[i]
    else:
        out = "No"
        break

print(out)

Measured memory_bytes: 14396
using System;
class Program
{
    public static void Main()
    {
        string[] imp = Console.ReadLine().Split(' ');
        int h, w;
        h = int.Parse(imp[0]);
        w = int.Parse(imp[1]);
        char[,] c1 = new char[h, w];
        char[,] c2 = new char[2 * h, w];
        char[] imp2;
        for (int i = 0; i < h; i++)
        {
            imp2 = Console.ReadLine().ToCharArray();
            for (int j = 0; j < w; j++)
                c1[i, j] = imp2[j];
        }
        for (int i = 0; i < 2 * h; i++)
            for (int j = 0; j < w; j++)
                c2[i, j] = c1[i / 2, j];
        for (int i = 0; i < 2 * h; i++)
        {
            for (int j = 0; j < w; j++)
                Console.Write(c2[i, j]);
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 11220
#include <stdio.h>

int main(void) {
	int n,i;
	int aone,bone;
	int a,b;
	while(1) {
		scanf("%d",&n);
		if(n==0)break;
		a=b=0;
		for(i=0;i<n;i++) {
			scanf("%d %d",&aone,&bone);
			if(aone>bone)a+=aone+bone;
			else if(aone<bone)b+=aone+bone;
			else {
				a+=aone;
				b+=bone;
			}
		}
		printf("%d %d\n",a,b);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int x = sc.nextInt();
        int n = sc.nextInt();

        if(n == 0){
            System.out.println(x);
            return;
        }else {

            List<Integer> p = new ArrayList<>();
            for (int i = 0; i < n; i++){
                p.add(sc.nextInt());
            }


            int minValue = Integer.MAX_VALUE;
            int ans = 101;
            for (int i = 0; i <= 101; i++) {
                for(int j = 0; j < n; j++) {
                    if(!p.contains(i)){
                        if (minValue > Math.abs(i - x)) {
                            minValue = Math.abs(i - x);
                            ans = i;
                        }
                    }
                }
            }

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


Measured memory_bytes: 27492
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-
// ALDS1_3-A: Stack

#include <cassert>
#include <cstdio>
#include <cstdlib>

template <int N>
class stack {
  unsigned int top_ = 0; // C++11
  int ds_[N];
public:
  inline int pop() {
    assert(!is_empty());
    return ds_[--top_];
  }
  inline void push(int i) {
    assert(!is_full());
    ds_[top_++] = i;
  }
  inline bool is_empty() { return top_ == 0; }
  inline bool is_full() { return top_ == N; }
};

template <int N>
class calc {
  stack<N> stack_;
public:
  inline void add() {
    int b = stack_.pop();
    int a = stack_.pop();
    stack_.push(a+b);
  }
  inline void sub() {
    int b = stack_.pop();
    int a = stack_.pop();
    stack_.push(a-b);
  }
  inline void mul() {
    int b = stack_.pop();
    int a = stack_.pop();
    stack_.push(a*b);
  }    
  inline int pop() { return stack_.pop(); }
  inline void push(int i) { stack_.push(i); }
  inline bool is_empty() { return stack_.is_empty(); }
};

int main(void) {
  calc<100> calc; // ns <= 100
  char buf[6+1]; // n <= 10**6 or '+',etc == 1
  
  while (std::scanf("%6s", buf) != EOF) {
    switch (buf[0]) {
    case '+':
      calc.add(); break;
    case '-':
      calc.sub(); break;
    case '*':
      calc.mul(); break;
    default:
      calc.push(std::atoi(buf)); break;
    }
  }
  printf("%d\n", calc.pop());
  assert(calc.is_empty());

  return 0;
}
// end

Measured memory_bytes: 2612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}

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

int n, m;
vector<pair<int,int>> bri;

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N, -1) { }

    int root(int x) { //根を得る
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { //結合
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
    }

    bool same(int x, int y) { //同根？
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) { //属する木のサイズを得る
        return -par[root(x)];
    }
};

signed main() {
    cin >> n >> m;
    bri.resize(m);
    for (int i = 0; i < m; i++) {
        int u, v;
        scanf("%Ld%Ld", &u, &v);
        u--; v--;
        bri[i] = pair<int,int>(u,v);
    }
    reverse(bri.begin(), bri.end());

    UnionFind tree(n);
    int inconv = n*(n-1)/2;
    vector<int> res(m);
    for (int i = 0; i < m; i++) {
        res[i] = inconv;
        int a = bri[i].first;
        int b = bri[i].second;
        if (!tree.same(a,b)) {
            inconv -= tree.size(a) * tree.size(b);
            tree.unite(a,b);
        }
    }
    for (int i = m-1; i >= 0; i--) printf("%Ld\n", res[i]);
}

Measured memory_bytes: 4480
N = int(input())
A = list([int(x) for x in input().split()])

result = [0] * N
x = 0
for key, i in enumerate(A):
    if key % 2 == 0:
        x += i
    else:
        x -= i

result[0] = x

for i in range(1, N):
    result[i] = 2 * A[i-1] - result[i-1]

print(' '.join([str(x) for x in result]))


Measured memory_bytes: 24932
#include <bits/stdc++.h>
#define rep(i , n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
    int N, s{}, m{100};
    cin >> N;
    while(cin >> N) {
        s += N;
        if (N % 10){
            m = min(m , N);
        }
    }
    if (m == 100){
        s = 0;
    }
    else if (s % 10 == 0){
        s -= m;
    }
    cout << s << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
int main()
{
  int n, d, ans = 0;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i, n)
  {
    rep(j, d) cin >> x[i][j];
  }
  rep(i, n)
  {
    rep(j, i)
    {
      int sq = 0;
      rep(k, d)
      {
        int s = x[i][k] - x[j][k];
        sq += s * s;
      }
      int t = sqrt(sq) + 0.5;
      if (t * t == sq)
        ans++;
    }
  }
  cout << ans << endl;
}

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

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))

int main()
{
	int N, M;
	int L[100000];
	int R[100000];
	int max, min;

	scanf("%d%d", &N, &M);

	for (int i = 0; i < M; i++)
		scanf("%d%d", &L[i], &R[i]);

	min = 1, max = N;


	for (int i = 0; i < M; i++)
	{
		if (L[i] > min)
			min = L[i];
		if (R[i] < max)
			max = R[i];
	}

	if (max - min + 1 > 0)
		printf("%d", max - min + 1);
	else
		printf("0\n");
		
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int64_t INF = 1000100;//1LL << 60;

int main() {
  int N,M;cin>>N>>M;
  vector<bool>ok(N+1,true);
  vector<int>a(M);
  for(int i=0;i<M;i++){
    cin>>a[i];
    ok[a[i]]=false;
  }
  vector<int>dp(N+1);

  dp[0]=1;
  if(ok[1]==true){dp[1]=1;}

  for(int i=2;i<=N;i++){
    if(ok[i-1]==true){dp[i]+=dp[i-1];}
    if(ok[i-2]==true){dp[i]+=dp[i-2];}
    dp[i]%=1000000007;
  }
  cout<<dp[N]<<endl;
  return 0;}

Measured memory_bytes: 1024