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

int rangemin[202020];

int main() {
    memset(rangemin, INT_MAX, sizeof(rangemin));
    int n;
    cin >> n;
    vector<int> as;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        as.push_back(a);
        if (i == 0) {
            rangemin[0] = a;
        } else {
            rangemin[i] = min(rangemin[i - 1], a);
        }
    }

    int ans = INT_MIN;
    for (int i = 1; i < n; i++) {
        ans = max(ans, as[i] - rangemin[i - 1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4652
N = int(input())
INF = 10**10
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))+[INF]
C = sorted(list(map(int,input().split())))+[INF]
AB = [0]*N
BC = [0]*N
j = 0
for i in range(N):
    while A[i] >= B[j]:
        j += 1
    if j < N:
        AB[j] += 1
for i in range(N-1):
    AB[i+1] += AB[i]
j = 0
cur = 0
ans = 0
for i in range(N):
    while C[i] > B[j]:
        cur += AB[j]
        j += 1
    ans += cur
print(ans)

Measured memory_bytes: 106968
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                 as IM
import           Data.List
import qualified Data.Map                    as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main = do
  [n] <- readInt
  h <- readInt
  putStrLn $ solve h 0 (maximum h)

solve [] _ _ = "Yes"
solve (h:hs) max min
  | max - 1 > h = "No"
  | h > max = solve hs h min
  | h < min = solve hs max min
  | otherwise = solve hs max min


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

int main(){
  long long n,q,s[10001],t,k;
  cin>>n;
  for(long long i=0;i<n;i++){
    cin>>s[i];
  }
  cin>>q;
  k=0;
  for(long long i=0;i<q;i++){
    cin>>t;
    for(long long j=0;j<n;j++){
      if(s[j]==t){
	k++;
	break;
      }
    }
  }
  cout<<k<<endl;
  return 0;
}

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

int main(void){
    long long int n, a, b, hp[100010];
    cin >> n >> a >> b;
    for(int i=0;i<n;++i) cin >> hp[i];
    sort(hp, hp+n);
    long long int cnt = 1, sita=1, ue=1000000000, min=1000000000;
    while(abs(ue-sita)>1){
        long long int sum = 0;
        for(int i=0;i<n;++i){
            if(hp[i] <= b*cnt) continue;
            else{
                long long int h = hp[i]-b*cnt;
                sum += (h+a-b-1)/(a-b);
            }
        }
        if(sum <= cnt){
            if(cnt < min) min = cnt;
            ue = cnt;
            cnt = (cnt + sita)/2;
        }else{
            if(cnt==min-1) break;
            sita = cnt;
            cnt = (cnt + ue)/2;
        }
        if(sita==ue) break;
    }
    cout << min << endl;
}

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

using namespace std;

int main() {
    vector<int> s(3);
    for (int i = 0; i < 3; ++i) cin >> s.at(i);
    cout << (count(s.begin(), s.end(), 5) == 2 && count(s.begin(), s.end(), 7) == 1 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())

ans = [0 for _ in range(n+1)]
m = int(n**0.5) + 1
for x in range(1, m):
    for y in range(1, m):
        for z in range(1, m):
            t = x*x + y*y + z*z + x*y + y*z + z*x
            if t < n + 1:
                ans[t] += 1

for i in range(1, n+1):
    print(ans[i])


Measured memory_bytes: 9400
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
	int N, i, ac = 0,wa =0, tle =0, re = 0;
	string s;
	cin >> N;
	rep(i, N) {
		cin >> s;
		if(s=="AC"){
			ac++;
		}
		if (s == "WA") {
			wa++;
		}
		if (s == "TLE") {
			tle++;
		}if (s == "RE") {
			re++;
		}
	}
	cout << "AC x "<<ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;

	return 0;
}

Measured memory_bytes: 3652
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;

int main(int argc, char const *argv[]) {
  std::string NN;

  std::cin >> NN;

  if (NN.size() == 2) {
    std::cout << NN << '\n';
  }else{
    for (size_t i = 0; i < NN.size(); i++) {
      std::cout << NN[NN.size() - 1 - i] ;
    }
  }

  return 0;
}


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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n, h;
    int a[100000], b[100000];
    cin >> n >> h;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }

    vector<pair<int, int>> v, v2;
    for (int i = 0; i < n; i++)
    {
        v.push_back(make_pair(a[i], b[i]));
        v2.push_back(make_pair(b[i], a[i]));
    }
    sort(all(v));
    sort(all(v2));

    // for (int i = 0; i < n; i++)
    // cout << v2[i].first << "," << v2[i].second << endl;
    int fmx = v[n - 1].first;
    int smx = v[n - 1].second;
    bool use = false;
    int sum = 0;
    int cnt = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        if (v2[i].first >= fmx && sum < h)
        {
            sum += v2[i].first;
            cnt++;
            /*
            if (v2[i].first != smx || use)
            {
                sum += v2[i].first;
                cnt++;
            }
            else
            {
                use = true;
            }
            */
            // cout << "*";
        }
        // cout << v2[i].first << endl;
    }

    // cout << "cnt=" << cnt << "," << sum << endl;

    if (h - sum > 0)
    {
        int sub = h - sum;
        int psub = sub - smx;
        // cout << sub << "," << smx << "," << fmx << "," << max(0LL, (sub - smx + fmx - 1) / fmx) << endl;
        // cout << ((sub + fmx - 1) / fmx) << endl;
        if (sub > 0)
            cnt += ((sub + fmx - 1) / fmx);
        // cnt += max(0LL, (max(0LL, sub - smx) + fmx - 1) / fmx);
        // cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 5100
def resolve():
    N = int(input())
    A = [0]+list(map(int, input().split()))
    dp = [[None for _ in range(2)] for _ in range(N+1)]
    dp[0][0] = 0
    dp[0][1] = -float("inf")
    for i in range(1, N+1):
        dp[i][0] = max(dp[i-1][0]+A[i], dp[i-1][1]-A[i])
        dp[i][1] = max(dp[i-1][0]-A[i], dp[i-1][1]+A[i])
    print(dp[N][0])



if '__main__' == __name__:
    resolve()

Measured memory_bytes: 73888
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <cstdlib>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define SORTR(v) sort((v).begin(),(v).end(),greater<int>())
const ll INF = (1LL << 40);
typedef pair<int, int> P;
const int MOD = 1000000007;

int main() {

	int n, m;
	cin >> n >> m;

	cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;

	return 0;

}

Measured memory_bytes: 256
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main(){
	let r = get!(usize);
	println!("{}", 3*r*r);
}

Measured memory_bytes: 4352
// WeirdBugsButOkay

# include <bits/stdc++.h>

# define ll long long
# define ld long double
# define pii pair <int,int>
# define pll pair <ll,ll>
# define mp make_pair
# define pb push_back
# define ff first
# define ss second
# define endl '\n'

using namespace std;

ll pow3(ll a, ll b, ll m = 1000000007)
{
    ll res = 1;
    while(b > 0)
    {
        if(b & 1)
            res = (res * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return res;
}

void solve()
{
    string s;
    cin >> s;
    ll n = s.size(), rem = 0;
    ll inf = 2019;
    map <ll, ll> m;
    m[0]++;
    ll p10[n + 1] = {0};
    p10[0] = 1;
    for(ll i = 1; i <= n; i++)
        p10[i] = (p10[i - 1] * 10) % inf;
    ll ans = 0;
    for(ll i = 1; i <= n; i++)
    {
        ll x = s[i - 1] - '0';
        rem = (rem * 10 + x) % inf;
        ll val = (rem * p10[n - i]) % inf;
        ans += m[val];
        m[val]++;
    }
    cout << ans << endl;
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll q = 1;
    //cin >> q;
    for(ll i = 0; i < q; i++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5264
function main(input) {
  const args = input.split('\n')[1].split(' ').map((n) => parseInt(n));
  var difference = 0;
  args.sort((a, b) => b - a).forEach((n, i) => {
  	(i % 2 === 0)? difference += n : difference -= n;
  });
  console.log(difference);
}

main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21192
n,q = [int(x) for x in input().split()]
G = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = [int(x)-1 for x in input().split()]
    G[a].append(b)
    G[b].append(a)
count = [0]*n
for _ in range(q):
    a,b = [int(x) for x in input().split()]
    a -= 1
    count[a] += b

from collections import deque
ans = [0]*n
q = deque()
used = [0]*n
q.append(0)
used[0]=1
ans[0] += count[0]

while q:
    p = q.popleft()
    for i in G[p]:
        if used[i]!=1:
            used[i]=1
            ans[i]+=ans[p]+count[i]
            q.append(i)

for i in ans:
    print(i,end=" ")

Measured memory_bytes: 109132
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let v = read_vec::<i64>();
    let (mut x, y) = (v[0], v[1]);

    let mut first = 0;
    let mut cur = 0;
    let mut xs = vec![];
    let mut ys = vec![];

    let mut is_first = true;
    let mut is_x = true;
    for ch in s {
        if ch == 'T' {
            if is_first {
                x -= first;
            } else if is_x {
                xs.push(cur);
            } else {
                ys.push(cur);
            }
            is_x = !is_x;
            is_first = false;
            cur = 0;
        } else {
            if is_first {
                first += 1;
            }
            cur += 1;
        }
    }
    if cur > 0 {
        if is_first {
            x -= first;
        } else if is_x {
            xs.push(cur);
        } else {
            ys.push(cur);
        }
    }

    if solve(xs, x) && solve(ys, y) {
        println!("Yes");
    } else {
        println!("No");
    }
    // debug!(x, y);
    // debug!(xs);
    // debug!(ys);
}

fn solve(xs: Vec<i64>, target: i64) -> bool {
    let mut dp = HashSet::new();
    dp.insert(0);
    for x in xs {
        let mut next = HashSet::new();
        for elem in dp {
            next.insert(elem + x);
            next.insert(elem - x);
        }
        dp = next;
    }
    dp.contains(&target)
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4476
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String kaibun = sc.next();
        int len = kaibun.length();
        String kaibun1 = kaibun.substring(0,(len-1)/2);
        String kaibun2 = kaibun.substring((len + 3)/2 - 1,len);

        StringBuffer kaibun4 = new StringBuffer(kaibun1);
        String kaibun3 = kaibun4.reverse().toString();
        StringBuffer kaibun5 = new StringBuffer(kaibun2);
        String kaibun6 = kaibun5.reverse().toString();
        StringBuffer kaibun7 = new StringBuffer(kaibun);
        String kaibun8 = kaibun7.reverse().toString();
        if(kaibun3.equals(kaibun1) && kaibun6.equals(kaibun2) && kaibun8.equals(kaibun)){
            System.out.println("Yes");
        } else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 22996
use std::cmp;

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

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

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

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

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

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

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

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

fn main() {
    input! {
    	n:chars
    }
    let mut nn = n.to_vec();
    nn.sort();
       
    println!("{}", if nn[0]==nn[1]&&nn[2]==nn[3]&&nn[1]!=nn[2] { "Yes" } else { "No" });
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,k,l,c=0;
    string s;
    vector<char > v;
    cin>>n;
    cin>>s;
    s.push_back('A');
    for(i=0;i<n;i++)
    {
        if(s[i]!=s[i+1])
        {
//            cout<<s[i]<<endl;
            v.push_back(s[i]);
        }
    }
    cout<<v.size()<<endl;
}


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

template<class T>
vector<vector<T> > combination(const vector<T>& seed, int target_size) {
    vector<int> indices(target_size);
    vector<vector<T> > results;
    const int seed_size = seed.size();
    int start_index = 0;
    int size = 0;
    while (size >= 0) {
        for (int i = start_index; i < seed_size; ++i) {
            indices[size++] = i;
            if (size == target_size) {
                vector<T> comb(target_size);
                for (int x = 0; x < target_size; ++x) {
                    comb[x] = seed[indices[x]];
                }
                results.push_back(comb);
                break;
            }
        }
        --size;
        if (size < 0) break;
        start_index = indices[size] + 1;
    }
    return results;
}

bool isTriangle(int a, int b, int c) {
    vector<int> LL;
    LL.push_back(a);
    LL.push_back(b);
    LL.push_back(c);
    //cout << LL[0] << LL[1] << LL[2] << endl;
    int max = *max_element(LL.begin(), LL.end());
    LL.erase(max_element(LL.begin(), LL.end()));
    //cout << LL[0] << LL[1] << endl;
    if (LL[0] + LL[1] > max) {
        return true;
    }
    return false;
}

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    //cout << N << endl;
    for(int i=0;i<N;i++) {
        cin >> L.at(i);
    }

    vector<vector<int> > cands = combination(L, 3);
    int c = 0;
    for(int i=0;i<(int)cands.size();i++) {
        if (cands[i][0] != cands[i][1] && cands[i][1] != cands[i][2] && cands[i][2] != cands[i][0]) {
            if(isTriangle(cands[i][0], cands[i][1], cands[i][2])) {
                c++;
            }
        }
    }
    cout << c << endl;
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

int main(){
    int k;
    string s;
    cin>>k>>s;

    int S=s.size();

    if(S<=k){
        cout<<s<<endl;
    }
    else {
        string ss=s.substr(0,k);
        cout<<ss<<"..."<<endl;
    }
}


Measured memory_bytes: 3620
import math
import sys
input = sys.stdin.readline


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

    ans = 1000000000100
    n = math.ceil(math.sqrt(N))
    for i in range(1, n+1):
        if N%i==0:
            ans = min(ans, i + N//i -2)

    print(ans)


if __name__ == '__main__':
    main()

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




public class Main
{

	static String s1,s2;


	public static void main(String[] Rohan)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));





		// String[] s=br.readLine().split(" ");

		s1=br.readLine();
		s2=br.readLine();


		int[][] dp=new int[s1.length()+1][s2.length()+1];


		for(int i=1;i<=s2.length();i++)
		{
			if(s2.charAt(i-1)==s1.charAt(0))
				dp[1][i]=1;
			else
				dp[1][i]=dp[1][i-1];
		}

		for(int i=2;i<=s1.length();i++)
		{
			for(int j=1;j<=s2.length();j++)
			{
				if(s1.charAt(i-1)==s2.charAt(j-1))
					dp[i][j]=Math.max(dp[i-1][j-1]+1,Math.max(dp[i-1][j],dp[i][j-1]));
				else
					dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
			}
		}

		// for(int i=0;i<=s1.length();i++)
		// {
		// 	for(int j=0;j<=s2.length();j++)
		// 		System.out.print(dp[i][j]+" ");
		// 	System.out.println();
		// }


		int indx=dp[s1.length()][s2.length()]-1;
		char[] c=new char[dp[s1.length()][s2.length()]];



		int i=s1.length(),j=s2.length();


		while(i>0 && j>0)
		{
			if(s1.charAt(i-1)==s2.charAt(j-1))
			{
				c[indx]=s1.charAt(i-1);indx--;
				i--;j--;
			}
			else
			{
				if(dp[i-1][j]>dp[i][j-1])
				{
					i--;
				}
				else
					j--;
			}
		}

		for(int i1=0;i1<dp[s1.length()][s2.length()];i1++)
			System.out.print(c[i1]);
		System.out.println();
		

	}
}

Measured memory_bytes: 83124
from itertools import product
N, M = list(map(int, input().split()))
k_list = []
s_list_list = []
for _ in range(M):
    k, *s_list = list(map(int, input().split()))
    k_list.append(k)
    s_list_list.append(s_list)
p_list = list(map(int, input().split()))

def light_check(switch_pattern):
    return all([
        sum([int(switch_pattern[s-1]) for s in s_list]) % 2 == p
        for s_list, p in zip(s_list_list, p_list)
    ])

cnt = 0
for switch_pattern in product('01', repeat=N):
    if light_check(switch_pattern):
        cnt += 1
print(cnt)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int H[] = new int[N];
		for(int i = 0 ; i < N ; ++i){
			H[i] = sc.nextInt();
		}
		int ret = 0;
		for(int h : H){
			if(h >= K){
				++ret;
			}
		}
		System.out.println(ret);
	}
}


Measured memory_bytes: 49508
#include <bits/stdc++.h>
#define int long long int
#define MOD(x) ((x % MOD_N) + MOD_N) % MOD_N
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,v) for(auto i=v.begin();i!=v.end();++i)
#define REACH(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
#define LB(c,x) distance((c).begin(),lower_bound(ALL(c),x))
#define UB(c,x) distance((c).begin(),upper_bound(ALL(c),x))
#define COUNT(c,x) (upper_bound(ALL(c),x)-lower_bound(ALL(c),x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;
#define NL cerr<<endl;
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T sum(vector<T>&v){return accumulate(ALL(v),T());}
template<typename T>T sum(vector<T>&v,int a,int b){return accumulate(v.begin()+a,v.begin()+b,T());}
template<typename T>T max(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T min(vector<T>&v){return *min_element(ALL(v));}
template<typename T>T max_index(vector<T>&v){return distance((v).begin(),max_element(ALL(v)));}
template<typename T>T min_index(vector<T>&v){return distance((v).begin(),min_element(ALL(v)));}

struct edge { int to, cost; };

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}

