akhauriyash/Code-Regression huggingface dataset:
H, W, K = map(lambda x: int(x), input().split())

matrix = []
for i in range(H):
	row = input()
	dots = []
	for j in range(W):
		dots.append(row[j])
	matrix.append(dots)

ans = 0
for bitR in range(1 << H):
	for bitC in range(1 << W):
		black = 0
		for i in range(H):
			for j in range(W):
				if ((bitR >> i) & 1) == 0 and ((bitC >> j) & 1) == 0 and matrix[i][j] == '#':
					black += 1
		if black == K:
			ans += 1

print(ans)





Measured memory_bytes: 9096
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;
typedef long long ll;

int N, M;
int P[100000], Y[100000];
vector<int> yd[100001];

int main() {
    scanf("%d %d ", &N, &M);
    for (int i = 0; i < M; i++) {
        scanf("%d %d ", &P[i], &Y[i]), yd[P[i]].push_back(Y[i]);
    }

    for (int i = 0; i < N; i++) sort(yd[i + 1].begin(), yd[i + 1].end());

    for (int i = 0; i < M; i++) {
        auto lb  = lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]);
        int rank = lb - yd[P[i]].begin() + 1;
        printf("%06d%06d\n", P[i], rank);
    }
}


Measured memory_bytes: 7680
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int N,A,B;
int main (){
      cin>>N>>A>>B;
      if(N==1){
            cout<<"Hello World"<<endl;
      }
      else{
            cout<<A+B<<endl;
      }
      
      return 0;
}


Measured memory_bytes: 256
N = int(input())

keta = 1
keta_max_list = []
keta_max_list.append(0)

keta_max_list.append(26**(keta))
while True:
    if N <= keta_max_list[keta]:
        break
    keta += 1
    keta_max_list.append(keta_max_list[keta-1] + 26**(keta))
#print(keta,keta_max_list)

keta_list = [0 for _ in range(keta+1)]

for i in range(keta, 0, -1):  # keta ～　1 桁目までループ
    for j in range(1,27):
        if (N-keta_max_list[i-1])/26**(i-1) <= j:
            keta_list[i] = j
            N -= j*26**(i-1)
            break
            
ans_list = []
for i in range(keta, 0, -1):
    ans_list.append(chr(97+keta_list[i]-1))
ans = "".join(ans_list)

