akhauriyash/Code-Regression huggingface dataset:
import math


def main():
    X = int(input())

    MAX = 10 ** 9

    for b in range(0, MAX + 1):
        # b = 1,2,3...
        a = math.pow(abs(b ** 5 + X), 1 / 5)
        # print(f'b={b} a={a}')
        # print(f'b={b} a={a}')
        if round(a) ** 5 == abs(b ** 5 + X):
            if b ** 5 + X > 0:
                print(int(a), b)
                return
            else:
                print(-int(a), b)
                return

        # b = -1, -2, -3
        a = math.pow(abs(- b ** 5 + X), 1 / 5)
        # print(f'b={-b} a={a}')
        if round(a) ** 5 == abs(- b ** 5 + X):
            if - b ** 5 + X > 0:
                print(int(a), -b)
                return
            else:
                print(-int(a), -b)
                return

    raise ValueError()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9500
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#define MP make_pair
#define F first
#define S second
using namespace std;
typedef long long ll;
ll n;
ll a[1000010], s[1000010];

ll fans = 2e10;

int main () {
	cin >> n;
	for (int i = 1; i <= n; i ++)
		cin >> a[i], s[i] = s[i - 1] + a[i];
	for (int i = 1; i < n; i ++) {
		ll l = s[i], r = s[n] - l;
		fans = min (fans, abs(l - r));
	}
	cout << fans << endl;
	return 0;
}

Measured memory_bytes: 5888
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

const ll MAX_V = 201;
ll vn = MAX_V;
vvll G(MAX_V);
vll match(MAX_V);
V<bool> used(MAX_V, false);

void add_edge(ll u, ll v) {
    G[u].push_back(v);
    G[v].push_back(u);
}