const int INF = 1e18;
const int MOD_N = 1e9+7;

signed main()
{
   int N ,K, L, R; cin >> N >> K >> L >> R;
   V<int> a(N); REP(i, N) cin >> a[i];

   V<V<int>> b(K+1);
   REP(s, 1<<N/2) {
      int total = 0, num = 0;
      REP(i, N/2) if (s >> i & 1) {
         total += a[i]; num++;
      }
      if (K < num) continue;
      b[num].push_back(total);
   }
   REP(i, K+1) SORT(b[i]);

   int ans = 0;
   REP(s, 1<<N-N/2) {
      int total = 0, num = 0;
      REP(i, N-N/2) if (s >> i & 1) {
         total += a[i + N/2]; num++;
      }
      if (K < num) continue;
      ans += (UB(b[K-num], R-total) - LB(b[K-num], L-total));
   }
   cout << ans << endl;

   return 0;
}



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

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);
	boolean[] inside = new boolean[3];
	inside[0] = true;

	while ( stdin.hasNextLine() ) {

	    String input[] = stdin.nextLine().split( "," );
	    swap( inside, index( input[0] ), index( input[1] ) );	    
	}
	final String[] val = { "A", "B", "C" };
	for ( int i = 0; i < 3; i++ ) {
	    if ( inside[i] ) {
		System.out.println( val[i] );
	    }
	}
    }

    static void swap( boolean[] ar, int i1, int i2 ) {
	final boolean vi1 = ar[i1];
	ar[i1] = ar[i2];
	ar[i2] = vi1;			       
    }
    
    static int index( String s ){
	if ( "A".equals( s ) ){
	    return 0;
	} else if ( "B".equals( s ) ){
	    return 1;
	} else {
	    return 2;
	}
    }
    
}

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

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2, 7, 61] if n < 1<<32 else [2, 3, 5, 7, 11, 13, 17] if n < 1<<48 else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8 + 1
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r-k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x-ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n//g): return n//g
def primeFactor(N):
    i = 2
    ret = {}
    n = N
    mrFlg = 0
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i%2
        if i == 101 and n >= 2**20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    mrFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if mrFlg > 0: ret = {x: ret[x] for x in sorted(ret)}
    return ret

