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

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,int> PLI;
const int MN=51;
const int MM=101;
const int MA=51;
const int MC=2*MN*MA;
const int MV=MN*MC+5;
const LL INF=0x3f3f3f3f3f3f3f3f;
// sp at most go through less tahn 2n node 2n-1 edges?
// V = 50*2*50*50=250 000
// E = 100*2*50*50=500 000

vector<PII> g[MV];

int n,m,s;

inline int id(int u,int val)
{
	return u*(MC)+val;
}

LL dis[MV];
int vis[MV];
priority_queue<PLI,vector<PLI>,greater<PLI>> qu; 
void dij(int st,int v)
{
	memset(dis,INF,sizeof(dis));
	qu.push({0,id(st,v)});
	dis[id(st,v)]=0;
	while(!qu.empty())
	{
		PLI p=qu.top(); qu.pop();
		int u=p.second;
		LL d=dis[u];
		if(vis[u]) continue;
		vis[u]=1;
		for(auto e:g[u])
		{
			int v=e.first;
			LL w=e.second;
			if(vis[v]) continue;
			if(dis[v]>d+w)
			{
				dis[v]=d+w;
				qu.push({dis[v],v});
			}
		}
	}
}

int main()
{
	scanf("%d%d%d",&n,&m,&s);
	int u,v,a,b;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d%d%d",&u,&v,&a,&b);
		for(int i=0;i+a<MC;i++)
		{
			g[id(u,i+a)].push_back({id(v,i),b});
			g[id(v,i+a)].push_back({id(u,i),b});
		}
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a,&b);
		for(int j=0;j+a<MC;j++)
			g[id(i,j)].push_back({id(i,j+a),b});
	}
	if(s>=MC) s=MC-1;
	dij(1,s);
	for(int i=2;i<=n;i++)
	{
		LL mi=INF;
		for(int j=0;j<MC;j++)
			mi=min(mi,dis[id(i,j)]);
		printf("%lld\n",mi);
	}
	return 0;
}

Measured memory_bytes: 33792
#include<stdio.h>
#define INF 10000000
void warshall_floyd(void);
int min(int,int);
int graph[101][101];
int n,c,d;

int main(void){
  int k,i,j,x,e,a,b;

  while(1){

    scanf("%d %d",&n,&k);
    if(n==0 && k==0)break;

    for(i=0;i<=n;i++)
      for(j=0;j<=n;j++)
	graph[i][j] = (i==j?0:INF);

    for(i=0;i<k;i++){
      scanf("%d",&x);
      
      if(x){
	scanf("%d %d %d",&c,&d,&e);
	if(graph[c][d]>e){
	graph[c][d]=graph[d][c]=e;
	warshall_floyd();
	}
      }
      else{
	scanf("%d %d",&a,&b);
	if(graph[a][b]<INF)printf("%d\n",graph[a][b]);
	else printf("-1\n");
      }

    }

  }
  
  return 0;
}

void warshall_floyd(void){
  int i,j;

    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
	graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
      }
    }
}

int min(int x,int y){
  return (x<y)?x:y;
}

Measured memory_bytes: 456
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  string S;
  ll K;
  cin >> S >> K;
  if(K<S.size()) S=S.substr(0,K);

  for(int i=0;i<S.size() && i<K;++i){
    if(S.at(i)=='1') continue;
    cout << S.at(i) << endl;
    return 0;
  }

  cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		String p = scan.nextLine();
		s += s.substring(0, s.length() - 1);
		if(s.indexOf(p) == -1){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 26316
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main() {
    ll N;
    cin >> N;
    vector<ll>A(N);
    vector<ll>B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end(), greater<ll>());
    if (N % 2 == 0) {
        ll a, b, c, d; 
        double x, y;
        a = A[N/2-1];
        b = B[N-(N/2-1)-1];
        c = A[N-(N/2-1)-1];
        d = B[N/2-1];
        cout << (b+d)-(a+c)+1 << endl;;
    } else {
        cout << B[N/2] - A[N/2] + 1 << endl;
    }
}


Measured memory_bytes: 6356
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace

solve :: Int -> [[Int]] -> Int
solve n ass = case sum of
                Just x -> x
                Nothing -> -1
  where
  vec = VU.fromListN (n*n) (concat ass)
  enc i j = i * n + j
  dist i j = vec VU.! (enc i j)
  road (i,j) = and <$> mapM f [0..n-1] >>= ite231 (Just d) (Just 0)
    where
      d = dist i j
      f k | k == i || k == j = Just True
          | d < tri = Just True
          | d == tri = Just False
          | otherwise = Nothing
        where tri = dist i k + dist k j
  indices = [(i,j) | i <- [0..n-1], j <- [i+1..n-1]]
  sum = foldl' (+) 0 <$> mapM road indices


