akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cctype>
#include <vector>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5;
struct Edge
{   
    int next, to;
    Edge(int next = 0, int to = 0):next(next), to(to) {};
}edge[N<<1];
int tot, head[N];
void _add(int x, int y) { edge[++tot] = Edge(head[x], y), head[x] = tot; }
void add(int x, int y) { _add(x, y), _add(y, x); }
int n, f[N], fa[N], root, col[N];
vector<int> s[N];
void dfs(int x, int d)
{
    f[x] -= fa[x] != 0, col[x] = - 1, s[d].push_back(x);
    for(int i = head[x]; i; i = edge[i].next)
    {
        int y = edge[i].to;
        if(y == fa[x]) continue;
        fa[y] = x, dfs(y, d+1);
    } 
}
int main()
{
    n = read();
    if(n == 2) return puts("Second"), 0;
    for(int i = 1; i < n; ++i)
    {
        int x = read(), y = read();
        ++f[x], ++f[y], add(x, y);
    }
    for(int i = 1; i <= n; ++i) if(f[i] > 1) root = i;
    dfs(root, 1);
    for(int p = n; p; --p)
        for(int k = 0; k < s[p].size(); ++k)
        {
            int x = s[p][k];
            if(col[x] == -1&&col[fa[x]] == -1)
            {
                col[x] = 0, col[fa[x]] = 1, --f[fa[x]], --f[fa[fa[x]]];
                if(f[fa[x]]) return puts("First"), 0;
            }
            else if(col[x] == -1&&col[fa[x]] == 0) return puts("First"), 0;
        }
    puts("Second");
    return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <map>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;

int main()
{
    int s;
    cin >> s;
    int L = s/100;
    int R = s-100*L;
    if (L >= 1 && L <= 12)
    {
        if (R >= 1 && R <= 12) cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
    }else
    {
        if (R >= 1 && R <= 12) cout << "YYMM" << endl;
        else cout << "NA" << endl;
    }    
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

string To_NDig(ll n,int t){
    string res="";
    if(t==0) return 0;
    while(n!=0){
        int a = n%t;
        if(a<0) a += abs(t);
        n = (n - a) / t;
        res += char('0' + a);
    }
    reverse(res.begin(),res.end());
    if(res.size()==0) res = '0';
    return res;
}

int main(){
    int n,d=-2;
    cin >> n;
    cout << To_NDig(n,d) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int n;
main()
{
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int q;cin>>q;
  for(int i=0;i<q;i++)
  {
    int k;cin>>k;
    cout<<distance(a.begin(),lower_bound(a.begin(),a.end(),k))<<" "<<
    distance(a.begin(),upper_bound(a.begin(),a.end(),k))<<endl;
  }
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	
	if(x>__int128(k)*d){
		cout<<x-k*d;
		return 0;
	}
	else{
		ll y=x%d;
		ll i=(x-y)/d;
		
		if((k-i)%2)y=abs(y-d);
		cout<<y;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 3616
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.Map.Entry;

public class Main{
	
	public static void main(String[] args) throws IOException{
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		HashMap<Long, Long> map = new HashMap<Long, Long>();
		
		for(int i = 0; i < N; i++){
			long a = in.nextLong();
			Long count = map.get(a);
			if(count == null) map.put(a, Long.valueOf(1));
			else map.put(a, count+1);
		}
		
		List<Entry<Long, Long>> listEntries = new ArrayList<Entry<Long, Long>>(map.entrySet());
        
        Collections.sort(listEntries, new Comparator<Entry<Long, Long>>() {
            public int compare(Entry<Long, Long> obj1, Entry<Long, Long> obj2) {
                return obj2.getKey().compareTo(obj1.getKey());
            }
        });
        
        /*
        for(int i = 0; i < listEntries.size(); i++){
        	Entry e = listEntries.get(i);
        	System.out.println(e.getKey() + " " + e.getValue());
        }
        */
        
        long max1 = 0, max2 = 0;
        
        for(int i = 0; i < listEntries.size(); i++) {
        	Entry e = listEntries.get(i);
        	long k = (long)e.getKey();
        	long v = (long)e.getValue();
        	
        	if(v >= 4){
        		if(k > max1) max1 = k;
        		max2 = k;
        		break;
        	}else if(v >= 2){
        		if(max1 == 0) max1 = k;
        		else{
        			max2 = k;
        			break;
        		}
        	}
        }
        
        System.out.println(max1 * max2);
	}
}


Measured memory_bytes: 64120
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	int N, M;
	cin >> N >> M;
	priority_queue<ll> q;
	for (auto i = 0; i < N; ++i)
	{
		ll a;
		cin >> a;
		q.push(a);
	}

	for (auto i = 0; i < M; ++i)
	{
		auto a = q.top();
		q.pop();
		q.push(a / 2);
	}

	auto result = 0ll;
	while (!q.empty())
	{
		result += q.top();
		q.pop();
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in); 
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a < b) { 
            if (b < c) { 
                System.out.printf("%d %d %d\n", a, b, c);
            } else if (a < c) {
                System.out.printf("%d %d %d\n", a, c, b);
            } else {
                System.out.printf("%d %d %d\n", c, a, b);
            }
        } else {
            if (a < c) { 
                System.out.printf("%d %d %d\n", b, a, c);
            } else if (b < c) {
                System.out.printf("%d %d %d\n", b, c, a);
            } else {
                System.out.printf("%d %d %d\n", c, b, a);
            }
        }
    }
}


Measured memory_bytes: 26384
#include "bits/stdc++.h"
using namespace std;

#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 

#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

const int N =1e5+5;

int mod= 1e9+7;
int dx[4]={0,0,+1,-1};
int dy[4]={+1,-1,0,0};


void solve() {

  int n;
  string s;
  cin>>n;
  cin>>s;
   
  if(n<3200)
	   cout<<"red\n";
  else
	  cout<<s<<endl;
}

int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
		solve();


	return 0;	  
}



Measured memory_bytes: 256
#include <stdio.h>
#define max(a,b) (a)>(b)? (a):(b);

main(){
    int N,W;
    int v[100],w[100];
    int dp[101][15000]={{0,},};
    int i,j;

    scanf("%d %d",&N,&W);
    for(i=0;i<N;i++)
        scanf("%d %d",&v[i],&w[i]);

    for(i=1;i<=N;i++){
        for(j=0;j<=W+1;j++){
            if(j-w[i-1]<0)
                dp[i][j]=dp[i-1][j];
            else
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
        }
    }

    int maxv=-1;
    for(i=0;i<=W;i++){
        maxv=max(maxv,dp[N][i]);
    }
    printf("%d\n",maxv);

    return 0;
}

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

#define DEBUG

#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif

#define int long long
typedef long long ll;
//constexpr int INF = 1e9;
//constexpr int MOD = 1000000007;

decltype(1) main() {
    //cin.tie(nullptr);
    //ios_base::sync_with_stdio(false);
    int h;
    cin >> h;
    int ans = 0;
    constexpr int cnt = 1;
    for (int i = 0; h > 0; i++, h = h / 2) {
        ans += cnt << i;
    }
    cout << ans << endl;
    return 0;
}


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

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

    ll A[N + 1];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    A[N] = 0;

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += A[i] / 2;
        A[i] %= 2;
        if (A[i] > 0 && A[i + 1] > 0) {
            ++ans;
            --A[i];
            --A[i + 1];
        }
    }

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

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

