akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

int eye[2][4];
double x[2];

int main(){
	while(scanf("%lf%lf",&x[0],&x[1]) != EOF){
		for(int i = 0; i < 2; i++){
			if(x[i] >= 1.1) eye[i][0]++;
			else if(x[i] >= 0.6) eye[i][1]++;
			else if(x[i] >= 0.2) eye[i][2]++;
			else eye[i][3]++;
		}
	}
	for(int i = 0; i < 4; i++) printf("%d %d\n", eye[0][i], eye[1][i]);
}

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


int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  rep(i,m) cin >> b[i];
  vector<vector<int>> a(n,vector<int>(m));
  rep(i,n) {
    rep(j,m) cin >> a[i][j];
  }
  
  int count = 0;
  rep(i,n){
    int ans = c;
    rep(j,m){
      ans += a[i][j]*b[j];
    }
    if(ans > 0) ++count;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    n,k=map(int,input().split())
    MOD=10**9+7

    def pre(n,MOD):
        a=1
        for i in range(1,n+1):
            a=(a*i)%MOD
        an=a
        b=pow(a,MOD-2,MOD)
        bs=[1]*(n+1)
        bs[n]=b
        for i in range(n,1,-1):
            b=b*i%MOD
            bs[i-1]=b
        return an,bs

    a,b=pre(n-1,MOD)
    ans=1
    for i in range(1,min(n-1,k)+1):
        s=(a*n*b[i])%MOD
        s=(s*b[n-i])%MOD
        s=(s*a*b[n-i-1])%MOD
        s=(s*b[i])%MOD
        ans+=s
        ans%=MOD
    print(ans)
    
if __name__ == '__main__':
    main()

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  int cnt2 = 0;
  cin >> N;
  vector<int> A(N);
  map <int, int> m;
  rep(i, N) {
    cin >> A[i];
  }
  sort(all(A));
  int k = A[N-1];
  vector<bool> dp(k+1, true);
  for (int i = 0; i < N; i++) {
    if (dp[A[i]]) {
      for (int j = 2*A[i]; j<=k; j+=A[i]) {
        dp[j] = false;
      }
    }
  }
  int cnt = 0;
  rep(i, N) {
    if (dp[A[i]]) {
      cnt++;
      m[A[i]]++;
    }
  }
  for (auto ite = m.begin(); ite != m.end(); ite++) {
    if (ite->_2 > 1)
      cnt2 += ite->_2;
  }
  cout << cnt-cnt2 << endl;
}


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

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

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

  int ans=1e9;
  for(int i=1;i<N;i++){
    int A=i;
    int B=N-i;
    int count=0;
    while(A>0){
      count+=A%10;
      A/=10;
    }
    while(B>0){
      count+=B%10;
      B/=10;
    }
    ans=min(ans,count);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP (i,m,n) for(int i=( int)m ; i < (int ) n ; ++i )
#define rep (i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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



int main() {
	int s, w;
	cin >> s >> w;

	if (w >= s) cout << "unsafe" << endl;
	else cout << "safe" << endl;
	return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    int ans = n*(n-1)/2+m*(m-1)/2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<28;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string A,B;cin>>A>>B;
    B=B+B+B;
    int N=A.size();
    int cnt1=0,cnt2=0;
    for(int i=0;i<N;i++){
        if(A[i]=='1') cnt1++;
        if(B[i]=='1') cnt2++;
    }
    if(cnt1&&cnt2==0){
        cout<<-1<<endl;
        return 0;
    }
    if(cnt1==0&&cnt2==0){
        cout<<0<<endl;
        return 0;
    }
    
    int ans=INF;
    
    vector<int> left(N),right(N);
    
    for(int i=0;i<N;i++){
        for(int j=0;;j--){
            if(B[N+i+j]=='1'){
                left[i]=j;
                break;
            }
        }
    }
    
    for(int i=0;i<N;i++){
        for(int j=0;;j++){
            if(B[N+i+j]=='1'){
                right[i]=j;
                break;
            }
        }
    }
    
    for(int r=0;r<N;r++){
        int sum=r;
        vector<pair<int,int>> S={{-INF,0},{0,INF}};
        for(int i=0;i<N;i++){
            if(A[i]!=B[i+N+r]){
                sum++;
                
                if(right[i]>r){
                    S.push_back({left[i],right[i]-r});
                }
            }
        }
        
        sort(all(S));
        
        for(int i=1;i<S.size();i++){
            S[i].second=max(S[i].second,S[i-1].second);
        }
        
        int mi=INF;
        
        for(int i=1;i<S.size();i++){
            mi=min(mi,(abs(S[i].first)+S[i-1].second)*2);
        }
        
        sum+=mi;
        
        ans=min(ans,sum);
    }
    
    reverse(all(A));
    reverse(all(B));
    reverse(all(left));
    reverse(all(right));
    swap(left,right);
    for(int i=0;i<N;i++){
        left[i]*=-1;
        right[i]*=-1;
    }
    
    for(int r=0;r<N;r++){
        int sum=r;
        vector<pair<int,int>> S={{-INF,0},{0,INF}};
        for(int i=0;i<N;i++){
            if(A[i]!=B[i+N+r]){
                sum++;
                
                if(right[i]>r){
                    S.push_back({left[i],right[i]-r});
                }
            }
        }
        
        sort(all(S));
        
        for(int i=1;i<S.size();i++){
            S[i].second=max(S[i].second,S[i-1].second);
        }
        
        int mi=INF;
        
        for(int i=1;i<S.size();i++){
            mi=min(mi,(abs(S[i].first)+S[i-1].second)*2);
        }
        
        sum+=mi;
        
        ans=min(ans,sum);
    }
    
    cout<<ans<<endl;
}



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

int main() {
  int n, k;
  cin >> n >> k;
  int x = k - 1;
  if (x + k <= n) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

int32_t main() {
    int64_t h, n, a[100009], sum = 0;
    cin >> h >> n;
    for(int i = 1; i <= n; i++){
        int temp;
        cin >> temp;
        sum += temp;
    }
    if(sum >= h)
        cout << "Yes\n";
    else
    cout << "No\n";
}


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

int main() {
  ll N, X, T;
  cin >> N >> X >> T;
  if(N % X == 0) cout << (N / X) * T << endl;
  else cout << (N / X + 1) * T << endl;
}

Measured memory_bytes: 3608
<>;
for(<>){
	/ /;
	push@{$`},$'+0;
	push@{$'+0},$`
}
$_[@o=1]=1;
map{
	while(($g)=grep!$_[$_],@{$o[-1]}){
		push@o,$g;
		$_[$g]=1
	}
	@o=reverse@o
}0,1;
print@o." @o"


Measured memory_bytes: 105088
h, w = map(int, input().split())
map_list = [0]*h
for i in range(h):
    map_list[i] = input()

ans_list = [0]*h
for i in range(h):
    ans_list_i = [0]*w
    for j in range(w):
        if map_list[i][j] == "#":
            ans_list_i[j] = "#"
            continue
        key = 0
        for a in range(i-1, i+2):
            if 0 <= a <= h-1:
                for b in range(j-1, j+2):
                    if 0 <= b <= w-1:
                        if map_list[a][b] == "#":
                            key += 1
        ans_list_i[j] = str(key)
    ans_list[i] = "".join(ans_list_i)
for i in range(h):
    print(ans_list[i])

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

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

int main(void){
    int n;
    cin >> n;
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    int res = 0;
    for (int i = 0; i < n; i++) {
        res = gcd(res, a[i]);
    }
    cout << res << endl;
}


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

const int maxn=5e5+9;
string s;
int q;
int tag=0;
char a[maxn];
int l=2e5+4,r=l;

int main(){
	char p;
	while (p=getchar()){
		if (p==' ' || p=='\n')break;
		a[r++]=p;	
	}
	cin >> q;
	for (int i=1,t,f;i<=q;i++){
		cin >> t;
		if (t==1) tag = 1-tag;
		else{
			cin >> f >> p;
			f--;
			if (tag^f)a[r++]=p;
			else a[--l]=p;
		}
	}
	if (tag) reverse(a+l,a+r);
	for (int i=l;i<r;i++){
		cout << a[i];	
	}
	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
int main()
{
	int H, W, i, j;
	while (1){
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0){
			break;
		}
		else for (i = 1; i <= H; i++){
			for (j = 1; j <= W; j++)
				printf("#");
			printf("\n");
			}

		printf("\n");
			
		
	}
	return 0;
}

Measured memory_bytes: 1000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

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

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

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

void Main() {
  int H, W, A, B; cin >> H >> W >> A >> B;
  rep(i, 0, B){
    rep(j, 0, A) cout << 0;
    rep(j, A, W) cout << 1;
    cout << endl;
  }
  rep(i, B, H){
    rep(j, 0, A) cout << 1;
    rep(j, A, W) cout << 0;
    cout << endl;
  }
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 1280
n, m=map(int, input().split())
es0=[]
es=[[] for i in range(n)]
for i in range(m):
    a,b=map(int, input().split())
    es0.append((a-1,b-1))
    es[a-1].append(b-1)
    es[b-1].append(a-1)

from collections import deque

def bfs(s, es):
    visited=[0]*n
    visited[s]=1
    q=deque([s])
    while q:
        p=q.popleft()
        for r in es[p]:
            if visited[r]==0:
                q.append(r)
                visited[r]=1
    if 0 in visited:
        return False
    else: return True

from copy import deepcopy
ans=0
for e in es0:
    newes=deepcopy(es)
    newes[e[0]].remove(e[1])
    newes[e[1]].remove(e[0])
    if bfs(0,newes):
        continue
    else:
        ans+=1
print(ans)

Measured memory_bytes: 47708
#include <bits/stdc++.h>
using namespace std;
//vector <long long> nCrModV;
long long before = 0;
long long ans = 0;
long long mod = (long long)pow(10,9)+7;
long long getPowerRemain(long long n, long long power, long long mod){
    #if 0
    cout << "n:" << n << " power:" << power << " mod:" << mod << endl;
    #endif
    //powを2進数で管理
    long long exp = 0;
    long long result = 1;
    long long nn = n;
    while(power>0){
        int tmp = (power&1);
        power>>=1;
        //cout << exp << endl;
        if(tmp!=0){
            if(exp>0){
                long long loopCnt = exp;
                while(loopCnt>0){
                    nn*=nn;
                    nn%=mod;
                    loopCnt--;
                }
                result*=nn;
                result%=mod;
                nn = n;
            }else{
                result*=n;
                result%=mod;
            }
        }
        exp++;
    }
    #if 0
    cout << "2進法出力：";
    for(int i = (binary.size()-1); i >=0; i--){
        cout << binary[i];
    }
    cout << endl;
    #endif
    #if 0
    for(int i = 0; i < powerVector.size(); i++){
        cout <<powerVector[i] << endl;
    }
    #endif
    #if 0
    for(int i = 0; i < resultVector.size(); i++){
        cout << resultVector[i] << endl;
    }
    #endif
    return result;

}
long long getInverseElement(long long base, long long mod){
    return getPowerRemain(base,mod -2,mod);
}
inline long long nCrMod(long long n, long long r, long long mod){
    long long ret = 1;
    long long inv = 1;
    if(r==1){
        ret = n;
    }else{
        for(long long i = 0; i < r; i++){
            ret*=(n-i);
            ret %= mod;
            inv*=getInverseElement(r-i,mod);
            inv %= mod;
        }
    }
    ret *= inv;
    ret %= mod;
    return ret;
}
int main(){
    #if 0
    return 0;
    #endif
    long long n,a,b;
    cin >> n >> a >> b;
    #if 0
    cout << getPowerRemain(2,6,mod) << endl;
    cout << pow(2,6) << endl;
    // for(int i = 0; i < 10; i++){
    //     cout << getPowerRemain(2,i,mod) << endl;
    // }
    return 0;
    #endif
    long long allpattern = getPowerRemain(2,n,mod);
    //cout << allpattern << endl;
    long long nCa = nCrMod(n,a,mod);
    //cout << nCa << endl;
    long long nCb = nCrMod(n,b,mod);
    //cout << nCb << endl;
    ans = allpattern - nCa - nCb - 1;
    while(ans<0){
        ans+=mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int n;
    int count = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int sequence;
        cin >> sequence;
        if (sequence != i + 1)
        {
            count++;
        }
    }
    (count <= 2) ? cout << "YES" : cout << "NO";
    return 0;
}

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

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

  //s += '#';

  vector<int> sum(n+1);
  sum.at(0) = 0;
  for(int i=1;i<n+1;i++){
    if(s.at(i-1) == '#') sum.at(i) = sum.at(i-1)+1;
    if(s.at(i-1) == '.') sum.at(i) = sum.at(i-1);
  }

//ここまで

  vector<int> h(n+1);
  for(int i=0;i<n+1;i++){
    h.at(i) = sum.at(i)+n-i-(sum.at(n)-sum.at(i));
  }
//  h.at(n)=sum.at(n);

  int m=h.at(0);
  for(int i=1;i<n+1;i++) m=min(m,h.at(i));

  cout << m << endl;
}


Measured memory_bytes: 2180
unittest
{
	assert( [ "aatt" ].parse.expand.solve == 5 );
	assert( [ "xxxxxxxxxx" ].parse.expand.solve == 1 );
	assert( [ "abracadabra" ].parse.expand.solve == 44 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto as = input.front.to!( dchar[] );
	return tuple( as );
}

auto solve( dchar[] as )
{
	auto ans = 1L;
	auto cs = new long[ 26 ];
	auto ct = 0L;
	foreach( a; as )
	{
		auto i = a - 'a';
		ans += ct - cs[ i ];
		cs[ i ]++;
		ct++;
	}
	return ans;
}


Measured memory_bytes: 3512
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		Map<Integer, ArrayList<Integer>> tree = new HashMap<Integer, ArrayList<Integer>>();
 		for(int i = 1;i<=n;i++){
 			tree.put(i, new ArrayList<Integer>());
 		}
 		tree.get(1).add(-1);
 		for(int i = 0;i<n-1;i++){
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		int a = Integer.parseInt(st.nextToken());
	 		tree.get(i+2).add(a);
	 		tree.get(a).add(i+2);
 		}
 		for(int i = 1;i<=n;i++){
 			out.println((tree.get(i).size()-1));
 		}
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




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

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//

vector<bool> sieve(long long max){ // 0 <= x <= max までの素数を調べ、返す。
    vector<bool> isPrime;
    
    if(max+1 > isPrime.size()){     // resizeで要素数が減らないように
        isPrime.resize(max+1,true); // isPrimeに必要な要素数を確保
    } 
    isPrime[0] = false; // 0は素数ではない
    isPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる (i*iで実現している)
        if(isPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                isPrime[i*j] = false;      // 素数ではない
    
    return isPrime;
}

//----------//
// 素因数分解する 
// たとえば 60 = 2^2 x 3 x 5 だったら {(2, 2), (3, 1), (5, 1)} を返す
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}
// 最大公約数を求める
long long GCD(long long x, long long y) {
    return y ? GCD(y, x%y) : x;
}

int main() {
    long long A, B;
    cin >> A >> B;
    long long G = GCD(A, B);
    auto pf = prime_factorize(G);
    cout << pf.size() + 1 << endl;
}


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

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

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y)return ;
	if(ran[x] < ran[y])par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y])ran[y]++;
	}
}

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

