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

#define ll long long

using namespace std;

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

int a[22][22];
int n;
int musk[22];
int dp[1 << 21];
int bt[1 << 21];

int add(int a, int b) {
	return (a + b) % mod;
}

int go(int mask) {
	if (mask == 0) return 1;
	int &res = dp[mask];
	if (res != -1) return res;
	int qwe = n - __builtin_popcount(mask);
	int asd = mask & musk[qwe];
	res = 0;
	while (asd > 0) {
		int bit = bt[asd & -asd];
		res = add(res, go(mask ^ (1 << bit)));
		asd -= (1 << bit);
	}
	return res;
}

main() {
	memset(dp, -1, sizeof dp);
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int res = 0;
		for (int j = 0, x; j < n; j++) {
			scanf("%d", &x);
			res += (x << j);
		}
		musk[i] = res;
	}
	for (int i = 0; i < n; i++) {
		bt[1 << i] = i;
	}
	printf("%d", go((1 << n) - 1));
}


Measured memory_bytes: 12672
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <limits>

using ld = long double;
using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	/* constant */
	constexpr double epsilon = std::numeric_limits<double>::epsilon();

	/* math */
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	ul inline digit(const ul &num){ return static_cast<ul>(std::log10(num+epsilon))+1; }

	/* algorithm */
	ul gcd(const ul &a,const ul &b) { return (!b) ? a : gcd(b,a%b); } // NOTE: a > b

	/* string */
	inline ul same_char_count(const std::string s,const char &ch){ return std::count(std::cbegin(s),std::cend(s),ch); }
}

// std::cout << std::fixed << std::setprecision(15) << std::endl;

int main(int argc,char *argv[])
{
	ll s;
	std::cin >> s;

	std::string str(std::to_string(s));

	ll digit = lamlib::digit(s);
	constexpr ll max_d = 10;

	ul ans = 0;
	for(ll i = 0;i < (1<<(digit-1));++i)
	{
		std::bitset<max_d> bs(i);
		std::string eq;
		for(ll j = 0;j < digit;++j)
		{
			if(bs.test(j))
			{
				eq.push_back(str[j]);
				eq.push_back('+');
			}
			else { eq.push_back(str[j]); }
		}
		ll idx = 0;
		for(ll j = 1;j < eq.size();++j)
			if(eq[j] == '+')
			{
				std::string tmp;
				for(ll k = idx;k < j;++k) { tmp.push_back(eq[k]); }
				idx = j+1;
				ans += stoll(tmp);
			}
		if(idx != eq.size()){ ans += stoll(eq.substr(idx)); }
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
typedef long long int LLI;
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  string s;
  cin>>s;
  reverse(all(s));
  cout<<s<<endl;
}

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

using namespace std;

int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a, a+3);
    if (a[0]==5 && a[1]==5 && a[2]==7) cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    IOS
    int n;
    cin>>n;
    lli x;
    cin>>x;
    lli g;
    lli a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        a[i] = abs(a[i]-x);
    }
    g = a[0];
    for(int i=1;i<n;i++)
        g = __gcd(g,a[i]);
    cout<<g;
    return 0;
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define REPD(i,n) FOR(i,n-1,0)
#define PB push_back
#define mod 1000000007


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;
    
    
    return 0;   
}

Measured memory_bytes: 256
using System;
internal class Program
    {
        public static void Main(string[] args)
        {
            var t = Console.ReadLine();
            var x = t.Split();
            var total = 0;
            foreach (var v in x)
            {
                total += Convert.ToInt32(v);
            }
            if(total < 22)
            {
                Console.WriteLine("win");
                return;
            }
            Console.WriteLine("bust");
        }
    }

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long o=0,x=0;
	string s;
	cin>>s;
	for (int i=0;i<s.size();i++)
		if (s[i]=='o') o++;
		else x++;
	if (x>=8) cout<<"NO";
	else cout<<"YES";
	return 0;
}

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

int main(){
    int W, H, N;
    cin >> W >> H >> N;

    int X[N], Y[N], A[N];
    for(int i = 0; i < N; ++i){
        cin >> X[i] >> Y[i] >> A[i];
    }

    int left = 0, right = W, up = H, down = 0;
    int total = right * up;
    for(int i = 0; i < N; ++i){
        switch(A[i]){
            case 1:
                if(left < X[i]) left = X[i];
                break;
            case 2:
                if(right > X[i]) right = X[i];
                break;
            case 3:
                if(down < Y[i]) down = Y[i];
                break;
            case 4:
                if(up > Y[i]) up = Y[i];
                break;
        }
    }
        
    cout << (max(0, right - left))*(max(0, up - down)) << endl;

    return 0;
}


