akhauriyash/Code-Regression huggingface dataset:
def main():

    from bisect import bisect_left as bl, bisect_right as br, insort
    import sys,heapq,math
    from collections import defaultdict as dd, deque
    def data(): return sys.stdin.readline().strip()
    def mdata(): return list(map(int, data().split()))
    out = sys.stdout.write
    # sys.setrecursionlimit(100000)
    INF = int(1e9)
    mod = int(1e9)+7

    n,m=mdata()
    if n%2!=0:
        for i in range(1,m+1):
            print(i,n-i)
    else:
        for i in range(1,min(m+1,(n-1)//4+1+((n-1)//2)%2)):
            print(i, n - i+1)
        for i in range(min(m+1,(n-1)//4+1+((n-1)//2)%2),m+1):
            print(i,n-i)



if __name__ == '__main__':
    main()


Measured memory_bytes: 70464
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>inline int popcount(T a) {return __builtin_popcount(a);}
template<class T>inline T emod(T a, T p) { return (a%p + p) % p;}
//------------------
class UnionFind {
private:
	unsigned size_; std::vector<int> par, rank; //par = root? -size: par 
public:
	UnionFind() : size_(0), par(std::vector<int>()), rank(std::vector<int>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_+1); rank.resize(size_+1);
		for (unsigned i = 0; i <= size_; i++) par[i] = -1, rank[i] = 0;
	}
	//unsigned size() { return size_; }
	unsigned root(unsigned x) {return par[x] < 0 ? x : par[x] = root(par[x]); }
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y])par[y] += par[x], par[x] = y;
		else if (rank[x] == rank[y])par[x] += par[y], par[y] = x, rank[x]++;
		else par[x] += par[y], par[y] = x;
	}
	int size(int x){ return -par[root(x)];} 
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};
int main() {
    cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15);
    int n; int k; cin >> n >> k;
    vector<int> p(n);
    UnionFind uf(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
        uf.unite(i, p[i]);
    }
    vector<ll> c(n);
    rep(i, n) cin >> c[i];

    vector<ll> sm(n);
    
    rep(i, n) {
        sm[uf.root(i)] += c[i];
    }

    ll ans = -LINF;
    rep(i, n) {
        if(sm[uf.root(i)] > 0) {
            int loop = max(k/uf.size(i)-1, 0);
            ll tmp = sm[uf.root(i)] * loop;
            ll j = i;
            rep(_, k - loop * uf.size(i)) {
                j = p[j];
                tmp += c[j];
                chmax(ans, tmp);
            }
        } else {
            int j = i;
            ll tmp = 0;
            rep(cnt, k) {
                j = p[j];
                tmp += c[j];
                chmax(ans, tmp);
                if(cnt > uf.size(i)) break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}
/*
2 5
2 1
10 -7
3 5
3 1 2
-1000 -2000 -3000
*/

Measured memory_bytes: 3764
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t;
		while ((t = in.nextInt()) > 0) {
			int n = in.nextInt();
			int time = 0;
			while (n-- > 0) {
				if (time < t) {
					time -= in.nextInt();
					time += in.nextInt();
				} else {
					in.next();
					in.next();
				}
			}
			if (time >= t) {
				System.out.println("OK");
			} else {
				System.out.println(t - time);
			}
		}
	}
}

Measured memory_bytes: 23584
import fractions
N, X=map(int, input().split())
x=list(map(int, input().split()))
if N==1:
  print(abs(X-x[0]))
  exit()

l=[abs(x[i]-X) for i in range(N)]
temp=fractions.gcd(l[0], l[1])
if N==2:
  print(temp)
  exit()
  
for i in range(2, N):
  temp=fractions.gcd(temp, l[i])
  
print(temp)

Measured memory_bytes: 16240
#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);
	int k;
	cin>>k;
	vector<ll> ans;
	auto dfs=[&](auto &dfs,int pre,string now)->void{
		if(now.size()==12) return ;
		ans.push_back(stoll(now));
		rep(i,10){
			if(abs(i-pre)<=1){
				dfs(dfs,i,char(i+'0')+now);
			}
		}
	};
	rep(i,10) dfs(dfs,i,to_string(i));
	sort(begin(ans),end(ans));
	ans.erase(unique(begin(ans),end(ans)),end(ans));
	cout<<ans[k]<<endl;
}

