akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ans;
int n;
int a[111],x[111][111],y[111][111];
signed main(){

    cin>>n;
    rep(i,n){
        cin>>a[i];
        rep(j,a[i])cin>>x[i][j]>>y[i][j];
    }
    rep(i,1<<n){
        int f[16],cnt=0;
        bool ok=1;
        rep(j,n){
            if((1<<j) & i){
                cnt++;
                f[j]=((1<<j) & i);
            }
        }
        rep(j,n){
            if((1<<j) & i){
                rep(k,a[j]){                  
                    //if(((1<<(x[j][k]-1)) & i)^y[j][k])ok=0;
                    if(((i >> (x[j][k]-1)) & 1) ^ y[j][k]) ok = false;
                }
            }
            /*else{
                rep(k,a[j]){
                    if(f[x[j][k]]!=y[j][k]+1)ok=0;
                }
            }*/
        }
        if(ok)ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int ans=1;
	while(ans<=n)
	{
		ans*=2;
	}
	cout<<ans/2<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out, false);
        int n = scanner.nextInt();
        int t = scanner.nextInt();
        int[] dp = new int[6005];
        int[][] vals = new int[n][2];
        for(int i = 0; i < n; i++) {
            vals[i][0] = scanner.nextInt();
            vals[i][1] = scanner.nextInt();
        }
        Arrays.sort(vals, new Comparator<int[]>() {
            public int compare(int[] a, int[] b) {
                return a[0] - b[0];
            }
        });
        Arrays.fill(dp, -1);
        dp[0] = 0;
        for(int i =0; i < n; i++) {
            for(int k = t-1; k >= 0; k--) {
                if (dp[k] == -1) continue;
                dp[k + vals[i][0]] = Math.max(dp[k + vals[i][0]], dp[k] + vals[i][1]);
            }
        }
        int ans = 0;
        for(int i = 0; i < dp.length; i++) {
            ans = Math.max(ans, dp[i]);
        }
        out.println(ans);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li h, w, n;
set<li> obj[200200];

int main() {
    cin >> h >> w >> n;
    rin{
        li x, y;
        cin >> x >> y;
        obj[x].insert(y);
    }

    li high = 1;
    repp(i, 1, h) {
        for (auto& y : obj[i + 1]) {
            if (y <= high) {
                cout << i << endl;
                return 0;
            }
        }
        if (high < w && obj[i + 1].count(high + 1) == 0) {
            high++;
        }
    }
    cout << h << endl;

    return 0;
}

Measured memory_bytes: 18944
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	int[][] list;
	String[] message;
	public void run(){
		int n = sc.nextInt();
		calc(n);
	}
	public void calc(int n){
		list = new int[n+1][n+1];
		message = new String[n+1];
		
		for(int i = 1; i < n+1; i++){
			int k = sc.nextInt();
			String s = sc.next();
			
			list[k][i] = 1;
			message[i] = s;
		}
		
		print(-1, 0, n);
	}
	public void print(int depth, int k, int n){
		if(k != 0){
			for(int i = 0; i < depth; i++){
				System.out.print(".");
			}
			System.out.println(message[k]);
		}
		for(int i = 0; i < n+1; i++){
			if(list[k][i] == 1){
				print(depth+1, i, n);
			}
		}
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
}

Measured memory_bytes: 64684
#if 0
なんでTLEするんやぁ…
#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int V, E, R;
vector<pair<int,int>> ST[500010];
int C[100010];
bool Q[100010];
const int Inf = 10000*100000+100;
priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> P;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> V >> E >> R;
  for (int i=0; i<E; ++i) {
    int s, t, d;
    cin >> s >> t >> d;
    ST[s].push_back(make_pair(t,d));
  }
  for (int i = 0; i < V; i++) {
    C[i] = (i == R ? 0 : Inf);
    Q[i] = true;
    P.push(make_pair(C[i], i));
  }
  int cnt = 0;
  while (cnt < V) {
    int d = P.top().first, u = P.top().second; P.pop();
    if (Q[u]) {
      Q[u] = false; cnt++;
      for (auto it = ST[u].begin(); it != ST[u].end(); ++it) {
        int v = (*it).first; int d = (*it).second;
        if (Q[v]) {
          C[v] = min(C[v], C[u] + d);
          P.push(make_pair(C[v], v));
        }
      }
    }
  }
  for (int i = 0; i < V; i++)
    cout << (C[i] == Inf ? "INF" : to_string(C[i])) << endl;
}