Measured memory_bytes: 384
/*input
aabbaa
*/
#include "bits/stdc++.h"
using namespace std;
int dp[200005];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	string s; cin >> s;
	fill(dp,dp+200005,-1e9);
	dp[s.size()] = 0;
	dp[s.size()-1] = 1;
	for(int i=s.size()-1;i--;){
		if(s[i] == s[i+1])
			dp[i] = max(1 + dp[i+2],2+dp[i+3]);
		else
			dp[i] = 1 + dp[i+1];
	}

	cout << dp[0];
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const ll mod=1e+9+7;
int main(void){
    int n;cin>>n;
    map<pair<ll,ll>,pair<int,int>> mp;
    int zero=0;
    rep(i,n){
        ll a,b;cin>>a>>b;
        if(a==0&&b==0){
            zero++;
            continue;
        }
        if(b<0){
            a*=-1;b*=-1;
        }
        if(b==0&&a<0){
            a=1;b=0;
        }
        ll g=gcd(a,b);//片方が0だともう片方の絶対値が出てくる
        a/=g;b/=g;
        if(a>0)mp[{-b,a}].first++;
        else mp[{a,b}].second++;
    }
    vector<ll> s(10*n+1,1);
    rep(i,n*10){
        s[i+1]=s[i]*2;
        s[i+1]%=mod;
    }
    
    ll res=1;
    for(auto& p:mp){
        int x=p.second.first;
        int t=p.second.second;
        ll tmp=1;
        tmp+=s[x]-1;tmp%=mod;
        tmp+=s[t]-1;tmp%=mod;
        res*=tmp;res%=mod;
    }
    res=(res+zero+mod-1)%mod;
    cout<<res<<endl;
}

Measured memory_bytes: 31264
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;
int a[110];
int main() {
    int n, m, x;
    cin >> n >> m >> x;
    x--;
    rep(i, m) {
        int ai;
        cin >> ai;
        ai -= 1;
        a[ai] = 1;
    }
    int ans1 = 0;
    int ans2 = 0;
    for (int i = x; i < n; i++) {
        if (a[i] == 1) ans1 += 1;
    }

    for (int i = x; i >= 0; i--) {
        if (a[i] == 1) ans2 += 1;
    }

    cout << min(ans1, ans2) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef vector<int> VE;
#define int long long
#define INF 1000000009
#define INFL 1000000000000000018
#define mod 1000000007
#define pb push_back
#define MAXN 100005

int n;
string s[200];

signed main()
{
    cin >> n;
    for(int i = 0; i < n ;i++){
        cin >> s[i];
    }
    char fin = s[0][s[0].size() - 1];
    for(int i = 1; i < n ;i++){
        for(int j = 0; j < i; j++){
            if(s[i] == s[j]){
                cout << "No" << endl;
                return 0;
            }
        }
        if(fin != s[i][0]){
            cout << "No" << endl;
            return 0;
        }
        fin = s[i][s[i].size() - 1];
    }
    cout << "Yes" << endl;



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	string t;
	cin>>t;
	int done=1;
	int l1=s.size();
	int l2=t.size();
	if(l1==l2-1){
		for(int i=0;i<l1;i++){
			if(s[i]!=t[i]){
			done=-1;
			break;	
			}
		}
		if(done==-1){
			cout<<"No"<<endl;
		}else {
			cout<<"Yes"<<endl;
		}
	}else {
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3576
N = int(input())
ans = 0
a_chance = 0
a_remain = []
b_remain = []
for i in range(N):
    a,b = map(int,input().split())
    if b >= a:
        ans += b
        a_chance += b-a
    else:
        a_remain.append(a)
        b_remain.append(b)
if a_chance ==0:
    print(0)
else:
    print(ans+sum(b_remain)-min(b_remain))  

Measured memory_bytes: 76536
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
#define ll long long
#define fast_io cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
#define MOD 1000000007
using namespace std;

int main(){
	fast_io;
	ll n,k;
	cin>>n>>k;
	ll ans;
	ans = n%k;
	cout<<ans;
}

Measured memory_bytes: 764
import java.io.PrintWriter;
import java.util.Scanner;
class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		while(sc.hasNext()){
			String str = sc.nextLine();
			for(int i = 0; i < str.length();i++){
				//System.out.println(str.charAt(i));
				if(String.valueOf(str.charAt(i)).equals("@")){
					String temp = String.valueOf(str.charAt(i+1));
					int n = Integer.parseInt(temp);
					for(int j = 0; j < n; j++){
						pw.write(str.charAt(i+2));
					}
					i+=2;
				}else{	
					pw.write(str.charAt(i));
				}
			}
			pw.println();
			pw.flush();
		}
	}	
}

Measured memory_bytes: 26072
#include<stdio.h>

int main(){

	char n[100];
	int cek=0;
	scanf("%s",n);
	for(int i=0;i<100;i++){
		if(n[i]=='9'){
			cek=1;
		}
	}
	printf("%s\n",  cek ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 128
use std::io::{stdin, BufReader, StdinLock, BufRead};

fn main() {
    let std_in = stdin();
    let mut br = BufReader::new(std_in.lock());

    let s = rs(&mut br);
    let f = s[0].to_digit(10).unwrap() * 10 + s[1].to_digit(10).unwrap();
    let b = s[2].to_digit(10).unwrap() * 10 + s[3].to_digit(10).unwrap();
    let fb = f > 0 && f < 13;
    let bb = b > 0 && b < 13;
    if fb && bb {
        println!("AMBIGUOUS");
    } else if fb {
        println!("MMYY");
    } else if bb {
        println!("YYMM");
    } else {
        println!("NA");
    }
}


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

fn rs(br: &mut BufReader<StdinLock>) -> Vec<char> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().chars().collect()
}

fn rn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> T {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn rvs(br: &mut BufReader<StdinLock>) -> Vec<Vec<char>> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.chars().collect()).collect()
}

fn rvn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> Vec<T> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}