bool dfs(ll v) {
    used[v] = true;
    for (auto u: G[v]) {
        ll w = match[u];
        if (w<0 || (!used[w] && dfs(w))) {
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

ll bipartite_matching() {
    ll res = 0;
    REP(i, MAX_V) match[i] = -1;
    REP(v, vn) {
        if (match[v] < 0) {
            REP(i, MAX_V) used[i] = false;
            if (dfs(v)) res++;
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll a(n), b(n), c(n), d(n);
    REP(i, n) cin >> a[i] >> b[i];
    REP(i, n) cin >> c[i] >> d[i];
    REP(i, n) {
        REP(j, n) {
            if (a[i] < c[j] && b[i] < d[j]) {
                add_edge(i, 100+j);
            }
        }
    }
    cout << bipartite_matching() << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main() {
    ll n,m;
    cin >> n >> m;
    vector<ll> x(n);
    for (ll i=0;i<n;++i){
        x[i]=0;
    }
    for (ll i=0;i<m;++i){
        ll a,b;
        cin >> a >> b;
        x[a-1]+=1;
        x[b-1]+=1;
    }
    for (ll i=0;i<n;++i){
        cout << x[i] << endl;
    }
    return 0;
}


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

int main(){

    string S;
    cin >> S;

    for(int i=0;i<S.length()-1;i++){
        if(S[i]==S[i+1]){
            cout << "Bad" <<endl;
            return 0;
        }
    }

    cout << "Good" <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
 #define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define   ipr         	pair<int, int>
#define   pb            push_back
#define   ff            first
#define   ss            second
#define fill(a,b) memset(a, b, sizeof(a))
#define   fr(i, j, k)   for (int i = j; i < k; i++)
#define   rf(i, j, k)   for (int i = j; i >= k;i--)
#define   int           long long int
#define   ll 			unsigned long long
#define   ld            long double
#define   all(x)        x.begin(), x.end()
#define   rall(x)       x.rbegin(),x.rend()
#define   mp            make_pair
#define L(x) ('a'<=x && x<='z')
#define   inf           INT_MAX
#define   read_file();	freopen("input.txt", "r", stdin);	freopen("output.txt", "w", stdout);
#define   IOS           std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 
const ld  pi   =  acos(-1);
const int mod =  1000000007;
const double epsilon = 1e-9; 
 
 
template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template<class T> ostream& operator <<(ostream &out,set<T> &A){for(auto x:A) out<<x<<" ";return out;}
template<class T> ostream& operator <<(ostream &out,unordered_set<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}
 
int binpow(int a,int b) {
    a=a%mod;
   
    int res = 1;
while (b > 0) {
        if (b & 1)res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
}
return (res+mod)%mod;
}
 



 
 int32_t main(){
    IOS;
 
     int t;
     //cin>>t;
   
     t=1;
   while(t--){
 
   
 int k;
   cin>>k;
   while(k--)cout<<"ACL";

   cout<<"\n";
 }
 }

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

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

const int INF=100000000;

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

ll lcm(ll a, ll b){
	ll g=gcd(a,b);
	return a/g*b;
}

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

	ll ans=1LL;
	for (int i = 0; i < n; ++i){
		ll t;
		cin>>t;
		ans=lcm(ans,t);
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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 long long INF = 1LL<<60;

int main(){
    int n;cin >> n;
    vector<int> x(n);
    int sum =0;
    for(auto &i:x) {cin >> i;sum+=i;}
    
    sort(x.begin(),x.end());
    int l = x[0],r = x[n-1];
    Int ans = INF;
    for(int i=l;i<=r;i++){
        Int sum = 0;
        for(auto &xi:x){
            sum+=(xi-i)*(xi-i);
        }
        chmin(ans,sum);
    }
    cout << ans << endl;
    return 0; 

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert//also use as v.is(v's it,w's it,w's it);
#define ps push//TMP//stack,(priority) queue,
#define fr front//TMP//queue//for priority, use top().
typedef long long ll;//not necessarily
typedef pair<int,int> pii;
//Add other types in the same way.
const ll M=1000000007;//can be changed
int mod(int a){	return (a+M)%M;	}//M can be a variable
void plmod(ll &a,ll b){	a=(a+b+M)%M;	return;	}
void mnmod(ll &a,ll b){	a=(a-b+M)%M;	return;	}
void mlmod(ll &a,ll b){	a=(a*b)%M;  	return;	}
//Caution! you may need sth larger than "+M"!
void chmax(int &a,int b){	a=max(a,b);	return;	}
void chmin(int &a,int b){	a=min(a,b);	return;	}
//These 2 could be better in long long

int main(){
	string s,t;
	cin>>s;
	if(	s=="KIHABARA"
		||s=="KIHABRA"
		||s=="KIHBARA"
		||s=="KIHBRA"
		||s=="AKIHABARA"
		||s=="AKIHABRA"
		||s=="AKIHBARA"
		||s=="AKIHBRA"
		||s=="KIHABAR"
		||s=="KIHABR"
		||s=="KIHBAR"
		||s=="KIHBR"
		||s=="AKIHABAR"
		||s=="AKIHABR"
		||s=="AKIHBAR"
		||s=="AKIHBR") cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main(){
    int n;
    int j=0;
    cin >> n;
    for(int i=1;i<10;i++){
        if(n % i == 0){
            if(n < 10*i) {
                cout << "Yes" <<endl;
                j = 1;
                break;
            }
        }
    }
    if(j != 1) cout <<"No" << endl;
}



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

using namespace std;

int main(void){
    string s;
    int ans = 0;

    cin >> s;

    for(int i=0; i<s.length()/2; i++){
        if(s[i] != s[s.length()-i-1])
            ans++;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.List;

public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    String input = sc.nextLine();
		String[] array = input.split(" ");
		List<String> list = Arrays.asList(array);
	    System.out.println(list.indexOf("0") + 1);
	}
}


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

int main(){
  long long ans=0;
  int n;
  cin >> n;
  
  long long l[86] ;
  l[0] = 2;
  l[1] = 1;
  
  for(int i=0;i<n+1;i++){
    if(i==0)continue;
    if(i==1)continue;
    
    ans = l[i-1]+l[i-2];
    l[i] = ans;
  }
  
  cout << l[n] << endl;
  return 0;
}


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

#define INF INT_MAX/2
struct Maxflow {
	struct edge { int to, cap, rev; edge(int t, int c, int r) { to = t; cap = c; rev = r; } };
	int V;
	vector<vector<edge>> G;
	vector<int> itr, level;

	Maxflow(int V) : V(V) { G.assign(V, vector<edge>()); }

	void add_edge(int from, int to, int cap) {
		G[from].push_back(edge(to, cap, (int)G[to].size()));
		G[to].push_back(edge(from, 0, (int)G[from].size() - 1));
	}

	void bfs(int s) {
		level.assign(V, -1);
		queue<int> q;
		level[s] = 0; q.push(s);
		while (!q.empty()) {
			int v = q.front(); q.pop();
			for (auto &e : G[v]) {
				if (e.cap > 0 and level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}

	int dfs(int v, int t, int f) {
		if (v == t) return f;
		for (int& i = itr[v]; i < (int)G[v].size(); ++i) {
			edge& e = G[v][i];
			if (e.cap > 0 and level[v] < level[e.to]) {
				int d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	int run(int s, int t) {
		int ret = 0, f;
		while (bfs(s), level[t] >= 0) {
			itr.assign(V, 0);
			while ((f = dfs(s, t, INF)) > 0) ret += f;
		}
		return ret;
	}
};

typedef complex<double> P;
const double EPS = 1e-10;






int N, M;
P TP[100];
double TV[100];
P BP[100];

bool check(double t)
{
	Maxflow mf(1 + N + M + 1);
	rep(i, 0, N) mf.add_edge(0, i + 1, 1);
	rep(i, 0, N) rep(j, 0, M)
	{
		P vec = TP[i] - BP[j];
		double tt = abs(vec) / TV[i];
		if (tt <= t + EPS) mf.add_edge(i + 1, 1 + N + j, 1);
	}
	rep(i, 0, M) mf.add_edge(1 + N + i, 1 + N + M, 1);

	if (mf.run(0, 1 + N + M) == M)
		return true;
	else
		return false;
}

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

	while (cin >> N >> M)
	{
		if (N == 0) return 0;

		rep(i, 0, N)
		{
			double x, y; cin >> x >> y >> TV[i];
			TP[i] = P(x, y);
		}
		rep(i, 0, M)
		{
			double x, y; cin >> x >> y;
			BP[i] = P(x, y);
		}

		double l = 0, r = 1e12;
		rep(i, 0, 100)
		{
			double m = (l + r) / 2.0;
			if (check(m))
				r = m;
			else
				l = m;
		}
		printf("%.10f\n", r);
	}
}

Measured memory_bytes: 3428
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <string>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(std::min<int>(l_, r_)), r(r_) {}
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): r(std::max<int>(l_, r_) - 1), l(l_ - 1) {}
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

int main() {
  std::string S, T, U;
  int A, B;
  std::cin >> S >> T >> A >> B >> U;
  if (S == U) --A;
  else --B;
  std::cout << A << ' ' << B << '\n';
  return 0;
}


Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

r = inputs[0][0]
g = inputs[0][1]
b = inputs[0][2]
nn = inputs[0][3]

# body
if $debugFlag
  p r
  p g
  p b
  p nn
end

arr = [r, g, b].sort
x = arr[2]
y = arr[1]
z = arr[0]

cnt = 0
for i in 0..nn/x do
  for j in 0..nn/y do
    cnt += 1 if (nn - i*x - j*y)%z == 0 and (nn - i*x - j*y) >= 0
    # if (nn - i*x - j*y)%z == 0
    #   p "(#{i}, #{j}, #{(nn-i*x-j*y)/z})"
    # end
  end
end

puts cnt


Measured memory_bytes: 1788
n,q = map(int,input().split())
s = input()

t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == 'AC' else 0)

#print (t)

for _ in range(q):
    l,r = map(int,input().split())
    print (t[r-1]-t[l-1])


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

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

  double a;
  double sum = 0;
  for (int i=0; i<N; ++i) {
    cin >> a;
    sum += 1 / a;
  }

  cout << fixed << setprecision(14) << 1 / sum << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
bool m_panduan(int x){
    for(int i=2;i*i<=x;i++)
        if(x%i==0)
            return false;
    return true;
}
int main(){
    int n;
    scanf("%d",&n);
    printf("2");
    for(int i=11,j=2;j<=n;i+=10){
        if(m_panduan(i)){
            printf(" %d",i);
            j++;
        }
    }
    printf("\n");
    return 0;
}


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

int main() {
	string s,f,b,x;
	cin>>s;
	for(int i=0;i<8;i++){
		f=s.substr(0,i-0);
		b=s.substr(f.size()+(s.size()-7),s.size()-(s.size()-7+f.size()));
		x=f+b;
		//cout<<f<<" "<<b<<endl;
		if(x=="keyence"){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
}

Measured memory_bytes: 256
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
int a[100100];
int sum[100100];
int N, M;
signed main() {
  cin>>N>>M;
  for (int i = 0; i < M; i++) a[i]=0;
  for (int i = 0; i < N+1; i++) sum[i]=0;

  for (int i = 0; i < M; i++) {
    int L, R; cin>>L>>R;
    L--;
    a[L]++;
    a[R]--;
  }
  
  for (int i = 0; i < N; i++) {
    sum[i+1] = sum[i] + a[i];
  }
  
  int ans = 0;
  for (int i = 0; i < N+1; i++) {
    if (sum[i] >= M) ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 1792
////////////////////////////////////
///     Please Give Me AC!!!     ///
////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

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

int main(){
    int N; cin>> N;
    vector<int> h (N);
    forin(h);

    vector<int> dp(N, 1e9);
    dp[0] = 0;

    for(int i = 1; i < N; i++){
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if(i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout<< dp[N - 1] << endl;
}

Measured memory_bytes: 4004
import Control.Monad
import Control.Applicative
import Data.List
import Data.List.Split

main = do
  xs <- input ( toTpl . splitOn "," )
  putStrLn $ solve xs

solve :: [(String,String)] -> String
solve xs = foldl exchange "A" xs

exchange :: String -> (String, String) -> String
exchange s (x, y)
  | s == x = y
  | s == y = x
  | otherwise = s

input :: (String -> a) -> IO [a]
input f = map f . lines <$> getContents 

toTpl :: [String] -> (String,String)
toTpl [x,y] = (x,y)

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ara[300005];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i=1; i<=3*n; i++)scanf("%d", &ara[i]);
    sort(ara+1, ara+1+3*n);
    ll res= 0;
    for(int i=3*n -1, j=0; j<n; i-= 2, j++)res+= ara[i];
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 2560
#include <vector>
#include <algorithm>
#include <iostream>
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(void){
    int N;
    cin >> N;
    ll buf;
    vector<ll> A;
    REP(i,N){cin >> buf; A.push_back(buf);}
    sort(A.begin(),A.end());
    int check_count = 1, sum = 0; ll check = A[0];
    for(int i=1;i<N;i++){
        if(check==A[i]){
            check_count ^= 1;
        }
        else{
            sum += check_count;
            check = A[i];
            check_count = 1;
        }
    }
    sum += check_count;
    cout << sum << endl;
}

Measured memory_bytes: 1400
N=int(input())
h=list(map(int,input().split()))
h.insert(0,0)
c=[0]*(N+1)
c[2]=abs(h[1]-h[2])
for i in range(3,N+1):
    c[i]=min((abs(h[i]-h[i-1])+c[i-1]),(abs(h[i]-h[i-2])+c[i-2]))
print(c[N])

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

int main(){
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    int x[N], y[M];
    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    for(int i = 0; i < M ; i++){
        cin >> y[i];
    }
    sort(x, x + N);
    sort(y, y + M);
    for(int Z = x[N-1] + 1; Z <= y[0]; Z++){
        if(X < Z && Z <= Y) {
            cout << "No ";
            break;
        }
    }
    cout << "War\n";
    return 0;
}

Measured memory_bytes: 384
n = int(input())
d = [[int(i) for i in input().split()] for i in range(n)]
status = (0,0,0)
result = "Yes"
for i in d:
    dist = abs((i[1]+i[2]) - (status[1]+status[2]))
    time = i[0] - status[0]
    if (time >= dist) and (time - dist) % 2 == 0:
        status = i
    else:
        result = "No"
        break
print(result)

Measured memory_bytes: 21156
import std.stdio;                                                                                      
                                                                                                       void main() {                                                                                              int a, b;                                                                                          
    readf("%d %d\n", &a, &b);                                                                                  
    write(a - 1 + (b >= a ? 1 : 0));                                                                   
}


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

using namespace std;

int main() {
    int n, h;
    cin >> n >> h;
    vector<int> b(n);
    int maxA = -1;

    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a >> b[i];
        maxA = max(a, maxA);
    }
    sort(b.begin(), b.end(), greater<int>());

    int sum = 0;
    int count = 0;
    for (int i = 0; i < n; ++i) {
        if (b[i] < maxA)break;
        sum += b[i];
        count++;
        if (sum >= h) {
            cout << count << endl;
            return 0;
        }
    }
    int nokori = h - sum;

    if (nokori % maxA != 0)count++;
    count += nokori / maxA;
    cout << count << endl;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(20)

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 998244353;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, K, A[200000]; cin >> N >> K;
  int sum[200010] = {};
  REP(i, N){
    cin >> A[i]; A[i]--;
    sum[i+1] = A[i];
  }
  umap<int, INTV> mp;
  REP(i, N){
    sum[i+1] += sum[i];
    sum[i+1] %= K;
  }
  REP(i, N+1){
    cerr << sum[i] << endl;
    mp[sum[i]].eb(i);
  }
  int ans = 0;
  umap<int, int> C;
  queue<int> que;
  RREP(i, N+1){
    C[sum[i]]++;
    que.push(sum[i]);
    cerr << i << " : " << C[sum[i]]-1 << endl;
    ans += C[sum[i]]-1;
    if(que.size() == K){
      int x = que.front(); que.pop();
      C[x]--;
    }
  }
  /*
  REP(i, N+1){
    int num = sum[i];
    INTV vec = mp[num];
    int cnt = lower_bound(ALL(vec), i+K) - lower_bound(ALL(vec), i);
    if(*lower_bound(ALL(vec), i+K) - i >= K) cnt--;
    cerr << " : " << cnt << endl;
    ans += cnt;
  }
  */
  cout << ans << endl;
}


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


int main(void)
{
	//入力変数
	int h_input[11] = {0};

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

	//出力
	cout << h_input[10] << endl;

	return 0;
}

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

using namespace std;

int main(){
    string S; cin >> S; string T = S;
    sort(S.begin(), S.end());
    sort(T.begin(), T.end());
    T.erase(unique(T.begin(), T.end()), T.end());

    if (S == T) cout << "yes" << endl;
    else        cout << "no"  << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;


int main(void)
{
    string S;
    cin >> S;

    string erasables[] = {"dream", "dreamer", "erase", "eraser"};
    while (S.length() > 0) {
        int i;
        for (i = 0; i < 4; i++) {
            if (S.length() >= erasables[i].length() &&
                    S.substr(S.length() - erasables[i].length()) == erasables[i])
                break;
        }
        if (i != 4) {
            S = S.substr(0, S.length() - erasables[i].length());
        } else
            break;
    }
    if (S.length() == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long
int main(){
    set<string> s;
    int n;
    string t;
    cin >> n;
    for (int i=0; i<n; i++){
    	cin >> t;
    	s.insert(t);
    }
    cout << s.size();
    return 0;
}







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

template <typename T>
vector<T> dijkstra(const vector<vector<pair<int, T>>> &G, int source) {
    const T INF = numeric_limits<T>::max();
    using P = pair<T, int>;

    vector<T> dist(G.size(), INF);
    dist[source] = 0;

    priority_queue<P, vector<P>, greater<P>> que;
    que.emplace(0, source);

    while(!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if(dist[v] < p.first) continue;

        for(auto edge : G[v]) {
            if(dist[edge.first] > dist[v] + edge.second) {
                dist[edge.first] = dist[v] + edge.second;
                que.emplace(dist[edge.first], edge.first);
            }
        }
    }

    return dist;
}

int node(int i, int j) {
    return i * 2500 + j;
}

int main() {
    int N, M; long long S;
    cin >> N >> M >> S;
    S = min(S, 2499LL);
    
    vector<vector<pair<int, long long>>> G(N * 2500);
    for(int i=0; i<M; ++i) {
        int u,v,a; long long b;
        cin >> u >> v >> a >> b;
        --u; --v;
        for(int j=a; j<2500; ++j) {
            G[node(u, j)].emplace_back(node(v, j - a), b);
            G[node(v, j)].emplace_back(node(u, j - a), b);
        }
    }

    for(int i=0; i<N; ++i) {
        long long c, d; cin >> c >> d;
        for(int j=0; j + c < 2500; ++j) {
            G[node(i, j)].emplace_back(node(i, j + c), d);
        }
    }

    auto dist = dijkstra(G, S);
    for(int i=1; i<N; ++i) {
        cout << *min_element(begin(dist) + node(i, 0), begin(dist) + node(i + 1, 0)) << '\n';
    }
}

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

int main() {
  int N, K = 0;
  string S;

  cin >> N >> S >> K;

  char str1 = S[K-1];

  int count = 0;
  string outS;

  for (int i = 0; i < N; i++) {
	if(S[i] == str1) {
		outS = outS + str1;
	} else {
		outS = outS + '*';
	}
  }

  cout << outS << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef pair<int,int> P;
vector<int> G[220];

const int MOD=1000000007;

int d[220][220];
int color[220];
int n;

bool nibu(int v,int c)
{
	color[v]=c;
	for(int i=0;i<G[v].size();i++)
	{
		int w=G[v][i];
		if(color[v]==color[w])return false;
		else if(color[w]==0 && !nibu(w,-c))return false;
	}
	return true;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		for(int j=0;j<n;j++)	
		{
			if(s[j]=='0' && i!=j)d[i][j]=MOD;
			else if(s[j]=='1')d[i][j]=1;
			else d[i][j]=0;
			if(d[i][j]==1)
			{
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	
	if(!nibu(0,1)){cout<<-1<<"\n";return 0;}
	
	int diam=0;
	for(int k=0;k<n;k++)
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)diam=max(diam,d[i][j]);
	cout<<diam+1<<"\n";	
	return 0;
}

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

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        n: usize,
        a: i64,
        b: i64,
        c: i64,
        ll: [i64; n]
    }
    let rule = Rule {
        n: n,
        a: a,
        b: b,
        c: c,
        ll: ll
    };
    let result = dfs(&rule, 0, 0, 0, 0).unwrap();
    println!("{}", result - 30);
}

struct Rule {
    n: usize,
    a: i64,
    b: i64,
    c: i64,
    ll: Vec<i64>
}

fn dfs(rule: &Rule, cur: usize, a: i64, b: i64, c: i64) -> Option<i64> {
    if cur == rule.n {
        if vec![a, b, c].into_iter().min().unwrap() == 0 {
            return None;
        }
        let ad = (a - rule.a).abs();
        let bd = (b - rule.b).abs();
        let cd = (c - rule.c).abs();
        return Some(ad + bd + cd);
    }
    vec![
        dfs(rule, cur + 1, a, b, c),
        dfs(rule, cur + 1, a + rule.ll[cur], b, c).map(|v| v + 10),
        dfs(rule, cur + 1, a, b + rule.ll[cur], c).map(|v| v + 10),
        dfs(rule, cur + 1, a, b, c + rule.ll[cur]).map(|v| v + 10),
    ].into_iter()
        .filter_map(|v| v).min()
}


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

typedef long long ll;
int main(){
	ll b,c1,c2,q1,q2,aizu,ord;
	bool flag;

	while(cin>>q1,q1){
		flag=false;
		cin>>b>>c1>>c2>>q2;
		if(b/c1>q2){
			aizu=q2;
			ord=(b-c1*q2)/c2;
		}else{
			aizu=b/c1;
			ord=(b%c1)/c2;
		}
		//cout<<aizu<<" "<<ord<<endl;
		if(aizu==0){cout<<"NA"<<endl;}
		else if((aizu+ord)<q1){
			for(ll i=aizu-1;i>0;i--){
				if((b-c1*i)/c2>=q1-i){
					flag=true;
					cout<<i<<" "<<(b-c1*i)/c2<<endl;
					break;
				}
			}
			if(!flag){
				cout<<"NA"<<endl;
			}
		}else{
			cout<<aizu<<" "<<ord<<endl;
		}
	}
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	int w[n];
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> w[i];
		sum += w[i];
	}

	int min = 1e3;
	int w_s = 0;
	for (int i = 0; i < n; i++) {
		w_s += w[i];
		if (abs(sum - w_s*2) < min) {
			min = abs(sum - w_s*2);
		}
	}

	cout << min << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 500010;
const int MOD = (ll)1e9 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

typedef pair<int, int>P;

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


typedef pair<string, string>P2;
int N;
string res = "";
vector<string>bits;
void dfs(int n,string res) {
	if (n == N) {
		bits.pb(res);
		return;
	}
	dfs(n + 1, res + '1');
	dfs(n + 1, res + '0');
}
map<P2,int>mp,mp2;
signed main() {
	string s;
	cin >> N >> s;
	string S = s.substr(0, N);
	string T = s.substr(N, N);
	//print(S); print(T);
	dfs(0,res);
	for (auto str: bits) {
		//print(str);
		string red="", blue="";
		REP(i, N) {
			if (str[i] == '0')red += S[i];
			else blue += S[i];
		}
		VREVERSE(blue);
		//pe(red); print(blue);
		mp[make_pair(red, blue)]++;
	}
	for (auto str : bits) {
		string red="", blue="";
		REP(i, N) {
			if (str[i] == '0')red += T[i];
			else blue += T[i];
		}
		VREVERSE(blue);
		mp2[make_pair(blue, red)]++;
	}
	int ans = 0;
	for (auto x : mp) {
		//pe(x.first.first); print(x.first.second);
		ans += x.second*mp2[x.first];
	}
	print(ans);
}	


Measured memory_bytes: 121840
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>

#define mod 1000000007
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;

int X[] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Y[] = {1, 1, 1, 0, -1, -1, -1, 0};

void solve() {
    int n, k, res = 0;
    cin >> n >> k;
    int l[n];
    REP(i, n) cin >> l[i];

    sort(l, l+n);
    reverse(l, l+n);
    REP(i, k) res += l[i];
    cout << res << endl;
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
def card_game(pairs):
    points = [0, 0]
    for pair in pairs:
        if (pair[0] > pair[1]):
            points[0] += 3
        elif (pair[0] < pair[1]):
            points[1] += 3
        else:
            points[0] += 1
            points[1] += 1

    return points

if __name__ == '__main__':
    n = int(input())
    pairs = []
    for _ in range(n):
        pairs.append(input().split())

    points = card_game(pairs)
    print(' '.join(map(str, points)))



Measured memory_bytes: 5720
using System;

class Atcoder39
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);

        if (a + b == c || b + c == a || c + a == b)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}

Measured memory_bytes: 11092
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())

ans = 1

for i in range(2, N):
    c = 2
    if i ** c <= N:
        while (i ** c) <= N:
            c += 1
    else:
        continue
    ans = max(ans, i ** (c - 1))

print(ans)

Measured memory_bytes: 3316
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	
	if a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0 {
		fmt.Println("Possible")
	} else {
		fmt.Println("Impossible")
	}
}

Measured memory_bytes: 512
#include <stdio.h>

int hikyori(int dist)
{
  int A,B;
  int i;
  scanf("%d %d",&A,&B);

  if(1 <= dist && dist<= 1000)
  {
    if( 1 <= A && A <= B && B<= 1000)
    {
      for(i = A; i<=B;i++)
      {
        if( i % dist == 0)
        {
          printf("OK\n");
          return 0;
        }
      }
    }
  }
  printf("NG\n");
  return 0;
}

int main(void)
{
  int K;
  
  scanf("%d",&K);
  hikyori(K);
  return 0;
}

Measured memory_bytes: 1620
N, M = list(map(int, input().split()))
L = [0] * M
R = [0] * M
for i in range(M):
  L[i], R[i] = list(map(int, input().split()))
result = min(R) - max(L) + 1
if result > 0:
  print(result)
else:
  print('0')

Measured memory_bytes: 10996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  int ans=1;
  int memo; cin>>memo;
  rep(i,1,N){
    int X; cin>>X;
    if(memo>=X)
      ans++;
    memo=min(memo,X);
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	// 1 => 0
	// 2 => 1
	// 3 => 2+1 = 3
	// 4 => 3+2+1 = 6
	// 5 => 4+3+2+1 = 10
	N := nextInt()
	s := make([]string, N)
	for i := 0; i < N; i++ {
		si := next()
		chars := strings.Split(si, "")
		sort.Strings(chars)
		s[i] = strings.Join(chars, "")
	}
	sort.Strings(s)
	var ans uint64 = 0
	var rep uint64 = 0
	before := ""
	for i := 0; i < N; i++ {
		if before != s[i] {
			rep = 0
			before = s[i]
		} else {
			rep++
			ans += rep
		}
	}
	fmt.Fprintln(out, ans)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// Genericsがないので筋肉で...
// interfaceでの取扱がようわからんし
func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// mapからkeysとvaluesを返す感じのやつ
// なんかしらんけどmap[interface{}]interface{}しか受け付けない。なんのためのinterface{}やねん
// なので呼ぶときのmapはmap[int]stringとかじゃダメ
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
	return
}


Measured memory_bytes: 6528
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535;
#define MOD 1000000007;


vint a, b, c;
ll up(ll x) {
	ll l = 0, r = a.size()-1;
	while (r-l>1) {
		ll m = (l + r) / 2;
		if (x>a[m]) {
			l = m;
		}
		else {
			r = m;
		}
	}
	return l;
}

ll down(ll x) {
	ll l = 0, r = c.size()-1;
	while (r - l > 1) {
		ll m = (l + r) / 2;
		if (x>=c[m]) {
			l = m;
		}
		else {
			r = m;
		}
	}
	return l;
}

int main(void) {
	ll n;
	cin >> n;
	ll cnt=0;
	a.resize(n+2);
	b.resize(n+2);
	c.resize(n+2);
	a[0] = b[0] = c[0] = -1;
	a[n+1] = b[n + 1] = c[n + 1] = 2000000000;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> c[i];
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	for (int i = 1; i <= n; i++) {
		cnt+=up(b[i])*(n-down(b[i]));
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 2560
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
if m == 1:
    print(1, 2)
else:
    l1 = 1
    r1 = l1 + m
    l2 = r1 + 1
    r2 = l2 + m - 1
    while True:
        if l1 >= r1:
            break
        print(l1, r1)
        if l2 >= r2:
            break
        print(l2, r2)
        l1 += 1
        l2 += 1
        r1 -= 1
        r2 -= 1







Measured memory_bytes: 79368
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int a;
	int b;
	int c;
	
	scanf("%d", &n);
	
	a = 0;
	b = 1;
	
	while(n != 0){
		c = n;
		for(i = 0; c % 2 == 0; i++){
			c = c / 2;
		}
		if(a < i){
			a = i;
			b = n;
		}
		n--;
	}
	printf("%d\n", b);
	return(0);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

int main() {

    ll N;
    cin >> N;

    vector <string> s(N);


    REP(i,N)
    {
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s.begin(),s.end());

    ll res = 0;

    ll len = 1;
    REP(i,N-1)
    {
        if(s[i] == s[i+1])
        {
            res += len;
            ++len;
        }
        else
        {
            len = 1;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 7296
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        sc.close();

        String result = "No";
        if (a.equals(b.substring(0, b.length()-1))) {
            result = "Yes";
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 35528
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; scanf("%d", &___T); for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 1e9+7;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
int n , a[maxn];
int main()
{
    map<int , ll>mp;
    cin >> n;
    for(int i = 0; i <n; i++){
        cin >> a[i];
        mp[a[i]]++;
    }
    ll sum = 0;
    for(map<int , ll>::iterator it = mp.begin(); it!=mp.end();it++){
        sum+=(*it).second * ((*it).second - 1) / 2;
    }
    // cout << sum << endl;
    for(int i = 0; i < n; i++){
        cout << sum - mp[a[i]]*(mp[a[i]]-1)/2+((mp[a[i]]-1)*(mp[a[i]]-2)/2)<<"\n";
    }
    
    
}

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


int main()
{
	string s;  
	int y,m,d; char c1,c2; cin>>y>>c1>>m>>c2>>d;
	if(m<=4)
	cout<<"Heisei"<<endl;
	
	else 
	cout<<"TBD"<<endl;
	
}



Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		char[] s = sc.next().toCharArray();
		int len = s.length;
		char[] c1 = new char[len];
		char[] c2 = new char[len];
		for (int i = 0; i < len; i = i + 2) {
			c1[i] = '0';
			c2[i] = '1';
		}
		for (int i = 1; i < len; i = i + 2) {
			c1[i] = '1';
			c2[i] = '0';
		}
		int dif1 = 0, dif2 = 0;
		for (int i = 0; i < len; i++) {
			if (s[i] != c1[i]) {
				dif1++;
			}
			if (s[i] != c2[i]) {
				dif2++;
			}
		}
		System.out.println(Math.min(dif1, dif2));
	}
}


Measured memory_bytes: 26676
/*  Author : Alpha_The_Coder
    Created on 13/09/2020      */
#include <bits/stdc++.h>
using namespace std;
#define iamalpha ios_base::sync_with_stdio(false);cin.tie(NULL);
#define loop(a,n) for(int i=a;i<n;i++)
#define nloop(a,n) for(int j=a;j<n;j++)
#define lli long long int
lli mod=1000000007;
void solve();


int main()
{
    iamalpha;
    int t=1;
    while(t--)
    {
        solve();
    }
}

void solve()
{

    int n;
    lli count=0;
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        int ab=n-i;

        for(int j=1;j<=sqrt(ab);j++)
        {
            if(ab%j==0)
                {
                    if(j*j==ab)
                    count+=1;
                    else
                    count+=2;
                }

         }


    }
    printf("%lli",count);
}


// Solely contributed by Subhojeet Sahoo aka Alpha


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n,m;cin>>n;
    int t[n];
    int sum=0;
    rep(i,n){cin>>t[i];sum+=t[i];}
    cin>>m;
    int mx=-1;
    int dif[m];
    rep(i,m){int p,x;cin>>p>>x;dif[i] = t[p-1]-x;}
    rep(i,m){
        co(sum-dif[i]);
    }
}

Measured memory_bytes: 256
n, s = int(raw_input()), raw_input()
h = {'(':+1 , ')':-1}
m = 0
bal = 0
for i in range(len(s)):
	bal += h[s[i]]
	m = min(bal,m)

print '(' *abs(m) + s + ')' * (bal + abs(m))

Measured memory_bytes: 85432