print(ans)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main() {
	int n, c, ans=INF, in;
	cin >> n >> c;
	vvi d(c, vi(c)), vv(n, vi(n));
	rep(i, c) {
		rep(j, c) {
			cin>>d[i][j];
		}
	}
	rep(i, n) {
		rep(j, n) {
			cin >> vv[i][j];
		}
	}
	vvi dist(3, vi(c));
	rep(k, c) {
		rep(i, n) {
			rep(j, n) {
				dist[(i + j) % 3][k] += d[vv[i][j]-1][k];
			}
		}
	}
	rep(i, c) {
		rep(j, c) {
			if(i!=j){
				rep(k, c) {
					if (j != k&&k != i){
					ans = min(ans, dist[0][i] + dist[1][j] + dist[2][k]);
					}
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1280
package main

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

var sc = bufio.NewScanner(os.Stdin)
const MAX_N = 1e5 + 10

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

func main() {
    sc.Split(bufio.ScanWords)
    var n, k, q int64
    var a [MAX_N]int64

    n = nextInt()
    k = nextInt()
    q = nextInt()
    for i := int64(0); i < q; i++ {
        a[i] = nextInt()
        a[i]--
    }
    var cnt [MAX_N]int64

    for i := int64(0); i < q; i++ {
        cnt[a[i]]++
    }

    for i := int64(0); i < n; i++ {
        if k - (q - cnt[i]) > 0 {
            fmt.Println("Yes")
        } else {
            fmt.Println("No")
        }
    }
}

Measured memory_bytes: 4736
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_TOWN_MAX		200000									// 最大町数

// 内部変数
static FILE *szpFpI;											// 入力
static int siTCnt;												// 町数
static long long slMCnt;										// 移動回数
static int si1To[D_TOWN_MAX];									// 行き先
static int si1MCnt[D_TOWN_MAX];									// 移動回数[町]

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si1MCnt, -1, sizeof(si1MCnt));

	// 町数・移動回数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%lld", &siTCnt, &slMCnt);

	// 行き先 - 取得
	for (i = 0; i < siTCnt; i++) {
		fscanf(szpFpI, "%d", &si1To[i]);
		si1To[i]--;
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 移動回数[町] - セット
	int liTNo = 0;
	si1MCnt[liTNo] = 0;
	int liMCnt = 0;
	while (slMCnt > 0) {

		// 移動先
		liMCnt++;
		slMCnt--;
		int liTNo2 = si1To[liTNo];

		// 新規
		if (si1MCnt[liTNo2] < 0) {
			si1MCnt[liTNo2] = liMCnt;
		}

		// ２回目
		else {

			// 周回
			int liLen = liMCnt - si1MCnt[liTNo2];
			long long llRCnt = slMCnt / (long long)liLen;
			slMCnt -= llRCnt * (long long)liLen;
		}

		// 次へ
		liTNo = liTNo2;
	}

	return liTNo + 1;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

int main() {
        int n;
        scanf("%d", &n);
        vector<pair<int, int>> p(n);
        int ma = 0, mi = 1e9 + 5;
        rep(i, n) {
                scanf("%d%d", &p[i].first, &p[i].second);
                ma = max(ma, max(p[i].first, p[i].second));
                mi = min(mi, min(p[i].first, p[i].second));
        }
        int c = 0;
        rep(i, n) {
                c += (p[i].first == ma || p[i].second == ma || p[i].first == mi || p[i].second == mi);
        }
        long long ans = 1e18 + 5;
        if (c != 1) {
                rep(i, n) {
                        if (p[i].first > p[i].second) {
                                swap(p[i].first, p[i].second);
                        }
                }
                sort(p.begin(), p.end());
                int v = p.back().first;
                int u = 1e9 + 5;
                rep(i, n) {
                        ans = min(ans, (long long) (v - min(p[i].first, u)) * (ma - mi));
                        v = max(v, p[i].second);
                        u = min(u, p[i].second);
                }
        }
        vector<int> l, r;
        rep(i, n) {
                if (p[i].first > p[i].second) {
                        l.push_back(p[i].first);
                        r.push_back(p[i].second);
                } else {
                        r.push_back(p[i].first);
                        l.push_back(p[i].second);
                }
        }
        sort(l.begin(), l.end());
        sort(r.begin(), r.end());
        ans = min(ans, (long long) (l.back() - l.front()) * (r.back() - r.front()));
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,a,n) for(int (i) = (a);(i) < (n);(i)++)
typedef long long ll;

using namespace std;

int main(){
	int n,m;
	string s;
	cin >> n >> m;
	
	rep(i,0,n){
		cin >> s;
		cout << s << endl << s << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int N;
    string S;
    int64_t ans = 0;

    cin >> N;
    cin >> S;

    // (1) (#R * #G * B)の場合を列挙 
    int64_t RGBnum[3] = {0, 0 ,0};  // Rは[0], Gは[1], Bは[2] 
                                    // 右辺もint64_tじゃないと結果がintにキャストされてしまう 
    for(int cnt = 0; cnt < S.length(); cnt++){
        if(S[cnt] == 'R'){
            RGBnum[0]++;
        }else if(S[cnt] == 'G'){
            RGBnum[1]++;
        }else{
            RGBnum[2]++;
        }
    }
    ans = RGBnum[0] * RGBnum[1] * RGBnum[2];

    // (2) (K = 2j -i)の場合を引いていく　
    for(int i = 0; i < N - 2; i++){
        for(int j = i + 1; j < N -1; j++){
            int k = 2 * j - i;// (K = 2j -i)の場合を人為的に作る 
            if((S[i] != S[j]) && (S[k] != S[j]) && (S[i] != S[k])){
                if(k < N){
                    ans--;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int M=1e6+6;
const int inf=0x3f3f3f3f;
const ll INF=1e18;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<' '<<a<<' '<<b;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    vector<ll> dp1(N+1);
    auto dp2 = dp1, dp3 = dp1, dp4 = dp1, dp5 = dp1;
    rep(i,N) {
        dp1[i+1] = dp1[i] + A[i];
        dp2[i+1] = min(dp2[i],dp1[i]) + ((A[i]==0) ? 2 : A[i]%2);
        dp3[i+1] = min({dp3[i],dp2[i],dp1[i]}) + ((A[i]&1) ? 0 : 1);
        dp4[i+1] = min({dp4[i],dp3[i],dp2[i],dp1[i]}) + ((A[i]==0) ? 2 : A[i]%2);
        dp5[i+1] = min({dp5[i],dp4[i],dp3[i],dp2[i],dp1[i]}) + A[i];
    }
    cout << min({dp1[N],dp2[N],dp3[N],dp4[N],dp5[N]}) << ln;
}

Measured memory_bytes: 9600
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL
ll n , m;
vector<int> k(10) , p(10);
vector<vector<int>> s(11, vector<int>(11));

int onswitch(int onoff, int ik) {
	int ret = 0;
	for(int i=0;i<k[ik];i++) {
		if ((onoff & (1 << ( (int)s[ik][i]-1)) ) != 0) ret++;
	}
	return ret;
}
int main() {
	int		a,b,c,h,i,j,l,x,y;
	int		ans = 0;
	cin >> n >> m;

	for(i=0;i<m;i++) {
		cin >> k[i];
		for(j=0;j<k[i];j++) {
			cin >> s[i][j];
		}
	}
	for(i=0;i<m;i++) cin >> p[i];

	for(i=0;i<(1<<n);i++) {
		bool f = true;
		for(j=0;j<m;j++) {
			if ( (onswitch(i,j) %2) != p[j]) f = false;
		}
		if (f) ans++;
	}
	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));

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


Measured memory_bytes: 3628
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;

    long[long] mp;
    foreach (a; A) mp[a] += 1;

    auto B = mp.keys.array;
    B.sort();

    long[] P;
    for (long i = 0; (1L << i) <= 4 * 10L^^9; ++i) P ~= (1L << i);


    long ans = 0;

    foreach_reverse (a; B) {
        foreach_reverse (p; P) {
            if (p - a == a) {
                long x = mp[a] / 2;
                ans += x;
                mp[a] -= x * 2;
            } else if ((p - a) in mp) {
                long x = min(mp[a], mp[p-a]);
                ans += x;
                mp[a] -= x;
                mp[p-a] -= x;
            }
        }
    }

    ans.writeln;
}


Measured memory_bytes: 27504
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, h, w = map(int, input().split())
    ans = 0
    for _ in range(n):
        a, b = map(int, input().split())
        if a >= h and b >= w:
            ans += 1

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 63056
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class UnionFind():
    def __init__(self):
        self.__table = {}
        self.__size = defaultdict(lambda: 1)

    def __root(self, x):
        if x not in self.__table:
            self.__table[x] = x
        elif x != self.__table[x]:
            self.__table[x] = self.__root(self.__table[x])

        return self.__table[x]

    def same(self, x, y):
        return self.__root(x) == self.__root(y)

    def union(self, x, y):
        x = self.__root(x)
        y = self.__root(y)
        if x != y:
            self.__size[x] += self.__size[y]
            self.__size[y] = self.__size[x]
            self.__table[x] = y
            

    def size(self, x):
        return self.__size[self.__root(x)]

@mt
def slv(N, M, AB):
    uf = UnionFind()

    ans = [N*(N-1)//2]
    for a, b in reversed(AB):
        s =  uf.same(a, b)
        if s:
            ans.append(ans[-1])
        else:
            try:
                s1, s2 = uf.size(a), uf.size(b)
                uf.union(a, b)
            except:
                s1 = 1
                s2 = 0
            ans.append(ans[-1] - s1*s2)
            
    ans.pop()
    # print(ans)
    for a in reversed(ans):
        print(a)
            

    # return ans


def main():
    # N = read_int()
    N, M = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    slv(N, M, AB)



if __name__ == '__main__':
    main()


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var val = cin.Read();
            var x = val[0];
            var c = 0;
            var max = 0;
            for (int i = 1; i < val.Length; ++i)
                if (val[i] == x) c++;
                else { max = Max(c, max); c = 0; x = val[i]; }

            max = Max(c, max);
            if (max >= 2) WriteLine("Yes");
            else WriteLine("No");
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}



Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,b) for (int i=0; i<(b); ++i)
#define endl '\n'
#define sz(x) (int) x.size()
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define sqr(x) ((x)*(x))
typedef long long int64;
typedef unsigned long long qword;
using namespace std;
const int base=1e9+7;
int n;
int64 f[1<<16];
int64 cost[1<<16];
int st[16];
int a[16][16];
void Input()
{
    cin >> n;
    REP(i,n) REP(j,n) cin >> a[i][j];
}
void Solve()
{
    REP(mask,1<<n) {
        REP(i,n) if (mask>>i&1)
            REP(j,i) if (mask>>j&1)
                cost[mask]+=a[i][j];
        int top=0;
        REP(i,n)
            if (mask>>i&1) st[top++]=i;
        int nxtmask=0;
        REP(nxt,1<<top) {
            nxtmask=0;
            REP(i,top)
                if (nxt>>i&1) nxtmask|=1<<st[i];
            f[mask]=max(f[mask],cost[nxtmask]+f[mask^nxtmask]);
        }
    }
    cout << f[(1<<n)-1];
}
int main()
{
    #ifdef meomeomeooooo
        freopen("input.txt","r",stdin);
        //freopen(".out","w",stdout);
    #endif // meomeomeooooo
    iostream::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Solve();
    return 0;
}


Measured memory_bytes: 1280
import sys
read = sys.stdin.read
def main():
    n = int(input())
    a = input()
    if not 'WR' in a:
        print(0)
        sys.exit()
    a = list(a)
    rnum = a.count('R')
    rl = 0
    rr = 0
    for i1 in range(rnum):
        rl += a[i1] == 'W'
    for j1 in range(n - rnum):
        rr += a[rnum + j1] == 'R'
    r = max(rl, rr)
    print(r)
if __name__ == '__main__':
    main()


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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()



int N,K;

void solve() {
    ll A[55],S[55];
    memset(S,0,sizeof(S));
    cin >> N >> K;
    _for(i,N)cin >> A[i];
    _for(i,N)S[i+1] = S[i]+A[i];
    ll mx = -1;
    rep(i,0,N)rep(j,N+1,i){
            int k = K-(N-(j-i));
            if(k<0)continue;
            ll sum = S[N] - (S[j] - S[i]);
            vector<int > v;
            _for(ii,i)v.emplace_back(A[ii]);
            rep(jj,j,N)v.emplace_back(A[jj]);
            sort(all(v));
            int ind = 0;
            if(!v.empty()){
                while(v[ind] < 0 && ind < v.size() && k > 0)sum -= v[ind],ind++,k--;
//                if(k&1){
//                    if(ind<v.size())sum -= v[ind];else sum += v[ind-1];
//                }
            }
            mx = max(sum ,mx);
        }

    cout << mx << endl;
}
int main() {
    solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

ll dp[55][400000];
ll C(ll n,ll k){
	if(n<k)return 0;
	if(k<0)return 0;
	return dp[k][n-k];
}
void init(){
	rep(i,55)rep(j,400000){
		if(i==0&&j==0){
			dp[i][j]=1;
		}
		else{
			dp[i][j]=0;
			if(i)dp[i][j]+=dp[i-1][j];
			if(j)dp[i][j]+=dp[i][j-1];
		}
	}
}

ll n,k,a[50],s,t;

ll calc(ll x){
	ll res=0;
	for(ll i=1;i<=k;i++){
		res+=C(x,i);
	}
	return res;
}

int main(){
	init();
	cin>>n>>k>>s>>t;
	rep(i,n)cin>>a[i];
	bool alv[50];
	rep(i,n)alv[i]=1;
	vector<ll> dig;
	rep(i,18){
		bool ss=s&(1<<i);
		bool tt=t&(1<<i);
		if(ss==1&&tt==0){
			cout<<0<<endl;
			return 0;
		}
		if(ss==1){
			rep(j,n)if(!(a[j]&(1<<i)))alv[j]=0;
		}
		else if(tt==0){
			rep(j,n)if(a[j]&(1<<i))alv[j]=0;
		}
		else{
			dig.push_back(i);
		}
	}
	int m=0;
	rep(i,n){
		if(alv[i]){
			a[m]=a[i];
			m++;
		}
	}
	n=m;
	ll ans=0;
	rep(i,(1<<(int)dig.size())){
		bool us[18];
		rep(j,18)us[j]=0;
		rep(j,dig.size()){
			if(i&(1<<j)){
				us[dig[j]]=1;
			}
		}
		unordered_map<ll,ll> mas;
		rep(j,n){
			ll res=0;
			rep(r,18){
				if(us[r]){
					res+=a[j]&(1<<r);
				}
			}
			mas[res]++;
		}
		ll res=0;
		for(auto t:mas){
			res+=calc(t.second);
		}
		
		int pcnt=0;
		rep(j,18)pcnt+=us[j];
		if(pcnt%2==0)ans+=res;
		else ans-=res;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 175448
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]

s_unique = list(set(s))
N_unique = len(s_unique)

ans = 0
for i in range(0,N_unique):
	string = s_unique[i]
	if ans < s.count(string)-t.count(string):
		ans = s.count(string)-t.count(string)

print(ans)

Measured memory_bytes: 3064
//{{{By oToToT
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <random>
#include <utility>
#include <stack>
#include <sstream>
#include <functional>
#include <deque>
#include <cassert>
using namespace std;
/* include everything for Kotori~ <3 */

using lld = int64_t;
using llu = uint64_t;
using llf = long double;
using PII = pair<int,int>;
using PIL = pair<int,lld>;
using PLI = pair<lld,int>;
using PLL = pair<lld,lld>;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
/* define some types for Ruby! */

#define FF first
#define SS second
#define SZ(x) (int)((x).size())
#define ALL(x) begin(x), end(x)
#define PB push_back
#define WC(x) while(x--)
/* make code shorter for Di~a~ */

template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
	s<<"[";
	for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
	s<<"]";
	return s;
}
template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.FF<<","<<p.SS<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
/* make output easier for Ainyan~n~ */

bool debug = 0;
#define DUMP(x) if(debug) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<'\n'
template<typename T>
void DEBUG(const T& x){if(debug) cerr<<x;}
template<typename T, typename... Args>
void DEBUG(const T& head,const Args& ...tail){
	if(debug){cerr<<head; DEBUG(tail...);}
}
/* Let's debug with Nico~Nico~Ni */
//}}}

int main(int argc, char* argv[]){
	if(argc>1 and string(argv[1])=="-D") debug=1;
	if(!debug){ios_base::sync_with_stdio(0);cin.tie(0);}
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2-x1, dy=y2-y1;
	cout<<x2-dy<<' '<<y2+dx<<' '<<x2-dy-dx<<' '<<y2+dx-dy<<'\n';
	return 0;
}

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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  int n;
  int ans;
  
  cin >> n;
  
  ans = n*n*n;
  cout << ans << endl;
  
  return 0;
}

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

bitset<50001> pt;

void MakeTable(int n){
  pt.reset();
  pt.set(2);
  
  int i;
  for(i=3;i<=n;i+=2)pt.set(i);
  
  i = 3;
  while(i*i<=n){
    for(int j=3*i;j<=n;j+=2*i)pt.reset(j);
    do{i+=2;}while(!pt[i]);
  }
}

int main(){
  int n,ans;
  MakeTable(50000);

  while(1){
    cin >> n;
    if(!n)break;
    if(n&1){
      if(pt[n-2])cout << 1 << endl;
      else cout << 0 << endl;
    }else{
      ans = 0;
      for(int i=0;i<=n/2;i++)
	if(pt[i] && pt[n-i])ans++;
      cout << ans << endl;
    }
  }
}
	

Measured memory_bytes: 872
#include "bits/stdc++.h"
using namespace std;

int main() {
    string s;
    cin >> s;
    
    bool ease = true;
    for (int i = 0; i < s.size(); ++i) {
        if (i % 2) {
            if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
                ease = false;
                break;
            }
        } else {
            if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
                ease = false;
                break;
            }
        }
    }

    cout << (ease ? "Yes" : "No");

    return 0;
}


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

public class Main {
    int n;
    long a, b, k;
    int MOD = 998244353;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        a = sc.nextInt();
        b = sc.nextInt();
        k = sc.nextLong();
        solve();
    }

    void solve() {
        Combination c = new Combination(300000, MOD);
        long ans = 0;
        for (int i = 0; i <= n; i++) {
            if (k < a * i) break;
            if ((k - a * i) % b == 0) {
                long jl = (k - a * i) / b;
                if (jl > n) {
                    continue;
                }
                int j = (int)jl;
                ans += c.comb(n, i) * c.comb(n, j) % MOD;
                ans %= MOD;
            }
        }
        System.out.println(ans);
    }

    class Combination {
        long mod;
        int[] facts;
        int[] invs;
        int[] invFacts;

        public Combination(int max, int mod) {
            this.mod = mod;
            facts = new int[max + 2];
            invs = new int[max + 2];
            invFacts = new int[max + 2];
            invs[1] = 1;
            for (int i = 2; i <= max + 1; i++) {
                invs[i] = (int)((long)invs[mod % i] * (mod - mod / i) % mod);
            }
            facts[0] = 1;
            invFacts[0] = 1;
            for (int i = 1; i <= max + 1; i++) {
                facts[i] = (int)(facts[i - 1] * (long)i % mod);
                invFacts[i] = (int)(invFacts[i - 1] * (long)invs[i] % mod);
            }
        }

        long comb (int n, int k) {
            if (k < 0 || k > n) return 0;
            return facts[n] * (long)invFacts[k] % mod * (long)invFacts[n - k] % mod;
        }

        long combRep(int n, int k) {
            return comb(n + k - 1, k);

        }
    }

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


Measured memory_bytes: 25556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
const ll md = 1000000007;

ll add(ll a, ll b, ll mod = md) {
    return (a%mod + b%mod + mod)%mod;
}

ll mul(ll a, ll b, ll mod = md) {
    return (a%mod * b%mod + mod)%mod;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = n/2;
        x = (x*x)%mod;
    }
    return res;
}

ll power2(ll x, ll n) {
    ll res = 1;
    while (n) {  
        if (n & 1) res = (res*x);
        n = n/2;
        x = (x*x);
    }  
    return res;
}

ll lg(ll k, ll e) {
	ll i, x = k;
	for(i = 0; ; i++, x = x*k) {
		if(x > e) {
			break;
		}
	}
	return i;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector<ull> a(n);
    bool good=  true;
    for(int i = 0; i < n; i++) {
    	cin >> a[i];
    }
    ll prod = 1;
    for(int i = 0; i < n; i++) {
    	if((long double)1000000000000000000/prod < a[i]) {
    		good = false;
    		break;
    	} else {
    		prod *= a[i];
    	}
    }
    for(int i = 0; i < n; i++) {
    	if(a[i] == 0) {
    		good = true;
    		prod = 0;
    		break;
    	}
    }
    if(good) {
    	cout << prod << "\n";
    } else {
    	cout << "-1\n";
    }
    return 0;
}

Measured memory_bytes: 3992
/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define rep(i, n) for (int(i) = (0); (i) < (n); ++(i))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x

void prep()

{
	ios_base::sync_with_stdio(0);

	cin.tie(0);

	cout.tie(0);

	/*#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);

#endif*/
}

int main()

{
	prep();
	int n;
	cin >> n;
	map<string, int> ans;
	for (int i = 0; i < n; i++)
	{
		string str;
		cin >> str;
		ans[str]++;
	}
	string anss[] = {"AC", "WA", "TLE", "RE"};
	for (auto il : anss)
	{
		cout << il << " "
			 << "x"
			 << " " << ans[il] << endl;
	}

	return 0;
}
/*
6
AC
TLE
AC
AC
WA
TLE
AC x 10
WA x 0
TLE x 0
RE x 0
*/


Measured memory_bytes: 3580
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
  int i,n;
  double sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    double x;
    char s[100]={'\0'};
    scanf("%lf %s",&x,s);
    if(s[0]=='J') sum+=x;
    else sum+=x*380000;
  }
  printf("%lf",sum);
  return 0;
}

Measured memory_bytes: 128
#include<atcoder/all>
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int) (n); i++)
#define MAX 300001
using namespace atcoder;
using namespace std;

