akhauriyash/Code-Regression huggingface dataset:
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
#define exist_in(list, value) (list.end() != std::find(all(list),value))
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
//template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
//template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
//template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
//template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
//template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }
//template<class T1, class T2> bool exist_in(const T1& list, const T2& v) { return (list.end() != std::find(list.begin(), list.end(), v)); }
//template<class T> bool exist_in(const T& c, const typename T::value_type& v) {	return (c.end() != std::find(c.begin(), c.end(), v));}

/*****/

void Main()
{
	int n;
	cin >> n;
	cout << (n % 10 == 9 || n / 10 % 10 == 9 ? "Yes" : "No");
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long int lint;
typedef unsigned long long int ulint;

//#define DEBUG

#ifdef DEBUG
#	define dump(i) cout << "[*] " #i " : " << i << endl;
#	define debug(i) i
#else
#	define dump(i)
#	define debug(i)
#endif
#define rep(i, MAX) for (int i = 0; i < (MAX); ++i)

int ss(const vector<int>& v) {
	debug(for (int i : v) cout << i << " ");
	debug(cout << endl;);
	if (v[0] < 0) {
		bool open = true;
		vector<int> l;
		auto b = v.begin()+1;
		for (auto i = v.begin() + 1; i != v.end(); ++i) {
			if (*i == v[0]) {
				if (open) {
					vector<int> vv(b, i);
					l.push_back(ss(vv));
					open = false;
				} else {
					b = i+1;
					open = true;
				}
			}
		}
		int kazu = (l.size()+1) / 2;
		sort(l.begin(), l.end());
		return accumulate(l.begin(), l.begin() + kazu, 0);
	} else {
		return (v[0] + 1) / 2;
	}
}

inline void slv() {
	string s;
	cin >> s;
	vector<int> v;
	int n = 0;
	string number = "";
	for (char c : s) {
		if (c == '[') {
			--n;
			v.push_back(n);
		} else if (c == ']') {
			if (!number.empty()) v.push_back(std::stoi(number));
			v.push_back(n);
			++n;
			number = "";
		} else {
			number += c;
		}
	}

	cout << ss(v) << endl;
}

inline void solve() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		slv();
	}
}

int main() {
	//*
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	// */
#ifdef DEBUG
	const auto start = chrono::high_resolution_clock::now();
#endif
	solve();
#ifdef DEBUG
	const auto stop = chrono::high_resolution_clock::now();
	cerr << "[*] time: " << chrono::duration_cast<chrono::milliseconds>(stop-start).count()
		<< " [ms]" << endl;
#endif
	return 0;
}



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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;++i) cin >> A[i];
  bool flag = true;
  for(int i=0;i<N;++i){
    if(A[i]%2 == 0)
    {
      if((A[i]%3 == 0) or (A[i]%5 == 0));
      else flag = false;
    }
  }
  if(flag) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

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


int main() {
  
  int N, X, count; //Nは入力　Xは出力
  cin >> N;
  int genzai = -1;
  
  for ( int i = 0; i < N; i++ ) {
    int a = N - i; //aは最終的に返す値
    int b = N - i; //実際に割る数
    count = 0;
    
    while ( b % 2 == 0 ) {
      count++;
      b /= 2;
    }
    
    if ( genzai < count ) {
      genzai = count;
      X = a;
    }
  }
  
  cout << X << endl;
  
}

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

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> values, costs;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        std::cin >> tmp;
        values.push_back(tmp);
    }

    for (int i = 0; i < N; i++)
    {
        std::cin >> tmp;
        costs.push_back(tmp);
    }
    int result = 0;
    for (int i = 0; i < N; i++)
    {
        if (values[i] > costs[i]) { result += values[i] - costs[i]; }
    }

    std::cout << result << std::endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	cout << N * N*N << endl;

	return 0;
}

Measured memory_bytes: 256
class Grid
  attr_reader :h, :w
  attr_accessor :grid

  def initialize(h, w)
    @h = h
    @w = w
    @grid = []
  end

  DIRS = [ [-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]].freeze

  def count_mine(r, c)
    cnt = 0

    DIRS.each do |(dr, dc)|
      cr = r + dr
      cc = c + dc

      next if cr < 0 || @h <= cr
      next if cc < 0 || @w <= cc

      cnt += 1 if @grid[cr][cc] == "#"
    end
    cnt
  end

  def replace_mine_count
    0.upto @h-1 do |r|
      0.upto @w-1 do |c|
        if @grid[r][c] == "."
          @grid[r][c] = count_mine(r, c)
        end
      end
    end
  end

  def print_result
    @grid.each do |row|
      0.upto(@w-1) do |c|
        print row[c]
      end
      puts
    end
  end

