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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    unsigned long long c,d;
    ll a,b; cin >> a  >> b >> c >> d;
    auto C = (c*d)/__gcd(c,d);
    auto solve = [&] (ll x) {
        return x - (x/c + x/d - x/C);
    };
    cout << solve(b) - solve(a-1) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int k(int n){
  if(n<2) return 1;
  else return n*k(n-1);
}
int main(){
  int n; scanf("%d",&n);
  int a[n][2];
  double d[n][n],s=0;
  for(int i=0; i<n; i++){
    scanf("%d%d\n",&a[i][0],&a[i][1]);
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      d[i][j] = sqrt(pow(a[i][0]-a[j][0],2)+pow(a[i][1]-a[j][1],2));
      s+=d[i][j];
    }
  }
  printf("%lf\n",s/n);
  return 0;
}

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

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//const int INF = 0x3f3f3f3f;
//const int mod=1e9+7;
//const double pi=3.14159265359;
//###################################################################
int main() {
         int n=D();
         if(n%1000==0)puts("0");
         else
             cout<<1000-(n%1000);

}

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

using namespace std;

int main() {
	string S;
	cin >> S;
	if (std::string::npos != S.find("RRR")) {
		cout << 3<<endl;
	}
	else if (std::string::npos != S.find("RR")) {
		cout << 2 << endl;
	}
	else if (std::string::npos != S.find("R")) {
		cout << 1<<endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		int M = Integer.parseInt(scan.next());
		int[] P = new int[M];
		int[] Y = new int[M];
		Map<Integer, List<Integer>> map = new HashMap<>();
		List<Integer> value = new ArrayList<>();
		int key;

		for (int i = 0; i < M; i++) {
			key = Integer.parseInt(scan.next());
			P[i] = key;
			value = map.get(key);
			if(value == null) {
				value = new ArrayList<>();
				map.put(key, value);
			}
			Y[i] = Integer.parseInt(scan.next());
			value.add(Y[i]);
		}


		for (Map.Entry<Integer, List<Integer>> entry : map.entrySet()) {
			Collections.sort(entry.getValue());
		}

		Map<Integer,Map<Integer,Integer>> index_map = new HashMap<Integer,Map<Integer,Integer>>();
		Map<Integer,Integer> index = new HashMap<>();
		int num;
		for (Map.Entry<Integer, List<Integer>> entry : map.entrySet()) {
			num =1;
			index = new HashMap<Integer, Integer>();
			for(int year:entry.getValue()) {
				index.put(year, num);
				num++;
			}
			index_map.put(entry.getKey(), index);
		}

		PrintWriter out = new PrintWriter(System.out);
		for (int i = 0; i < M; i++) {
			out.print(String.format("%06d", P[i]));
			out.println(String.format("%06d", index_map.get(P[i]).get(Y[i])));
		}
		out.flush();

	}

	private static int getNumber(int value, List<Integer> value_list) {
		int num = 1;
		for (int v : value_list) {
			if (value == v) {
				return num;
			}
			num++;
		}
		return num;
	}
}


Measured memory_bytes: 172588
#include<iostream>

using namespace std;

int main() {
  int min, max;
  string str;
  
  cin >> min;
  cin >> max;

  int c=0, l;
  bool flag;
  for(int i=min; i<=max; i++) {
    str = to_string(i);
    l = str.length();
    flag = true;
    for(int j=0; j<l/2; j++) {
      if (str[j] != str[l-1-j]) 
        flag = false;
    }
    if(flag)
      c++;
  }

  cout << c << endl;

  return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let w: i64 = input();
    let a: i64 = input();
    let b: i64 = input();

    if a + w < b {
        println!("{}", b - a - w);
    } else if b + w < a {
        println!("{}", a - b - w);
    } else {
        println!("0");
    }
}


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

#define int long long
//#define uint __int128_t

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,n=200020;
int h[200020],a[200020];
int bit[200020],dp[200020];

//区間の最大値を求める
int query(int i){
    int res=0;
    while(i>0){
        chmax(res,bit[i]);
        i-=(i&-i);
    }
    return res;
}

//区間の最大値をaに更新
void add(int i,int a){
    while(i<=n){
        chmax(bit[i],a);
        i+=(i&-i);
    }
}


signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    cin>>N;
    rep(i,0,N)cin>>h[i];
    rep(i,0,N)cin>>a[i];
    
    rep(i,0,N){
        dp[h[i]]=chmax(dp[h[i]],query(h[i]-1)+a[i]);
        add(h[i],dp[h[i]]);
    }
    int ans=0;
    rep(i,0,200020)chmax(ans,dp[i]);
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 6528
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))