int op(int a, int b){
  return max(a, b);
}

int e(){
  return 0;
}
  
int main(){
  int N, K, A;
  cin >> N >> K;
  segtree<int, op, e> seg(MAX);
  rep(i, N){
    cin >> A;
    A;
    if(!i) seg.set(A, 1);
    else{
      int m = seg.prod(max(0, A - K), min(MAX, A + K + 1));
      seg.set(A, m + 1);
    }
  }
  cout << seg.all_prod() << endl;
  return 0;
}

Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n>=400&&n<=599)
	cout<<"8";
	else
	{
		if(n>=400&&n<=599)
	cout<<"8";
	else
	{
		if(n>=600&&n<=799)
	cout<<"7";
	else
	{
		if(n>=800&&n<=999)
	cout<<"6";
	else
	{
		if(n>=1000&&n<=1199)
	cout<<"5";
	else
	{
		if(n>=1000&&n<=1399)
	cout<<"4";
	else
	{
		if(n>=1400&&n<=1599)
	cout<<"3";
	else
	{
		if(n>=1600&&n<=1799)
	cout<<"2";
	else
	cout<<"1";
	}
	}
	}
	}
	}
	}
	}
}

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

using namespace std;


char s[111111];
long long a[5];
char mch[6] = {'M', 'A', 'R', 'C', 'H'};
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%s", s);
        for(int j = 0; j < 5; j++){
            if(s[0] == mch[j]) a[j]++;
        }
    }
    long long ans = 0;
    for(int i = 0; i < 3; i++){
        for(int j = i + 1; j < 4; j++){
            for(int k = j + 1; k < 5; k++){
                ans += a[i] * a[j] * a[k];
            }
        }
    }
    printf("%lld\n", ans);
}

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

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int[] v = new int[n];
		int[] c = new int[n];
		int result = 0;
		for(int i = 0; i < n; i++) {
			v[i] = ni();
		}
		for(int i = 0; i < n; i++) {
			c[i] = ni();
		}
		for(int i = 0; i < n; i++) {
			int dif = v[i] - c[i];
			result += dif > 0 ? dif : 0;
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

using namespace std;

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


int main()
{
	int n, m;
	double p[610];
	vector<int> ed[610], inv_ed[610];
	cin >> n >> m;
	int s, t;
	rep(i, m)
	{
		cin >> s >> t;
		s--; t--;
		ed[s].pb(t);
		inv_ed[t].pb(s);
	}
	p[n-1]=0;
	for(int i=n-2; i>=0; i--)
	{
		p[i]=1;
		rep(j, ed[i].size())
		{
			p[i]+=p[ed[i][j]]/(double)ed[i].size();
		}
	}
	int mx[610];
	rep(i, n-2)
	{
		mx[i]=ed[i][0];
		rep(j, ed[i].size())
		{
			if(p[ed[i][j]]>p[mx[i]]) mx[i]=ed[i][j];
		}
	}
	double ans=p[0];
	rep(k, n-2)
	{
		if(ed[k].size()>1)
		{
			for(int i=n-2; i>=0; i--)
			{
				p[i]=0;
				rep(j, ed[i].size())
				{
					if(i!=k || ed[i][j]!=mx[i]) p[i]+=p[ed[i][j]]/(double)ed[i].size();
				}
				if(i==k) p[i]=p[i]*(double)ed[i].size()/(double)(ed[i].size()-1);
				p[i]+=1.0;
			}
			ans=min(ans, p[0]);
		}
	}
	cout << setprecision(9) << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> alist = new ArrayList<>();
        int max = 0;
        int secondMax = 0;
        for (int x=1; x<=n;x++) {
            int tmp = Integer.parseInt(sc.next());
            alist.add(tmp);
            if (max<=tmp) {
                secondMax = max;
                max=tmp;
                continue;
            }
            if (secondMax<tmp) {
                secondMax=tmp;
            }
            
        }
        for (int x=1; x<=n;x++) {
            int tmp = alist.get(x-1);
            System.out.println(tmp!=max?max:secondMax);
        }
    }
}