int main()
{

	bool is_prime[50001];
	
	is_prime[0]=is_prime[1]=false;
	for(int i=2; i<50001; i++){
		is_prime[i]=true;
	}
	
	for(int i=2; i*i<50001; i++){
		if(is_prime[i]){
			for(int j=i*i; j<50001; j+=i){
				is_prime[j]=false;
			}
		}
	}
	
		
	while(true){
		int n;
		cin>>n;
		
		if(n==0)
break;
		int output=0;

		for(int i=0; i<=n/2; i++){
			if(is_prime[i] && is_prime[n-i])
			{
					output++;
			}
		}
		cout<<output<<endl;
	}
}
		

Measured memory_bytes: 3148
s = [int(i) for i in input()]
cnt = 0
for i in range(len(s) - 1):
    if s[i] == 0 and s[i + 1] == 0:
        s[i + 1] = 1
        cnt += 1
    elif s[i] == 1 and s[i + 1] == 1:
        s[i + 1] = 0
        cnt += 1
print(cnt)


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


class First_Grader{
public:
	First_Grader();
	~First_Grader();
	long long Calc();

private:
	int N;
	int max;
	long long* number;
	long long* F;
	long long* memo;
	

};

First_Grader::First_Grader(){

	max = 20;
	F = new long long[max + 1];
	memo = new long long[max + 1];

	cin >> N;
	number = new long long[N];

	for (int i = 0; i < N;i++){
		cin >> number[i];
	}

	for (int i = 0; i < max + 1; i++){
		F[i] = 0;
		memo[i] = 0;
	}

}


First_Grader::~First_Grader(){
	delete[] number;
	delete[] F;
	delete[] memo;
}

long long First_Grader::Calc(){
	for (int i = 0; i < N - 1 ; i++){

		if (i == 0)	F[number[i]] = 1;
		else{
			for (int j = 0; j < max + 1; j++){
				if (F[j] != 0){
					if (j + number[i] <= max) memo[j + number[i]] += F[j];
					if (j - number[i] >= 0) memo[j - number[i]] += F[j];
				}
			}
			for (int j = 0; j < max + 1; j++){
				F[j] = memo[j];
				memo[j] = 0;
			}
		}
	}
	return F[number[N - 1]];
}


int main(){
	First_Grader* solve = new First_Grader;
	cout << solve->Calc() << endl;
	delete solve;
	return 0;
}

Measured memory_bytes: 1200
while (list=gets)!=nil
	sum=0
	list=list.split(",").map{|i|i.to_i}
	v1,v2=list[10,2]
	
	for i in 0..9
		sum+=list[i]
	end
	
	r=v1*sum.quo(v1+v2)
	
	for i in 0..9
		r-=list[i]
		if r<=0.0
			puts i+1
			break
		end
	end
end

