akhauriyash/Code-Regression huggingface dataset:
import bisect
n = int(input())

l = list(map(int,input().split()))
l.sort()

res = 0
for i in range(2,n):
    cnt = 0
    for j in range(i):
        p = l[i]-l[j]
        k = bisect.bisect_right(l,p)
        cnt += i-k
        if k <= j:
            cnt -= 1
    res += cnt
print(res//2)

Measured memory_bytes: 44604
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a >= c) {
		if (a >= d) {
			cout << 0 << endl;
			return 0;
		}
		else {
			if (d >= b) {
				cout << b - a << endl;
			}
			else {
				cout << d - a << endl;
			}
		}
	}
	else {
		if (c >= b) {
			cout << 0 << endl;
			return 0;
		}
		else {
			if (b >= d) {
				cout << d - c << endl;
				return 0;
			}
			else {
				cout << b - c << endl;
			}
		}
	}
	return 0;
}

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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            var List = new List<string>();
            while (true)
            {
                string s = Console.ReadLine();
                if (s == "0 0")
                {
                    break;
                }
                List.Add(s);
            }

            var List2 = new List<int>();
            int count = 0;

            for (int m = 0; m < List.Count; m++)
            {
                string[] sArray = List[m].Split(' ');
                int n = int.Parse(sArray[0]);
                int x = int.Parse(sArray[1]);

                for (int i = 1; i <= n; i++)
                {
                    for (int j = i + 1; j <= n; j++)
                    {
                        for (int k = j + 1; k <= n; k++)
                        {
                            if (x == i + j + k)
                            {
                                count++;
                            }
                        }
                    }
                }
                Console.WriteLine(count);
                count = 0;
            }
        }
    }
}


Measured memory_bytes: 16000
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define LL long long
int N;
LL A[200010];

bool judge(LL x){
    for(int s = 0; s < N; s++){//始点
        int lb = s, ub = s + N + 1;
        while(ub - lb > 1){
            int mid = (ub + lb) / 2;
            if(A[mid] >= x + A[s]){
                ub = mid;
            }else{
                lb = mid;
            }
        }
        int t = ub;
        lb = ub;
        ub = s + N + 1;
        while(ub - lb > 1){
            int mid = (ub + lb) / 2;
            if(A[mid] >= x + A[t]){
                ub = mid;
            }else{
                lb = mid;
            }
        }
        if(A[s + N] - A[ub] > x) return true;
    }
    return false;
}

int main(){
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> A[i];
        A[i + N] = A[i];
    }
    for(int i = 1; i <= N * 2; i++){
        A[i] += A[i - 1];
    }
    LL lb = 0;
    LL ub = A[N];
    while(ub - lb > 1){
        LL mid = (ub + lb) / 2;
        if(judge(mid)){
            lb = mid;
        }else{
            ub = mid;
        }
    }
    cout << lb << endl;
    return 0;
}


Measured memory_bytes: 4660
N, K = map(int,input().split())

n = [0 for _ in range(N)]
for i in range(K):
  d = int(input())
  D = list(map(int,input().split()))
  for j in range(d):
    n[D[j]-1] += 1

ans = 0
for i in n:
  if i == 0:
    ans += 1
    
print(ans)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;  
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int min_n = 114514;
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
    int n = 0;
    while(A.at(i) % 2 == 0) {
      A.at(i) /= 2;
      n++;
    }
    min_n = min(n, min_n);
  }
  cout << min_n << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

int main(void) {
    cin >> n;

    cin >> b;
    ll min = b, cnt = 1;

    for (int i = 1; i < n; ++i) {
        cin >> b;
        if (b <= min) {
            ++cnt;
            min = b;
        }
    }

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 256
require 'pp'

def gets; ARGF.gets; end

class Node
  attr_accessor :parent, :size

  def initialize(n)
    @parent = n
    # 自分も含めたグループ全体のサイズ
    # ★ただし、自分がroot以外の場合にのみ正しい値が入っている
    @size = 1
  end
end
class UnionFindTree
  # 0 から n まで（計 n+1個）のNodeを作る
  def initialize(n)
    @nodes = (0..n).to_a.map { |i| Node.new(i) }
  end

  # x要素のルート親を返す
  def find(x)
    return x if @nodes[x].parent == x

    @nodes[x].parent = find(@nodes[x].parent)
  end

  # a,b を同一グループ化する
  def unite(a, b)
    a = find(a)
    b = find(b)
    return if a == b

    if @nodes[a].size < @nodes[b].size
      # a の方を大グループにする
      a, b = b, a
    end
    # b を a にぶら下げる
    @nodes[b].parent = a
    @nodes[a].size += @nodes[b].size
  end

  # a,b が同一グループ？
  def same?(a, b)
    find(a) == find(b)
  end

  # aの所属グループのサイズ（a を含む）
  def size(a)
    @nodes[find(a)].size
  end
end

class Solver

  def main
    n, m, k = gets.chomp.split.map(&:to_i)
    uft = UnionFindTree.new(n)

    fk = Array.new(n) { [0, 0, 0] }

    m.times do |i|
      a, b = gets.chomp.split.map(&:to_i)
      a -= 1
      b -= 1
      uft.unite(a, b)
      fk[a][0] += 1
      fk[b][0] += 1
    end

    k.times do |i|
      a, b = gets.chomp.split.map(&:to_i)
      a -= 1
      b -= 1

      if uft.same?(a, b)
        fk[a][1] += 1
        fk[b][1] += 1
      end
    end

    0.upto(n-1) do |i|
      sz = uft.size(i)
      a = sz - 1 - fk[i][0] - fk[i][1]
      if i == 0
        print "#{a}"
      else
        print " #{a}"
      end
    end
    puts
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 19068
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}