Measured memory_bytes: 73228
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
res = 0
for i in a:
    res += b[i - 1]
for i, j in zip(a, a[1:]):
    if j == i + 1:
        res += c[i - 1]
print(res)

Measured memory_bytes: 38256
#include<iostream>
#include <string>
#include <algorithm>
#include <deque>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define REP(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;

deque<char>s;
int q; 
int h=0;//反転
int main(){
    string first;
    cin>>first>>q;
    REP(i,0,first.size())s.push_back(first[i]);
    
    for(int i=0;i<q;i++){
        int t=0;
        cin>>t;
        if(t==1){
            h++;
        }
        if(t==2){
            int f=0;
            char c;
            cin>>f;
            cin>>c;
            if(f==1){//先頭に追加
                if(h%2==0){//非反転
                    s.push_front(c);
                }else{//反転
                    s.push_back(c);
                }
            }
            if(f==2){//末尾に追加
                if(h%2==0){//非反転
                    s.push_back(c);
                }else{
                    s.push_front(c);
                }
            }
        }
    }
    if(h%2==1)reverse(s.begin(),s.end());
    for(int i=0;i<s.size();i++){
        cout<<s.at(i);
    }
}

Measured memory_bytes: 896
import java.lang.reflect.Array;
import java.util.*;
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 output = 0;
		int temp = 0;
		int var = arr[0];
		for(int i = 1;i<N;i++) {
			if(var>=arr[i]) {
				temp++;
			}
			else {
				
				if(output<=temp) {
					output = temp;
				}
				temp =0;
			}
			var = arr[i];
		}
		if(output < temp)output = temp;
		System.out.println(output);

	}
	

}


