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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

class UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<int> size;
    vector<vector<int>> group;
public:
    UnionFind(int n = 1) {
        par.resize(n + 1);
        rank.resize(n + 1);
        size.resize(n + 1);
        group.resize(n + 1);
        for (int i = 0; i <= n; ++i) {
            par[i] = i;
            rank[i] = 0;
            size[i] = 1;
            group[i].push_back(i);
        }
    }

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

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

    bool unit(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return false;
        } else {
            if (rank[x] < rank[y]) {
                swap(x, y);
            }
            if (rank[x] == rank[y]) {
                ++rank[x];
            }
            par[y] = x;
            size[x] += size[y];
            return true;
        }
    }

    int get_size(int x) {
        return size[find(x)];
    }

    void merge(int x, int y) {
        x = find(x);
        y = find(y);
        if (group[x].size() > group[y].size()) {
            swap(x, y);
        }
        copy(group[y].begin(), group[y].end(), back_inserter(group[x]));
        group[y].clear();
        par[y] = x;
    }
};

void solve() {
    ll N, Q;
    cin >> N >> Q;
    UnionFind unionFind(N);
    rep(q, Q) {
        ll t, u, v;
        cin >> t >> u >> v;
        if (t) {
            cout << unionFind.is_same(u, v) << '\n';
        } else {
            unionFind.unit(u, v);
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

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

    int a, b;
    cin >> a >> b;
    cout << max({2*a - 1, 2*b - 1, a + b}) << '\n';
    return 0;
}


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

int main(){
  int ans=0,n,p[21];
  
  cin >> n;

  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  for(int i=1;i<n-1;i++){
    if(p[i-1]<p[i] && p[i]<p[i+1]){
      ans++;
    }else if(p[i+1]<p[i] && p[i]<p[i-1]){
      ans++;
    }
  }
  
  cout << ans << '\n';
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

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 main() {
	int a, b;
	cin >> a >> b;
	
	int ans = max(a - b * 2, 0);

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll MOD = 1000000007;

int main(){
  ll N;
  cin >> N;

  ll sqN = (ll)(sqrt(N)) + 1;
  
  vl primes(N + 1, 1);
  primes[0] = primes[1] = 0;
  rep2(i, 2, sqN + 1){
    if(primes[i] != 0){
      ll j = 2;
      while(i*j <= N){
	primes[i*j] = 0;
	j++;
      }
    }
  }

  ll ans = 1;
  
  rep(i, N + 1){
    if(primes[i] == 0) continue;

    ll cnt = 0;
    ll j = i;

    while(j <= N){
      cnt += N / j;
      j *= i;
    }

    ans = ans * (cnt + 1) % MOD;
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
  int ans=0;;
  for(int i=0;i<5;i++){
  cin>>n;
    if(n==0){
	ans=i+1;
      break;
    }
  }
  
  cout<<ans;
return 0;
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    int a, b, c, ans;
    while(cin>>n>>x) {
        if(n==0 && x==0) break;
        ans=0;
        for(a=1; a<n; a++) {
            for(b=a+1; b<n; b++) {
                c=x-a-b;
                if(b<c && c<=n) ans++;
            }
        }
        cout<<ans<<'\n';
    }
    return 0;
}

Measured memory_bytes: 1196
import std.stdio;
import std.ascii;
import std.bigint;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
import std.numeric;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void main()
{
    auto nm = aryread;
    long N = nm[0];
    long M = nm[1];

    auto ps = factorize(M).values;
    BigInt result = 1;

    foreach (p; ps)
    {
        BigInt a = iota(1, p + 1).map!BigInt.reduce!((a, b) => a * b);
        BigInt b = iota(p).map!BigInt.map!(x => N + x)
            .reduce!((a, b) => a * b);
        result *= b / a;
    }
    (result % (10 ^^ 9 + 7)).writeln;
}

long[long] factorize(long x)
{
    long[long] ps;
    while ((x & 1) == 0)
    {
        x /= 2;
        ps[2] = (2 in ps) ? ps[2] + 1 : 1;
    }
    for (long i = 3; i <= x; i += 2)
        while (x % i == 0)
        {
            x /= i;
            ps[i] = (i in ps) ? ps[i] + 1 : 1;
        }
    return ps;
}


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

int main()
{
    int n, m;

    cin >> n >> m;

    vector<int> k(m);
    vector<vector<int>> s(m, vector<int>(n));
    vector<int> p(m);

    for (int i = 0; i < m; i++)
    {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++)cin >> s[i][j];
    }
    for (int i = 0; i < m; i++)cin >> p[i];

    int ans = 0;
    int i,j,l;
    for (i = 0; i < (1 << n); i++)
    {
        bitset<10> on_off_bit(i);
        for (j = 0; j < m; j++)
        {
            int buf = 0;
            for (l = 0; l < k.at(j); l++)
            {
                if(on_off_bit.test(s.at(j).at(l) - 1))buf++;
            }
            if(buf % 2 != p.at(j))break;
        }
        if(j == m)ans++;
    }
    
    cout << ans << endl;
}

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

#define PI 3.1415926535897932384662433832795028841971
#define pb push_back

typedef long long ll;

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

	string s, t;
	cin >> s >> t;
	
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != t[i]) {
			cout << "No\n";
			return 0;
		}
	}
	
	cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int zero;
    string s="0 1 2 3 4 5 6 7",ans="0 1 2 3 4 5 6 7";
    queue<pair<string,int>> q;
    q.push(make_pair(s,0));
    unordered_map<string,int> m;
    pair<string,int> ps;
    string now;
    int count;
    while(!q.empty()){
        ps=q.front();q.pop();
        now=ps.first;
        count=ps.second;
        m[now]=count;
        zero = now.find('0');
        if((0<=zero&&zero<=4) || (8<=zero&&zero<=12)){
            swap(now[zero],now[zero+2]);
            if(m.find(now) == m.end())
                q.push(make_pair(now,count+1));
            swap(now[zero],now[zero+2]);
        }
        if((2<=zero&&zero<=6) || (10<=zero&&zero<=14)){
            swap(now[zero],now[zero-2]);
            if(m.find(now) == m.end())
                q.push(make_pair(now,count+1));
            swap(now[zero],now[zero-2]);
        }
        if(zero<=6){
            swap(now[zero],now[zero+8]);
            if(m.find(now) == m.end())
                q.push(make_pair(now,count+1));
            swap(now[zero],now[zero+8]);
        }
        if(8<=zero){
            swap(now[zero],now[zero-8]);
            if(m.find(now) == m.end())
                q.push(make_pair(now,count+1));
        }
    }
    while(getline(cin,s)){
        cout<<m[s]<<endl;
    }
}






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

int main()
{
    string s;
    cin >> s;
    int sz = s.size();
    if(s[0] != 'A') return cout << "WA\n", 0;
    int cnt = 0;
    for(int i = 1; i < sz; ++i)
    {
        if(isupper(s[i]))
        {
            if(i == 1 || i == sz - 1 || s[i] != 'C') return cout << "WA\n", 0;
            ++cnt;
        }
    }
    if(cnt != 1) return cout << "WA\n", 0;
    cout << "AC\n";
}

Measured memory_bytes: 3604
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
//use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;

fn main() {
    proconio::input! {
        n:i64,m:i64
    }

    println!("{}", (n * (n - 1) + m * (m - 1)) / 2);
}


Measured memory_bytes: 2116
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
long long int A[100005];
int main()
{
	long long int n, k, q, m;
	while(cin >> n >> k >> q)
	{
		memset(A, 0, sizeof(A));
		for(long long int i = 1; i <= n; i++) A[i] = k - q;
		for(long long int i = 1; i <= q; i++)
		{
			scanf("%lld", &m);
			A[m]++;
		}
		for(long long int i = 1; i <= n; i++)
			if(A[i] <= 0) cout << "No" << endl;
			else cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>

using namespace std;

typedef pair<int, string> P;

main(){
  int n;
  while(cin >> n && n){
    P data[21];
    int d[21][31];
    int cnt[30];
    int m[21];
    fill(cnt, cnt+30, 0);
    for(int i=0;i<n;i++){
      data[i].first = 0;
      cin >> data[i].second;
      cin >> m[i];
      for(int j=0;j<m[i];j++){
        cin >> d[i][j];
        cnt[d[i][j]]++;
      }
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<m[i];j++){
        data[i].first += n - cnt[d[i][j]] + 1;
      }
    }
    sort(data, data+n);
    cout << data[0].first << ' ' << data[0].second << endl;
  }
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    ll a, b, k; cin >> a >> b >> k;
    rep(i, 0, k) {
        if (i % 2 == 0) {
            if (a & 1) a--;
            b += a / 2;
            a -= a / 2;
        } else {
            if (b & 1) b--;
            a += b / 2;
            b -= b / 2;
        }
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef pair<int, int> pii;

int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		string a;
		int mi, ma;
		cin >> a;
		sort(all(a));
		mi = atoi(a.c_str());
		reverse(all(a));
		ma = atoi(a.c_str());
		cout << ma - mi << endl;
	}
}

Measured memory_bytes: 1232
s = input()[::-1]
l = len(s)
x = [0 for _ in range(2019)]
x[0] += 1
k = 0
p = 1
for si in s:
    k += int(si) * p % 2019
    k %= 2019
    x[k] += 1
    p *= 10
    p %= 2019
 
ans = 0
for xi in x:
    ans += max(0, xi * (xi - 1) // 2)
print(ans)

Measured memory_bytes: 9244
#include<iostream>
#include <numeric>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {
	ull A, B;
	cin >> A >> B;
	
	ull X = A * B;
 
	if(A < B){
		ull tmp = A;
		A = B;
		B = tmp;
	}
 
	ull R = A % B;
	while(R != 0){
		A = B;
		B = R;
		R = A % B;
	}
 	
	cout << X / B;
	
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int d=0;
  for(int i=0; i<s.size(); i++){
    if(i%2 == 0){
      if(s.at(i) == 'L'){
        cout << "No" << endl;
        d++;
        break;
      }
    }
    else{
      if(s.at(i) == 'R'){
        cout << "No" << endl;
        d++;
        break;
      }
    }
  }
  if(!d){
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

		int n, k;
	cin >> n >> k;
	for (int i = k - n + 1; i < k + n; i++)
		cout << i << ' ';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Vsort(a) sort(a.begin(), a.end())
#define ll long long
using namespace std;

int main() {
  
  ll int N;
  cin >> N;
  ll int c, d, e;
  ll int count = 0;
  
  ll int A[N];
  for(ll int i = 0; i < N; i++){
    cin >> A[i];
  }
  
  for(ll int i = 0; i < N - 1; i++){
    c = A[i];
    d = A[i + 1];
    if(c > d){
      e = c - d;
      count += e;
      A[i + 1] += e;
    }
  }
  
  cout << count;
  
  return 0;
}


Measured memory_bytes: 5128
#include <iostream>
using namespace std;
int main() {
  int A[100][100];
  int B[100][100];
  long C[100][100] = {};
  int i, j, k, n, m, l;
  cin >> n >> m >> l;
  for(i = 0; i < n; i++) {
	for(j = 0; j < m; j++) {
	  cin >> A[i][j];
	}
  }
  for(i = 0; i < m; i++) {
	for(j = 0; j < l; j++) {
	  cin >> B[i][j];
	}
  }
  for(i = 0; i < n; i++) {
	for(j = 0; j < l; j++) {
	  for(k = 0; k < m; k++) {
		C[i][j] += A[i][k] * B[k][j];
	  }
	}
  }
  for(i = 0; i < n; i++) {
	for(j = 0; j < l; j++) {
	  cout << C[i][j];
	  if(j < l - 1) { cout << " "; }
	  else { cout << endl; }
	}
  }
  return 0;
}

Measured memory_bytes: 3228
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		for(int i = 0;i < n;i++) {
			itemList[i] = sc.next();
		}
		Arrays.sort(itemList);
		int answer = 1;
		for(int i = 1;i < n;i++) {
			if(!itemList[i].equals(itemList[i -1])) {
				answer++;
			}
		}
		System.out.println(answer);



	}
}

Measured memory_bytes: 62240
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b, c;
    cin >> a >> b >> c ;
    //*/
    
    /*
    vector<int> vec(4);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    */
    
    //*
    if(b >= c - a && c - a >= 0 ){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    //*/
    
    //cout << min(a, b) + min(c, d) << endl;

    return 0; 
}


Measured memory_bytes: 3620
n = int(input())
a = [int(i) for i in input().split()]

for i in range(len(a)):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j]>v:
        a[j+1] = a[j]
        j-=1
    a[j+1]=v
    print(" ".join([str(i) for i in a]))

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;

    map<char, int> cnt;
    vector<bool> isWin(n, false);
    cnt['r'] = 0;
    cnt['s'] = 0;
    cnt['p'] = 0;
    for(int i = 0; i < n; i++)
    {
        if(i <= k - 1)
        {
            cnt[t[i]]++;
            isWin[i] = true;
        }
        else
        {
            if(t[i] == t[i - k] && isWin[i - k])
                continue;
            else
            {
                cnt[t[i]]++;
                isWin[i] = true;
            }
        }
    }

    int ans = 0;
    for(auto a : cnt)
    {
        if(a.fst == 'r')
            ans += a.snd * p;
        else if(a.fst == 's')
            ans += a.snd * r;
        else
            ans += a.snd * s;
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define mkpr(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()

typedef long long int ll;

ll general,total;
//ll num[ten5];
//ll num2[ten5];
//char cmap[10][10];
//priority_queue<ll> pqll;   //decrease
//priority_queue<double> pqd;
//stack<int> stk;
//vector<pair<ll,ll>> vpll;
//vector<pair<double,double>> vpdd;
//vector<ll> vll[ten52];
//vector<double> vd;
//deque<ll> deq[55];
//list<int> li;
//set<int> sint;
//set<ll> sll;
//set<char> sch;
set<string> sStr;
//map<ll,ll> mp;

ll numR[4000],numG[4000],numB[4000];

/*ll cmp(pair<ll,ll> a,pair<ll,ll> b)
{
    return a.first<b.first;
    //arrising
}*/


int main()
{
    long long int sum,sum2;
    long long int m,n,o,i,j,k=1;
    long long int a,a1,a2,a3,a4,a5,a6;
    string s;
    sum=sum2=0;
    a=a1=a2=a3=a4=a5=a6=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s;
        if(sStr.find(s)==sStr.end())
            sStr.insert(s);
    }
    cout<<sStr.size();
    return 0;
}





Measured memory_bytes: 19184
import sys
sys.setrecursionlimit(10**7)


def dfs(now):
    global ans
    if len(now) == N:
        tmp_ans = 0
        for a, b, c, d in query:
            a -= 1
            b -= 1
            if now[b] - now[a] == c:
                tmp_ans += d
        ans = max(tmp_ans, ans)
    else:
        for i in range(now[-1], M+1):
            tmp = now.copy()
            tmp.append(i)
            dfs(tmp)


N, M, Q = map(int, input().split())  # N個の数列, 上限M, Q個のクエリ
query = [list(map(int, input().split())) for _ in range(Q)]

A = [1]
ans = 0
dfs(A)
print(ans)


Measured memory_bytes: 9244
//ABC 132 D Blue and Red Balls

#include <iostream>
typedef long long ll;
using namespace std;

ll MOD=1e9+7;

int dp[2001][2001];

int main() {
    int N, K;
    cin >> N >> K;

    dp[0][0] = 1;
    for(int i=1; i<2001; i++) {
        for(int j=0; j<=i; j++) {
            if(i==j || j==0) dp[i][j] = 1;
            else dp[i][j] = (dp[i-1][j-1] + dp[i-1][j])%MOD;
        }
    }

    for(int i=1; i<=K; i++) {
        cout << ((ll)dp[N-K+1][i] * (ll)dp[K-1][i-1])%MOD << endl;
    }

    return 0;
}


/*

for(int i=1; i<=k; i++)

n-k+1 C i * k-1 C i-1

*/


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;


int main(){
  LL n,l,t;
  cin >> n >> l >> t;
  vector<LL> left(n),right(n);
  LL x,w;
  LL leftcount=0,rightcount=0;
  bool zeroleft=false;
  for(int i=0;i<n;i++){
    cin >> x >> w;
    if(w==1){
      right[rightcount++]=x;
    }else{
      left[leftcount++]=x;
    }
  }
  LL num=leftcount*(t/l)+distance(left.begin(),lower_bound(left.begin(),left.begin()+leftcount,t%l))-(rightcount*(t/l)+rightcount-distance(right.begin(),lower_bound(right.begin(),right.begin()+rightcount,l-t%l)));
  // cout << distance(left.begin(),upper_bound(left.begin(),left.begin()+leftcount,t%l)) << endl;
  // cout << rightcount-distance(right.begin(),lower_bound(right.begin(),right.begin()+rightcount,l-t%l)) << endl;
  // cout << num << endl;
  vector<LL> pos(n);
  for(int i=0;i<rightcount;i++){
    right[i]=(right[i]+t%l)%l;
    pos[i]=right[i];
  }
  for(int i=0;i<leftcount;i++){
    left[i]=((left[i]-t%l)%l+l)%l;
    pos[i+rightcount]=left[i];
  }
  sort(pos.begin(),pos.end());
  vector<LL> ans(n);
  for(int i=0;i<n;i++){
    ans[((num+i)%n+n)%n]=pos[i];
  }
  for(int i=0;i<n;i++) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 4352
a,b,c,x,y = map(int,input().split())
if 2*c >= a+b:
    ans = a*x + b*y
elif 2*c <= min(a,b) or (2*c<=a and x >= y) or (2*c<=b and y>= x):
    ans = 2*c*max(x,y)
elif x >= y:
    ans = 2*c*y+a*(x-y)
else:
    ans = 2*c*x+b*(y-x)
print(ans)


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

int main(){
    ll h,n;
    cin >> h >> n;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        h -= a;
    }
    if(h<=0) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import deque, defaultdict

    h, w = map(int, readline().split())
    que = deque()
    grid = [["#"] * (w + 2)]

    for row in range(1, h + 1):
        s = input()
        for col, c in enumerate(s, 1):
            if c == "#":
                que.append((row, col, 0))
        grid.append(["#"] + list(s) + ["#"])

    grid.append(["#"] * (w + 2))
    direction = [(0, 1), (1, 0), (-1, 0), (0, -1)]
    cnt = 0

    while que:
        cr, cc, cnt = que.popleft()
        for mr, mc in direction:
            nr, nc = cr + mr, cc + mc
            if grid[nr][nc] == ".":
                que.append((nr, nc, cnt + 1))
                grid[nr][nc] = "#"

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 113004
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    int a[300001]={};
    int n; cin>>n;
    string s; cin>>s;
    FOR(i,0,n){
        if(s[i]=='E') a[i]=0;
        else a[i]=1;
    }
    int b[300002]={},c[300002]={};
    FOR(i,0,n){
        b[i+1]=b[i]+a[i];
    }
    ROF(i,0,n){
        c[i+1]=c[i+2]+(1-a[i]);
    }
    int m=INF;
    FOR(i,1,n+1){
        int k=b[i-1]+c[i+1];
        m=min(m,k);
    }
    co(m);
}


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


int main()
{
	
	string st;
	int num = 0;

	while (1){
		cin >> st;
		num = 0;
		if (st == "0")break;
		for (int i = 0; i < st.length(); i++){
			num += st[i] - '0';
		}
		cout << num << endl;
	}

	return 0;
}


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

const int N = 3054, M = N * 2;

int n, E = 0;
int to[M], first[N], next[M];
int a[N];

inline void addedge(int u, int v) {
	to[++E] = v, next[E] = first[u], first[u] = E;
	to[++E] = u, next[E] = first[v], first[v] = E;
}

bool dfs(int x, int px = 0) {
	int i, y; bool r = true;
	for (i = first[x]; i && r; i = next[i])
		if ((y = to[i]) != px && a[y] < a[x]) r &= dfs(y, x);
	return !r;
}

int main() {
	int i, u, v; bool first = true;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i) scanf("%d", a + i);
	for (i = 1; i < n; ++i) scanf("%d%d", &u, &v), addedge(u, v);
	for (i = 1; i <= n; ++i) if (dfs(i)) first ? first = false : putchar(32), printf("%d", i);
	return putchar(10), 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >>n;
vector <double>num(n,0);
for(int i=0;i<n;i++){
cin >> num.at(i);
}
sort(num.begin(),num.end(),greater<>());  
for(int i=0;i<n-1;i++){
double l,m;
l= num.back();
num.pop_back();
m= num.back();
num.pop_back();
num.push_back((l+m)/2);
}
double ans = num.back();
  
  
cout << ans <<endl; 
}



Measured memory_bytes: 3828
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        for (int i = 1; i <= b; i++) {
            if (a == c || a + i == c) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}

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

int main(){
  string type;
  string qwer = "qwerttasdfgzxcvb";
  string yuio = "yuiophjklnm";
  
  while ( 1 ){
    cin >> type;
    if ( type == "#" ) break;
    int LR = 0;
    int count = 0;  //sayuukirikawari
    for ( int i = 0; i != type.size(); i++ ){
      if ( LR == 0 ){
	for ( int j = 0; j != qwer.size(); j++ ){
	  if ( type[i] == qwer[j] ){
	    LR++;
	    count++;
	    if ( i == 0 ) count--;
	    break;
	  }
	}
      }else{
	for ( int j = 0; j != yuio.size(); j++ ){
	  if ( type[i] == yuio[j] ){
	    LR--;
	    count++;
	    break;
	  }
	}
      }
    }
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int64_t> A(N);
  rep(i, N) cin >> A[i];

  int64_t answer = 0;
  for (int i = 0; i < N - 1; ++i) {
    for (int j = i + 1; j < N; ++j) {
      int64_t diff = abs(A[i] - A[j]);
      answer = max(answer, diff);
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i; j <= n; j += i) {
                ans += j;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35600
#include <stdio.h>

int main(void) {
	int a, b, c;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	if (a < b && b < c) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}



Measured memory_bytes: 2140
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
#print(A1,A2)

ans = 0
for i in range(N):
  sumAs = sum(A1[:i+1]) + sum(A2[i:])
#  print(sumAs)
  if ans <= sumAs:
    ans = sumAs
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1000100100;

int main() {
    string S;
    cin >> S;

    ll ans = INF;
    for(ll i = 0; i + 2 < S.length(); ++i) {
        ll tmp = stoi(S.substr(i, 3));
        if(abs(753 - tmp) < ans) {
            ans = abs(753 - tmp);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;

void Shiritori() {
	int N;
	cin >> N;
	map<string, int> m;
	string bef = "";
	for (size_t i = 0; i < N; i++)
	{
		string w;
		cin >> w;
		m[w]++;
		if (m[w] == 2) {

			cout << "No" << "\n";
			return;
		}
		if (i > 0) {
			if (bef[bef.size() - 1] != w[0]) {
				cout << "No" << "\n";
				return;
			}
		}
		bef = w;
	}

	cout << "Yes" << "\n";
}

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

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        System.out.println(str.charAt(2) == str.charAt(3) && str.charAt(4) == str.charAt(5) ?
                "Yes" : "No");
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll power(ll x, ll n) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	
	ll a[n+5],a1[n+5];
	ll mx = 0;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		a1[i]=a[i];
		mx = max(mx,a[i]);
	}
	
	map<ll,ll> pam;
	for(ll i=0;i<n;i++)
	{
		map<ll,ll> pam2;
		while(a[i]%2==0)
		{
			a[i]/=2;
			pam2[2]++;
		}
		for(ll j=3;j*j<=a[i];j++)
		{
			while(a[i]%j==0)
			{
				pam2[j]++;
				a[i]/=j;
			}
		}
		if (a[i]>2)
			pam2[a[i]]++;

		for(auto p = pam2.begin();p!=pam2.end();++p)
		{
			pam[(*p).first] = max(pam[(*p).first],(*p).second);
		}
	}
	ll res=1;
	for(auto p = pam.begin();p!=pam.end();++p)
	{
		//cout<<(*p).first<<" "<<(*p).second<<"\n";
	
		res=(res*(power((*p).first,(*p).second))%mod);
	}
	//cout<<res<<"\n";
    ll ans = 0;
    for(ll i=0;i<n;i++)
    {
    	ll Ans = power(a1[i],mod-2);
    	Ans*=res;
    	if (Ans>=mod)
    		Ans%=mod;
    	ans+=Ans;
    	ans%=mod;
    }
    cout<<ans;
}

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


int MOD=1000000007;
int main(void){
	int A,B;
	cin >> A >> B;
	if(A<=9 && B<=9){
		cout << A*B << endl;
		return 0;
	}
	cout << "-1" << endl;
}


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

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if ((a==5||b==5||c==7)&&(a==5||b==7||c==5)&&(a==7||b==5||c==5))
	{
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define len(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>

signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  cout << b + a - 2 * a * (b % a != 0) << endl;
  ret;
}


Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n, a[101];
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		if(a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0){
			cout << "DENIED" << endl;
			return 0;
		}
	cout << "APPROVED" << endl;
    return 0;
}

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

typedef long long ll;

#define rep(i,n) for(int i = 0; i < n; i++)
#define debug(x) cerr << #x << ": " << x << "\n";

using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }

int main(){
  ll K;
  cin >> K;

  ll ans = 0;
  for(ll a=1; a<=K; a++){
    for(ll b=1; b<=K; b++){
      for(ll c=1; c<=K; c++){
	ll ab = gcd(a,b);
	ans += gcd(ab,c);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a,b;
cin>>a>>b;
cout<<a*b<<endl;
    return 0;
}

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

int main(void) {
	list<int> li;
	list<int>::iterator it = li.begin();
	int q, i, com, x;
	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> com;
		if (com == 0) {
			cin >> x;
			it = li.insert(it, x);
		} else if (com == 1) {
			cin >> x;
			for (int i = 0; i < abs(x); i++) {
			    if (x > 0) 
			        it++;
		        else
		            it--;
			}
		} else {
			it = li.erase(it);
		}
	}
	for (it = li.begin(); it != li.end(); it++)
		cout << *it << endl;
}


Measured memory_bytes: 18572
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 string s;
  cin>>s;
  stack<char> a;
  int n=s.size();
  rep(i,0,n){
   if(s[i]=='B'){
     if(a.size()!=0)
     a.pop();
     
   }
    else{
      a.push(s[i]);
    }
  }
  string ans="";
  while(a.size()>0){
   ans+=a.top();
    a.pop();
  }
  reverse(all(ans));
  cout<<ans<<endl;
  
}

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

typedef unsigned int ui;

ui trans(string x){
  ui res = 0, k = 1;
  for(int i=x.size()-1;i>=0;i--){
    if('a'<=x[i] && x[i]<='f')res += k*(x[i]-'a'+10);
    else res += k*(x[i]-'0');
    k<<=4;
  }
  return res;
}
 
string rev_trans(ui x){
  if(x==0)return "0";
  ui k = 1;
  string res;
  while(x){
    ui tmp = (x/k)&((1U<<4)-1);
    if(tmp<10)res += (char)('0'+tmp);
    else res += (char)('a'+tmp-10);
    x>>=4;
  }
  reverse(res.begin(),res.end());
  return res;
}

int main(){
  int s;
  string str;
  ui a[9];

  cin >> s;
  for(int t=0;t<s;t++){
    for(int i=0;i<9;i++){
      cin >> str;
      a[i] = trans(str);
    }

    ui mask = 0, cut = 0;
    for(int i=0;i<32;i++){
      cut |= 1U<<i;
      
      ui sum = 0;
      for(int j=0;j<8;j++)sum += (a[j]^mask)&cut;
      if((sum&cut) != ((a[8]^mask)&cut))mask |= 1U<<i;
    }
    cout << rev_trans(mask) << endl;
  }
}

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit (ll b, ll i) { return b & (1 << i); }
inline ll ceiv (ll a, ll b) { return (a + b - 1) / b; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main() {
    int k; cin >> k;
    rep(i,k) cout << "ACL";
    cout << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

class Main
{
	public static String invertCase(String str){
		char[] chars = str.toCharArray();
		for(int i=0; i<chars.length; i++){
			chars[i] = Character.isUpperCase(chars[i])
					? Character.toLowerCase(chars[i])
					: Character.toUpperCase(chars[i]);
		}
		return new String(chars);
	}
	
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		String str = scan.nextLine();
		System.out.println(invertCase(str));
	}
}


Measured memory_bytes: 26212
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


tmp = A[0]
for i in range(1, N):
    tmp = lcm(tmp, A[i])

B = [0] * N
for i in range(N):
    B[i] = tmp // A[i]

print(sum(B) % mod)


Measured memory_bytes: 262388
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  n = 2*n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  int ans=0;
  for(int i=0;i<n;i+=2){
    ans +=a.at(i);
  }
  cout <<ans;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,k,i;
	cin>>a>>b>>k;
	for(i=0;i<k;i++){
		if(i&1){
			a+=(b>>=1);
		}else{
			b+=(a>>=1);
		}
	}
	cout<<a<<" "<<b;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
#define MAX_N (10010)
#define MAX_C (100010)
#define INF (MAX_N * MAX_C)

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

vector<P> G[MAX_N];
int d[MAX_N];
int par[MAX_N];
bool arrived[MAX_N];

int main()
{
    int n;
    scanf("%d", &n);

    for ( int i = 0; i < n; i++ ) {
	int u, k;
	scanf("%d %d", &u, &k);
	for ( int j = 0; j < k; j++ ) {
	    int v, c;
	    scanf("%d %d", &v, &c);
	    G[u].push_back( make_pair( v, c ) );
	}
    }

    for ( int i = 0; i < n; i++ ) {
	d[i] = INF;
    }
    d[0] = 0;
    par[0] = -1;

    priority_queue<P, vector<P>, greater<P> > PQ;
    PQ.push( make_pair( 0, 0 ) );

    while ( !PQ.empty() ) {
	P p = PQ.top(); PQ.pop();
	if ( p.first > d[p.second] ) continue;
	int u = p.second;
	arrived[u] = true;

	for ( int i = 0; i < G[u].size(); i++ ) {
	    P v = G[u][i];
	    if ( !arrived[v.first] ) {
		if ( d[v.first] > d[u] + v.second ) {
		    d[v.first] = d[u] + v.second;
		    PQ.push( make_pair( d[v.first], v.first ) );
		    par[v.first] = u;
		}
	    }
	}
    }

    for ( int i = 0; i < n; i++ ) {
	printf("%d %d\n", i, d[i]);
    }
    
    return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    rep0(i, a+b){
        if( i == a){
            if( s[i] != '-'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if( !isdigit(s[i])){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3076
from sys import exit

N = int(input())

S = []
for _ in range(N):
	S.append(input())

count = 0
a_count = 0
b_count = 0
a_b_count = 0

for s in S:
	if s[0] == 'B' and not s[-1] == 'A':
		b_count += 1
	if not s[0] == 'B' and s[-1] == 'A':
		a_count += 1
	if s[0] == 'B' and s[-1] == 'A':
		a_b_count += 1
	for i in range(len(s) - 1):
		if s[i] == 'A':
			if s[i + 1] == 'B':
				count += 1

if a_b_count == 0:
	print(count + min(a_count, b_count))
else:
	if not (a_count == 0 and b_count == 0):
		a_count += 1
		b_count += 1
	print(count + min(a_count, b_count) + a_b_count - 1)


Measured memory_bytes: 3700
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            // 長さNは不要なので捨てる
            Console.ReadLine();

            // 整数の入力
            int divisionCnt = 0;

            // スペース区切りの整数の入力
            string secondLine = Console.ReadLine();
            foreach (var a in secondLine.Split(' '))
            {
                for (int tar = int.Parse(a); tar % 2 == 0; tar /= 2)
                {
                    divisionCnt++;
                }
            }

            //出力
            Console.WriteLine(divisionCnt);
        }
    }
}


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

int main(){
  int x,y;
  int flag = 0;
  cin >> x >> y;
  for(int i=0;i <= x;i++){
    int z = 2*i + 4*(x-i);
    if(z == y){
      flag = 1;
    }
  }
  if(flag == 1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                1000000007
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b,ll m) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= m;} b >>= 1; x *= x; x %= m;} return p % m;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (pp(ll) p1, pp(ll) p2){
        return p1.ff >= p2.ff;
    }
};


int main(){
    //FIO;
    ll x; cin >> x;
    if(x >= 1800){
        cout << 1 << endl;
    }else if(x >= 1600){
        cout << 2 << endl;
    }else if(x >= 1400){
        cout << 3 << endl;
    }else if(x >= 1200){
        cout << 4 << endl;
    }else if(x >= 1000){
        cout << 5 << endl;
    }else if(x >= 800){
        cout << 6 << endl;
    }else if(x >= 600){
        cout << 7 << endl;
    }else if(x >= 400){
        cout << 8 << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
def permutations(L):
    if L == []:
        return [[]]
    else:
        return [[h] + t for i, h in enumerate(L) for t in permutations(L[:i] + L[i+1:])]


n = int(input())
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]

l = permutations([i for i in range(1, n + 1)])

a = l.index(p) + 1
b = l.index(q) + 1

print(abs(a - b))


Measured memory_bytes: 9712
#include<iostream>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<string>
using namespace std;

class Parsing{
private:
  string parse;
  int pos;
public:

  Parsing(string s){
    parse = s;
    pos = 0;
  }
  int fact(){
    if(parse[pos] == '('){
      pos++;
      int p = expression();
      pos++;
      return p;
    }else{
      int p=0;
     
      while('0' <= parse[pos] && parse[pos] <= '9'){
	p *= 10;
	p += parse[pos]-'0';
	pos++;
      }
      return p;
    }
  }

 int term(){
    int p = fact();
    while(parse[pos] == '*' || parse[pos] == '/'){
      if(parse[pos] == '*'){pos++;p *= fact();}
      else {pos++;p /= fact();}
    }
    return p;
  }

 int expression(){
    int p = term();
    while(parse[pos] == '+' || parse[pos] == '-'){
      if(parse[pos] == '+'){pos++;p+=term();}
      else {pos++;p-=term();}
    }
    return p;
  } 
 

};








int main(){
  string s;
  int N;
  cin >> N;
  while(N-- > 0){
 
    cin >> s;
   
    Parsing par = Parsing(s.substr(0,s.length()-1));
    cout << par.expression() << endl;
    
  }
  return 0;
}

Measured memory_bytes: 1220