ite231 t e c = if c then t else e

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n]:remLines1 = remLines0
      n = readBInt bs_n
      ass = map (map readBInt) remLines1
  in solve n ass

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 3708
N = int(input())
H = list(map(int, input().split()))
# print(N, H)

ans = 0
last = H[0]
count = 0
for i in range(1, N):
    if last >= H[i]:
        # print('keep', i, last, H[i], count)
        count += 1
    else:
        # print('reset', i, last, H[i], count)
        ans = max(ans, count)
        count = 0
    last = H[i]
    if i == N - 1:
        ans = max(ans, count)

print(ans)


Measured memory_bytes: 63856
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
	int i,j,n,k,a[101]; bool dp[lim] = {};
	cin>>n>>k;
	for(i=0; i<n; i++) cin>>a[i];
	dp[0] = 0;
	for(i=1; i<=k; i++){
		bool check = 1;
		for(j=0; j<n && (i>=a[j]); j++) check &= dp[i-a[j]];
		dp[i] = !check;		
	}
	cout<<(dp[k]?"First":"Second");
}

Measured memory_bytes: 384
<?php
list($n, $m) = ints();
for($i = 0; $i <= $m; $i++){
  $map[$i] = [];
}
for($i = 0; $i < $n; $i++){
  list($a, $b) = ints();
  $map[$m-$a][] = $b;
}
$pq = new SplPriorityQueue();
$pq->setExtractFlags(SplPriorityQueue::EXTR_PRIORITY);
$size = 0;
$sum = 0;
for($i = $m; $i>=0; $i--){
  foreach($map[$i] as $money){
    $pq->insert($money, $money);
    $size++;
  }
  if($size>0){
    $mm = $pq->extract();
    $size--;
    $sum+=$mm;
  }
}
printf("%d", $sum);


function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    int r;
    cin >> r;
    SPC(18);
    out(2 * r * PI);

    return 0;
}


Measured memory_bytes: 3796
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] field = new char[h][];
		for (int i = 0; i < h; i++) {
		    field[i] = sc.next().toCharArray();
		}
		boolean[][] ans = new boolean[h + 2][w + 2];
		for (int i = 2; i <= h; i++) {
		    Arrays.fill(ans[i], true);
		    ans[i][0] = false;
		    ans[i][w + 1] = false;
		}
		for (int i = 1; i <= h; i++) {
		    for (int j = 1; j <= w; j++) {
		        if (field[i - 1][j - 1] == 'o') {
		            ans[i][j - 1] = false;
		            ans[i][j] = false;
		            ans[i][j + 1] = false;
		        } else if (field[i - 1][j - 1] == 'x') {
		            for (int k = i - 1; k <= i + 1; k++) {
		                for (int l = j - 1; l <= j + 1; l++) {
		                    ans[k][l] = false;
		                }
		            }
		        }
		    }
		}
		int count = 0;
		for (int i = 1; i <= h; i++) {
		    for (int j = 1; j <= w; j++) {
		        if (ans[i][j]) {
		            count++;
		        }
		    }
		}
        System.out.println(count);
	}
}



Measured memory_bytes: 28280
#include <stdio.h>