end

def main
  h, w = ARGF.gets.split.map(&:to_i)

  g = Grid.new(h, w)
  h.times do
    g.grid << ARGF.gets.chars
  end

  g.replace_mine_count

  g.print_result
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 2172
s=input()
q=int(input())
query = [input().split() for i in range(q)]

Inv = False #反転しているか
front_str = [] #末尾側
back_str = [] #先頭側

for query_list in query:
    if query_list[0] == '1':
        Inv = not Inv
    else:
        if query_list[1] == '1': #先頭に追加
            if Inv:
                front_str.append(query_list[2])
            else:
                back_str.append(query_list[2])
        else:
            if Inv:
                back_str.append(query_list[2])
            else:
                front_str.append(query_list[2])

answer = "".join(back_str[::-1] + [s] + front_str)

if Inv:
    answer = answer[::-1]

print(answer)

Measured memory_bytes: 43780
N, K = map(int, input().split())
banlist = [False]*N
for k in range(K):
    D = int(input())
    l = list(input().split())
    for i in l:
        if banlist[int(i)-1] == False:
            banlist[int(i)-1] = True
print(banlist.count(False))

Measured memory_bytes: 9184
n,q=map(int,input().split())
s=input()
c=[0]*n
for i in range(1,n):
  t=s[i-1:i+1]
  if t=="AC":c[i]+=1
from itertools import accumulate
s=list(accumulate(c))
for i in range(q):
  l,r=map(int,input().split())
  l-=1
  r-=1
  print(s[r]-s[l])




Measured memory_bytes: 8584
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#define pi acos(-1)
using namespace std;
int main()
{
    int n,x;
    while (cin>>n>>x&&(x!=0||n!=0))
    {
        int sum=0;
        for(int i=1;i<=n;i++)
            for(int j=i+1;j<=n;j++)
                for(int k=j+1;k<=n;k++)
                    if(i+k+j==x)sum++;
        cout<<sum<<endl;
    }
    return 0;
}



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

int main(){

    double n,ans=0;
    cin >> n;
    ans = n * 2 * 3.1415;
    cout << std::fixed << std::setprecision(8) << ans << endl;
	return 0;
}



Measured memory_bytes: 3772
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);
  static int N;

  public static void main(String[] args) {
    System.out.println(solve());
  }

  static int solve() {
    char[] A = sc.next().toCharArray();
    char[] B = sc.next().toCharArray();
    N = A.length;
    int lastOnePos = N;
    for (int i = N - 1; i >= 0; i--) {
      if (B[i] == '1') {
        lastOnePos = i;
        break;
      }
    }
    if (lastOnePos == N) {
      for (char c : A) {
        if (c == '1') {
          return -1;
        }
      }
      return 0;
    }
    int ans = solve(A, B, lastOnePos);
    for (int i = 0; i < N / 2; i++) {
      char tmp = A[i];
      A[i] = A[N - 1 - i];
      A[N - 1 - i] = tmp;
      tmp = B[i];
      B[i] = B[N - 1 - i];
      B[N - 1 - i] = tmp;
    }
    for (int i = N - 1; i >= 0; i--) {
      if (B[i] == '1') {
        lastOnePos = i;
        break;
      }
    }
    return Math.min(ans, solve(A, B, lastOnePos));
  }

  static int solve(char[] A, char[] B, int lastOnePos) {
    int ans = N;
    for (int i = 0; i < N; i++) {
      if (A[i] != B[i]) ++ans;
    }
    int[] prevPos = new int[N];
    int[] nextPos = new int[N];
    int p = lastOnePos - N;
    for (int i = 0; i < N; i++) {
      if (B[i] == '1') p = i;
      prevPos[i] = p;
    }
    int n = 0;
    while (B[n] == '0') {
      ++n;
    }
    n += N;
    for (int i = N - 1; i >= 0; i--) {
      if (B[i] == '1') n = i;
      nextPos[i] = n;
    }
    ArrayList<Integer> rest = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      rest.clear();
      int diff = 0;
      for (int j = 0; j < N; j++) {
        if (A[j] != B[(j - i + N) % N]) {
          ++diff;
          if (j - prevPos[j] > i) {
            rest.add(((j - prevPos[j] - i) << 16) | (nextPos[j] - j));
          }
        }
      }
      int move;
      if (!rest.isEmpty()) {
        Collections.sort(rest);
        int[] revMax = new int[rest.size() + 1];
        for (int j = rest.size() - 1; j >= 0; j--) {
          revMax[j] = Math.max(revMax[j + 1], rest.get(j) & 0xFFFF);
        }
        move = revMax[0];
        for (int j = 0; j < rest.size(); j++) {
          move = Math.min(move, (rest.get(j) >> 16) + revMax[j + 1]);
        }
      } else {
        move = 0;
      }
//      System.out.println(rest);
//      System.out.println(i + " " + diff + " " + move);
      ans = Math.min(ans, diff + move * 2 + i);
    }
    return ans;
  }

}


