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

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

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

const ll LINF = 2e18;
const int INF = 1e9;

ll mx = 1000000000000001;

void solve(ll N) {
  string s = "";

  while (N >= 1) {
    ll r = N % 26;
    char c;
    if (r == 0) {
      c = 'z';
      N /= 26;
      N -= 1;
    } else {
      c = 'a' - 1 + r;
      N /= 26;
    }
    s.push_back(c);
  }
  cout << string(s.rbegin(), s.rend()) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 3716
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

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


ull E = 1000000007;

int main() {
    int N, K;
    cin >> N >> K;
    ull ans = K;
    for (int i = 1; i < N; ++i) {
        ans *= K - 1;
    }
    cout << ans << endl;
}


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

using namespace std;

const int N = 110;

int dp[N][N], n, m;

int main() {
  cin >> n >> m;
  int ans = 123456789;
  string temp, last;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    for (int j = 0; j < m; j++) {
      dp[i][j] = 123456789;
      if (i == 0 && j == 0) 
        dp[i][j] = temp[0] == '#';
      if (i > 0)
        dp[i][j] = min(dp[i][j], dp[i - 1][j] + (temp[j] == '#' && last[j] == '.'));
      if (j > 0)
        dp[i][j] = min(dp[i][j], dp[i][j - 1] + (temp[j] == '#' && temp[j - 1] == '.')); 
      ans = min(ans, dp[i][j]);
    }
    last = temp;
  }
  cout << dp[n - 1][m - 1] << '\n';
  return 0;
}

Measured memory_bytes: 256
#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()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

string a[5]={"hi","hihi","hihihi","hihihihi","hihihihihi"};