Measured memory_bytes: 10604
jisho= {0:
    [[1,2],[3,1],[4,3],[2,4]],
     1:
    [[0,3],[3,5],[5,2],[2,0]],
    2:
    [[0,1],[1,5],[5,4],[4,0]],
    3:
    [[0,4],[4,5],[5,1],[1,0]],
    4:
    [[0,2],[2,5],[5,3],[3,0]],
    5:
    [[2,1],[1,3],[3,4],[4,2]]
       }
i_number = [int(x) for x in input().split()]
n = int(input())
for _ in range(n):
    q1,q2 = [int(x) for x in input().split()]
    for i,n in enumerate(i_number):
        if q1 == n:
            qq1 = i
        if q2 == n:
            qq2 = i
    for k,v in jisho.items():
        if [qq1,qq2] in v:
            print(i_number[k])



Measured memory_bytes: 5608
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int n, a, b, c, l[8];

int rec(int A, int B, int C, int x, int mp){
	x--;
	if(x<0){
		if(A*B*C==0) return 1e9;
		return mp + abs(a-A) + abs(b-B) + abs(c-C) - 30;
	}

	return std::min({
		rec(A+l[x], B, C, x, mp+10),
		rec(A, B+l[x], C, x, mp+10),
		rec(A, B, C+l[x], x, mp+10),
		rec(A, B, C, x, mp)
	});
}

int main(){
	scanf("%d %d %d %d", &n, &a, &b, &c);
	REP(i, 0, n) scanf("%d", &l[i]);
	printf("%d\n", rec(0, 0, 0, n, 0));
	return 0;
}