int main(){
	int n, m, q, x, y;
	scanf("%d%d", &n, &m);
	for(int i = 0;i < n;i++)par[i] = i;
	for(int i = 0;i < m;i++){
		scanf("%d%d", &x, &y);
		unite(x, y);
	}
	scanf("%d", &q);
	for(int i = 0;i < q;i++){
		scanf("%d%d", &x, &y);
		if(same(x, y))printf("yes\n");
		else printf("no\n");
	}
	return 0;
}


Measured memory_bytes: 3928
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    long long N;
    long long A, B, C, D, E;
    cin >> N;
    cin >> A >> B >> C >> D >> E;
    
    long long MinMove = min({A, B, C, D, E});
    
    long long ans = (N + MinMove - 1) / MinMove + 4;
    cout << ans << endl;
    
}

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


int main(){

    int a,b,c;
    cin >> a >> b >> c;
    int ans;

    if(b*a > c){
        ans = c;
    }else{
        ans = b*a;
    }

    cout << ans << endl;

    
}

Measured memory_bytes: 256
/*
csc -debug A.cs && mono --debug A.exe <<< "-13 3"
*/

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Reflection;

public class HelloWorld {
    public static void SolveCodeForces() {
        var A = cin.NextLong();
        var B = cin.NextLong();
        System.Console.WriteLine(Math.Max(A + B, Math.Max(A - B, A * B)));
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public static class Helpers {
    public static string Join<T>(this IEnumerable<T> arr, string sep = " ") {
        return string.Join(sep, arr);
    }

    public static void Swap<T>(ref T a, ref T b) {
        var tmp = a;
        a = b;
        b = tmp;
    }

    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}

Measured memory_bytes: 13140
#include <cstdio>
using namespace std;
const int N=200005;
int n,m,x,y,cnt,head[N],vis[N],deg[N][2],q[N],qtd,qtl;
char col[N];
struct edge{
  int to,nex;
}e[N*2];
void add(int x,int y){
  e[++cnt].to=y;e[cnt].nex=head[x];head[x]=cnt;
  e[++cnt].to=x;e[cnt].nex=head[y];head[y]=cnt;
}
int main(){
  scanf("%d%d",&n,&m);
  scanf("%s",col+1);
  for (int i=1;i<=m;i++) {
  scanf("%d%d",&x,&y),add(x,y);
  deg[x][col[y]=='B']++;deg[y][col[x]=='B']++;
  }
  for (int i=1;i<=n;i++)
    if (deg[i][0]==0||deg[i][1]==0) vis[q[qtl++]=i]=1;
  while (qtd!=qtl){
  	int x=q[qtd++];
  	for (int i=head[x];i;i=e[i].nex)
  	  if (!vis[e[i].to]){
  	  	 if (!--deg[e[i].to][col[x]=='B']){
  	  	 	  vis[e[i].to]=1;
  	  	 	  q[qtl++]=e[i].to;
			 }
		}
  }
  if (qtl==n) puts("No");
  else puts("Yes");
}

Measured memory_bytes: 7296
#include<iostream>
#include<cmath>
#include<iomanip>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a;
    long long c;
    double b;
    cin>>a>>b;
        c=(b+1e-6)*100;
    cout<<a*c/100<<endl;
}


Measured memory_bytes: 3688
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = vs[0];
			int k = vs[1];
			int[] h = new int[n];
			for (int i = 0; i < n; i++) {
				h[i] = int.Parse(Console.ReadLine());
			}
			Array.Sort(h);
			int ans = h[k - 1] - h[0];
			for (int i = k; i < n; i++) {
				ans = Math.Min(ans, h[i] - h[i - (k - 1)]);
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 17632
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		if(line.equals("AAA") || line.equals("BBB")){
          System.out.println("No");
        }else{
          System.out.println("Yes"); 
        }
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                     \
    ios::sync_with_stdio(false);\
    cin.tie(0)

// *start on @date: 2020-03-14 20:24 

int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};


int main() 
{
    IOS;
    int k;
    cin>>k;
    cout<<a[k-1];
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{

    class Program
    {
        static bool CalDistance(int[] x, int[] y) 
        {
            int dis2 = 0;
            for (int i = 0; i < x.Length; i++)
            {
                dis2 += (x[i] - y[i]) * (x[i] - y[i]);
            }
            int tempdis = (int)Math.Floor(Math.Sqrt(dis2 + 0.1));
            if (dis2 == tempdis * tempdis)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            var n = int.Parse(s[0]);
            var d = int.Parse(s[1]);
            var xs = new int[n][];
            for (int i = 0; i < n; i++)
            {
                var temps = Console.ReadLine().Split(' ');
                xs[i] = new int[d];
                for (int j = 0; j < d; j++)
                {
                    xs[i][j] = int.Parse(temps[j]);
                }
            }

            int count = 0;

            for (int i = 0; i < n; i++)
            {
                for (int j = i+1; j < n; j++)
                {
                    if (CalDistance(xs[i], xs[j]))
                    {
                        count++;
                    }
                }
            }

            Console.WriteLine(count);
            /*
            int count = 0;
            Array.Sort(ds);
            if (ds.Length % 2 == 1)
            {
                Console.WriteLine(0);
            }
            else if (ds[ds.Length / 2 - 1] == ds[ds.Length / 2])
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(ds[ds.Length / 2] - ds[ds.Length / 2 - 1]);
            }
            */



#if DEBUG
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
        }
    }
}


Measured memory_bytes: 11220
using System;
using System.Collections.Generic;
using System.Globalization;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var (N, M, K) = ReadLineInt3();
            
            var CumSumA = new List<long> { 0 };
            foreach(var s in Console.ReadLine().Split(' '))
            {
                var sum = CumSumA[CumSumA.Count - 1] + Convert.ToInt64(s);
                if(K < sum) { break; }
                CumSumA.Add(sum);
            }

            var CumSumB = new List<long> { 0 };
            foreach (var s in Console.ReadLine().Split(' '))
            {
                var sum = CumSumB[CumSumB.Count - 1] + Convert.ToInt64(s);
                if (K < sum) { break; }
                CumSumB.Add(sum);
            }

            var ans = 0;
            var b = CumSumB.Count - 1;
            for (var a = 0; a < CumSumA.Count; a++)
            {
                while (K < CumSumA[a] + CumSumB[b]) { b--; }
                ans = Math.Max(ans, a + b);
             
            }

            Console.WriteLine(ans);
        }