int main(){cout<<fixed<<setprecision(20);
		   string s;
           cin>>s;
           
           bool ok=0;
           rep(i,0,5){
            if(s==a[i])ok=true; 
           }
           Yes(ok);
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define X first
#define Y second
#define sps printf(" ")
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define all(v) v.begin(),v.end()
#define dis(it,it1) distance(it,it1)+1
#define MAX 200005
#define INF 1000000000
#define MOD 1000000007
#define print(cs) printf("Case %lld: ",cs)
#define Yesno(ok) if(ok)puts("YES");else puts("NO")
#define yesno(ok) if(ok)puts("Yes");else puts("No")
ll lcm(ll a,ll b)
{
    return ((a*b)/__gcd(a,b));
}
int main()
{
    ll test=1;
    while(test--)
    {
        ll i,j,k,l,n,m,r;
        in(n);
        ll arr[n];
        for(i=0;i<n;i++)in(arr[i]);
        ll tot=0;
        for(i=1;i<n;i++)
        {
            if(arr[i]<arr[i-1])tot+=arr[i-1]-arr[i],arr[i]=arr[i-1];
        }
        cout<<tot;endl;
    }
}


Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int l=s.size();
  long long ans=0;
  for(int i=0;i<l;i++){
    for(int j=1;i+j<=l;j++){
      ans+=(s[i]-'0')*pow(10,j-1)*pow(2,l-1-min(l-1,j+i))*pow(2,i);
      //cout << ans << endl;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
def sp(a,b,c,xq,yq):
    xr=xq-2*a*(a*xq+b*yq+c)/(a**2+b**2)
    yr=yq-2*b*(a*xq+b*yq+c)/(a**2+b**2)
    print xr,yr

while 1:
    try:
        x1,y1,x2,y2,xq,yq=map(float,raw_input().split(','))
        sp(y2-y1,-(x2-x1),x2*y1-x1*y2,xq,yq)
    except:
        break

Measured memory_bytes: 6368
package main

import (
	"fmt"
)

func main() {
	var a, b, k int64
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&k)

	if a >= k {
		a -= k
		fmt.Printf("%d %d\n", a, b)
		return
	}

	k -= a
	a = 0

	b -= k
	if b < 0 {
		b = 0
	}
	fmt.Printf("%d %d\n", a, b)
}

Measured memory_bytes: 512
#include <stdio.h>
#include <limits.h>
#define U 1000
#define NIL -1
#define WHITE 0
#define BLACK 1
#define MAX 3000
int d[U];
int parent[U];
int color[U];

int main(){
  int cost=0;
  int mincost;
  int i,j,k,u,v;
  int n;
  int A[105][105];
  scanf("%d",&n);


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

  for(u=0;u<n;u++){
    d[u] = MAX;
    parent[u] = NIL;
    color[u] = WHITE;
  }
  d[0]=0;//最初の島のコストは０

    while(1){
      mincost = MAX;

      for(i=0;i<n;i++){
	if(color[i] != BLACK && d[i] < mincost ){
	  mincost = d[i];
	  u = i;
	}
      }


      // printf("aiueo\n");

      if(mincost == MAX) break;

      color[u] = BLACK;

      for(v=0; v<n; v++ ){
	if(color[v] != BLACK && A[u][v] < d[v] && A[u][v] != NIL ){
	  parent[v] = u;
	  d[v] =  A[u][v] ; 
	}
      }
      
    }

    for(v=0; v<n; v++ ) cost +=  d[v];

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

    return 0;
}




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

int main()
{

int a,b ;
cin>>a>>b ;
	if(a%3==0||b%3==0||(a+b)%3==0)
	cout<<"Possible"<<endl;
	else
	cout<<"Impossible"<<endl;



	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
// #include <bits/stdc++.h>
using namespace std;

int main() {
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  int arr[] = {A, B, C, D, E};
  int min = 10;
  for (int i = 0; i < 5; i++) {
    int reminder = arr[i] % 10;
    if (reminder < min && reminder != 0) min = arr[i] % 10;
  }

  if (min == 10) min = 0;

  int sum = 0;
  for (int i = 0; i < 5; i++) {
    sum += ceil((double)arr[i] / 10) * 10;
  }

  cout << (min == 0 ? (sum + min) : (sum + min - 10)) << endl;
  return 0;
}

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


int64_t gcd_impl(const int64_t a, const int64_t b)
{
    // cout << a << " " << b << endl;
    int64_t r;
    r = a % b;
    if (r == 0)
    {
        return b;
    }
    else
    {
        return gcd_impl(b, r);
    }
}


int64_t gcd(int64_t a, int64_t b)
{
    //cout << a << " " << b << endl;
    if (a < b)
    {
        // int64_t tmp;
        // tmp = a;
        // a = b;
        // b = tmp;
        swap(a, b);
    }
    else if (a == b)
    {
        return 1;
    }
    return gcd_impl(a, b);
}


int64_t getNumberOfMultiplesBetween1And(int64_t n, int64_t divisor)
{
    if (n < 1)
    {
        return 0;
    }
    else
    {
        return (n / divisor);
    }
}



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

    int64_t lcmCD, gcdCD;
    gcdCD = gcd(c, d);
    // cout << gcdCD << endl;
    lcmCD = c * d / gcdCD;

    int64_t numAtoB, num1toB, num1toAminus1;
    num1toB = b - getNumberOfMultiplesBetween1And(b, c) - getNumberOfMultiplesBetween1And(b, d) + getNumberOfMultiplesBetween1And(b, lcmCD);
    num1toAminus1 = (a - 1) - getNumberOfMultiplesBetween1And((a - 1), c) - getNumberOfMultiplesBetween1And((a - 1), d) + getNumberOfMultiplesBetween1And((a - 1), lcmCD);
    numAtoB = num1toB - num1toAminus1;

    cout << numAtoB << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
 
using namespace std;
int main(){
 
ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,i;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    int c=0,x=1;
    for(i=0;i<n;i++)
    {
    	if(a[i]==x)
        {
        	c++;
        	x++;
        	
		}
	}
	if(c==0)
	cout<<-1;
	else
	cout<<n-c;
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define pb push_back
#define fi first
#define se second
 
const ll MOD = 1000000007;

int main() {
   int n; scanf("%d", &n);
   vector<int> a(n);
   for (int &i : a)
      scanf("%d", &i);
   multiset<int, greater<int>> ans;
   for (int i : a) {
      multiset<int>::iterator it = ans.upper_bound(i);
      if (it != ans.end())
         ans.erase(it);
      ans.insert(i);
   }
   printf("%d ", ans.size());
   return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll const N=1e3;
ll INF=0x3f3f3f3f;
int main()
{
    ll n,r;
    cin>>n>>r;
    if(n>=10)
        cout<<r<<endl;
    else
        cout<<r+1000-n*100<<endl;
    return 0;
}


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

int main(){
  string N;
  cin >> N;
  for(int i=0; i<N.length(); i++){
    if(N[i] == '1')
      N[i] = '9';
    else if(N[i] == '9')
      N[i] = '1';
  }
  cout << N << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define M 1000000007

int main(void){
    int n,h,w,ans=0;cin>>n>>h>>w;
	for(int i=0;i<n;i++){
	    int a,b;cin>>a>>b;
	    if(a>=h&&b>=w)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize);

    println!(
        "{}",
        if n == 1 {
            "Hello World".to_string()
        } else {
            input!(a: usize, b: usize);
            (a + b).to_string()
        }
    );
}


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

#define rep(n, i) for (int i = 0; i < (n); ++i)

using ll = long long;
using namespace std;

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

    int answer = -1;
    rep (1001, i) {
      if ( floor(i * 0.08) == a && floor(i * 0.10) == b ) {
        answer = i;
        break;
      }
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char a[1000005];
int dp[1000005];
int h, w, k;
set<int>row[1000005], col[1000005];
void remove(int x, int y){
	row[x].erase(row[x].find(y));
	col[y].erase(col[y].find(x));
}
void explore(int X, int Y){
	queue<pair<int, int>>q;
	q.push({X, Y});
	while(!q.empty()){
		int x=q.front().first, y=q.front().second;
		//cout<<x<<" "<<y<<" "<<dp[x*w+y]<<endl;
		q.pop();
		auto it=col[y].lower_bound(x);
		while(it!=col[y].end() && *it<=x+k){
			int cur=*it;
			if(a[cur*w+y]=='@') break;
			dp[cur*w+y]=dp[x*w+y]+1;
			remove(cur, y);
			q.push({cur, y});
			it=col[y].lower_bound(x);
		}

		it=col[y].lower_bound(x);
		if(!col[y].empty() && it!=col[y].begin()){
			it--;
			while(*it>=x-k){
				int cur=*it;
				if(a[cur*w+y]=='@') break;
				dp[cur*w+y]=dp[x*w+y]+1;
				bool b=true;
				if(it==col[y].begin()) b=false;
				remove(cur, y);
				q.push({cur, y});
				it=col[y].lower_bound(x);
				if(it==col[y].begin()) break;
				else it--;
			}
		}
		it=row[x].lower_bound(y);
		while(it!=row[x].end() && *it<=y+k){
			int cur=*it;
			//cout<<cur<<" "<<y+k<<endl;
			if(a[x*w+cur]=='@') break;
			dp[x*w+cur]=dp[x*w+y]+1;
			remove(x, cur);
			q.push({x, cur});
			it=row[x].lower_bound(y);
		}

		it=row[x].lower_bound(y);
		if(!row[x].empty() &&it!=row[x].begin()){
			it--;
			while(*it>=y-k){
				int cur=*it;
				if(a[x*w+cur]=='@') break;
				dp[x*w+cur]=dp[x*w+y]+1;
				remove(x, cur);
				q.push({x, cur});
				it=row[x].lower_bound(y);
				if(it==row[x].begin()) break;
				else it--;
			}
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int x1, y1, x2, y2;
	cin>>h>>w>>k>>x1>>y1>>x2>>y2;
	x1--;
	y1--;
	x2--;
	y2--;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i*w+j];
			row[i].insert(j);
			col[j].insert(i);
		}
	}
	for(int i=0;i<1000005;i++) dp[i]=-1;
	dp[x1*w+y1]=0;
	remove(x1, y1);
	explore(x1, y1);
	cout<<dp[x2*w+y2]<<endl;
}


Measured memory_bytes: 196028
use proconio::{input, fastout};
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        n: usize,
        t: i64,
        a: i64,
        h: [i64;n],
    }
    let INF = 100_0000;
    let mut minv = INF;
    let mut mini = 1;
    for i in 0..n {
        let te: i64 = t * 1000 - h[i] * 6;
        debug!(te);
        if minv > (a*1000 - te).abs() {
            minv = (a*1000 - te).abs();
            mini = i+1;
        }
    }

    println!("{}", mini);

}


Measured memory_bytes: 2200
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

int main() {
  ll h; cin >>h;
  int n; cin >>n;
  ll attack = 0;
  rep(i,n){
    ll tmp; cin >>tmp;
    attack += tmp;
  }
  if (attack >= h) cout <<"Yes" <<endl;
  else cout <<"No" <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <tuple>
 
using namespace std;
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES" : "NO")
#define mod(a, b) (b + (a % b)) % b
#define MOD (int)1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

void add_self(int& a, int b){
    a += b;
    if(a >= MOD) a -= MOD;
}


int dp[1010][1010];

void solve(){
    int h, w;
    cin >> h >> w;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            char x;
            cin >> x;
            if(x == '#' || i == 0 || j == 0) dp[i][j] = 0;
            else dp[i][j] = -1;
        }
    }
    
    dp[1][1] = 1;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(dp[i][j] == -1){
                add_self(dp[i - 1][j], dp[i][j - 1]);
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[h][w];
}
 
int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int MAX_N=1<<17;
const ll INF=(1ll<<31)-1;
//update value Query min
class Lz_segtree{
public:
    int n;
    ll e=-1;
    ll init=0;
    vector<ll> dat,lz;
    Lz_segtree(int n_):n(n_){
        n=1;
        while(n<n_) n*=2;
        dat.resize(n*2,INF);
        lz.resize(n*2,e);
    }
    void update_f(ll& d,ll x){
        d=x;
    }
    ll dat_propergate(ll l,ll r){
        return min(l,r);
    }
    void lz_propergate(ll& l,ll& r,ll x){
        l=x,r=x;
    }
    void eval(int len,int k){
        if(lz[k]!=e) update_f(dat[k],lz[k]);
        if(len>1){//flag check!
            if(lz[k]!=e)lz_propergate(lz[k*2+1],lz[k*2+2],lz[k]);
        }
        lz[k]=e;
    }
    //range [a,b)
    void update(int a,int b,int k,int l,int r,ll x){
        eval(r-l,k);
        if(r<=a||b<=l) return;
        if(a<=l&&r<=b){
            update_f(lz[k],x);
            eval(r-l,k);
        }
        else{
            update(a,b,k*2+1,l,(l+r)/2,x);
            update(a,b,k*2+2,(l+r)/2,r,x);
            dat[k]=dat_propergate(dat[2*k+1],dat[2*k+2]);
        }
    }
    //range [a,b)
    ll query(int a,int b,int k,int l,int r){
        eval(r-l,k);
        if(r<=a||b<=l) return INF;
        if(a<=l&&r<=b) return dat[k];
        else{
            ll vl=query(a,b,k*2+1,l,(l+r)/2);
            ll vr=query(a,b,k*2+2,(l+r)/2,r);
            return dat_propergate(vl,vr);
        }
    }
    void update(int a,int b,ll x){
        return update(a,b,0,0,n,x);
    }
    ll query(int a,int b){
        return query(a,b,0,0,n);
    }
};

int main(){
    int n,q,c,s,t,x;
    cin>>n>>q;
    Lz_segtree seg(n);
    rep(i,q){
        cin>>c;
        if(c==0){
            cin>>s>>t>>x;
            seg.update(s,t+1,x);
        }
        else{
            cin>>s>>t;
            ll ans=seg.query(s,t+1);
            cout<<ans<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 7060
#include <stdio.h>
#include <queue>
#include <utility>
using namespace std;
int main(){
    int n,l,temp;
    priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >pq;
    scanf("%d%d",&n,&l);
    for(int i=0;i<l;i++){
        scanf("%d",&temp);
        pq.push(make_pair(temp,i));
    }
    printf("%d",pq.top().first);
    for(int i=l;i<n;i++){
        scanf("%d",&temp);
        pq.push(make_pair(temp,i));
        while(pq.top().second<=i-l)pq.pop();
        printf(" %d",pq.top().first);
    }
    printf("\n");
}

Measured memory_bytes: 10812
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    ll al[a],bl[b],cl[c];
    for (ll i=0;i<a;i++)cin >> al[i];
    for (ll i=0;i<b;i++)cin >> bl[i];
    for (ll i=0;i<c;i++)cin >> cl[i];
    sort(al,al+a);
    sort(bl,bl+b);
    sort(cl,cl+c);
    ll ans[x+y];
    for (ll i=0;i<x;i++){
        ans[i]=al[a-1-i];
    }
    for (ll i=0;i<y;i++){
        ans[i+x]=bl[b-1-i];
    }
    sort(ans,ans+x+y);
    for (ll i=0;i<c and i<x+y;i++){
        ans[i]=max(ans[i],cl[c-1-i]);
    }
    ll count=0;
    for (ll i=0;i<x+y;i++){
        count+=ans[i];
    }
    cout << count << endl;
    return 0;
}


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

int main()
{
	long int w,h,x,y;
    cin>>w>>h>>x>>y;

    cout<<w*h/2.0<<" "<<((double(x)==w/2.0&&double(y)==h/2.0)? 1:0)<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
LL a[204014], b[204014], c[204014], d[204014];
int book[204014];
LL get_f(LL f[], int x);
int main(){
  int n, k, l, i, u, v, t1, t2, id;
  while(~scanf("%d %d %d", &n, &k, &l)){
    for(i = 1; i <= n; i++)
      a[i] = b[i] = i;
    for(i=0; i < k; i++){
      scanf("%d %d", &u, &v);
      t1 = get_f(a, u);
      t2 = get_f(a, v);
      if(t1 != t2) a[t2] = t1;
    }
    for(i = 0; i < l; i++){
      scanf("%d %d", &u, &v);
      t1 = get_f(b, u);
      t2 = get_f(b, v);
      if(t1 != t2) b[t2] = t1;
    }

    LL e = n+1;
    for(i = 1; i <= n; i++){
      c[i] = get_f(a, i) + e*get_f(b, i);
      d[i] = c[i];
    }

    sort(d+1, d+1+n);
    memset(book, 0, sizeof(book));
    for(i = 1; i <= n; i++){
      id = lower_bound(d+1, d+1+n, c[i]) - d;
      book[id]++;
    }
    for(i = 1; i <= n; i++){
      id = lower_bound(d+1, d+1+n, c[i]) - d;
      printf("%d%c", book[id], i == n? '\n': ' ');
    }
  }
  return 0;
}
LL get_f(LL f[], int x){
  if(x == f[x]) return f[x];
  return f[x] = get_f(f, f[x]);
}

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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> b(n-1);
    for (int &i: b) scanf("%d", &i);
    b.push_back(1000000000);
    vector<int> a(n);
    a[0] = b[0];
    for (int i=1; i<n; i++) {
        a[i] = min(b[i-1], b[i]);
    }
    // for (int i: a) {
        // printf("%d ", i);
    // }
    // printf("\n");
    printf("%d\n", accumulate(a.begin(), a.end(), 0));
}

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

using namespace std;
#define ll long long int

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

	ll n,k,start;
	cin>>n>>k;
	ll arr[n+5]={0},h[n+5]={0};
	for (int i = 1; i <= n; ++i)
	{
		cin>>arr[i];
	}

	h[1]=1;start=1;
	// cout<<start<<" "<<h[start]<<endl;
	while(1){
		start=arr[start];
		// cout<<start<<" "<<h[start]<<endl;
		if(h[start])
			break;
		else
			h[start]=1;
	}
	// cout<<endl;
	ll left=0,loop=0,i=1;
	while(1){
		if(i==start)
			break;
		i=arr[i];
		left++;
		// cout<<i<<" "<<left<<endl;
	}
	// cout<<endl;
	loop++;
	i=arr[i];
	// cout<<i<<" "<<loop<<endl;
	while(1){
		if(i==start)
			break;
		i=arr[i];
		loop++;
		// cout<<i<<" "<<loop<<endl;
	}
	k-=left;
	if(k<0){
		k+=left;
		i=1;
		while(k){
			i=arr[i];
			k--;
		}
		cout<<i<<endl;
	}
	else{
		k=k%loop;
		i=start;
		while(k){
			i=arr[i];
			k--;
		}
		cout<<i<<endl;
	}

	return 0;
}


Measured memory_bytes: 6772
#include <stdio.h>

int main(void){
	int num;
	int array[100];
	int i, j, k;
	
	scanf("%d", &num);

	for(i = 0; i < num; i++){
		scanf("%d", &array[i]);
	}

	for(j = 0; j < num / 2; j++){
		int a = array[j];
		array[j] = array[(num - 1) - j];
		array[(num - 1) - j] = a;
	}

	for(k = 0; k < num; k++){
		printf("%d", array[k]);
		if(k != num - 1){
			printf(" ");	
		}
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

//Drawing Lots
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int[] a = new int[w+1];
		for(int i=1;i<=w;i++)a[i]=i;
		int m = sc.nextInt();
		while(m--!=0){
			String[] s = sc.next().split(",");
			int l = Integer.parseInt(s[0]);
			int r = Integer.parseInt(s[1]);
			int t = a[l];
			a[l] = a[r];
			a[r] = t;
		}
		for(int i=1;i<=w;i++)System.out.println(a[i]);
	}
}

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

#ifdef DONLINE_JUDGE
//freopen("a.in", "r", stdin);
//freopen("a.out","w",stdout); // console output is better (in most cases)
#else
// add i/o method of specific testing system
#endif

using namespace std;

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

    int m, n;
    while (cin >> m >> n, m || n)
    {
        for (int i = 0; i < m; ++i)
        {
            for (int j = 0; j < n; ++j)
            {
                if ((i + j) % 2)
                {
                    cout << ".";
                }
                else
                {
                    cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <bitset>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 1000050;
std::string S;
const int MAX_Q = 100;
int N, Q, k_in[MAX_Q];

long long solve(int k) {
    long long ret = 0;
    long long eff_D = 0;
    long long eff_M = 0;
    long long eff_DM = 0;
    
    for (int i = 0; i < N; i++) {
        if (S[i] == 'D') {
            eff_D++;
        } else if (S[i] == 'M') {
            eff_M++;
            eff_DM += eff_D;
        } else if (S[i] == 'C') {
            ret += eff_DM;
        }

        if (0 <= i - k + 1) {
            if (S[i-k+1] == 'D') {
                eff_D--;
                eff_DM -= eff_M;
            } else if (S[i-k+1] == 'M') {
                eff_M--;
            }
        }

        if (0 <= i - k) {
            if (S[i-k] == 'D') {
                //eff_DM -= eff_M;
            } else if (S[i-k] == 'M') {
                //eff_M--;
            }
        }
        //std::cout << "check:" << i << " " << eff_D << " " << eff_M << " " << eff_DM << " " << ret << std::endl;
    }

    return ret;
}

int main(int argc, char **argv) {
    std::cin >> N;
    std::cin >> S;
    std::cin >> Q;

    for (int i = 0; i < Q; i++) {
        std::cin >> k_in[i];
    }

    for (int i = 0; i < Q; i++) {
        std::cout << solve(k_in[i]) << std::endl;
    }

    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    string s;
    cin >> s;
    
    unordered_set<string> ans_set;
    unordered_set<string> small_set;
    small_set.insert("");

    for (auto c: s)
    {
        unordered_set<string> new_set = small_set;
        for (auto str: small_set)
        {
            // cout << c << ' ' << str << endl;
            if (str.size() < 2)
                new_set.insert(str+c);
            else
                ans_set.insert(str+c);
        }
        swap(small_set, new_set);
    }
    
    cout << ans_set.size() << endl;

    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    cin >> S;
    if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) cout << "Bad";
    else cout << "Good";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int product = a * b;
		if (product % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}

}


Measured memory_bytes: 21844
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200


int main(){
	int a[N];
	long long dp[N];
	long long dp2[N];
	int n, m, k, xx;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d %d %d", &n,&m,&xx);
	k = (1 << (m-1));
	f(i, m){
		dp[i] = 0;
		dp2[i] = 0;
	}
	dp[0] = 1;
	f(i, n){
		f(j, k){
			x = j;
			f(ii, m-1){
				a[ii] = x % 2;
				x = x / 2;
			}
			v = true;
			f(ii, m - 2){
				if (a[ii] == 1 && a[ii + 1] == 1)v = false;
			}
			if (v){
				f(ii, m){
					v = true;
					if (ii > 0){
						if (a[ii - 1] == 1){
							v = false;
							dp2[ii - 1] += dp[ii];
							dp2[ii - 1] = dp2[ii - 1] % MOD;
						}
					}
					if (ii < m-1){
						if (a[ii] == 1){
							v = false;
							dp2[ii + 1] += dp[ii];
							dp2[ii + 1] = dp2[ii + 1] % MOD;
						}
					}
					if (v){
						dp2[ii] += dp[ii];
						dp2[ii] = dp2[ii] % MOD;
					}
				}
			}
		}
		f(j, m){
			dp[j] = dp2[j];
			dp2[j] = 0;
		}
	}

	printf("%lld\n", dp[xx-1]);


	return 0;
}

Measured memory_bytes: 256
x = input()
visited = [0]*(len(x))
ans = 0
s = 0
t = 0
for i in range(len(x)):
    if not visited[i]:
        if x[i:i+2] == "ST":
            ans += 2
            visited[i+1] = 1
        elif x[i] == "S":
            s += 1
        elif x[i] == "T" and s:
            ans += 2
            s -= 1
print(len(x)-ans)

Measured memory_bytes: 4840
import java.util.Scanner;
public class Main {
	public static int INF = 10000000;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int min = INF;
		int max = -INF;
		long sum = 0;
		for(int i = 0;i<a.length;i++) {
			a[i] = sc.nextInt();
			if(min > a[i])  min = a[i];
			if(max < a[i]) max = a[i];
			sum += a[i];
		}
		System.out.println(min+" "+max+" "+sum);
	}
}



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


int main() {
  int a,b,c;
  cin >> a>>b>>c;
  if(a<=c&&a+b>=c){
    cout<<"YES"<<endl;
  }

  else{
    cout<<"NO"<<endl;
  }
  
}







Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
using namespace std;


int main(void)
{
	int N, Q; cin >> N >> Q;
	vector<lli> a(N); rep(i, 0, N)cin >> a[i];
	vector<lli> x(Q); rep(i, 0, Q)cin >> x[i];
	
	rep(que, 0, Q) {
		int r = 0;
		lli ans = 0;
		lli sum = 0;
		rep(l, 0, N) {
			while (r < N&&sum + a[r] <= x[que]) {
				sum += a[r];
				r++;
			}
			ans += (r - l);
			if (l == r)r++;
			else sum -= a[l];
		}
		cout << ans << endl;
	}


	return 0;
}



Measured memory_bytes: 3604
#include<stdio.h>

#define Max  1000
#define vMax 10000

int n, a[Max], s;
int b[Max], t[vMax + 1];


int partition(int a[], int p, int r){
  int i, j;
  int t, x;
  x = a[r];
  i = p - 1;

  for(j = p ; j < r ; j++){
    if(a[j] <= x){
      i++;
      t = a[i];
      a[i] = a[j];
      a[j] = t;
    }
  }

  t = a[i + 1];
  a[i + 1] = a[r];
  a[r] = t;

  return i + 1;
}

void quickSort(int a[], int p, int r){
  int q;
  if(p < r){
    q = partition(a, p, r);
    quickSort(a, p, q - 1);
    quickSort(a, q + 1, r);
  }
}



int solve(){
  int i,ans = 0, cur, S, m, an, v;

  int V[Max];
  for(i = 0 ; i < n ; i++){
    b[i] = a[i];
    V[i] = 0;
  }

  quickSort(b, 0, n - 1);

  for(i = 0 ; i < n ; i++) t[b[i]] = i;
  for(i = 0 ; i < n ; i++){
    if(V[i]) continue;
    cur = i;
    S = 0;
    m = vMax;
    an = 0;
    while(1){
      V[cur] = 1;
      an++;
      v = a[cur];

      if(v < m) m = v;

      S += v;
      cur = t[v];
      if(V[cur]) break;
    }
    if(S + (an -2) * m < m + S + (an + 1) * s) ans += S + (an -2) * m;
    else ans +=  m + S + (an + 1) * s;
  }
  return ans;
}


int main(){
  int i;

  scanf("%d", &n);
  s = vMax;
  for(i = 0 ; i < n ; i++){
    scanf("%d", &a[i]);
    if(a[i] < s) s = a[i];
}

  int ans = solve();
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
#define endl '\n'
#define for(i,s,n) for(int i=s;i<n;i++)
#define vii vector<int>
int t = 1, n, k;
vii v;
int dp[2][100001];
int solve(int player, int rem) {///0 for First ,1 for Second
	if (rem < 0) return player;
	int& ret = dp[player][rem];
	if (~ret) return ret;
	bool ok = 0;
	for (i, 0, n) {
		int r = solve((player + 1) % 2, rem - v[i]);
		if (r == player) ok = 1;
	}
	if (ok) return ret = player;
	else return ret = (player + 1) % 2;
}
signed main()
{
	fast;
	///cin>>t;
	while (t--)
	{
		memset(dp, -1, sizeof dp);
		cin >> n >> k;
		v = vii(n);
		for (i, 0, n) cin >> v[i];
		if (solve(0, k))
			cout << "Second\n";
		else
			cout << "First\n";
	}
}


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

using ld = long double;
using point = complex<ld>;

constexpr ld eps = 1e-10;

struct circle {
    circle(point p, ld r) : p(p), r(r) {}

    point p;
    ld r;

    bool operator<(const circle& other) const {
        return r < other.r;
    }
};

ld dist(point p1, point p2) {
    return abs(p1 - p2);
}

bool is_in_circle(circle const& c, point const& p) {
    auto d = dist(c.p, p);
    return d + eps < c.r;
}

// 1: -> cross or touch
// 0: -> otherwise
int is_cc(circle const& c1, circle const& c2) {
    const auto d = dist(c1.p, c2.p);
    const auto R = max(c1.r, c2.r), r = min(c1.r, c2.r);
    return R - r - eps <= d && d - eps <= R + r;
}

int rec(int i, vector<circle> const& cs, vector<int>& dp) {
    const int n = cs.size();
    if(dp[i] != -1) return dp[i];
    int& res = dp[i] = 1;
    for(int j = 0; j < i; ++j) {
        if(is_cc(cs[i], cs[j]) == 0) {
            res = max(res, rec(j, cs, dp) + 1);
        }
    }
    return res;
}

int main() {
    int n;
    while(cin >> n, n) {
        point s, t;
        {
            ld sx, sy, tx, ty;
            cin >> sx >> sy >> tx >> ty;
            s = point(sx, sy);
            t = point(tx, ty);
        }

        vector<circle> fish_c, rat_c;
        for(int i = 0; i < n; ++i) {
            ld x, y, r;
            cin >> x >> y >> r;
            circle c(point(x, y), r);
            if(is_in_circle(c, s) != is_in_circle(c, t)) {
                (is_in_circle(c, s) ? fish_c : rat_c).push_back(move(c));
            }
        }
        sort(begin(fish_c), end(fish_c));
        sort(begin(rat_c), end(rat_c));

        const int sz1 = fish_c.size(), sz2 = rat_c.size();
        vector<int> dp1(sz1, -1), dp2(sz2, -1);
        int ans = 0;
        for(int i = 0; i < sz1; ++i) {
            ans = max(ans, rec(i, fish_c, dp1));
        }
        for(int i = 0; i < sz2; ++i) {
            ans = max(ans, rec(i, rat_c, dp2));
        }
        for(int i = 0; i < sz1; ++i) {
            for(int j = 0; j < sz2; ++j) {
                if(is_cc(fish_c[i], rat_c[j]) == 1) continue;
                ans = max(ans, dp1[i] + dp2[j]);
            }
        }

        cout << ans << endl;
    }
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define rgi register int
#define rgl register long long
#define il inline

using namespace std;

const int oo = 0x3f3f3f3f;
const int N = 1e5 + 10;

int n;

struct PEO
{
	int id, val;
} p[N];

bool cmp(struct PEO a, struct PEO b)
{
	return a.val < b.val;
}

il int read()
{
	rgi x = 0, f = 0, ch;
	while(!isdigit(ch = getchar())) f |= ch == '-';
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

int main()
{
	n = read();
	for(rgi i = 1; i <= n; ++i)
	{
		p[i].val = read();
		p[i].id = i;
	}
	sort(p + 1, p + n + 1, cmp);
	for(rgi i = 1; i <= n; ++i)
		printf("%d ", p[i].id);
	return 0;
}


Measured memory_bytes: 1536
N,M=map(int,input().split())
list1=[]
for i in range(M):
    list1.append(list(map(int,input().split()))[1:])
plist=list(map(int,input().split()))
ans=0
for i in range(2**N):
    listtemp=[0]*N
    for j in range(N):
        listtemp[j]=(i>>j)
    for num in range(len(list1)):
        x=0
        for y in list1[num]:
            x+=(listtemp[y-1])
        if plist[num]!=x%2:
            break
    else:
        ans+=1
print(ans)

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


ll into(int s[8]){
  ll sum=0;
  for(int i=0; i<8; i++){
    sum=sum*10+s[i];
  }
  return sum;
}

int main(){
  int n;
  cin>>n;
  while(n--){
    long long a, b;
    int s[8];
    for(int i=0; i<8; i++)scanf("%1d", &s[i]);
    sort(s, s+8);
    a=into(s);
    sort(s, s+8, greater<int>());
    b=into(s);
    cout<<b-a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	string s[n];
	for(int i = 0; i < n; i++) {
		cin >> s[i];
	}
	
	int frontB = 0, backA = 0, fBbA = 0, insideAB = 0;
	bool isFrontB;
	
	for(int i = 0; i < n; i++) {
		isFrontB = false;
		if(*begin(s[i]) == 'B') {
			frontB++;
			isFrontB = true;
		}
		if(*(end(s[i])-1) == 'A') {
			backA++;
			if(isFrontB) fBbA++;
		}
		
		if(s[i].length() < 2) break;
		for(auto itr = begin(s[i]); itr != end(s[i]); itr++) {
			if(*itr == 'A' && *(itr+1) == 'B') insideAB++;
		}
	}
	
	int combinedAB = min(frontB, backA);
	if(fBbA != 0 && frontB == fBbA && backA == fBbA) combinedAB--;
	
	cout << insideAB + combinedAB << endl;
	
	return 0;
}

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

signed main()
{
    int k;cin>>k;
    set<int> dp;
    for(int i=1;i<10;i++)
        dp.insert(i);
    auto it=dp.begin();
    while(dp.size()<k)
    {
            int num=(*it *10)+(*it%10);
            if(*it%10!=0)
                dp.insert(num-1);
            dp.insert(num);
            if(*it%10!=9)
                dp.insert(num+1);
        it++;
    }
    it=dp.begin();
    advance(it,k-1);
    cout<<*it<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <string.h>
int n, r[128], t[13]; bool used[22370000]; char com[8], s[14];
int main() {
	scanf("%d", &n); r[65] = 1, r[67] = 2, r[71] = 3;
	for(int i = 2; i < 13; i++) t[i] = t[i - 1] + (1 << (2 * i - 2));
	for(int i = 0; i < n; i++) {
		scanf("%s %s", com, s);
		int h = 0, l = strlen(s);
		for(int j = 0; j < l; j++) h = h * 4 + r[s[j]];
		if(com[0] == 105) used[h + t[l]] = true;
		else puts(used[h + t[l]] ? "yes" : "no");
	}
}

Measured memory_bytes: 3944
#include "bits/stdc++.h"
using namespace std;
const long long INF = 1e18;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmin(x,y) x = min(x,y);
long long dp[20][20];

vector<long long>calc(vector<pair<int, int>>&A) {
	int n = A.size();
	sort(A.begin(), A.end());
	for (int i = 0; i < n + 1; ++i) {
		for (int j = 0; j < n + 1; ++j) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for (int l = 0; l < n; ++l) {
		for (int r = l + 1; r <= n; ++r) {
			{
				long long now = INF;
				for (int k = l; k < r; ++k) {
					long long s = 0;
					for (int i = l; i < r; ++i) {
						s += abs(A[i].first - A[k].first)*ll(A[i].second);
					}
					chmin(now, s);
				}
				rep(j, n) chmin(dp[r][j + 1], dp[l][j] + now);
			}
			{
				ll now = 0;
				for (int i = l; i < r; ++i) {
					now += abs(A[i].first)*ll(A[i].second);
				}
				rep(j, n + 1) chmin(dp[r][j], dp[l][j] + now);
			}
		}
	}

	vector<long long>res(n + 1, INF);
	rep(j, n + 1) res[j] = dp[n][j];
	return res;
}

int main() {
	int N;
	cin >> N;
	vector<int>X(N), Y(N), P(N);
	vector<long long >Ans(N + 1, INF);
	for (int n = 0; n < N; ++n) {
		cin >> X[n] >> Y[n] >> P[n];
	}
	for (int n = 0; n < (1 << N); ++n) {
		vector<pair<int, int>>Ax, Ay;
		for (int m = 0; m < N; ++m) {
			if (n >> m & 1) {
				Ax.emplace_back(X[m], P[m]);
			}
			else {
				Ay.emplace_back(Y[m], P[m]);
			}
		}
		vector<long long> dx = calc(Ax);
		vector<long long> dy = calc(Ay);
		for (int p = 0; p < dx.size(); ++p) {
			for (int q = 0; q < dy.size(); ++q) {
				Ans[p + q] = min(Ans[p + q], dx[p] + dy[q]);
			}
		}
	}
	for (int i = 0; i < N + 1; ++i) {
		cout << Ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3636
N_ko, M_hon = map(int, input().split())
Heights = list(map(int, input().split()))
# indexs = [i for i in range(1, N_ko + 1)]
indexs=[]

for i in range(M_hon):
    a, b = map(int, input().split())
    a -= 1
    b -= 1

    h_a = Heights[a]
    h_b = Heights[b]


    if (h_a > h_b):
        indexs.append(b)

    elif (h_b > h_a):
        indexs.append(a)
    
    else:
        indexs.append(a)
        indexs.append(b)

ans = N_ko - len(set(indexs))


print(ans)


Measured memory_bytes: 91336
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double area = r * r * Math.PI;
        double circumference = r * 2 * Math.PI;
        System.out.printf("%f %f", area, circumference);
        sc.close();
    }
}


Measured memory_bytes: 28348
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    ll a,b;
    ll x;
    cin >> x;
    ll ans_a;
    ll ans_b;
    ll check=0;
    rep(a,0,100){
        
        rep(b,0,100){
            if(pow(a,5)+pow(b,5)==x){
                ans_a = a;
                ans_b = b*-1;
                check =1; 
            }
            if(check==1){
                break;
            }
        }
        if(check==1){
            break;
        }
    }
    if(check==0){
        rep(a,0,200){
            rep(b,0,a+1){
                if(pow(a,5)-pow(b,5)==x){
                    ans_a = a;
                    ans_b = b;
                    check = 1;
                    break;
                }
                if(check==1){
                    break;
                }
            }
            if(check==1){
                break;
            }
        }
    }
    cout << ans_a << ' ' <<ans_b << endl;
    


  return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    for (int x = 1; x <=3500; ++x) {
        for (int y = 1; y <=3500; ++y) {
            ll s=n*x*y;
            ll t=4*x*y-n*y-n*x;
            if(t==0)continue;
            if(s%t==0){
                if(s/t>0){
                    cout <<x<<" "<<y<<" "<<s/t<<endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const ll INF = 4e18;
using P = pair<ll,ll>;

int main()
{
    int n,k;
    cin >> n >> k;
    vector<P> v(n);
    for(auto& [x,y] : v) cin >> x >> y;
    sort(all(v));//x0<x1<...
    ull res = INF;
    for(int i = 0; i < n; ++i) {
        for(int j = i+1; j < n; ++j) {
            for(int l = 0; l < n; ++l) {
                for(int r = l+1; r < n; ++r) {
                    ll minX = v[i].first;
                    ll maxX = v[j].first;
                    ll minY = min(v[l].second, v[r].second);
                    ll maxY = max(v[l].second, v[r].second);
                    int cnt = 0;
                    for(auto [x,y] : v) {
                        if(minX <= x && x <= maxX &&
                           minY <= y && y <= maxY) cnt++;
                    }
                    if(cnt >= k) chmin(res,(maxX-minX)*(ull)(maxY-minY));
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3660
import java.util.*

fun main(args: Array<String>) {
    val mod = 1000000007L
    val N = readInt()
    val v = readIntList().asSequence()
    val v0 = v.filterIndexed { index, i -> index % 2 == 0 }.groupBy { it }.map { it.key to it.value.size }.sortedByDescending { it.second }.toMutableList().apply { this.add(0 to 0) }
    val v1 = v.filterIndexed { index, i -> index % 2 == 1 }.groupBy { it }.map { it.key to it.value.size }.sortedByDescending { it.second }.toMutableList().apply { this.add(0 to 0) }

    val ans = N - if (v0[0].first != v1[0].first) v0[0].second + v1[0].second
                  else Math.max(v0[1].second + v1[0].second, v0[0].second + v1[1].second)

    println(ans)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt).toList()
fun readLongList() = readLine()!!.split(" ").map(String::toInt).toList()


Measured memory_bytes: 75820