akhauriyash/Code-Regression huggingface dataset:
import * as fs from "fs";

let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const n = +input[0];
const a = input[1].split(" ").map((x: string): number => +x);
const b = input[2].split(" ").map((x: string): number => +x);
const c = input[3].split(" ").map((x: string): number => +x);

const cmp = (a: number, b: number):number => a - b;
a.sort(cmp);
b.sort(cmp);
c.sort(cmp);

const dp = new Array<number>(n); // dp[i]: Biを用いた場合のB,Cのパターン数

let ic=n;
for(let i=n-1; i>=0; i--){
	while(ic-1 >= 0 && c[ic-1] > b[i]) ic--;
	if(i==n-1) dp[i] = n-ic;
	else dp[i] = dp[i+1]+n-ic;
}

let result = 0;
let ib = 0;
for(let i=0; i<n; i++){
	while(ib<n && b[ib] <= a[i]) ib++;
	if(ib>=n) break;
	result += dp[ib];
}

console.log(result);


Measured memory_bytes: 56444
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    set<int> have_okashi;
    rep(i, k) {
        int d;
        cin >> d;
        rep(j,d) {
            int a;
            cin >> a;
            have_okashi.insert(a);
        }
    }
    cout << n-have_okashi.size() << endl;
}

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

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    int ans = a[0];
    for (int j = 1; j < n; ++j) ans = gcd(ans, a[j]);
    cout << ans << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
#define gc getchar_unlocked
#define fo(i, n) for (i = 0; i < n; i++)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%I64d", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d", &x)
#define pl(x) printf("%I64d", x)
#define pb push_back
#define em emplace_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define clr(x) memset(x, 0, sizeof(x))
#define PI 3.1415926535897932384626s
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
const int mod = 1e9 + 7;
ll epow(ll base, ll pow)
{
    ll result = 1;
    while (pow)
    {
        if (!(pow % 2))
        {
            base = (base * base) % mod;
            pow /= 2;
        }
        else
        {
            result = (result * base) % mod;
            pow--;
        }
    }
    return result;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("E:/BE/input.txt", "r", stdin);
    freopen("E:/BE/output.txt", "w", stdout);
#endif
  int i, j;
    si(i), si(j);

    if (j >= i)
        cout << "unsafe" << endl;
    else
    {
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3784
#coding:UTF-8

while True:
	a,op,b = map(str,raw_input().split())
	a = int(a)
	b = int(b)

	if op == '+':
	    print(a+b)
	elif op == '-':
		print(a-b)
	elif op == '*':
		print(a*b)
	elif op == '/':
		print(a/b)
	else:
	    break

Measured memory_bytes: 6288
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char in[4100];
int C[4100];
int dp[2100][2100];
int sum[2][4100][2100];
int ad[2][2100];
int calc(int a,int b,int c,int d,int e){
	return sum[a][d+1][e+1]-sum[a][b][e+1]-sum[a][d+1][c]+sum[a][b][c];
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a*2;i++){
		scanf("%s%d",in+i,C+i);
		C[i]--;
		if(in[i]=='W'){
			sum[0][i+1][C[i]+1]++;
			ad[0][C[i]]=i;
		}else{
			sum[1][i+1][C[i]+1]++;
			ad[1][C[i]]=i;
		}
	}
	for(int i=0;i<2;i++)for(int j=0;j<4050;j++)for(int k=0;k<2050;k++){
		sum[i][j+1][k]+=sum[i][j][k];
	}
	for(int i=0;i<2;i++)for(int j=0;j<4050;j++)for(int k=0;k<2050;k++){
		sum[i][j][k+1]+=sum[i][j][k];
	}
	
	for(int i=0;i<2100;i++)for(int j=0;j<2100;j++)
		dp[i][j]=mod;
	dp[0][0]=0;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=a;j++){
		//	printf("%d %d: %d\n",i,j,dp[i][j]);
			if(i<a){
				int cost=a*2-1-(i+j)-calc(0,ad[0][i]+1,i+1,a*2,a)-calc(1,ad[0][i]+1,j,a*2,a);
				dp[i+1][j]=min(dp[i+1][j],dp[i][j]+cost);
			}
			if(j<a){
				int cost=a*2-1-(i+j)-calc(0,ad[1][j]+1,i,a*2,a)-calc(1,ad[1][j]+1,j+1,a*2,a);
				dp[i][j+1]=min(dp[i][j+1],dp[i][j]+cost);
			}
		}
	}
	printf("%d\n",dp[a][a]);
}

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