        #region 使いまわし
        static string ReadLineStr() { return Console.ReadLine(); }

        static int ReadLineInt() { return Convert.ToInt32(Console.ReadLine()); }
        static (int, int) ReadLineInt2()
        {
            var temp = Console.ReadLine().Split(' ');
            return (Convert.ToInt32(temp[0]), Convert.ToInt32(temp[1]));
        }
        static (int, int, int) ReadLineInt3()
        {
            var temp = Console.ReadLine().Split(' ');
            return (Convert.ToInt32(temp[0]), Convert.ToInt32(temp[1]), Convert.ToInt32(temp[2]));
        }
        static List<int> ReadLineIntList()
        {
            var data = new List<int>();
            foreach (var temp in Console.ReadLine().Split(' '))
            {
                data.Add(Convert.ToInt32(temp));
            }

            return data;
        }

        static long ReadLineLong() { return Convert.ToInt64(Console.ReadLine()); }
        static (long, long, long) ReadLineLong3()
        {
            var temp = Console.ReadLine().Split(' ');
            return (Convert.ToInt64(temp[0]), Convert.ToInt64(temp[1]), Convert.ToInt64(temp[2]));
        }
        static List<long> ReadLineLongList()
        {
            var data = new List<long>();
            foreach (var temp in Console.ReadLine().Split(' '))
            {
                data.Add(Convert.ToInt64(temp));
            }

            return data;
        }
        #endregion
    }
}