N = int(input())
ans = 0
D = {}
for _ in range(N):
    pf = primeFactor(int(input()))
    a, b = 1, 1
    for p in pf:
        a *= p ** (pf[p] % 3)
        b *= p ** (-pf[p] % 3)
    if a not in D: D[a] = 0
    if a == b:
        if D[a] == 0: ans += 1
    else:
        if b not in D: D[b] = 0
        if D[b] <= D[a]: ans += 1
    D[a] += 1

print(ans)

Measured memory_bytes: 123352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll t1,t2,a1,a2,b1,b2;
  cin >> t1 >> t2;
  cin >> a1 >> a2;
  cin >> b1 >> b2;
  ll ans = 0;
  tmp1 = (a1-b1) * t1;
  tmp2 = tmp1 + (a2-b2) * t2;
  if(tmp2 == 0){
    cout << "infinity" << endl;
  }else{
    //cout << "a" << endl;
    if((tmp1 >= 0 && tmp2 >= 0) || (tmp1 <= 0 && tmp2 <= 0) ){
      ans = 0;
    }else{
      tmp1 = abs(tmp1);
      tmp2 = abs(tmp2);
      //cout << tmp1 << tmp2 << endl;
      tmp3 = tmp1 / tmp2;
      ans = tmp3 * 2;
      if(tmp1 == tmp2 * tmp3){
        ans--;
      }
      ans++;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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<int64_t> a(n+1),b(n);
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];

    int64_t ans = 0;

    rep(i,n){
            if(a[i] >= b[i]) {
                a[i]-=b[i];
                ans+=b[i];
            }
            else{
                if(a[i]+a[i+1] >= b[i]){
                    a[i+1] = a[i] + a[i+1] - b[i];
                    a[i] = 0;
                    ans+=b[i];
                }
                else{
                    ans+=(a[i]+a[i+1]);
                    a[i] = 0;
                    a[i+1] = 0;
                }
            }
    }

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

Measured memory_bytes: 1792
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int A = s.nextInt();
    int B = s.nextInt();
    int C = s.nextInt();
    int D = s.nextInt();
    System.out.println(Math.max(A*B, C*D));
  }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  int N,M;
  cin >> N >> M;
  vector<ll> A(N);
  for(ll i=0;i<M;++i) cin >> A[i];
  ll sum = accumulate(A.begin(),A.end(),0);
  if(sum>N) cout << "-1" << endl;
  else cout << N-sum << endl;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



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

  int n, m;
  cin >> n >> m;
  vl a(n), b(n), c(m), d(m);
  rep(i,n) cin >> a[i] >> b[i];
  rep(i,m) cin >> c[i] >> d[i];
  rep(i,n) {
    ll dist = infll;
    int ans = -1;
    rep(j,m) {
      ll tmp = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if(tmp < dist) {
        dist = tmp;
        ans = j;
      } 
    }
    cout << ans + 1 << endl;
  }
}

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

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll maxv = max({a * d, a * c, b * c, b * d});
    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 3632
