akhauriyash/Code-Regression huggingface dataset:
n = int(input())
s = input()
cnt = s.count('R')*s.count('G')*s.count('B')
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i] != s[j]:
            if 2*j-i > n-1:
                break
            if s[2*j-i] not in(s[i],s[j]):
                cnt -= 1
print(cnt)

Measured memory_bytes: 9200
#[allow(unused_macros)]
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(unused_macros)]
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(unused_macros)]
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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      m: usize,
      aa: [usize1; n],
    }

    let mut imos = vec![0i64; m*2];
    let mut adjust = vec![0i64; m*2];

    let mut ttl = 0;
    for i in 0..n-1 {
        let a = aa[i];
        let mut b = aa[i+1];
        let diff = ((b + m) - a) % m;
        ttl += diff;

        if diff <= 1 {
            continue;
        }

        if b < a {
            b += m;
        }

        imos[ a+2 ] += 1;
        imos[ b+1 ] -= 1;
        adjust[ b+1 ] -= (b - a - 1) as i64;
    }

    let mut cur = 0;
    let mut score = 0;
    let mut scores = vec![0; m];
    for i in 0..m*2 {
        cur += imos[i];
        score += cur;
        score += adjust[i];
        scores[i%m] += score;
    }

    let ans = *scores.iter().max().unwrap();
    puts!("{}\n", ttl-ans as usize);
}


Measured memory_bytes: 10492
ae = [int(input()) for _ in range(5)]