Measured memory_bytes: 23656
N = int(input())
A = list(map(int, input().split()))


ans = 0
i = 0
r = 0
tmp_sum = 0 # A[i]
tmp_xor = 0 # A[i]
tmp = 0
for i in range(N):
    # while r < N and tmp & A[r] == 0 :# tmp_sum == tmp_xor:
    # print("i, ", i, "tmp_sum, tmp_xor: ", tmp_sum, tmp_xor)
    while r < N and tmp_sum+A[r] == tmp_xor^A[r]:
        # tmp |= A[r]
        tmp_sum += A[r]
        tmp_xor ^= A[r]
        r += 1

    ans += r - i 
    tmp_sum -= A[i]
    tmp_xor ^= A[i]
    tmp ^= A[i]

    
    

print(ans)




Measured memory_bytes: 77772
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    int a[3];
    REP(i, 3)
    cin >> a[i];

    sort(a, a + 3);

    int ans = a[0] + a[1] + a[2] * 10;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1000000000;
long long S;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> S; long long x = (MAX - S % MAX) % MAX;
  cout << "0 0 " << MAX << " 1 " << x << " " << (S + x) / MAX << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k;
char c[15];
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) cin>>c[i];
	cin>>k;
	for(int i=1;i<=n;i++) {
		if(int(c[i])==int(c[k])) cout<<c[i];
		else cout<<"*";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

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

const int mod=1e9+7;

int main(){
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    ll m=min(min(a,min(b,c)),min(d,e));
    cout << 4+(n%m==0?n/m:n/m+1) << endl;
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	stack<int> st;
	rep(i,s.size()){
		if(s[i] == '0') st.push(0);
		if(s[i] == '1') st.push(1);
		if(!st.empty() && s[i] == 'B') st.pop();
	}
	vector<int> ans;
	while(!st.empty()){
		ans.push_back(st.top());
		st.pop();
	}
	reverse(ans.begin(),ans.end());
	rep(i,ans.size()){
		cout << ans[i];
	}
	cout << endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
d = {}
s = set()
ans = 0
d[a[0]] = 1
s.add(a[0])
for i in range(1, n):
    if i-a[i] in s:
        ans += d[-a[i]+i]
    
    if a[i]+i in s:
        d[a[i]+i] = d[a[i]+i]+1
    else:
        s.add(a[i]+i)
        d[a[i]+i] = 1
print(ans)

Measured memory_bytes: 54116
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
 
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  
  int n;
  cin >> n;
  vvl cnt(n+1,vector<ll>(3));
  
  ll ans=1;
  rep(i,n){
    ll a;
    cin >> a;
    bool did=true;
    ll res=0;
    rep(j,3){
      if(cnt[i][j]==a && did){
        did=false;
        cnt[i+1][j]=cnt[i][j]+1;
        res++;
      }
      else if(cnt[i][j]==a && !did){
        cnt[i+1][j]=cnt[i][j];
        res++;
      }
      else cnt[i+1][j]=cnt[i][j];
    }
    ans*=res;
    ans%=MOD;
  }
  cout << ans << endl;
  
}


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

int main() {
  int N,K,R,S,P;
  cin>>N>>K>>R>>S>>P;
  string T;
  cin>>T;
  long long ans=0;
  for(int i=0;i<K;i++){
    long long count=0;
    int last=i-K;
    for(int j=i;j<N-K;j+=K){
      if(T.at(j)==T.at(j+K)){
        count++;
      }
      else{
        if(T.at(j)=='r'){
          ans+=P*(count/2+1);
        }
        else if(T.at(j)=='s'){
          ans+=R*(count/2+1);
        }
        else{
          ans+=S*(count/2+1);
        }
        count=0;
      }
      last=j;
    }
    if(T.at(last+K)=='r'){
      ans+=P*(count/2+1);
    }
    else if(T.at(last+K)=='s'){
      ans+=R*(count/2+1);
    }
    else{
      ans+=S*(count/2+1);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int h, w; scanf("%d%d", &h, &w);
	std::vector<std::string> s(h);
	for(int i = 0; i < h; i++) cin >> s[i];

	auto a = make_v<int>(h, w);
	for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) a[i][j] = (s[i][j] == '#');

	auto dp = make_v<int>(h, w, 2);
	for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) dp[i][j][0] = dp[i][j][1] = 1 << 30;
	if(a[0][0]) dp[0][0][1] = 1;
	else dp[0][0][0] = 0;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			for(int k = 0; k < 2; k++) {
				if(j + 1 < w) { // 右
					int nx = i, ny = j + 1;
					if(a[nx][ny] ^ k) dp[nx][ny][1 - k] = std::min(dp[nx][ny][1 - k], dp[i][j][k] + (k == 0));
					else dp[nx][ny][k] = std::min(dp[nx][ny][k], dp[i][j][k]);
				}
				if(i + 1 < h) {
					int nx = i + 1, ny = j;
					if(a[nx][ny] ^ k) dp[nx][ny][1 - k] = std::min(dp[nx][ny][1 - k], dp[i][j][k] + (k == 0));
					else dp[nx][ny][k] = std::min(dp[nx][ny][k], dp[i][j][k]);
				}
			}
		}
	}
	
	printf("%d\n", std::min(dp[h - 1][w - 1][0], dp[h - 1][w - 1][1]));
	return 0;
}