int dx4[4]={1,-1,0,0};
int dy4[4]={0,0,1,-1};

int r,h,w;
int fl[32][32];
char s[32][32];

void rep(int p,int q){
  if(p<0 || h<=p){return;}
  if(q<0 || w<=q){return;}
  if(fl[p][q]==1){return;}
  if(s[p][q]=='#'){return;}
  //printf("<%d %d>\n",p,q);
  int i;
  fl[p][q]=1;
  r++;
  for(i=0;i<4;i++){
    rep(p+dx4[i],q+dy4[i]);
  }
}

int main(){
  int i,j,p,q;
  while(scanf("%d%d",&w,&h),w!=0){
    r=0;
    for(i=0;i<h;i++){
      scanf("%s",s[i]);
      for(j=0;j<w;j++){
        fl[i][j]=0;
        if(s[i][j]=='@'){p=i;q=j;}
      }
    }
    rep(p,q);
    printf("%d\n",r);
  }
  return 0;
}



Measured memory_bytes: 2028
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
    int n, z, w, ans = 0;
    cin >> n >> z >> w;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    if(n == 1)
        ans = abs(a[n - 1] - w);
    else
        ans = max(abs(a[n - 2] - a[n - 1]), abs(a[n - 1] - w));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(s[k-1])


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

int main() {
	int n;
	cin>>n;
	if(n>81 || n==0){
		cout<<"No"<<endl;
		return 0;
	}
	
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j==n){
				cout<<"Yes"<<endl;
				return 0;
			}
			if(i*j>n)
			break;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  cin>>s;
  long long int streak=0;
  long long int longest=0;
  for(long long int i=0; i<s.size(); i++){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
      streak++;
    }else{
      longest=max(longest,streak);
      streak=0;
    }
  }
  longest=max(longest,streak);
  cout<<longest<<endl;
}

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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

ll gcd(ll n,ll m){
    if (n==0)return m;
    return gcd(m%n,n) ;
}

long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (n*temp*temp)%SIZE;
    return (temp*temp)%SIZE;

}

int main() {
   ll n,k ;
   cin >>n>>k;

   string s;
   cin >>s;
   ll same =0;
   ll dif =0;
    for (int i = 0; i < n-1; ++i) {
        if(s[i] == s[i+1] )same++;
        if(s[i] != s[i+1] )dif++;
    }
   // cout << same << " "<< dif << " \n";
    cout << same + min(dif,k * 2);

    return 0;
}



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