sum_ae = 0
g = 9
cnt = 0  
for i in ae:
    if i % 10 != 0:
        g = min(g, i % 10)
        sum_ae += (i//10 + 1) * 10
        cnt += 1
    else:
        sum_ae += i
if cnt != 0:
    print(sum_ae - (10-g))
else:
    print(sum_ae)

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

using namespace std;

typedef long long LL;

int N, A, B;
string S;

int main()
{

  cin >> N >> A >> B;
  cin >> S;
  int a = 0, b = 0;
  for (size_t i = 0; i < S.length(); i++) {
    if(S[i] == 'c'){
      printf("No\n");
    }
    else if(S[i] == 'a'){
      if(a+b < A + B){
        printf("Yes\n");
        a++;
      }
      else{
        printf("No\n");
      }
    }
    else{
      if(a+b < A + B && b < B){
        printf("Yes\n");
        b++;
      }
      else{
        printf("No\n");
      }
    }
  }

  return 0;
}


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

int main() {
int  N;
string S,T,U;  
    cin >> N >> S >>T ;
U=S+T;  
for (int i = 0; i < N; i++) {
  U.at(i*2)=S.at(i);
}
for (int i = 0; i < N; i++) {
  U.at(i*2+1)=T.at(i);
}
 cout << U <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int dp[2][500][500];
signed main() {
    fill((int*)dp, (int*)dp+2*500*500, INF);
    
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    vector<vi> g(N);
    REP(i, N) {
        int a, b, c;
        cin >> a >> b >> c;
        g[i] = {a, b, c};
    }
    dp[0][0][0] = 0;
    REP(i, N) {
        REP(a, 401) {
            REP(b, 401) {
                if (dp[i%2][a][b] != INF) {
                    chmin(dp[(i+1)%2][a+g[i][0]][b+g[i][1]], dp[i%2][a][b] + g[i][2]);
                }
                chmin(dp[(i+1)%2][a][b], dp[i%2][a][b]);
            }
        }
    }
    int ans = INF;
    REPF(i, 1, 500) {
        if (Ma * i > 500 || Mb * i > 500) break;
        chmin(ans, dp[N%2][Ma*i][Mb*i]);
    }
    cout << (ans != INF ? ans : -1) << endl;
    return 0;
}



Measured memory_bytes: 4224
#include <stdio.h>
#include <string.h>
#include <math.h>
int max(int i,int j,int n,int rhom[][100]){
	int r,l;
	if(i<=n/2){
	if(j==0)l=0; else l=rhom[i-1][j-1];
	r=rhom[i-1][j];
	}else{
	l=rhom[i-1][j];
	r=rhom[i-1][j+1];
	}
	return r>l ? r : l;
}
int main(void){
	char tex[200];
	char* tt;
	int rhom[100][100],n,i=0,j=0;
	while(fgets(tex,200,stdin)!=NULL){
		tt=strtok(tex,",");j=0;
		while(tt!=NULL){
			sscanf(tt,"%d",&n);
			rhom[i][j]=n;
			tt=strtok(NULL,",");j++;
		}
		rhom[i][j]=0;i++;
	}
	n=i;
	for(i=1;i<n;i++){
		for(j=0;j<(n+1)/2-abs(i-n/2);j++){
			rhom[i][j]+=max(i,j,n,rhom);
		}
	}
	printf("%d\n",rhom[n-1][0]);
	return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int a[5]={};
  for(int i=0;i<3;i++){
    int x,y;
    cin>>x>>y;
    a[x]++;
    a[y]++;
  }
  bool flag=false;
  for(int i=1;i<=4;i++){
    if(a[i]>=3) flag=true;
  }
  if(flag) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;

  return 0;
}


Measured memory_bytes: 256
def check(n,p):
    for j in range(0,len(p)):
        if(n==p[j]):
            return False
    return True

def check_main(X,N,p):
    for i in range(0,51):
        if (check(X-i,p)):
            return X-i
        elif(check(X+i,p)):
            return X+i


if __name__ == "__main__":
    X,N = input().split()
    numbers = list(map(int,input().split()))
    X = int(X)
    N = int(N)
    numbers.sort()
    print(check_main(X,N,numbers))

Measured memory_bytes: 9216
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
		int num[] =new int[times];
		int max = 0;
		int min = 0;
		for(int i=0;i<times;i++){
			num[i] = scan.nextInt();
			
		}
		max = num[1] - num[0];
		min = num[0];
		for(int i=1;i<times;i++){
			if(max < num[i]-min){
				max = num[i]-min;
			}
			if(min > num[i]){
				min = num[i];
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 100688
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;




int main() {

	int n, m;
	
	cin >> n >> m;
	int t1 = m * 1900 + (n - m) * 100;

	int ans = t1;
	for (int i = 0; i < m; i++) {
		ans *= 2;
	}

	cout << ans << endl;
}

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

int main(void)
{
    int count = 0;
    string s,ans = "CODEFESTIVAL2016";
    cin >> s;
    for(int i = 0;i < s.size();i++)
    {
        if(s[i] != ans[i]){count++;}
    }
    cout << count << endl;
    return 0;
}

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

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

    long long x[n], y[n], h[n];
    long long si;
    for(long long i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0) si = i;
    }

    long long ansx, ansy, ansh;  
    for(long long cy = 0; cy <= 100; cy++){
        for(long long cx = 0; cx <= 100; cx++){
            long long H = h[si] + abs(cx-x[si]) + abs(cy-y[si]);
            bool ok = true;

            for(long long i = 0; i < n; i++){
                if(h[i] > 0 and  H != h[i] + abs(cx-x[i]) + abs(cy-y[i])){
                    ok = false;
                }
                if(h[i] == 0 and H > abs(cx-x[i]) + abs(cy-y[i])){
                    ok = false;
                }
            }

            if(ok == true) ansx = cx, ansy = cy, ansh = H;
        }
    }
    

    cout << ansx << " " << ansy << " " << ansh << endl;
    return 0;
}

Measured memory_bytes: 3520
n, m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

ca = [0]
cb = [0]
a.each { |e| ca << ca[-1] + e }
b.each { |e| cb << cb[-1] + e }

a_idx = ca.bsearch_index { |e| e > k }&.pred
a_idx ||= n
max = 0

0.upto(a_idx) do |idx|
  rest = k - ca[idx]
  b_idx = cb.bsearch_index { |e| e > rest }&.pred
  b_idx ||= m

  max = [idx + b_idx, max].max
end

puts max

Measured memory_bytes: 45084
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          163577857
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

 typedef tree<pii, null_type, less<pii>, rb_tree_tag,  
            tree_order_statistics_node_update>  odst; 


void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   
    #endif
}



void solve()
{
 int n;
 cin >> n ;
 int a[n+1];

 forf(i,1,n+1) cin >> a[i];

 map<int,int>mp;
 
 int an =0;
 for(int i=1;i<=n;i++)
 {
   an += mp[i-a[i]];
   mp[a[i]+i]++;
 }

 cout<<an<<endl;
}

int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

 }

Measured memory_bytes: 27736
# coding: utf-8
 
w, h, N = list(map(int, input().split()))
 
rect = [0, w, 0, h]
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if [1, -1][a % 2] * ([x, y][a > 2] - rect[a - 1]) < 0:
        rect[a - 1] = [x, y][a > 2]
 
length = lambda x: [x, 0][x < 0]
print(length(rect[1] - rect[0]) * length(rect[3] - rect[2]))

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