Measured memory_bytes: 66476
def insertionSort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt = cnt + 1
        A[j+g] = v
    return cnt

n = int(input())
a = []
g = []
for i in range(n):
    x = int(input())
    a.append(x)
count = 0
m = 1;
while m<= n:
    g.append(m)
    m = (m*3) + 1
l = len(g)
print(str(l))
l = l-1
while l>0:
    print(str(g[l]) + " ", end = '')
    count += insertionSort(a, n, g[l])
    l = l-1
print(str(g[l]))
count += insertionSort(a, n, g[l])
print(str(count))
for i in a:
    print(str(i))



Measured memory_bytes: 45520
import std;

alias Book = Tuple!(int, "cost", int[], "ss");

int calc(int x, Book[] books) {
    auto n = books.length;
    auto m = books[0].ss.length;

    int ans = int.max;
    foreach (es; subsets(n.iota)) {
        int cost = 0;
        auto ss = new int[m];
        foreach (e; es) {
            cost += books[e].cost;
            foreach (k, s; books[e].ss) ss[k] += s;
        }
        if (ss.all!(e => e >= x)) {
            ans = min(ans, cost);
        }
    }
    return ans == int.max ? -1 : ans;
}

void main() {
    int n, m, x; scan(n, m, x);
    Book[] books;
    foreach (_; 0..n) {
        auto t = readints;
        books ~= Book(t[0], t[1..$]);
    }
    writeln(calc(x, books));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;

Subsets!R subsets(R)(R range)
if (isInputRange!R)
{
    return Subsets!R(range);
}

struct Subsets(R) {
    alias E = ElementType!R;
    private E[] _source;

    private E[] _current;
    private int _state;

    this(R source) {
        _source = source.array;
        _state = 1;
        next();
    }

    private void next() {
        _current = null;
        if (_state < (1 << _source.length)) {
            _current = [];
            for (int i = 0; i < _source.length; i++) {
                if (_state & (1 << i)) _current ~= _source[i];
            }
            _state++;
        }
    }

    @property E[] front() { return _current; }
    @property bool empty() { return _current == null; }
    void popFront() { next(); }
}


Measured memory_bytes: 4496
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <queue>
#include <stack>
#include <algorithm>

#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep1(i,n) for(int i=1; i<=(n); i++)
#define mst(x,a) memset(x, a, sizeof(x))
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(),x.end()
#ifdef LOCAL
    #define dbg(a) cout << #a": " << a << endl;
#else
    #define dbg(a)
#endif // LOCAL

using namespace std;
typedef long long ll;
typedef unsigned int uin;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const double dinf = inf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<double,double> pdd;

ll qpow(ll a, ll b, ll mod){
    ll ret = 1;
    for(;b; b>>=1){
        if(b&1) ret = ret*a%mod;
        a = a*a%mod;
    }
    return ret;
}

const int N = 1e5 + 10;
const int M = 1e4 + 10;
const int mod = 998244353;
const double eps = 1e-6;



int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.tie(0);

    ll x,y;
    cin>>x>>y;
    if(abs(x-y)<=1) printf("Brown\n");
    else printf("Alice\n");

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    h=60*h+m;
    double radh=2*PI*h/(12*60),radm=2*PI*m/60;
    double theta=radh-radm;
    double ans=sqrt(a*a+b*b-2*a*b*cos(theta));
    cout<<setprecision(20)<<ans<<endl;
}

Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
int main(){
  int a,b,c;cin>>a>>b>>c;
  cout<<c/a*b<<endl;
}

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