while True:
    n = input()
    if n==0:
        break
    list = []
    for i in range(0,n):
        tmp = input()
        list.append(tmp)
    list.sort()
    list.pop()
    list.pop(0)
    sum = 0
    for i in range(0,len(list)):
        sum += list[i]
    print sum/(n-2)

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

int main()
{
	long long int n,p,k=0,a[200001];
	cin>>n>>p;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	if(a[i]>=p)
	k++;
	}
	cout<<k<<endl;
	
	
	return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int i,j,p[100010],q,a[100010];
  for(i=0;i<=100005;i++){
    p[i]=1;
  }
  p[0]=0,p[1]=0;
  for(i=2;i*i<=100005;i++){
    if(p[i]==1){
      for(j=2;i*j<=100005;j++){
        p[i*j]=0;
      }
    }
  }
  a[0]=0,a[1]=0;
  for(i=3;i<=100005;i=i+2){
    a[i]=a[i-2];
    if(p[i]==1 && p[(i+1)/2]==1){
      a[i]++;
    }
  }
  scanf("%d\n",&q);
  int l,r;
  for(i=0;i<q;i++){
    scanf("%d %d\n",&l,&r);
    if(l==1){
      printf("%d\n",a[r]);
      continue;
    }
    printf("%d\n",a[r]-a[l-2]);
  }
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> vec(N);
  for(ll i=0;i<N;i++) {
cin>>vec[i];
  }
  ll ans=0;
  
  
  
  for(ll i=1;i<=min(N,K);i++) {
    
    for(ll j=0;j<=i;j++) {
      ll sum=0;
      priority_queue<ll> S;
      ll count=0;
      while(count<j) {
        sum+=vec[count];
        if(vec[count]<0) {
S.push(vec[count]*-1);
        }
        count++;
      }
      
      for(ll h=0;h<i-j;h++) {
sum+=vec[N-1-h];
        if(vec[N-1-h]<0) {
S.push(vec[N-1-h]*-1);
        }
      }
      
      ll s=i;
      while(s<K) {
        if(S.empty()) {
break;
        }
sum+=S.top();
        S.pop();
        
        s++;
      }
      
      ans=max(ans,sum);
    }
  }
    
    
    cout<<ans<<endl;
  }
      
      

      
    
    
    
    
    
    

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

    int n,cont=0;
    cin>>n;
    char s[n];
    
    for(int i=0;i<n;i++){
        cin>>s[i];
    }

    for(int i=0;i<n-2;i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            cont++;
        }
    }

    cout<<cont;

    return 0;
}

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