Measured memory_bytes: 896
s = input()
if s[0] != 'A':
    print('WA')
    exit(0)
if s[2:-1].count('C') != 1:
    print('WA')
    exit(0)
for i in range(1,len(s)):
    if i >= 2 and i < len(s)-1 and s[i] == 'C':
        continue
    if not (ord('a') <= ord(s[i]) and ord(s[i]) <= ord('z')):
        print('WA')
        exit(0)
print('AC')

Measured memory_bytes: 3064
from itertools import permutations
N = int(input())
point = []
dist_sum = 0
per = 0

for _ in range(N):
    x, y = map(int, input().split())
    point.append([x, y])

for p in permutations(point, N):
    for i in range(N - 1):
        dist_sum += ((p[i][0] - p[i + 1][0])**2 + (p[i][1] - p[i + 1][1])**2)**0.5
    per += 1

print(dist_sum / per)

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

vector<long long> adj[200005];
vector<long long> res;

void dfs(long long v,long long p=-1)
{
    for(auto itr:adj[v])
    {
        if(itr==p)continue;
        res[itr]+=res[v]; //
        dfs(itr,v);
    }
}

int main()
{
    long long n,q;
    cin>>n>>q;
    long long a,b;
    for(int i=0;i<n-1;i++)
    {
        cin>>a>>b;
        a--;b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    long long p,x;
    res.resize(n);
    for(int i=0;i<q;i++)
    {
        cin>>p>>x;
        p--;
        res[p]+=x;
    }
    
    dfs(0);//Yo !
    
    for(int i=0;i<n;i++)
    {
        cout<<res[i]<<" ";
    }
}


Measured memory_bytes: 24320
#include<bits/stdc++.h>
    using namespace std;
     
    int main(){
        string s;
        cin >> s;
        string s2 = s;
        reverse(s.begin(), s.end());
        if(s == s2)cout << "Yes" << endl;
        else cout << "No" << endl;
     
        return 0;
    }

Measured memory_bytes: 256
inputs = list(input().split())
stack = []

for i in range(len(inputs)):
    if inputs[i] in ('+', '-', '*'):
        ope = inputs[i]
        if ope == '+':
            stack.append(stack.pop() + stack.pop())
        elif ope == '-':
            stack.append(-stack.pop() + stack.pop())
        elif ope == '*':
            stack.append(stack.pop() * stack.pop())
    else:
        stack.append(int(inputs[i]))

print(stack.pop())


Measured memory_bytes: 5604
N,M =  map(int, input().split())
HList = input().split(" ")
ABHash = {}
for i in range(M) :
    A,B = map(int, input().split())
    A = A-1
    B = B-1
    if A not in ABHash :
        ABHash[A] = []
    ABHash[A].append(B)
    if B not in ABHash :
        ABHash[B] = []
    ABHash[B].append(A)

count = 0

for i in range(N) :
    if i not in ABHash :
        count += 1
        continue

    BList = ABHash[i]
    AHeight = int(HList[i])
    isGood = True
    
    for j in range(len(BList)) :
        if AHeight <= int(HList[BList[j]]) :
            isGood = False
    if(isGood) :
        count += 1
print(count)

Measured memory_bytes: 34672
#include<iostream>
#include<set>
using namespace std;
int main(){
  int n;cin>>n;
  set<string> u;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    u.insert(s);
  }
  cout << u.size() << endl;
  return 0;
}  