int main() {
    int n, m;
    vector< string> blue, red;
    cin >> n;
    blue.resize(n);
    for (string& s : blue) cin >> s;
    cin >> m;
    red.resize(m);
    for (string& s : red) cin >> s;
    int res = 0;
    for (auto& s : blue) {
        int cnt = 0;
        for (auto z : blue) if (z == s) cnt++;
        for (auto z : red) if (z == s) cnt--;
        res = max(res, cnt);
    }
    printf("%d\n", res);
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <assert.h>
using namespace std;
struct P{double x,y;};
int main(){
	P d[4];
	while(cin >> d[0].x >> d[0].y){
		for(int i = 1 ; i < 4 ; i++){
			cin >> d[i].x >> d[i].y;
		}
		double a=0,b=0;
		if(d[0].x == d[1].x){
			cout << (d[2].y == d[3].y?"YES":"NO") << endl;
		}else if(d[2].x == d[3].x){
		cout << (d[0].y == d[1].y?"YES":"NO") << endl;
		}else{
			a = (d[0].y-d[1].y)/(d[0].x-d[1].x);
			b = (d[2].y-d[3].y)/(d[2].x-d[3].x);
			cout << (a*b == -1.0?"YES":"NO") << endl;
		}
	}
};

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, MAX = 1e18;
typedef long double ld;

lint A, B, C, D, E;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> A >> B >> C >> D >> E;
	cout << max(0ll , C * 60 + D - A * 60 - B - E);
}