#define ll long long
#define ar array
 
using namespace std;

int main() {
	
	int a,b,c,area;
	
	cin >> a >> b >> c;
	
	area = (a*b)/2;
	
	cout << area << endl;
	
   	return 0;
}
   

Measured memory_bytes: 256
n=int(input())
candy=[list(map(int,input().split())) for i in range(2)]

ans=candy[0][0]+sum(candy[1])
t=ans
for i in range(n-1):
    t+=candy[0][i+1]
    t-=candy[1][i]
    if t>ans:
        ans=t
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  int N,K;
  int snuke[10000]={0};
  int sx=0;
  scanf("%d%d",&N,&K);
  for(int i=0;i<K;i++){
    int d;
    scanf("%d",&d);
    for(int j=0;j<d;j++){
      scanf("%d",&snuke[sx]);
      sx++;
    }
  }
  int ans=0;
  for(int i=1;i<=N;i++){ //snukeは1からN
    int okashi=0;
    for(int j=0;j<sx;j++){
      if(snuke[j]==i){
	okashi++;
      }
    }
    if(okashi==0){
      ans++;
    }
  }
  printf("%d\n",ans);
}


Measured memory_bytes: 1768
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 x, a, b;
  cin >> x >> a >> b;
  cout << (x - a) % b << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=c-(a-b);
    if(ans>0){
    cout<<ans<<endl;
    }
    else{
        cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
# ABC084D - 2017-like Number
import sys
input = sys.stdin.readline

from bisect import bisect_left, bisect_right


def get_primes(n: int) -> list:
    # return a list of primes <= n
    n += 1  # include n itself
    sieve = [1] * n
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i]:
            sieve[i * i :: 2 * i] = [0] * ((n - i * i - 1) // (2 * i) + 1)
    return [2] + [i for i in range(3, n, 2) if sieve[i]]


def main():
    Q = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(Q))
    P = get_primes(10 ** 5)
    S = set(P)
    selected_P = [p for p in P if (p + 1) // 2 in S]
    ans = []
    bsr, bsl = bisect_right, bisect_left
    for l, r in A:
        x = bsr(selected_P, r) - bsl(selected_P, l)
        ans += [x]
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

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

tmp =  [input().split() for i in range(n)]
a = [[name,int(time)] for name,time in tmp]

total_time = 0

count = 0
while(a):
    current = a.pop(0)
    if(current[1] > q):
        current[1] -= q
        a.append(current)
        total_time += q
    else:
        total_time += current[1]
        print(current[0],total_time,sep = " ")


Measured memory_bytes: 21260
import bisect
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

A.sort()
B.sort()
C.sort()
num_b = []
stim = [0]
cnt = 0
for i in B:
    ind = bisect.bisect_left(A,i)
    num_b.append(ind)

for i in num_b:
    stim.append(stim[-1]+i)

for i in C:
    ind = bisect.bisect_left(B,i)
    cnt += stim[ind]

print(cnt)


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

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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i != 0) {
            continue; 
        }
        long long ex = 0; // 指数
        // 割れるだけ割る
        while (N % i == 0) {
            ++ex;
            N /= i;
        }
        // 結果を push
        res.push_back({i, ex});
    }

    // 残った数はそのまま push
    if (N != 1) {
        res.push_back({N, 1});
    } else {
        res.push_back({1, 1});
    }

    return res;
}