Measured memory_bytes: 6140
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<utility>
using std::max;
using std::min;
using std::pair;
using std::make_pair;
typedef long long ll;
const int N=1e4+5;
int n;
ll x[N],y[N];
int res[3];
int dp[64][2][3];
inline void calc(ll c,ll x,ll y,ll r)
{
	ll n=x-c;
	register int i,j,k;
	r-=y;
	if(r<0)
		return res[0]=res[1]=res[2]=0,void();
	memset(dp,0,sizeof(dp));
	dp[63][1][0]=1;
	for(i=63;i>0;i--)
		if(!(n>>(i-1)&1))
		{
			for(j=0;j<3;j++)
			{
				if(dp[i][0][j])
					dp[i-1][0][(j*2)%3]^=1;
				if(dp[i][1][j])
				{
					if(r>>(i-1)&1)
						dp[i-1][0][(j*2)%3]^=1;
					else
						dp[i-1][1][(j*2)%3]^=1;
				}
			}
		}
		else
		{
			for(j=0;j<3;j++)
			{
				if(dp[i][0][j])
				{
					dp[i-1][0][(j*2)%3]^=1;
					dp[i-1][0][(j*2+1)%3]^=1;
				}
				if(dp[i][1][j])
				{
					if(r>>(i-1)&1)
						dp[i-1][0][(j*2)%3]^=1,dp[i-1][1][(j*2+1)%3]^=1;
					else
						dp[i-1][1][(j*2)%3]^=1;
				}
			}
		}
	y=(y%3+3)%3;
	res[y]=dp[0][0][0]^dp[0][1][0];
	res[(y+1)%3]=dp[0][0][1]^dp[0][1][1];
	res[(y+2)%3]=dp[0][0][2]^dp[0][1][2];
	return;
}
int lres[3],rres[3],mres[3];
inline ll epc(ll c)
{
	int k;
	ll l=-1000000000000000000ll,r=1000000000000000000ll,mid;
	register int i;
	rres[0]=rres[1]=rres[2]=0;
	for(i=1;i<=n;i++)
	{
		calc(c,x[i],y[i],r);
		rres[0]^=res[0];rres[1]^=res[1];rres[2]^=res[2];
	}
	lres[0]=lres[1]=lres[2]=0;
	for(i=0;i<3;i++)
		if(rres[i])
		{
			k=i;
			break;
		}
	while(l<r)
	{
		mid=(l+r)>>1;
		mres[0]=mres[1]=mres[2]=0;
		for(i=1;i<=n;i++)
		{
			calc(c,x[i],y[i],mid);
			mres[0]^=res[0];mres[1]^=res[1];mres[2]^=res[2];
		}
		if(mres[k]^lres[k])
			r=mid,memcpy(rres,mres,sizeof(int)*3);
		else
			l=mid+1,memcpy(lres,mres,sizeof(int)*3);
	}
	return l;
}
inline bool light(ll x,ll y)
{
	int res=0;
	ll xx,yy,n,m;
	register int i;
	for(i=1;i<=::n;i++)
	{
		xx=::x[i];yy=::y[i];
		n=xx-x;m=y-yy;
		if(m<0||m>n)
			continue;
		res^=((n|m)==n);
	}
	return res;
}
inline void solve(ll c,pair<ll,ll> &a,pair<ll,ll> &b)
{
	ll k=epc(c),lk=k,rk=k;
//	fprintf(stderr,"%lld\n",k);
	register ll i;
	for(i=1ll<<62;i;i>>=1)
		if(light(c,lk-i))
			lk-=i;
	for(i=1ll<<62;i;i>>=1)
		if(light(c,rk+i))
			rk+=i;
	a.first=c+(rk-lk);a.second=lk;
	b.first=c-(rk-lk);b.second=rk;
	return;
}
signed main()
{
	pair<ll,ll> a1,a2,b1,b2;
	register int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%lld%lld",&x[i],&y[i]);
	solve(-100000000000000000,a1,a2);
	solve(-100000000000000001,b1,b2);
	if(a1==b1||a1==b2)
		printf("%lld %lld\n",a1.first,a1.second);
	else
		printf("%lld %lld\n",a2.first,a2.second);
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

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

vector<int> h[12];

void solve() {
  int n; string s; cin >> n >> s;
  for (int i = 0; i < n; ++i) {
    h[s[i]-'0'].push_back(i);
  }
  set<string> ss;
  for (int i = 0; i < n-2; ++i) {
    for (char j = 0; j < 10; ++j) {
      int ij = upper_bound(h[j].begin(), h[j].end(), i)-h[j].begin();
      int cj = h[j].size() - ij;
      if (!cj) continue;
      for (char k = 0; k < 10; ++k) {
	int ik = upper_bound(h[k].begin(), h[k].end(), h[j][ij])-h[k].begin();
	int ck = h[k].size() - ik;
	if (!ck) continue;
	ss.insert(string({s[i], s[h[j][ij]], s[h[k][ik]]}));
      }
    }
  }
  printf("%d", ss.size());
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 512
H, W = map(int, input().split())
a = []
for i in range(H):
    a.append(input())

allwhiteh = [1] * H
allwhitev = [1] * W
for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            allwhiteh[i] = 0
            allwhitev[j] = 0

for i in range(H):
    for j in range(W):
        if not allwhiteh[i] and not allwhitev[j]:
            print(a[i][j], end="")
    if not allwhiteh[i]:
        print("")




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

using pint = pair<ll, ll>;
ll N;
vector<pint> A;

int main(){
    cin >> N;
    A.resize(N);
    for(ll i = 0; i < N; i++){
        cin >> A[i].first;
        A[i].second = i+1;
    }
    sort(A.begin(), A.end());
    for(ll i=0; i<N; i++){
        cout << A[i].second << " ";
    }

    return 0;
}

Measured memory_bytes: 4752
# B
import numpy as np
N, M = map(int, input().split())
mat = np.zeros((N, N))
for i in range(M):
    a, b = map(int, input().split())
    mat[a-1, b-1] += 1
    mat[b-1, a-1] += 1

for n in range(N):
    print(int(mat[n, :].sum()))

Measured memory_bytes: 21892
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
using namespace std;
int main(){
    ll x;
    cin>>x;
    for(ll i=0;i<100000;i++){
        if(x<=i*(i+1)/2){
            cout<<i<<endl;
            return 0;
        }
    }
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>

int field[90][90];
bool visited[90][90];

int h,w,depth;

void dfs(int x,int y,int d);

int main()
{
	
	while(1)
	{
		std::cin>>w>>h;
		if(w==0&&h==0)break;
		
		memset(field,0,sizeof(field));
		depth=0;
		
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				std::cin>>field[i][j];
			}
		}
		
		for(int y=0;y<h;y++)
		{
			for(int x=0;x<w;x++)
			{
				if(field[y][x]==1)
				{
					memset(visited,0,sizeof(visited));
					dfs(x,y,1);
				}
			}
		}
		
		std::cout<<depth<<std::endl;
	}
	return 0;
}

void dfs(int x,int y,int d)
{
	visited[y][x]=true;
	
	if(y>0&&field[y-1][x]==1&&!visited[y-1][x])dfs(x,y-1,d+1);
	if(y<h-1&&field[y+1][x]==1&&!visited[y+1][x])dfs(x,y+1,d+1);
	if(x>0&&field[y][x-1]==1&&!visited[y][x-1])dfs(x-1,y,d+1);
	if(x<w-1&&field[y][x+1]==1&&!visited[y][x+1])dfs(x+1,y,d+1);
	visited[y][x]=false;
	depth=std::max(depth,d);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int a,b;
  cin >> a >> b;
  a %= b;
  cout << min(a,abs(a-b));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

vec a(100010);
ll row = 0;
void line_s(ll bit){
    ll id = -1;
    reps(i,row,N) if((a[i]>>bit)&1) id = i;
    //cout<<bit<<' '<<id<<endl;
    if(id == -1) return;
    swap(a[row], a[id]);
    rep(i,N) if((i != row) && (((a[i]>>bit)&1))) a[i] ^= a[row];
    ++row;
    return;
}

int main() {
    cin>>N;
    M = 0;
    rep(i,N) {
        cin>>a[i];
        M ^= a[i];
    }
    for(ll i = 59; i >= 0; --i) if((((M>>i)&1) == 0) && (row < N)) line_s(i);
    ll ans = 0;
    rep(i,row) ans ^= a[i];
    cout<<(ans|M)*2 - M<<endl;
    //cout<<M<<' '<<ans<<endl;
}

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

double det(double a, double b, double c, double d){
	return a*d - b*c ;
}

int main() {
	// your code goes here
	
	double a,b,c,d,e,f;
	double x,y;
	while(cin>>a>>b>>c>>d>>e>>f){
		x=det(c,b,f,e)/det(a,b,d,e);
		y=det(a,c,d,f)/det(a,b,d,e);
		if(x==0){x=0;}  if(y==0){y=0;}
		cout<<fixed<<setprecision(3)<<x<<" "<<y<<endl;
	}
	return 0;
}

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

#define ull unsigned long long
#define ll long long
#define imei(...)   "[ "<< #__VA_ARGS__ <<" = "<< __VA_ARGS__ <<" ] "

using namespace std;

int main(void)
{
    int x;
    cin >> x;
    if (!x) {
        cout << "1";
    } else if (x==1) {
        cout <<"0";
    }

    return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
using namespace std;
long long f[200000];
int main()
{
	long long n,ans=0;
	scanf("%lld",&n);
	for (int i=0;i<n;i++)
	{
		scanf("%lld",&f[i]);
		f[i]-=i+1;
	}
	nth_element(f,f+((n-1)>>1),f+n);
	int b=f[((n-1)>>1)];
	for (int i=0;i<n;i++) ans+=abs(f[i]-b);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1664
n,m=map(int,input().split())
C=list(map(int,input().split()))

dp=[[float('inf')]*(n+1) for i in range(m+1)]
for i in range(m+1):
    dp[i][0]=0

for i in range(1,m+1):
    c=C[i-1]
    for j in range(1,n+1):
        dp[i][j]=dp[i-1][j]
        if j>=c:
            dp[i][j]=min(dp[i][j],dp[i-1][j-c]+1,dp[i][j-c]+1)

print(dp[m][n])
        


Measured memory_bytes: 43784
import sys
import math
for line in sys.stdin:
    xa,ya,xb,yb,xc,yc,xd,yd = [float(i) for i in line.split(",")]
    
    # 図形の凸性:各頂点における外積を計算し、一つでも符号の異なるものがあれば非凸
    ab = (xb-xa,yb-ya)
    bc = (xc-xb,yc-yb)
    cd = (xd-xc,yd-yc)
    da = (xa-xd,ya-yd)
    va = da[0]*ab[1] - da[1]*ab[0]
    vb = ab[0]*bc[1] - ab[1]*bc[0]
    vc = bc[0]*cd[1] - bc[1]*cd[0]
    vd = cd[0]*da[1] - cd[1]*da[0]
    if all(map(lambda x:x/abs(x) == 1.0,[va,vb,vc,vd])) or all(map(lambda x:x/abs(x) == -1.0,[va,vb,vc,vd])):
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstdlib>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

const int INF = 1 << 30;

typedef pair<int, int> pii;

#define mp make_pair
#define fi first
#define se second

vector<pii> v[2];

map<int, int> mymap[2];

int a, n, res;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n; res = n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a;
		mymap[i & 1][a]++;
	}
	for (int k = 0; k < 2; k++)
		for (auto x : mymap[k])	
			v[k].emplace_back(mp(x.second, x.first));
	v[0].emplace_back(mp(0, 0));
	v[1].emplace_back(mp(0, 0));
	for (int k = 0; k < 2; k++)
	{
		sort(v[k].begin(), v[k].end());
		reverse(v[k].begin(), v[k].end());
	}
	if (v[0][0].se != v[1][0].se)
		cout << n - v[0][0].fi - v[1][0].fi << endl;
	else
		cout << min(n - v[0][0].fi - v[1][1].fi, n - v[0][1].fi - v[1][0].fi) << endl;
	return 0;	
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,k; cin>>n>>k;
    ll num[210000]={};
    rep(i,n){
        ll a; cin>>a;
        num[--a]++;
    }
    sort(num,num+n);
    ll ans=0;
    rep(i,n-k) ans+=num[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5228
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

int[30][30] DC;
int[30][3] CS;

void main()
{
    auto nc = readln.split.to!(int[]);
    auto N = nc[0];
    auto C = nc[1];

    foreach (i; 0..C) {
        foreach (j, d; readln.split) {
            DC[i][j] = d.to!int;
        }
    }

    foreach (i; 0..N) {
        foreach (j, c; readln.split) {
            CS[(i+j+2)%3][c.to!int-1]++;
        }
    }

    auto ret = long.max;
    foreach (a; 0..C) {
        foreach (b; 0..C) {
            if (b == a) continue;
            foreach (c; 0..C) {
                if (a == c || b == c) continue;
                long sum;
                foreach (x, aa; CS[0][0..C]) sum += DC[x][a] * aa;
                foreach (x, bb; CS[1][0..C]) sum += DC[x][b] * bb;
                foreach (x, cc; CS[2][0..C]) sum += DC[x][c] * cc;
                ret = min(ret, sum);
            }
        }
    }

    writeln(ret);
}

Measured memory_bytes: 4732
#include "bits/stdc++.h"

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

const ll MOD = 998244353;

ll n, k, cur = 0;
vector<pair<ll, ll>> v;
vector<ll> dp, ex;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    dp.assign(n + 1, 0);
    ex.assign(n + 5, 0);
    v.assign(k, {0, 0});
    for(int i = 0; i < k; ++i){
        cin >> v[i].f >> v[i].s;
    }
    dp[0] = 1;
    for(int i = 0; i <= n; ++i){
        cur += ex[i];
        dp[i] += cur;
        for(auto [x, y] : v){
            if(i + x > n) continue;
            if(i + y > n) y = n - i;
            ex[i + x] += dp[i];
            ex[i + x] %= MOD;
            ex[i + y + 1] -= dp[i];
            ex[i + y + 1] = (ex[i + y + 1]%MOD + MOD)%MOD;
        }
    }
    // for(auto i : dp) cout << i << " ";
    cout << (dp[n - 1]%MOD + MOD)%MOD;
    return 0;
}

Measured memory_bytes: 6368
#include<stdio.h>
int main(void) {
	int n, i, j;
	while (1) {
		int count = 0,
			x = 0;
		scanf("%d", &n);
		if (n == 0) break;
		for (i = 0; i < n / 2;i++) {
			for (j = i+1; x <= n;j++) {
				x += j;
				if (n == x) count++;
			}
			x = 0;
		}
		printf("%d\n",count);
	}
	return 0;
}

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


constexpr double EPS = 1E-10;
// constexpr double EPS = 1E-5;

double add(double a, double b) {
    if (abs(a+b) < EPS * (abs(a) + abs(b))) return 0;
    return a+b;
}

struct P
{
    double x, y;
    P() {}
    P(double x, double y) : x(x), y(y) {}
    P operator + (P p) {
        return P(add(x, p.x), add(y, p.y));
    }
    P operator - (P p) {
        return P(add(x, -p.x), add(y, -p.y));
    }
    P operator * (double d) {
        return P(x*d, y*d);
    }
    double dot(P p) {
        return add(x*p.x, y*p.y);
    }
    double det(P p) {
        return add(x*p.y, -y*p.x);
    }
    double norm()
    {
        return sqrt(x*x+y*y);
    }
};

bool operator < (const P& a, const P& b) {
    return a.x != b.x ? a.x < b.x : a.y < b.y;
}

int ccw(P a, P b, P c)
{
    P v1 = b-a;
    P v2 = c-a;
    if (v1.det(v2) > EPS) return 1;
    if (v1.det(v2) < EPS) return -1;
    if (v1.dot(v2) < EPS) return 2;
    if (v1.norm() < v2.norm()) return -2;
    return 0;
}

double cosine(P a, P b, P c)
{
    P v1 = a - b;
    P v2 = c - b;
    return max(min(v1.dot(v2) / v1.norm() / v2.norm(), 1.0), -1.0);
}

vector<pair<P, int> > convex_hull(vector<pair<P, int> >& ps)
{
    if (ps.size() == 0) return vector<pair<P, int> >(0);
    if (ps.size() == 1) return ps;
    vector<pair<P, int> > points = ps;
    sort(points.begin(), points.end());
    int n = points.size();
    int k=0;
    vector<pair<P, int> > qs(2*n);
    for (int i=0; i<n; i++) {
        while (k>1 && ccw(qs[k-2].first, qs[k-1].first, points[i].first) <= 0) k--;
        qs[k++] = points[i]; 
    }
    for (int i=n-2, t=k; i>=0; i--) {
        while (k>t && ccw(qs[k-2].first, qs[k-1].first, points[i].first) <= 0) k--;
        qs[k++] = points[i];
    }
    qs.resize(k-1);
    return qs;
}


int main()
{
    int N;
    cin >> N;
    if (N == 2)
    {
        cout << "0.5\n0.5" << endl;
        return 0;
    }
    vector<pair<P, int> > points(N);
    for (int i=0; i<N; i++)
    {
        int x, y;
        cin >> x >> y;
        points[i] = make_pair(P(x, y), i);
    }

    vector<pair<P, int> > totsu = convex_hull(points);

    vector<double> ans(N, 0.0);
    int n = (int)totsu.size();
    for (int i=0; i<n; i++)
    {
        // cout << totsu[i].first.x << " " << totsu[i].first.y << " " << totsu[i].second << endl;
        ans[totsu[i].second] = acos(-cosine(totsu[(i-1+n)%n].first, totsu[i].first, totsu[(i+1)%n].first)) / 3.14159265358979 / 2.0;
    }
    for (auto d : ans) cout << std::setprecision(10) << d << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque

N, K = map(int, input().split(' '))
P = list(map(int, input().split(' ')))

# 累積和
sum_list = [0] * (N + 1)
sum_list[0] = 0
for i in range(1, N+1):
    sum_list[i] = sum_list[i-1] + P[i-1]

max_sum = 0
for i in range(N-K+1):
    s = sum_list[i+K] - sum_list[i]
    if max_sum < s:
        max_sum = s

ans = (max_sum + K) / 2

print(ans)


Measured memory_bytes: 25572
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

main :: IO ()
main = do
  [n, m] <- readInts
  edges <- replicateM m $ do
    [a, b] <- readInts
    return (a-1, b-1)
  let graph = createGraph n edges
  print $ solve n graph

type Graph = [[Int]]

createGraph :: Int -> [(Int, Int)] -> Graph
createGraph n edges = loop (replicate n []) edges
  where updateGraph i v graph = concat [take i graph, [v : (graph !! i)], drop (i+1) graph]
        loop graph [] = graph
        loop graph ((a,b):es) =
          let nextGraph = updateGraph b a $ updateGraph a b graph
          in loop nextGraph es

solve :: Int -> Graph -> Int
solve n graph = dfs 0 1 [0]
  where dfs i depth visited
          | depth == n = 1
        dfs i depth visited
          | nexts == [] = 0
          | otherwise = sum $ flip map nexts $ \w -> dfs w (depth+1) (w:visited)
            where nexts = filter (not . (`elem` visited)) $ graph !! i

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"


Measured memory_bytes: 1020
/**
 *    author:  FromDihPout
 *    created: 2020-06-20
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int ans = 0, n = (int) s.length();
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i-1]) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int E = max(A,C);
    int F = min(B,D);
    if (F - E <= 0){
        cout << 0 << endl;
    }
    else{
        cout << F - E << endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define For(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define Max(x) *max_element(ALL(x))
#define Min(x) *min_element(ALL(x))
#define Lower_bound(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define Upper_bound(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define itn int
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

template <class T = int>
int in() {
  T x;
  cin >> x;
  return x;
}
int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}

signed main() {
  int n = in();
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  vector<int> ans(n);
  if (n % 2 == 1) {
    ans[n / 2] = a[0];
    For(i, 1, n) {
      if (i % 2) {
        ans[n / 2 + (i + 1) / 2] = a[i];
      } else {
        ans[n / 2 - i / 2] = a[i];
      }
    }
  } else {
    rep(i, n) {
      if (i % 2 == 0) {
        ans[n / 2 - 1 + (i + 2) / 2] = a[i];
      } else {
        ans[n / 2 - (i + 1) / 2] = a[i];
      }
    }
  }
  rep(i, n - 1) {
    cout << ans[i] << " ";
  }
  cout << ans[n - 1] << endl;
}


Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

int main(void){
    int a, b;
    cin >> a >> b;
    
    if(b % a == 0){
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli i, o, t, j, l, s, z;
int main() {
  cin >> i >> o >> t >> j >> l >> s >> z;
  lli ans = o;
  if (i>0 && j>0 && l>0
      && ((j%2==1 && l%2==1)
      || (i%2==1 && j%2==1)
      || (i%2==1 && l%2==1))) {
    --i; --j; --l;
    ans += 3;
  }
  ans += i/2*2 + j/2*2 + l/2*2;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int max_n = 1e6;
map<int,int> table;
int n;
typedef long long ll;
ll k;
int main(){
  cin >> n >> k;
  vector<pair<ll, ll> > v(n);
  for(int i=0 ; i<n ; i++){
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end());
  ll sum = 0;
  ll res = 0;
  for(int i=0 ; i<n ; i++){
    sum += v[i].second;
    if(sum >= k){
      res = v[i].first;
      break;
    }
  }
  cout << res << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int b, f, r, v;
    int a[4][3][10];
    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 10; k++){
                a[i][j][k] = 0;
            }
        }
    }

    for (int i = 0; i < n; i++){
        cin >> b >> f >> r >> v;
        a[b-1][f-1][r-1] += v;
    }

    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 10; k++){
                cout << " " << a[i][j][k];
            }
            cout << "\n";
        }
        if (i < 3){
            cout << "####################" << "\n";
        }

    }

    return 0;
}

Measured memory_bytes: 3072
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
    a:i64,b:i64,
     }

    println!("{}", lcm(a, b));
}
pub fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
pub fn lcm(a: i64, b: i64) -> i64 {
    a / gcd(a, b) * b
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}

struct TT{
	LL a,b;
}tt,ss;
LL t,n,m,ans;
LL MOD=1e9+7;
char a[22],b[111];

int main()
{
//	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,res,cnt=0;
	cin>>a;
	l=strlen(a);
	for(i=0;i<l;i++){
		if(a[i]=='0'||a[i]=='1')b[cnt++]=a[i];
		else cnt--;
		if(cnt<0)cnt=0;
	}
	for(i=0;i<cnt;i++)putchar(b[i]);puts("");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N;
int table[100005];

int main(){

	scanf("%d",&N);

	int pre = -1;
	bool FLG = true;

	for(int i = 0; i < N; i++){

		scanf("%d",&table[i]);
		if(!FLG)continue;

		if(pre > table[i]){

			FLG = false;
			continue;
		}

		if(pre < table[i]){

			table[i]--; //低くした方が後々有利

		}else if(pre == table[i]){

			//Do nothing
		}
		pre = table[i];
	}

	if(FLG){

		printf("Yes\n");

	}else{

		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 640
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 28-Mar-20 6:43:57 PM
	flamers will **** you
*/
//#include<flamers.h>

#include "bits/stdc++.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define POB pop_back

using namespace std;

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
//	cout<<"hi"<<endl;
	int k, n;
	cin>>k>>n;
	// k - an + a1
	
	int mx = 0;
	int a[n];
	for(int i = 0; i < n; i++) cin>>a[i];
	for(int i = 1; i < n; i++) {
		mx=  max(mx, a[i] - a[i-1]);
	}
	mx = max(mx, k - a[n-1] + a[0]);
	cout<<k - mx<<endl;
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
data_ls = list()
flg = 0
for i in range(N):
    data_ls.append([int(i) for i in input().split()])
t,x,y = zip(*data_ls)
data_ls = [(t[0], x[0], y[0])]
for i in range(len(t) - 1):
    data_ls.append((t[i+1] - t[i], x[i+1] - x[i], y[i+1] - y[i]))

def detect_possible(_list):
    t, x, y = _list
    move = abs(x) + abs(y)
    if move <= t and (move - t) % 2 == 0:
        return True
    else:
        return False

for i in data_ls:
    result = detect_possible(i)
    if not result:
        flg += 1
        break

if flg > 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 30552
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 998244353;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

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

ll i,j,k,ii,jj,n,m,a,b,c,d,e,f,g,h,r,w,l,num,sum,ans,ok,ng,mid;
ll x[500005],y[500005],z[500005];
char s[500005],t[500005],u[500005];
bool like[5000];
bool dame,flag;
//string s;
int main(){
	cin >> n >> m;
	for(i=0;i<n;i++){
		cin >> k;
		for(j=0;j<m;j++){
			like[j] = false;
		}
		for(j=0;j<k;j++){
			cin >> a;
			like[a-1] = true;
		}
		for(j=0;j<m;j++){
			if(like[j])x[j]++;

		}
	}
	for(i=0;i<m;i++){
		if(x[i] == n)ans++;
	}
	p(ans);

	return 0;
}

Measured memory_bytes: 26624
#include<iostream>
using namespace std;
int n,a[50];
int solve(int i,int m)
{
	if(m==0) return 1;
	if(i>=n) return 0;
	int res=solve(i+1,m)||solve(i+1,m-a[i]);
	return res;
}
int main()
{
	int q,m,i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cin>>q;
	for(i=0;i<q;i++)
	{
		cin>>m;
		if(solve(0,m))
		cout<<"yes"<<endl;
		else
		cout<<"no"<<endl; 
	}
	return 0;
}

Measured memory_bytes: 3056
#include <iostream>
#include <algorithm>
using namespace std;
int main(){

  int a,b,c;

  cin>>a>>b>>c;

  if (a > b) 
    swap(a , b);

  if (b > c)
    swap(b , c);

  if (a > b)
    swap(a , b) ;

  cout<< a<<" "<<b<<" "<<c<<endl;

  return 0;}

Measured memory_bytes: 1168
#include <cstdio>

using namespace std;

int main()
{
  double a, b, c, d, e, f;
  while(scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) != -1){
    double y = 0, x = 0;
    double g = e * a;
    double h = f * a;
    double i = b * d;
    double j = c * d;
    double k = i - g;
    double l = j - h;
    y = l / k;
    x = (c - b*y) / a;

    printf("%.3lf %.3lf\n", x, y);
  }
  return 0;
}

Measured memory_bytes: 1080
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  if(abs(a-b)<=k&&abs(b-c)<=k||abs(a-c)<=k)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  }


Measured memory_bytes: 3536
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)

int main(){
    int n;
	while(cin >> n, n) {
		vector<pair<int, int> > v;
		rep(i,n) {
			pair<int, int> p;
			int s=0, m;
			cin >> p.second;
			rep(j,4) {
				cin >> m;
				s += m * 60;
				cin >> m;
				s += m;
			}
			p.first = s;
			v.push_back(p);
		}
		sort(v.begin(), v.end());
		cout << v[0].second << endl << v[1].second << endl << v[v.size()-2].second << endl;
	}
    return 0;
}

Measured memory_bytes: 1304
#include<iostream>
using namespace std;
int main(void) {
	int a;
	int b;
	int c;

	scanf("%d%d%d",&a,&b,&c);
	if (a + b + c < 22) {
		cout << "win";
	}
	else {
		cout << "bust";
	}
	return 0;
}

Measured memory_bytes: 888
#include <iostream>

using namespace std;

using ll = long long;

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

typedef pair<int, int> P;

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

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while (1) {
		int r0, w0, c, r;
		cin >> r0 >> w0 >> c >> r;
		if (r0 == 0) break;
		
		if ((double) r0 / w0 >= (double) c) cout << 0 << endl;
		else {
			int x = 1;
			while (r0 + x * r < c * w0) ++x;
			cout << x << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3136
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int a[200005];
int c[200005];
int main()
{
	int n,k,i,j,b,d;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)
	{
		scanf("%d",&b);
		a[b]++;
	}
d=0;
	for(i=0;i<=n;i++)
	{
		if(a[i])
		c[d++]=a[i];
	}
	sort(c,c+d);
	int ct=0;
	int x=d;
	for(i=0;i<x&&k<d;i++)
	{
		ct+=c[i];
		d--;
	}
	printf("%d\n",ct);
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
 
public class Main{
	int N;
	int M;
	int[] bits;
	int[] rl;
	public void solve(){
		N = nextInt();
		M = nextInt();
		bits = new int[N];
		for(int i = 0; i < N; i++){
			bits[i] = nextInt();
		}
		
		rl = new int[M];
		for(int i = 0; i < M; i++){
			rl[i] = nextInt();
		}
		int[] bb = new int[N];
		int idx = 0;
		for(int i = 0; i < M; i++){
			for(int j = 0; j < rl[i]; j++){
				bb[idx++] = i % 2;
			}
		}
		int a = swap(bits, bb);

		idx = 0;
		for(int i = 0; i < M; i++){
			for(int j = 0; j < rl[i]; j++){
				bb[idx++] = (i + 1) % 2;
			}
		}
		int b = swap(bits, bb);
		out.println(Math.min(a, b));
	}
	
	public int swap(int[] a, int[] b){
		int ans = 0;
		for(int i = 0; i < a.length; i++){
			if(a[i] != b[i]){
				
				int idx = -1;
				for(int j = i + 1; j < b.length; j++){
					if(a[i] == b[j]){
						idx = j;
						break;
					}
				}
				if(idx == -1) return Integer.MAX_VALUE;
				for(int j = idx; j > i; j--){
					swap(b, j, j - 1);
					ans++;
				}
			}
		}
		return ans;
	}
 
	public void swap(int[] a, int i, int j){
		int tmp = a[i];
		a[i] = a[j];
		a[j] = tmp;
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 24396
#include <stdio.h>
 
int main(void){
    int i,dice[7];
    char order[101];
     
    for(i=1;i<7;i++)
        scanf("%d", &dice[i]);
     
    scanf("%s", order);
     
    for(i=0;order[i]!='\0';i++){
         
        dice[0] = dice[1];
         
        switch(order[i]){
                 
            case 'E':
                dice[1] = dice[4];
                dice[4] = dice[6];
                dice[6] = dice[3];
                dice[3] = dice[0]; 
                break;
             
            case 'N':
                dice[1] = dice[2];
                dice[2] = dice[6];
                dice[6] = dice[5];
                dice[5] = dice[0]; 
                break;
             
            case 'S':
                dice[1] = dice[5];
                dice[5] = dice[6];
                dice[6] = dice[2];
                dice[2] = dice[0]; 
                break;
                 
            case 'W':
                dice[1] = dice[3];
                dice[3] = dice[6];
                dice[6] = dice[4];
                dice[4] = dice[0]; 
                break;
 
        }
    }
     
    printf("%d\n", dice[1]);
     
    return 0;
}


Measured memory_bytes: 2088