Measured memory_bytes: 3652
n = gets.to_i

n.times do
  bs = gets.chop.split(" ").map{|s| s.to_i}
  #p bs

  b0 = 0
  b1 = 0
  ok = 1

  for b in bs
    if b0 > b
      if b1 > b
        ok = 0
        break
      end

      b1 = b
    elsif b1 > b
      b0 = b
    elsif b0 < b1
      b1 = b
    else
      b0 = b
    end

    #puts "b=#{b}, " + [b0,b1].join(",")
  end

  puts (ok > 0 ? "YES" : "NO")
end

Measured memory_bytes: 6104
a = input()
A = int(a[0])
B = int(a[2])
C = int(a[4])

if(A==5 and B==7 and C==5):
    print('YES')
elif(A==7 and B==5 and C==5):
    print('YES')
elif(A==5 and B==5 and C==7):
    print('YES')
else:
    print('NO')



Measured memory_bytes: 9020
def Kosuu(n,sak):
    if n <= sak:
        kazu = n + 1
        sta = 0
        end = n
    else:
        kazu = sak * 2 + 1 - n
        sta = n - sak
        end = sak
    return [kazu,sta,end]
    
while True:
    try:
        Sum = 0
        n = int(input())
        ABl = Kosuu(n,2000)
        
        for i in range(ABl[1],ABl[2] + 1):
            Sum += Kosuu(i,1000)[0] * Kosuu(n -i,1000)[0]
        print(Sum)
    except EOFError:
        break
            

