akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll n, m;
	cin >> n >> m;
	vector<ll> p(m);
	vector<string> s(m);
	for (ll i = 0; i < m; i++) {
		cin >> p[i] >> s[i];
		p[i]--;
	}

	vector<bool> ac(n, false);
	vector<ll> cnt_wa(n, 0);
	for (ll i = 0; i < m; i++) {
		if (ac[p[i]]) continue;
		if (s[i] == "AC") ac[p[i]] = true;
		else cnt_wa[p[i]]++;
	}
	ll a = 0, b = 0;
	for (ll i = 0; i < n; i++) {
		if (ac[i]) {
			a++;
			b += cnt_wa[i];
		}
	}
	cout << a << ' ' << b << endl;
}

Measured memory_bytes: 7872
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let S: Vec<char> = sc.chars();
    let T: Vec<char> = sc.chars();
    let mut ans = 0;
    for i in 0..S.len() {
        if S[i] == T[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

#define pii pair<int, int>
#define x first
#define y second

using namespace std;

const int N = 1e5+5;

int n, A[N];
map<int, int> m1, m2;
vector<pii> v1, v2;

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", A + i);
    for(int i = 1; i <= n; i++) {
        if(i & 1) ++m1[A[i]];
        else ++m2[A[i]];
    }
    for(auto p : m1) v1.emplace_back(p);
    for(auto p : m2) v2.emplace_back(p);
    sort(v1.begin(), v1.end(), [&](const pii &a, const pii &b) {
        return a.y > b.y;
    });
    sort(v2.begin(), v2.end(), [&](const pii &a, const pii &b) {
        return a.y > b.y;
    });
    if(m1.size() == 1 && m2.size() == 1 && m1.begin()->x == m2.begin()->x) printf("%d\n", n / 2);
    else if(v1[0].x == v2[0].x) printf("%d\n", n - v1[0].y - max(v1[1].y, v2[1].y));
    else printf("%d\n", n - v1[0].y - v2[0].y);

    return 0;
}

Measured memory_bytes: 6520
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;

int main(){
  ll n; cin >> n;
  vector<ll> b(n+1);
  rep1(i,n-1){
    cin >> b[i];
    if(debug) cout << b[i] << endl;
  }
  b[0]=b[1];b[n]=b[n-1];
  if(debug){
    for(auto e:b){
      cout << e << endl;
    }
  } 
  ll ans=0;
  for(ll i=0; i<n; i++){
    ans+=min(b[i],b[i+1]);
  }
  cout << ans;
  return 0;
}


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

int cala(int x,int s){return (s*100+99+x)/(x+100);}
int calb(int x,int s){return s*(x+100)/100;}

int main(){
  int x,y,s,p,q,smax;
  while(cin>>x>>y>>s && (x||y||s)){
    smax=-1;
    p=1;q=s-1;
    while(p<=q){
      int t=cala(x,p),u=cala(x,q);
      if(calb(x,t)+calb(x,u)<=s)
        smax=max(calb(y,t)+calb(y,u),smax);
      p++,q--;
    }
    cout<<smax<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
lint lcm(lint a,lint b){
      return a/__gcd(a,b)*b;
  }
  int main(){
     lint N;
     cin>>N;
     lint A[N];
     lint B[N];
     rep(i,N){
         cin>>A[i];
         B[i]=A[i];
         
     }
     sort(A,A+N);
      sort(B,B+N);
     rep(i,N-1){
            A[i+1]+=A[i];
     }
     sort(A,A+N,greater<lint>());
     lint ans=1;
     rep(i,N-1){
        if(A[i]<=A[i+1]*3)ans++;
        else break;
     }
     cout<<ans;
  }
  

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+9;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


LL my_pow(int x, int y){
	LL a=1;
	REP(i,y){
		a *= x;
		a %= MOD;
	}
	return a % MOD;
}

int n,k,r,s,p;
int check(char x){
	if(x == 'r'){
		return p;
	}
	if(x == 's'){
		return r;
	}
	if(x == 'p'){
		return s;
	}
}

void Main()
{
	string t;
	cin>>n>>k;
	cin>>r>>s>>p;
	cin>>t;

	LL point=0;

	REP(i,n){
		if(i<k){
			point += check(t[i]);
		}
		else{
			if(t[i-k] != t[i]){
				point += check(t[i]);
			}
			else{
				t[i] = 'z';
			}
		}
		//dump(point)
	}
	
	cout << point << endl;



	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 512
<?php 
  fscanf(STDIN,"%s",$s);
	$count = 0;
	for($i=0;$i<3;$i++){
      if($s[$i]=='R'){
        $count++;
      }elseif($count>0){
        echo $count."\n";
        exit;
      }
    }
	
	if($count>0){
      echo $count;
    }else{
      echo "0\n";
    }

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

int main(){
  int N;
  vector<int64_t> A(100010);

  cin >> N;
  int neg = 0;
  for(int i=0; i<N; i++){
    int a; cin >> a; A[i] = abs(a);
    if (a < 0) neg++;
  }

  sort(A.begin(), A.begin()+N);

  if(neg % 2 == 0){
    for(int i=0; i<N; i++){
      if(A[i] < 0) A[i] *= -1;
    } 
  } else {
    A[0] = min(A[0], -1 * A[0]); 
    for(int i=1; i<N; i++){
      if(A[i] < 0) A[i] *= -1;
    }
  }

  int64_t ans = 0;
  for(int i=0; i<N; i++){
    //cout << A[i] << endl;
    ans += A[i];
  }
  cout << ans << endl;
} 

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

void insertionSort(vector<int> array,int n)
{
    for(int i=1;i<n;i++){
        for(int k=0;k<n-1;k++)
            cout << array[k] << ' ';
        cout << array[n-1] << endl;
        int value = array[i];
        int j = i -1;
        while(j >= 0 && array[j] > value){
            array[j+1] = array[j];
            j--;
        }
        array[j+1] = value;
    }
    for(int k=0;k<n-1;k++)
        cout << array[k] << ' ';
    cout << array[n-1] << endl;
}
int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;i++)
        cin >> vec[i];
    insertionSort(vec,n);
}



Measured memory_bytes: 3136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[2]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = iA - iB;
            if (sS[1] == "+") { iOut = iA + iB; }

            //出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin>>n;
    
    string ans;
    while(n>0){
        n--;
        ll r=n%26;        
        ans+='a'+r;
        n/=26ll;        
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

int main() {
    ll N, K, C;
    cin >> N >> K >> C;
    string S;
    getline(cin, S);
    getline(cin, S);
    vector<ll> work(N, 0);
    for (ll i = 0; i < N; i++) {
        if (S.at(i) == 'o') {
            work[i] = 1;
        }
    }
    vector<ll> rightmax(N, 0);
    for (ll i = N - 1; i >= 0; i--) {
        if (i == N - 1) {
            rightmax[i] = work[i];
            continue;
        }
        if (i + C + 1 <= N - 1) {
            rightmax[i] = max(rightmax[i + 1], work[i] + rightmax[i + C + 1]);
        } else {
            rightmax[i] = max(rightmax[i + 1], work[i]);
        }
    }

    vector<ll> leftmax(N, 0);
    for (ll i = 0; i < N; i++) {
        if (i == 0) {
            leftmax[i] = work[i];
            continue;
        }
        if (i - C - 1 >= 0) {
            leftmax[i] = max(leftmax[i - 1], work[i] + leftmax[i - C - 1]);
        } else {
            leftmax[i] = max(leftmax[i - 1], work[i]);
        }
    }
    for (ll i = 0; i < N; i++) {
        ll total = 0;
        total += (i > 0) ? leftmax[i - 1] : 0;
        total += (i < N - 1) ? rightmax[i + 1] : 0;
        if (total < K) {
            print(i + 1);
        }
    }
}


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

using namespace std;

#define int long long
#define LL long long
#define ULL unsigned long long

const int LL_INF = ~(ULL)0 >> 1;

signed main() {
    string s;
    cin >> s;

    int max = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] != 'J') continue;

        int j, o, sti;
        for (j = i; j < s.size(); ++j) {
            if (s[j] != 'J') break;
        }
        for (o = j; o < s.size(); ++o) {
            if ((s[o] != 'O') || (j - i < o - j)) break;
        }
        for (sti = o; sti < s.size(); ++sti) {
            if (s[sti] != 'I') break;
        }

        int lenj = j - i, leno = o - j, leni = sti - o;
        if ((leno <= lenj) && (leno <= leni) && (0 < lenj) && (0 < leno) && (0 < leni)) {
            int temp = min(leni, min(leno, lenj));
            if (max < temp) max = temp;
        }

        i = j;
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int n,m,x,y;cin>>n>>m>>x>>y;
    int xx[n];
    int yy[m];
    for(int i = 0;i<n;i++) cin>>xx[i];
    for(int i = 0;i<m;i++) cin>>yy[i];
    sort(xx,xx+n);
    sort(yy,yy+m);
    for(int i=x+1;i<=y;i++){
        if(i>xx[n-1]&&i<=yy[0]){
          cout<<"No War";
          return 0;
        }
    }
    cout<<"War";
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
    int n,i,count=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        count+=a[i];
    }
    count=count-n;
    printf("%d\n",count);
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		int a= sc.nextInt();
		int b= sc.nextInt();
		int c= sc.nextInt();
		if(b-a == c-b){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 22996
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  if(b == 0)return a;
  return gcd(b,a%b);
}
int main(){
  ll n,m;
  cin >> n >> m;
  string s,t;
  cin >> s >> t;

  ll lcm = n * (m / gcd(n,m));

  map<int,char> dict;
  for(int i = 0;i < n;i++){
    dict[i * (lcm / n) + 1] = '*';
  }

  for(int i = 0;i < m;i++){
    dict[i * (lcm / m) + 1] = '*';
  }

  for(int i = 0;i < n;i++){
    dict[i * (lcm / n) + 1] = s[i];
  }

  for(int i = 0;i < m;i++){
    if(dict[i * (lcm / m) + 1] == '*')dict[i * (lcm / m) + 1] = t[i];
    else if(dict[i * (lcm / m) + 1] != t[i]){
      cout << -1 << endl;
      return 0;
    }
  }

  cout << lcm << endl;
}

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

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

int main(){
	int n;
	int snack[1001][4];
	while( cin >> n, n ){
		rep(i,n)	snack[i][0] = -1;
		rep(i,n){
			int k,p,q,r;
			cin >> k >> p >> q >> r;
			snack[i][0] = p;
			snack[i][1] = q;
			snack[i][2] = r;
			snack[i][3] = k;
		}
		int P, Q, R, C;
		cin >> P >> Q >> R >> C;
		bool first = true;
		rep(i,n){
			if( snack[i][0] != -1 ){
				if( snack[i][0] <= P &&
					snack[i][1] <= Q &&
					snack[i][2] <= R &&
					(snack[i][0]+snack[i][2])*4+snack[i][1]*9 <= C ){
					if(first)	first = false;
					cout << snack[i][3] << endl;
				}
			}
		}
		if(first)	cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#https://at274.hatenablog.com/entry/2020/06/29/181102
import collections
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
A=set(A)
MAX_A=10**6
X=[0]*(MAX_A + 1)#0-MAX_Aまでの整数がAの倍数で何回割られるか
for i in A:
  for j in range(i,MAX_A + 1,i):
    X[j]+=1

#割られた回数が1つしかないものはその数自身で割ったのでカウント
#ただし複数ある場合は除外
ans = len([a for a in A if (X[a] == 1) and (c[a] == 1)])
print(ans)

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

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		int X = scanner.nextInt();

		//長さMのint型配列arrayを宣言
		int[] array = new int[M];

		//arrayに値を追加
		for (int i = 0; i < M; i++) {
			array[i] = scanner.nextInt();
		}

		/*
		for (int i : array) {
			System.out.println("array：" + i);
		}
		*/

		//Integer型の配列cellを宣言(コストを表す)
		int[] cell = new int[N+1];

		//全てのマスのコストは0とする
		Arrays.fill(cell, 0);

		//arrayに入っている値のマスのコストは1
		for (int i : array) {
			cell[i] = 1;
		}

		/*
		for (int i : cell) {
			System.out.println("cell：" + i);
		}
		*/

		//最小コストの計算
		//スタート地点はcell[X]
		//0がゴールの場合
		int cost0 = 0;
		for (int i = X; i >= 0; i--) {
			cost0 += cell[i];
		}

		int costN = 0;
		//Nがゴールの場合
		for (int i = X; i < N+1; i++) {
			costN += cell[i];
		}

		//System.out.println("cost0：" + cost0);
		//System.out.println("costN：" + costN);

		int cost = cost0 <= costN ? cost0 : costN;
		System.out.println(cost);
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n],ans = 0;
    for(int i = 0; i < n; i++) cin >> a[i];

    sort(a,a+n,greater<int>());

    for(int i = 0; i < n; i++){
        if(i % 2) ans -= a[i];
        else ans += a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns        #-}
{-# LANGUAGE FlexibleContexts    #-}
{-# LANGUAGE RankNTypes          #-}
{-# LANGUAGE ScopedTypeVariables #-}
import           Control.Applicative
import           Control.Monad
import           Control.Monad.State
import           Data.Array.IArray
import           Data.Array.ST
import           Data.Array.Unboxed
import qualified Data.ByteString.Char8 as BS
import           Data.Char
import           Data.List


main :: IO ()
main = do
  n <- readLn :: IO Int
  ps <- readLnAsArrayWith unconsDouble n :: IO (UArray Int Double)

  let dp = solve n ps

  print $ sum $ map (\j -> dp ! (n,j)) [(n`div`2+1)..n]

solve :: Int -> UArray Int Double -> UArray (Int,Int) Double
solve n ps = runSTUArray $ do
  dp <- newArray ((0,0),(n,n)) 0.0

  writeArray dp (0,0) 1.0

  forM_ [0..n-1] $ \i -> do
    let p = ps ! (i+1)
    forM_ [0..i] $ \j -> do
      q <- readArray dp (i,j)
      q1 <- readArray dp (i+1,j+1)
      q2 <- readArray dp (i+1,j)
      writeArray dp (i+1,j+1) $ q1 + q * p
      writeArray dp (i+1,j) $ q2 + q * (1 - p)
  return dp


unconsDouble :: StateT BS.ByteString Maybe Double
unconsDouble = StateT $ parse dbl . BS.dropWhile isSpace

newtype Parser a = P (BS.ByteString -> Maybe (a, BS.ByteString))

parse :: Parser a -> BS.ByteString -> Maybe (a, BS.ByteString)
parse (P p) = p

item :: Parser Char
item = P BS.uncons

instance Functor Parser where
  fmap g p = P $ \inp -> case parse p inp of
                           Nothing       -> Nothing
                           Just (v, out) -> Just (g v, out)

instance Applicative Parser where
  pure v = P $ \inp -> Just (v, inp)

  pg <*> px = P $ \inp -> case parse pg inp of
                            Nothing       -> Nothing
                            Just (g, out) -> parse (fmap g px) out

instance Monad Parser where
  return = pure
  p >>= f = P $ \inp -> case parse p inp of
                          Nothing       -> Nothing
                          Just (v, out) -> parse (f v) out

instance Alternative Parser where
  empty = P $ const Nothing
  p <|> q = P $ \inp -> case parse p inp of
                          Nothing       -> parse q inp
                          Just (v, out) -> Just (v, out)


sat :: (Char -> Bool) -> Parser Char
sat p = do
  x <- item
  if p x then return x else empty

digit :: Parser Char
digit = sat isDigit

char :: Char -> Parser Char
char x = sat (==x)

dbl :: Parser Double
dbl = (char '-' >> (negate <$> natdot)) <|> natdot
  where natdot = (\xs _ ys -> read $ xs <> "." <> ys) <$> some digit <*> char '.' <*> some digit
          <|> read <$> some digit






-- 1D Data
-- for list
readLnAsListWith :: StateT BS.ByteString Maybe a -> IO [a]
readLnAsListWith !st = unfoldr (runStateT st) <$> BS.getLine

-- for array (boxed or unboxed)
readLnAsArrayWith :: IArray a e => StateT BS.ByteString Maybe e -> Int -> IO (a Int e)
readLnAsArrayWith !st !n = listArray (1,n) <$> readLnAsListWith st



Measured memory_bytes: 75412
using System;

class ITP1_4_C
{
    public static void Main()
    {
        int[] Output = new int[10000];
        int count = 0;

        for (; count < 10000; count++)
        {
            string[] Input = Console.ReadLine().Split(' ');

            int a = int.Parse(Input[0]);
            int b = int.Parse(Input[2]);
            int answer = 0;

            if (Input[1] == "?")
                break;

            switch (Input[1])
            {
                case "+":
                    answer = a + b;
                    break;
                case "-":
                    answer = a - b;
                    break;
                case "*":
                    answer = a * b;
                    break;
                case "/":
                    answer = a / b;
                    break;
            }

            Output[count] = answer;
        }

        for (int i = 0; i < count; i++)
            Console.WriteLine(Output[i]);
    }
}

Measured memory_bytes: 9204
#include <iostream>
#include<sstream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<iomanip>
#define  mem(a,b) memset(a,b,sizeof(a))

const int mo=1000000007;
const int inf=0x3f3f3f3f;
double pi=3.14159265358979323846;
double e= 2.71828182845904523536;
typedef long long ll;
using namespace std;

int main()
{
    int n;
    cin>>n;
    if(n<=999)
        cout<<"ABC";
    else
        cout<<"ABD";
    return 0;
}




Measured memory_bytes: 256
import fractions

def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    n = int(input())
    task = [tuple(map(int, input().split())) for _ in range(n)]
    tmp = 0
    task.sort(key=lambda x:x[1])
    for a, b in task:
        tmp += a
        if tmp > b:
            print("No")
            return
    print("Yes")

main()

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

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
  int N,f=0,t=0,o=0;
  string ans="No";
  cin >> N;
  vector<int> a(N);
  rep(i,N) {
    cin >> a[i];
    if(a[i]%4==0) f++;
    else if(a[i]%2==0) t++;
    else o++;
  }
  
  if(f>o-1) ans = "Yes";
  else if(f>o-2) {
    if(t==0) ans = "Yes";
    else if(t==0) ans = "No";
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
typedef pair<int,int> pii;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second


void solve()
{
    int a,b,c,d;cin>>a>>b>>c>>d;
    if(a!=c)cout<<1<<endl;
    else cout<<0<<endl;

}

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


Measured memory_bytes: 256
def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

def resolve():
  n, k = map(int, input().split())
  a = list(map(int, input().split()))
  if k in a:
    print('POSSIBLE')
    return

  if k > max(a):
    print('IMPOSSIBLE')
    return

  g = a[0]
  for x in a:
    g = gcd(x, g)

  for x in a:
    if x < k:
      continue
    if (x - k) % g == 0:
      print('POSSIBLE')
      return

  print('IMPOSSIBLE')
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 20000
#include<bits/stdc++.h>
using namespace std;
char s[1003],t[1003];
int n,m,ans,q;
int main()
{
    scanf("%s",s);
    scanf("%s",t);
    n=strlen(s);
    m=strlen(t);
    ans=m;
    for(int i=0;i<=n-m;++i)
    {
        q=m;
        for(int j=0;j<m;++j)
        {
            q-=s[i+j]==t[j];
        }
        ans=min(ans,q);
    }
    printf("%d\n",ans);
    return 0;
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

// dp[i][S] := 左からi人の男性と，女性の部分集合Sでマッチングする場合の数
// dp[S] := 左からbitcount[S](ビットが立っている個数)人の男性と

// dp[0] = 1
// dp[S] = Sum dp[S/l] * a[bitcnt[S]-1][l] l \in S

ll dp[1 << 21];
ll a[25][25];
ll bitcnt[1<<21];
ll mod = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    rep(i, n) {
        rep(j, n) {
            cin >> a[i][j];
        }
    }

    dp[0] = 1;
    for (int s = 1; s < (1<<n); ++s) {
        bitcnt[s] = bitcnt[s/2] + s % 2;    // 最後の一桁以外のところは/2で分かり，最後の一桁は剰余でわかる
        for (int l = 0; l < n; ++l) {
            if ((s >> l) % 2 == 0) continue;
            dp[s] += dp[s - (1 << l)] * a[bitcnt[s] - 1][l];
            dp[s] %= mod;
        }
    }

    cout << dp[(1 << n) - 1] << endl;
}


Measured memory_bytes: 33024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    public static void Main()
    {
        var a = Read.Long();
        var b = Read.Long();
        var n = Read.Long();
        long x = Min(b - 1, n);
        long result = (long)((a * x) / (double)b) - a * (long)(x / (double)b);
        WriteLine($"{result}");
    }
}

static class Read
{
    static Queue<string> queue = new Queue<string>();
    static void Enqueue()
    {
        ReadLine().Split(' ').ToList().ForEach(a => queue.Enqueue(a));
    }
    public static int Int()
    {
        if(queue.Count == 0)
            Enqueue();
        return int.Parse(queue.Dequeue());
    }
    public static long Long()
    {
        if(queue.Count == 0)
            Enqueue();
        return long.Parse(queue.Dequeue());
    }
    public static double Double()
    {
        if(queue.Count == 0)
            Enqueue();
        return double.Parse(queue.Dequeue());
    }
    public static string String()
    {
        if(queue.Count == 0)
            Enqueue();
        return queue.Dequeue();
    }
}


Measured memory_bytes: 18864
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Program{
  public static void Main(){

    int n = int.Parse(Console.ReadLine());
    var input = Console.ReadLine().Split();
    
    int mx = 0;
    int mn = 1001;
    for(int i=0; i<n; i++){
      int k = int.Parse(input[i]);
      if(mx < k) mx = k;
      if(mn > k) mn = k;
    }
    Console.WriteLine(mx - mn);

  }
}

Measured memory_bytes: 11092
import numpy as np
h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
a=np.reshape(a,(h,w))
a=a[:,np.any(a=='#',axis=0)][np.any(a=='#',axis=1),:]
[print("".join(a[i])) for i in range(a.shape[0])]

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int A,B;
    cin >> A >> B;
    B += A*3;
    cout << B/2 << endl;
    return 0;
}

Measured memory_bytes: 764
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
int n,b,i,j;
scanf("%d%d",&n,&b);
char s[n+1][b+1];
for(i=0;i<n;i++)
{
	scanf("%s",s[i]);
}
for(i=0;i<n;i++)
{
	for(j=i+1;j<n;j++)
	{
		if(strcmp(s[i],s[j])>0)
		{
			char tem[b+1];
			strcpy(tem,s[i]);
			strcpy(s[i],s[j]);
			strcpy(s[j],tem);
		}
	}
}
for(i=0;i<n;i++)
{
	printf("%s",s[i]);
}
}

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

void dijkstra(int s);
const int Infty = 20000000;

int **M,*d,*p,n;
string *color;

int main(){
	cin>>n;
	M = new int*[n]; for(int i=0;i<n;i++) M[i] = new int[n];
	d = new int[n]; p = new int[n]; color = new string[n];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++) M[i][j] = -1;
	}

	for(int i=0;i<n;i++){
		int vertex,deg,e,w;
		cin>>vertex>>deg;
		for(int j=0;j<deg;j++){
			cin>>e>>w;
			M[i][e]  = w;
		}
	}

	dijkstra(0);

	for(int i=0;i<n;i++) delete [] M[i]; delete [] M;
	delete [] d; delete [] p; delete [] color;
}

void dijkstra(int s){
	for(int i=0;i<n;i++){
		d[i] = Infty; color[i] = "WHITE";
	}
	d[s] = 0; p[s] = -1;

	while(true){
		int u , mindist = Infty;
		for(int i=0;i<n;i++){
			if(color[i]!="BLACK" && d[i]<mindist){
				mindist = d[i];
				u = i;
			}
		}

		if(mindist==Infty) break;

		color[u] = "BLACK";

		for(int v=0;v<n;v++){
			if(color[v]!="BLACK" && M[u][v]!=-1){
				if(d[u]+M[u][v]<d[v]){
					d[v] = d[u]+M[u][v];
					p[v] = u;
					color[v] = "GRAY";
				}
			}
		}
	}

	for(int i=0;i<n;i++)
		cout<<i<<" "<<d[i]<<endl;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    if(M%2){
        for(int i=0;i<M/2;i++){
            cout << i+1 << " " << M-i << "\n";
        }
        for(int i=0;i<=M/2;i++){
            cout << M+1+i << " " << 2*M+1-i << "\n";
        }
    }else{
        for(int i=0;i<M/2;i++){
            cout << i+1 << " " << M+1-i << "\n";
            cout << M+i+2 << " " << 2*M+1-i << "\n";
        }
    }
}

Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int h, w, n, sr, sc, u, d, r,l, ans = 0;
	string s, t;
	cin >> h >> w >> n >> sr >> sc >> s >> t;
	u = sr;// sr;
	d = sr;//h - sr + 1;
	r = sc;//w - sc + 1;
	l = sc;//sc;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'U')u = u - 1;
		if (s[i] == 'D')d = d + 1;
		if (s[i] == 'R')r = r + 1;
		if (s[i] == 'L')l = l - 1;
		if (u == 0) ans = 1;
		if (d > h) ans = 1;
		if (r > w) ans = 1;
		if (l == 0) ans = 1;
		if (t[i] == 'U')d = d - 1;
		if (t[i] == 'D')u = u + 1;
		if (t[i] == 'R')l = l + 1;
		if (t[i] == 'L')r = r - 1;
		d = max(d, 1);
		u = min(u, h);
		l = min(l, w);
		r = max(r, 1);
	}
	if (ans == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	

}

Measured memory_bytes: 776
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] pri = new int[1000002];
		for(int i=2;i<=1000000;i++){
			pri[i] = i;
		}
		for(int i=2;i<=1000000;i++){
			for(int j=i+i;j<=1000000;j+=i){
					pri[j]=0;
			}
		}
		
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int count=0;
			
			for(int i=0;i<=n/2;i++){
				if(pri[i]!=0 && pri[n-i]!=0)count++;
			}
			System.out.println(count);
			

		}
	}	
}