int main(){
    int n,k;
    cin >> n;
    vector<int> a(n);
    rep(i,0,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    int ans = 0;


    if(a.at(n/2)==a.at(n/2-1)){
        cout << 0 << endl;
        return 0;
    }else{
        cout << a.at(n/2) - a.at(n/2-1) << endl;
        return 0;
    }

}

Measured memory_bytes: 3772
l,r=map(int,input().split())
a=2019
lpre=l//a
rpre=r//a
if lpre==rpre:
    l=l%a
    r=r%a
else:
    l=l%a
    r=r%a+a
my_min=float("INF")
for i in range(l,r+1):
    for j in range(i+1,r+1):
        b=(i*j)%a
        if b<my_min:
            my_min=b

print(my_min)
        

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int H,W,h,w;
  cin >> H >> W >> h >> w;

  cout << H * W - h * W - w * H + h * w << endl;
}



Measured memory_bytes: 256
n = gets.to_i
h = Hash.new(0)
filled = 0
k = 0
done = false
n.times do
  x = gets.to_i

  if done
    puts 'No'
    next
  end

  if x < filled
    puts 'No'
    next
  end

  if x == filled
    if filled == k
      puts 'Yes'
      done = true
    else
      puts 'No'
    end
    next
  end

  puts 'Yes'
  k += 1
  h[x] += 1
  if x == filled + 1
    x += 1 until h[x] == 0
    filled = x - 1
  else
    until h[x] == 1
      h[x] = 0 
      k -= 1
      h[x -= 1] += 1
    end
    filled += 1 if x == filled + 1
  end
end



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

#define BUF_SIZE 2096
int main(void) {
  char line[BUF_SIZE];
  FILE *fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int num, i;
  sscanf(line, "%d", &num);


  int max = 0;
  
  int min = INT_MAX;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  char *tmpbuf = line;;
  for(i = 0; i < num; i++) {
    char *buf = strtok(tmpbuf, " ");
    int elem = strtol(buf, NULL, 10);
    if(elem > max) max = elem;
    if(elem < min) min = elem;
    tmpbuf = NULL;
  }
  printf("%d\n", max - min);
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string A = Console.ReadLine();
            string B = Console.ReadLine();
            string ans = "EQUAL";
            if (A == B)
            {
                Console.WriteLine(ans);
                Console.ReadLine();
                return;
            }

            if (A.Length > B.Length)
            {
                ans = "GREATER";
                Console.WriteLine(ans);
                Console.ReadLine();
                return;
            }
            else if (A.Length < B.Length)
            {
                ans = "LESS";
                Console.WriteLine(ans);
                Console.ReadLine();
                return;
            }

            for (int i = 0; i < A.Length; i++)
            {
                if (int.Parse(A[i].ToString()) > int.Parse(B[i].ToString()))
                {
                    ans = "GREATER";
                    Console.WriteLine(ans);
                    Console.ReadLine();
                    return;

                }
                else if (int.Parse(A[i].ToString()) < int.Parse(B[i].ToString()))
                {
                    ans = "LESS";
                    Console.WriteLine(ans);
                    Console.ReadLine();
                    return;
                }
            }

        }
    }
}


Measured memory_bytes: 11092
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