if 0 in a:
    print(0)
    exit()
now = 1
for i in a:
    now *= i
    if now > 10**18:
        print(-1)
        exit()

print(now)


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

using namespace std;

typedef long long ll;

int n, A[100010];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &A[i]);
	sort(A + 1, A + n + 1);
	if(A[1] >= 0) {
		ll tot = -A[1];
		for(int i = 2; i <= n; i++) tot += A[i];
		printf("%lld\n", tot);
		for(int i = 2; i < n; i++) printf("%d %d\n", A[1], A[i]), A[1] -= A[i];
		printf("%d %d\n", A[n], A[1]);
	} else if(A[n] <= 0) {
		ll tot = A[n];
		for(int i = 1; i < n; i++) tot -= A[i];
		printf("%lld\n", tot);
		for(int i = 1; i < n; i++) printf("%d %d\n", A[n], A[i]), A[n] -= A[i];
	} else {
		ll tot = 0;
		for(int i = 1; i <= n; i++) if(A[i] < 0) tot -= A[i]; else tot += A[i];
		printf("%lld\n", tot);
		int i;
		for(i = n - 1; A[i] >= 0; i--) printf("%d %d\n", A[1], A[i]), A[1] -= A[i];
		for(; i >= 1; i--) printf("%d %d\n", A[n], A[i]), A[n] -= A[i];
	}
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}