Measured memory_bytes: 52364
#include <iostream>

int main(int argc, char const* argv[])
{
  int W, H, x, y, r;
  std::cin >> W >> H >> x >> y >> r;
  int left   = x - r;
  int right  = x + r;
  int top    = y + r;
  int bottom = y - r;
  if (left < 0 || bottom < 0 || H < top || W < right)
    std::cout << "No" << std::endl;
  else
    std::cout << "Yes" << std::endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;
// 変数初期化
vector<ll> bsv; // binary_search用のvector
ll a,b,c,n,m;
typedef pair<ll, ll> Pll;
vector<Pll> facts; // 素因数分解の結果格納用(基数:乗数)
vector<vector<ll> > bit_search_v; //nit全探索の結果格納用

// index が条件を満たすかどうか
bool isOK(ll index, ll key) {
    if (bsv[index] >= key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search(int key) {
    int ng = -1;
    int ok = (ll)bsv.size();

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    // OK(key以上となる)のindex番号を返す
    return ok;
}

// 最大公約数
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

// 最小公倍数
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

//　素因数分解
void prime_fact(ll target){
    ll base=2, exp=0;
    while (base*base<=target) {
        while (target%base==0) {
            target /= base; exp++;
        }
        if (exp>0) {
            facts.push_back(make_pair(base, exp));
        }
        base++; exp=0;
    }
    if (target>1) facts.push_back(make_pair(target,1));
}
// prime_factの結果の確認用
void print_facts(){
    for (int i=0; i<facts.size(); i++) {
        cout << facts[i].first << " " << facts[i].second << endl;
    }
}

// bit全探索
void bit_search(ll target){
    for (ll i=0; i<(1<<target); ++i) {
        if (i==0) continue;
        vector<ll> v;
        for (ll j=0; j<target; ++j) {
            if (i&(1<<j)) v.push_back(j);
            if (i&(1<<j)) cout << i << "  :  " << j << endl;
        }
        bit_search_v.push_back(v);
    }
}
// bit全探索の結果確認用
void print_bit_search(){
    for (ll i=0; i<bit_search_v.size(); ++i) {
        for (ll j=0; j<bit_search_v[i].size(); ++j) {
            cout << bit_search_v[i][j] << " ";
        }
        cout << endl;
    }
}



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

    cin >> a;
    cout << a+a*a+a*a*a << endl;

    return 0;
}

Measured memory_bytes: 3164
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N, M;

  ll a = 1, b = M + 1;
  
  ll tmp = b;
  
  for (;;) {
    cout << a << " " << b << endl;
    if (b - a <= 2) break;
    a++;b--;
  }
  a = tmp+1; b = M * 2 + 1;
  if (a < b)
    for (;;) {
    cout << a << " " << b << endl;
    if (b - a <= 2) break;
    a++;b--;
  }

}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pii pair<int,int>
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int a,b,c; cin>>a>>b>>c;
  if(a<b&&b<c) co("Yes");
  else co("No");
  
  return 0;
}


Measured memory_bytes: 3080
import heapq