int main() {
	int n, m;	//????????????
	std::cin >> n >> m;

	// STL???vector??????????????£????????????2?¬???????????????????
	std::vector< std::vector<int> > A;
	A.resize(n);
	for (int i = 0; i < n; i++)
	{
		A[i].resize(m);
	}
	// STL???vector??????????????£????????????1?¬???????????????????
	std::vector<int> b;
	b.resize(m);

	// ??\???
	// ??????A
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			int a;
			std::cin >> a;
			A[i][j] = a;
		}
	}
	// ????????????b
	for (int i = 0; i < m; i++)
	{
		int B;
		std::cin >> B;
		b[i] = B;
	}
	// ?¨???????????????????
	for (int i = 0; i < n; i++)
	{
		int sum = 0;
		for (int j = 0; j < m; j++)
		{
			sum += A[i][j] * b[j];
		}
		std::cout << sum << std::endl;
	}
	/*
	// ??????
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			std::cout << A[i][j] << " ";
		}
		std::cout << std::endl;
	}
	*/
	return 0;
}

Measured memory_bytes: 3132
import numpy as np

n, k = list(map(int, input().split()))
MOD = 10 ** 9 + 7
l = int(n ** 0.5)
coe = [n // i - l for i in range(l, 0, -1)]
coe.append(0)
coe.reverse()
coe = np.array(coe, dtype=np.int64)

dp1 = np.ones(l + 1, dtype=np.int64)
dp2 = coe.copy()
dp1[0] = 0
for i in range(k - 1):
    dp1acc_f = np.add.accumulate(dp1) % MOD
    dp1acc_b = np.add.accumulate((dp1 * coe % MOD)[::-1])[::-1] % MOD
    s = dp1acc_f[-1]
    dp1acc_f = np.roll(dp1acc_f, 1)
    dp1[1:] = (s + dp2[1:]) % MOD
    dp2[1:] = (dp1acc_b + dp1acc_f * coe)[1:] % MOD
ans = (dp1.sum() + dp2[1]) % MOD
print(ans)


Measured memory_bytes: 14348
#include<iostream>
// #define ll long long
using namespace std;
// ll mod=1e9+7;
// ll power(ll x,ll y) 
// { 
//     ll res = 1;      
//     while (y > 0) 
//     { 
//         if (y & 1) 
//             res = (res*x); 
//         y = y>>1;
//         x = (x*x);  
//     } 
//     return res; 
// }
     
int main() {
      int k,a,b,i;
      cin>>k>>a>>b;
      int flag=0;
      for(i=a;i<=b;i++){
            if(i%k==0){
                flag=1;
                break;
            }
      }
      if(flag)cout<<"OK"<<endl;
      else
        cout<<"NG"<<endl;


}

Measured memory_bytes: 3100
#include<stdio.h>
int main()
{
    int K,X;
    scanf("%d%d",&K,&X);
    int i,s,a;
    if(K==1)
        printf("%d\n",X);
    else
    {
        K--;
        s=X-K;
        a = X+K;
        for(i=s; i<=a; i++)
        {
            if(i==a) printf("%d\n",i);
            else
            printf("%d ",i);
        }
    }
    return 0;
}

Measured memory_bytes: 128
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
a=get_i
ans=0
(N-1).times do|i|
  (N-1).downto(i+1) do|j|
      if a[j-1]>a[j]
          a[j-1],a[j]=a[j],a[j-1]
          ans+=1
      end 
  end
end
puts a.join(" ")
puts ans


Measured memory_bytes: 8920
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main() {
	int N, K;
	cin >> N >> K;
	cout << N - K + 1 << endl;
	return 0;
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<LL> x, y;
  LL N = (1ll << 60) - 2;
  Solver(LL n) : n(n), x(n), y(n){};
  bool isOdd(LL a, LL b) {
    if (a < b) return false;
    if (b < 0) return false;
    //if (a < b) swap(a, b);
    return (a - b) == (a ^ b);
  }
  int coeffMod2(LL ord) {
    int ret = 0;
    for (int i = 0; i < n; ++i) {
      ret += isOdd(y[i] + N, ord - x[i]);
    }
    DBG(ord, ret % 2)
    return ret % 2;
  }
  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> x[i] >> y[i];
    }
    //*(1+x)^(2^60-2)
    //t^0
    if (coeffMod2((1ll << 57))) {
      LL lb = -(1ll << 57), ub = (1ll << 57);
      while (ub - lb > 2) {
        LL mid = (ub + lb) / 2;
        if (coeffMod2(mid)) {
          ub = mid;
        } else {
          lb = mid;
        }
      }
      cout << ub << endl;
    } else {
      assert(coeffMod2((1ll << 57) + 1));
      LL lb = -(1ll << 57) + 1, ub = (1ll << 57) + 1;
      while (ub - lb > 2) {
        LL mid = (ub + lb) / 2;
        if (coeffMod2(mid)) {
          ub = mid;
        } else {
          lb = mid;
        }
      }
      cout << ub << endl;
    }
  }
};  // namespace Problem
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}