Measured memory_bytes: 25584
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int c,sum;
char b[10000],a[10000];
int main(){
	a[0]='C';
	a[1]='O';
	a[2]='D';
	a[3]='E';
	a[4]='F';
	a[5]='E';
	a[6]='S';
	a[7]='T';
	a[8]='I';
	a[9]='V';
	a[10]='A';
	a[11]='L';
	a[12]='2';
	a[13]='0';
	a[14]='1';
	a[15]='6';
	cin>>b;
	for(int i=0;i<16;i++){
		if(a[i]!=b[i]){
			sum++;
		}
	}
	cout<<sum;
	return 0;
}

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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

struct Block {
    ll w, s, v;
    bool operator<(const Block &rhs) const {
        return s + w < rhs.s + rhs.w;
    }
};

void solve() {
    int N;
    cin >> N;
    vector<Block> B(N);
    for (int i = 0; i < N; i++) {
        ll w, s, v;
        cin >> w >> s >> v;
        B[i] = {w, s, v};
    }
    sort(all(B));

    const ll inf = 2e18;
    vector<vector<ll>> dp(N + 1, vector<ll>(20001, -inf));
    dp[0][0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= 20000; j++) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j <= B[i].s && j + B[i].w <= 20000) {
                dp[i + 1][j + B[i].w] = max(dp[i + 1][j + B[i].w], dp[i][j] + B[i].v);
            }
        }
    }

    ll ans = 0;
    for(int j = 0; j <= 20000; j++) {
        ans = max(ans, dp[N][j]);
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

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

using namespace std;

const int N = 2e5 + 7;
int n;


int main() {
    std :: ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long ans=0;
    int k;
    cin >>  n >> k;
    vector < int > vt(n);
    for(int i = 0 ; i < n ; ++i) {
        cin >> vt[i];
    }
    sort(vt.begin(),vt.end());
    for(int i = 0 ; i < k ; ++i) ans += vt[i];
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3660
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
using namespace std;
#define EPS (1e-10)
#define equals(a,b) (fabs((a) - (b)) < EPS)
class Point{
public:
  double x,y;
  Point(double x = 0, double y = 0):x(x), y(y) {}
  Point operator + (Point p){
    return Point(x+p.x,y+p.y);
  }
  Point operator - (Point p){
    return Point(x-p.x,y-p.y);
  }
  Point operator * (double k){
    return Point(x*k,y*k);
  }
  Point operator / (double k){
    return Point(x/k,y/k);
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};
typedef Point Vector;
double norm(Vector a){
  return pow(a.x,2.0)+pow(a.y,2.0);
}
double abs(Vector a){
  return sqrt(norm(a));
}
class Circle{
public:
  Point c;
  double r;
  Circle(Point c = Point(),double r = 0.0):c(c),r(r){}
};
int check(Circle a,Circle b){
  double d1 = abs(b.c-a.c) , d2 = (a.r+b.r);
  
  if(d1+b.r-a.r<0) return 2;
  if(d1+a.r-b.r<0) return -2;
  if(d1-d2<=0) return 1;
  return 0;
}
int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    Point a,b;
    double r1,r2;
    cin >> a.x >> a.y >> r1 >> b.x >> b.y >> r2;
    Circle c1(a,r1),c2(b,r2);
    cout << check(c1,c2) << endl;
  }
  return 0;
}

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

int main() {
    int n;
    string s;
    map<string, int> mp;

    cin >> n;
    while(n--) {
        cin >> s;
        mp[s]++;
    }

    printf("AC x %d\n", mp["AC"]);
    printf("WA x %d\n", mp["WA"]);
    printf("TLE x %d\n", mp["TLE"]);
    printf("RE x %d\n", mp["RE"]);
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int,P> P3;
typedef pair<double, P3> P4;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(3e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    for(int i=min(a,b);i>0;i--){
        if(a%i==0 && b%i==0)k--;
        if(k==0){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)



int main()
{
	ll n, m;
	cin >> n >> m;
	vector<bool> ac(n, false);
	vector<ll> wa(n, 0); 
	
	ll p;
	string s;
	rep(i, m)
	{
		cin >> p >> s;
		if (ac[p - 1] == false)
		{
			if (s == "AC")
			{
				ac[p - 1] = true;
			}
			else
			{
				wa[p - 1]++;
			}
		}
	}

	ll x, y;
	x = y = 0;
	rep(i, n)
	{
		if (ac[i])
		{
			x++;
			y += wa[i];
		}
	}

	cout << x << " " << y << "\n";


	return 0;
}

Measured memory_bytes: 3968
#l[index]>keyとなる最小のindexを求める
def binary_search_left(array,key)
    ng=-1
    ok=array.length
    while (ok-ng).abs>1
        mid=(ng+ok).div(2)
        if key>array[mid]
            ng=mid
        else
        ok=mid
        end
    end
    return ng
    
end
#key>l[index]の最大のindexを求める
def binary_search_right(array,key)
    ng=-1
    ok=array.length
    while (ok-ng).abs>1
        mid=(ng+ok).div(2)
        if key>=array[mid]
            ng=mid
        else
        ok=mid
        end
    end
    return ok
    
end



n =gets.to_i
@a=gets.split.map(&:to_i)
@b=gets.split.map(&:to_i)
@c=gets.split.map(&:to_i)
 
@a=@a.sort
@c=@c.sort
answer=0
for i in 0..@b.length-1
    #配列が0からより＋1
    aa=binary_search_left(@a,@b[i])+1
    cc=(n-binary_search_right(@c,@b[i]))
    answer+=aa*cc

end
p answer

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int64_t> h(n);
    for (auto& e : h) cin >> e;

    sort(begin(h), end(h));
    int64_t ans = 1e10;
    for (int i = 0; i + k - 1 < n; i++) ans = min(ans, h[i+k-1] - h[i]);
    cout << ans << endl;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

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<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);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    int c = 0;
    int ans = 0;
    REP(i,N){
        int a;
        cin >> a;

        if(a==i+1){
            if(c==0) {
                ans++;
                c++;
            } else {
                c = 0;
            }
        } else {
            c = 0;
        }
    }

    pl(ans)

    return 0;
}


Measured memory_bytes: 256
x, y = gets.split.map(&:to_i)
cnt = (x.abs - y.abs).abs
if x == y
elsif x.abs == y.abs
  cnt += 1
elsif x >= 0 && x < y
elsif y > 0 && x > y
  cnt += 2
elsif y == 0 && x > y
  cnt += 1
elsif x < 0 && x > y
  cnt += 2
elsif x == 0 && x > y
  cnt += 1
elsif y <= 0 && x < y
#elsif x > y
#  cnt += 1
#elsif x < y && x.abs < y.abs
#  cnt += 1
#elsif x < y && x.abs > y.abs
else
  cnt += 1
end
puts cnt

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

n, k, q = map(int, input().split())
A = list(map(int, input().split())) + [-1]
ans = float("inf")
for a in A:
  L = []
  K = []
  for t in A:
    if t >= a:
      L.append(t)
    else:
      L.sort()
      for c in range(len(L)-k+1):
        K.append(L[c])
      L = []
  K.sort()
  if len(K) < q:
    continue
  else:
    y = K[q-1]
    ans = min(ans, y-a)
print(ans)

Measured memory_bytes: 75304
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ZYCSwing
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            out.println((100 * n + 1800 * m) << m);
        }

    }
}