n = int(input())
edges = [set((w, j) for j, w in enumerate(map(int, input().split())) if w > -1) for _ in range(n)]

visited = [False] * n
visited[0] = True
queue = list(edges[0])
heapq.heapify(queue)
total_cost, remains = 0, n - 1
while True:
    cost, vertex = heapq.heappop(queue)
    if visited[vertex]:
        continue
    visited[vertex] = True
    total_cost += cost
    remains -= 1
    if not remains:
        break
    for t in edges[vertex]:
        if not visited[t[1]]:
            heapq.heappush(queue, t)

print(total_cost)

Measured memory_bytes: 8704
import java.util.*;
class Main {
     
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        Dice dice1 = new Dice(stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt());
        Dice dice2 = new Dice(stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt());
        boolean a = solv(dice1, dice2, 0);
        System.out.println((a)?"Yes":"No");
    }
    public static boolean solv(Dice f, Dice dice,int count) {
        if(dice.Top == f.Top && dice.S == f.S && dice.Bottom == f.Bottom && dice.E == f.E && dice.N == f.N && dice.W == f.W) return true;
        if(count == 6) return false;
        Dice tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnN();
        if(solv(f,tmp,count+1)) {
            return true;
        }
        tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        if(solv(f,tmp,count+1)) {
            return true;
        }
        tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnE();
        tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnW();
        if(solv(f,tmp,count+1)) {
            return true;
        }
         
        return false;
    }
     
     
     
}
 
class Dice {
    int Top; //1
    int Bottom; //6
    int N; //   5
    int S; //   2
    int W; //左 4
    int E; //右 3
    Dice(int a, int b, int c, int d, int e, int f) {
        Top = a;
        S = b;
        E = c;
        W = d;
        N = e;
        Bottom = f;
    }
    public void TurnN() {
        int tmp = Top;
        Top = S;
        S = Bottom;
        Bottom = N;
        N = tmp;
    }
    public void TurnW() {
        int tmp = Top;
        Top = E;
        E = Bottom;
        Bottom = W;
        W = tmp;
    }
    public void TurnE() {
        int tmp = Top;
        Top = W;
        W = Bottom;
        Bottom = E;
        E = tmp;
    }
    public void TurnS() {
        int tmp = Top;
        Top = N;
        N = Bottom;
        Bottom = S;
        S = tmp;
    }
     
}


