akhauriyash/Code-Regression huggingface dataset:
public class Main {

  private static void solve() {
    char[] s = ns();
    int n = s.length + 1;

    int lastUp = -1;
    int[] a = new int[n];
    int cnt = 0;
    for (int i = 0; i < n - 1; i++) {
      if (s[i] == '<') {
        if (cnt > 0) {
          a[lastUp + 1] = Math.max(cnt, a[lastUp + 1]);
          for (int j = lastUp + 2; j < i; j++) {
            a[j] = --cnt;
          }
          cnt = 0;
        }
        a[i + 1] = a[i] + 1;
        lastUp = i;
      } else {
        cnt++;
      }
    }

    if (cnt > 0) {
      a[lastUp + 1] = Math.max(cnt, a[lastUp + 1]);
      for (int j = lastUp + 2; j < n; j++) {
        a[j] = --cnt;
      }
      cnt = 0;
    }

    // System.out.println(Arrays.toString(a));
    long ret = 0;
    for (int v : a) {
      ret += v;
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 30804
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define BUFSIZE 1000000


int dis[BUFSIZE]={0};
int N,K;
int cal(int start_pos){
  if(start_pos == N + 1)
    return 0;
  if(start_pos == 1 ){
    if(dis[N-1] - dis[0] > K - (dis[1] - dis[0]))
       return K - (dis[1] - dis[0]);
    else  return  dis[N-1] - dis[0];
  }
  if(start_pos == N){
    if(dis[N-1] - dis[0] > K - (dis[N-1] - dis[N-2]))
       return K - (dis[N-1] - dis[N-2]);
    else  return  dis[N-1] - dis[0];
  }





  if(dis[start_pos - 1] + dis[start_pos + 1] > dis[start_pos]*2 )
      return (K - (dis[start_pos + 1] - dis[start_pos]));
  else  return (K - (dis[start_pos] - dis[start_pos - 1]));

  cal(start_pos + 1);
}


int main(void){
  scanf("%d %d",&K,&N);

  for(int i = 0 ; i < N ; i++){
    scanf("%d",&dis[i]);
  }
  int answer = cal(1);
  for(int i = 1 ; i <= N ; i++) {
      if(answer >= cal(i)){

          answer = cal(i);
      }
  }
  printf(" %d",answer);
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;
const int MAX=1000000;

int main()
{
   int a[105];
   int n,d,x,ans;
   cin>>n>>d>>x;
   for(int i=0;i<n;i++)
    cin>>a[i];
    ans=x;
    for(int i=0;i<n;i++)
    {
        int j=0;
        while(a[i]*j+1<=d) {ans++;j++;}

    }

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


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

int main() {
  int N, M, sum = 0;
  int T[110];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> T[i];
    sum += T[i];
  }

  cin >> M;
  for (int i = 0; i < M; i++) {
    int P, X;
    cin >> P >> X;
    cout << sum - T[P - 1] + X << endl;
  }
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int cnt[30];
map<string, bool> mp;
signed main(void)
{
  int n, k;
  cin >> n >> k;
  REP(i, n) {
    string s;
    cin >> s;
    if(mp.find(s) == mp.end()) {
      cnt[s[0]-'A']++;
      mp[s] = true;
    }
  }

  int ret = 0;
  while(true) {
    sort(cnt, cnt+26, greater<int>());
    int tmp = 0;
    REP(i, 26) {
      if(tmp < k && cnt[i] > 0) {
        tmp++;
        cnt[i]--;
      }
    }
    if(tmp == k) ret++;
    else break;
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 1280
main = do
  n <- getLine >>= return . (read :: String -> Int)
  xs <- getLine >>= return . map (read :: String -> Int) . words
  insSort xs 1

printXs xs = putStrLn $ unwords $ map show xs

insSort xs n | n == length xs = printXs xs >> return ()
insSort xs n = do
  printXs xs
  let ys = insSort1 xs n
  insSort ys (n+1)

insSort1 :: [Int] -> Int -> [Int]
insSort1 xs n =
  insert (take n xs) (xs !! n) ++ (drop (n+1) xs)

insert :: [Int] -> Int -> [Int]
insert xs z =
  aux xs [] z
    where
      aux []   ys z = ys ++ [z]
      aux (x:xs) ys z = if z < x then ys ++ [z] ++ x:xs
                                 else aux xs (ys++[x]) z

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

template <class T>
struct SegmentTree{
  using F = function<T(T,T)>;
  F f;
  T inf;
  int n;
  vector<T> node;

  SegmentTree(vector<T> v,T inf,F f):inf(inf),f(f){
    n = 1; while(n < v.size()) n *= 2;
    node.resize(2*n-1,inf);
    for(int i = 0; i < v.size(); i++) node[i+n-1] = v[i];
    for(int i = n-2; i >= 0; i--) node[i] = f(node[2*i+1],node[2*i+2]);
  }

  void update(int k,T val){
    k += n-1;
    node[k] = val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  void add(int k,T val){
    k += n-1;
    node[k] += val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  T getval(int a,int b){ return getval(a,b,0,0,n); }
  T getval(int a,int b,int k,int l,int r){
    //区間[a, b)の値を返す
    if(r <= a || b <= l) return inf;
    if(a <= l && r <= b) return node[k];
    T vl = getval(a, b, 2*k+1, l, (l+r)/2);
    T vr = getval(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
  }
};

signed main(){

  int n,k; cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    a[i]--;
  }

  int ans = n+1;
  auto f = [](int x,int y){
    return x + y;
  };

  int j = 0;
  SegmentTree<int> seg(vector<int> (n,0),0,f);
  SegmentTree<int> seg2(vector<int> (n,0),0,f);
  for(int i = 0; i < n; i++){
    while(j < n && seg.getval(0,k) < k){
      seg.update(a[j],1);
      seg2.add(a[j],1);
      j++;
    }
    if(seg.getval(0,k) < k) continue;
    ans = min(ans,j - i);
    seg2.add(a[i],-1);
    if(seg2.getval(a[i],a[i]+1) <= 0) seg.update(a[i],0);
  }
  if(ans == n+1) ans = 0;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 8460
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
        int i;
        int height_of_mountain[10];

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

        sort(height_of_mountain, height_of_mountain+10);

        cout << height_of_mountain[9] << endl;
        cout << height_of_mountain[8] << endl;
        cout << height_of_mountain[7] << endl;

        return 0;
}

Measured memory_bytes: 3112
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑


int main() {



	int a, b;
	cin >> a >> b;
	for (int i = b - a + 1; i <= a + b - 1; ++i) {
		cout << i;
		if (i != a + b - 1) { cout << " "; }
	}
	cout << endl;









}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

string g;
int y, m, d;

int main() {
    while(1) {
        cin >> g;
        if(g == "#") break;
        cin >> y >> m >> d;
        if(y == 31) {
            if(m >= 5) {
                cout << "? 1 " << m << " " << d << endl;
            }else {
                cout << g << " " << y << " " << m << " " << d << endl;
            }
        }else if(y > 31) {
            cout << "? " << y-30 << " " << m << " " << d << endl;
        }else {
            cout << g << " " << y << " " << m << " " << d << endl;
        }
    }
}


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

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

int main() {
	ll i, j;
	ll A, P;
	cin >> A >> P;
	cout << (A * 3 + P)/2 << endl;

	return 0;
}


Measured memory_bytes: 256
# frozen_string_literal: true

n = gets.to_i
s = gets.chomp.chars

h = Hash.new {|h,k| h[k]=[]}

(0..(n - 1)).each do |i|
  h[s[i]].push i
end

count = h['R'].size * h['G'].size * h['B'].size

%w[R G B].permutation(3).each do |e|
  h[e[0]].each do |i|
    h[e[1]].each do |j|
      next if j < i

      k = j + j - i
      count -= 1 if k < n && s[k] == e[2]
    end
  end
end
puts count


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

int N;
int h[110];

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) cin >> h[i];
    int ans = 0;
    while (true) {
        bool update = false;
        rep(i, N) {
            if (h[i]>0 && h[i+1]==0) ans++;
            if (h[i]>0) {
                h[i]--;
                update = true;
            }
        }
        if (!update) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _139
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();
            int cnt = 0;
            { 
                if (S[0]== T[0]) 
                {
                    cnt += 1;
                }
                if (S[1] == T[1]) 
                {
                    cnt += 1;
                }
                if (S[2] == T[2]) 
                {
                    cnt += 1;
                }
                Console.WriteLine(cnt);
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <string.h>
#include <algorithm>


#define C "CORRECT"
#define W "WRONG"

#define T_MAX 55
#define P_MAX 15

struct TeamData
{
	int teamID;
	int ok;
	int kasan;
};

bool operator < (const TeamData& self,const TeamData& oth){  
    if(self.ok==oth.ok) {
    	if(self.kasan==oth.kasan) return self.teamID<oth.teamID;
    	return self.kasan<oth.kasan;
    }  
    return self.ok>oth.ok;
}

using namespace std;

int main(void)
{
	int t,p,r;
	int i1,i2;
	int tID,pID,tim;
	string s;

	int miss[T_MAX][P_MAX];


	while(1){
		cin >> t >> p >> r;
		if(t+p+r==0) break;

		vector<TeamData> team(t);
		memset(miss,0,sizeof(miss));
		

		for(i1=0;i1<t;i1++){
			team[i1].teamID=i1+1;
			team[i1].ok=0;
			team[i1].kasan=0;
		}


		for(i1=0;i1<r;i1++){
			cin >> tID >> pID >> tim >> s;

			if (s==C) {
				team[tID-1].ok++;
				team[tID-1].kasan+=(miss[tID][pID]*1200+tim);
				
			}
			else if(s==W) {
				miss[tID][pID]++;
			}
		}

		sort(team.begin(), team.end());

		for(i1=0;i1<t;i1++){
			cout << team[i1].teamID << " " << team[i1].ok << " " << team[i1].kasan << endl;
		}
	}
	return 0;

}

Measured memory_bytes: 1240
import bisect
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
A_cum = [0]
B_cum = [0]
A_cum[0] = A[0]
for j in range(len(A)-1):
    A_cum.append(A_cum[j]+ A[j+1])
B_cum[0] = B[0]
for l in range(len(B)-1):
    B_cum.append(B_cum[l] + B[l+1])
for i in range(len(A_cum)):
    k = A_cum[i]
    if k >K:
        break
    b = bisect.bisect(B_cum,K-k)
    check = i+b+1
    if check>ans:
        ans = check
check = bisect.bisect(B_cum,K)
if check>ans:
    ans = check    
print(ans)

Measured memory_bytes: 132676
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int n;
    cin>>n;
    cout<<n*n*n<<endl;

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

Measured memory_bytes: 256
require 'matrix'

while line = gets
  data = line.split.map(&:to_f)
  a = Matrix.rows([
    [data[0],data[1]],
    [data[3],data[4]]])
  y = Matrix.column_vector([data[2],data[5]])
  x = a.inv*y
  result = []
  x.each do |i|
    result << sprintf("%#.3f",i)
  end
  puts result.join(" ")
end

Measured memory_bytes: 6420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
AC
Pxが2番目となる範囲
*/

ll n,a[100010],ans=0;
map<ll,ll> m;
set<ll> s;

void init(){
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)m[a[i]]=i;
}

int main(void){
	init();
	s.insert(-1);
	s.insert(n);
	ireg(i,1,n){
		ll tmp=0,l2=-1,l=-1,r=n,rr=n;
		ll p = m[i];
		// cerr<<"==="<<i<<":"<<p<<"==="<<endl;
		s.insert(p);
		auto q = s.find(p);
		if(i!=n){
			auto itl = prev(q);
			if(*itl!=-1){
				l=*itl;
				itl--;
				l2=*itl;
			}
			auto itr = next(q);
			// cerr<<*itr<<endl;
			if(*itr!=n){
				r=*itr;
				itr++;
				rr=*itr;
			}
			if(l!=-1){
				tmp+=(l-l2)*(r-p);
			}
			if(r!=-1){
				tmp+=(rr-r)*(p-l);
			}
			// printf("%lld,%lld,%lld,%lld,\n",l2,l,r,rr);
		}
		// cerr<<"tmp: "<<tmp<<endl;
		ans+=tmp*i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11904
import math
a,b,x=map(float,input().split())
S=a**2
V=S*b
h=0
ans=0
if x>=V/2:
  h=2*(V-x)/S
  ans=math.atan(h/a)
  ans=ans/(math.pi)*180.0
  print(ans)
else:
  h=(2*(V-x)/b-S)/a
  h=a-h
  ans=math.atan(b/h)
  ans=ans/(math.pi)*180
  print(ans)

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 998244353

N, M, K = MAP()

lim = 2*10**5+10  # 必要そうな階乗の限界を入れる
fact = [1] * (lim+1)
fact_inv = [1] * (lim+1)
for n in range(1, lim+1):
	fact[n] = (fact[n-1] * n) % mod
fact_inv[lim] = pow(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
	fact_inv[n-1] = (n * fact_inv[n]) % mod
def C(n, r):
    return (((fact[n] * fact_inv[r]) % mod) * fact_inv[n-r]) % mod

ans = 0
for i in range(K+1):
	# print(i, C(N-1, i) * M * pow(M-1, N-i-1))
	ans += (C(N-1, i) * M)%mod * pow(M-1, N-i-1, mod)
	ans %= mod

print(ans)


Measured memory_bytes: 75128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int,int> vii;
typedef vector<ll,ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef set <int> :: iterator sitr;
typedef set <ll> :: iterator sltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef mset <int> :: iterator msitr;
typedef mset <ll> :: iterator msltr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
bool valida,validb;
str s;
str a,b;
int x,y;
int main(){
    cin>>s;
    x = ((int(s[0])-48)*10) + int((s[1])-48);
    y = ((int(s[2])-48)*10) + int((s[3])-48);

    if(x>=1 && x<=12){valida=true;}
    if(y>=1 && y<=12){validb=true;}

    if(valida && validb)printf("AMBIGUOUS\n");
    else if(valida && !validb)printf("MMYY\n");
    else if(!valida && validb)printf("YYMM\n");
    else if(!valida && !validb)printf("NA\n");
}


Measured memory_bytes: 256
fn divisor(n:i32) -> Vec<i32>{
    let mut v: Vec<i32> = Vec::new();
    let a = (n as f64).sqrt() as i32;
    for i in 1..a+1{
        if n%i != 0 {continue}
        v.push(i);
        if i*i == n{
            continue
        }
        v.push(n/i);
    }
    return v
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let n :i32 = s.trim().parse().unwrap();
    let mut ans = 0;
    for i in 1..n+1{
        if i%2 == 0 {continue}
        if divisor(i).len() == 8{
            ans += 1;
        }
    }
    println!("{}", ans);
}

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

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

int main(){

    int A,H;
    cin >> H >> A;
    int cnt = 0;

    while(1)
    {
        H -= A;
        cnt++;
        if(H<=0)       
            break;
    }

    cout << cnt << endl;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int N, K;
    cin >> N >> K;
    if(K == 1) {
        printf("%lld\n", 0);
    }
    else {
        printf("%lld\n", N - K);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
	char s[100001],a='a';
	int n,i,j,z=0;
	scanf("%s",s);
	n=strlen(s);
	for(i=0; i<=25; i++){
		a=a+i;
		for(j=0; j<n; j++){
			if(s[j]==a){
				z=1;
			}
		}
		if(z==0){
			printf("%c\n",a);
			return 0;
		}
		a='a';
		z=0;
	}
	printf("None\n");
	return 0;
}

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

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

void Empty(int *, int *);
void swap(int *, int *);
int Cal();
int DFS(int, int, int, int, int);

int main(){
  int i, j, l;
  int x, y, a;

for(i=0;i<3;i++)
  for(i = 0 ; i < 3 ; i++){
    for(j = 0 ; j < 3 ; j++){
      scanf("%d",&Puzzle[i][j]);
    }
  }

  Empty(&x,&y);

  for(l = 0 ; l < 100 ; l++){
    for(i = 0 ; i < 3 ; i++){
      for(j = 0 ; j < 3 ; j++){
 tmp[i][j] = Puzzle[i][j];
      }
    }

    a = DFS(x, y, -1, 0, l);
    if(a != -1){
      printf("%d\n",a);
      break;
    }

    for(i = 0 ; i < 3 ; i++){
      for(j = 0 ; j < 3 ; j++){
 Puzzle[i][j] = tmp[i][j];
      }
    }

    a = -1;
    if(l == 99) printf("%d\n",a);
  }

  return 0;
}

void Empty(int *x, int *y){
  int i, j;

  for(i = 0 ; i < 3 ; i++){
    for(j = 0 ; j < 3 ; j++){
      if(!Puzzle[i][j]){
 *x = j;
 *y = i;
 return;
      }
    }
  }
}

void swap(int *a, int *b){
  int tmp;

  tmp = *a;
  *a = *b;
  *b = tmp;
}


int Cal(){
  int i, a;
  int sum = 0;

  for(i = 0 ; i < 9 ; i++){
    a = Puzzle[i/3][i%3];
    if(a){
      a--;
      sum += abs(i/3 - a/3)  + abs(i%3 - a%3);
    }
  }

  return sum;
}

int DFS(int x, int y, int p, int dep, int limit){
  int i, h, nx, ny, res;

  h = Cal();

  if(h == 0) return dep;
  if(dep + h > limit) return -1;

  for(i = 0 ; i < 4 ; i++){
    nx = x + dx[i];
    ny = y + dy[i];

    if(~p && i == (p+2)%4) continue;
    if(!(0 <= nx && nx < 3 && 0 <= ny && ny < 3)) continue;

    swap(&Puzzle[y][x], &Puzzle[ny][nx]);
    res = DFS(nx, ny, i, dep+1, limit);
    if(~res) return res;

    swap(&Puzzle[y][x], &Puzzle[ny][nx]);
  }

  return -1;
}



Measured memory_bytes: 2112
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_pow(int base, int exp)
{
	_T ans = 1;

	for (int i = 0; i < exp; i++) {
		ans *= (_T)base;
	}
	return ans;
}

static void D();

int main()
{
	D();
	fflush(stdout);
	return 0;
}

static void D()
{
	int X;
	get(X);
	
	int base = 1, exp = 0, ans = 1;
	for (base = 1; base <= X; base++) {
		for (exp = 2; exp <= X; exp++) {
			int tmp = tp_pow<int>(base, exp);
			if (tmp > X) break;
			ans = std::max(ans, tmp);
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3696
// 26.07.2020
// 00:38:12

#pragma GCC optimize("O3")

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

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define ld long double
#define rep(i,a,n) for (int i=(int)(a);i<(int)(n);i++)
#define per(i,a,n) for (int i=(int)(n-1);i>=(int)(a);i--)
#define mp(a, b) make_pair(a, b)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define fi first
#define se second


const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};


template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while(b <= a) {
        b *= 2;
        --k;
    }
    while(c <= b) {
        c *= 2;
        --k;
    }
    if (k < 0) {
        cout << "No\n";
    }
    else {
        cout << "Yes\n";
    }
}

Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int h, w, k, dat[600][11], kn[600], cons, tmp[600][11];
string s[20];
bool mk[600];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> h >> w >> k;
	cons = 1 << (h - 1);
	for (int i = 0; i < h; i++) cin >> s[i];
	for (int j = 0; j < w; j++) {
		for (int t = 0; t < cons; t++) {
			if (mk[t]) continue;
			int cur = 0, work = t;
			tmp[t][cur] = 0;
			for (int i = 0; i < h; i++) {
				tmp[t][cur] += s[i][j] - '0';
				if (work % 2) {
					cur++;
					tmp[t][cur] = 0;
				}
				work /= 2;
			}
			bool flag = false;
			for (int i = 0; i <= cur; i++) {
				if (tmp[t][i] > k) mk[t] = true;
				if (dat[t][i] + tmp[t][i] > k) {
					flag = true;
					break;
				}
			}
			if (flag) {
				kn[t]++;
				for (int i = 0; i <= cur; i++) {
					dat[t][i] = tmp[t][i];
				}
			}
			else {
				for (int i = 0; i <= cur; i++) {
					dat[t][i] += tmp[t][i];
				}
			}
		}
	}
	int ans = 1e9;
	for (int t = 0; t < cons; t++) {
		if (mk[t]) continue;
		int tmp = t, t_cnt = 0;
		while (tmp) {
			if (tmp % 2) t_cnt++;
			tmp /= 2;
		}
		ans = min(ans, kn[t] + t_cnt);
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 384
a,b,c,d,e,f=`dd`.split.map &:to_f;x,y,z,w=c-a,d-b,e-a,f-b;s=(x*w-y*z).abs/2;o,q,r=[[x,y],[z,w],[x-z,y-w]].map{|x,y|(x*x+y*y)**0.5}.sort;p 2*s/(o+q+r+4*s/r)

Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
const ll mod=1e9+7;
bool sortbysec(const pair<int,int>&a,const pair<int,int>&b)
{
    return (a.second<b.second);
}
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll dbc=(b/c);
    ll dbd=(b/d);
    ll k=((c*d)/__gcd(c,d));
    ll dbcd=(b/k);
    ll db=dbc+dbd-dbcd;
    ll dac=((a-1)/c);
    ll dad=((a-1)/d);
    ll dacd=((a-1)/k);
    ll da=dac+dad-dacd;

    ll ndcd=db-da;
    ll n=(b-a)+1;
    cout<<n-ndcd<<endl;








}





















































Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;



int main() {
    ll N,M;
    cin >> N >> M;
    vector<ll> s;
    vector<ll> c;
    for (ll i = 0;i<M;i++) {
        ll ss,cc;
        cin >> ss >> cc;
        s.push_back(ss);
        c.push_back(cc);
    }
    ll ans = -1;
    for (ll i = 0;i<1000;i++) {
        string num = to_string(i);
        bool ok = true;
        if (num.length() != N) continue;
        for (ll j = 0;j<M;j++) {
            if (num.at(s.at(j)-1) - '0' != c.at(j)) { //型に注意
                ok = false;
            }
        }
        if (ok) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
 
bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
double t;
double x;


int main(){
    cin >> t >> x;
    cout << fixed;
    cout << setprecision(6) << t/x << endl;
}

Measured memory_bytes: 256
/*
  In the name of ALLAH
  Author : Raashid Anwar
*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define int int64_t
const int M1 =  998244353;
const int M2 =  1000000007;
mt19937 rng((uint64_t)chrono::steady_clock::now().time_since_epoch().count());

void solve() {
  int n;
  cin >> n;
  set <int> mp[2][2];
  int ans = 0;
  for(int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    for(int l : {0, 1})
        for(int m : {0, 1})
          if(!mp[l][m].empty()) {
            int sum = (l? -x: x) + (m? -y: y);
            ans = max(ans, sum + *mp[l][m].rbegin());
          }
    for(int l : {0, 1})
      for(int m : {0, 1})
        mp[l][m].insert({(l? x: -x) + (m? y: -y)});
  }
  cout << ans << "\n";
}
 
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}

Measured memory_bytes: 41160
n,m,c = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)
ass = n.times.map{ gets.split.map(&:to_i) }

puts ass.select {|as|
  m.times.map{|i| as[i]*bs[i] }.inject(&:+) + c > 0
}.count


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

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int l=s.length();
    if(s[l-1]=='s')
    {
        cout<<s<<"es";
    }
    else
    {
        cout<<s<<"s";
    }
    return 0;
}


Measured memory_bytes: 3644
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int H1, H2, M1, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int answer = (H2 - H1) * 60 + (M2 - M1) - K;
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3608
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}

	public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			int n,m,a,b,p,p2,k,s,switchN;
			int on,check,len;
			double mm;
			int index,index2,index3,result;
			Map <Integer,Integer> mapSwitchN = new HashMap<Integer,Integer> ();
			Map <Integer,Integer> mapS = new HashMap<Integer,Integer> ();
			Map <Integer,Integer> mapP = new HashMap<Integer,Integer> ();
			Map <Integer,Integer> mapAnswer = new HashMap<Integer,Integer> ();
			// All 4, On 3, Off 2, None 1
			String s1,s2,c,ze;
			ze="0000000000";

			n = sc.nextInt();
			m = sc.nextInt();
			
			Map <String,Integer> mapName = new TreeMap<String,Integer> ();
			Map <Integer,Integer> mapScore = new TreeMap<Integer,Integer> ();

			for(index=0;index<m;index++) {
				k = sc.nextInt();
				mapSwitchN.put(index,k);
				for(index2=0;index2<k;index2++){
					s= sc.nextInt();
					mapS.put(index*n+index2,s);
					}
				}
			
			for(index=0;index<m;index++) {
				p = sc.nextInt();
				mapP.put(index,p);
				}
			sc.close();

			result=0;
			mm=Math.pow(2, n);
			LoopX: for(index=0;index<mm;index++) {
				
				s1=Integer.toBinaryString(index);
				len=s1.length();
				s2=s1;
				if(len<n) s2=ze.substring(0,n-len)+s1;
				//System.out.println(s2);
				check=0;
				LoopY: for(index2=0;index2<m;index2++) {
					k=mapSwitchN.get(index2);
					on=0;
					for(index3=0;index3<k;index3++){
						s=mapS.get(index2*n+index3);
						c=s2.substring(s-1,s);
						if(c.contentEquals("1")) on=on+1;
						}
					on=on%2;
					if(on!=mapP.get(index2)) {
						check=1;
						break LoopY;
						}
					}
					//System.out.println(check);
					if(check==0) result++;
				}

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

	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cstdio>
#include <string>
using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define VEC vector<int>
#define INF INT_MAX
#define debug(a) cout<<a
// vector<VEC> v (n, VEC(n))

int n;
vector<int> s;

bool aaaaaburiburi(int x)//????????¢?´¢????????????????????????
{
	int lb = 0, ub = n, mid;
	while (lb < ub)
	{
		mid = (lb + ub) / 2;
		if (s[mid] == x)return true;//???????????£?????????????????????????????????
		if (s[mid] < x)lb = mid + 1;
		else if (s[mid] > x)ub = mid;
	}
	return false;//????????§????????????????????????????????????????????????????????????????????????????????????
}

int main()
{
	cin >> n;
	s.resize(n);
	loop(i, n)cin >> s[i];
	int q, t = 0, ans = 0;//?????´???????????????????????????????????§?????°????????§??????
	cin >> q;
	loop(i, q)
	{
		cin >> t;
		if (aaaaaburiburi(t))ans++;//?????????????????????????????????????????????
	}
	cout << ans << endl;//?????£????????????????????????????????????????????????????????????
	return 0;
}

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

int main(){
    
    std::vector<int> v;

    for(size_t i = 0; i < 3; i++){
        int tmp;
        std::cin >> tmp;
        v.emplace_back(tmp);
    }

    std::sort(v.begin(), v.end());

    std::cout << v[0] + v[1] << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}


int main() {
    LL N, A, B;
    cin >> N >> A >> B;
    VI X(N);
    REP(i, N) cin >> X[i];

    LL ans = 0;
    FOR(i, 1, N) {
        ans += min((X[i] - X[i - 1]) * A, B);
    }

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


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

using namespace std;



typedef long long ll;


int gcd(int a, int b) {
  int amari = 0;

  if(a > b){
    int temp;
    temp = a;
    a = b;
    b = temp;
  }


  while(true){
    if((amari = b % a) == 0){
      return a;
  }

  b = a;
  a = amari;
  }
}


  int main() {
  int k, sum=0, ans1, ans2;
  cin >> k;
  for (int i = 1; i < k+1; i++){
    for (int j = 1; j < k+1; j++){
      for (int l = 1; l < k+1; l++){
        ans1 = gcd(i, j);
        ans2 = gcd(j, l);
        ans1 = gcd(ans1, ans2);
        sum += ans1;
      }
    }
  }
  cout << sum << endl;
  return 0;
  }


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

int main(){
  int n,i;
  double kotae=0;
  cin>>n;
  double a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  kotae=a[0];
  for(i=1;i<n;i++){
    kotae=(kotae+a[i])/2;
  }
  cout<<kotae;
}

Measured memory_bytes: 256
N,M,X = map(int,input().split(" "))
A = input().split(" ")
A = [int(i) for i in A]
cost = []

c = 0
for i in range(len(A)):
    if A[i] < X:
        c += 1
cost.append(c)

c = 0
for i in range(len(A)):
    if X < A[i]:
        c += 1
cost.append(c)
#print(cost)
print(min(cost))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

bool comb(pair<int,int> a,pair<int,int> b){
    if(a.first==b.first){
        return a.second>b.second;
    }else return a>b;
}

int main(){
    int n;cin>>n;
    vector<pair<int,int>> v(n);
    
    rep(i,0,n){
        cin>>v[i].se>>v[i].fi;
    }
    rep(i,0,n-1){
        rep(j,i+1,n){
            if(v[i].fi>v[j].fi){
                pair<int,int> temp;
                temp=v[i];
                v[i]=v[j];
                v[j]=temp;
            }else if(v[i].fi==v[j].fi){
                if(v[i].se<v[j].se){
                    pair<int,int> temp;
                    temp=v[i];
                    v[i]=v[j];
                    v[j]=temp;
                }
            }
        }
    }
    cout<<v[n-1].se<<" "<<v[n-1].fi<<endl;

    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main(){
	while(1){
		int N, s, i, sum = 0, maxs = 0, mins = 1001;
		scanf("%d", &N);
		if(N == 0){
			return 0;
		}
		for(i = 0; i < N; i++){
			scanf("%d", &s);
			sum += s;
			maxs = max(maxs, s);
			mins = min(mins, s);
		}
		printf("%d\n", (sum - maxs - mins) / (N - 2));
	}
}


Measured memory_bytes: 3160
N,M = map(int,input().split())

L = [1 for i in range(N)]

R = [0 for i in range(N)]
R[0] = 1

for i in range(M) :
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    
    L[x] -= 1
    L[y] += 1
    
    if R[x] == 1 and R[y] == 0 :
        R[y] = 1
    
    if L[x] == 0 and R[x] == 1 :
        R[x] = 0
    

print(sum(R))
    

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

signed main() {
  int n, k, ans;
  cin >> n >> k;

  int n0 = n / k;
  int n1 = (n + (k / 2)) / k;
  ans = n0 * n0 * n0;
  if (k % 2 == 0) ans += n1 * n1 * n1;
  cout << ans << endl;
}

Measured memory_bytes: 256
<?php

class Caluculate {

    public function getAnswer() {
        $n = trim(fgets(STDIN));
        $count = 0;

        for ($i = 0; $i < $n; $i++) {
            $num = (int) fgets(STDIN);
            if ($this->isPrime($num)) $count++;
        }

        echo $count . PHP_EOL;
    }
}

class CheckPrimeNumber extends Caluculate {

    public function isPrime($num) {

        if ($num == 2) {
            return true;
        } elseif ( $num < 2 or $num % 2 == 0) {
            return false;
        } else {
            $start = 3;
            while ($start <= sqrt($num) + 1) {
                if ($num % $start == 0) {
                    return false;
                }
                $start += 2;
            }
            return true;
        }
    }
}

$rate = new CheckPrimeNumber();
$rate->getAnswer();



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

int main(){
  int N,L;
  string S[100];

  cin>>N>>L;
  for(int i=0;i<N;i++){
    cin>>S[i];
  }

  sort(S,S+N);

  for(int i=0;i<N;i++){
    cout<<S[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
from itertools import accumulate
n, m, k = [int(i) for i in sys.stdin.readline().split()]

par = list(range(n))
ns = [1 for i in range(n)]

def find(x):
    ls = []
    while x != par[x]:
        ls.append(x)
        x = par[x]
    for l in ls:
        par[l] = x
    return x

def unite(x, y):
    x = find(x)
    y = find(y)
    if x != y:
        par[x] = y
        ns[y] += ns[x]

def is_same(x, y):
    if find(x) == find(y):
        return True
    else:
        return False

ls = [0 for i in range(n)]
friends = [0 for i in range(n-1)]

for i in range(m):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    ls[a] -= 1
    ls[b] -= 1
    unite(a, b)

for i in range(n):
    root = find(i)
    ls[i] += ns[root]


for i in range(k):
    c, d = [int(i) for i in sys.stdin.readline().split()]
    c -= 1
    d -= 1
    if is_same(c, d):
        ls[c] -= 1
        ls[d] -= 1

print(" ".join([str(i - 1) for i in ls]))

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

using namespace std;

int n, pCount;
void repair(int *preList, int *inList)
{
    if (!preList[0]) return;
    
    int preL[40] = {0}, preR[40] = {0};
    int inL[40] = {0}, inR[40] = {0};
    
    int i;
    for (i = 0; inList[i] != preList[0]; i++){
        inL[i] = inList[i];
    }
    for (int j = i + 1; inList[j] != 0; j++){
        inR[j - (i + 1)] = inList[j];
    }
    int lcnt = 0, rcnt = 0;
    for (i = 1; preList[i] != 0; i++){
        bool found = false;
        for (int j = 0; inL[j] != 0; j++){
            if (preList[i] == inL[j]){
                preL[lcnt++] = preList[i];
                found = true;
            }
        }
        if (!found) preR[rcnt++] = preList[i];
    }
    
    repair(preL, inL);
    repair(preR, inR);
    printf("%d%c", preList[0], " \n"[++pCount == n]);
}

int main()
{
    int preList[41] = {0}, inList[41] = {0};
    
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++){
        scanf("%d", preList + i);
    }
    for (int i = 0; i < n; i++){
        scanf("%d", inList + i);
    }
    
    repair(preList, inList);
    
    return (0);
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int a[26]={0},i,j,c=0;
 string str;
 cin>>str;
  	for(j=65;j<91;j++)
	 {
	 	for (int i = 0; i < str.size(); i++)
 	
 		{
 			if(j==str[i])
			 	a[j-65]++;		
 		
		 }
	 }
 	for(i=0;i<26;i++)
 		{
 			if(a[i]==2)
 				c++;
		 }
		if(c==2)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
 	return 0;
}
 	
 					

Measured memory_bytes: 3596
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))


typedef unsigned long long int uint64;
typedef long long int          int64;

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

int main()
{
  int cnt;
  int64 N, L;
  int64 i;
  int64 min = 1000;
  int64 taste;
  int64 total = 0;
  int64 min_t = 0;

  get_NK(&N, &L);

  for(i=1; i<=N; i++) {
    taste = L + i - 1;
    if (min > ABS(taste)) {
      min = ABS(taste);
      min_t = taste;
    }
    total += taste;
  }

  total -= min_t;
  printf("%d", total);

  return 0;
}



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

class Road{
private:
	int col,row,close_num, goal_num;
	std::vector<int> close_x;
	std::vector<int> close_y;
	
public:
	Road(int a, int b, int n){
		col = a;
		row = b;
		close_num = n;
		close_x.resize(n);
		close_y.resize(n);
		goal_num = 0;
	}
	
	void inPoint(){
		for(int i=0; i<close_num; ++i){
			std::cin >> close_x[i] >> close_y[i];
		}
	}
	
	void go_road(int now_x,int now_y){
		
		if(now_x == col && now_y == row){
			++goal_num;
			return;
		}
		
		if(now_x+1 <= col)
			if(isGo(now_x+1, now_y)){
				go_road(now_x+1, now_y);
			}
		
		if(now_y+1 <= row)
			if(isGo(now_x, now_y+1)){
				go_road(now_x, now_y+1);
			}
			
	}
	
	int isGo(int x, int y){
		for(int i=0; i<close_num; ++i){
			if(x == close_x[i] && y == close_y[i])
				return 0;
		}
		return 1;
	}
	
	void showGoal(){
		std::cout << goal_num << std::endl;
	}
};

int main(){
	int a,b;

	while(std::cin >> a >> b){
		if(a == 0 && b == 0) break;
		
		int n;
		std::cin >> n;
		
		Road road(a,b,n);
		road.inPoint();
		road.go_road(1,1);
		road.showGoal();
	}
	
	return 0;

}

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

int main(){
  char a[101],b[101];
  scanf("%s%s",a,b);
  int al = strlen(a),
    bl = strlen(b),
    i;
  if(al>bl){
    printf("GREATER\n");
  }else if(bl > al){
    printf("LESS\n");
  }else{
    for(i=0;i<al;i++){
      if(a[i] > b[i]){
        printf("GREATER\n");
        break;
      }else if(b[i] > a[i]){
        printf("LESS\n");
        break;
      }
    }
    if(i==al){
      printf("EQUAL\n");
    }
  }
  return 0;
}

Measured memory_bytes: 128