Measured memory_bytes: 21460
import java.io.*;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int x=Integer.parseInt(scan.next());
    int y=Integer.parseInt(scan.next());
    if(x<y){
      int tmp=x;
      x=y;
      y=tmp;
    }
    while(y>0){
      int r=x%y;
      x=y;
      y=r;
    }

    System.out.println(x);
  }
}



Measured memory_bytes: 25888
from collections import deque

k = int(input())

visited = [False]*(k+1)
dist = [0]*(k+1)
dist[1] = 1
que = deque([(1, 1)])

while len(que) > 0:
    cost, node = que.popleft()
    if visited[node]:
        continue
    
    visited[node] = True
    dist[node] = cost

    if not visited[10*node%k]:
        que.appendleft((cost, 10*node%k))
    if not visited[(node+1)%k]:
        que.append((cost+1, (node+1)%k))

print(dist[0])


Measured memory_bytes: 10556
#include <stdio.h>

int main() {
	
	char input[20];
	scanf("%s", &input);
	input[5] = ' ';
	input[13] = ' ';
	
	for(int i = 0 ; input[i] != '\0'; i++){
		printf("%c", input[i]);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 1656
# sys.stdin.readline()
import sys
input = sys.stdin.readline

n = int(input())
ans = n
for x in range(n+1):
    c = 0
    t = x
    for i in range(10**5):
        c += t%6
        t //= 6
        if t <= 0:
            break
    t = n-x
    for j in range(10**5):
        c += t%9
        t //= 9
        if t <= 0:
            break
    if ans > c:
        ans = c
print(ans)


Measured memory_bytes: 3060
#include <cmath>
#include <iostream>
//#include <string>
using namespace std;

int main(){
  int A,B,C,K;
  string ans="No";
  cin >> A >> B >> C;
  cin >> K;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K-i;j++){
      if(A<B*pow(2,i)&&B*pow(2,i)<C*pow(2,j)) ans="Yes";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4064
/*
Look at the star
Look at the shine for U
*/ 

#include<bits/stdc++.h>
#define sl(x) scanf("%d",&x)
using namespace std;
const int INF = 0x3f3f3f;
const int N = 1e6+5;
const int mod = 1e9+7;

int main()
{
	int n,m;
	sl(n);sl(m);
	if(n < m)
	{
		puts("1");
		return 0;
	}
	if(n%m == 0) puts("0");
	else puts("1");
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void print(int H, int W) {
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
           if (i == 0 || i == H - 1 || j == 0 || j == W - 1)
               cout << '#';
           else
               cout << ".";
        }
        cout << endl;
    }
}

int main() {
    int H, W;
    while (cin >> H >> W) {
        if (H == 0 && W == 0) {
            break;
        }
        print(H, W);
        cout << endl;
    }
    return 0;
}


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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k, d, t;
    cin >> n >> k;
    unordered_map<int, int> f;
    for (int i = 0; i < k; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> t;
            f[t]++;
        }
    }

    int ans =0 ;
    for (int i = 1; i <= n; i++)
    {
        if (f[i] == 0)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
import sys
sys.setrecursionlimit(10**9)

N,K = map(int,input().split())
P = [ i-1 for i in list(map(int,input().split())) ]
C = list(map(int,input().split()))
ans = -float('inf')

for i in range(N):
  cycle = []
  tot = 0
  nex = i
  while True:
    nex = P[nex]
    cycle.append(C[nex])
    tot += C[nex]
    if nex == i: break

  l = len(cycle)
  t = 0
  for j in range(l):
    t += cycle[j]
    if j+1 > K: break
    now = t
    if tot > 0:
      now += tot*((K-(j+1))//l)
    ans = max(ans, now)

print(ans)


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

int main() {
	string s; cin >> s;
	for (int i = 0; i < (int) s.size(); i++) {
		if ((i % 2 && s[i] == 'R') || (i % 2 == 0 && s[i] == 'L')) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}


Measured memory_bytes: 256