Measured memory_bytes: 26336
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    ll N, a, b;
    cin >> N >> a >> b;

    if ((b - a) % 2LL == 0LL) {
        cout << (b - a) / 2LL << endl;
    } else {
        ll ans = 0;
        if (b - 1LL < N - a) {
            ll tmp = a - 1;
            a -= tmp;
            b -= tmp;
            ans += tmp;
            // cout << a << " " << b << " " << ans;
            cout << ans + min(b - 1LL, ((b - 1LL) - a) / 2LL + 1) << endl;
        } else {
            ll tmp = N - b;
            b += tmp;
            a += tmp;
            ans += tmp;
            cout << ans + min(N - a, (b - (a + 1LL)) / 2LL + 1) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import Foundation

let main: () = {
    let N = getInt()
    let S = getString().map(String.init)
    var (R, G, B) = (0, 0, 0)
    S.forEach { c in
        switch (c) {
            case "R": R += 1
            case "G": G += 1
            case "B": B += 1
            default: break
        }
    }
    let total = R * G * B
    var exc = 0
    for n in 0 ..< N - 2 {
        for m in n + 1 ..< N - 1 {
            let k = m + (m - n)
            if (k >= N) {continue}
            if (S[n] != S[m] && S[n] != S[k] && S[m] != S[k]) {exc += 1}
        }
    }
    let ans = total - exc    
    print(ans)
}()

func getString() -> String { readLine()! }
func getInt() -> Int { Int(getString())! }
func getDouble() -> Double { Double(getString())! }



Measured memory_bytes: 13168
#include <iostream>
#include<cmath>
using namespace std;
bool isprime(int a){
    if(a==2) return true;
    else if(a%2==0) return false;
    else{
        int i=3;
        while(i<=sqrt(a)){
            if(a%i==0) return false;
            else i+=2;
        }
        return true;
    }
}
int main(){
    int n,x,count=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        if(isprime(x)) count+=1;
    }
    cout<<count<<endl;
    
}


Measured memory_bytes: 3088
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long

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

  ll N,ans = 0; cin >> N;
  vector<ll> vec(N);
  for (ll i = 0; i < N; ++i) cin >> vec[i];
  
  for (ll i = 0; i < N-2; ++i) {
    ll a = vec[i];
    ll b = vec[i+1];
    ll c = vec[i+2];
    if (max({a,b,c})!=b && min({a,b,c})!=b) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main()
{
//    freopen("in.txt","r",stdin);

    string s;
    while(getline(cin,s))
    {
        int len=s.length();
        for(int i=0;i<len;i++)
        {
            if(islower(s[i]))
                s[i]=toupper(s[i]);
            else if(isupper(s[i]))
                s[i]=tolower(s[i]);
        }
        for(int i=0;i<len;i++)
            cout<<s[i];
        cout<<endl;
    }
}



Measured memory_bytes: 3168
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  ll N; cin>>N;

  ll ans = N%2==1 ? (N-1)/2 : N/2 - 1;
  
  cout << ans << endl;

  return 0;
}


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

public class Main implements Runnable {

    private void solve() throws IOException {

        int N = nextInt();
        boolean isSet = false;
        int prev = nextInt();
        int ret = 1;
        boolean isBigger = false;
        for(int i = 1; i < N; ++i) {
            int next = nextInt();
            if(!isSet) {
                if(next > prev) {
                    isBigger = true;
                    isSet = true;
                } else if(next < prev) {
                    isBigger =false;
                    isSet = true;
                }
                else isSet = false;

            } else {
                if(isBigger) {
                    if(next < prev) {
                        ++ret;
                        isSet = false;
                    }
                } else {
                    if(next > prev) {
                        ++ret;
                        isSet =false;
                    }
                }
            }
            prev = next;
        }
        writer.println(ret);
    }

    public static void main(String[] args) {
        new Main().run();
    }

    BufferedReader reader;
    //    BufferedReader reader2;
    StringTokenizer tokenizer;
    PrintWriter writer;
    //    BufferedWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
//            reader = new BufferedReader(new FileReader("input.txt"));
            //            reader2 = new BufferedReader(new FileReader("1.in"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
//            writer = new     PrintWriter("output.txt");
//                                                    writer = new BufferedWriter(System.out);
            //                        writer = new BufferedWriter(new OutputStreamWriter(System.out));
            solve();
            reader.close();
            //            reader2.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    short nextShort() throws IOException {
        return Short.parseShort(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }

        return tokenizer.nextToken();
    }

}

Measured memory_bytes: 37788
#include<bits/stdc++.h>
using namespace std;
#define nl cout<<'\n';
int main()
{
    long long a,c;
    string b;
    cin>>a>>b;
    c=((b[0]-'0')*100)+((b[2]-'0')*10)+(b[3]-'0');
    a=a*c;
    a=a/100;
    cout<<a;
    nl;
    return 0;
}


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

struct Card { char suit, value; };

void bubble(struct Card A[], int n)	{
	for (int i = 0; i < n; i++)	{
		for (int  j = n - 1;  j >= i + 1; j--)	{
			if (A[j].value < A[j-1].value)	{
				Card t = A[j];
				A[j] = A[j-1];
				A[j-1] = t;
			}
		}
	}			
}	

void selection(struct Card A[], int n)		{
	for (int i = 0; i < n; i++)	{
		int minj = i;
		for (int j = i; j < n; j++)	{
			if (A[j].value < A[minj].value)
				minj = j;
		}
		Card t = A[i];
		A[i] = A[minj];
		A[minj] = t;
	}
}

void print(struct Card A[], int n)	{
	for (int i = 0; i < n; i++)	{
		if (i > 0)
			cout << " ";
		cout <<  A[i].suit << A[i].value;
	}
	cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int n)  {
  for (int i = 0; i < n; i++)  {
    if (C1[i].suit != C2[i].suit)
      return false;
    }
  return true;
}