int main() {
    long long N, target = 1, ans = 1, num = 1000000007;
    cin >> N;

    vector<long long> ex(N+1, 0); //指数情報を格納していく
    for (int i = 1; i <= N; ++i) {
        const auto &res = prime_factorize(i);
        for (auto p : res) {
            ex[p.first] += p.second;
        }
    }

    for (long long i = 2; i <= N; ++i) {
        ans *= ex[i] + 1 ;
        ans %= num;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3544
import math
[A, B, H, M] = list(map(int, input().split()))
a = 2 * math.pi / 12 * (H + M / 60)
b = 2 * math.pi / 60 * M
c = a - b
answer = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(c))
print(answer)

Measured memory_bytes: 9448
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
H, W = ri_()
a = [[i for i in rs()] for _ in range(H)]
a = [i for i in a if i.count('#') > 0]
a = list(zip(*a))
a = [i for i in a if i.count('#') > 0]
a = list(zip(*a))
a = [''.join(i) for i in a]
for ai in a:
    print(ai)

Measured memory_bytes: 63724
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <cctype>
#include <cmath>
#include <cstring>
#include <climits>
#include <complex>
#include <set>
#include <deque>
#define DEBUG(x) cerr<<"line:"<<__LINE__<<", "<<#x" == "<<(x)<<endl;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(it,s) for(__typeof(s.begin()) it=s.begin();it!=s.end();it++)
#define fst first
#define snd second
#define ALL(a) a.begin(),a.end()
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define DRI(x) int (x);scanf("%d",&(x))
#define DRII(x,y) int (x),(y);scanf("%d%d",&(x),&(y))
#define DRIII(x,y,z) int (x),(y),(z);scanf("%d%d%d",&(x),&(y),&(z))
#define MS0(a) memset((a),0,sizeof((a)))
#define MS1(a) memset((a),-1,sizeof((a)))
#define MS(a,b) memset((a),(b),sizeof((a)))
using namespace std;

typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

#define INF (int)1e9
#define EPS (1.0e-8)
// ------------------

const int maxn = 100+10;
string s[maxn];

int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
#endif
    int n, l;
    cin >> n >> l;

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

    sort(s, s + n);
    string res = "";
    for (int i = 0; i < n; i++) {
        res += s[i];
    }
    cout << res << endl;
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
my ($n, $m, $c) = split / /, <STDIN>;
my @b = split / /, <STDIN>;
my @as = map { [ split(/ /, <STDIN>) ] } 0..($n-1);
my $count_ok = 0;
for my $a (@as) {
    my $p = $c;
    $p += $a->[$_] * $b[$_] for 0..($m-1);
    if($p > 0) {
        $count_ok += 1
    }
}
print $count_ok, "\n";


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int x[200010],y[200010],n,cmax,cmin=1999999999+10,dmax,dmin=1999999999+10,mx=999999999+1;
int main()
{
    int i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>x[i]>>y[i];
        cmax=max(cmax,x[i]+y[i]);
        cmin=min(cmin,x[i]+y[i]);
        dmax=max(dmax,x[i]+mx-y[i]);
        dmin=min(dmin,x[i]+mx-y[i]);
    }
    cout<<max(cmax-cmin,dmax-dmin);
    cin>>i;
}
    


Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int main(){
  int N,A,B; cin>>N>>A>>B;
  int cnt[3]={};
  rep(i,N){
    int P; cin>>P;
    if(P<=A) cnt[0]++;
    else if(P<=B) cnt[1]++;
    else cnt[2]++;
  }
  cout<<min({cnt[0],cnt[1],cnt[2]})<<endl;
  return 0;
}


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