Measured memory_bytes: 19232
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int K; cin >> K;
    set<string> st;
    int n = S.length();
    rep(i, n) {
        string T;
        REP(j, i, min(i + 5, n - 1)) {
            T += S[j];
            st.insert(T);
        }
    }
    auto itr = st.begin();
    while(--K) itr++;
    cout << *itr << endl;

    return 0;
}


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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N;
  cin >> N;
  vi P(N);
  for (auto& p : P) {
    cin >> p;
  }

  si cache;
  auto check = [&](int x) {
    auto it = cache.lower_bound(x);
    return it == begin(cache);
  };

  ll ret = 0;
  REP(i, N) {
    const int x = P[i];
    if (check(x)) ret++;
    cache.insert(x);
  }

  cout << ret << endl;

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 10368
#include <bits/stdc++.h>
// #include "../cxx-prettyprint/prettyprint.hpp"  vecの内容をきれいに表示

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
// ここに処理を記述

	// 文字列は0-indexed dpテーブルは1-indexedなのに注意
	string s, t;
	cin >> s >> t;

	vector< vector<int> > dp(s.size()+1, vector<int>(t.size()+1,0));

	// dp[i][j] = (sのi文字目，tのj文字目までのLCSの長さ)
	// s[i] = t[j] ならその文字は使ったほうがいい (一応ほかの遷移とのmax)
	// その他の遷移 : sが1文字前 or tが1文字前 のうち長いほうを採用
	string ans="";
	REP(i,s.size()){
		REP(j, t.size()){
			if(s[i]==t[j]) dp[i+1][j+1] = max(dp[i][j] + 1, max(dp[i][j+1], dp[i+1][j]));
			else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
		}
	}

	// cout << dp <<"\n";

	// 文字列 : dpテーブルを逆にたどり復元
	// s[i] == j[j] --> その文字は採用 dp[s-1][j-1]へ
	// そうでないとき --> dpの値が減らないほうに動き上記条件を強制させる
	// 長さが0になるまで続ける
	int len = dp[s.size()][t.size()];
	int i = s.size();
	int j = t.size();

	while(len > 0){
		if(s[i-1] == t[j-1]){
			ans = s[i-1] + ans;
			i--;
			j--;
			len--;
		}
		else if(dp[i-1][j] == dp[i][j]){
			i--;
		}
		else{
			j--;
		}
	}

	cout << ans << "\n";

return 0;
}

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

using namespace std;

int main(){
	string S;
	cin >> S;
	int N=S.size();
	int red=0, blue=0;
	rep(i,N){
		if(S[i]=='0') red++;
		else blue++;
	}
	cout << min(red,blue)*2 << endl;

	return 0;
}

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