int main(void)  {
	Card C1[100], C2[100];
	int n;
	char ch;
	
	cin >> n;
	for (int i = 0; i < n; i++)  {
		cin >> C1[i].suit >> C1[i].value;
		}
		
		for (int i = 0; i < n; i++)
			C2[i] = C1[i];
			
		bubble(C1, n);
		selection(C2, n);
		
		print(C1, n);
		cout << "Stable" << endl;
		print(C2, n);
		if (isStable(C1, C2, n))  {
			cout << "Stable" << endl;
		} else {
			cout << "Not stable" << endl;
	}		
	return 0;
}



				

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int maxi = 0;
	for( int i = 1; i*i <= m; ++i ){
		if( m%i == 0 ){
			if( m/i >= n ){
				maxi = max( maxi, i );
			}
			if( i >= n ){
				maxi = max( maxi, m/i );
			}
		}
	}
	cout << maxi << endl;
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
mod=10**9+7

import math 
L=math.floor(math.sqrt(M))

X=dict()

for i in range(2,L+2):
    while M%i==0:
        X[i]=X.get(i,0)+1
        M=M//i

if M!=1:
    X[M]=X.get(M,0)+1
    


def Combi2(a,b):#aは大きいが、bは小さいとき
    if b>a:
        return 0
    ANS=1
    for i in range(min(b,a-b)):
        ANS=ANS*(a-i)*pow(min(b,a-b)-i,mod-2,mod)

    return ANS%mod

ANS=1
for x in X.values():
    ANS=(ANS*Combi2(x+N-1,x))%mod

print(ANS)

Measured memory_bytes: 3064
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

A, B, C, D = In.ints()

takTurn = True
while A>0 and C>0:
    if takTurn:
        C-=B
    else:
        A-=D

    takTurn = not takTurn

if A<=0:
    Out.str("No")
else:
    Out.str("Yes")

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 68132
#include<bits/stdc++.h>
using namespace std;
int N;
long long A,S,res;
map<long long,long long>mp;
int main(){
  cin>>N;
  mp[0]=1;
  while(N--){
    cin>>A;
    S+=A;
    ++mp[S];
  }
  for(auto it=mp.begin();it!=mp.end();++it){
    res+=it->second*(it->second-1)/2;
  }
  cout<<res<<endl;
}

Measured memory_bytes: 12800
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	int a, b;cin >> a >> b;
	cout << a * b << " " << 2 * (a + b) << "\n";
	return 0;
}



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

