akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10, MOD = 1e9 + 7;



int main()
{
    fastInp;

    ll n;
    cin >> n;
    vector<ll> vec(n);
    for (int i = 0; i < n; i++) cin >> vec[i];

    vector<ll> cnt(n);

    ll ans = 1, t = 3;

    for (int i = 0; i < cnt.size(); i++) {
        cnt[vec[i]]++;
        if (vec[i] == 0) {
            ans *= t;
            t--;
        } else {
            ans *= cnt[vec[i] - 1];
            cnt[vec[i] - 1]--;
        }
        ans %= MOD;
    }

    cout << (ans) % MOD;

    return 0;
}

Measured memory_bytes: 4800
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	int a[4],b[4];
	while(~scanf("%d%d%d%d",a,a+1,a+2,a+3)){
		scanf("%d%d%d%d",b,b+1,b+2,b+3);
		int hit=0,bro=0;
		rep(i,4)if( a[i]==b[i] ){
			hit++;
		}
		rep(i,4){
			rep(j,4){
				if( i!=j ){
					if( b[i]==a[j] )bro++;
				}
			}
		}
		printf("%d %d\n",hit,bro);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main() 
{
    FIO
    int x; cin>>x;
    int happ=0;
    while(x) {
    	if (x >= 500)
    	{
    		happ += 1000;
    		x -= 500;
    	}
    	else if (x >= 5)
    	{
    		happ += 5;
    		x -= 5;
    	}
    	else {
    		x = 0;
    	}
    }

    cout<<happ;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i < n; i++)
#define INF 1001001001
#define LINF (1LL << 62)
using namespace std;
using ll = long long;
using P = pair<int,int>;

void solv() {
    int N, L;
    cin >> N >> L;
    vector<string> str;
    rep(i, N) {
        string buf;
        cin >> buf;
        //cout << buf << endl;
        str.push_back(buf);
    }
    sort(str.begin(), str.end());
    rep(i, N) cout << str[i];
    cout << endl;
}

int main() {
    solv();
    return 0;
}

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

int main() {
    while (true) {
        int sum; cin >> sum;
        if (sum == 0) break;

        int sum_sub = 0;
        for (int i = 0; i < 9; i++) {
            int tmp; cin >> tmp;
            sum_sub += tmp;
        }
        cout << sum - sum_sub << endl;
    }
}


Measured memory_bytes: 3084
#include<stdio.h>
int main(void){
	int S[13]={0};
	int H[13]={0};
	int C[13]={0};
	int D[13]={0};
	int n,i,k;
	char c;
	scanf("%d",&n);
	
	for( i = 0;i <= n;i++){
		scanf("%c %d\n",&c,&k);
		if(c == 'S')
		S[k-1] = 1;
		if(c == 'H')
		H[k-1] = 1;
		if(c == 'C')
		C[k-1] = 1;
		if(c == 'D')
		D[k-1] = 1;
		
	}
	for(i = 0;i < 13;i++){
		if(S[i] == 0)
		printf("S %d\n",i + 1);
	}
		for(i = 0;i < 13;i++){
		if(H[i] == 0)
		printf("H %d\n",i+ 1);
	}
		for(i = 0;i < 13;i++){
		if(C[i] == 0)
		printf("C %d\n",i + 1);
	}
		for(i = 0;i < 13;i++){
		if(D[i] == 0)
		printf("D %d\n",i + 1);
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int maxS = 2600;

ll d[51][maxS];
bool used[51][maxS];

struct Edge {
    int to, cost, time;
};

vector<Edge> g[51];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, s;
    cin >> n >> m >> s;
    for (int i = 0; i < m; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        g[a].push_back({b, c, d});
        g[b].push_back({a, c, d});
    }
    vector<int> co(n + 1), ti(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> co[i] >> ti[i];
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < maxS; j++) {
            d[i][j] = 1e18;
        }
    }
    d[1][min(s, maxS - 1)] = 0;
    set<pair<int, pair<int, int>>> setV;
    setV.insert({0, {1, min(s, maxS - 1)}});
    while (!setV.empty()) {
        auto p = setV.begin()->second;
        int x = p.first;
        int sum = p.second;
        setV.erase(setV.begin());
        used[x][sum] = true;
        for (auto e : g[x]) {
            if (sum >= e.cost && d[e.to][sum - e.cost] > d[x][sum] + e.time) {
                setV.erase({d[e.to][sum - e.cost], {e.to, sum - e.cost}});
                d[e.to][sum - e.cost] = d[x][sum] + e.time;
                setV.insert({d[e.to][sum - e.cost], {e.to, sum - e.cost}});
            }
        }
        if (d[x][min(maxS - 1, sum + co[x])] > d[x][sum] + ti[x]) {
            setV.erase({d[x][min(maxS - 1, sum + co[x])], {x, min(maxS - 1, sum + co[x])}});
            d[x][min(maxS - 1, sum + co[x])]  = d[x][sum] + ti[x];
            setV.insert({d[x][min(maxS - 1, sum + co[x])], {x, min(maxS - 1, sum + co[x])}});
        }
    }
    for (int i = 2; i <= n; i++) {
        ll ans = 1e18;
        for (int j = 0; j < maxS; j++) {
            ans = min(ans, d[i][j]);
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 8864
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let mut v: Vec<i64> = read_vec();
    let n = v[0] as usize;
    let k = v[1];
    let a = (0..n).map(|_| read::<i64>() - k).collect::<Vec<_>>();
    let mut sums = vec![-k; n + 1];
    for i in 1..n + 1 {
        sums[i] = sums[i - 1] + a[i - 1];
    }

    let indexes = argsort(&sums);
    let mut c = vec![0; n + 1];
    for i in 0..n + 1 {
        c[indexes[i]] = n + 1 - i;
    }

    let mut bt = BinaryIndexTree::new(indexes.len());
    let mut ans = 0;
    for i in 0..indexes.len() {
        ans += i - bt.sum(c[i]) as usize;
        bt.add(c[i] as usize, 1);
    }
    println!("{:?}", ans);
}

fn argsort<T: std::cmp::Ord + std::marker::Copy>(v: &Vec<T>) -> Vec<usize> {
    let mut sort_v = Vec::new();
    for i in 0..v.len() {
        sort_v.push((v[i], i));
    }
    sort_v.sort();
    sort_v.iter().map(|x| x.1).collect::<Vec<usize>>()
}

struct BinaryIndexTree {
    bit: Vec<i64>,
    n: usize,
}

impl BinaryIndexTree {
    fn new(n: usize) -> BinaryIndexTree {
        BinaryIndexTree {
            bit: vec![0; n + 1],
            n: n,
        }
    }

    fn sum(&self, i: usize) -> i64 {
        let mut i = i;
        let mut s = 0i64;
        while i > 0 {
            s += self.bit[i];
            i -= (i as i64 & -(i as i64)) as usize;
        }
        s
    }

    fn add(&mut self, i: usize, x: i64) {
        let mut i = i;
        while i <= self.n {
            self.bit[i as usize] += x;
            i += (i as i64 & -(i as i64)) as usize;
        }
    }
}


Measured memory_bytes: 15472
#include<iostream>

using namespace std;

int main()
{
    int K,A,B;
    cin >> K >> A >> B;

    if(A%K == 0 or B%K == 0){
        cout << "OK" << endl;
    }else if(A/K == B/K){
        cout << "NG" << endl;
    }else{
        cout << "OK" << endl; 
    }

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 1 << 18;
constexpr int maxm = 1 << 10;
int V[maxn], W[maxn], v[maxm], w[maxm], Log[maxn], sv[maxm], sw[maxm];
map<int, int> mp[maxm];
int test = 0;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N = (1 << 18) - 1;
    for(int i = 2; i < maxn; i += 1) Log[i] = Log[i / 2] + 1;
    if(not test) cin >> N;
    mp[0][0] = 0;
    for(int i = 1; i <= N; i += 1){
        if(not test) cin >> V[i] >> W[i];
        else{
            V[i] = rand() % maxn;
            W[i] = rand() % maxn;
        }
        if(i < maxm){
            for(auto p : mp[i / 2]){
                mp[i][p.first] = max(mp[i][p.first], p.second);
                mp[i][p.first + W[i]] = max(mp[i][p.first + W[i]], p.second + V[i]);
            }
            int m = 0;
            for(auto &p : mp[i]) m = p.second = max(m, p.second);
        }
    }
    int Q = 100000;
    if(not test) cin >> Q;
    for(int _ = 1, u = 0, F = 0; _ <= Q; _ += 1){
        if(not test) cin >> u >> F;
        else{
            u = rand() % N + 1;
            F = rand() % (maxn * 18);
        }
        int n = 0;
        for(; u >= maxm; u >>= 1, n += 1){
            v[n] = V[u];
            w[n] = W[u];
        }
        for(int i = 1; i < (1 << n); i += 1){
            sv[i] = sv[i - (1 << Log[i])] + v[Log[i]];
            sw[i] = sw[i - (1 << Log[i])] + w[Log[i]];
        }
        int ans = 0;
        for(int i = 0; i < (1 << n); i += 1){
            auto it = mp[u].upper_bound(F - sw[i]);
            if(it == mp[u].begin()) continue;
            ans = max(ans, prev(it)->second + sv[i]);
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 39428
#include <stdio.h>
int main() {
    int n, i, temp, ans;
    int data[5000];
    while (1) {
        scanf(" %d", &n);
        if (n == 0)
            break;
        temp = -100000;
        for (i = 0; i < n; i++) {
            scanf(" %d", &data[i]);
            if (data[i] > temp)
                temp = data[i];
        }
        if (temp <= 0) {
            printf("%d\n", temp);
            continue;
        }
        temp = ans = 0;
        for (i = 0; i < n; i++) {
            temp = (data[i] + temp > 0) ? data[i] + temp : 0;
            ans = (temp > ans) ? temp : ans;
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 616
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int n = 0;
		for(int i = a;i <= b;i++){
			if(c%i==0) n++;
		}
		System.out.println(n);
	}
}



Measured memory_bytes: 26300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int h, w;
    cin >> h >> w;
    char a[h][w];
    for (ll i = 0; i < h; i++) {
        for (ll j = 0; j < w; j++)
            cin >> a[i][j];
    }
    for (ll j = 0; j < w+2;j++){
        cout << '#';
    }
    cout << endl;
    for (ll i = 0; i < h;i++){
        for (ll j = 0; j < w + 2;j++){
            if (j == 0) cout << '#';
            else if(j == w+1)
                cout << "#" << endl;
            else
                cout << a[i][j-1];
        }
    }
        for (ll j = 0; j < w+2;j++){
        cout << '#';
    }
    cout << endl;
}


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

int main(void){
       int x,n;
       int p[110];
       int temp1,temp2,s,t;
       int i;
       int j,k;
       scanf("%d %d",&x,&n);
       for(i=0;i<n;i++){
              scanf("%d",&p[i]);
       }


       for(i=0;i<52;i++){
              s=1;
              t=1;
              temp1 = x+i;
              for(j=0;j<n;j++){
                     if(p[j] == temp1){
                            s=0;
                            break;
                     }
              }

              temp2 = x-i;
              for(k=0;k<n;k++){
                     if(p[k] == temp2){
                            t=0;
                            break;
                     }
              }

              if(t==1 || s ==1){
                     if(t==1 && s==0){
                            printf("%d",temp2);
                     }
                     else if(t==0 && s==1){
                            printf("%d",temp1);
                     }
                     else{
                            printf("%d",temp2);
                     }

                     break;
              }
       }

       return 0;

}

Measured memory_bytes: 1736
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

int main(void) {

    int n;
    cin >> n;
    int *p = new int[n];

    ll ans = 0;
    int maxv = -1;

    for(int i = 0; i < n; ++i){
        cin >> p[i];
        ans += p[i];
        if(maxv < p[i]) {
            maxv = p[i];
        }
    }

    cout << ans - maxv/2 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        long num = sc.nextLong();
        if(num == 1){
            System.out.println(0);
            return;
        }

        Map<Long, Long> map = devide(num);

        int count = 0;
        // 素数ごとにカウントする
        for(Map.Entry<Long, Long> entry : map.entrySet()){
            // 指数を順に減らしていく
            long sisu = entry.getValue();
            for(long i=1; i <= sisu; i++){
                sisu -= i;
                count++;
            }
            // 余った分は最後に足すので関係なし
        }
        System.out.println(count);
    }

    static Map<Long, Long> devide(long num){
        long tmpnum = num;
        Map<Long, Long> map = new HashMap<>();
        for(long i=2; i*i < num; i++){
            // <2, count>, <3, count>...
            long count = 0;
            while(tmpnum % i == 0){
                tmpnum = tmpnum / i;
                count++;
            }
            if(count != 0){
                map.put(i, count);
            }
        }
        if(tmpnum != 1L){
            map.put(tmpnum, 1L);
        }
        return map;
    }
}

Measured memory_bytes: 37036
import java.util.Scanner;

public class Main {

    public static void main(String args[] ) throws Exception {


        Scanner s = new Scanner(System.in);


        int a = s.nextInt();    // Reading input from STDIN
        int b = s.nextInt();

        int sum = a+b;
        int k = sum/2;

        if(sum%2==0){
            System.out.println(k);
        }else{
            System.out.println("IMPOSSIBLE");
        }

    }
}



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

int main() {
    int A,B,C,D,s,f;
    cin >> A >> B >> C >> D;
    s = max(A,C);
    f = min(B,D);
    cout << ((f-s > 0) ? f-s : 0) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    char c;
    in>>c;
    cout<<++c<<endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int h, w, n, sr, sc;string s, t;
signed main(){
  cin>>h>>w>>n>>sr>>sc>>s>>t;
  int a[4];
  a[0] = a[2] = 1;a[1] = w;a[3] = h;
  bool b = false;
  reverse(s.begin(), s.end());reverse(t.begin(),t.end());
  rep(i,n){
    if(t[i] == 'L')a[1]++;
    if(t[i] == 'R')a[0]--;
    if(t[i] == 'U')a[3]++;
    if(t[i] == 'D')a[2]--;
    chmax(a[0],1LL);chmin(a[1],w);chmax(a[2],1LL);chmin(a[3],h);
    if(s[i] == 'L')a[0]++;
    if(s[i] == 'R')a[1]--;
    if(s[i] == 'U')a[2]++;
    if(s[i] == 'D')a[3]--;
    if(a[0] > a[1] || a[2] > a[3])b = true;
  }
  b = b | !(a[0] <= sc && sc <= a[1] && a[2] <= sr && sr <= a[3]);
  cout << (b ? "NO" : "YES") << endl;
}


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

using namespace std;

int main()
{
    int x,y,z,i,dap = 0;
    
    scanf("%d %d %d",&x,&y,&z);
    for(i=x;i<=y;i++) if(i%z==0) dap++;
    printf("%d\n",dap);
    return 0;
}


Measured memory_bytes: 3812
package main

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

var (
	in= bufio.NewReader(os.Stdin)
	out= bufio.NewWriter(os.Stdout)
)

func main() {
	_ = readInt64Slice()
	a := readFloat64Slice()
	var denominator float64
	for _, v := range a {
		denominator += 1/v
	}
	fmt.Println(1/denominator)
}

func readInt64Slice() []int64 {
	line := readStringSlice()
	slice := make([]int64, 0, len(line))
	for _, tmp := range line {
		val, err := strconv.ParseInt(tmp, 10, 64)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		slice = append(slice, val)
	}
	return slice
}
func readFloat64Slice() []float64 {
	line := readStringSlice()
	slice := make([]float64, 0, len(line))
	for _, tmp := range line {
		val, err := strconv.ParseFloat(tmp, 64)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		slice = append(slice, val)

	}
	return slice
}
func readString() string {
	s, _, _ := in.ReadLine()
	return string(s)
}
func readStringSlice() []string {
	line := readString()
	s := strings.Split(line, " ")
	return s
}
func dump(value ...interface{}) {
	for _, v := range value {
		fmt.Printf("%#v\n", v)
	}
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

def solve():
    K, A, B = map(int, input().split())
    res = 1
    if B <= A:
        res += K
    elif K <= A:
        res += K
    elif B-A<=2:
        res += K
    else:
        K -= (A-1)
        res += A-1
        res += (K//2)*(B-A)
        res += K%2

    return str(res)
if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 3060
#include <cstdio>
// D - Three Colors

#define MOD 998244353

using namespace std;

int a[305],dp[45005],dp2[45005];

int main() {
    int N,i,j,sum,imp,tot;
    bool even;

    scanf("%d",&N);

    sum = 0;
    for (i = 0;i < N;i++) {
        scanf("%d",&a[i]);
        sum += a[i];
    }

    if (sum % 2 == 0)
        even = true;
    else
        even = false;

    sum >>= 1;
    dp[0] = 1;
    dp2[0] = 1;
    for (i = 0;i < N;i++) {
        for (j = sum - a[i];j >= 0;j--) {
            dp[j + a[i]] += ((dp[j] << 1) % MOD);
            dp[j + a[i]] %= MOD;
            dp2[j + a[i]] += dp2[j];
            dp2[j + a[i]] %= MOD;
        }
    }

    imp = 0;
    for (i = 0;i <= sum;i++)
        imp = (imp + dp[i]) % MOD;

    if (even)
        imp = (imp - dp2[sum] + MOD) % MOD;
    imp = (int) ((1LL * imp * 3) % MOD);

    tot = 1;
    for (i = 0;i < N;i++)
        tot = (int) ((1LL * tot * 3) % MOD);

    printf("%d\n",(tot - imp + MOD) % MOD);

    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b, c, d; cin >> a >> b >> c >> d;
  cout << max(0, min(b, d) - max(a, c)) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
using namespace std;
int main(){
  int n,m;
  vector< string > bv(102);
  vector< string > rv(102);
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> bv[i];
  }
  cin >> m;
  for(int i=0; i<m; i++){
    cin >> rv[i];
  }
  string s;
  int max=0;
  bool found=false;
  for( int i=0; i<n; i++){
    int tmp=0;
    for( int j=0; j<n; j++){
      if( bv[i]==bv[j] ) tmp++;
    }
    for( int j=0; j<m; j++){
      if( bv[i]==rv[j] ) tmp--;
    }
    if( tmp > max ){
      max = tmp;
      s = bv[i];
      found=true;
    }
  }
  if(found) cout << max << endl;
  else cout << 0 <<endl;
  return 0;
  
}


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

using namespace std;

int main()
{
	string S;
	long long K;

	cin >> S >> K;

	int one_count = 0;
	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == '1')
		{
			one_count++;
		}
		else
		{
			break;
		}
	}

	if (K <= one_count)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << S[one_count];
	}

	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
s="#"+input()+"#"
ans=0
for i in range(1,n+1):
    if s[i]=="R" and s[i+1]=="R":
        ans+=1
    if s[i]=="L" and s[i-1]=="L":
        ans+=1
a=max(s.count("LR"),s.count("RL"))
if k>=a:
    ans=n-1
else:
    ans+=2*k
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){

    int n,x=0;
    cin>>n;
    int a[n+1];

    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
        if(a[i]>a[i+1]){
          x+=a[i]-a[i+1];
          a[i+1]+=(a[i]-a[i+1]);
        }
    }
    cout<<x<<endl;


}


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

int main(void){
    char c1[3],c2[3];
    cin>>c1>>c2;

    cout<<((c1[0]==c2[2]&&c1[2]==c2[0]&&c1[1]==c2[1])?"YES":"NO")<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
	int i,a;
	vector<int> v;
	for(i=0;i<3;i++){
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(), v.end());
	cout<<(v.back() - *v.begin());
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int W,a,b;
int abs(int a,int b){
	int tmp=a-b;
	if(tmp<0) tmp*=-1;
	return tmp;
}
int main(){
	cin>>W>>a>>b;
	cout<<max(0,abs(a,b)-W)<<endl;
}

Measured memory_bytes: 256
//#define NDEBUG

#include <bits/stdc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define B back()
#define FR front()
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)
#define iceil(a) ((int)ceil(a))
#define ifloor(a) ((int)floor(a))

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

int main(){
    StarBurstStream

    int n;
    cin >> n;

    ll sum = 0;
    ll t = 0;
    for(int i = 0; i < n; i++){
        int d;
        cin >> d;
        sum += t * d;
        t += d;
    }

    cout << sum << "\n";

    return 0;
}

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

namespace ARC069
{
    public class C
    {
        private void Run()
        {
            var input = Console.ReadLine().Trim().Split();

            var s = long.Parse(input[0]);
            var c = long.Parse(input[1]);
            long t = Math.Min(s, c / 2);
            Console.WriteLine(t + (c - 2 * t) / 4);
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new C().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


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

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

  int n;
  cin >> n;

  if (n >= 1000) cout << "ABD\n";
  else cout << "ABC\n";

  return (0);
}


Measured memory_bytes: 3640
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
    if (l[i] != i + 1):
        ind = l.index(i + 1)
        l[i], l[ind] = l[ind], l[i]
        break

ok = 1
for i in range(1, n):
    if (l[i] < l[i - 1]):
        ok = 0
if ok:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,X,K,Q;
ll A[200010],B,C;
set<ll> S;
ll ans;
int main(){

    cin>>N>>M;
    cout<<(N<=M?"unsafe":"safe")<<endl;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    string S[3];
    rep(i, 3){
        cin >> S[i];
    }

    rep(i, 3){
        cout << S[i][0];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3588
import sys
sys.setrecursionlimit(3000)
def dfs(r, c, n):
    board[r][c] = n
    drc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
    for dr, dc in drc:
        nr, nc = r + dr, c + dc
        if 0 <= nr < h and 0 <= nc < w and board[nr][nc] != n:
            if board[nr][nc] in 'WB':
                pile.append(board[nr][nc])
                continue
            dfs(nr, nc, n)

while True:
    w, h = map(int, input().split())
    if w == 0 and h == 0: break
    board = [list(input()) for _ in range(h)]
    place = 0
    piles = []
    black, white = [], []
    for r in range(h):
        for c in range(w):
            if board[r][c] == '.':
                pile = []
                place += 1
                dfs(r, c, place)
                piles.append(pile)
    for i, pile in enumerate(piles):
        if not pile: continue
        for p in pile:
            if p != 'B':
                break
        else:
            black.append(i+1)
        for p in pile:
            if p != 'W':
                break
        else:
            white.append(i+1)
    ans_b, ans_w = 0, 0
    for row in board:
        for c in row:
            if c in black:
                ans_b += 1
            elif c in white:
                ans_w += 1
    print(ans_b, ans_w)

Measured memory_bytes: 9396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  string a, b, c;
  cin >> a >> b >> c;
  
  cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n) return 0;
return fact[n]*ifact[k]*ifact[n-k];
}
}c(220000);
int n,a,b;
vi edge[220000];
vl t(220000);
mint dp1[220000];
mint dp2[220000];
void dfs1(int x,int p=-1){
    dp1[x]=1;
    for(auto to:edge[x]){
        if(to==p) continue;
        dfs1(to,x);
        dp1[x]*=c(t[x]+t[to],t[to]);
        dp1[x]*=dp1[to];
        t[x]+=t[to];
    }
    t[x]++;
}
void dfs2(int x,int p,mint ret){
    dp2[x]=dp1[x]*ret*c(n-1,t[x]-1);
    for(auto to:edge[x]){
        if(to==p) continue;
        dfs2(to,x,dp2[x]/(c(n-1,t[to])*dp1[to]));
    }
}
int main(){
    cin >> n;
    rep(i,220000) t[i]=0;
    rep(i,n-1){
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    dfs1(1);
    dfs2(1,-1,1);
    rrep(i,n){
        cout <<dp2[i].x << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
    int n,s;
    while (1) {
        cin >> n;
        if(n==0) break;
        int p = n;
        vector<int> score;
        cin >> s;
        n--;
        score.push_back(s);
        int mins=s,maxs=s,result=0;
        while(n--){
            cin >> s;
            maxs = max(maxs,s);
            mins = min(mins,s);
            score.push_back(s);
        }
        vector<int>::iterator it;
        it = score.begin();
        bool maxf=false,minf=false;
        while(it != score.end()){
            if (((*it)==mins) && (minf == false)) {
                minf = true;
            }
            else if(((*it)==maxs) && (maxf == false)){
                maxf = true;
            }
            else{
                result += (*it);
            }
            it++;
        }
        cout << result/(p-2) << endl;
    }
}

Measured memory_bytes: 1216
import sys
sys.setrecursionlimit(1000000)

def dfs(l,d,k):
  for i in l[k]:
    if d[i[0]]==-1:
      d[i[0]]=d[k]+i[1]
      dfs(l,d,i[0])

n=int(input())
l=[[] for i in range(n)]
for i in range(n-1):
  a,b,c=map(int,input().split())
  l[a-1].append([b-1,c])
  l[b-1].append([a-1,c])
q,k=map(int,input().split())
d=[-1 for i in range(n)]
d[k-1]=0
dfs(l,d,k-1)
L=[list(map(int,input().split())) for i in range(q)]
for i in range(q):
  print(d[L[i][0]-1]+d[L[i][1]-1])

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

int main()
{
	int r, g, b;
	while (cin >> r >> g >> b) {
		int i = r * 100 + g * 10 + b;
		if (i % 4 == 0) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
    return 0;
}



Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
use whiteread::parse_line;
use std::collections::HashMap;

struct Obs {
    h: usize,
    is_toll: bool,
}

fn main() {
    // N 展望台の数 M ルートの数
    let (n, m): (usize, usize) = parse_line().unwrap();
    // H[N] 展望台の高さ
    let h_list: Vec<usize> = parse_line().unwrap();
    let mut obs_list: Vec<Obs> = vec![];

    // 構造体の初期化
    for idx in 0..n {
        obs_list.push(Obs{ 
            h: h_list[idx],
            is_toll: true,
        });
    }

    // 高さの算出
    for _ in 0..m {
        let (a, b): (usize, usize) = parse_line().unwrap();
        // 高さの解決
        fn calc (target: &Obs, comparison: &Obs) -> bool {
            if target.is_toll {
                return target.h > comparison.h
            }
            false
        };
        obs_list[a - 1].is_toll = calc(&obs_list[a - 1], &obs_list[b - 1]);
        obs_list[b - 1].is_toll = calc(&obs_list[b - 1], &obs_list[a - 1]);
    }

    let mut count = 0;
    for obs in obs_list {
        if obs.is_toll {
            count = count + 1;
        }
    }
    print!("{}", count);
}

Measured memory_bytes: 4936
import copy


def compare_num(ans_tmp, candidate):
    sum_tmp = sum(ans_tmp)
    sum_candidate = sum(candidate)
    if sum_tmp == sum_candidate:
        for t, c in zip(ans_tmp, candidate):
            if t > c:
                return ans_tmp
            elif t < c:
                return candidate
        else:
            return ans_tmp

    else:
        return ans_tmp if sum_tmp > sum_candidate else candidate


N, M = map(int, input().split())
A_array = list(map(int, input().split()))
# print(A_array)
match_num_array = [2, 5, 5, 4, 5, 6, 3, 7, 6]
can_use_num_tmp = [-1, -1, -1, -1, -1, -1]
for A in A_array:
    can_use_num_tmp[match_num_array[A - 1] - 2] = max(
        A, can_use_num_tmp[match_num_array[A - 1] - 2])
can_use_num_tmp.sort()

can_use_num = []
can_use_num_match = []

for tmp in can_use_num_tmp[::-1]:
    if tmp == -1:
        break
    can_use_num.append(tmp)
    can_use_num_match.append(match_num_array[tmp - 1])

# print(can_use_num, can_use_num_match)
ans = []

ans.append([0] * len(can_use_num))

for n in range(1, N + 1):
    ans_tmp = -1

    for i, match_num in enumerate(can_use_num_match):
        if n - match_num >= 0 and ans[n - match_num] != -1:
            candidate = copy.deepcopy(ans[n - match_num])
            candidate[i] += 1
            ans_tmp = candidate if ans_tmp == -1 else compare_num(
                ans_tmp, candidate)
    ans.append(ans_tmp)

ans_str = ""
for ans_num, ans_count in zip(can_use_num, ans[N]):
    ans_str += (str(ans_num) * ans_count)

print(ans_str)

Measured memory_bytes: 53208
#include <iostream>
#include <cstdio>

using namespace std;

int main(void)
{
	int n, table[9][9];
	bool ok[9][9];
	cin >> n;
	for (int cnt = 0; cnt < n; cnt++){
		for (int i = 0; i < 9; i++){
			for (int j = 0; j < 9; j++){
				cin >> table[i][j];
				ok[i][j] = true;
			}
		}
		
		// cout << "input ok" << endl;
		// れつ
		for (int i = 0; i < 9; i++){
			bool done[10] = {false};
			for (int j = 0; j < 9; j++){
				if (done[table[i][j]]){
					ok[i][j] = false;
					for (int k = 0; k < j; k++){
						if (table[i][j] == table[i][k]){
							ok[i][k] = false;
						}
					}
				}
				done[table[i][j]] = true;
			}
		}
		
		// ぎょう
		for (int i = 0; i < 9; i++){
			bool done[10] = {false};
			for (int j = 0; j < 9; j++){
				if (done[table[j][i]]){
					ok[j][i] = false;
					for (int k = 0; k < j; k++){
						if (table[j][i] == table[k][i]){
							ok[k][i] = false;
						}
					}
				}
				done[table[j][i]] = true;
			}
		}
		
		for (int y = 0; y < 9; y += 3){
			for (int x = 0; x < 9; x += 3){
				bool done[10] = {false};
				for (int i = 0; i < 3; i++){
					for (int j = 0; j < 3; j++){
						int ny = y + i, nx = x + j;
						// printf("%d ", table[ny][nx]);
						if (done[table[ny][nx]]){
							ok[ny][nx] = false;
							for (int k = 0; k < 3; k++){
								for (int l = 0; l < 3; l++){
									if (table[ny][nx] == table[y + k][x + l]){
										ok[y + k][x + l] = false;
									}
								}
							}
						}
						done[table[ny][nx]] = true;
					}
					// cout << endl;
				}
				// cout << endl;
			}
		}
		
		for (int i = 0; i < 9; i++){
			for (int j = 0; j < 9; j++){
				printf("%c%d", ok[i][j] ? ' ' : '*', table[i][j]);
			}
			cout << endl;
		}
		
		if (cnt + 1 < n) cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

void Q1() {

	double r;
	double PI = 3.141592653589;
	cin >> r;

	printf("%lf %lf\n", PI*r*r, 2 * r*PI);

}

void Q2() {
	int a, b;
	string op;

	while (true)
	{
		cin >> a >> op >> b;
		if (op == "?") { break; }
		else if (op == "+") {
			cout << a + b << endl;
		}
		else if (op == "-") {
			cout << a - b << endl;
		}
		else if (op == "*") {
			cout << a * b << endl;
		}
		else if (op == "/"){
			cout << a / b << endl;
		}
	}
	
}

void Q3() {
	int x; cin >> x;
	long long sum = 0;
	vector<int> a;
	a.resize(x);

	for (int i = 0; i < x; i++) {
		cin >> a[i];
		sum += a[i];

	}

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

	cout << a[0] << " " << a[x - 1] << " " << sum << endl;
}

void Q4() {

	while (true)
	{
		int a, b;
		cin >> a >> b;

		if (a == 0 && b == 0)break;

		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				cout << "#";
			}
			cout << "\n";
		}
		cout << "\n";
	}
}

void Q5() {
	while (true)
	{
		int a, b;
		cin >> a >> b;

		if (a == 0 && b == 0)break;

		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				if (i != 0 && i != a - 1 && j != 0 && j != b - 1)
					cout << ".";
				else
					cout << "#";
			}
			cout << "\n";
		}
		cout << "\n";
	}

}

int main() {
	Q5();
	return 0;
}

Measured memory_bytes: 1124
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define MOD 1000000007ll
ll B = 810893ll;
ll hS[300100];
ll hT[300100];
int L[300100];
int R[300100];
ll Pow[300100];
int Sl,Tl;
ll LeftT(int len){return hT[len-1];}
ll RightT(int len){return (hT[Tl-1]-((hT[Tl-1-len]*Pow[len])%MOD)+MOD)%MOD;}
ll LeftS(int pos,int len)
{
	ll res = hS[pos+len-1];
	if(pos>0)res = (res-((hS[pos-1]*Pow[len])%MOD)+MOD)%MOD;
	return res;
}
ll RightS(int pos,int len)
{
	ll res = hS[pos];
	if(pos>=len)res = (res-((hS[pos-len]*Pow[len])%MOD)+MOD)%MOD;
	return res;
}
int main()
{
	string S,T;
	cin >> S;
	cin >> T;
	Sl = S.size();
	Tl = T.size();
	hS[0]=(S[0]-'A');
	hT[0]=(T[0]-'A');
	for(int i=1;i<S.size();i++)hS[i]=((hS[i-1]*B)+(S[i]-'A'))%MOD;
	for(int i=1;i<T.size();i++)hT[i]=((hT[i-1]*B)+(T[i]-'A'))%MOD;
	Pow[0]=1ll;
	for(int i=1;i<=300000;i++)Pow[i]=(Pow[i-1]*B)%MOD;
	for(int i=0;i<S.size();i++)
	{
		int l = 0,r = min(Tl,Sl-i)+1;
		while(r-l>1)
		{
			int mid = (l+r)/2;
			if(LeftS(i,mid)==LeftT(mid))l = mid;
			else r = mid;
		}
		L[i]=l;
	}
	for(int i=0;i<S.size();i++)
	{
		int l = 0,r = min(i+1,Tl)+1;
		while(r-l>1)
		{
			int mid = (l+r)/2;
			if(RightS(i,mid)==RightT(mid))l = mid;
			else r = mid;
		}
		R[i]=l;
	}
	int ans = 0;
	for(int i=0;i<Sl-Tl+1;i++)if(L[i]+R[i+Tl-1]==Tl-1)ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11092
// Author: πα

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

int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    k = min(n, k);
    vector<int> v(n);
    for(int& it : v)
        cin >> it;
    sort(v.rbegin(), v.rend());
    long ans = 0;
    for(int i = k; i < n; ++i)
        ans += v[i];
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int a, b, n;
	cin >> n >> a >> b;
	if (n * a >= b) cout << b << '\n';
	else cout << a * n << '\n';

	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>

using namespace std;

struct Elem {
    string str;
    Elem *right;
    Elem *left;
};

Elem *root, *NIL;

void init() {
    NIL = new Elem();
    NIL->str = "";
    NIL->right = NIL;
    NIL->left = NIL;
    root = NIL;
}

void insert(string s) {
    Elem *cur = root, *back = root;
    while (cur != NIL) {
        back = cur;
        if (s == cur->str) {
            return;
        }
        if (s < cur->str) {
            cur = cur->left;
        }
        else {
            cur = cur->right;
        }
    }
    Elem *add = new Elem();
    add->str = s;
    add->left = NIL;
    add->right = NIL;
    if (root == NIL)
        root = add;
    else if (s < back->str)
        back->left = add;
    else
        back->right = add;
}

bool find(string s) {
    Elem *cur = root;
    while (cur != NIL) {
        if (s == cur->str) {
            return true;
        }
        if (s < cur->str) {
            cur = cur->left;
        }
        else {
            cur = cur->right;
        }
    }
    return false;
}

int main() {
    int n;
    string s, t;
    init();

    cin >> n;
    while (n--) {
        cin >> s >> t;
        if (s == "insert") {
            insert(t);
        }
        if (s == "find") {
            if (find(t))
                cout << "yes" << endl;
            else
                cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 28256
n=input()
k=len(n)
dp=[[0]*2 for _ in range(k)]
dp[0][0]=min(int(n[0]),11-int(n[0]))
dp[0][1]=min(int(n[0])+1,11-(int(n[0])+1))
for i in range(1,k):
  dig=int(n[i])
  dp[i][0]=min(dp[i-1][0]+dig,dp[i-1][1]+10-dig)
  dp[i][1]=min(dp[i-1][0]+dig+1,dp[i-1][1]+10-(dig+1))
print(dp[k-1][0])

Measured memory_bytes: 170048
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
const long long MOD = 1000000007;

int H, W;
bool ss[2001][2001];
int sum_i[2001][2001];
int sum_j[2001][2001];

int main() {
    cin >> H >> W;
    for (int i = 1; i <= H; i++) {
        string S;
        cin >> S;
        for (int j = 1; j <= W; j++) {
            ss[i][j] = S[j - 1] == '.';
        }
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (ss[i][j]) {
                sum_i[i][j] = sum_i[i - 1][j] + 1;
                sum_j[i][j] = sum_j[i][j - 1] + 1;
            }
        }
    }

    for (int i = H; i >= 1; i--) {
        for (int j = W; j >= 1; j--) {
            if (ss[i][j]) {
                if (i != H) sum_i[i][j] = max(sum_i[i + 1][j], sum_i[i][j]);
                if (j != W) sum_j[i][j] = max(sum_j[i][j + 1], sum_j[i][j]);
            }
        }
    }

    int ans = 0;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            //printf("%c(%d, %d)\t", ss[i][j] ? '.' : '#', sum_i[i][j], sum_j[i][j]);
            ans = max(ans, sum_i[i][j] + sum_j[i][j] - 1);
        }
        //cout << '\n';
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 35456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        int r = in.nextInt();
        int d = in.nextInt();
        int x = in.nextInt();

        for (int i = 0; i < 10; i++) {
            x = (r * x) - d;
            out.println(x);
        }
    }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define ll long long
int main()
{
    ll ans = 0;
    ll n;
    std::vector<ll> L;

    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        ll temp = 0;
        std::cin >> temp;
        L.push_back(temp);
    }
    std::sort(L.begin(), L.end());

    for (ll i = 0; i < n - 2; ++i) {
        for (ll j = i + 1; j < n - 1; ++j) {
            if (L[j] == L[i]) {
                continue;
            }
            for (ll k = j + 1; k < n; k++) {
                if (L[j] == L[k]) {
                    continue;
                }
                if (L[i] + L[j] > L[k]) {
                    ++ans;
                }
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3632
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    l = [x for x in a if x % 2 == 0 and x % 3 != 0 and x % 5 != 0]
    print("APPROVED" if not l else "DENIED")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940