int main(){
 
  int A,B,C,D;
  cin >> A >> B >> C >> D ;
  
  if( A+B < C+D) {
   cout << "Right" << endl; 
  }
  
  else if( A+B > C+D) {
   cout << "Left" << endl; 
  }
  
  else{
   cout << "Balanced" << endl; 
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e18
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

const int maxn = 52;


struct Matrix {
	vector<vector<ll> > t;

	Matrix(ll n) {
		t = vvl(n, vl(n));
	}

	ll size() {
		return t.size();
	}

	Matrix operator* (Matrix m1) {
		ll n = size();
		Matrix temp(n);
		rep(i, n)
			rep(j, n)
				rep(k, n)
					temp.t[i][j] = (temp.t[i][j] + (t[i][k] * m1.t[k][j]) % MOD) % MOD;
		
		return temp;
	}
};

void mat_expo(Matrix &a, ll k)
{
	ll n = a.size();
	Matrix res(n);
	rep(i, n) res.t[i][i] = 1;

	while (k) {
		if (k & 1)
			res = (res * a);

		k >>= 1;
		a = (a * a);
	}

	a = res;
}

void solve() {
	ll n, k;
	cin >> n >> k;

	Matrix a(n);

	rep(i, n) rep(j, n) cin >> a.t[i][j];

	mat_expo(a, k);

	ll ans = 0;
	rep(i, n)
		rep(j, n) ans = (ans + a.t[i][j]) % MOD;

	cout << ans << endl;
}

int main()
{
    fastio;
    ll t  = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 384
a=gets.to_i
v=gets.split.map &:to_i
c=gets.split.map &:to_i
d=[]
a.times{|i|d<< v[i]-c[i]}
d.delete_if{|i|i<0}
d<< 0 if d.size==0
p d.inject(:+)

Measured memory_bytes: 1788
#include<stdio.h>
#include <math.h>
int main()
{
int x1, y1;
double a,b,c,d,m,n,x,y;

while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&m,&c,&d,&n)!=EOF){
x=1000*(d*m-b*n)/(a*d-b*c);
y=1000*(a*n-c*m)/(a*d-b*c);
x1=x;
y1=y;
x = (double)x1/1000;
y = (double)y1/1000;
printf("%.3lf %.3lf\n", x, y);
}
return 0;
}

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

int size(int a){
  if(a==0) return 0;
  return size(a/10)+1;
}
int main(){
  long long N;
  cin>>N;
  long long cnt;
  for(long long i=1;i*i<=N;i++){
    if(N%i==0) cnt=i;
  }
  cout<<max(size(cnt),size(N/cnt));
}


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

int main(){
    char a[4],b[4];
    int c = 0;
    cin  >> a;
    cin  >> b;

for(int i = 0; i < 3; i++){
  if(a[i] == b[i]){
    c++;
  }
}
 cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if (s[n-1] == 's') cout << s << "es" << endl;
    else               cout << s << "s" << endl;
    return 0;
}


Measured memory_bytes: 3616
//AtCoder ABC089 B - Hina Arare
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N;
    cin>>N;
    unordered_map<char,ll> tbl;
    for(ll i=0;i<N;++i){
        char c;
        cin>>c;
        ++tbl[c];
    }
    cout<<(tbl.size()==4?"Four":"Three")<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

    int n, m, a;
    while (true)
    {
        cin >> n >> m >> a;
        if (n == 0)
            break;
        int line[1001][1001] = {0};
        for (int i = 0; i < m; i++)
        {
            int h, p, q;
            cin >> h >> p >> q;
            line[p][h] = q;
            line[q][h] = p;
        }
        for (int hei = 1000; 0 < hei; hei--)
        {
            if (line[a][hei] != 0)
                a = line[a][hei];
        }
        cout << a << endl;
    }
}