int main(){
    int a, b, c, cnt = 0;
    cin >> a >> b >> c;

    for (int i = a; i <= b; i++){
        if(c%i == 0) cnt++;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3096
n,a,b,k=map(int,input().split())
if k==0:
    print(1)
    quit()
mod=998244353
fra=[1]*(n+2)
inv=[1]*(n+2)
t1=1
t2=1
for i in range(1,n+2):
    t1*=i
    t1%=mod
    t2*=pow(i,mod-2,mod)
    t2%=mod
    fra[i]=t1
    inv[i]=t2
def comb(n,r):
    return fra[n]*inv[n-r]*inv[r]%mod
ans=0
for i in range(max(0,-(-(k-b*n)//a)),min(n+1,k//a+1)):
    t=k-i*a
    if t>b*n or t%b!=0:
        continue
    else:
        t//=b
        ans+=(comb(n,i)*comb(n,t))%mod
        ans%=mod
print(ans)

Measured memory_bytes: 26680
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()
    t = input()

    s = sorted(s)
    t = sorted(t)

    for i in s:
        for j in t:
            if ord(i)< ord(j):
                print('Yes')
                return


    if len(s)<len(t):
        ok = 1
        for i in s:
            if i not in t:
                ok = 0
        if ok:
            print('Yes')
            return


    print('No')

solve()


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

char ans(char c) {
  if(c == 'A') return 'T';
  if(c == 'T') return 'A';
  if(c == 'C') return 'G';
  if(c == 'G') return 'C';
}

int main () {
  char c;
  cin >> c;
  cout << ans(c) << endl;

  return 0;
}


Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	q := getNextInt(scanner)

	nodes := make([]*Node, n)
	for i := 0; i < n; i++ {
		nodes[i] = &Node{
			p: i,
		}
	}

	for i := 0; i < q; i++ {
		com := getNextInt(scanner)
		x := getNextInt(scanner)
		y := getNextInt(scanner)

		rx := getRoot(nodes, x)
		ry := getRoot(nodes, y)
		if com == 0 {
			if rx < ry {
				nodes[ry].p = rx
				continue
			}
			nodes[rx].p = ry
			continue
		}
		if rx == ry {
			fmt.Fprintln(writer, 1)
			continue
		}
		fmt.Fprintln(writer, 0)
	}

	writer.Flush()
}

// Node ...
type Node struct {
	p int
}

func getRoot(nodes []*Node, i int) int {
	if i == nodes[i].p {
		return i
	}
	nodes[i].p = getRoot(nodes, nodes[i].p)
	return nodes[i].p
}



Measured memory_bytes: 2968
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}



void solve(long long N, long long A, long long B, long long C, long long D, long long E){
    long long geko = min({A,B,C,D,E});
    cout << (N+geko-1LL) / geko + 4 << endl;
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    long long E;
    scanf("%lld",&E);
    solve(N, A, B, C, D, E);
    return 0;
}


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

using namespace std;

int main() {
    vector<int> l;
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int t; cin >> t;
        l.push_back(t);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            for (int k = 0; k < j; k++) {
                if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]) {
                    if (l[i] == l[j] || l[j] == l[k] || l[i] == l[k]) {
                        continue;
                    }
                    ans++;
                }
            }
        }
    }

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

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    double r;
    cin >> r;
    cout << fixed << setprecision(10) << 2.0 * r * M_PI << endl;
}


Measured memory_bytes: 3752
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

const int nmax = 5000;

string s;

vector<string> sol;
map<string, bool> m;

bool cmp(string a,string b) {
    int i = 0;
    while(i < a.size() && i < b.size() && a[i] == b[i])
        i ++;
    if(i >= a.size())
        return 1;
    if(i >= b.size())
        return 0;
    return a[i] < b[i];
}