int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m;
	cin >> n >> m;
	Graph g(n);
	map<int, int> mp;
	REP(i, m)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		add_edge(g, a, b, 0);
		add_edge(g, b, a, 0);
	}
	vi color(n, -1);
	REP(i, n)
	{
		if (color[i] >= 0) continue;
		int b = 1, w = 0;
		color[i] = 0;
		queue<int> que;
		que.push(i);
		while (!que.empty())
		{
			int t = que.front();
			que.pop();
			for (auto e : g[t])
			{
				int nx = e.to;
				if (color[nx] >= 0)
				{
					if (color[nx] == color[t])
					{
						cout << -1 << endl;
						return 0;
					}
					else continue;
				}
				color[nx] = 1 - color[t];
				if (color[nx]) w++;
				else b++;
				que.push(nx);
			}
		}
		mp[abs(b - w)]++;
	}
	vi v;
	int sum = 0;
	for (auto i : mp)
	{
		sum += i.first*i.second;
		int t = 1;
		int cnt = 0;
		while (1)
		{
			if (cnt + t <= i.second)
			{
				cnt += t;
				v.push_back(i.first*t);
				t *= 2;
			}
			else
			{
				v.push_back(i.first*(i.second - cnt));
				break;
			}
		}
	}
	vector<bool> dp(n + 1, false);
	dp[0] = true;
	REP(i, v.size())
	{
		for (int j = n; j >= 0; j--)
		{
			if (j - v[i] < 0) break;
			if (!dp[j - v[i]]) continue;
			dp[j] = true;
		}
	}
	ll ans = 0;
	REP(i, dp.size())
	{
		if (dp[i])
		{
			ll dif = abs(i - (sum - i));
			ll tmp = (n + dif) / 2 * (n - dif) / 2 - m;
			chmax(ans, tmp);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
string S, T;

    cin >> S >> T;

int count=0;
for(int i=0 ;i<3 ; i++){
   if(S.at(i)==T.at(i)){
      count+=1;
   }
}
cout << count << endl;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;




int main(){
    ll n,m;
    cin>>n>>m;
    vector<vector<ll>> a(n);
    for(int i=0;i<n;i++){
        for(int t=0;t<n;t++){
            char b;
            cin>>b;
            a[i].push_back((b=='#'?1:0));
        }
    }
    vector<vector<ll>> b(m);
    for(int i=0;i<m;i++){
        for(int t=0;t<m;t++){
            char c;
            cin>>c;
            b[i].push_back((c=='#'?1:0));
        }
    }
    bool judge=false;
    for(int i=0;i+m<=n;i++){
        for(int t=0;t+m<=n;t++){
            bool j=true;
            for(int x=0;x<m && j;x++){
                for(int y=0;y<m && j;y++){
                    if(b[x][y]!=a[x+i][y+t]){j=false;}
                }
            }
            if(j){judge=true;}
        }
    }
    cout<<(judge?"Yes":"No")<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2010;
int n;
int a[maxn];

void solve() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	sort(a + 1, a + n + 1);
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1, cnt; j <= n; ++j) {
			cnt = lower_bound(a + 1, a + n + 1, a[i] + a[j]) - a - 1 - j;
			ans += cnt;
		}
	printf("%d\n", ans);
}
int main() {
	solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    double a, b, x, ans;
    cin >> a >> b >> x;
    if(a*b*a/2 < x){
        double up = (a*b-x/a)*2/a;
        ans = atan2(up, a);
    }else{
        double s = (2*x)/(a*b);
        ans = atan2(b, s);
    }
    ans *= 180.0/M_PI;
    cout << setprecision(20)<< ans << endl;
    return 0;
}

Measured memory_bytes: 256
//prince_bundela

#include<string.h>
#include <iostream>
#include<cstdio>
#include <stack>
#include <vector>
// this is a comment
using namespace std;
#define INF 0x7ffffff
typedef long long ll;
const int maxn=1e5+10;
int pre[maxn];
int dis[maxn];
int findset(int x)
{
    if(x==pre[x])   return x;
    int root=findset(pre[x]);
    dis[x]=dis[pre[x]]+dis[x];
    return pre[x]=root;
}
bool unionset(int x,int y,int w)
{
    int fx=findset(x),fy=findset(y);
    if(fx==fy)
        return w==dis[y]-dis[x];
    pre[fy]=fx;
    dis[fy]=dis[x]+w-dis[y];
    return true;
}
int n,m;       //input members
int main()    //main body
{
   scanf("%d%d",&n,&m);
   for(int i=1;i<=n;i++)
    pre[i]=i;
   bool lose=true;
   for(int i=0;i<m;i++)
   {
       int x,y,w;
   scanf("%d%d%d",&x,&y,&w);
        if(lose)
       lose=unionset(x,y,w);
   }
   if(lose) printf("Yes\n");          //output
   else     printf("No\n");
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int number[20000];
	int i;
	int howmany;
	
	for(i=0;i<20000;i++)
	{
		scanf("%d",&number[i]);
		if(number[i] == 0)
		{
			howmany = i;
			
			goto next;
		}
	}
	
	next:
	
	for(i=0;i<howmany;i++)
	{
		printf("Case %d: %d\n",i+1,number[i]);
	}
	
	return 0;
}

Measured memory_bytes: 2740
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){
    int n, m, s, g1, g2;
    while (cin >> n >> m >> s >> g1 >> g2,n!=0){
        s--, g1--, g2--;

        vvi G(n, vi(n, 1e8));
        rep(i, m){
            int a, b, c;
            cin >> a >> b >> c;
            a--, b--;
            G[a][b] = c;
        }

        rep(k, n)rep(i, n)rep(j, n){
            G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
        }
        rep(i, n) G[i][i] = 0;

        int ans = 1e8;
        rep(i, n){
            ans = min(ans, G[s][i] + G[i][g1] + G[i][g2]);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1260
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	long long n;
	int fac=1;
	cin>>n;
	if(n==1)
	cout<<1<<endl;
	else{
	while(pow(2,fac)<=n)fac++;
	long long ans;
	ans=pow(2,fac)-1;
	printf("%lld",ans);
}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iterator> 
#include <map>
#include <unordered_map> 
#include <set>
#include <algorithm>
#include <string>
using namespace std;
/*void IO(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}*/
int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
void solve(){
    int n;
    cin>>n;
    cout<<arr[n-1];
}
int main(){
    //IO();
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    while(t--){
        solve();
    }
    return 0;
}


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

string f(int k, string s){
  string ret = s;
  ret[k-1] += (97 - 65);
  return ret;
}

int main(void){
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  cout << f(k, s) << endl;
  return 0;
}


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

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N, L;
  std::cin >> N >> L;
  std::vector<i64> a;
  tools::read(a, N);

  std::vector<i64>::iterator it1, it2;
  for (it1 = a.begin(), it2 = ++a.begin(); it2 != a.end(); ++it1, ++it2) {
    if (*it1 + *it2 >= L) break;
  }
  if (it2 == a.end()) {
    std::cout << "Impossible" << std::endl;
    return 0;
  }

  const i64 last = std::distance(a.begin(), it2);
  std::cout << "Possible" << std::endl;
  for (i64 i = 1; i < last; ++i) {
    std::cout << i << std::endl;
  }
  for (i64 i = N - 1; i > last; --i) {
    std::cout << i << std::endl;
  }
  std::cout << last << std::endl;
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    /* ll t;
    cin>>t;
    while(t--) */
    {
        ll i,j,k,x,l,m,n,a,b,c,d,cnt=0,p,q;
        cin>>x;
        for(i=0;i<=1000000;i++)
        {
            for(j=-1000;j<=1000;j++)
            {
            if(i!=j)
                {if(x%abs(i-j)==0)
                {
                    if((pow(i,5)-pow(j,5))==x)
                    {
                        cout<<i<<" "<<j<<endl;
                        i=1000000;
                    }
                }
                }
            }
        }



    }
}


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

int main(int argc, char const *argv[])
{
    string s,t;
    cin >> s;
    cin >> t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    s<t ? cout << "Yes" : cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    if (A + B <= 2 * C) {
        cout << A * X + B * Y << endl;
        return 0;
    }
    if (A >= 2 * C && X >= Y) {
        cout << 2 * C * X << endl;
        return 0;
    }
    if (B >= 2 * C && X <= Y) {
        cout << 2 * C * Y << endl;
        return 0;
    }
    if (X >= Y) {
        cout << 2 * C * Y + A * (X - Y) << endl;
    }
    else {
        cout << 2 * C * X + B * (Y - X) << endl;
    }


}


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

int main(){
  long w, l, x, y;
  int ans = 0;
  double s;
  cin >> w >> l >> x >> y;
  s = (w * l) / 2.0;
  if(x*2 == w && y*2 == l) ans = 1;
  cout << s << " " << ans << endl;
} 

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

template <class T>
inline T Max(const T &a, const T &b) {return a > b ? a : b;}

const int N = 23, C = (1 << 20) + 5;

int n, k, fi[N][C][2], ansl, anss;
bool start[N][C];
char s[C];

std::vector<int> f[N][N];

int main()
{
	std::cin >> n >> k;
	for (int i = 0; i <= n; i++)
	{
		scanf("%s", s);
		for (int S = 0; S < (1 << i); S++)
			start[i][S] = s[S] - '0';
	}
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= i; j++)
			for (int S = 0; S < (1 << i); S++)
				f[i][j].push_back(!j && start[i][S] ? 1 : 0);
	for (int i = 1; i <= n; i++)
		for (int S = 0; S < (1 << i); S++)
			if (S < (1 << i - 1)) fi[i][S][0] = 1, fi[i][S][1] =
				S ? fi[i - 1][S][1] + 1 : 0;
			else fi[i][S][1] = 1, fi[i][S][0] = S < (1 << i) - 1
				? fi[i - 1][S ^ (1 << i - 1)][0] + 1 : 0;
	for (int i = n; i >= 0; i--)
		for (int j = 0; j < i; j++)
			for (int S = 0; S < (1 << i); S++)
			{
				f[j][j][S >> i - j] += f[i][j][S];
				int S1 = S >> i - j, S2 = S & (1 << i - j) - 1,
					p0 = fi[i - j][S2][0], p1 = fi[i - j][S2][1];
				if (p0) f[i - p0 + 1][j + 1][(S1 << i - j - p0 + 1) |
					(S2 & (1 << i - j - p0) - 1)] += f[i][j][S];
				if (p1) f[i - p1 + 1][j + 1][(S1 << i - j - p1 + 1) |
					(S2 & (1 << i - j - p1) - 1) | (1 << i - j - p1)] += f[i][j][S];
			}
	for (int i = 1; i <= n; i++)
		for (int S = 0; S < (1 << i); S++)
			if (f[i][i][S] >= k && i > ansl) ansl = i, anss = S;
	for (int i = ansl; i >= 1; i--) printf("%d", (anss >> i - 1) & 1);
	return puts(""), 0;
}

Measured memory_bytes: 245692
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

using pii = pair<int,int>;
vector<pii> ary;
set<int> block;

const int limit = 200010;
int s[limit], t[limit], x[limit], e[limit];

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,q;
	cin >> n >> q;
	rep(i, n){
		cin >> s[i] >> t[i] >> x[i];
		s[i] -= x[i];
		t[i] -= x[i];
		ary.push_back(pii(s[i], i));
		ary.push_back(pii(t[i], i));
	}

	rep(i, q) cin >> e[i];
	
	sort(begin(ary), end(ary));
	const int m = ary.size();
	int pos = 0;

	rep(i, q){
		while(pos < m and ary[pos].first <= e[i]){
			const int idx = ary[pos].second;
			if(block.find(x[idx]) != end(block))
				block.erase(x[idx]);
			else
				block.insert(x[idx]);
			pos++;
		}
		if(block.empty())
			cout << -1 << endl;
		else
			cout << *begin(block) << endl;
	}

	return 0;
}