int main(){
  int n,h[100000],flag=1,
      i;
  
  scanf("%d",&n);
  
  scanf("%d",&h[0]);
  h[0]--;
  for(i=1;i<n;i++){
    scanf("%d", &h[i]);
    if(h[i-1] < h[i]){
      h[i]--;
    }
  }
  
  for(i=1;i<n;i++){
    if(h[i-1] > h[i]){
      flag=0;
    }
  }
  if(flag){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 512
// Made by Luis Miguel Baez
// es.luismiguelbaez@gmail.com

#include <bits/stdc++.h>
 
using namespace std;

#define endl '\n'
#define precise(n,k) fixed << setprecision(k) << n
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define uint  unsigned int
#define ll    long long
#define ull   unsigned long long
#define ld    long double

#define pii   pair<int, int>
#define piii  pair<int, pair<int, int>>
#define pll   pair<ll, ll>

#define F  first
#define S  second
#define PB push_back
#define MP make_pair

#define debug(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(bool b) {
    return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename T>
string to_string(const vector<T> &v) {
    bool first = true;
    string res = "{";
    for (const T &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string((T)x);
    }
    res += "}";
    return res;
}

// add templates here

template<class T>
void println(const T &data) {
    cout << to_string((T)data) << endl;
}

template <typename T>
void write(vector<T> &v, bool size=true) {
    if(size) cout << v.size() << endl;
    string res = "";
    for(const T &x: v) {
        res += to_string((T)x) + " ";
    }
    cout << res << endl;
}


const int MOD = int(1e9+7);
const int oo  = int(1e9 + 20);
const ll lloo  = (ll)(1e18 + 10);

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

    ld N, D;
    cin >> N >> D;
    
    cout << ceil(N/(D*2.0+1.0)) << endl;
    

    return 0;
}

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

using namespace std;

#define PI 3.1415926535897932384626433

int main()
{
    cout << fixed << setprecision(9);

    long double A, B, H, M;

    cin >> A >> B >> H >> M;

    long double angle_minute = M * 6;
    long double angle_hour = H * 30 + M * 0.5;
    long double angle = abs(angle_hour - angle_minute) * PI / 180;

    ///cout << angle_hour << " " << angle_minute << '\n';

    long double ans = sqrt(A * A + B * B - 2 * A * B * cos(angle));

    cout << ans;
    return 0;
}


Measured memory_bytes: 4136
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a; cin >> a;
    if (N == 1) {
        cout << a << endl;
        return 0;
    }
    int ans = 1;
    int i = 2;
    int r = 1;
    rep(k, N) {
        r *= i;
        if (r > a) {
            cout << 1 << endl;
            return 0;
        }
    }

    while(a >= r) {
        if (a % r == 0) ans = i;
        i++;
        r = (pow(i, N) + 0.5);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int A,B,C,D,E,f,g;
    cin >>A>>B>>C>>D>>E;
    f=0;
    g=abs(A);
    if(A<0){f=f+C*g;}
    if(A<1){f=f+D;}
    if(A<1){f=f+B*E;}else{f=f+(B-A)*E;}
    cout<<f<<endl;
}



Measured memory_bytes: 3096
class Array
  def med; n = size; s = sort; n.odd? ? s[n/2] : (s[n/2] + s[n/2-1]) / 2.0 end
end

n = gets.to_i
a = gets.split.map(&:to_i)

r = a.map.with_index{|t,i| t -= i + 1 }.sort

f = r.med.floor
c = r.med.ceil

ans_f = r.inject(0){|s,t| s += (t-f).abs  }
ans_c = r.inject(0){|s,t| s += (t-c).abs  }

puts [ans_f, ans_c].min

Measured memory_bytes: 23800
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return [init]*size1
  else
    return [[init]*size2]*size1
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

X,N=get_i
p=get_i
min=INF
ans=-1
-100.upto(200) do|i|
    if not p.include?(i) and min>(X-i).abs
        ans=i
        min=(X-i).abs
    end
end
puts ans

Measured memory_bytes: 14400
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>

int pw(int n) {
    if(n==0) {
        return 1;
    }
    int i;
    int ans = 1;
    for(i=0; i<n; i++) {
        ans *= 100;
    }
    return ans;
}

int main(void){
    int D, N;
    scanf("%d %d", &D, &N);
    if(N == 100) {
        N += 1;
    }

    printf("%d\n", pw(D)*N);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <cmath>
#include <array>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI;
typedef pair<int,int> pii;
const int mod = (int)1e9+7;



int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a[3];
	string s;
	cin >> a[0]>>a[1]>>a[2];
	sort(a, a+3);
	if(a[0]==5 && a[1]==5 && a[2]==7) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, a[101][101];
	int ab, i, j, k, b;
	int u[101][101] = {0};

	scanf("%d", &n);

	for (i = 1; i <= n; i++)
	{
		scanf("%d", &ab);
		scanf("%d", &b);
		for (j = 1; j <= b; j++)
		{
			scanf("%d", &k);
			u[ab][k] = 1;
		}
	}

	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			printf("%d", u[i][j]);
			if  (j != n)
				putchar(' ');
		}
		putchar('\n');
	}
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  char S[N+1];
  cin >> S;

  int ans = 0;
  char sec_num[4];
  for (int i = 0; i < 10; i++) {
    sec_num[0] = char(i+48);
    for (int j = 0; j < 10; j++) {
      sec_num[1] = char(j+48);
      for (int k = 0; k < 10; k++) {
	sec_num[2] = char(k+48);
	sec_num[3] = '\0';
	int indx = 0;
	for (int l = 0; l < N; l++) {
	  if (sec_num[indx] == S[l]) {
	    indx++;
	  }
	  if (indx == 3 ) {
	    ans++;
	    break;
	  }
	}
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast  \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int main()
{
    fast
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    while(a>0)
    {
        a -= d;
        c -= b;
        if (c <= 0)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

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


def f(x):
    li = [i for i in range(1, x + 1) if x % i == 0]
    # print(li)
    return len(li)


cnt = 0

for i in range(1, n + 1, 2):
    if f(i) == 8:
        cnt += 1

print(cnt)


Measured memory_bytes: 2940
for i in range(int(input())):
    t, x, y = map(int, input().split())
    if x + y > t or (x + y) % 2 != t % 2:
        can = 0
        break
    else:
        can = 1
if can == 0: print("No")
elif can == 1: print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  map<string, int> poll;
  
  cin >> N;
  vector<string> S(N);
  for(int i=0; i<N; i++)
    cin >> S.at(i);
  
  for(auto x : S){
    if(poll.count(x))
      poll[x]++;
    else
      poll[x] = 1;
  }
  int tmp =0;
  for(auto x : poll){
    if(x.second > tmp)
      tmp = x.second;
  }
  
  vector<string> A;
  for(auto x : poll){
    if(x.second == tmp) A.push_back(x.first);
  }
  
  for(auto x : A)
    cout << x << endl;
}

Measured memory_bytes: 28404
N = int(input())
S = input()
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            
            if str(i) in S:
                x = S.index(str(i))
                if str(j) in S[x+1:]:
                    y = S[x+1:].index(str(j))+x+1
                    if str(k) in S[y+1:]:
                        ans+=1
           

print(ans)
                    
                   

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

using namespace std;
using p=pair<int,int>;
typedef long long ll;

int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll>h(n);
  rep(i,n){
    cin >> h[i];
  }
  sort(h.begin(),h.end());
  ll m=0;
  rep(i,n-k){
    m+=h[i];
  }
  cout << m << endl;
    
 
  return 0;

}

Measured memory_bytes: 4808
#include <bits/stdc++.h>
#include <set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
#define mod 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<n;i++)
using namespace std;
void fastio()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

}
ll int multiply(ll int a,ll int b)
{
	ll int ans=(a%mod*b%mod)%mod;
	return ans;
}
ll int add(ll int a, ll int b)
{
	ll int ans=(a%mod+b%mod)% mod;
	return ans;
}
 
void solve()
{
	string s,t;
	cin>>s>>t;
	ll int n=s.size();
	ll int m=t.size();
	ll int dp[n+1][m+1];
	memset(dp,0,sizeof dp);
	ll int i,j;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=m;j++)
		{
			if (i==0 || j==0)
				dp[i][j]=0;
			else
			{
				if (s[i-1]==t[j-1])
					dp[i][j]=1+dp[i-1][j-1];
				else
				{
					ll int op1=dp[i-1][j];
					ll int op2=dp[i][j-1];
					dp[i][j]=max(op1,op2);
				}
			}
		}
	}
	// rep(i,n+1)
	// {
	// 	rep(j,m+1)
	// 	cout<<dp[i][j]<<" ";
	// 	cout<<endl;
	// }
	string ans="";
	// cout<<ans<<endl;
	i=n,j=m;
	while(i>0 && j>0)
	{
		if (dp[i][j]==dp[i-1][j])
		{
			i--;
		}
		else if (dp[i][j]==dp[i][j-1])
		{
			j--;
		}
		else
		{
			ans+=s[i-1];
			i--;
			j--;
		}

	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;


}

int main()
{ 
	fastio();
    ll int t;
    // cin>>t;
    t=1;
    while(t--)
    {
    	solve();
    }
}

	
		
	
	
	
	





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

using namespace std;

const int N = 1e6 + 6, H = 1e8 - 1;

const double PI = acos(-1);
int m;
int seg[N << 2];
void build(int id = 1, int l = 0, int r = m) {
  seg[id] = 0;
  if (r-l < 2)
    return;
  int mid = (l + r) >> 1, il = id << 1, ir = il | 1;
  build(il, l, mid);
  build(ir, mid, r);
  seg[id] = max(seg[il], seg[ir]);  
}
void upd(int x, int val, int id = 1, int l = 0, int r = m) {
  if (r-l < 2) {
    seg[id] = val;
    return;
  }
  int mid = (l + r) >> 1, il = id << 1, ir = il | 1;
  if (x < mid)
    upd(x, val, il, l, mid);
  else
    upd(x, val, ir, mid, r);
  seg[id] = max(seg[il], seg[ir]);  
}

int get(int x, int y, int id = 1, int l = 0, int r = m) {
  if (x >= r || l >= y) return 0;
  if (x <= l && r <= y) return seg[id];
  int mid = (l + r) >> 1, il = id << 1, ir = il | 1;
  return max(get(x, y, il, l, mid), get(x, y, ir, mid, r));
}


int a, b, c, d, n;
int x[N], y[N], id[N], tmp[N];
bool cmp(int l, int r) {
  return x[l] < x[r];
}

int getid(vector<int>&v, int a) {
  return lower_bound(v.begin(), v.end(), a) - v.begin();
}


int main() {
  scanf("%d %d %d %d", &a, &b, &c, &d);
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d %d", x+i, y+i), id[i] = i;
  if (a > c) {
    swap(a, c);
    swap(b, d);
  }
  if (b > d) {
    b = H - b;
    d = H - d;
    for (int i = 0; i < n; i++)
      y[i] = H - y[i];
  }
  sort(id, id+n, cmp);
  for (int i = 0; i < n; i++)
    tmp[i] = x[id[i]];
  for (int i = 0; i < n; i++)
    x[i] = tmp[i];
  for (int i = 0; i < n; i++)
    tmp[i] = y[id[i]];
  for (int i = 0; i < n; i++)
    y[i] = tmp[i];
  vector<int> vx, vy;
  vx.push_back(a);
  vx.push_back(c);
  vy.push_back(b);
  vy.push_back(d);
  for (int i = 0; i < n; i++) {
    vx.push_back(x[i]);
    vy.push_back(y[i]);
  }
  int dx = c-a, dy = d-b;
  double ans = (double)100.0 * ((c-a) + (d-b));
  sort(vx.begin(), vx.end());
  vx.erase(unique(vx.begin(), vx.end()), vx.end());
  sort(vy.begin(), vy.end());
  vy.erase(unique(vy.begin(), vy.end()), vy.end());
  a = getid(vx, a);
  b = getid(vy, b);
  c = getid(vx, c);
  d = getid(vy, d);
  for (int i = 0; i < n; i++) {
    x[i] = getid(vx, x[i]);
    y[i] = getid(vy, y[i]);
  }
  m = vy.size();
  int bst = 0;
  build();
  for (int i = 0; i < n; i++) {
    if (a <= x[i] && x[i] <= c && b <= y[i] && y[i] <= d) {
      int val = get(0, y[i]+1) + 1;
      bst = max(val, bst);
      upd(y[i], val);
    } 
  }
  if (bst == min(dx, dy)+1)
    ans += PI * 5;
  ans += bst * (PI * 5 - 20);
  printf("%.20lf\n", ans);
  return 0;
}

Measured memory_bytes: 19180
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

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

    int h, w;
    cin >> h >> w;

    vector<P> A;
    char C[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> C[i][j];
            if(C[i][j] == 'B'){
                A.push_back({i, j});
            }
        }
    }

    int a = A.size(), ans = 0;
    for(int i = 0; i < a; i++){
        for(int j = i + 1; j < a; j++){
            ans = max(ans, abs(A[i].first - A[j].first) + abs(A[i].second - A[j].second));
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int s[7];
int main(){
    int sum=0;
    rep(i,6) cin>>s[i],sum+=s[i];
    sum-=*min_element(s,s+4)+min(s[4],s[5]);
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
#include<string.h>
int main(){
    int  x[10000],y[10000],i=0,j=0,a[10000];
    char op[10000];

    while(1){
        scanf("%d%s%d",&x[i],op,&y[i]);
        if(strcmp(op,"?")==0){
            break;
        }
        if(strcmp(op,"+")==0){
            a[i]=x[i]+y[i];
        }else if(strcmp(op,"-")==0){
            a[i]=x[i]-y[i];
        }else if(strcmp(op,"*")==0){
            a[i]=x[i]*y[i];
        }else if(strcmp(op,"/")==0){
            a[i]=x[i]/y[i];
        }
        i++;
    }

    for(j=0;j<i;j++){
        printf("%d\n",a[j]);
    }

    return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int h, w;
    cin >> h >> w;
    vstr s(h);
    rep(i, h) cin >> s[i];
    vvint vh(h, vint(w, 0));
    vvint vw(h, vint(w, 0));
    rep(i, h) {
        rep(j, w) {
            if (j == 0) {
                if (s[i][j] == '.') vh[i][j] = 1;
                else vh[i][j] = -1;
                continue;
            }
            if (s[i][j] == '.') {
                if (vh[i][j-1] == -1) vh[i][j] = 1;
                else vh[i][j] = vh[i][j-1]+1;
            }
            else vh[i][j] = -1;
        }
        rrep(j, w) {
            if (j == w-1) continue;
            if (s[i][j+1] == '#' || s[i][j] == '#') continue;
            vh[i][j] = vh[i][j+1];
        }
    }
    
    rep(j, w) {
        rep(i, h) {
            if (i == 0) {
                if (s[i][j] == '.') vw[i][j] = 1;
                else vw[i][j] = -1;
                continue;
            }
            if (s[i][j] == '.') {
                if (vw[i-1][j] == -1) vw[i][j] = 1;
                else vw[i][j] = vw[i-1][j]+1;
            }
            else vw[i][j] = -1;
        }
        rrep(i, h) {
            if (i == h-1) continue;
            if (s[i+1][j] == '#' || s[i][j] == '#') continue;
            vw[i][j] = vw[i+1][j];
        }
    }

    int ans = 0;
    rep(i, h) rep(j, w) ans = max(ans, vh[i][j]+vw[i][j]-1);

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

Measured memory_bytes: 35712
#include <bits/stdc++.h>
using namespace std;
const int INF=1<<30;
typedef pair<int,int> P;
typedef pair<P,int> PP;
int main() {
  int n,m;
  bool ff=0;
  while(cin >> n && n) {
    cin >> m;
    if(ff) cout << endl;
    ff=1;
    int a[n+1][m+1],cnt=0;
    for(int i=0; i<=n; i++) {
      for(int j=0; j<=m; j++) {
        string s;
        cin >> s;
        if(s[0]=='?') {
          a[i][j]=INF;
          cnt++;
        } else {
          stringstream ss;
          ss << s;
          ss >> a[i][j];
        }
      }
    }
    vector<PP> ans;
    while(1) {
      bool ck=0;
      for(int i=0; i<n; i++) {
        for(int j=0; j<m; j++) {
          if(a[i][j]==INF) {
            bool f=1;
            for(int k=0; k<m; k++) {
              if(j!=k&&a[i][k]==INF) f=0;
            }
            if(f) {
              int sum=a[i][m];
              for(int k=0; k<m; k++) {
                if(j!=k) sum-=a[i][k];
              }
              a[i][j]=sum;
              ans.push_back(PP(P(i,j),a[i][j]));
              ck=1;
              continue;
            }
            f=1;
            for(int k=0; k<n; k++) {
              if(i!=k&&a[k][j]==INF) f=0;
            }
            if(f) {
              int sum=a[n][j];
              for(int k=0; k<n; k++) {
                if(i!=k) sum-=a[k][j];
              }
              a[i][j]=sum;
              ans.push_back(PP(P(i,j),a[i][j]));
              ck=1;
            }
          }
        }
      }
      if(!ck) break;
    }
    if(ans.size()!=cnt) cout << "NO" << endl;
    else {
      sort(ans.begin(),ans.end());
      for(int i=0; i<ans.size(); i++) cout << ans[i].second << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1228
#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define li long long int
#define pb push_back
const li limit=999999;

int main() {
    li t,i,j,l=0;
    li N,M,K,Z;
    cin>>N; 
    K=7%N;
    li ct=1;
    while(K != 0 && ct<limit)
    {
        K=(K*10)%N;
        K=(K+7)%N;
        ct++;
    }
    if(ct == limit)
    cout<<"-1";
    else
    cout<<ct;
    return 0;
}


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

using namespace std;

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

	int max = N, min = 1;

	for (int i = 1; i <= M; i++)
	{
		int l, r;
		cin >> l >> r;

		if (l > min)
			min = l;
		if (r < max)
			max = r;
	}

	if (max >= min)
	{
		cout << max - min + 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine

calc table (x : xs) = do
  count_x <- VUM.read table (x -1)
  VUM.write table (x -1) (count_x + 1)
  when (xs /= []) $ calc table xs

printCount table n n' = do
  count_n <- VUM.read table n'
  print count_n
  when (n /= n') $ printCount table n (n' + 1)

main = do
  [n, m] <- getIntList
  xss <- getIntNList m
  let xss' = concat xss
  table <- VUM.replicate n 0 :: IO (VUM.IOVector Int)
  calc table xss'
  printCount table (n -1) 0


Measured memory_bytes: 508
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
      
      if(a==b){
        System.out.print(c);
      }
      if(c==b){
        System.out.print(a);
      }
      if(a==c){
        System.out.print(b);
      }
      
		
      
    }
}

Measured memory_bytes: 21844
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    s = input()
    for i in range(1, len(s)):
        if s[i] == s[i-1]:
            print('Bad')
            exit()
    print('Good')

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define Speed_UP  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define 	pb	push_back 
#define 	ff	first 
#define 	ss	second 
#define sz(x) (int)x.size()
#warning Remeber to change t
using namespace std;
typedef long long ll;
inline void setIO(string name="") {
	#ifndef ONLINE_JUDGE 
	freopen((name+".in").c_str(), "r", stdin); 
	freopen((name+".out").c_str(), "w", stdout);
	#endif
	}
	ll const mx=1e5+7;
	ll freq[mx];
int main(){
	Speed_UP
	ll t;
	t=1;
	while(t--){
		ll n;
		cin>>n;
		for(int i=0;i<n;i++){
			ll x;
			cin>>x;
			freq[x]++;
			freq[x+1]++;
			freq[x-1]++;
		}
		ll ans=0;
		ll cand=0;
		for(int i=0;i<mx;i++){
			if(freq[i]>ans){
				ans=freq[i];
				cand=i;
			}
		}
		cout<<ans;
		
		
		
	}





}


Measured memory_bytes: 4296
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define rev_all( x ) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;

const int inf = 1e9 + 5;
const long double PI = 3.141592653589793;

void solve(){
  int n, ans = 0;
  cin >> n;
  vector<int> a(n);
  for(int& x:a){
    cin >> x;
  }
  sort(all(a), greater<int>());
  ans += a[0];
  n-=2;
  int i = 1;
  while(n > 0){
    ans += a[i];
    n--;
    if(n > 0){
      ans+=a[i];
      n--;
    }
    i++;
  }
  cout << ans << endl;
  return;
}  
signed main(){
  fast;
  int t;
  t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 4784
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	int C0 = 0;
	int C1 = 0;
	int C2 = 0;
	int C3 = 0;

	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;

		if (S == "AC") {
			C0++;
		}
		else if (S == "WA") {
			C1++;
		}
		else if (S == "TLE") {
			C2++;
		}
		else if (S == "RE") {
			C3++;
		}
	}

	cout << "AC x " << C0 << endl;
	cout << "WA x " << C1 << endl;
	cout << "TLE x " << C2 << endl;
	cout << "RE x " << C3 << endl;
}


Measured memory_bytes: 3540
/*i-=-1*/
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define in(n) for(int i=0;i<n;i++)
#define inj(n) for(int j=0;j<n;j++)
#define itn int
#define ll long long 
#define ull unsigned ll
#define int ull int
#define S second 
#define F first 
#define mod 1000000007ull
#define globalbool 2000000
#define pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
using namespace std::chrono;
//int pow()
int ans=0;
int poww(int x,int y,int m=mod) 
{ 
    if (y == 0) 
        return 1; 
    int p = poww(x, y / 2, m) % m; 
    p = (p * p) % m; 
  
    return (y % 2 == 0) ? p : (x * p) % m; 
}
int  modInverse(int a, int m=mod) 
{ 
    return poww(a, m - 2, m); 
}
int cnt(int n)
{
    if(n==0)
        return 1ll;
    
    //int pp=n/2;
    int temp=cnt(n/2);
    temp*=temp;
    temp%=mod;
    if(n%2)
    {
        return (2*temp)%mod;
    }
    return temp;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	auto start = high_resolution_clock::now();
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    int N=2*100000+10;
    int A[N]={0};
    int fact[N]={0};
    fact[0]=A[0]=1;
    for(int i=1;i<=N;i++)
    {
      fact[i]=fact[i-1]*i;
      fact[i]%=mod;
    }
    //cout<<"HERE"<<n<<endl;
    for(int i=1;i<=N;i++)
    {
      A[i]=A[i-1]*(n-i+1);
      A[i]%=mod;
    }
    int inva=modInverse(fact[a]),invb=modInverse(fact[b]);
    // in(10)
    //     cout<<fact[i]<<' ';
    // cout<<endl;
    // in(10)
    //     cout<<A[i]<<' ';
    // cout<<endl;
    //int p=poww(n);
    int numOfWays=cnt(n);
    //cout<<numOfWays<<endl;
    numOfWays--;
    inva*=A[a];
    invb*=A[b];
    inva%=mod;
    invb%=mod;
    cout<<(numOfWays-inva-invb+2*mod)%mod;
	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: 3328
#include <bits/stdc++.h>
using namespace std;

int main(){

    float n, t;
    float din = 0;
    scanf("%f", &n);
    for(int i = 0; i < n; i++){
        scanf("%f", &t);
        din += 1 / t;
    }
    printf("%.9f", 1 / din);

    return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define per(i,l,r) for (int i=l;i>=r;i--)
using namespace std;
typedef long long ll;
int n,x,ans;
int a[200500];
map<int,int> mp;
bool cmp(int x,int y){
    return x>y;
}
int main(){
    scanf("%d",&n);
    rep(i,1,n) scanf("%d",&a[i]);
    sort(a+1,a+1+n,cmp);
    rep(i,1,n) {
        int gg=0;
        per(j,30,0) {
            if ((1<<j)>a[i]&&mp[(1<<j)-a[i]]) {
                mp[(1<<j)-a[i]]--;
                ans++;
                gg=1;
                goto o;
            }
        }
        o:;
        if (!gg) mp[a[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 29824
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1] * (n + 1)
    self.rnk = [0] * (n + 1)

  def Find_Root(self, x):
    if self.root[x] < 0:
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]

  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if x == y:
      return 
    elif self.rnk[x] > self.rnk[y]:
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if self.rnk[x] == self.rnk[y]:
        self.rnk[y] += 1

  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)

  def Count(self, x):
    return -self.root[self.Find_Root(x)]

uf = UnionFind(N)
Q = [tuple(map(int, input().split())) for _ in range(M)]
Q.reverse()
res = [0]
for u, v in Q:
  x = res[-1]
  if uf.isSameGroup(u, v): res.append(x)
  else:
    res.append(uf.Count(u) * uf.Count(v) + x)
  uf.Unite(u, v)
res.reverse()
for i in range(1, M + 1):
  print(N * (N - 1) // 2 - res[i])

Measured memory_bytes: 108780
#ITP1_9_A
import sys

W = input()
T = []
while True:
    line = input()
    if line == "END_OF_TEXT":
        break
    T.append(line)
    
count = 0
for line in T:
    #line = line.strip("\n")
    words = line.split()
    for word in words:
        if W == word.lower():
            count+=1
print(count)


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


int main(){
  int n,i;
  cin >> n;
  vector<int> a(n),b(n);
  for(i=0;i<n;++i){
    cin >> a[i];
  }
  int j=0;
  int k=1;
  i=n/2;
  while(j<n){
    b[i]=a[j];
    j++;
    if(n%2==0){
      k=k*(-1);
      i=i+k;
      if(k>0){
        k++;
      }else{
        k--;
      }
    }else{
      i=i+k;
      k=k*(-1);
      if(k>0){
        k++;
      }else{
        k--;
      }
    }
  }
  for(i=0;i<n;++i){
    cout << b[i] ;
    if(i!=n-1){
      cout << " " ;
    }else{
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3712
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        Console.ReadLine();
        var nArray = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        var cnt = 0;
        while (nArray.All(n => n % 2 == 0))
        {
            cnt++;
            for (int i = 0; i < nArray.Length; i++)
            {
                nArray[i] = nArray[i] / 2;
            }
        }

        Console.WriteLine(cnt);
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define pri 1000000007
#define all(x) x.begin(),x.end()
#define mnx 1000001
#define pr pair<ll,ll>
#define ez 
#define prin(x) cout<<setprecision(11)<<fixed<<x<<" ";
using namespace std;


void masterstroke()
{   ll w,h,x,y;
	cin>>w>>h>>x>>y;
	ll un=0;
	if(w%2==0&&h%2==0&&x==(w/2)&&y==(h/2)){
		un=1;
	}
	double long area=(w*h)/2.0;
	prin(area);
	cout<<un<<endl;
}


int main(){

	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)
	masterstroke();

}


Measured memory_bytes: 256
n,k=map(int,input().split())
A=list(map(int,input().split()))

if n==k:
    print(1)
else:
    if (n-k)%(k-1)!=0:
        print(int((n-k)/(k-1))+2)
    else:
        print(int((n-k)/(k-1))+1)

Measured memory_bytes: 13812
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

s = S()
q = I()
flag = 0
ans = deque(s)

for i in range(q):
    query = input()
    if query[0] == '1':
        flag = flag ^ 1  # flagを反転
    else:
        if (query[2] == '1' and not flag) or (query[2] == '2' and flag):
            ans.appendleft(query[4])
        else:
            ans.append(query[4])

if not flag:
    print("".join(ans))
else:
    print("".join(reversed(ans)))


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<int> vd(n);
  for (int i = 0; i < n; i++) {
    cin >> vd[i];
  }

  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += vd[i] * vd[j];
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	int a, b, c, k;
	cin >> a >> b >> c;
	cin >> k;
	
	int cnt = 0;
	while(b <= a) {
		cnt++;
		b *= 2;
	}
	while(c <= b) {
		cnt++;
		c *= 2;
	}
	cout << (cnt <= k ? "Yes" : "No");
}


Measured memory_bytes: 3648