Measured memory_bytes: 4352
//region Template
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#ifdef LOCAL
#include <debug_prettyprint.hpp>
#else
#define debug(...) 42
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#endif
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout<<fixed<<setprecision(12);
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = max(lhs, rhs.val); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = min(lhs, rhs.val); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
//endregion



struct SegTree {
#define IS_LEAF(id) (id>=N)
#define LC (ID<<1)
#define RC (ID<<1|1)
    static const int INF = 1<<30;
    static const int H = 20; //TODO
    static const int N = 1<<H;
    int t[2*N]={0};

private:
    void update(int ID) {
        t[ID] = max(t[LC], t[RC]);
    }

public:

    void setPoint(int pos, int val, int ID=1, int L=0, int R=N-1) {
        if(L==R) {
            t[ID]=val;
            return;
        }
        int mid = L+R>>1;
        if(pos<=mid)
            setPoint(pos, val, ID*2, L, mid);
        else
            setPoint(pos, val, ID*2+1, mid+1, R);
        update(ID);
    }

    int queryMax(int from, int to, int ID=1, int L=0, int R=N-1) {
        if(from<=L && to>=R)
            return t[ID];
        int res=0;
        int mid = L+R>>1;
        if(from<=mid)
            res |= MAX( queryMax(from, to, ID*2, L, mid) );
        if(to>mid)
            res |= MAX( queryMax(from, to, ID*2+1, mid+1, R) );
        return res;
    }
} st;

signed main() {
    FASTIO

    int n,k; cin>>n>>k;
    vi A = READ<int>(n);

    for(auto a : A) {
        int mx = st.queryMax(max(a-k, 0), a+k );
        st.setPoint(a, mx+1);
    }

    cout<<st.queryMax(0, 7e5)<<endl;

}

Measured memory_bytes: 6924
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <limits.h>
#include <cmath>

int main()
{
    int N;
    std::cin >> N;

    std::vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> A[i];
    }

    std::sort(A.begin(), A.end());
    long long B = 0LL;
    int amin = INT_MAX;
    bool f = false;
    for (int i = 0; i < N; i++)
    {
        if (A[i] < 0)f = !f;
        int a = std::abs(A[i]);
        B += a;
        amin = std::min(amin, a);
    }

    if (f)B -= amin * 2;

    std::cout << B << std::endl;
    return 0;
}

Measured memory_bytes: 640
import std;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "T", long, "A");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto dishes = new Pair[](n);
    foreach (i; iota(n))
    {
        long t, a;
        scan(t, a);
        dishes[i] = Pair(t, a);
    }
    dishes.sort!"a.T + a.A > b.T + b.A"();
    // dishes.each!(x => x.writeln());
    auto cnt_t = iota(n).filter!(x => !(x % 2))
        .map!(i => dishes[i].T);
    auto cnt_a = iota(n).filter!(x => x % 2)
        .map!(i => dishes[i].A);
    writeln(cnt_t.sum() - cnt_a.sum());
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

#define vd vector<double>
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'
 