int main() {
  int N, M;
  cin >> N;
  vector<string> s(N);
  for(int i; i < N; i++) cin >> s.at(i);
  cin >> M;
  vector<string> t(M);
  for(int i; i < M; i++) cin >> t.at(i);
  
  int count = 0;
  for(int i; i < N; i++){
    int ncount = 0;
    for(int j = 0; j < N; j++){
      if( s.at(i) == s.at(j)) ncount++;
    }
    for(int j = 0; j < M; j++){
      if(s.at(i) == t.at(j)) ncount--;
    }
    count = max(count, ncount);
  }
  
  cout << count << endl;
}

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

int main(void)
{
        char tmp[100];
        int a, b;

        for (;;) {
                if (scanf("%d%d", &a, &b) == EOF)
                        return 0;
                sprintf(tmp, "%d", a + b);
                printf("%d\n", strlen(tmp));
        }
}

Measured memory_bytes: 608
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <utility>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#include <unordered_set>
using namespace std;
using int64 = long long;
using vint = vector<int>;
#define ForInt(i, n) for (int i = 0; i < (n); ++i)
#define ForLong(i, n) for (int64 i = 0; i < (n); ++i)
#define ForIntInit(i, begin, end) for (int i = (begin); i < (end); ++i)
#define ForItr(it, itBegin, itEnd) for (auto it = (itBegin); it != (itEnd); ++it)