Measured memory_bytes: 6984
#include <algorithm>
#include<cfenv>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include<numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
vector<llong> AllDivisors(llong N) {
	vector<llong> ANS;
	for (llong i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ANS.push_back(i);
			if (N / i != i)ANS.push_back(N / i);
		}
	}
	sort(ANS.begin(), ANS.end());
	return ANS;
}
bool IsPrime(llong N) {
	for (llong i = 2; i * i <= N; i++) {
		if (N % i == 0) return false;
	}
	return true;
}
//ここまで共通
string S;
int main() {
	cin >> S;
	if (S == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}

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

class AtCoder
{
    static AtCoder atCoder;
    public static void Main()
    {
        atCoder = new AtCoder();
        atCoder.Run();
    }

    static void staticMethod()
    {
        atCoder.Run();
    }

    void Run()
    {
        var line = System.Console.ReadLine();
        string[] inputs = line.Split();
        int A = int.Parse(inputs[0]);
        int B = int.Parse(inputs[1]);
        int C = int.Parse(inputs[2]);

        if( C>=A&&C<=B)
        {
            System.Console.WriteLine("Yes");
        }
        else
        {
            System.Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push _back
int main()
{
    ll money,score=0;
    cin>>money;
    score+=(money/500)*1000;
    money=money%500;
    score+=(money/5)*5;
    cout<<score;
    return 0;
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
k=int(input())
num=0
for i in range(8):
    if a<b:
        break
    num+=1
    b*=2
for i in range(8):
    if b<c:
        break
    num+=1
    c*=2
if num>k:
    print("No")
else:
    print("Yes")


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

int main(){
	int N, M, X;
	int min = 0;
	int max = 0;
	cin >> N >> M >> X;
	int A[110];
	for(int m=0; m<M; ++m){
		cin >> A[m];
	}
	for(int i=0; i<M; ++i){
	if(A[i]<X){
		++min;
	}else{
		++max;
	}
	}
	int res;
	if (min>max){
	res = max;
	}else{
	res = min;
	}
	cout << res;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	int j;
	
	for (i = 1; i <= 9; i++){
		for (j = 1; j <= 9; j++){
			printf("%dx%d=%d\n", i , j, i * j);
		}
	}
	
	return (0);
}

Measured memory_bytes: 524
"""
import math


a, b, x = list(map(float, input().split()))

theta = 0
if x >= a * a * b / 2:
    theta = math.atan((2.0 * (a * a * b - x)) / (a ** 3)) / (2 * math.pi) * 360
else:
    theta = math.atan((a * b * b) / 2.0 * x) / (2 * math.pi) * 360

print(theta)
"""

from math import atan, pi

a, b, x = map(int, input().split())

if x >= a * a * b / 2:
    print(atan((a*a*b-x)/(a*a*a/2))/(2 * pi)*360)
else:
    print(90 - atan(x/(a*b*b/2))/(2 * pi)*360)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;
int64_t N, K, ans;

void dfs(vector<vector<int>> &g, int v, int p = -1) {
    if(p == -1) {
        for(int i=0; i<g[v].size(); i++) {
            ans *= K-1-i;
            ans %= MOD;
            dfs(g, g[v][i], v);
        }
    } else {
        for(int i=0; i<g[v].size(); i++) {
            if(g[v][i] == p) continue;
            dfs(g, g[v][i], v);
        }
        for(int i=0; i<g[v].size()-1; i++) {
            ans *= K-2-i;
            ans %= MOD;
        }
    }
    return;
}

int main(void) {
    cin >> N >> K;
    ans = K;
    vector< vector<int> > g(N);
    while(--N) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs(g, 0);

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


Measured memory_bytes: 9216
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    c: [[usize; 3]; 3]
    }
    for i in  0..2{
        for j in 0..2{
            if c[i][j + 1] + c[i + 1][j] != c[i][j] + c[i + 1][j + 1]{
                println!("No");
                return
            }
        }
    }
    println!("Yes")
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	static int[][] area;
	static int White,Black;
	static int[] x= {0,1,0,-1};
	static int[] y= {1,0,-1,0};
	static int zone;
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		area=new int[100][100];
		for(int i=0; i<100; i++) {
			for(int j=0; j<100; j++) {
				area[i][j]=0;
			}
		}
		if(A==B && A==1) {
			pl("1 2");
			pl(".#");
			System.exit(0);
		}
		if(A==1 && B>1) {
			White=A;
			Black=B;
			zone=1;
			pl("100 100");
			dot(zone);
			StringBuilder sb=new StringBuilder();
			for(int i=0; i<100; i++) {
				sb=new StringBuilder();
				for(int j=0; j<100; j++) {
					if(area[i][j]==0) {
						sb.append(".");
					}
					else {
						sb.append("#");
					}
				}
				pl(sb.toString());
			}
			System.exit(0);
		}
		else {
			pl("100 100");
			White=A;
			Black=B;
			zone=1;
			Black--;
			White--;
			fill(zone);
			zone+=2;
			dot(zone);
			StringBuilder sb=new StringBuilder();
			for(int i=0; i<100; i++) {
				sb=new StringBuilder();
				for(int j=0; j<100; j++) {
					if(area[i][j]==0) {
						sb.append(".");
					}
					else {
						sb.append("#");
					}
				}
				pl(sb.toString());
			}
			System.exit(0);
		}
	}
	public static void fill(int i) {
		for(int j=0; j<100; j++) {
			area[i][j]=1;	//黒でぬる
		}
		White--;
		if(White<=49) {
			for(int j=1; j<=White; j++) {
				area[i-1][j*2-1]=1;
			}
			White=0;
		}
		else if(White>49) {
			for(int j=1; j<=97; j+=2) {
				area[i-1][j]=1;
			}
			White-=49;
			if(White>0) {
				zone+=2;
				fill(i+2);
			}
		}
	}
	public static void dot(int i) {

		if(Black<=50) {
			for(int j=0; j<Black; j++) {
				area[i][j*2]=1;
			}
			Black=0;
		}
		else if(Black>50) {
			for(int j=0; j<100; j+=2) {
				area[i][j]=1;
			}
			Black-=50;
			if(Black>0) {
				dot(i+2);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

Measured memory_bytes: 22996
dic = {}

N = int(input())
s = [input() for i in range(N)]
for i in range(N):
  dic.setdefault(s[i],0)
  dic[s[i]] += 1
  
M = int(input())
t = [input() for j in range(M)]
for j in range(M):
  dic.setdefault(t[j],0)
  dic[t[j]] -= 1

if max(dic.values()) > 0:
  print(max(dic.values()))
else:
  print(0)

Measured memory_bytes: 3188
#include <stdio.h>


int main(void){
long int test,a,b,sum,i,n,l[1000],bt[100],g[100],c,cl,cb,cg;
    cl=cb=cg=0;
    scanf("%ld%ld%ld",&n,&a,&b);
    for(i=0;i<n;i++)
    {
        scanf("%ld",&c);
        if(c<=a)
        {
            cl++;
        }else{
            if(c>b)
            {
                cg++;
            }else{
                if(c>a && c<=b)
                {
                    cb++;
                }
            }
        }
    }
    if(cl>cg)
    {
        if(cg>cb)
        {
            printf("%ld",cb);
        }else{
            printf("%ld",cg);
        }
    }else{
        if(cl>cb)
        {
            printf("%lld",cb);
        }else{
            printf("%lld",cl);
        }
    }

 



      return 0;
}


Measured memory_bytes: 128
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from math import hypot, copysign

for n in xrange(int(stdin.readline())):
    xa, ya, ra, xb, yb, rb = (float(s) for s in stdin.readline().split())

    distance = hypot(xa - xb, ya - yb)
    diff = ra - rb

    if ra + rb < distance:
        print('0')
    elif abs(diff) <= distance:
        print('1')
    else:
        print(int(copysign(2, diff)))

Measured memory_bytes: 4416
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
const int maxn = 105 + 5;
const int mod = 1e9 + 7;
ll ksm (ll a, ll b)
{
    ll ans = 1 , base = a;
    while (b)
    {
        if (b & 1) ans = ans * base % mod;
        b >>= 1;
        base = base * base % mod;
    }
    return ans;
}
ll C (ll a , ll b)
{
    ll up = 1 , down = 1;
    for (ll i = 0 ; i < b ; i++){
        (up *= (a - i)) %= mod;
        (down *= (b - i)) %= mod;
    }
    return up % mod * ksm(down , mod - 2) % mod;
}
ll a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    ll n , a , b; cin >> n >> a >> b;
    ll ans = ksm(2 , n) % mod;
  //  cout << C(n , a) << " " << C(n , b) << endl;
    ans = (ans - C(n , a) + mod) % mod;
    ans = (ans - C(n , b) + mod) % mod;
    ans = (ans - 1 + mod) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<functional>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

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

	for (int m = 0; m < N; m++) {
		int R = 0;

		for (int y = 0; y < N-m; y++) {
			R += A[y];
		}
		for (int k = N-1-m; k < N ; k++) {
			R += B[k];
		}

		if (Y < R) {
			Y = R;
		}
	}

	cout << Y << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N, Q;

vvi G;
vector<bool> visited;
vi P;
vi ans;

void dfs(int v, int pp) {
    ans[v] = pp + P[v];
    visited[v] = true;
    for (auto nv : G[v]) {
        if (visited[nv]) continue;
        dfs(nv, ans[v]);
    }
}

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

    G = vvi(N, vi(0));
    visited = vector<bool>(N, false);

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    P = vi(N, 0);
    for (int i = 0; i < Q; i++) {
        int p, x;
        cin >> p >> x;
        P[p - 1] += x;
    }

    ans = vi(N);
    dfs(0, 0);

    for (int i = 0; i < N; i++) {
        cout << ans[i] << ' ';
    }
    cout << endl;
    return 0;
}


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

int main() {
  int n; cin >> n;
  vector<int> x(n);
  rep(i,n) { cin >> x[i]; }
  vector<int> sorted(n);
  sorted = x;
  sort(sorted.begin(), sorted.end());
  int cl = sorted[(n-1)/2];
  int cr = sorted[(n-1)/2+1];
  rep(i,n) {
    if (x[i] <= cl) cout << cr << endl;
    else cout << cl << endl;
  }
  return 0;
}

Measured memory_bytes: 4828
#include <cstdio>
#include <cmath>
int main(){
	long long a,b;
	scanf("%lld %lld",&a,&b);
	long long res=1;
	int cnt=1;
	while(res*a<=b){
		res*=2;
		cnt++;
	}
	printf("%d\n",cnt-1);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 10000007 //10^9+7

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}


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

  vector<ll> r;
  vector<ll>g;
  vector<ll> b;
  ll sum = 0;

  for(ll i=0;i<n;i++){
    if(s[i]=='R') r.push_back(i);
    if(s[i]=='G') g.push_back(i);
    if(s[i]=='B') b.push_back(i);
  }
  
  for(int i=0;i<r.size();i++){
    for(int j=0;j<g.size();j++){
      sum += b.size();
      if((max(r[i], g[j]) - min(r[i],g[j]))%2==0 && s[min(r[i],g[j])+(max(r[i], g[j]) - min(r[i],g[j]))/2]=='B') sum--;
      if(max(r[i],g[j]) + (max(r[i], g[j]) - min(r[i],g[j])) < n &&s[max(r[i],g[j]) + (max(r[i], g[j]) - min(r[i],g[j]))]=='B') sum--;
      if(min(r[i],g[j]) - (max(r[i], g[j]) - min(r[i],g[j])) >= 0 && s[min(r[i],g[j]) - (max(r[i], g[j]) - min(r[i],g[j]))]=='B') sum--;
    }
  }

  cout<<sum<<endl;
  return 0;

}

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

/**
 * Created by Olcia on 10.06.2017.
 */
public class Main {
    public static void main(String[] args) {
        Scanner a = new Scanner(System.in);

        int b = a.nextInt();
        int[] tab = new int [b];
        for (int i = 0; i < b ; i++) {
            tab [i] = a.nextInt();
        }
        Arrays.sort(tab);
        int r = tab[b-1] - tab[0];
        System.out.println(r);  

    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mset(x, y) memset((x), (y), sizeof(x))
#define sz(x) ((int)(x).size())
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define cerr cout
#define endl '\n'
using namespace std;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

struct PairCmp
{
    bool operator()(const pii& lhs, const pii& rhs) const
    { 
        return lhs.second < rhs.second; 
    }
};

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

	int h, w, i, j, m, mx = 0, my = 0, curr = 0;
	cin >> h >> w >> m;
	int x[m], y[m];
	map<int, int> xc, yc;
	map<int, set<int>> xhas;
	rep(i, 0, m)
	{
		cin >> x[i] >> y[i];
		xc[x[i]]++;
		yc[y[i]]++;
		xhas[x[i]].insert(y[i]);
	}

	for(auto xi : xc)
		mx = max(mx, xi.ss);
	for(auto yi : yc)
		my = max(my, yi.ss);
	set<int> sx, sy;
	for(auto xi : xc)
	{
		if(mx == xi.ss)
			sx.insert(xi.ff);
	}
	for(auto yi : yc)
	{
		if(my == yi.ss)
			sy.insert(yi.ff);
	}
	//pr(sx, sy, mx, my);

	for(auto xi : sx)
	{
		for(auto yi : sy)
		{
			if(xhas[xi].find(yi) == xhas[xi].end())
			{
				cout << mx + my;
				return 0;
			}
		}
	}
	cout << mx + my - 1;
}

Measured memory_bytes: 104388