int main() {
    float a, b;
    cin >> a >> b;
    int result = ceil((b-1.0)/(a-1.0));

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	int x, n;
	cin >> x >> n;
	int mi = INF;
	map<int, int> s;
	bool aru = false;
	rep(i, n) {
		int p; cin >> p;
		if (x == p) aru = true;
		//mi = min(mi, abs(x-p));
		s[p]++;
	}
	if (!aru) {
		cout << x << endl;
		return 0;
	}
	int j = 1;
	int ans, cnt = 0;
	while (true)
	{
		int l = x-j, r = x+j;
		if (s[l]==0) {ans = l; break;}
		if (s[r]==0) {ans = r; break;}
		j++;
		if (j > 200) break; 
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main() {
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    int s=a*b, g=c*d;
    if (s>=g) {
        cout <<s<< endl;
    }
    else {
        cout <<g << endl;
    }
}  

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

int	main()
{
	int	N;
	cin >> N;
	vector<int>	a_vec(N);
	for (int i = 0; i < N; ++i)
		cin >> a_vec.at(i);
	sort(a_vec.begin(), a_vec.end(), greater<int>());
	int	point = 0;
	for (int i = 0; i < N; ++i) {
		if (i % 2 == 0)
			point += a_vec.at(i);
		else
			point -= a_vec.at(i);
	}
	cout << point << endl;
}


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


n, m = map(int, input().split())

SUBMISSIONS = {i:[] for i in range(1, n + 1)}
for _ in range(m):
    p, s = input().split()
    SUBMISSIONS[int(p)].append(s)

ac, penalty = 0, 0
for i in range(1, n + 1):
    wa = 0
    for result in SUBMISSIONS[i]:
        if result == "WA":
            wa += 1
        else:
            ac += 1
            penalty += wa
            break

print(ac, penalty)


Measured memory_bytes: 28900
import string

[H,W]=map(int, raw_input().split())
lw=string.ascii_lowercase
A=[0 for i in range(26)]
for i in range(H):
    st=raw_input()
    for c in st:
        A[lw.index(c)]+=1

K=(W/2)*(H/2)
L=(W*(H%2)+H*(W%2)-2*(H%2)*(W%2))/2
M=(H%2)*(W%2)

f=0
ans=["No","Yes"]
P=sum([a/4 for a in A])
#print P,K
if P>=K:
    P-=K
    while(K>0):
        for i in range(26):
            if A[i]>=4:
                A[i]-=4
                K-=1
                if K==0: break
        #print K,A
    Q=sum([a/2 for a in A])
    #print Q,L
    if Q>=L:
        Q-=L
        L=0
        R=Q*2+sum([a%2 for a in A])
        #print R,M
        if R>=M:
            f=1
print ans[f]


Measured memory_bytes: 2948
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, c = M()
x = a[0] + b[0] + c[0]
print(str.upper(x))

Measured memory_bytes: 74692
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll N;cin>>N;
    map<string,ll> m;
    REP(i,N){
        string s;
        cin>>s;
        m[s]++;
    }
    ll cnt=0;
    for(auto r:m){
        cnt++;
    }
    cout<<cnt<<"\n";
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int a, b, k;
    cin >> a >> b >> k;
    vector<int> v;
    for(int i = 1; i <= min(a, b); ++i) {
        if(a % i == 0 && b % i == 0) v.pb(i);

    }
    sort(all(v), greater<>());
    cout << v[k - 1] << endl;
    return 0;
}



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

#define F first
#define S second

using ll = long long;
using pii = pair <int, int>;

const int oo = 1e9 + 4;
const int SZ = 2e5 + 4;

int n;
vector <int> g;

void read() {
    cin >> n;
    g.resize(n, 0);
    for (int i = 1; i < n; i++) {
        int t;
        cin >> t;
        g[t - 1]++;
    }
}

void solve() {
    for (auto t : g) cout << t << endl;
}

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

    read();
    solve();
}


Measured memory_bytes: 3992
#include <stdio.h>

#define N 100

int main(void)
{
	int g[N][N];
    int adj[N][N];
    int n, i, j;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &g[i][0]);
        scanf("%d", &g[i][1]);
        for (j = 2; j < g[i][1] + 2; j++) {
            scanf("%d", &g[i][j]);
        }
    }

    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            adj[i][j] = 0;
        }
    }   

    for (i = 0; i < n; i++) {
        for (j = 0; j < g[i][1]; j++) {
            adj[g[i][0] - 1][g[i][j + 2] - 1]++;
        }
    }   

    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            if (j != n - 1) {
                printf("%d ", adj[i][j]);
            } else {
                printf("%d", adj[i][j]);
            }
        }
        printf("\n");
    }


	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	int n, k;
	cin >> n >> k;
	k--;
	vector<int> tree;
	for ( int i = 0 ; i < n ; i++ ){
		int tmp;
		cin >> tmp;
		tree.push_back(tmp);
	}
	sort(tree.begin(), tree.end());
	int m = 1E9;
	for ( int i = k ; i < n ; i++ ){
		m = min(m, tree[i] - tree[i-k]);
	}
	cout << m << "\n";
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	string s; cin >> s;
	int red = 0;
	int blue = 0;
	rep (i, N){
		red += (int)(s[i] == 'R');
		blue += (int)(s[i] == 'B');
	} // end rep

	cout << (red > blue ? "Yes" : "No") << endl;

	return 0;
}

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


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