using Graph = vector<vint>;

int bfs(const Graph& g, int start, int goal)
{
	vint dist(g.size(), -1);
	queue<int> q;
	q.push(start);
	dist[start] = 0;
	while (!q.empty())
	{
		int cur = q.front();
		q.pop();

		auto itEnd = g[cur].end();
		ForItr(it, g[cur].begin(), itEnd)
		{
			if (*it == goal)
			{
				return dist[cur] + 1;
			}
			else if (dist[*it] == -1)
			{
				q.push(*it);
				dist[*it] = dist[cur] + 1;
			}
		}
	}

	return -1;
}

int main()
{
	int n, s, t;
	int64 m;
	cin >> n >> m;
	Graph g(3 * n);
	int u, v;
	ForLong(i, m)
	{
		cin >> u >> v;
		--u;
		--v;
		g[3 * u].push_back(3 * v + 1);
		g[3 * u + 1].push_back(3 * v + 2);
		g[3 * u + 2].push_back(3 * v);
	}
	cin >> s >> t;
	--s;
	--t;

	int steps = bfs(g, 3 * s, 3 * t);
	if (steps > 0)
	{
		steps /= 3;
	}
	cout << steps << endl;

	return 0;
}


Measured memory_bytes: 17792
from collections import defaultdict
import bisect
s = input()
t = input()
ls = len(s)
dbls = s*2
idx = 0
ans = 0
dic = defaultdict(list)

for i, c in enumerate(dbls):
    dic[c] += [i+1]

for c in t:
    if not c in dic.keys():
        print(-1)
        exit()
    lst = dic[c]
    i = bisect.bisect_right(lst, idx)
    idx = lst[i]
    if idx > ls:
        ans += ls
        idx -= ls
    else:
        idx = lst[i]

if not idx == 0:
    ans += idx
print(ans)


Measured memory_bytes: 12404