Measured memory_bytes: 50220
# include <iostream>
# include <stdint.h>
# include <stdio.h>
# include <math.h>
# include <algorithm>
# include <string>
using namespace std;


int main(){
	int scoret =0, scoreh =0, n,min;
    string strt,strh;
    cin >>n;
    for(int i=0;i<n;i++){
        cin >>strt >>strh;
        int t =(int)strt.size(), h =(int)strh.size();
        if(t >= h){
            min = h;
        }
        if(t <h){
            min = t;
        }
        for(int j =0;j< min;j++){
            if(strt[j] <strh[j]){
                scoreh += 3;
                break;
            }
            else if(strt[j] > strh[j]){
                scoret +=3;
                break;
            }
            if(j == min-1){
                if(t<h){
                    scoreh +=3;
                }
                else if( t>h){
                    scoret +=3;
                }
                else if(t ==h){
                    scoret += 1;
                    scoreh +=1;
                }
            }
        }
    }
    cout <<scoret<<" "<<scoreh <<"\n";
	return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++)
    cin >> l[i];
  sort(l.begin(), l.end());
  int ans = 0;
  for (int i = 0; i < n-2; i++) {
    for (int j = i+1; j < n-1; j++) {
      int k = lower_bound(l.begin()+j+1, l.end(), l[i]+l[j]) - l.begin();
      ans += k-(j+1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

class make_str {
public:
	make_str(int Nval);
	~make_str();
	vector<string>& main_calc();
private:
	void calc_str(string str, int num, int cnt);
private:
	int Nv = 0;
	string alphabet = "abcdefghijklmnopqrstuvwxyz";
	string inistr = "";
	vector<string> ans;
};

make_str::make_str(int Nval) {
	ans.clear();
	Nv = Nval;
	for (int i = 0; i < Nv; i++) {
		inistr += "a";
	}
}

make_str::~make_str() {
}

void make_str::calc_str(string str, int num, int cnt) {
	string cstr;
	cstr = str;
	int ccnt = cnt + 1;
	if (num == Nv) {
		ans.push_back(str);
		return;
	}
	else {

		// 文字追加なし
		for (int i = 0; i < cnt; i++) {
			cstr = str;
			cstr[num] = alphabet[i];
			calc_str(cstr, num + 1, cnt);
		}

		// 文字追加あり
		cstr = str;
		cstr[num] = alphabet[cnt];
		calc_str(cstr, num + 1, cnt + 1);
	}
}

vector<string>& make_str::main_calc() {

	calc_str(inistr, 1, 1);

	return ans;
}

int main() {

	int N = 0;
	cin >> N;

	make_str ms(N);
	vector<string> ansv = ms.main_calc();

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

	for (int i = 0; i < ansv.size(); i++) {
		cout << ansv[i] << endl;
	}

	return 0;
}


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

using namespace std;

int main(void){
    int N, M;
    cin >> N >> M;

    vector<int> L(M), R(M);
    for(int i=0; i<M; i++)
        cin >> L[i] >> R[i];

    int min = L[0];
    int max = R[0];

    for(int i=1; i<M; i++){
        min = (min<L[i]) ? L[i] : min; 
        max = (R[i]<max) ? R[i] : max;
    }

    if(max - min < -1)
        cout << 0 << endl;
    else
        cout << max - min + 1 << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;



int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x-a) > abs(x-b)) cout << "B" << endl;
  else cout << "A" << endl;
}

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

int main() {
  int n;
  cin >> n;
  ll sum = 0;
  vector<ll> A(n);
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    sum += a;
    A[i] = sum;
  }
  ll min_diff = sum;
  for (int i = 0; i < n; i++) {
    min_diff = min(min_diff, max(A[i], sum - A[i]) - min(A[i], sum - A[i]));
  }

  cout << min_diff << endl;

  return 0;
}

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

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