int main() {
    int a,b;
    cin >> a >> b;
    if(a <= b) cout << a << endl;
    else cout << a-1 << endl;
}

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

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

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {

  ll a, b, c; cin >> a >> b >> c;
  ll right = 4 * a * b, left, tmp = c - a - b;
  left = pow(tmp,2);
  /* cout << right << " " << left << endl; */
  if (4 * a * b < tmp * tmp && tmp > 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    ll a;
    int b,c;

    scanf("%lld %d.%d", &a, &b, &c );
    ll ans = a*b+a*c/100;

    printf ("%lld\n", ans );

    return 0;
}



Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    string s;
    int k;
    cin >> s >> k;
    set<string> st;
    int cnt = 0;
    for(int num = 0; num < k; num++){
        for(int i = 0; i < s.size(); i++){
            string sub = "";
            for(int j = 0; j <= cnt; j++){
                if (i+j < s.size()) sub += s[i+j];
            }
            st.insert(sub);
        }
        cnt++;
    }
    cnt = 0;
    for(auto x : st){
        cnt++;
        if (cnt != k) continue;
        cout << x << endl;
        return 0;
    }
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define range(a,b)		substr(a,b-a+1)
#define w(x)            int x; cin>>x; while(x--)
#define trace(x) 		cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool check(int *arr, int n, int mx, int pos)
{
	int req = 0;

	for (int i = 0; i < n; ++i)
	{
		req += (arr[i] + mx - 1) / mx;
		req--;
	}

	return (req <= pos);
}

int32_t main()
{
	FIO;
	int n, k; cin >> n >> k;

	mk(arr, n, int);

	for (int i = 0; i < n; ++i)
		cin >> arr[i];

	int beg = 1, end = 1e9, ans;

	while (beg <= end)
	{
		int mid = (beg + end) / 2;

		if (check(arr, n, mid, k))
			ans = mid, end = mid - 1;

		else
			beg = mid + 1;
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 5172
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}


//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll a,b,c;
cin>>a>>b>>c;
ll tmp=max({a,b,c})*3-(a+b+c);
if(tmp%2==0){
    cout<<tmp/2<<endl;
}
else{
    cout<<(tmp+3)/2<<endl;
}
}








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

int main(){
  
  int N,D;
  cin >> N >> D;
  int P[N][D];
  
  for (int i = 0; i < N; i++){
    for (int j = 0; j < D; j++){
      cin >> P[i][j];
    }
  }
  
  int hantei[2000];
  
  for (int i = 0; i < 2000; i++){
    hantei[i] = (i+1) * (i+1);
  }
  
  int counter;
  
  for (int s = 0; s < N; s++){
    for (int i = s+1; i < N; i++){
      int hensa = 0;
      
      for (int j = 0; j < D; j++){
        int kyori =  P[i][j] - P[s][j];
        hensa += kyori * kyori;
      }
      
      for (int h = 0; h < 2000; h++){
        if (hensa == hantei[h]){
          counter ++;
          break;
        }
      }
    }
  }
  
  cout << counter << endl;
}

Measured memory_bytes: 256
import Data.Array
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

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

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

judge :: Array Int Int -> Int -> Int -> Int -> Int
judge xs n' n mi
  | n' > n = 0
  | x <= mi = 1 + judge xs (n' + 1) n x
  | otherwise = judge xs (n' + 1) n mi
  where
    x = xs ! n'

main = do
  n <- getInt
  ps <- getIntList
  let ps' = listArray (1, length ps) ps
  print $ judge ps' 1 n (ps' ! 1)


Measured memory_bytes: 27772
n, m = [int(x) for x in input().split(" ")]

c = []
d = []
for i in range(n):
    a = [int(x) for x in input().split(" ")]
    if i == 0:
        c = a[- a[0]:]
    else:
        b = a[- a[0]:]
        for ce in c:
            if ce in b:
                 d.append(ce)
        c = d
        d = []

print(len(c))
        


Measured memory_bytes: 3060
import java.io.*;

class Main
{
    public static void main(String args[])
    {
        String buf;
        int num;
        long ans;
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            buf = br.readLine();
            num = Integer.parseInt(buf);
            ans = 0;
            for(int i = 1; i <= num; i++){
                if (i % 3 == 0 || i % 5 == 0){
                    continue;
                }else{
                    ans += i;
                }
            }
            System.out.println(Long.toString(ans));
        } catch(Exception e) {}
  }
}

Measured memory_bytes: 32632
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<int(ceil(log2(double(n))))
	分析样例：奇数or偶数
	偶数
	线段离散化
	make_pair 慢
	坐标离散化
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL (long long)
#define IT iterator
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	int n;//<=100
	scanf("%d",&n);
	int res=n<<1;
	string s,t;
	cin>>s>>t;
	rb(i,1,n){
		int k=1;
		bool OK=true;
		rb(j,i,n){
			if(t[k-1]!=s[j-1]){
				OK=false;
				break;
			}
			k++;
		}
		if(OK){
			res-=n-i+1;
			break; 
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t h;
  cin >> h;
  int64_t n = 1;
  int64_t sum = 0;
  while( h > 1) {
    h /= 2;
    sum += n;
    n *= 2;
  }
  sum += n;
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    pw.println(Math.max(a * b, Math.max(a + b, a - b)));
  }
}


Measured memory_bytes: 21844
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var t [5]int

	for i := 0; i < 5; i++ {
		tmp, _ := reader.ReadString('\n')
		tmp = strings.Trim(tmp, "\n")
		t[i], _ = strconv.Atoi(tmp)
	}

	diff, sum := calcDiff(t)

	var pos int
	min := sum
	for i := 0; i < 5; i++ {
		if min > (sum - diff[i]) {
			min = sum - diff[i]
			pos = i
		}

	}

	var ans int
	for i := 0; i < 5; i++ {
		if i != pos {
			ans += t[i] + diff[i]
		} else {
			ans += t[i]
		}
	}
	fmt.Println(ans)
}

func calcDiff(t [5]int) ([5]int, int) {
	var diff [5]int
	var sum int
	for i := 0; i < 5; i++ {
		rem := t[i] % 10
		if rem > 0 {
			diff[i] = 10 - rem
		} else {
			diff[i] = 0
		}
		sum += diff[i]
	}

	return diff, sum

}


Measured memory_bytes: 640