int main() {
    cin >> s;
    int k;
    cin >> k;
    for(int len = 1;len <= k;len ++) {
        for(int i = len - 1;i < s.size();i ++) {
            string aux;
            aux.resize(len);
            for(int j = i-len+1; j <= i;j ++)
                aux[j-(i-len+1)] = s[j];
            if(m[aux] ==  0) {
                m[aux] = 1;
                sol.push_back(aux);
            }

        }

    }
    sort(sol.begin(),sol.end(), cmp);
    cout << sol[k-1];
    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()
/* --- */
const int N = 510;
int n, c[N], s[N], f[N];

int calc (int x, int t) {
	if (x == n - 1) return t;
	if (t <= s[x]) return calc(x + 1, s[x] + c[x]);
	int k = (t - 1) / f[x] + 1;
	return calc(x + 1, k * f[x] + c[x]); 
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n - 1; i++) scanf("%d%d%d", &c[i], &s[i], &f[i]);
	for (int i = 0; i < n; i++) printf("%d\n", calc(i, 0));
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int mod = 1000000007;

int main(){
    int a,b;
    cin>>a>>b;
    if(a>=13) ;
    else if(a>=6) b /=2;
    else b=0;
    cout<<b<<endl;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n, m = LI()
L = LI()
for i in range(n):
    L[i] *= -1


heapify(L)
for i in range(m):
    p = heappop(L)
    heappush(L, -(-p//2))



print(-sum(L))

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()



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

    vector< vector<char> > yx(H,vector<char>(W));
    for(int y=0;y<H;y++){
        for(int x=0;x<W;x++){
            cin >> yx[y][x];
        }
    }

    vector< vector<int> > column(H,vector<int>(W,0));
    vector< vector<int> > row(H,vector<int>(W,0));

    int y=0;
    int x=0;
    int score = 0;

    for(int y=0;y<H;y++){
        int score = 0;
        for(int x=0;x<W;x++){
            if(yx[y][x]=='#'){
                score=0;
            }else score++;
            column[y][x]=max(score,column[y][x]);
        }
        int x = W-1;
        score = 0;
        while(x>=0){
            score = max(score,column[y][x]);
            if(column[y][x]==0){
                score = 0;
                x--;
                continue;
            }
            column[y][x]=score;
            x--;
        }

    }

    for(int x=0;x<W;x++){
        int score = 0;
        for(int y=0;y<H;y++){
            if(yx[y][x]=='#')score=0;
            else score++;
            row[y][x]=max(score,row[y][x]);
        }

        int y = H-1;
        score = 0;
        while(y>=0){
            score = max(score,row[y][x]);
            if(row[y][x]==0){
                score = 0;
                y--;
                continue;
            }
            row[y][x]=score;
            y--;
        }
    }

    int ans = 0;
    for(int y=0;y<H;y++){
         for(int x=0;x<W;x++){
            ans = max(ans,column[y][x]+row[y][x]-1);
         }
    }
    
    cout << ans << endl;
   
    

}



Measured memory_bytes: 35584
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;
const double PI = 3.14159265358979323846;
//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

ll N;
  cin>>N;
  vector<ll> vec(N+2);
 for(int i=1;i<N+2;i++){
   for(int j=0;j<N+2;j=j+i){
     vec[j]++;
   }
 }
  ll sum=0;
    for(int i=0;i<N;i++){
sum+=vec[i+1]*(i+1);
     // cout<<vec[i]<<" "<<sum<<endl;
    }
  cout<<sum<<endl;
}



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

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int a[][] = new int[2][n];
            for (int i = 0; i < n; i++) {
                a[0][i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < n; i++) {
                a[1][i] = Integer.parseInt(in.next());
            }
            int ans = 0;
            int sum = 0;
            int ptrx = n - 1;
            int ptry = -1;

            for (int i = 0; i < 2; ) {
                sum = 0;
                for (int j = i; j <= ptrx; j++) {
                    sum += a[0][j];
                }
                if (ptrx >= 0) {
                    for (int j = ptrx; j < n; j++) {
                        sum += a[1][j];
                    }
                }
                ans = Math.max(ans, sum);
                ptrx--;
                if (ptrx < 0) {
                    i++;
                    ptrx = n - 1;
                }
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21972
function Main(input) {
  input = input.split("\n");
  tmp1 = input[0].split(" ");
  var n = parseInt(tmp1[0]);
  var a = parseInt(tmp1[1]);
  tmp= input[1].split(" ");
  x=new Array(n);
  var sum2=0;
  for(i=0;i<tmp.length;i++){
    x[i]=parseInt(tmp[i]);
  }
  var s=0;
  for(i=0;i<n;i++){
    sum2=sum2+x[i];
  }
  var b = new Array(sum2+1);
  for(var y = 0; y < sum2+1; y++) {
    b[y] = new Array(n+1).fill(0);
  }
  b[0][0]=1;
  for(j=0;j<n;j++){
    for(i=sum2;i>=0;i--){
      for(k=0;k<n+1;k++){
        if(b[i][k]>=1){
          b[i+x[j]][k+1]=b[i+x[j]][k+1]+b[i][k];
        }
      }
    }
  }
  for(i=1;i<=n && i*a<=sum2;i++){
      s=s+b[i*a][i];
  }


  console.log('%s', s);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include<cstdio>
#include<algorithm>
using namespace std;
int a[10005];
int main()
{
	int n; scanf("%d",&n);
	for (int i=1; i<=n; i++) scanf("%d",&a[i]);
	int s=1,ans=0;  
	for (int i=2; i<=n; i++)
		if (a[i]==a[i-1]) s++;
		else ans+=s/2,s=1;
	printf("%d\n",ans+s/2);
	return 0;
}

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

using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	int sum=0;
	int len=a.length();
	for(int i=0;i<len;i++)
	{
		//cout<<a[i]<<" "<<b[i]<<endl;
		if(a[i]!=b[i])
		{
			//cout<<a[i]<<" "<<b[i]<<endl;
			sum++;
		}
	}
	cout<<sum;
}

Measured memory_bytes: 3916
#include<iostream>
#include<cstring>
using namespace std;
char b[115];
int main()
{
	int l=0;
	cin>>b;int len=strlen(b);
	for(int i=0;i<len;i++)
	{
		char a=b[i];
		if(a=='C'&&l==0) l=1;
		if(l==1&&a=='F') l=2;
	}
	if(l==2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

vector<long long> dijkstra(const vector<vector<pair<int, long long>>> &G, int s){
    struct RadixHeap {
        inline int bsr(long long x){ return (x == 0) ? -1 : 63-__builtin_clz(x); }
        vector<pair<long long, int>> v[65];
        long long last, sz;
        RadixHeap() : last(0), sz(0) { }
        inline bool empty () { return (sz == 0); }
        inline void push(long long x, int u) { sz++; v[bsr(x^last)+1].emplace_back(x, u); }
        inline pair<long long, int> pop () {
            if (!v[0].size()) {
                int i = 1;
                while (!v[i].size()) { i++; }
                last = min_element(v[i].begin(), v[i].end())->first;
                for (auto x : v[i]) { v[bsr(x.first^last)+1].emplace_back(x); }
                v[i].clear();
            }
            pair<long long, int> res = v[0].back();
            sz--;
            v[0].pop_back();
            return res;
        }
    };
    constexpr long long inf = INT64_MAX;
    vector<long long> ret(G.size(), inf); ret[s] = 0;
    RadixHeap rh; rh.push(ret[s], s);
    while (!rh.empty()) {
        long long dist; int node;
        tie(dist, node) = rh.pop();
        if (ret[node] < dist) continue;
        for (auto &e : G[node]) {
            int next_node; long long next_dist;
            tie(next_node, next_dist) = e;
            if (ret[next_node] > ret[node] + next_dist){
                ret[next_node] = ret[node] + next_dist;
                rh.push(ret[next_node], next_node);
            }
        }
    }
    return ret;
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    vector<vector<pair<int, long long>>> g1(n), g2(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        long long c1, c2;
        cin >> a >> b >> c1 >> c2;
        a--; b--;
        g1[a].emplace_back(b, c1);
        g1[b].emplace_back(a, c1);
        g2[a].emplace_back(b, c2);
        g2[b].emplace_back(a, c2);
    }
    
    vector<long long> d1 = dijkstra(g1, s); // yen
    vector<long long> d2 = dijkstra(g2, t); // snuuk
    vector<long long> d(n);
    for (int i = 0; i < n; i++) d[i] = d1[i] + d2[i];
    for (int i = n-1; i > 0; i--) d[i-1] = min(d[i-1], d[i]);
    
    for (auto& ans : d) cout << MAX - ans << '\n';
    return 0;
}

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

int main(){
  int K,S;
  cin >> K >> S;
  
  int X,Y,Z;
  int c=0;
  for(X=0;X<=K;++X){
    for(Y=0;Y<=K;++Y){
      Z = S-X-Y;
      if(Z<=K && Z>=0)
        c++;
    }
  }
  
  cout << c << endl;
}


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

template <typename T>
struct cumulative_sum_2d {
    int h, w;
    vector<vector<T> > acc;
    bool frozen;
    cumulative_sum_2d(int h_, int w_) :
            h(h_),
            w(w_),
            acc(h + 1, vector<T>(w + 1)),
            frozen(false) {
    }
    void add(int y, int x, T value) {
        assert (not frozen);
        assert (0 <= y and y < h);
        assert (0 <= x and x < w);
        acc[y + 1][x + 1] += value;
    }
    void freeze() {
        assert (not frozen);
        frozen = true;
        REP (y, h) {
            REP (x, w) {
                acc[y + 1][x + 1] += acc[y + 1][x];
                acc[y + 1][x] += acc[y][x];  // in the same loop for speed
            }
            acc[y + 1][w] += acc[y][w];
        }
    }
    T get(int ly, int lx, int ry, int rx) const {  // [l, r)
        assert (frozen);
        assert (0 <= ly and ly <= ry and ry <= h);
        assert (0 <= lx and lx <= rx and rx <= w);
        return acc[ry][rx] - acc[ry][lx] - acc[ly][rx] + acc[ly][lx];
    }
};

vector<int> solve(int N, int M, int Q, vector<int> const & l, vector<int> const & r, vector<int> const & p, vector<int> const & q)  {
    cumulative_sum_2d<int> acc(N + 3, N + 3);
    REP (j, M) {
        acc.add(l[j], r[j], 1);
    }
    acc.freeze();
    vector<int> answer(Q);
    REP (k, Q) {
        answer[k] = acc.get(p[k], p[k], q[k] + 1, q[k] + 1);
    }
    return answer;
}

int main() {
    int N, M, Q; cin >> N >> M >> Q;
    vector<int> l(M), r(M);
    REP (j, M) {
        cin >> l[j] >> r[j];
    }
    vector<int> p(Q), q(Q);
    REP (k, Q) {
        cin >> p[k] >> q[k];
    }
    auto answer = solve(N, M, Q, l, r, p, q);
    for (int x : answer) {
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 3968
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] num = new int[n];
		String[] str = (br.readLine()).split(" ");
		for (int i = 0; i<n ; i++ ) {
			num[i] = Integer.parseInt(str[i]);
		}
		int count = 0;
		for (int i = 0 ; i<num.length ; i++  ) {
			int mini = i;
			for (int j = i; j<num.length ; j++ ) {
				if ( num[j] < num[mini]) {
					mini = j;
				}
			}
			if (i != mini) {
				int work = num[i];
				num[i] = num[mini];
				num[mini] = work;
				count++;
			}
		}
		for (int i = 0; i<num.length ; i++ ) {
			if ( i == num.length-1) {
				System.out.println(num[i]);
			}else{
				System.out.print(num[i] + " ");
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 24388
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>
#include <array>
#include <string>
#include <map>
using namespace std;

#define DB(x)

/*
int getIntSp(){
    string str;
    getline(cin,str,' ');
    return stoi(str);
}

int getIntLF(){
    string str;
    getline(cin,str);
    return stoi(str);
}
 */


int main() {
    int A,B,C;
    cin >> A >> B >> C;
    if( 22 <= A+B+C ){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <climits>
#include <vector>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

#define MOD 1000000007

long long add_mod(long long x,long long y){
	return (x+y)%MOD;
}

long long sub_mod(long long x,long long y){
	return (x-y+MOD)%MOD;
}

long long mul_mod(long long x,long long y){
	return x*y%MOD;
}

long long inv_mod(long long x){
	if(x == 1) return 1;
	long long d = MOD/x+1;
	return d*inv_mod(x-(MOD%x))%MOD;
}

long long div_mod(long long x, long long y){
	return x*inv_mod(y)%MOD;
}

long long conv_mod(long long n,long long r){
	vector<long long> kaijyo(n+1);
	kaijyo[0] = 1;
	kaijyo[1] = 1;
	for(int i = 2;i <= n;i++){
		kaijyo[i] = i*kaijyo[i-1]%MOD;
	}
	return div_mod(div_mod(kaijyo[n],kaijyo[n-r]),kaijyo[r]);
}

long long dp[301][301][301];
bool able[301][301][301];
int main(){
  int i,j;
  int n,m;
  cin >> n >> m;
  vector<int> l(m),r(m),x(m);
  for(int i = 0;i < m;i++){
    cin >> l[i] >> r[i] >> x[i];
  }
  memset(dp,0,sizeof(dp));
	for(int i = 0;i <= n;i++) for(int j = 0;j <= n;j++) for(int k = 0;k <= n;k++) able[i][j][k] = true;
	for(int i = 0;i < m;i++){
		switch(x[i]){
			case 1:
			for(int j = l[i];j < r[i];j++){
				for(int k = 0;k < j;k++){
					able[r[i]][j][k] = false;
					able[j][r[i]][k] = false;
					able[j][k][r[i]] = false;
					able[r[i]][k][j] = false;
					able[k][r[i]][j] = false;
					able[k][j][r[i]] = false;
				}
			}
			break;
			case 2:
			for(int j = 0;j < l[i];j++){
				for(int k = 0;k < l[i];k++){
					able[r[i]][j][k] = false;
					able[j][r[i]][k] = false;
					able[j][k][r[i]] = false;
				}
			}
			for(int j = l[i];j < r[i];j++){
				for(int k = l[i];k < r[i];k++){
					able[r[i]][j][k] = false;
					able[j][r[i]][k] = false;
					able[j][k][r[i]] = false;
				}
			}
			break;
			case 3:
			for(int j = 0;j < l[i];j++){
				for(int k = j;k < r[i];k++){
					able[r[i]][j][k] = false;
					able[j][r[i]][k] = false;
					able[j][k][r[i]] = false;
					able[r[i]][k][j] = false;
					able[k][r[i]][j] = false;
					able[k][j][r[i]] = false;
				}
			}
			break;
		}
	}
  if(able[0][0][1]) dp[0][0][1] = 1;
  if(able[0][1][0]) dp[0][1][0] = 1;
  if(able[1][0][0]) dp[1][0][0] = 1;
	for(int i = 1;i < n;i++){
		for(int j = 0;j < i;j++){
			for(int k = 0;k < i;k++){
				if(able[i+1][j][k]) dp[i+1][j][k] = add_mod(dp[i+1][j][k],dp[i][j][k]);
				if(able[i][i+1][k]) dp[i][i+1][k] = add_mod(dp[i][i+1][k],dp[i][j][k]);
				if(able[i][j][i+1]) dp[i][j][i+1] = add_mod(dp[i][j][i+1],dp[i][j][k]);
				if(able[i+1][i][k]) dp[i+1][i][k] = add_mod(dp[i+1][i][k],dp[j][i][k]);
				if(able[j][i+1][k]) dp[j][i+1][k] = add_mod(dp[j][i+1][k],dp[j][i][k]);
				if(able[j][i][i+1]) dp[j][i][i+1] = add_mod(dp[j][i][i+1],dp[j][i][k]);
				if(able[i+1][k][i]) dp[i+1][k][i] = add_mod(dp[i+1][k][i],dp[j][k][i]);
				if(able[j][i+1][i]) dp[j][i+1][i] = add_mod(dp[j][i+1][i],dp[j][k][i]);
				if(able[j][k][i+1]) dp[j][k][i+1] = add_mod(dp[j][k][i+1],dp[j][k][i]);
			}
		}
	}
  long long ans = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			ans = add_mod(ans,dp[n][i][j]+dp[i][j][n]+dp[i][n][j]);
		}
	}
  cout << ans << endl;
}


Measured memory_bytes: 240000
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#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;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  long long n; cin >> n;
  long long ans = n - 1;
  for (long long i = 2; i * i <= n; ++i) {
    if (n % i == 0) ans = min(ans, i + n / i - 2);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
n = int(input())
mp = list(map(int,input().split()))

#Ai + i 
#j-Aj
ans = 0
cnt = [0]*(n+1)
for i in range(n-1):
    j=i+1
    a = mp[i]+i
    if(a<=n):
        cnt[a] += 1 
    b = j-mp[j]
    if(b<0):
        continue
    ans += cnt[b]
    

print(ans)

Measured memory_bytes: 32376
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

bool comp_a(const string &a, const string &b){
  string tmp_a = a;
  string tmp_b = b;
  replace(tmp_a.begin(), tmp_a.end(), '?', 'a');
  replace(tmp_b.begin(), tmp_b.end(), '?', 'a');
  return tmp_a < tmp_b;
}

bool comp_z(const string &a, const string &b){
  string tmp_a = a;
  string tmp_b = b;
  replace(tmp_a.begin(), tmp_a.end(), '?', 'z');
  replace(tmp_b.begin(), tmp_b.end(), '?', 'z');
  return tmp_a < tmp_b;
}

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<string> vec;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    vec.pb(s);
  }
  string t;
  cin >> t;
  sort(vec.begin(), vec.end(), comp_a);
  int start_a = lower_bound(vec.begin(), vec.end(), t, comp_a) - vec.begin();
  int end_a = upper_bound(vec.begin(), vec.end(), t, comp_a) - vec.begin();
  sort(vec.begin(), vec.end(), comp_z);
  int start_z = lower_bound(vec.begin(), vec.end(), t, comp_z) - vec.begin();
  int end_z = upper_bound(vec.begin(), vec.end(), t, comp_z) - vec.begin();

  for(int i = start_z; i <= end_a; i++){
    cout << i + 1;
    if(i != end_a)cout << " ";
  }
  cout << endl;
	return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;




int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    reverse(all(s));
    ll dp[100010][20],n=s.size(),M[100010];
    M[0]=1;
    rep2(i,1,n){
        M[i]=M[i-1]*10%13;
    }
    rep(i,100009)rep(j,20) dp[i][j]=0;
    if(s[0]=='?'){
        rep(i,10) dp[0][i]=1;
    } else{
        dp[0][s[0]-'0']=1;
    }
    rep2(i,1,n){
        if(s[i]=='?'){
            rep(j,10){
                rep(k,13){
                    dp[i][(k+j*M[i])%13]+=dp[i-1][k];
                    dp[i][(k+j*M[i])%13]%=MOD;
                }
            }
        } else{
            rep(k,13){
                dp[i][(k+(s[i]-'0')*M[i])%13]+=dp[i-1][k];
                dp[i][(k+(s[i]-'0')*M[i])%13]%=MOD;
            }
        }
    }
    cout<<dp[n-1][5]<<endl;
    return 0;
}

Measured memory_bytes: 16896
#2
# -*- coding: utf-8 -*-
import sys
from math import *
if __name__ =="__main__":
    str_in = input()
    num = [int(n) for n in str_in.split()]
    N,A,B=num
    SUM=0
    if N<0 or N>(10**4) or A<0 or B<0 or A>36 or B>36 or A>B:
        print("error input!")
    else:
        for i in range(1,(N+1)):
            #print(i)
            ii0 = int((i / 1) % 10 )
            ii1 = int((i / 10) % 10)
            ii2 = int((i / 100) % 10)
            ii3 = int((i / 1000) % 10)
            ii4 = int((i / 10000) % 10)
            #print(ii4,ii3,ii2,ii1,ii0)
            SUMi=ii4+ii3+ii2+ii1+ii0
            if(SUMi>=A and SUMi<=B):
                SUM+=i
        print(SUM)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}

int main(void){
    ll n,m,i,answa=0,ansac=0;
    scanf("%lld%lld",&n,&m);
    ll ac[n],a,wa[n];
    char s[3];
    for(i=0;i<n;i++){
        ac[i]=0;
        wa[i]=0;
    }
    for(i=0;i<m;i++){
        scanf("%lld%s",&a,s);
        if(ac[a-1]==1) continue;
        if(ac[a-1]==0){
            if(s[0]=='W') wa[a-1]++;
            if(s[0]=='A'){
                ac[a-1]=1;
                ansac++;
            }
        }
    }
    for(i=0;i<n;i++){
        if(ac[i]==1) answa+=wa[i];
    }
    printf("%lld %lld\n",ansac,answa);
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
char s[505][505];
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
			if (((i&1)&&(j!=m))||s[i][j]=='#'||j==1) putchar('#');
			else putchar('.');
		puts("");
	}
	puts("");
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
			if ((!(i&1)&&(j!=1))||s[i][j]=='#'||j==m) putchar('#');
			else putchar('.');
		puts("");
	}
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define ins insert
#define sb substr
#define con continue
#define ub upper_bound
#define lb lower_bound
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define pll pair<ll,ll>
#define pld pair<ld,ld>
using namespace std;

ll power(ll x, ll y);
ll mpower(ll x, ll y, ll p);
ll modInv(ll a, ll m);
ll gcdExtended(ll a, ll b, ll *x, ll *y);
bool isPrime(ll n);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,i,j,k,l,h,p,q,r,x,y,z,a,b,c,d,f,n,m,M=1000000007;
    char ch,ch2,ch3;
    string s,s1,s2,s3;
    vector<ll> v,w;
    vector<ll> :: iterator itrv;
    unordered_map<ll,ll> N;
    set<ll> S;
    set<ll> :: iterator itr;
    cin>>n>>k;
    ll A[n],B[n];
    for(i=0;i<n;i++){
        cin>>A[i];
    }
    for(i=1;i<n;i++){
        if(A[i]<A[i-1]){
            B[i-1]=1;
        }
        else{
            B[i-1]=0;
        }
    }
    for(i=1;i<n;i++){
        B[i]+=B[i-1];
    }
    x=1;
    for(i=0;i<k;i++){
        S.ins(A[i]);
    }
    f=0;
    for(i=k;i<n;i++){
        p=*S.begin();
        S.erase(A[i-k]);
        q=*S.rbegin();
        S.ins(A[i]);
        if(A[i]<q){
            x++;
            con;
        }
        if(A[i-k]==p){
            con;
        }
        if((B[i-1]-B[i-k])!=0){
            x++;
        }
    }
    for(i=k;i<n;i++){
        if(B[i-1]-B[i-k]==0){
            f=1;
            break;
        }
    }
    if(f){
        f=0;
        for(i=1;i<k;i++){
            if(A[i]<A[i-1]){
                f=1;
                break;
            }
        }
        if(f){
            x++;
        }
    }
    cout<<x;
    return 0;
}

ll modInv(ll a, ll m){
    ll x, y;
    ll g = gcdExtended(a, m, &x, &y);
    ll res = (x%m + m) % m;
    return res;
}

ll gcdExtended(ll a, ll b, ll *x, ll *y){
    if (a == 0){
        *x = 0, *y = 1;
        return b;
    }
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}

ll mpower(ll x, ll y, ll p){
    ll res = 1;
    x = x % p;
    while(y > 0){
        if(y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

ll power(ll x, ll y){
    ll res = 1;
    while (y > 0){
        if (y & 1) res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}

bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    ll p=sqrt(n);
    for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;
    return true;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX
#define LINF LLONG_MAX
#define mod 1000000007
#define pie 3.141592653589793238462643383279
#define P pair<int,int>
#define prique priority_queue
#define F first
#define S second
using namespace std;
signed main(){
	string s;
	cin>>s;
	cout<<s.substr(0,s.size()-8)<<endl;
	return 0;
}



Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

sumPair = do
  x <- readLn :: IO Integer
  y <- readLn :: IO Integer
  let s = show $ x + y
  if length s <=  80
    then putStrLn s
    else putStrLn "overflow"

main = do
  n <- readLn
  replicateM n sumPair

Measured memory_bytes: 4176
def r(a):
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append([l,a[i]])
            l=1
    ll.append([l,a[-1]])
    return ll
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
a.sort()
a=r(a)
b=0
for i in range(len(a)):
    if a[i][0]%2==1:
        b+=1
print(b)

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

using namespace std;

using ll = long long;

int main(){

    string s, t;
    cin >> s;
    cin.ignore();
    cin >> t;
    cin.ignore();

    int cnt = INT_MAX;
    for(int i = 0; i < s.size() - t.size() + 1; i++){
        string ss = s.substr(i, t.size());
        int tcnt = 0;
        //cout << ss << endl;
        for(int j = 0; j < t.size(); j++){
            if(ss[j] != t[j]) ++tcnt;
        }
        if(cnt > tcnt) cnt = tcnt;
        if(tcnt == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << cnt << endl;
    return 0;

}

Measured memory_bytes: 3632