Measured memory_bytes: 256
def f_b():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    k2 = k**2-((k**2-k)//2)

    o = [0]*n
    for i in range(n):
        a1 = a[:i]
        a2 = a[i+1:]
        a1 = len([j for j in a1 if j < a[i]]) * (k2-k)
        a2 = len([j for j in a2 if j < a[i]]) * (k2)
        o[i] = a1+a2
    print(sum(o)%(10**9+7))

if __name__ == "__main__":
    f_b()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 999999797
#define N 100001

string s, t;
int dp[3001][3001], p[3001][3001];

void build(int i, int j, int mx) {
        if (mx == 0)
                return;
        if (p[i][j] == 1) {
                build(i - 1, j - 1, mx - 1);
                cout << s[i - 1];
        } else {
                if (p[i][j] == 2) {
                        build(i - 1, j, mx);
                } else
                        build(i, j - 1, mx);
        }
        return;
}
int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        cin >> s>> t;
        int l1 = s.size(), l2 = t.size();
        memset(dp, 0, sizeof dp);
        for (int i = 1; i <= l1; i++) {
                for (int j = 1; j <= l2; j++) {
                        if(s[i - 1] == t[j - 1]) {
                                dp[i][j] = max(dp[i - 1][j - 1] + 1, dp[i][j]);
                                p[i][j] = 1;
                        } else {
                                if (dp[i - 1][j] >= dp[i][j - 1]) {
                                        dp[i][j] = dp[i - 1][j];
                                        p[i][j] = 2;
                                } else {
                                        dp[i][j] = dp[i][j - 1];
                                        p[i][j] = 3;
                                }
                        }
                }
        }
        build(l1, l2, dp[l1][l2]);
return 0;
}


Measured memory_bytes: 70784
import math
n = int(input())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
for p in range(1,4):
    s = [math.fabs(x[i]-y[i])**p for i in range(n)]
    z = math.pow(sum(s), 1/p)
    print("{:.6f}".format(z))
t = [math.fabs(x[i]-y[i]) for i in range(n)]
print("{:.6f}".format(max(t)))

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long

const int N=1005;
const int MOD=2019;
 
 
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int l,r;
  cin>>l>>r;
 int a=l%MOD;
 int  b=r%MOD;
 int x=1000000000;
 if(r - l + 1 >= 2019){
		cout << 0 << endl;
		return 0;
	}
 for(int i=a;i<=b;i++)
 	{
 		for(int j=i+1;j<=b;j++)
 		{
            int t=(i*j)%MOD;
            x=min(x,t);
 		}
 	}
 	cout<<x;
}



Measured memory_bytes: 256