signed main(){
    string s;
    cin >> s;
    int n = s.length();

    vector<vector<int>> charPos(26, vector<int>());
    rep(i, n){
        charPos[s[i]-'a'].push_back(i+1);
    }
    rep(i, 26){
        charPos[i].push_back(INF);
    }

    vector<int> pos;
    set<char> cs;
    vector<int> len(n+1);
    for(int i = n; i >= 0; i--){
        int far = 0;

        rep(c, 26){
            int lo = -1;
            int hi = charPos[c].size()-1;

            while(hi - lo > 1){
                int mid = (lo + hi) / 2;
                if(charPos[c][mid] > i){
                    hi = mid;
                }else{
                    lo = mid;
                }
            }

            far = max(far, charPos[c][hi]);
        }

        if(far == INF){
            len[i] = 1;
            continue;
        }

        len[i] = len[far] + 1;
    }

    string ans = "";
    int current = 0;
    rep(i, len[0]){
        rep(c, 26){
            int lo = -1;
            int hi = charPos[c].size()-1;

            while(hi - lo > 1){
                int mid = (lo + hi) / 2;
                if(charPos[c][mid] > current){
                    hi = mid;
                }else{
                    lo = mid;
                }
            }

            if(charPos[c][hi] == INF || len[charPos[c][hi]] + 1 == len[0] - i){
                current = charPos[c][hi];
                ans.push_back('a' + c);
                break;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3964
#include "bits/stdc++.h"
using namespace std;
const int MAXN=1e5+1,OO=0x3f3f3f3f;
typedef  long long ll;
int main(){
int n,k,ans=0,x; cin>>n>>k;
  while(n--)
      cin>>x,ans+=(x>=k);
  cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int arr[] = new int[n];
		
		for(int i=0; i<n; i++){
			arr[i] = sc.nextInt();
		}
		
		int count =1;
		int prev = arr[0];
		boolean flag = true;
		int i=1;
		
		while(i<n){
			if(arr[i] > prev){
				flag = true;
				prev = arr[i];
			}else if(arr[i] < prev){
				flag = false;
				prev = arr[i];	
			}else{
				i++;
				continue;
			}
			i++;
			
			for( ;i<n; i++){
				if(flag == true){
					if(arr[i] >= prev)
						prev =  arr[i];
					else{
						prev = arr[i];
						i++;
						count++;
						break;
					}
				}else{
					if(arr[i] <= prev)
						prev =  arr[i];
					else{
						prev = arr[i];
						i++;
						count++;
						break;
					}
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 50316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n);
  map<ll, int> cnt;
  rep(i, n) {
    cin >> A[i];
    cnt[A[i]]++;
  }
  if(n%3) {
    if(cnt.size()==1 && cnt.count(0)) cout << "Yes" << endk;
    else cout << "No" << endl;
  } else {
    bool ok = true;
    for(auto ele: cnt) if(ele.second%(n/3)) ok = false;
    if(!ok) cout << "No" << endk;
    else {
      if(cnt.size()==1) {
        if(cnt.count(0)) cout << "Yes" << endk;
        else cout << "No" << endk;
      } else if(cnt.size()==2) {
        if(cnt.count(0) && cnt[0]==n/3) cout << "Yes" << endk;
        else cout << "No" << endk;
      } else if(cnt.size()==3) {
        vector<ll> B;
        for(auto ele: cnt) B.push_back(ele.first);
        if((B[0]^B[1]^B[2])==0 &&
           cnt[B[0]]==n/3 &&
           cnt[B[1]]==n/3 &&
           cnt[B[2]]==n/3) cout << "Yes" << endk;
        else cout << "No" << endk;
      } else {
        cout << "No" << endk;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 8584
#include<stdio.h>
int main(){
  int m,i,s=-1,c[4],t[4],p[4]={10,50,100,500};
  while(scanf("%d",&m),m){
    if(s>=0)printf("\n");
    for(i=0;i<4;i++)scanf("%d",&c[i]);
    for(i=s=0;i<4;i++)s+=c[i]*p[i];
    s-=m;
    for(i=4;i--;s%=p[i])t[i]=s/p[i];
    for(i=0;i<4;i++)c[i]-=t[i];
    for(i=0;i<4;i++){
      if(c[i]>0)printf("%d %d\n",p[i],c[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <sstream>
#include <cstdlib>


using namespace std;
 
int dp[10][10];
string S;
long long total_sum = 0;


 int main(void){

    cin >> S;

    int n = S.length();
    int ind_left;
    for(int mask=0;mask < (1<<(n-1));mask++){
      ind_left = 0;
        for(int i=0;i<n-1;i++){
            if(mask & (1<<i)){
                total_sum += stoll(S.substr(ind_left, i - ind_left + 1).c_str());
                ind_left = i + 1;
            }
        }
        total_sum += stoll(S.substr(ind_left, n - (ind_left)).c_str());
    }
    cout << total_sum << endl;
    return 0;

 }

Measured memory_bytes: 256
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	A := make([]int, n)
	B := make([]int, n)
	C := make([]int, n-1)

	for i := 0; i < n; i++ {
		A[i] = readInt()
	}
	for i := 0; i < n; i++ {
		B[i] = readInt()
	}
	for i := 0; i < n-1; i++ {
		C[i] = readInt()
	}

	ans := 0
	prev := 0
	for i := 0; i < n; i++ {
		ans += B[A[i]-1]
		if i > 0 && A[i]-1-prev == 1 {
			ans += C[prev]
		}
		prev = A[i] - 1
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import java.util.Scanner;

class Main
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int n;
        
         if(a > b){
             n = a;
             a = b;
             b = n;   
        }
          if(b > c){
             n = b;
             b = c;
             c = n;
    }
           if(a > b){
             n = a;
             a = b;
             b = n;
}
System.out.println(a + " " + b + " " + c);
    }
}


Measured memory_bytes: 26056
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    map<char, string> m;
    map<string, char> minv;
    m[' '] = "101";
    m['\''] = "000000";
    m[','] = "000011";
    m['-'] = "10010001";
    m['.'] = "010001";
    m['?'] = "000001";
    m['A'] = "100101";
    m['B'] = "10011010";
    m['C'] = "0101";
    m['D'] = "0001";
    m['E'] = "110";
    m['F'] = "01001";
    m['G'] = "10011011";
    m['H'] = "010000";
    m['I'] = "0111";
    m['J'] = "10011000";
    m['K'] = "0110";
    m['L'] = "00100";
    m['M'] = "10011001";
    m['N'] = "10011110";
    m['O'] = "00101";
    m['P'] = "111";
    m['Q'] = "10011111";
    m['R'] = "1000";
    m['S'] = "00110";
    m['T'] = "00111";
    m['U'] = "10011100";
    m['V'] = "10011101";
    m['W'] = "000010";
    m['X'] = "10010010";
    m['Y'] = "10010011";
    m['Z'] = "10010000";
    minv["00000"] = 'A';
    minv["00001"] = 'B';
    minv["00010"] = 'C';
    minv["00011"] = 'D';
    minv["00100"] = 'E';
    minv["00101"] = 'F';
    minv["00110"] = 'G';
    minv["00111"] = 'H';
    minv["01000"] = 'I';
    minv["01001"] = 'J';
    minv["01010"] = 'K';
    minv["01011"] = 'L';
    minv["01100"] = 'M';
    minv["01101"] = 'N';
    minv["01110"] = 'O';
    minv["01111"] = 'P';
    minv["10000"] = 'Q';
    minv["10001"] = 'R';
    minv["10010"] = 'S';
    minv["10011"] = 'T';
    minv["10100"] = 'U';
    minv["10101"] = 'V';
    minv["10110"] = 'W';
    minv["10111"] = 'X';
    minv["11000"] = 'Y';
    minv["11001"] = 'Z';
    minv["11010"] = ' ';
    minv["11011"] = '.';
    minv["11100"] = ',';
    minv["11101"] = '-';
    minv["11110"] = '\'';
    minv["11111"] = '?';
    string s;
    while(getline(cin, s)){
        string t;
        for (auto &&i : s) t += m[i];
        while(t.size()%5) t += '0';
        string ans;
        for (int i = 0; i < t.size(); i += 5) {
            cout << minv[t.substr(i, 5)];
        }
        puts("");
    }
    return 0;
}


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

int main()
{
    string str1, str2, str3;
    cin >> str1;
    str2 = str1;

    int i = 0, j = str1.size() - 1,count=0;
    while(i<=j){
        if(str1.at(i)!=str1.at(j)){
            count++;
        }
        i++;
        j--;
    }
    
    
    cout << count << endl;
    //cout << str3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int a,b;
int main() {
	//freopen("1.txt","r",stdin);
	read(a); read(b);
	for (int i=0;i<=100;i++) {
		if (1+i*(a-1)>=b) { printf("%d\n",i); break; }
	}
	return 0;
}

Measured memory_bytes: 256
import itertools
List=[int(input()) for i in range(5)]
List_2=list(itertools.permutations(List))
min = 100000
count = 0
for i in List_2:
  time = 0
  for j in i:
    if count != 4:
      time += j
      if time % 10 != 0:
        time = ((time // 10) + 1) * 10  
      count += 1
    elif count == 4 :
      time += j
      count = 0
  if time < min:
    min = time
print(min)


    

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

int main()
{
	int n,a[101],i;
	cin>>n;
	for(i=1;i<=n;i++) 
	{
		cin>>a[i];
	}
	i = n;
	for(;i>1;i--)
	{
		cout<<a[i]<<" ";
	}
	cout<<a[1]<<endl;
	return 0;
 } 


Measured memory_bytes: 3120
import Control.Monad

main :: IO ()
main = do
  l <- readLn
  if l == 0
    then return ()
    else do
      ls <- replicateM 12 getLine
      let ls' = map (map read . words) ls
          ans = solve l ls'
      putStrLn ans
      main

solve :: Int -> [[Int]] -> String
solve l ls = prof l ls 0
  where
    prof :: Int -> [[Int]] -> Int -> String
    --prof l ls acc count
    prof _ [] _ = "NA"
    prof l ([m,n]:xs) count
      | l - (m - n) <= 0 = show (count + 1)
      | otherwise = prof (l - (m - n)) xs (count + 1)

Measured memory_bytes: 4072
use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let a = read::<usize>();
    let s = read::<String>();
    if a < 3200 {
        println!("red")
    } else {
        println!("{}", s)
    }
}


Measured memory_bytes: 4352
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    r = Number(tmp0[0])
    console.log(3*r*r)
}
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("4\n");

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

constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    string s;
    map<string, ll> mp;
    REP(i,n) {
        cin >> s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll ans = 0;
    for (auto p:mp) {
        if (p.se == 1) continue;
        ans += p.se * (p.se - 1) / 2;
    }
    cout << ans << endl;
}

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

    /* Regular */
    int case_num = 1;
    if (argc > 1 && stoi(argv[1])) cin >> case_num;
    REP(case_no, case_num) {
      cerr << endl << "case " << case_no + 1 << endl;
      solve();
    }

    // /* AOJ */
    // solve();
    return 0;
}

Measured memory_bytes: 11264
n = int(input())
P = list(map(float,input().split()))
dp = [[0]*(n+1) for _ in range(n)]
dp[0][0] = 1-P[0]
dp[0][1] = P[0]
for i in range(1,n):
    for j in range(i+2):
        if j ==0:
            dp[i][j]= dp[i-1][j]*(1-P[i])
        else:
            dp[i][j] = P[i]*dp[i-1][j-1] + (1-P[i])*dp[i-1][j]

print(sum(dp[-1][(n+1)//2:]))

Measured memory_bytes: 204004
a,b=map(int,input().split())
d = list(map(int, input().split(" ")))
w = [0]*(len(d)+1)

# 累積和の計算
w[0] = 0
for i in range(0, len(d)):
  w[i+1] = w[i] + d[i]
  
ans = 0
for i in range(0, a-b+1):
    ans = max([ans,w[i+b]-w[i]])

d2 = 0.5*b + ans/2

if a == 1:
  print((d[0]+1)/2)
else:
  print(d2)

Measured memory_bytes: 24804
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

const int N = 1e5 + 10;
vector<pair<int, int>> edg[N];
bool col[N];

void dfs(int u, int f, bool c) {
  col[u] = c;
  for(int i = 0; i < int(edg[u].size()); i++) {
    if(edg[u][i].first != f) {
      dfs(edg[u][i].first, u, edg[u][i].second % 2 == 0 ? c : !c);
    }
  }
}

void Main() {
  int n; cin >> n;
  for(int i = 0; i < n; i++) {
    int u, v, w; cin >> u >> v >> w;
    edg[u].emplace_back(v, w);
    edg[v].emplace_back(u, w);
  }
  dfs(1, -1, 0);
  for(int i = 1; i <= n; i++) {
    cout << col[i] << "\n";
  }
}

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

int main() {
  int n, j;
  cin >> n;
  int a[n];
  for (int i = 1; i <= n; i++) {
    cin >> j;
    a[j - 1] = i;
  }
  cout << a[0];
  for (int i = 1; i < n; i++) {
    cout << ' ' << a[i];
  }
  cout << endl;
}

Measured memory_bytes: 1152
N, m = map(int, raw_input().split())
a = map(int, raw_input().split())
C = [-1, 2, 5, 5, 4, 5, 6, 3, 7, 6]

C = [C[A] for A in a]

dp = [-float('inf')] * (N + 1)
dp[0] = 0
for i in range(1, N + 1):
    for j in range(len(C)):
        if C[j] <= i:
            dp[i] = max(dp[i], dp[i - C[j]] * 10 + a[j])

print dp[N]


Measured memory_bytes: 43292
N, M = gets.split.map(&:to_i)
X = gets.split.map(&:to_i)

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

X.each do |x|
  mod_list[x % M] << x
end

ans = 0

0.upto(M / 2) do |m|
  listA = mod_list[m]
  listB = mod_list[M - m]
  a_size = listA.size
  b_size = listB.size

  if m == 0 || m == (M - m)
    ans += a_size / 2
  else
    counterA = Hash.new(0)
    counterB = Hash.new(0)

    listA.each do |a|
      counterA[a] += 1
    end

    listB.each do |b|
      counterB[b] += 1
    end

    pair_a_cnt = counterA.values.map { |c| c / 2 }.inject(:+) || 0
    pair_b_cnt = counterB.values.map { |c| c / 2 }.inject(:+) || 0

    match_cnt = [a_size, b_size].min
    ans += match_cnt

    ans += [(a_size - match_cnt) / 2, pair_a_cnt].min
    ans += [(b_size - match_cnt) / 2, pair_b_cnt].min
  end
end

puts ans


Measured memory_bytes: 27396
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	H, W := ReadInt(), ReadInt()
	N := ReadInt()
	a := ReadInts(N)
	rotateAxis := false
	if W > H {
		W, H = H, W
		rotateAxis = true
	}
	colorOrder := make([]int, N)
	for i := 0; i < N; i++ {
		colorOrder[i] = i
	}
	sort.Slice(colorOrder, func(i, j int) bool {
		return a[colorOrder[i]] > a[colorOrder[j]]
	})
	grid := make([][]int, H)
	for i := 0; i < H; i++ {
		grid[i] = make([]int, W)
		for j := 0; j < W; j++ {
			grid[i][j] = -1
		}
	}
	var dfs func(x, y, order, filled int) bool
	dfs = func(x, y, order, filled int) bool {
		if grid[y][x] >= 0 {
			return false
		}
		color := colorOrder[order]
		grid[y][x] = color
		filled++
		nextOrder := order
		if filled == a[color] {
			nextOrder = order + 1
			filled = 0
			if nextOrder == N {
				return true
			}
		}
		var dx = []int{1, 0, -1, 0}
		var dy = []int{0, 1, 0, -1}
		for i := 0; i < 4; i++ {
			nx, ny := x+dx[i], y+dy[i]
			if 0 <= nx && nx < W && 0 <= ny && ny < H {
				if dfs(nx, ny, nextOrder, filled) {
					return true
				}
			}
		}
		grid[y][x] = -1
		return false
	}
	dfs(0, 0, 0, 0)

	if rotateAxis {
		for x := 0; x < W; x++ {
			for y := 0; y < H; y++ {
				fmt.Printf("%d ", grid[y][x]+1)
			}
			fmt.Println()
		}
	} else {
		for y := 0; y < H; y++ {
			for x := 0; x < W; x++ {
				fmt.Printf("%d ", grid[y][x]+1)
			}
			fmt.Println()
		}
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	lnt A; string B; cin >> A >> B;
	lnt b = (B[0]-'0')*100 + (B[2]-'0')*10 + (B[3]-'0');
	cout << A*b / 100 << ln;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int n;
  cin>>n;
  int a[n+2];
  a[0]=a[n+1]=0;
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin>>a[i+1];
    sum+=abs(a[i+1]-a[i]);
  }
  sum+=abs(a[n+1]-a[n]);
  for(int i = 1; i < n+1; i++){
    int sum2 = 0;
    if(abs(a[i+1]-a[i])+abs(a[i]-a[i-1])!=abs(a[i+1]-a[i-1])){
       sum2=sum-(abs(a[i+1]-a[i])+abs(a[i]-a[i-1]))+abs(a[i+1]-a[i-1]);
    }
    else sum2 = sum;
    cout<<sum2<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 1664
#include<cstdio>

int N,X;

int main(){
    scanf("%d%d",&N,&X);
    if(X==1||X==2*N-1)
        return !puts("No");
    puts("Yes");
    if(N==2)
        return !puts("1\n2\n3");
    if(X==2){
        for(int i=1;i<=N-2;i++)
            printf("%d\n",4+i);
        printf("3\n2\n1\n4\n");
        for(int i=1;i<=N-3;i++)
            printf("%d\n",N+2+i);
        return 0;
    }
    int cnt=1;
    for(int i=1;i<=N-2;i++){
        if(cnt==X-2)
            cnt=X+2;
        printf("%d\n",cnt++);
    }
    printf("%d\n%d\n%d\n%d\n",X-1,X,X+1,X-2);
    for(int i=1;i<=N-3;i++){
        if(cnt==X-2)
            cnt=X+2;
        printf("%d\n",cnt++);
    }
}


Measured memory_bytes: 1408
N,M=map(int,input().split())
table=[set() for i in range(N)]
for i in range(M):
    A=[int(i) for i in input().split()]
    B=A[1:]
    for b in B:
        table[b-1].add(i)
P=[int(i) for i in input().split()]
#print(table)
ans=0
for k in range(1<<N):
    U=[0]*M
    for j in range(N):
        if k&(1<<j):
            for x in table[j]:
                U[x]+=1
                U[x]%=2
    if U==P:
        ans+=1
        #print(U,k)
print(ans)


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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define dbg(x) cout<<#x<<"="<<x<<endl
#define all(x) (x).begin(),(x).end()

#define INF INT_MAX/3

int gr(int v);

int N,M;
vector<int> g[1010];
int ind[1010];
int grd[1010];
vector<int> gs;

void dfs(int v,int sum){
  int res=sum;
  for(int nv : g[v]){
    res^=gr(nv);
  }
  gs.push_back(res);
  for(int nv : g[v]){
    res^=gr(nv);
    dfs(nv,res);
    res^=gr(nv);
  }
}

int gr(int v){
  if(grd[v]!=-1)return grd[v];
  for(int nv : g[v]){
    gr(nv);
  }

  gs.clear();
  dfs(v,0);
  sort(all(gs));
  gs.erase(unique(all(gs)),gs.end());
  int res=0;
  rep(j,gs.size()){
    if(res==gs[j])res++;
    else break;
  }
  return grd[v]=res;
}

int main(){
  cin>>N>>M;
  rep(i,M){
    int p;
    cin>>p;
    p--;
    g[p].push_back(i);
    ind[i]++;
  }
  //rep(i,N)dbg(ind[i]);

  memset(grd,-1,sizeof(grd));
  int res=0;
  rep(i,N){
    if(ind[i]==0){
      res^=gr(i);
      //dbg(gr(i));
    }
  }
  if(res==0)cout<<"Bob"<<endl;
  else cout<<"Alice"<<endl;
}



Measured memory_bytes: 3304
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x%N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x)%N;
		y = y >> 1;
		x = (x * x)%N;
	}
	return res;
}
double dist(ll x1,ll y1, ll x2,ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	vector<ll> arr(n, 0);
	f(i, 0, n)
	{
		ll temp;
		cin >> temp;
		arr[temp - 1] = i + 1;
	}
	f(i, 0, n-1)
		cout << arr[i] << " ";
	cout << arr[n - 1];
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

bool f(int x){
    //cout << x << endl;
    for(int i = 2;i < x;i++){
        if(x % i == 0){
            return false;
        }
    }
    return true;
}

int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int x;
    cin >> x;
    while(1){
        if(f(x) == false){
            x += 1;
        }else{
            break;
        }
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		long V = sc.nextLong();
		int B = sc.nextInt();
		long W = sc.nextLong();
		long T = sc.nextLong();

		long diff = Math.abs(A-B);
		long speed = V-W;

		if(speed*T>=diff){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
    }
}


Measured memory_bytes: 35636
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <string>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(std::min<int>(l_, r_)), r(r_) {}
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): r(std::max<int>(l_, r_) - 1), l(l_ - 1) {}
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

constexpr int inf = (1 << 30) - 1;

int solve(std::vector<char> A, std::vector<char> B) {
  int H = A.size();
  std::vector<std::vector<int>> cost(H + 1, std::vector<int>(H + 1));
  for (int dif: range(0, H)) {
    {
      int now = 0;
      for (int i: revrange(dif, H)) {
        if (A[H - i - 1] == B[H - i - 1 + dif]) {
          ++now;
        }
        cost[i][i - dif] += now;
      }
    }
    if (dif != 0) {
      int now = 0;
      for (int i: revrange(dif, H)) {
        if (A[H - i - 1 + dif] == B[H - i - 1]) {
          ++now;
        }
        cost[i - dif][i] += now;
      }
    }
  }
  std::vector<std::vector<int>> dp(H + 1, std::vector<int>(H + 1, inf));
  dp[0][0] = 0;
  for (int i: range(0, H + 1)) {
    for (int j: range(0, H + 1)) {
      if (i < H) {
        chmin(dp[i + 1][j], dp[i][j] + cost[i][j]);
      }
      if (j < H) {
        chmin(dp[i][j + 1], dp[i][j] + cost[i][j]);
      }
    }
  }
  return dp[H][H];
}

int main() {
  int H, W;
  std::cin >> H >> W;
  std::vector<std::vector<char>> grid(W, std::vector<char>(H));
  for (int i: range(0, H)) {
    for (int j: range(0, W)) {
      std::cin >> grid[j][i];
    }
  }
  int ans = 0;
  for (int j: range(0, W - 1)) {
    ans += solve(grid[j], grid[j + 1]);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1128
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;


const int inf = 1e9 + 7; 
const int N = 3e6;
int d[22][N], G[30][30];
int a[22][N], c[22], vis[22][N];
 
int main(){
	fastio;
	int n;cin >> n;
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			cin>>G[i][j];
		}
	}
	for(int i=0;i<n;++i){
		if(G[0][i]){
			d[0][1<<i]=1;
			a[0][c[0]++]=1<<i;
		}
	}
	for(int i=0;i<n-1;++i){
		for(int j=0;j<c[i];++j){
			for(int k=0;k<n;++k){
				if(((a[i][j]&(1<<k))==0)&&G[i+1][k]==1){
					if(!vis[i+1][a[i][j]|(1<<k)]){
						a[i+1][c[i+1]++]=a[i][j]|(1<<k);
						vis[i+1][a[i][j]|(1<<k)]=1;
					}
					d[i+1][a[i][j]|(1<<k)]=(d[i+1][a[i][j]|(1<<k)]+d[i][a[i][j]])%inf;
				}
			}
		}
	}
	cout<<d[n-1][(1<<n)-1]<<endl;
	return 0;
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int a, b;
	cin >> a >> b;
	cout << (a - 1) * (b - 1) << "\n";
}

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


Measured memory_bytes: 256
n, k = gets.chomp.split(" ").map(&:to_i)
list = [*0...n+1]
l = list[0..k-1].sum
r = list[-1*k..-1].sum
MOD = 10**9 + 7
ans = (r-l+1) % MOD

(k+1).upto(n+1) do |i|
  l += list[i-1]
  r += list[-1*i]
  ans = (ans + (r-l+1) % MOD) % MOD
end

p ans

Measured memory_bytes: 17588
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

const int N = 4096;
int bit[2][N][N];

int accum(int kind, int x, int y) {
  int tot = 0;
  while (x > 0) {
    int yy = y;
    while (yy > 0) {
      tot += bit[kind][x][yy];
      yy &= yy - 1;
    }
    x &= x - 1;
  }
  return tot;
}

void update(int kind, int x, int y, int v) {
  while (x < N) {
    int yy = y;
    while (yy < N) {
      bit[kind][x][yy] += v;
      yy += yy & (-yy);
    }
    x += x & (-x);
  }
}


int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, q;
  ll t_bake;
  cin >> h >> w >> t_bake >> q;
  queue<pair<ll, PI> > que; 
  REP(benedicta, 0, q) {
    ll t;
    int c, h, w;
    cin >> t >> c >> h >> w;
    while (not que.empty() && que.front().first <= t) {
      PI top = que.front().second;
      que.pop();
      int x = top.first;
      int y = top.second;
      update(1, x, y, 1);
      update(0, x, y, -1);
    }
    if (c == 0) {
      // set
      que.push(make_pair(t + t_bake, PI(h, w)));
      update(0, h, w, 1);
    } else if (c == 1) {
      // pick
      int cnt = accum(1, h, w) - accum(1, h, w - 1)
	- accum(1, h - 1, w) + accum(1, h - 1, w - 1);
      assert (0 <= cnt && cnt <= 1);
      if (cnt == 1) {
	update(1, h, w, -1);
      }
    } else if (c == 2) {
      // count
      int h2, w2;
      cin >> h2 >> w2;
      int b[2];
      REP(k, 0, 2) {
	b[k] = accum(k, h2, w2) - accum(k, h2, w - 1)
	  - accum(k, h - 1, w2) + accum(k, h - 1, w - 1);
      }
      cout << b[1] << " " << b[0] << "\n";
    }
  }
}

Measured memory_bytes: 51224
#include<iostream>
using namespace std;
int main()
{
	int n,b,f,r,v;
	int x[5][31]={0};
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>b>>f>>r>>v;
		x[b][r+(f-1)*10]+=v;
	}
	for(int i=1;i<=4;i++){
		for(int j=1;j<=30;j++){
			cout<<" "<<x[i][j];
			if(j==10||j==20||j==30)cout<<endl;
		}
		if(i!=4)cout<<"####################"<<endl;
	}

	return 0;
}


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

int main() {
  vector<int> x(3);
  vector<int> y(3);
  vector<int> z(3);
  rep (i, 3) cin >> x.at(i);
  rep (i, 3) cin >> y.at(i);
  rep (i, 3) cin >> z.at(i);
  while (x[0]*x[1]*x[2] > 0){
    x[0]--; x[1]--; x[2]--;
  }
  while (y[0]*y[1]*y[2] > 0){
    y[0]--; y[1]--; y[2]--;
  }
  while (z[0]*z[1]*z[2] > 0){
    z[0]--; z[1]--; z[2]--;
  }
  while (x[0]*y[0]*z[0] > 0) {
    x[0]--; y[0]--; z[0]--;
  }
  while (x[1]*y[1]*z[1] > 0) {
    x[1]--; y[1]--; z[1]--;
  }
  while (x[2]*y[2]*z[2] > 0) {
    x[2]--; y[2]--; z[2]--;
  }

  int sum=0;
  rep (i, 3)
    sum +=(x.at(i) + y.at(i) + z.at(i));
  if (!sum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 11200000001234567LL

int main(){
  using P = pair<long,int>;
  int n,m;
  while(cin>>n>>m, n|m){
    vector<vector<P>> vec(n);
    rep(i,m){
      int a,b,c;
      cin>>a>>b>>c;
      a--;b--;
      vec[a].pb(mp(c,b));
      vec[b].pb(mp(c,a));
    }

    vector<vector<long>> d(n, vector<long>(3,INF));
    priority_queue<P, vector<P>, greater<P>> pq;
    d[0][0] = 0;
    pq.push(mp(0,0));
    while(!pq.empty()){
      auto p = pq.top(); pq.pop();
      int v = p.se/3;
      int s = p.se%3;
      if(d[v][s] < p.fi) continue;
      for(auto to : vec[v]){
        int nv = to.se;
        long nd = p.fi;
        if(s==0){
          if(d[nv][1] > nd){
            pq.push(mp(nd, nv*3+1));
            d[nv][1] = nd;
          }
        }
        if(s==1){
          if(d[nv][2] > nd){
            pq.push(mp(nd, nv*3+2));
            d[nv][2] = nd;
          }
        }
        else {
          nd += to.fi;
          if(d[nv][s] > nd){
            pq.push(mp(nd, nv*3+s));
            d[nv][s] = nd;
          }
        }
      }
    } // while pq

    cout << min(d[n-1][0], d[n-1][2]) << endl;

  }

  return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  string S,T;
  cin>>S>>T;
  bool a=true;
  for(ll i=0;i<S.size();i++) {
if(S[i]!=T[i]) {
a=false;
}
  }
  if(a) {
cout<<"Yes"<<endl;
  }
  else {
cout<<"No"<<endl;
  }
}
 

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 100003, M = N << 1;

int n, k;
int a[N], b[N];
int tot, head[N], ver[M], nxt[M];
char s[N];

inline void add(int u, int v)
{
    ver[++tot] = v, nxt[tot] = head[u], head[u] = tot;
}

int main()
{
    n = gi(), k = gi();
    for (int i = 1; i <= n; i+=1) a[i] = gi();
    for (int i = 1; i <= k; i+=1)
    {
        int u = gi(), v = gi();
        add(u, v), add(v, u);
    }
    int cnt = 0;
    for (int i = 1; i <= n; i+=1)
    {
        bool fl = true;
        for (int j = head[i]; j; j = nxt[j])
        {
            int v = ver[j];
            if (a[v] >= a[i]) {fl = false; break;}
        }
        if (fl) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 5972