Measured memory_bytes: 16876
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

import math

k = readint()
a = readints()

flag = 0
if a[-1]!=2:
    flag = 1

b = 2
c = 2
for i in range(k-1,0,-1):
    b = math.ceil(b/a[i-1]) * a[i-1]
    c = ((c+a[i]-1)//a[i-1]) * a[i-1]
    if c == 0:
        flag = 1
        break
    if b>c:
        flag = 1
        break

c = c+a[0]-1

if flag:
    print(-1)
else:
    print(b,c)






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

int main() {
  int n,ans = 0;
  cin >> n;
  vector<int>data(n);
  for(int i = 0;i < n;i++){
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  for(int i = 0;i < n-2;i++){
    for(int j = i+1;j < n-1;j++){
     for(int k = j+1;k < n;k++){
       if(data.at(k) < data.at(i)+data.at(j)) ans++;
       else break;
     }
    }
  }
  cout << ans << endl;
}


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


int main(void){
    int K,X; cin >> K >> X;
    if(K*500 >= X) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#!/usr/bin/python3

import sys

sys.setrecursionlimit(10000)
ans = 0

def dfs(cur, visited, G):
    visited[cur] = True

    if all(visited):
        global ans
        ans += 1

    for c in G[cur]:
        if not visited[c]:
            dfs(c, visited, G)
            visited[c] = False
    return


def main():
    n, m = map(int, input().split())
    G = [[] for _ in range(n) ]

    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1; b -= 1;
        G[a] += [b]
        G[b] += [a]

    v = [ False for _ in range(n) ]

    dfs(0, v, G)
    print(ans)

main()

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<set>
using namespace std;
#pragma warning(disable:4996)
typedef long long ll;
int const Max = 1e6 + 5;
int lst[Max];

int main()
{
	int n;
	cin >> n;
	map<int, int> ma;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &lst[i]);
		ma[lst[i]] += 1;
	}
	sort(lst + 1, lst + n + 1, greater<int>());
	ll sum = lst[1];
	n -= 2;
	ma[lst[1]] -= 1;
	for (auto i = ma.begin(); i != ma.end(); i++) ma[i->first] = 2 * ma[i->first];
	int j = 1;
	while (n > 0)
	{
		if (ma[lst[j]])
		{
			sum += lst[j];
			ma[lst[j]] -= 1;
			n--;
		}
		else
		{
			j++;
		}
	}
	cout << sum << endl;
	return 0;

}

Measured memory_bytes: 13788
#include <iostream>
#include <string>
#include <algorithm>

int Solve(const std::string &s, int status)
{
	int count = 0;

	for (char c : s)
	{
		if (status != (c - '0'))
		{
			count++;
		}

		status ^= 1;
	}

	return count;
}

int main()
{
	using namespace std;

	string s;
	cin >> s;

	cout << min(Solve(s, 0), Solve(s, 1)) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define iter(it,a) for(auto it=a.begin();it!=a.end();it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define endl '\n'
typedef long long ll;

int n,m;
vector<int> edges[100000+1];
int ans[100000+1];
int maxd[100000+1];
pair<int,pair<int,int> > que[100000+1];

void dfs(int x,int d,int c){
	if(d>maxd[x]){
		if(maxd[x]==-1){
			ans[x] = c;
		}
		maxd[x] = d;
	}
	else{
		return;
	}
	if(d==0){
		return;
	}
	iter(it,edges[x]){
		dfs((*it),d-1,c);
	}
}

int main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    cin>>n>>m;
    int a,b;
    rep(i,0,m){
    	cin>>a>>b;
    	edges[a].pb(b);
    	edges[b].pb(a);
    }
    memset(maxd,-1,sizeof(maxd));
    int q; cin>>q;
    int v,d,c;
    rep(i,0,q){
    	cin>>v>>d>>c;
    	que[q-i-1]=mp(v,mp(d,c));
    }
    rep(i,0,q){
    	dfs(que[i].F,que[i].S.F,que[i].S.S);
    }
    rep(i,1,n+1){
    	cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 8440
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>W(N);
  for(int i=0;i<N;i++){
    cin>>W.at(i);
  }
  int ans=1e9;
  for(int i=1;i<N;i++){
    int l=0,k=0;
    for(int j=0;j<i;j++){
      l+=W.at(j);
    }
    for(int j=i;j<N;j++){
      k+=W.at(j);
    }
    ans=min(ans,abs(l-k));
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int h, w, n, a[10010];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> h >> w;
    cin >> n;
    erep(i, 1, n) cin >> a[i];
    int cnt = 1, now = 1;
    erep(i, 1, h) {
        int bf[10010];
        fill(bf, bf+n, 0);
        if (i%2 == 0) {
            eper(j, w, 1) {
                if (a[now] <= 0) {
                    now++;
                    cnt++;
                }
                a[now]--;
                bf[j] = cnt;       
            }
        } else {
            erep(j, 1, w) {
                if (a[now] <= 0) {
                    now++;
                    cnt++;
                }
                a[now]--;
                bf[j] = cnt;
            }
        }
        erep(j, 1, w) {
            cout << bf[j];
            if (j != w) cout << " ";
            else cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int par[100001];
long answer[100001]; 

int root(int c){
  if(par[c] == c) return c;
  else{
    par[c] = root(par[c]);
    root(par[c]);
  }
}

int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  int a[100000];
  int b[100000];
  for(int i=0;i<m;i++){
    scanf("%d %d",&a[i],&b[i]);
  }
  
  long c[100001];
  for(long i=1;i<=n;i++){
    c[i] = (i*(i-1))/2;
    //printf("%d ",c[i]);
  }
  
  int family[100001];
  for(int i=1;i<=n;i++){
    par[i] = i;
    family[i] = 1;
  }
  
  int x,y,fx,fy,fxy;
  answer[m] = c[n];
  for(int i=m-1;i>=1;i--){
    x = root(a[i]);
    y = root(b[i]);
    if(x != y){
      par[y] = x;
      fx = family[x];
      fy = family[y];
      family[x] += family[y];
      fxy = family[x];
      answer[i] = answer[i+1] - (c[fxy] - c[fx] - c[fy]);
    }else{
      answer[i] = answer[i+1];
    }
  }
  for(int i=1;i<=m;i++){
    printf("%ld\n",answer[i]);
  }
  return 0;
}

Measured memory_bytes: 4352
// ~maqsat~
/*    
**	  “Anyone who has never made a mistake has never tried anything new.”
**    © Albert Einstein
*/

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 1e10 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int main() {
    fre("");
    ACCELERATE;

    int n;
    cin >> n;

    set<int> s;
    for(int i = 1; i < n; i++) {
    	if(s.count(n - i)) continue;
    	if(n - i != i) s.in(i);
    }

    cout << sz(s);
    return 0;
}
/*
 
*/


Measured memory_bytes: 23680
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] monsters = new int[n + 1];
        int[] heroes = new int[n];

        for (int i = 0; i < n + 1; i++)
            monsters[i] = sc.nextInt();
        for (int i = 0; i < n; i++)
            heroes[i] = sc.nextInt();

        int rem = 0;
        long totalKilled = 0;
        for (int i = 0; i < n; i++) {
            int killedPrev = Math.min(rem, monsters[i]);
            int killedNow = Math.min(monsters[i] - killedPrev, heroes[i]);

            totalKilled += killedPrev + killedNow;
            rem = Math.max(heroes[i] - killedNow, 0);
        }
        totalKilled += Math.min(rem, monsters[n]);
        System.out.println(totalKilled);
    }
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        String str = scan.next();
        int len = str.length();
        for (int i = 0; i < len; i ++)
            System.out.print("x");
    }
}


Measured memory_bytes: 21844
import sys
input = sys.stdin.readline

A, B, K = map(int, input().split(' '))
th = 0
max_common = min(A, B)
for i in range(1, max_common+1)[::-1]:
    if A % i == 0 and B % i == 0:
        th += 1
        if th == K:
            print(i)
            break

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

typedef long long ll;
typedef unsigned long long ull;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
	cout << a << "\n";
}

int main(int argc, const char * argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    ull a,b,c;
    cin >> a >> b >> c;
    if(c>a+b){
        if(4*a*b < (c-a-b)*(c-a-b) ){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << 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,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
const int INF = 1e9;
const double pi = acos(-1.0);
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;

int main(){
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}  

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

int main(){
    string S;
    cin >> S;
    if(S=="SUN")cout << 7 << endl;
    else if(S=="MON")cout << 6 << endl;
    else if(S=="TUE")cout << 5 << endl;
    else if(S=="WED")cout << 4 << endl;
    else if(S=="THU")cout << 3 << endl;
    else if(S=="FRI")cout << 2 << endl;
    else if(S=="SAT")cout << 1 << endl;
}

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

int main(){
	long x;
	cin >> x;
	long i=0;
	long a=100;
	while(x>a){
		a=a+a*0.01;
		i++;
	}
	cout << i;
	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt(), w = sc.nextInt(), m[][] = new int[h][w], min = Integer.MAX_VALUE;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                m[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int sum = 0;
                for (int k = 0; k < h; k++) {
                    for (int l = 0; l < w; l++) {
                        sum += Math.min(Math.abs(i - k), Math.abs(j - l)) * m[k][l];
                    }
                }
                min = Math.min(min, sum);
            }
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 29392
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)

const int maxn = 100005;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }

char x[maxn];

void solve()
{
	scanf("%s", x + 1);
	int res = strlen(x + 1) + (x[1] == x[strlen(x + 1)]);
	if (res % 2 == 0)
	{
		puts("Second");
	}
	else
	{
		puts("First");
	}
}

int main()
{

	solve();
	return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  
  int a,b,count;
  int arr[N]={0};
  
  for(int i=1;i<=M;i++){
    cin >> a >> b;
    arr[a-1]++;
    arr[b-1]++;
  }
  
  for(int j=0;j<N;j++){
    cout << arr[j] << endl;
  }
}


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

int main() {
  int N, K, sum=0;
  cin >> N >> K;
  int l[N];
  
  for(int i=0; i<N; i++){
    cin >> l[i];
  }
  
  sort(l, l+N);
  reverse(l, l+N);
  
  for(int i=0; i<K; i++){
    sum += l[i];
  }
  
  cout << sum << endl;
    
  return 0;
}

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

using ll = long long;
#define int long long
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(obj) sort((obj).begin(), (obj).end())
#define ALL(obj) (obj).begin(), (obj).end()
/***** MAIN *****/
signed main() {
    int n;
    cin >> n;
    vector<int> top(n), mid(n), bott(n);
    REP(i,n) cin >> top[i]; REP(i,n) cin >> mid[i]; REP(i,n) cin >> bott[i];
    SORT(top); SORT(bott);
    ll ans = 0;
    REP(i,n) {
        int top_count = lower_bound(ALL(top), mid[i]) - top.begin();
        int bott_count = bott.end() - upper_bound(ALL(bott), mid[i]);
        ans += top_count * bott_count;
    }
    cout << ans;
    cout << "\n";
    return 0;
}
/***** MAIN *****/


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int j;
  double S;
  double ans = 0;
  for (int i = 1; i <= N; i++) {
    j = i;
    S = 1.0/N;
    while (j < K) {
      j = 2*j;
      S = S/2;
    }
    ans += S;
  }
  
  printf("%.12f\n",ans);
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int ans = (N - 1) / (K - 1);
  if ((N - 1) % (K - 1) != 0) ans++;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define Q 1000000007

// ll white, black;
// vector<vector<char>> c(h, vector<char>(w));
// ll ans = 0;
// vector<ll> a(N);
// const int M = 2;
// void dfs(vector<int> &A) {
//     // 終端条件 --- 10 重ループまで回したら処理して打ち切り
    

//     if(A.size() == h+w){
//       // rep(i, A.size()) cout << A[i];
//       // cout << " ";
//       vector<vector<char>> tmp(h, vector<char>(w));
//       rep(i, h){
//         rep(j, w) tmp[i][j] = c[i][j];
//       }
//       ll cnt = black;
//       for(ll i = 0; i < h; i++){
//         if(A[i] == 1){
//           // cout << i << " ";
//           rep(j, w){
//             if(tmp[i][j] == '#'){
//               tmp[i][j] = 'r';
//               cnt--;
//             }
//           }
//         }
//       }
//       for(ll i = h; i < h+w; i++){
//         if(A[i] == 1){
//           // cout << i << " ";
//           rep(j, h){
//             if(tmp[j][i-h] == '#'){
//               tmp[j][i-h] = 'r';
//               cnt--;
//             }
//           }
//         }
//       }

//       // cout << cnt << endl;
//       if(cnt == k) ans++;
      
//       return;
//     }

//     for (int v = 0; v < M; ++v) {
//         A.push_back(v);
//         dfs(A);
//         A.pop_back(); // これが結構ポイント
//     }
// }

int main(){
  
  ll x;
  cin >> x;

  if(x < 30) cout << "No" << endl;
  else cout << "Yes" << endl;



  return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    string s;
    string left = "qwertasdfgzxcvbb";
    while (cin >> s, s != "#") {
        int cnt = 0;
        bool l = left.find(s[0]) != string::npos;
        FOR(i, 1, s.length()) {
            if (left.find(s[i]) != string::npos) {
                if (!l) {
                    l = !l;
                    cnt++;
                }
            } else {
                if (l) {
                    l = !l;
                    cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1192
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long int;
const ll INF = 1E+12;

vector<ll> A, B, S, T;
int main(){
    int n, m;
    cin >> n >> m;
    A.resize(n+1);
    B.resize(m+1);
    int k;
    cin >> k;
    S.resize(n+1);
    T.resize(m+2);
    S[0] = T[0] = 0;
    for(int i = 1; i <= n; i++){
        cin >> A[i];
        S[i] = S[i-1] + A[i];
    }
    for(int i = 1; i <= m; i++){
        cin >> B[i];
        T[i] = T[i-1] + B[i];
    }
    T[m+1] = T[m] + INF;
    int ans = 0;
    for(int i = 0; i <= n; i++){
        int nk = k - S[i];
        if (nk < 0)break;
        int nans = upper_bound(T.begin(), T.end(), nk) - T.begin();
        nans += i;
        nans--;
        ans = max(ans, nans);
    }
    cout << ans << endl;
    return 0;
}

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

const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;

string s;
bool used[26];

int main(){

cin >> s;

if(s == "zyxwvutsrqponmlkjihgfedcba"){
    cout << -1;
    return 0;
}

if(s.size() < 26){
    for(int i=0; i<s.size(); i++){
        used[(int)(s[i] - 'a')] = true;
    }
    for(int i=0; i<26; i++){
        if(!used[i]){
            cout<<s + (char)('a' + i);
            return 0;
        }
    }
} else {
    used[(int)(s[25] - 'a')] = true;
    for(int i=s.size() - 2; i>=0; i--){
        int n = (int)(s[i] - 'a');
        for(int j=n+1; j<26; j++){
            if(used[j]){
                cout << s.substr(0, i) + (char)('a' + j);
                return 0;
            }
        }
        used[n] = true;
    }
}

return 0;

}















Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int h,w;
    cin>>h>>w;
    vector<string> x(h);
    forn(i,h)   cin>>x[i];

    for(int i=0;i<=h+1;i++){
        for(int j=0;j<=w+1;j++){
            if(i==0||i==h+1)  cout<<'#';
            else{
                if(j==0||j==w+1)  cout<<'#';
                else            cout<<x[i-1][j-1];
            }
        }
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 256
N,X = map(int, input().split())

burger_list = []
for i in range(N+1):
    if i == 0:
        burger_list.append([0,1])
    else:
        burger_list.append([2+burger_list[-1][0]*2,1+burger_list[-1][1]*2])

def pty(x,k,List):
    if x == 1:
        y = 0
    elif 1 < x <= sum(List[k-1])+1:
        y = 1
    elif x == 2+sum(List[k-1]):
        y = 2
    elif x == sum(List[k]):
        y = 4
    elif 2+sum(List[k-1]) < x <= 2+sum(List[k-1])*2:
        y = 3
    return y
        
ans = 0
k = N
while X > 0:
    n = pty(X,k,burger_list)
    if n == 0:
        if k == 0:
            ans += 1
        X = 0
    elif n == 2:
        ans += (burger_list[k-1][1]+1)
        X = 0
    elif n == 4:
        ans += burger_list[k][1]
        X = 0
    elif n == 1:
        X -= 1
        k -= 1
    elif n == 3:
        ans += (burger_list[k-1][1]+1)
        X -= (sum(burger_list[k-1])+2)
        k -= 1
print(ans)

Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import qualified Data.IntMap as M

pr = 2:3:1 # pr
m#(a:b:x)=[n|n<-[a^2..b^2-2],odd n,gcd n m<2]++(m*b)#(b:x)

fac _ m 1 = m
fac pa@(p:pr) m n
    | n`mod`p == 0 = fac pa (M.insertWith(+)p 1 m) (n`div`p)
    | True         = fac pr m n

main=do
    n<-readLn::IO Int
    print.foldl (\a n->(a*(n+1))`mod`1000000007) 1.M.elems $ foldl (fac pr) M.empty [2..n]


Measured memory_bytes: 1148
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] lucas = new long[n+1];
        lucas[0] = 2; lucas[1] = 1;
        for(int i = 2; i <= n; i++) lucas[i] = lucas[i-1] + lucas[i-2];
        System.out.println(lucas[n]);
    }
}

Measured memory_bytes: 23124