map<pair<int,int>,bool>m;
set<pair<int,int> >st;
int cnt;

int y[100009],x[100009],n,h,w;

signed main(){
	cin>>h>>w>>n;
	rep(i,n){
		cin>>y[i]>>x[i];
		y[i]--;x[i]--;
		m[P(y[i],x[i])]=true;
	}
	int a[10]={};
	rep(i,n){
		rep(j,9){
			int sum=0;
			int yy=y[i]+dy[j];
			int xx=x[i]+dx[j];
			if(yy<0||xx<0||yy+2>=h||xx+2>=w)continue;
			if(st.count(P(yy,xx)))continue;
			rep(k,9){
				int ny=yy+(dy[k]*-1);
				int nx=xx+(dx[k]*-1);
				if(m[P(ny,nx)])sum++;
			}
			//cout<<yy<<' '
			st.insert(P(yy,xx));
			a[sum]++;
			cnt++;
		}
	}
	cout<<(long long)a[0]+(long long)(h-2)*(w-2)-cnt<<endl;
	rep(i,9)cout<<a[i+1]<<endl;
}

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

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve
{
    int n;
    vector<int> f, primes;
    Sieve(int n = 1) : n(n), f(n + 1)
    {
        f[0] = f[1] = -1;
        for (long long i = 2; i <= n; i++)
        {
            if (f[i])
                continue;
            primes.push_back(i);
            f[i] = i;
            for (long long j = i * i; j <= n; j += i)
            {
                if (!f[j])
                    f[j] = i;
            }
        }
    }
    bool isPrime(int x)
    {
        return f[x] == x;
    }
    vector<int> factorList(int x)
    {
        vector<int> res;
        while (x != 1)
        {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<pair<int, int>> factor(int x)
    {
        vector<int> fl = factorList(x);
        if (fl.size() == 0)
            return {};
        vector<pair<int, int>> res(1, pair<int, int>(fl[0], 0));
        for (int p : fl)
        {
            if (res.back().first == p)
            {
                res.back().second++;
            }
            else
            {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
    vector<long long> factorList(long long x)
    {
        vector<long long> res;
        for (int p : primes)
        {
            while (x % p == 0)
            {
                res.push_back(p);
                x /= p;
            }
        }
        if (x != 1)
            res.push_back(x);
        return res;
    }

    vector<pair<long long, int>> factor(long long x)
    {
        vector<long long> fl = factorList(x);
        if (fl.size() == 0)
            return {};
        vector<pair<long long, int>> res(1, make_pair(fl[0], 0));
        for (long long p : fl)
        {
            if (res.back().first == p)
            {
                res.back().second++;
            }
            else
            {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};

int main()
{
    long long n;
    cin >> n;
    Sieve s(1000005);
    auto fs = s.factor(n);
    int ans = 0;
    for (auto p : fs)
    {
        int x = p.second;
        int b = 1;
        while (b <= x)
        {
            x -= b;
            b++;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7836
// clang-format off
#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(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep(i, n) for(int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T>& p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T>& vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
constexpr ll MOD = 1000000007;

constexpr int MAX = 100000;
ll x[MAX];
ll y[MAX];

int main()
{
    long long n, m;
    cin >> n >> m;
    rep(i, n){
        cin >> x[i];
    }
    rep(i, m){
        cin >> y[i];
    }

    ll X = 0;
    for(long long i = 0; i < n-1; i++){
        X += (((ll)((i+1)*(n-i-1)) % MOD) * ((x[i+1]-x[i])%MOD)) % MOD;
        X = X%MOD;
    }
    ll Y = 0;
    for(long long i = 0; i < m-1; i++){
        Y += (((ll)((i+1)*(m-i-1)) % MOD) * ((y[i+1]-y[i])%MOD)) % MOD;
        Y = Y%MOD;
    }
    cout << (X*Y)%MOD << endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  char s;
  cin >> s;

  if('a' <= s && s <= 'z') cout << 'a' << "\n";
  else cout << 'A' << "\n";

  return 0;
}


Measured memory_bytes: 3608
// 答えとなる領域は必ず面積1(だと思う)
#include<iostream>
#include<map>
using namespace std;

int main(){
    int n;
    cin >> n;
    map<int,map<int,int>> m;
    while(n-- > 0){
        int x, y, w;
        cin >> x >> y >> w;
        m[x][y] += w;
    }
    auto getter = [&](int x, int y)->int{
        return m.count(x) && m[x].count(y) ? m[x][y] : 0;
    };
    int ans = 0;
    for(auto p : m){
        int x = p.first;
        for(auto q : p.second){
            int y = q.first, w = q.second;
            for(int i : {-1, 1}){
                for(int j : {-1, 1}){
                    ans = max(ans, w+getter(x+i,y)+getter(x,y+j)+getter(x+i,y+j));
                }
            }
        }
    }
    cout << ans << " / 1" << endl;
    return 0;
}


Measured memory_bytes: 17156
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
 
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
 
#include <functional>
#include <cassert>
 
typedef long long ll;
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << endl;
 
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010
 
 
int main(){
  string s;
  cin >> s;
 
  s.erase(unique(s.begin(),s.end()),s.end());
 
  printf("%d\n",(int)s.size()-1);
  
  return 0;
}

Measured memory_bytes: 512
#B - Qualification simulator
N,A,B = map(int,input().split())
S = input()
S = list(S)

capacity = A + B
candidate = 0
overseas = 0
for i in S:
    if i == 'a' and candidate < capacity:
        candidate += 1
        print('Yes')
    elif i == 'b' and candidate < capacity and overseas < B:
        candidate += 1
        overseas += 1
        print('Yes')
    else :
        print('No')

Measured memory_bytes: 9820
#include <iostream>
 
using namespace std;
 
int main(void) {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= s - i && j <= k; j++) {
      if (s - i - j <= k) {
        ans++;
       // cout << i << " " << j << endl;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
a = list(map(int, list(input())))

for i in [True, False]:
    for j in [True, False]:
        for k in [True, False]:
            if i:
                ans = a[0] + a[1]
            else:
                ans = a[0] - a[1]
            if j:
                ans += a[2]
            else:
                ans -= a[2]
            if k:
                ans += a[3]
            else:
                ans -= a[3]
            if ans == 7:
                ans = str(a[0])
                if i:
                    ans += '+'
                else:
                    ans += '-'
                ans += str(a[1])
                if j:
                    ans += '+'
                else:
                    ans += '-'
                ans += str(a[2])
                if k:
                    ans += '+'
                else:
                    ans += '-'
                ans += str(a[3]) + '=7'
                print(ans)
                exit()

Measured memory_bytes: 9152
from itertools import groupby
from math import factorial


N = int(input())
words = [input() for _ in range(N)]
groups = groupby(sorted([''.join(sorted(list(word))) for word in words]))

res = 0
for k, vs in groups:
    l = len(list(vs))
    if l >= 2:
        res += factorial(l) // (factorial(l - 2) * 2)

print(res)


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

using namespace std;

int main(){
	int n;
	int k;
	cin >> n >> k;
	
	int ans = 0;
	for(int i = 0;i < n;i++){
		int x;
		cin >> x;
		ans += min(x,abs(k-x))*2;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
    int n; cin >> n;
    vi a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a),greater<int>());
    int al=0,bo=0;
    REP(i,n) (i%2?bo:al) += a[i];
    cout << al-bo << endl;
}




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

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

  double sum = 0;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
    sum += A[i];
  }

  int cnt = 0;
  rep(i, N) {
    if (A[i] >= (double)(sum / (4 * M))) cnt++;
  }
  if (cnt >= M)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
const ll INF=2e15;
typedef pair<ll, ll> E;
struct Edge{
    ll from,to;
    ll cost;
};
ll N,M,P;
vector<Edge> edges;
vector<Edge> edgeList[2510];
ll dist[2510];
ll pre[2510]={};
bool isAble[2510]={};
bool checked[2510];
/*bool Check(ll now){
    checked[now]=true;
    if(isAble[now]){
        return true;
    }
    if(now==N)return true;
    for(auto e:edgeList[now]){
        if(!checked[e.to]){
            if(Check(e.to)){
                return true;
            }
        }
    }
    return false;
}*/
int main(){
    cin>>N>>M>>P;
    for(ll i=0;i<M;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        Edge e={a,b,-(c-P)};
        edges.push_back( e );
        edgeList[a].push_back(e);
    }
    /*
        for(ll i=1;i<=N;i++){
        for(ll j=1;j<=N;j++){
            checked[j]=false;
        }
        isAble[i]=Check(i);
       // cout<<isAble[i]<<endl;
    }
    */
    for(ll i=1;i<=N;i++){
        dist[i]=INF;
    }
    dist[1]=0;
    for(ll i=1;i<N;i++){
        for(auto e:edges){
            ll newCost=dist[e.from]+e.cost;
            if(dist[e.to]>newCost){
                dist[e.to]=newCost;
                pre[e.to]=e.from;
            }
        }
    }
    ll now=N;
    ll cnt=0;
    while(now!=1){
        isAble[now]=true;
        now=pre[now];
        cnt++;
        if(cnt>N){
            cout<<"-1";
            return 0;
        }
    }
    for(auto e:edges){
        if(dist[e.from]+e.cost < dist[e.to]){
            if(isAble[e.to] || isAble[e.from]){
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }
    cout<<max(0LL,-dist[N])<<endl;
    return 0;
}

Measured memory_bytes: 768
n = int(input())
a = [0]
a.extend(list(map(int, input().split())))
cnt = {}
for i in range(n):
  cnt.setdefault(i, 0)
  if a[i] != 0 :
    cnt[a[i]-1] += 1

for i in cnt :
  print(cnt[i])


Measured memory_bytes: 39980
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


int main() {
    int n, q;
    cin >> n >> q;
    string S;
    cin >> S;
    vi l(q), r(q);
    rep(i, q) {
        cin >> l[i] >> r[i];
    }

    int c=0;
    vi num(n);
    rep(i, n-1) {
        if(S[i] == 'A' && S[i+1] == 'C') {
            ++c;
        } 
        num[i+1] = c;
    }

    rep(i, q) {
        cout << num[r[i]-1]-num[l[i]-1] << '\n';
    }
}

Measured memory_bytes: 2176
s=list(input())
T=list(input())

for i in range(len(s)-len(T)+1):
    F=0
    for j in range(len(T)):
        if s[len(s)-1-i-j]==T[len(T)-j-1] or s[len(s)-1-i-j]=="?":
            continue
        else:
            F=1
            break
    if F==0:
        for j in range(len(T)):
            if s[len(s)-1-i-j]=="?":
                s[len(s)-1-i-j]=T[len(T)-j-1]
        
        for j in range(len(s)):
            if s[j]=="?":
                s[j]="a"
        print("".join(s))
        exit()
print("UNRESTORABLE")


Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(I,N) for (int I = 0; I < (N); ++I)
#define fornd(I,N) for (int I = (N) - 1; I >= 0; --I)
#define forab(I,A,B) for (int I = (A); I <= (B); ++I)
#define forabd(I,A,B) for (int I= (B); I >= (A); --I)
#define FOREACH(I,A) for (__typeof__(A)::iterator I=A.begin(); I<A.end(); I++)
#define all(V) (V).begin(), (V).end()
#define pb push_back
#define mp make_pair

typedef long long int ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

const ll mod = 1000000007;

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

  vector<vector<int> > switches(M);
  int temp;
  forn(i, M) {
    int k;
    cin >> k;
    forn(j, k) {
      cin >> temp;
      temp--;
      switches[i].pb(temp);
    }
  }

  vector<int> p(M);
  forn(i, M) {
    cin >> p[i];
  }

  int com = 1 << N;
  int ans = 0;
  // cout << "pass" << endl;
  forn(i, com) {
    int base = 0;
    forn(j, M) {
      temp = 0;
      forn(k, switches[j].size()) {
        if (1 & (i >> switches[j][k])) {
          temp++;
        }
      }
      if ((temp % 2) == (p[j] % 2)) {
        base++;
      }
    }
    if (base == M) {
      ans++;
    }
    // cout << i << " " << base << endl;
  }

  cout << ans << endl;

  return 0;
}




Measured memory_bytes: 256
#include<string.h>
#define N 36
typedef struct number{
  char card[2];
  int num;
  int judge;
}S;
void bubblesort(S*,int);
void sellectionsort(S*,int);
void judgesort(S*,int);
int myatoi(char x){
  int y;
  y=x-48;
  return y;
}
int main(){
  int a,i;
  S tra[N],np[N];
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%s",tra[i].card);
    strcpy(np[i].card,tra[i].card);
    tra[i].num=myatoi(tra[i].card[1]);
    np[i].num=tra[i].num;
    tra[i].judge=i;
    np[i].judge=i;
  }
  bubblesort(tra,a);
  printf("%s",tra[0].card);
  for(i=1;i<a;i++)printf(" %s",tra[i].card);
  printf("\n");
  judgesort(tra,a);
  sellectionsort(np,a);
  printf("%s",np[0].card);
  for(i=1;i<a;i++)printf(" %s",np[i].card);
  printf("\n");
  judgesort(np,a);
  return 0;
}
void judgesort(S *tra,int y){
  int flag=1;
  int i;
  for(i=0;i<y;i++){
    if(tra[i].num==tra[i+1].num){
      if(tra[i].judge>tra[i+1].judge){
        printf("Not stable\n");
        flag=0;
        break;
      }
    }
  }
    if(flag)printf("Stable\n");
}
void bubblesort(S *tra,int x){
  int flag=1,j;
  S r;
  while(flag){
    flag=0;
    for(j=x-1;1<=j;j--){
      if(tra[j].num<tra[j-1].num){
        r=tra[j];
        tra[j]=tra[j-1];
        tra[j-1]=r;
        flag=1;
      }
    }
  }
}
void sellectionsort(S *tra,int x){
  int j,minj,i;
  S r;
  for(i=0;i<x;i++){
    minj=i;
    for(j=i;j<x;j++){
      if(tra[j].num<tra[minj].num)minj=j;
    }
    if(i!=minj){
      r=tra[i];
      tra[i]=tra[minj];
      tra[minj]=r;
    }
  }
}



Measured memory_bytes: 2140
#include <algorithm>
#include <cstdio>
#include <cstring>

const int Maxv = 110; 

int num[Maxv], ans, n, k; 

int main() {
    scanf("%d%d", &n, &k); 
    for (int i = 1; i <= n; i++)
        scanf("%d", &num[i]); 

    std::sort(num + 1, num + n + 1); 
    for (int i = 1; i <= n; i++) {
        k -= num[i]; 
        
        if (k < 0)
            break; 

        ans++; 
    }

    if (k > 0) ans--; 
    printf("%d\n", ans); 

    return 0; 
}

Measured memory_bytes: 128
#include <stdio.h>
int main(int argc, const char * argv[]) {
    int i, sum;
    char number[1000];
    
    while(1){
        scanf("%s",&number);
        if( number[0] == '0' ){
            break;
        }
        for( i = 0 ; ; i++ ){
            if( number[i] == '\0' ){
                break;
            }
            sum += number[i] - '0';
            
        }
        printf("%d\n",sum);
        sum = 0;
    }
    return 0;
}

Measured memory_bytes: 536
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
struct Edge {
    int d, i, j;
    Edge(int d_, int i_, int j_) : d(d_), i(i_), j(j_) {}
    bool operator< (const Edge& right) const{
        return d > right.d;
    }
};
void calc(int t, vector<vector<int> >& G, vector<int>& distance){
    int new_black = t;
    priority_queue<Edge> temp;
    for (int i = 1; i < G.size(); i++) {
        for (int j = 0; j < G.size(); j++) {
            if (distance[j] != -1) continue;
            int dis = G[new_black][j] + distance[new_black];
            temp.push(Edge(dis, new_black, j));
        }
        while (distance[temp.top().j] != -1) temp.pop();
        distance[temp.top().j] = temp.top().d;
        new_black = temp.top().j;
        temp.pop();
    }
}

int main(){
    int n;
    cin >> n;
    vector<vector<int> > G(n, vector<int>(n, 1e8));
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int c, v;
            cin >> c >> v;
            G[u][c] = v;
        }
    }

    vector<int> distance(n, -1);
    distance[0] = 0;
    calc(0, G, distance);
    for (int i = 0; i < n; i++) {
        cout << i << " " << distance[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3236
fun main(args: Array<String>) {
    val s = readInputLine().toCharArray()
    s.sort()
    val s2 = s.distinct()

    for ((i, c) in ('a'..'z').withIndex()) {
        if (i >= s2.size || s2[i] != c) {
            println(c.toString())
            return
        }
    }

    println("None")
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 39560
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (ll i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (ll i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < v.size() - 1; ++i)
    {
        os << v[i] << " ";
    }
    if (v.size() > 0)
    {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int gcd(int a, int b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main()
{
    int k;
    cin >> k;
    long long ans = 0;
    for (int i = 1; i <= k; ++i)
    {
        for (int j = i; j <= k; ++j){
            for (int l = j; l <= k; ++l){
                int num = gcd(gcd(i, j), l);
                if (i != j && j != l){
                    num *= 6;
                }else if (i == j && j == l){
                    num *= 1;
                }else{
                    num *= 3;
                }
                ans += num;
            }
        }
    }
    cout << ans << endl;
}

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

int main()
{
    int n,i,x;
    cin>>n;
    map<int,int> m;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        m.insert(pair<int,int>(x,i));
    }
    map<int,int>::iterator itr;
    itr=m.begin();
    for(itr=m.begin();itr!=m.end();itr++)
    {
        cout<<itr->second<<" ";
    }
    return 0;
}

Measured memory_bytes: 5504
r,x = 51,2**31
wc = [[15,2244],[10,1520],[12,1870],[5,850],[3,550],[2,380]]
dp = [x]*r
for w,c in wc:
	dp[w] = c
	for i in range(r - w):
		if dp[i] < x and dp[i + w] > dp[i] + c:
			dp[i + w] = dp[i] + c

while 1:
	n = input()
	if n == 0: break
	print dp[n/100]

Measured memory_bytes: 4240