Measured memory_bytes: 3828
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a*b<=c){
        cout<<a*b<<endl;
    }
    else{
        cout<<c<<endl;
    }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) {
        int n = 0;
        int k = 0;
        int[] arr = null;
        try (Scanner scanner = new Scanner(System.in)) {
            n = scanner.nextInt();
            k = scanner.nextInt();
            arr = new int[n];
            for(int i = 0; i < n ;i++) {
                arr[i] = scanner.nextInt();
            }
        }
        
        // dp[i] = i number of stone
        // will be true if for any arr[x] we have a way when 
        // we chose there is no way i - arr[x] stones can be pick; ie dp[i-arr[x]] == false;
        boolean[] dp = new boolean[k + 1];
        
        for(int stones = 0; stones <= k; stones++) {
            for(int ar : arr) {
                if(stones - ar >= 0 && !dp[stones - ar])
                    dp[stones] = true;
            }
        }

        System.out.println(dp[k]?"First":"Second");
    }
    
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    string s;
    cin >> s;
    int k = s.size(), cnt = 0;
    REP(i,k){
        if(s[i]=='o')cnt++;
    }
    if(cnt+15-k >= 8){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" <<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M,X;
  cin >> N >> M >> X;
  
  vector<int> A(M);
  int costA = 0;
  int costB = 0;
  for(int i = 0 ; i < M ;i++){
    cin >> A.at(i) ;
    if(A.at(i) < X) costA++;
    if(A.at(i) > X) costB++;
  }
  
  cout << min(costA, costB) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define il inline
#define vd void
typedef unsigned long long ll;
il ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
ll x[200010],s[200010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi();ll X=gi();
	for(int i=1;i<=n;++i)x[i]=gi(),s[i]=s[i-1]+x[i];
	ll ans=9e18,res;
	for(int i=1;i<=n;++i){
		res=1ll*i*X+5*(s[n]-s[n-i]);
		int l=n-i-i,r=n-i;
		for(int j=5;r>0;j+=2,l-=i,r-=i)res+=1ll*j*(s[r]-s[std::max(0,l)]);
		ans=std::min(ans,res);
	}
	printf("%llu\n",ans+1ll*n*X);
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int N;
string S;
bool length(string S, int len) {
  rep(i, N-len+1) {
    if (S.find(S.substr(i, len), i+len) != string::npos) {
      return true;
    }
  }
  return false;
}

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

  int start = 0, end = N;
  while (start < end) {
    int mid = start + (end - start) / 2;
    if (length(S, mid)) start = mid + 1;
    else end = mid-1;
  }
  while (!length(S, start)) --start;
  out(start);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && c == b){
        cout << "No" << endl;
    }
    else if(a != b && b != c && c != a){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  
  long long num=0;
  long long ans=10000000000;
  if(X<Y)
  {
    for(int i=0;i<X*2+1;i+=2)
    {
      num=A*(X-i/2)+B*(Y-i/2)+C*i;
      if(num<ans) ans=num;
    }
    for(int i=X*2;i<Y*2+1;i+=2)
    {
      num=B*(Y-i/2)+C*i;
      if(num<ans) ans=num;
    }
  }
  else
  {
    for(int i=0;i<Y*2+1;i+=2)
    {
      num=A*(X-i/2)+B*(Y-i/2)+C*i;
      if(num<ans) ans=num;
    }
    for(int i=Y*2;i<X*2+1;i+=2)
    {
      num=A*(X-i/2)+C*i;
      if(num<ans) ans=num;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

ll a[222222];
ll p[222222];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]; p[i]=a[i]+p[i-1];
	}
	map<ll,ll> ma; ll ans=0;
	ma[0]++;
	for(int i=1;i<=n;i++)
	{
		ans+=ma[p[i]];
		ma[p[i]]++;
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 15872
#include <iostream>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long int ll;

int main(){
    string a,b;	cin >> a >> b;
    if(a.size()>b.size()){
	puts("GREATER");
    }else if(a.size()<b.size()){
	puts("LESS");
    }else{
	if(a>b){
	    puts("GREATER");
	}else if(a<b){
	    puts("LESS");
	}else{
	    puts("EQUAL");
	}
    }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
int H1,H2,M1,M2,K;
int M,N;
scanf("%d %d %d %d %d",&H1,&M1,&H2,&M2,&K);
M=(60*H2+M2)-(60*H1+M1);
N=M-K;
printf("%d",N);

return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <map>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(void){
  int N;
  cin >> N;
  string S[N];
  rep(i, N)
    cin >> S[i];
  //ここまで入力

  //各文字から始まる名前がいくつあるかを格納
  map<char, long long> m;
  rep(i, N)
    if(S[i][0] == 'M' || S[i][0] == 'A' || S[i][0] == 'R' ||
       S[i][0] == 'C' || S[i][0] == 'H')
      m[S[i][0] ]++;

  //場合の数的に掛け算で求まる
  long long ans = 0;
  char str[] = {'M', 'A', 'R', 'C', 'H'};
  for(int i=0; i<5; i++)
    for(int j=i+1; j<5; j++)
      for(int k=j+1; k<5; k++)
	ans += m[str[i] ] * m[str[j] ] * m[str[k] ];

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


Measured memory_bytes: 6144
while (h, w = gets.split.map(&:to_i))!=[0,0] do
    h.times do |i|
		if (i%2)==0 then
			print("#."*(w/2))
			puts w%2==0 ? "" : "#"
		else
			print(".#"*(w/2))
			puts w%2==0 ? "" : "."
		end
	end
	puts
end


Measured memory_bytes: 6888
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
q=int(input())
ans=sum(a)
list1=(Counter(a))
b=[0]*q
c=[0]*q
ct=0
for i in range(q):
    b[i],c[i]=list(map(int,input().split()))
for i in range(q):
    if list1[b[i]]>0 :
        if list1[c[i]]==0:
            list1[c[i]]=list1[b[i]]
            ans=ans-(b[i]*list1[b[i]])+(c[i]*(list1[b[i]]))        
            list1[b[i]]=0
        else:
            ans=ans-(b[i]*list1[b[i]])+(c[i]*(list1[b[i]]))
            list1[c[i]]+=list1[b[i]]  
            list1[b[i]]=0  
    print(ans)

Measured memory_bytes: 87648
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <math.h>
#include <deque>
#include <queue>
#include <map>
#include <iterator>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
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; }

const int INF = 1e9;

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

	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<int> dp(n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		int lim = min(i + k, n - 1);
		for (int j = i + 1; j <= lim; j++) {
			dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
		}
	}

	cout << dp[n - 1] << endl;

}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	string s, str, str2;
	cin >> s;
	str = s.substr(0, n/2);
	str2 = s.substr(n/2, n);
	if (str == str2) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    int n;
    cin >> n;
    vector<int> l;
    REP(i, n) {
        int input;
        cin >> input;
        l.push_back(input);
    }

    sort(ALL(l));
    int longest = l[n-1];
    int sum = accumulate(l.begin(), l.end()-1, 0);
    if (sum <= longest){
        P("No");
    }
    else {
        P("Yes");
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

vector<ll> v;

ll f(ll p){
  ll ret = 0;
  rep(i,0,v.sz-1){
    ll a = v[i];
    if(a==0){
      if(p>0){
        ret += v.sz-1-i; 
      }
    }
    else if(a>0){
      if(a*v[i+1]>=p)continue;
      long long low = i+1;
      long long high = v.sz-1;
      while(low < high){
        long long mid = (high + low + 1) >> 1;
        if(a*v[mid]<p){
          low = mid;
        }
        else{
          high = mid - 1;
        }
      }
      ret += low-i;
    }
    else{
      if(a*v[v.sz-1]>=p)continue;
      long long low = i+1;
      long long high = v.sz-1;
      while(low < high){
        long long mid = (high + low) >> 1;
        if(a*v[mid]<p){
          high = mid;
        }
        else{
          low = mid + 1;
        }
      }
      ret += v.sz-low;
    }
  }
  return ret;
}

int main(){
  ll n,k;
  cin>>n>>k;
  k--;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  sort(all(v));
  long long low = -1000000000000000010LL;
  long long high = 1000000000000000010LL;
  
  while(low < high){
    long long mid = (high + low + 1) >> 1;
    
    if(k >= f(mid)){
      low = mid;
    }
    else{
      high = mid - 1;
    }
  }
  cout << low << endl;
  return 0;
}

Measured memory_bytes: 3444
n,a,b = map(int, input().split())
v = list(map(int, input().split()))
v.sort()
v.reverse()

ans = 0.0
for i in range(a):
	ans += v[i]

ans /= a
print("{0:.20f}".format(ans))

cnt = 0
cnt2 = 0
for i in range(n):
	if v[a-1] == v[i]:
		cnt += 1
		if i >= a-1:
			cnt2 += 1

comb = [[0 for i in range(55)] for j in range(55)]
for i in range(55):
	comb[i][i] = 1
	comb[i][0] = 1
	for j in range(1,i):
		comb[i][j] = comb[i-1][j-1] + comb[i-1][j]

ans2 = 0

if v[0] == v[a-1]:
	for i in range(a-1, b):
		if v[i] != v[0]:
			break
		num = i+1
		ans2 += comb[cnt][num]
else:
	num = cnt-cnt2+1
	ans2 += comb[cnt][num]
print(ans2)


Measured memory_bytes: 39408
def bfs(field,H,W,start_x,start_y,tmp_N):
    direction = [[-1,0],[1,0],[0,-1],[0,1]]
    que = []
    que.append([start_x,start_y])
    INF = 1000000
    min_path = [[INF] * W for i in range(H)]
    min_path[start_y][start_x] = 0
    while len(que) != 0:
        current = que.pop(0)
        for d in direction:
            nx = current[0] + d[0]
            ny = current[1] + d[1]
            if 0 <= nx < W and 0 <= ny < H and field[ny][nx] != "X" and min_path[ny][nx] == INF:
                min_path[ny][nx] = min_path[current[1]][current[0]] + 1
                if field[ny][nx] == tmp_N:
                    return nx,ny,min_path[ny][nx]
                else:
                    que.append([nx,ny])

def getField():
    matrix = []
    first = input().strip()
    H,W,N = map(int,first.split())
    for i in range(H):
        row = list(input().strip())
        for j in range(W):
            if row[j].isdigit():
                row[j] = int(row[j])
        matrix.append(row)
    return matrix,H,W,N

def getStart(field):
    for y in range(len(field)):
        for x in range(len(field[0])):
            if field[y][x] == "S":
                return x,y

def main():
    matrix,H,W,N = getField()
    sx,sy = getStart(matrix)
    distance = 0
    tmp_x,tmp_y,tmp_dist = bfs(matrix,H,W,sx,sy,1)
    distance += tmp_dist
    tmps = [tmp_x,tmp_y]
    for k in range(N-1):
        tmp_x,tmp_y,tmp_dist = bfs(matrix,H,W,tmps[0],tmps[1],k+2)
        distance += tmp_dist
        tmps = [tmp_x,tmp_y]
    print(distance)

if __name__=='__main__':
    main()

Measured memory_bytes: 36988
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int main(){
  
  int n, k;
  scanf("%d %d", &n, &k);

  int res = 1;
  REP(i,n){
    if(res * 2 < res + k){
      res *= 2;
    }else{
      res += k;
    }
  }

  printf("%d\n", res);
  return 0;
}



Measured memory_bytes: 256
[a,b] = [int(x) for x in input().split()]

for x in range(1,1250):
    tax_a = int(x*0.08)
    tax_b = int(x*0.1)

    if tax_a == a and tax_b == b:
        print(x)
        exit()
else:
    print(-1)

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

int n,i;

int f(int n)
{
	if(n==1) return 1;
	else if(n%2==0) return f(n/2);
	else return 0;
}

int main()
{
	while(cin>>n)
	{
		for(i=n;i>0;i--)
		{
			if(f(i)) break;
		}
		printf("%d\n",i);
	}
}

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

int n;
map<string, int> m;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<string> a(n);
    for (auto& i : a) {
        cin >> i;
        m[i]++;
    }

    for (int i = 1; i < n; i++) {
        if (a[i][0] != a[i - 1][a[i - 1].size() - 1]) {
            cout << "No";
            return 0;
        }
    }

    for (auto& i : m) {
        if (i.second > 1) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	int N,X;
	cin >> N>>X;
	double an = 0;
	
	for (int i = -1000000; i < 1000001; i++) {
		if (abs(i - X) <= abs(N-1) ){
			cout << i << " ";
		}
		
	}
	
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <utility>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <unordered_map>
#include <map>
#include <bitset>
#include <string>
#include <cstring>

#define pb push_back
#define mp make_pair
#define l(x) x << 1
#define r(x) x << 1 | 1
#define scan(x) do {while((x=getchar())<'0') ; for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0') ; } while(0)
char _;
#define x first
#define y second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<float, float> pff;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;

const int MAXN = 1e5 + 5;
int N, a, b, c, Q, K;
vector<pii> adj[MAXN];
ll dist[MAXN];

void dfs(int i, int p, ll d) {
    dist[i] = d;
    for (int j = 0; j < adj[i].size(); j++) {
        if (adj[i][j].x != p) {
            dfs(adj[i][j].x, i, d + adj[i][j].y);
        }
    }
}

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N - 1; i++) {
        scanf("%d %d %d", &a, &b, &c);
        adj[a].pb(mp(b, c));
        adj[b].pb(mp(a, c));
    }
    scanf("%d %d", &Q, &K);
    dfs(K, K, 0);
    for (int i = 0; i < Q; i++) {
        scanf("%d %d", &a, &b);
        printf("%lld\n", dist[a] + dist[b]);
    }
}


Measured memory_bytes: 14336
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	l := getNextInt(scanner) - 1
	r := getNextInt(scanner)
	d := getNextInt(scanner)
	fmt.Fprintln(writer, r/d-l/d)
}


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

int main()
{
    int n,b;
    cin>>n>>b;
    int a[n],s=0;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<b;i++)
        s+=a[i];
        cout<<s<<endl;
}


Measured memory_bytes: 3636
using System;
using System.Linq;
public class Aprob {
    public static void Main() {
        string[] readSome = new string[2];
        readSome = Console.ReadLine().Split(' ');
        long S = long.Parse(readSome[0]);
        long C = long.Parse(readSome[1]);
        long pairs = 0;
        if (C <= 2 * S) {
            pairs = C/2;
        } else {
            pairs = S;
            C -= 2 * S;
            S = 0;
            pairs += C / 4;
        }
        Console.WriteLine(pairs);
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int t[8];
//int n[101];
int ans = 0;
int count32 = 0;

int main(){
	
	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		int a;
		cin >> a;
		a = a/400;
		if(a <= 7) {t[a]++;}
		else {count32++;}
	}

	for(int i = 0; i < 8; i++){
		if(t[i] != 0) {
			ans++;
			
			
		} 
		
	}

	if(ans == 0){
		cout << 1 << " " << count32 <<endl;
	}
	else if(ans != 0){
		cout << ans <<" " << ans + count32 << endl;
	}




}

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

int main() {
    int x, n, temp;
    cin >> x >> n;
    int p[102] = {};

    for (int i = 0; i < n; i++) {
        cin >> temp;
        p[temp] = 1;
    }

    int i = 0;

    for (; x - i >= 0 || x + i <= 101; i++) {
        if (x - i >= 0 && p[x - i] == 0) {
            cout << x - i;
            return 0;
        } else if (x + i <= 101 && p[x + i] == 0) {
            cout << x + i;
            return 0;
        }
    }
    return 0;
}


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

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

    vector<long long int> cands = { a*c, a*d, b*c, b*d };
    long long int ans = *max_element(cands.begin(), cands.end());
    cout << ans << endl;
    return 0;
}


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    rep(i,n) cin>>h[i];
    vector<int> dp(n);
    dp[0]=0; //コスト
    rep(i,n){
        dp[i]=min(dp[max(0,i-1)]+abs(h[i]-h[max(0,i-1)]),dp[max(0,i-2)]+abs(h[i]-h[max(0,i-2)]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=3e3+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  string s;
  cin>>s;
  int sum=0;
  for(int i=0;i<s.size();i++)
  {
    int d=s[i]-'0';
    sum+=d;
  }
  if((sum%9)==0) cout<<"Yes"<<endl;  
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3772
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x=0; char ch=gc(); bool positive=1;
	for (;!isdigit(ch);ch=gc())if(ch=='-')positive=0;
	for (;isdigit(ch);ch=gc())x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(int a){
    if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(int a){
	if(a<0){
		a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=100005;
vector<int> v[N];
ll ans[N],mx,sum[N];
int n,m,vis[N],a[N],b[N],q[N],father[N];
inline bool cmp(int x,int y){
	return a[x]<a[y];
}
inline int getfather(int x){
	return father[x]==x?x:father[x]=getfather(father[x]);
}
void mer(int x,int y){
	int t1=getfather(x),t2=getfather(y);
	if(t1!=t2){
		sum[t2]+=sum[t1]; father[t1]=t2;
		ans[t2]=min(ans[t2],ans[t1]+max((ll)0,a[t2]-sum[t1]-ans[t1]));
	}
}
int main(){
	n=read(); m=read();
	for(int i=1;i<=n;i++){
		a[i]=read(); b[i]=read(); father[i]=q[i]=i; a[i]=max(a[i]-b[i],0);
	}
	sort(&q[1],&q[n+1],cmp);
	for(int i=1;i<=m;i++){
		int a=read(),b=read();
		v[a].push_back(b); v[b].push_back(a);
	}
	for(int i=1;i<=n;i++){
		int tot=0; vis[q[i]]=1; ans[q[i]]=a[q[i]]; sum[q[i]]=b[q[i]];
		for(unsigned j=0;j<v[q[i]].size();j++)if(vis[v[q[i]][j]]){
			mer(v[q[i]][j],q[i]);
		}
	}
	//cout<<ans[getfather(1)]<<" "<<sum[getfather(1)]<<endl;
	cout<<ans[getfather(1)]+sum[getfather(1)]<<endl;
}


Measured memory_bytes: 9468
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	ll n;
	cin>>n;
//	n--;
	string ans = "";
	ll prod  = 1;
	while(n>0){
		n-=1;
		ll val = n%26;
		ans+=char('a' + val);
		n/=26;
		
		
	}
	reverse(all(ans));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3656
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {


    public static void main(String[] args) {
    	
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int ans = 0;
        
        for(int i=n;i<=m;i++){
        	if(i/10000==i%10)
        		if((i/1000)%10==(i%100)/10)
        			ans++;
        }
        
        System.out.println(ans);


        in.close();
    }
}


Measured memory_bytes: 21844
import sys
from io import StringIO
import unittest

sys.setrecursionlimit(10**5)

def dfs(u, visited, g, seq):
	visited[u] = True
	for v in g[u]:
		if visited[v] == True or not seq[u][v]:
			continue
		dfs(v, visited, g, seq)

def resolve():
	n, m = map(int, input().split())
	seq = [[True]*n for _ in range(n)]
	g = [[] for _ in range(n)]
	edges = []
	ans = 0
	for _ in range(m):
		a, b = map(int, input().split())
		edges.append([a-1, b-1])
	for i in range(m):
		g[edges[i][0]].append(edges[i][1])
		g[edges[i][1]].append(edges[i][0])

	for i in range(m):
		visited = [False]*n

		seq[edges[i][1]][edges[i][0]] = False
		seq[edges[i][0]][edges[i][1]] = False

		dfs(0, visited, g, seq)
		if len(visited) != visited.count(True):
			ans += 1
		seq[edges[i][1]][edges[i][0]] = True
		seq[edges[i][0]][edges[i][1]] = True
	print(ans)
resolve()

Measured memory_bytes: 53208
/*
    Author      : Dinesh Verra
    College     : ABV-IIITM
    Date        : 20/08/2020
*/
// #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
using namespace std;
typedef long long ll;
// #define ll int
typedef unsigned long long ull;
#define cu continue
#define br break
#define pb push_back
#define eb emplace_back
#define mod 1000000007
#define inf INT_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define F first
#define S second
#define vll vector <ll>
#define vpll vector <pll>
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define all(v) v.begin(),v.end()
#define nl cout<<'\n'

template <typename A1>
void prn(A1&& arg)
{
	cout<<arg<<'\n';
}
template <typename A1, typename... A>
void prn(A1&& arg, A&&... args)
{
	cout<<arg<<' ';
	prn(args...);
}

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


	ll n,x,t;
	cin>>n>>x>>t;
	ll m=ceil(1.0*n/x);
	ll ans=m*t;
	prn(ans);
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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 (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    string S;
    cin >> S;
    ll res = 0;
    if(S=="RRR") res = 3;
    else if(S=="RRS" or S=="SRR" ) res = 2;
    else if(S=="SSS") res = 0;
    else res = 1;
    cout << res << endl;

    return 0;
}

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

using namespace std;


int main () {


	int n, k;
	scanf("%d %d", &n, &k);

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int x; scanf("%d", &x);
		if (x >= k) ++ans;
	}

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



	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    REP(i, N) cin >> H[i];

    vector<set<int> > near(N);
    REP(m, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        near[a].insert(H[b]);
        near[b].insert(H[a]);
    }

    int ans = 0;
    REP(i, N) {
        if(near[i].size() == 0) {
            ans++;
            continue;
        }
        int top = *near[i].rbegin();
        if(H[i] > top) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 17688
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>


using namespace std;
using ll = long long;

const ll mod = 1000000007;

int N, D, x[11][11];

int main()
{
	cin >> N >> D;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < D; j++)
		{
			cin >> x[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			int temp = 0;
			for (int k = 0; k < D; k++)
			{
				temp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			if (sqrt((double)temp) == floor(sqrt((double)temp))) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
	int n,m,ky,kx,d=0,w=1;
	cin>>n>>m>>ky;
	long long a[n+1];
	long long b[m+1];
	a[0]=0;
	b[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]=a[i]+a[i-1];
		if(a[i]<=ky)
		d=i;
	}
	for(int i=1;i<=m;i++)
	{
		cin>>b[i];
		b[i]=b[i]+b[i-1];
	}
	for(int i=d;i>=0;i--)
	{
		kx=ky-a[i];
		for(int p=w;p<=m;p++)
		{
			if(b[p]>kx)
			break;
			else if(d<i+p)
			d=i+p;
			w=p;
		}
	}
	cout<<d;
	return 0;
}

Measured memory_bytes: 6776
using System.Linq;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var allcard = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
        var scard = new List<int>();
        var hcard = new List<int>();
        var ccard = new List<int>();
        var dcard = new List<int>();

        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            switch(line[0])
            {
                case "S":
                    scard.Add(int.Parse(line[1]));
                    break;
                case "H":
                    hcard.Add(int.Parse(line[1]));
                    break;
                case "C":
                    ccard.Add(int.Parse(line[1]));
                    break;
                 case "D":
                    dcard.Add(int.Parse(line[1]));
                    break;
                default:
                    break;
            }
        }
        var z = allcard.Except(scard).ToList();
        z.Sort();
        foreach (var ss in z)
            Console.WriteLine("S {0}", ss);
        var zz = allcard.Except(hcard).ToList();
        zz.Sort();
        foreach (var ss in zz)
            Console.WriteLine("H {0}", ss);
        var zzz = allcard.Except(ccard).ToList();
        zzz.Sort();
        foreach (var ss in zzz)
            Console.WriteLine("C {0}", ss);
        var zzzz = allcard.Except(dcard).ToList();
        zzzz.Sort();
        foreach (var ss in zzzz)
            Console.WriteLine("D {0}", ss);



    }
}

Measured memory_bytes: 10064
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    for (ll i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    const ll MAX = accumulate(v.begin(), v.end(), (ll)0);
    vector<vector<ll>> dp(N + 1, vector<ll>(MAX + 1, W + 1));
    dp[0][0] = 0;
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j <= MAX - v[i]; j++) {
            dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
        }
        for (ll j = 0; j <= MAX; j++) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }

    ll ans = 0;
    for (ll j = MAX; j >= 0; j--) {
        if (dp[N][j] <= W) {
            ans = j;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 80256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.print("\n");
		}
	}
}

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

int main() {
  int d;
  while(true) {
    cin>>d;
    if(d==0) break;

    int a,b,sa=0,sb=0;
    for(int i=0; i<d; i++) {
      cin>>a>>b;
      if(a>b) sa+=a+b;
      else if(b>a) sb+=a+b;
      else sa+=a,sb+=b;
    }

    cout<<sa<<" "<<sb<<endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

string S;
int ans;
int cur;

int term(){
    int n = S[cur++] - '0';
    if(S[cur] == '*'){
        cur++;
        n *= term();
    }
    return n;
}

int expression(){
    int n = term();
    if(S[cur] == '+'){
        cur++;
        n += expression();
    }
    return n;
}

int left_to_right(){
    int tans = S[0] - '0';
    for(int i=1; i<S.length(); i+=2){
        int n = S[i+1] - '0';
        if(S[i] == '+')
            tans += n;
        else // *
            tans *= n;
    }
    return tans;
}

void solve(){
    cur = 0;
    
    char table[2][2] = {{'I', 'M'}, {'L', 'U'}};
    
    bool is_left_to_right = left_to_right() == ans;
    bool is_multiplication_first = expression() == ans;
    
    cout << table[is_left_to_right][is_multiplication_first] << endl;
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    
    cin >> S >> ans;
    solve();
    
    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\n" << (#x) << " = " << (x) << "\n"
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0; i < s.length(); ++i){
		if(s[i] == 'R')
			ans++;
	}
	if(ans == 2 && s[1] != 'R')
		cout << "1";
	else
		cout << ans;
	return 0;
}

Measured memory_bytes: 3608