class BinaryIndexTree{
    public:
        BinaryIndexTree(long long N) : n(N), data(n*2-1,0) {}
        long long sum(long long i){
            assert(i < n);
            long long s = 0;
            while(i > 0){
                s += data[i];
                i -= i & -i;
            }
            return s;
        } 
        long long add(long long i, long long x){
            assert(i < n);
            while(i <= n){
                data[i] += x;
                i += i & -i;
            }
        }
        long long size(void){
            return n;
        }
    private:
        long long n;
        vector<long long> data;
};


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    pair<ll,ll> a[n];
    rep(i,n){
        cin>>a[i].first;
        a[i].second = i+1;
    }
    sort(a,a+n,greater<pair<ll,ll>>());
    ll res[n+1]={};
    ll cnt = a[0].first;
    ll cur = 0;
    ll min_a = n;
    while(cur<n){
        while(cur<n&&cnt==a[cur].first){
            cur++;
        }
        chmin(min_a,a[cur-1].second);
        DEBUG{
            cout << "min_a: " << min_a << endl;
        }
        if(cur==n){
            res[min_a] += a[cur-1].first*cur;
        }else{
            res[min_a] += (a[cur-1].first-a[cur].first)*cur;
        }
        cnt = a[cur].first;
    }
    repr(i,1,n+1){
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3456
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N=intput()
S=input()
tmp=0
ans=deque()
for i in range(N):
    c=S[i]
    tmp = tmp+1 if c=='(' else tmp-1
    if tmp<0:
        ans.appendleft('(')
        tmp=0
    ans.append(c)
for _ in range(tmp):
    ans.append(')')
ans=list(ans)
lprint(ans,'')

Measured memory_bytes: 86956
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		String t = sc.nextLine();
		String T = t;
		while (true) {
			t = sc.nextLine();
			if (t.equals("END_OF_TEXT"))
				break;
			T += " " + t;
		}
		int count = 0;
		int result = 0;
		T = " " + T.toLowerCase() + " ";
		while (true) {
			result = T.indexOf(" " + W + " ");
			if (result == -1) {
				break;
			} else {
				count++;
				T = T.substring(result + W.length() + 1);
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 26268
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;

class Program
{
    public static void Main( )
    {

        int N = int.Parse( Console.ReadLine( ) );
        var inputs = Enumerable.Range( 1, N ).Select( x => Console.ReadLine( ) ).ToList( );

        Console.WriteLine($"AC x {inputs.Count(x => x=="AC")}" );
        Console.WriteLine($"WA x {inputs.Count(x => x=="WA")}" );
        Console.WriteLine($"TLE x {inputs.Count(x => x=="TLE")}" );
        Console.WriteLine($"RE x {inputs.Count(x => x=="RE")}" );

    }

}


Measured memory_bytes: 32328
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  ll H, W, A, B;
  cin >> H >> W >> A >> B;
  vector<string> S(H, "");
  REP(i, H) REP(j, W) { S[i].push_back('0'); }
  REP(i, H) REP(j, W) {
    if (i < H - B) {
      if (j < W - A) {
        S[i][j] = '1';
      }
    } else {
      if (j >= W - A) {
        S[i][j] = '1';
      }
    }
  }
  REP(i, H) cout << S[i] << endl;
}

Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()

int main(){
	int s; cin >> s;
	VVI dp(s+1,VI(s+1,0));
	ll ans=0; dp[0][0]=1;
	REP(i,s){
		VI sum(s+1,0);
		REP(j,s){
			sum[j+1]+=sum[j]+dp[i][j];
			sum[j+1]%=MOD;
		}
		for(int j=3;j<=s;j++){
			dp[i+1][j]=sum[j-2];
		}
		ans+=dp[i+1][s];
		ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 34540
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <cinttypes>

#define fi first
#define se second

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const int INF = 1e9;
const double EPS = 1e-9;

typedef pair<int, int> P;
inline P operator+(const P& p1, const P& p2) {
  return P(p1.first + p2.first, p1.second + p2.second);
}

#define int long long 
int N;
vector<int> A[3];

signed main(){
  cin >> N;
  A[0].resize(N);
  A[1].resize(N);
  A[2].resize(N);

  for (int i = 0; i < N; i++) {
    cin >> A[0][i];
  }
  for (int i = 0; i < N; i++) {
    cin >> A[1][i];
  }
  for (int i = 0; i < N; i++) {
    cin >> A[2][i];
  }

  sort(A[0].begin(), A[0].end());
  sort(A[1].begin(), A[1].end());
  sort(A[2].begin(), A[2].end());

  int ans = 0;

  for (int i = 0; i < N; i++) {
    int l1 = 0, r1 = N;
    int m1 = 0;
    while (r1 - l1 > 0) {
      m1 = (l1 + r1) / 2;
      if (A[0][m1] < A[1][i]) {
        if (l1 == m1) {
          break;
        }
        l1 = m1;
      } else {
        if (r1 == m1) {
          break;
        }
        r1 = m1;
      }
    }

    int l2 = 0, r2 = N;
    int m2 = 0;
    while (r2 - l2 > 0) {
      m2 = (l2 + r2) / 2;
      if (A[2][m2] <= A[1][i]) {
        if (l2 == m2) {
          break;
        }
        l2 = m2;
      } else {
        if (r2 == m2) {
          break;
        }
        r2 = m2;
      }
    }
    
    ans += r1 * (N - r2);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int64_t MAXH = 410;
int64_t H, W, ans = 0, black = 0, white = 0;
vector<vector<bool>> Black(MAXH, vector<bool>(MAXH, 0));
vector<vector<bool>> Checked(MAXH, vector<bool>(MAXH, 0));

void search(int64_t h, int64_t w, bool curBlack)
{
  if (h < 0 || h >= H || w < 0 || w >= W)
    return;
  if (Checked.at(h).at(w))
    return;
  if (curBlack && !Black.at(h).at(w) || !curBlack && Black.at(h).at(w))
    return;
  Checked.at(h).at(w) = true;
  curBlack ? black++ : white++;
  search(h + 1, w, !curBlack);
  search(h - 1, w, !curBlack);
  search(h, w + 1, !curBlack);
  search(h, w - 1, !curBlack);
}

int main()
{
  char c;
  cin >> H >> W;
  for (int h = 0; h < H; h++)
  {
    for (int w = 0; w < W; w++)
    {
      cin >> c;
      if (c == '#')
        Black.at(h).at(w) = 1;
    }
  }
  for (int h = 0; h < H; h++)
  {
    for (int w = 0; w < W; w++)
    {
      if (Black.at(h).at(w) && !Checked.at(h).at(w))
      {
        black = 0;
        white = 0;
        search(h, w, 1);
        ans += black * white;
      }
    }
  }
  cout << ans << endl;
}

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

public class Main {
	static class FenwickTree {
	    int n;
	    long x[];
	    public FenwickTree(int N) {
	    	this.n = N;
	    	x = new long[N + 1] ;
		}
	    int size()  { return n; }
	    long sum(int r) {
	        long S = 0;
	        for (r = r - 1; r >= 0; r = (r & (r + 1)) - 1) S += x[r];
	        return S;
	    }
	    long sum(int l, int r)  { return sum(r) - sum(l); }
	    void add(int k, long a) {
	        for (; k < n; k |= k + 1) {
	        	x[k] += a;
	        }
	    }
	    void set(int k, long a) { add(k, a - sum(k, k + 1)); }
	};
	static void solve(int A[] , int K){
		int N = A.length;
		FenwickTree ft = new FenwickTree(N);
		for(int i = 0 ; i < N ; ++i){
			int a = A[i];
			if(a == 0){
				continue;
			}
			ft.add(i,   a);
			ft.add(i + 1, - a);
		}
		for(int i = 0 ; i < K ; ++i){
			FenwickTree L = new FenwickTree(N);
			for(int j = 0 ; j < A.length ; ++j){
				int a = (int)ft.sum(0, j + 1);
				int l = j - a;
				int r = j + a;
				if(l < 0){
					l = 0;
				}
				if(r >= N){
					r = N - 1;
				}
				L.add(l, 1);
				L.add(r + 1, -1);
			}
			ft = L;
			boolean f = true;
			for(int j = 0 ; j < A.length ; ++j){
				int a = (int)ft.sum(0, j + 1);
				if(a != N){
					f = false;
					break;
				}
			}
			if(f){
				break;
			}
		}
		StringBuilder sb = new StringBuilder();
		for(int j = 0 ; j < A.length ; ++j){
			if(sb.length() > 0){
				sb.append(' ');
			}
			int a = (int)ft.sum(0, j + 1);
			sb.append(a);
		}
		System.out.println(sb.toString());
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0 ; i < N ; ++i){
			A[i] = sc.nextInt();
		}
		solve(A, K);
	}
}


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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O2")
#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")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cout << name << " = " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names+1, ',');
    cout.write(names, comma - names) << " = " << arg1 <<" | ";
    __f(comma+1, args...);
}
#else
#define debug(...)
#endif

LL solve(LL a,LL b)
{
    return a * b;
}
int main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    LL a , b , c, d;
    cin >> a >> b >> c >> d;

    vector<LL>vec;
    vec.push_back(solve(a,c));
    vec.push_back(solve(a,d));
    vec.push_back(solve(b,c));
    vec.push_back(solve(b,d));
    SORT(vec);
    cout << vec.back() << "\n";
    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}


Measured memory_bytes: 3628
N = int(input())
W = [input() for _ in range(N)]
ans = 'Yes'
W_set = set(W)
if len(W) == len(W_set):
  for i in range(1, N):
    if W[i][0] != W[i-1][-1]:
      ans = 'No'
      break
else:
  ans = 'No'
print(ans)

Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

amari=0
ans=0

for i in range(n):
    ans+=amari
    if a[i]-amari>=b[i]:
        ans+=b[i]
        amari=0
        
    else:
        ans+=a[i]-amari
        amari=min(a[i+1],b[i]-(a[i]-amari))
        

ans+=amari
print(ans)

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

int main(){
	int D=0;
  	cin >>D;
  
  if(D==25) cout<<"Christmas";
  else if(D==24) cout <<"Christmas Eve";
  else if(D==23) cout <<"Christmas Eve Eve";
  else if(D==22) cout <<"Christmas Eve Eve Eve";
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
/*int main(){//A
    int N;cin>>N;
    if(N%2==0) cout<<(double)N/2/N<<endl;
    else cout<<(double)(N/2+1)/N<<endl;
    return 0;
}*/

int main(){
    int N,K;cin>>N>>K;
    vector<int> h(N);
    int c=0;
    rep(i,0,N) {
        cin>>h[i];
        if(h[i]>=K) c++;
    }
    cout<<c<<endl;
    return 0;
}

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

bool augment(const vector<vector<int>>& g, int src, vector<int>& matchTo, vector<bool>& visited) {
  if (src < 0) return true;
  for (int dst : g[src]) if (!visited[dst]) {
    visited[dst] = true;
    if (augment(g, matchTo[dst], matchTo, visited)) {
      matchTo[src] = dst;
      matchTo[dst] = src;
      return true;
    }
  }
  return false;
}
int bipartiteMatching(const vector<vector<int>>& g, int L) {
	const int n = g.size();
	vector<int> matchTo(n, -1);
	int match = 0;
	for (int u = 0; u < L; ++ u) {
		vector<bool> visited(n);
		if (augment(g, u, matchTo, visited)) ++match;
	}
	return match;
}

int main() {
	int N;
	cin >> N;
	vector<int> x(2*N), y(2*N);
	vector<vector<int>> g(2*N);
	for (int i = 0; i < 2*N; ++ i) cin >> x[i] >> y[i];
	for (int i = 0; i < N; ++ i) {
		for (int j = N; j < 2*N; ++ j) {
			if (x[i] < x[j] && y[i] < y[j]) {
				g[i].push_back(j);
			}
		}
	}
	cout << bipartiteMatching(g, N) << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    private static final String blank = " ";

    public static void main(String[] args) {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        String input = null;

        try {
            while ((input = in.readLine()) != null) {

                String[] problemData = input.split(blank);

                int num1 = Integer.valueOf(problemData[0]);
                int num2 = Integer.valueOf(problemData[1]);

                int gcd = resolveGcd(num1, num2);
                long lcm = (long) (num1 / gcd * num2);

                System.out.println(gcd + blank + lcm);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static int resolveGcd(int num1, int num2) {

        int result = num1 % num2;

        if (result == 0) {
            return num2;
        }

        return resolveGcd(num2, result);
    }
}

Measured memory_bytes: 17104
n = gets.chomp.to_i
points = []
n.times do
  points << gets.chomp.split(' ').map(&:to_f)
end
sum = 0.0
(0...n).each do |i|
  p1 = points[i]
  (0...n).each do |j|
    next if i == j
    p2 = points[j]
    sum += (((p1[0] - p2[0]) ** 2) + ((p1[1] - p2[1]) ** 2)) ** 0.5
  end
end
puts sum / n.to_f

Measured memory_bytes: 1788
#include<bits/stdc++.h>
 using namespace std;
 int main(){

 	int n,k,x;
 	cin>>k>>x;
 	n=x-k+1;
 	int t=(k*2)-1;
 	while(t--){

        cout<<n<<" ";
        n++;
 	}
 	return 0;

 }


Measured memory_bytes: 256
/*There's a possibility*/
/*but stop sucking first*/
#define dbg(...) ; 
#define db(...) ; 
#include "bits/stdc++.h"
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define tst cout<<'*';
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mod 1000000007
using namespace std;
 
double ar[3000], dp[3000][3000],ans;
int n;

int main()
{
    fast;
    int i,j;
    cin>>n;
    f(i,0,n)
        cin>>ar[i];
    
    dp[n-1][0]=1-ar[n-1];
    dp[n-1][1]=ar[n-1];

    fr(i,n-2,0)
    {
        dp[i][0]=(1-ar[i])*dp[i+1][0];
        f(j,1,n+1)
            dp[i][j]=ar[i]*dp[i+1][j-1]+(1-ar[i])*dp[i+1][j];
    }

    f(i,(n+1)/2,n+1)
        ans+=dp[0][i];
    cout<<std::setprecision(9) <<ans;
    db(dp,0,2,0,3);
}

Measured memory_bytes: 73964
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;


int main(){
    int x[5];

    for(int i = 0;i < 5;i++){
        cin >> x[i];
    }
    for(int i = 0;i < 5;i++){
        if(x[i] == 0)cout << i + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3156
// -*- coding:utf-8-unix -*-

use proconio::input;
use num::integer::gcd;

fn main() {
    input! {
        n: u64
    }

    let mut r = 0;

    for i in 1..=n {
        for j in 1..=n {
            for k in 1..=n {
                r += gcd(gcd(i, j), k);
            }
        }
    }

    println!("{}", r);
}


Measured memory_bytes: 2132
<?php
list($n, $m, $v, $p) = ints();
$a = ints();
rsort($a);
$ok = -1;
$ng = $n;
while(abs($ok - $ng) > 1){
    $mid = intdiv($ok + $ng, 2);
    if(isOK($mid)){
        $ok = $mid;
    }else{
        $ng = $mid;
    }
}
echo $ok + 1;
function isOK($k){
    global $a, $m, $v, $n, $p;
    $minusable = ($n-$v) * $m;
    $over = 0;
    for($i = $k-1; $i >= $p-1; $i--){
        $o = $a[$i] - $a[$k];
        if($o > $m){
            return false;
        }
        $over += $o; 
    }
    return $over<=$minusable;
}

function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}


Measured memory_bytes: 16884
#include <iostream>
using namespace std;
#define rep(i,p,n)for(int i=p;i<n;i++)
int main(){
    int A,B,sum = 0,f,s, num, t=0;
    cin >> A >> B;
    f = A/10000, s = A/1000 - f*10;
    num = f*10000 + s*1000 + t*100 + s*10 + f;
    while(num <= B){
        rep(t, 0, 10){
            if((f*10000 + s*1000 + t*100 + s*10 + f) <= B && (f*10000 + s*1000 + t*100 + s*10 + f) >= A){
                sum++;
            }
            num = f*10000 + s*1000 + t*100 + s*10 + f;
        }
        if(++s>=10)f++,s=0;
    }
    cout << sum <<endl;
    
    return 0;
}


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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	float N,M,L;
  cin >> N >> M >> L;
  if(N / L <= M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

return 0;
}

Measured memory_bytes: 3736
// AOJ 2409: Power
// 2017.11.28 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

typedef struct { int a, b; char used; } T;
T cover[102];

int cmp(T *a, T *b)
{
	if (a->a - b->a) return a->a - b->a;	// ???????????????????????????????????????
	return b->b - a->a;						// ??????????????????????????????????????????????????????????????????
}

int main()
{
	int n, m, a, b, i, x, f, ans, min, max;

	scanf("%d%d", &n, &m);
	min = n+1, max = 0;
	for (i = 0; i < m; i++) {
		scanf("%d%d", &a, &b);
		if (a < min) min = a;
		if (b > max) max = b;
		cover[i].a = a, cover[i].b = b, cover[i].used = 0;
	}

	if (1 < min || max < n) goto na;
	qsort(cover, m, sizeof(T), cmp);

	ans = 0;
	for (x = 1; x <= n; x++) {
		f = 0, max = 0;
		for (i = 0; i < m; i++) {
			if (cover[i].used) continue;
			if (x < cover[i].a) {
				if (!f) goto na;
				break;
			}
			f = 1;
			if (max < cover[i].b) max = cover[i].b, cover[i].used = 1;
		}
		if (!f) goto na;
		ans++, x = max;
	}
	printf("%d\n", ans);
	return 0;
na: puts("Impossible");
	return 0;
}

Measured memory_bytes: 1820
n = int(input())
L = list(map(int,input().split(' ')))
L.sort()

ans = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if L[i]==L[j]:
        continue
      if L[j]==L[k]:
        continue
      if L[i]+L[j] <= L[k]:
        continue
      ans+=1

print(ans)


Measured memory_bytes: 9064
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        long x = Long.parseLong(sc.next());
        sc.close();

        // 主処理
        long amount = 100;
        int count = 0;
        while (amount < x) {
            amount += amount / 100;
            count++;
        }
        int result = count;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  mint dp[n + 1][4] = {};
  dp[0][0] = 1;
  vi v = {2, 3, 5};
  rep(i, n) {
    if(s[i] == '?') {
      rep(j, 3) dp[i + 1][j + 1] += dp[i][j];
      rep(j, 4) dp[i + 1][j] += dp[i][j] * 3;
    } else {
      int k = s[i] - 'A';
      dp[i + 1][k + 1] += dp[i][k];
      rep(j, 4) dp[i + 1][j] += dp[i][j];
    }
  }
  cout << dp[n][3] << endl;
}

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

int main(){
  string S;
  cin >> S;
  
  vector<bool> D(26,false);
  for(int i=0;i<S.size();i++){
    D.at(S.at(i) - 'a') = true;
//    cout << S.at(i) - 'a' << "\n";
  }
  
  int i_out = 0;
  for(int i=0;i<26;i++){
    if(D.at(i)==false){
      printf("%c\n",i+'a');
      return 0;
    }
  }
  printf("None\n");
  return 0;
}

Measured memory_bytes: 512
N,K=map(int, input().split())
Candles=list(map(int, input().split()))

Distance=[]
for i in range(N-K+1):
        Distance.append(abs(Candles[i]-Candles[i+K-1])+min(abs(Candles[i]),abs(Candles[i+K-1])))
print(min(Distance))

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <algorithm>
#define inf (1e9+9)

using namespace std;

int n, m;
int x[5005], y[5005];
vector<int> compX, compY;
int dif[5005][5005], sum[5005][5005];

int main(void)
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
	
	compX.push_back(-inf);
	for(int i = 1; i <= n; i++) compX.push_back(x[i]);
	sort(compX.begin(), compX.end());
	compX.erase(unique(compX.begin(), compX.end()), compX.end());
	for(int i = 1; i <= n; i++) x[i] = lower_bound(compX.begin(), compX.end(), x[i]) - compX.begin();
	
	compY.push_back(-inf);
	for(int i = 1; i <= n; i++) compY.push_back(y[i]);
	sort(compY.begin(), compY.end());
	compY.erase(unique(compY.begin(), compY.end()), compY.end());
	for(int i = 1; i <= n; i++) y[i] = lower_bound(compY.begin(), compY.end(), y[i]) - compY.begin();
	
	for(int i = 1; i <= n; i++) dif[x[i]][y[i]]++;
	for(int x = 1; x < 5005; x++){
		for(int y = 1; y < 5005; y++){
			sum[x][y] = sum[x-1][y] + sum[x][y-1] - sum[x-1][y-1] + dif[x][y];
		}
	}
	
	//for(int i = 0; i < compY.size(); i++) cout << compY[i] << " "; cout << endl;
	
	int sx, sy, tx, ty;
	for(int q = 0; q < m; q++){
		cin >> sx >> sy >> tx >> ty;
		sx = lower_bound(compX.begin(), compX.end(), sx) - compX.begin();
		sy = lower_bound(compY.begin(), compY.end(), sy) - compY.begin();
		tx = upper_bound(compX.begin(), compX.end(), tx) - compX.begin() - 1;
		ty = upper_bound(compY.begin(), compY.end(), ty) - compY.begin() - 1;
		//cout << sx << " " << sy << " " << tx << " " << ty << endl;
		cout << sum[tx][ty] - sum[sx-1][ty] - sum[tx][sy-1] + sum[sx-1][sy-1] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 121104
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
  
    for(int i=0;i<3;i++){
        if(a.at(i)=='B'){
            cout<<"ARC"<<endl;
        }else if(a.at(i)=='R'){
            cout<<"ABC"<<endl;
        }
    }
}


Measured memory_bytes: 3592