Measured memory_bytes: 7668
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int num_odd = 0;
  REP(i,0,N) {
    int a;
    cin >> a;
    num_odd += a % 2;
  }
  cout << (num_odd % 2 ? "NO" : "YES") << endl;
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int n,k,a[100005],ans;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>=k) ans++;
	}
	cout<<ans;
	return 0;
}

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

#define ll long long
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int sumdigits(int x){
    int ret = 0;
    while(x){
    ret += x%10;
    x /= 10;
    }
    return ret;
}

int main() {
    int N;
    cin >> N;
    int max = INF;
    
    for(int i=1;i<N;i++){
        if ( sumdigits(i) + sumdigits(N-i) < max ){
            max = sumdigits(i) + sumdigits(N-i);
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
n=gets.to_i
a=[0]+gets.split.map(&:to_i)

res=0
for i in 1..n-1
    if a[i]==i
        a[i], a[i+1]=a[i+1], a[i]
        res+=1
    end
end
res+=1 if a[n]==n
p res


Measured memory_bytes: 8836
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

ll N,S,W,Q;
vector<ll> A;

void make_seq(){
  A.resize(N);
  ll g=S;
  for(int i=0;i<N;i++){
    A[i]=(g/7)%10;
    if(g%2==0){g/=2;}
    else{g=((g/2)^W);}
  }
  reverse(A.begin(),A.end());
}

ll cul1(){
  map<int,int> M;
  ll k=1,sum=0,ret=0;
  M[0]=1;
  for(int i=0;i<N;i++){
    (sum+=k*A[i]%Q)%=Q;
    if(A[i]!=0){ret+=M[sum];}
    (k*=10)%=Q;
    M[sum]++;
    //cout<<i<<" "<<sum<<endl;
  }
  return ret;
}

ll cul2(){
  ll cnt=0,ret=0;
  for(ll i=N-1;i>=0;i--){
    if(A[i]!=0){cnt++;}
    if(A[i]%Q==0){ret+=cnt;}
  }
  return ret;
}


int main(){
  while(cin>>N>>S>>W>>Q,N){
    make_seq();
    //cout<<A<<endl;
    if(10%Q==0){
      cout<<cul2()<<endl;
    }
    else{
      cout<<cul1()<<endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 7872
N, K = map(int, raw_input().split())
L = K + 1
D = [[0] * L for i in range(L)]
b = 0

for i in range(N):
    x, y, c = raw_input().split()
    x, y, c = int(x), int(y), (c == 'W')
    p = (x / K + y / K + c) % 2
    D[y % K + 1][x % K + 1] += 1 - 2 * p
    b += p

for i in range(K):
    for j in range(L):
        D[i + 1][j] += D[i][j]

for i in range(L):
    for j in range(K):
        D[i][j + 1] += D[i][j]

a = 0

for i in range(L):
    for j in range(L):
        S = D[i][K] + D[K][j] - D[i][j] * 2
        a = max(a, S, D[K][K] - S)

print a + b

Measured memory_bytes: 23020
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int i,j,n,a[100],ans;
  while(1){
    cin >> n;
    if(n == 0) break;
    for(i=0;i<n;i++) cin >> a[i];
    sort(a,a+n);
    int m = n;
    ans = 0;
    for(i=1;i<n-1;i++){
      ans += a[i];
    }
    ans /= (n - 2);
    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 0
import Control.Monad
import Data.List
import Control.Applicative

solver :: [[Int]] -> Int -> Int
solver [] c = c
solver (x:xs) c =
  let ys = permutations x
      ms = intersect xs ys
      n  = length ms
  in
      solver (xs \\ ms) (c + n)


main :: IO()
main = do
  n <- (read :: String -> Int) <$> getLine
  inputs <- map (map (read :: String -> Int) . words) <$> replicateM n getLine
  print $ solver inputs 0

Measured memory_bytes: 5624
#include <iostream>

using namespace std;
#define rep(i, n) for(int i=0; i < n; i++)
int a, b, c, x, ans;
int main() {
    cin >> a >> b >> c >> x;
    if (x%50 != 0) {
        cout << ans << endl;
        return 0;
    }
    int d = x / 50;
    rep (i, a+1) {
        rep (j, b+1) {
            rep (k, c+1) {
                if (i*10 + j*2 + k == d) {
                    ans++;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
X = int(input())
E = []
C = {}
for i in range(M):
    u, v, w = map(int, input().split())
    E.append((w, u-1, v-1))
    C[w] = C.get(w, 0) + 1
E.sort()

*p, = range(N)
def root(x):
    if x == p[x]:
        return x
    y = p[x] = root(p[x])
    return y
def unite(x, y):
    px = root(x); py = root(y)
    if px == py:
        return 0
    if px < py:
        p[py] = px
    else:
        p[px] = py
    return 1

MOD = 10**9 + 7

G0 = [[] for i in range(N)]
K = 0
last = None
U = [0]*M
cost = 0
for i in range(M):
    w, u, v = E[i]
    if unite(u, v):
        cost += w
        U[i] = 1
        if last != w:
            K += C[w]
        G0[u].append((v, w))
        G0[v].append((u, w))
        last = w
def dfs0(u, p, t, cost):
    if u == t:
        return 0
    for v, w in G0[u]:
        if v == p:
            continue
        r = dfs0(v, u, t, cost)
        if r is not None:
            return r | (w == cost)
    return None
def dfs1(u, p, t):
    if u == t:
        return 0
    for v, w in G0[u]:
        if v == p:
            continue
        r = dfs1(v, u, t)
        if r is not None:
            return max(r, w)
    return None

if X - cost < 0:
    print(0)
    exit(0)

K = 0
for i in range(M):
    if U[i]:
        K += 1
        continue
    w, u, v = E[i]
    if dfs0(u, -1, v, w):
        K += 1
        U[i] = 1
if cost == X:
    ans = ((pow(2, K, MOD) - 2)*pow(2, M-K, MOD)) % MOD
    print(ans)
    exit(0)

L = 0
G = 0
for i in range(M):
    w, u, v = E[i]
    if last + (X - cost) < w:
        break
    G += 1
    if U[i]:
        continue
    r = dfs1(u, -1, v) + (X - cost)
    if r == w:
        L += 1
    elif r < w:
        G -= 1

ans = (2*(pow(2, L, MOD)-1)*pow(2, M-G, MOD)) % MOD
print(ans)

Measured memory_bytes: 4716