akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = -10000;

int main(){
  int N;
  cin >> N;
  string str;
  cin >> str;
  //累積和
  vector<int> a(N,0);
  for(int i = 0;i<N;i++){
    if(str[0] =='E') a[0] = 1;
    if(str[i+1] == 'E') a[i+1] = a[i] + 1;
    else a[i+1] = a[i];
  }

  
  vector<int> b(N,0);
  for(int i = 0;i<N;i++){
    if(str[0] =='W') b[0] = 1;
    if(str[i+1] == 'W') b[i+1] = b[i] + 1;
    else b[i+1] = b[i];
  }

  vector<int> ans(N);
  
  for(int i = 0;i<N;i++){
    if(i == 0){
    ans[0] = a[N-1] - a[0];
    }
    else{  
    ans[i] = b[i-1] + a[N-1]-a[i];
    }
  }
  sort(ans.begin(),ans.end());
  cout << ans[0] << endl;
}

Measured memory_bytes: 4228
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79696
import sys
input=sys.stdin.readline
n=int(input())
m=[]
for i in range(n):
    x,l=map(int,input().split())
    m.append((x+l,x-l))
m.sort()
ans=1
limit=m[0][0]
for i in range(1,n):
    if m[i][1]<limit:
        continue
    ans+=1
    limit=m[i][0]
print(ans)


Measured memory_bytes: 48604
def slove():
    import sys
    input = sys.stdin.readline
    a, b, k = list(map(int, input().rstrip('\n').split()))
    ans = []
    for i in range(a, min(a + k, b + 1)):
        ans.append(i)
    for i in range(max(b - k + 1, a), b + 1):
        if i not in ans:
            ans.append(i)
    ans.sort()
    print(*ans, sep="\n")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
import java.io.BufferedReader;
    import java.io.InputStreamReader;

    public class Main {
        public static void main(String[] args)throws Exception {
            BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
            String word = input.readLine();
            System.out.println(word.charAt(0) + String.valueOf(word.length() - 2) + word.charAt(word.length() - 1));
        }
    }


Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

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

  string S;
  cin >> S;
  string T = {};
  for(int i=0;i<S.size();i++){
    T += 'x';
  }
  cout << T << endl;
}

Measured memory_bytes: 256
from collections import Counter
input()
d = Counter(map(int, input().split()))
now = sum(k * v for k, v in d.items())
for _ in range(int(input())):
    b, c = map(int, input().split())
    cnt = d[b]
    d[b] = 0
    d[c] += cnt
    now += (c - b) * cnt
    print(now)


Measured memory_bytes: 22224
S = input()

ans = [0]*(len(S))
cnt = 0
for i in range(len(S)-1):
    cnt += 1
    if S[i] == "R" and S[i+1] =="L":
        ans[i] += -(-cnt//2)
        ans[i+1] += cnt//2
        x = i
        cnt = 0
    if S[i] == "L" and S[i+1] =="R":
        ans[x] += cnt//2
        ans[x+1] += -(-cnt//2)
        cnt = 0
    if i == len(S)-2:
        cnt += 1
        ans[x] += cnt//2
        ans[x+1] += -(-cnt//2)    

print(*ans)

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

int main(){
    int n;
    cin>>n;
    int count=0;
    vector<int>a(n+1);
    for(int i=1;i<n+1;i++)cin>>a[i];
    for(int i=1;i<n+1;i++){
        if(i%2==1){
            if(a[i]%2==1){
                count++;
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int N;
    cin >> N;
    vector<string> s(N);
    vector<int> t(N);
    REP(i,N){
        cin >> s[i] >> t[i];
    }
    string X;
    cin >> X;
    bool ok = 0;
    int answer = 0;
    REP(i,N){
        if(ok)answer += t[i];
        if(s[i] == X)ok = 1;
    }
    cout <<answer<< "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mz 998244353
#define pq priority_queue
using namespace std;

char s[6];
char ans[100005];
int n,x[100005],y[100005];
int dp[100005][7][7][7];

int dfs(int i,int a0,int a1,int a2)
{
    int a[3];
    if(i>n)
        return 1;
    a[0]=a0;
    a[1]=a1;
    a[2]=a2;
    if(dp[i][a0][a1][a2])
        return -1;
    if(a[x[i]]==0 && a[y[i]]==0)
        return dp[i][a0][a1][a2]=-1;
    a[0]=a0;
    a[1]=a1;
    a[2]=a2;
    if(a[y[i]]!=0)
    {
        a[y[i]]--;
        a[x[i]]++;
        if(dfs(i+1,a[0],a[1],a[2])==1)
        {
            ans[i]=x[i]+'A';
            return 1;
        }
    }
    a[0]=a0;
    a[1]=a1;
    a[2]=a2;
    if(a[x[i]]!=0)
    {
        a[x[i]]--;
        a[y[i]]++;
        if(dfs(i+1,a[0],a[1],a[2])==1)
        {
            ans[i]=y[i]+'A';
            return 1;
        }
    }
    return dp[i][a0][a1][a2]=-1;
}

int main()
{
    int a,b,c;
    scanf("%d%d%d%d",&n,&a,&b,&c);
    a=min(2,a);
    b=min(2,b);
    c=min(2,c);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s);
        x[i]=s[0]-'A';
        y[i]=s[1]-'A';
    }
    if(dfs(1,a,b,c)==-1)
        printf("No\n");
    else
    {
        printf("Yes\n");
        for(int i=1;i<=n;i++)
            printf("%c\n",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 88752
#include <iostream>
#include <vector>
#include <string>
#include <cstring>

using namespace std;

bool wall[16*16];
int mv[] = {0, 1, -1, 16, -16};

int compress(int pa, int pb, int pc){
	return (pa)|(pb<<8)|(pc<<16);
}

int solve(int start, int goal){
	static bool visit[16*16*16*16*16*16];
	memset(visit, false, sizeof(visit));
	visit[start] = true;
	vector<int> state[2]; state[0].push_back(start);
	for(int res=1; ;res++){
		int cur = 1-res%2, next = res%2;
		state[next].clear();
		for(int i=0;i<state[cur].size();i++){
			int pa = state[cur][i]%256, pb = (state[cur][i]>>8)%256, pc = (state[cur][i]>>16);
			for(int a=0;a<5;a++){
				int npa = pa + mv[a];
				if(wall[npa]) continue;
				for(int b=0;b<(pb?5:1);b++){
					int npb = pb + mv[b];
					if(npb!=0){
						if(wall[npb]) continue;
						if(npa==npb) continue;
						if(npb==pa&&npa==pb) continue;
					}
					for(int c=0;c<(pc?5:1);c++){
						int npc = pc + mv[c];
						if(npc!=0){
							if(wall[npc]) continue;
							if(npc==npa||npc==npb) continue;
							if(npc==pa&&npa==pc) continue;
							if(npc==pb&&npb==pc) continue;
						}
						int ns = (npa)|(npb<<8)|(npc<<16);
						if(visit[ns]) continue;
						if(ns==goal) return res;
						visit[ns] = true;
						state[next].push_back(ns);						
					}
				}
			}
		}
	}
	return -1;
}

int main(){
	int w, h, n;
	string mp[16];
	while(cin >> w >> h >> n, w){
		getline(cin, mp[0]);
		for(int i=0;i<h;i++) getline(cin, mp[i]);
		memset(wall, false, sizeof(wall));
		int start = 0, goal = 0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(mp[i][j]=='#') wall[16*i+j] = true;
				if(islower(mp[i][j])) start |= (16*i+j) << (8*(mp[i][j]-'a'));
				if(isupper(mp[i][j])) goal  |= (16*i+j) << (8*(mp[i][j]-'A'));
			}
		}
		printf("%d\n", solve(start, goal));
	}
}

Measured memory_bytes: 18000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String x = scan.next();
		String y = scan.next();
		char xC = x.charAt(0);
		char xY = y.charAt(0);
		if(xC<xY) {
			System.out.println("<");
		}else if(xC>xY) {
			System.out.println(">");
		}else {
			System.out.println("=");
		}
	}

}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>



void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}

int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }

  if(b==0){
    return a;
  }

  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }

  return b;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}


long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

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

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  /*
  解法1

  all:=A[1]+...+A[n]とすると
  与式を変形すると

  (答え)=(((all-A[i])*A[i])の総和)/2
  ということがわかるので，それを実装

  「2で割る」というのは「2の逆元を掛ける」ということに言い換えられるから
  mod上での逆元を求める関数(53行目，modinv)を書いて，それを最後に掛ければよい
  */

  long int n;
  scanf("%ld",&n);

  long int A[n];
  long int all=0;

  long int MOD=1e9+7;

  for(int i=0;i<n;i++){
    scanf("%ld",&A[i]);
    all+=A[i];
    all%=MOD;
  }

  long int ans=0;
  for(int i=0;i<n;i++){
    ans+=(all-A[i]+MOD)*A[i];
    ans%=MOD;
  }


  long int v=modinv(2,MOD);

  printf("%ld\n",ans*v%MOD);

  return 0;
}

Measured memory_bytes: 3272
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <algorithm>
#include <functional>
#include <utility>
#include <tuple>
#include <ctime>
#include <cmath>
#include <fstream>
#include <sstream>
using namespace std;
#define INF 1000000007
#define PB push_back
#define MP make_pair
#define X first
#define Y second

typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef queue<int> QI;
typedef queue<PII> QII;
typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef set<int> SI;
typedef set<PII> SII;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(0);
	int N;
	VI V;
	cin >> N;
	for(int i=0;i<N;i++)
	{
		int k; cin >> k; V.PB(k);
	}
	sort(V.begin(),V.end());
	cout << V[V.size()-1]-V[0] << endl;
return 0;
}


Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

as = inputs[1]

# body
if $debugFlag
  p as
end

lst = []

def calc(a)
  res = 0
  while a[0] != 1
    res += 1
    a /= 2
  end
  return res
end

as.each do |a_i|
  lst << calc(a_i)
end

puts lst.inject(:+)


Measured memory_bytes: 2556
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int64_t> vs(n);
    for (auto& v : vs)
    {
        cin >> v;
    }
    const auto argmax = std::distance(vs.begin(), max_element(vs.begin(), vs.end()));
    const auto argmin = std::distance(vs.begin(), min_element(vs.begin(), vs.end()));

    if (vs[argmax] + vs[argmin] >= 0)
    {
        cout << (2 * n - 1) << endl;
        for (int i = 1; i <= n; i++)
        {
            cout << (argmax + 1) << " " << i << endl;
        }
        for (int i = 1; i < n; i++)
        {
            cout << i << " " << (i + 1) << endl;
        }
    }
    else
    {
        cout << (2 * n - 1) << endl;
        for (int i = 1; i <= n; i++)
        {
            cout << (argmin + 1) << " " << i << endl;
        }
        for (int i = n; i > 1; i--)
        {
            cout << i << " " << (i - 1) << endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n, m, a[1000], sum;
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	sum = (sum + 4 * m - 1) / (4 * m);
	sort(a + 1, a + n + 1);
	for (int i = n; i >= 1; i--) {
		if (a[i] >= sum) {
			m--;
		} else {
			break;
		}
	}
	if (m > 0) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
class Main {
    public static void main(String[] args) throws Exception {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
 
        int count = Integer.parseInt(br.readLine());
        int[][] allCard = new int[4][13];
        for (int i = 0; i < count; i++) {
            String[] card = br.readLine().split(" ");
            int j = Integer.parseInt(card[1]) - 1;
            if (card[0].equals("S"))
                allCard[0][j] = 1;
            if (card[0].equals("H"))
                allCard[1][j] = 1;
            if (card[0].equals("C"))
                allCard[2][j] = 1;
            if (card[0].equals("D"))
                allCard[3][j] = 1;
        }
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 13; j++) {
                if (allCard[i][j] != 1) {
                    if (i == 0) {
                    	System.out.println("S" + " " + (j + 1));
                    }
                    if (i == 1) {
                    	System.out.println("H" + " " + (j + 1));
                    }
                    if (i == 2) {
                    	System.out.println("C" + " " + (j + 1));
                    }
                    if (i == 3) {
                    	System.out.println("D" + " " + (j + 1));
                    }
                }
            }
        }
    }
}
 

Measured memory_bytes: 24172
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 1000000000000;
int main(){
    int K,A,B ;
    cin >>K>>A>>B;
    rep2(i,A,B+1){
        if(i%K==0){
            cout <<"OK"<<endl;
            return 0;
        }
    }
    cout <<"NG"<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

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

    // input
    int N, T, A;
    cin >> N >> T >> A;
    vector<double> vec(N);
    int tmp;
    REP(i, N) {
        cin >> tmp;
        vec.at(i) = abs((T - (tmp * 0.006)) - A);
    }
    
    // calculation
    cout << IDX(vec, MIN(vec)) + 1 << "\n";
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


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

int H, W, N;

int main() {
    cin >> H >> W >> N;
    vector<int> obst(H + 1, W + 1);   //各xにおける障害物のy座標のうち最小のもの
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        if (obst[x] > y) {
            obst[x] = y;
        }
    }
    
    int ans = H;
    int y = 1;
    for (int x = 2; x <= H; x++) {
        if (obst[x] <= y) {
            ans = x - 1;
            break;
        }
        y = (obst[x] == y + 1)? y: y + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	1 <= n <= 20;
	long long ans = n;
	for(int i=n-1;i>1;i--){
		ans *= i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define MOD2 998244353

using namespace std;
typedef long long int ll;

ll dp[1010][1010];
vector<string> a(1010);

ll path(int i, int j)
{
	ll &ret = dp[i][j];
	if (ret != -1) return ret;
	ret = 0;
	if (i == 0 and j == 0) ret = 1;
	else if (a[i][j] != '#')
	{
		if (i) ret += path(i-1, j);
		if (j) ret += path(i, j-1);
		ret %= MOD;
	}
	return ret;
}

int main(void)
{
	fast;
	#ifndef ONLINE_JUDGE
	// freopen("in", "r", stdin);
	// freopen("out", "w", stdout);
	#endif

	int n, m; cin >> n >> m;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	memset(dp, -1, sizeof dp);
	cout << path(n-1, m-1);
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  ll h,n;
  cin >> h >> n;
  ll ans=0;
  ll a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    ans += a[i];
  }
  if(h>ans){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
  
}

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

int main(){
  int n = 0;
  long long int mi = 10000000000;
  long long int ma = -10000000000;
  long long int sum = 0;
  long long int num;
  cin >> n;
  for(int i = 0;i < n;i ++){
    cin >> num;
    mi = min(mi,num);
    ma = max(ma,num);
    sum += num;
  }
  cout << mi <<" " << ma << " " << sum << endl;
  return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  	cin>>n;
  	if (n%2==0)
    {
      cout<<fixed<<setprecision(10)<<1.0/2;
    }
  	else
    {
      cout<<fixed<<setprecision(10)<<1.0*ceil(1.0*n/2)/n;
    }
  	return 0;
}


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

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

int main() {
    int N;
    long long ans =1, l_1 = 1, l_2 = 2;
    cin >> N;
    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }

    rep(i, N) {
        ans = 0;
        ans = l_1 + l_2;
        l_2 = l_1; l_1 = ans;
        // cout << i+1 << "::" << ans << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
long long a[20000006];
int main()
{
       ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
       long long n, ans=0;
       cin >>n;
       for (int i=1; i<=n; i++)
       {
             for (int j=i; j<=n; j+=i)
             {
                   a[j]++;
             }
       }
       for (int i=1; i<=n; i++)
       {
             ans+=i*a[i];
       }cout << ans << endl;
	return 0;
}



Measured memory_bytes: 81728
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a,b,c,d;
	int i,ans;
	cin>>a>>b>>c>>d;
	if(a>=d)	cout<<d<<endl;
	else{
		d-=a;
		if(b>=d)cout<<a<<endl;
		else{
			d-=b;
			cout<<a-d<<endl;
		}
	}
	return 0;
}
	

Measured memory_bytes: 3676
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
   long long int a;
   long long  ans = 10000000000000000;
   cin >> a;
   for(int i = 1; i <= sqrt(a); i++) {
       if(a % i == 0){
           ans = min(ans,(a / i + i - 2));
       }
   }
   cout << ans << endl;
    return 0;
}

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

#define NDEBUG

// for DEBUG {{{
#ifdef NDEBUG
#define DEBUG_PRINT(fmt, ...) ((void)0)
#else
#define DEBUG_PRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#endif
#define ASSERT_RANGE(min,x,max) assert(((x)>=(min)) && ((x)<=(max)))
// }}}

#define N_MIN 3
#define N_MAX 2000
#define L_MIN 1
#define L_MAX 1000

int sort_int(int *a, int N) {// {{{
	int i;
	for (i = 0; i < N-1; i++) {
		int j;
		for (j = i + 1; j < N; j++) {
			if (a[i] > a[j]) {
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	return 0;
}// }}}
void merge_int(int *a, int *b, int lower, int sep, int upper) {// {{{
	int i_lower = lower;
	int i_upper = sep;
	int i_b = 0;
	while ((i_lower < sep) && (i_upper < upper)) {
		if (a[i_lower] < a[i_upper]) {
			b[i_b++] = a[i_lower++];
		} else {
			b[i_b++] = a[i_upper++];
		}
	}
	if (i_lower >= sep) {
		while (i_upper < upper) {
			b[i_b++] = a[i_upper++];
		}
	} else {
		while (i_lower < sep) {
			b[i_b++] = a[i_lower++];
		}
	}
	for (i_lower = 0; i_lower < i_b; i_lower++) {
		a[i_lower+lower] = b[i_lower];
	}
}// }}}
void merge_sort_int(int *a, int *b, int lower, int upper) {// {{{
	int sep;
	if ((lower == upper) || (lower + 1 == upper)) {
		return;
	}
	sep = (lower + upper) / 2;
	merge_sort_int(a,b,lower,sep);
	merge_sort_int(a,b,sep,upper);
	merge_int(a,b,lower,sep,upper);
}// }}}

int main(int argc, char **argv) {
	int N;
	int l[N_MAX];
	fscanf(stdin,"%d",&N);
	ASSERT_RANGE(N_MIN,N,N_MAX);
	{
		int i;
		for (i = 0; i < N; i++) {
			fscanf(stdin,"%d",&l[i]);
			ASSERT_RANGE(L_MIN,l[i],L_MAX);
		}
	}
	{
		int tmp[N];
		merge_sort_int(l,tmp,0,N);
	}

	{
		int ret = 0;
		int i_long = N-1;
		int i_short = 0;
		int i_mid = N-2;
		for (i_long = N-1; i_long >= 2; i_long--) {
			for (i_mid = i_long-1; i_mid >= 1; i_mid--) {
				if (l[i_long] >= l[i_mid]*2) {
					break;
				}
				for (i_short = i_mid-1; i_short >= 0; i_short--) {
					if (l[i_long] >= (l[i_mid] + l[i_short])) {
						break;
					}
					DEBUG_PRINT("%d %d %d\n",l[i_long],l[i_mid],l[i_short]);
				}
				ret += i_mid - i_short - 1;
			}
		}
		fprintf(stdout,"%d\n",ret);
	}
	return 0;
}


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll a, b, c;
  cin >> a >> b >> c;
  COUT(max(c-a+b, ll(0)));
}

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

/*

3 2
*/


Measured memory_bytes: 3584
N,M,C = map(int,input().split())
B=[int(x) for x in input().split()]
count=0
for i in range(N):
  s=0
  A=[int(x) for x in input().split()]
  for j in range(M):
    s +=A[j]*B[j]
  if s+C>0:
    count +=1
print(count)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def bin_sort(A,n_min=None,n_max=None):
    if(n_min is None): n_min=min(A)
    if(n_max is None): n_max=max(A)
    bin=[0]*(n_max-n_min+1)
    for a in A: bin[a-n_min]+=1
    B=[]
    for i in range(n_min,n_max+1): B+=[i]*bin[i-n_min]
    return B

def resolve():
    n=int(input())
    A=[0]*n
    for a in map(int,input().split()): A[a-1]+=1
    A=bin_sort(A,0,n)
    S=[0]*(n+1)
    for i in range(n): S[i+1]=S[i]+A[i]
    # output
    p=n; i=n
    for k in range(1,n+1):
        while(1):
            while(1):
                if(i<=0 or A[i-1]<p): break
                i-=1
            if(S[i]+p*(n-i)>=k*p): break
            p-=1
        print(p)
resolve()

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

using namespace std;

const int N = 100005;

int a, b, c;

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    if (x % 4 == 0) {
      ++a;
    }
    else if (x % 2 == 0) {
      ++b;
    }
    else {
      ++c;
    }
  }
  bool flag = false;
  if (n / 2 <= a && a) {
    flag = true;
  }
  c += b ? 1 : 0;
  if (a >= c) {
    flag = true;
  }
  puts(a >= c - 1 ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n, r;
    cin >> n >> r;
    cout << r + 100 * max(0, (10 - n)) << endl;
}

Measured memory_bytes: 256
N = int(input())
R = [tuple(map(int, input().split())) for i in range(N)]
B = [tuple(map(int, input().split())) for i in range(N)]

R.sort(key=lambda r: r[1], reverse=True)
B.sort()

ans = 0
for b in B:
    for r in R:
        if r[0] < b[0] and r[1] < b[1]:
            ans += 1
            R.remove(r)
            break
print(ans)


Measured memory_bytes: 3064
# coding: utf-8
# Your code here!
import collections
N = int(input())
s = input().split()
b = [str(l) for l in s]
c = collections.Counter(b)

K = int(input())
t = [input().split() for i in range(K)]

d = int(0)
e = int(0)
ans = int(0)
ckey = []
cvalue = []
clen = int(len(c))

for i in c.keys():
    ckey.append(i)
for i in c.values():
    cvalue.append(i)
for i in range(clen):
    ans = ans + int(ckey[i]) * int(cvalue[i])
    
for i in range(K):
    if c.get(t[i][0]) != None:
        d = c.get(t[i][0])
        if c.get(t[i][1]) != None:
            e = c.get(t[i][1])
            ans = ans - int(t[i][0]) * int(d) + int(t[i][1]) * int(d)
            print(ans)
            c[t[i][1]] = int(d) + int(e)
            c[t[i][0]] = 0
        else:
            ans = ans - int(t[i][0]) * int(d) + int(t[i][1]) * int(d)
            print(ans)
            c[t[i][1]] = int(d)
            c[t[i][0]] = 0
    else:
        print(ans)

Measured memory_bytes: 51412
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;} 
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[5];
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    int e = 0,f=0,g=0,h=0;
    rep(i,4){
        if(a[i] == 1) e++;
        else if(a[i] == 9) f++;
        else if(a[i] == 7) g++;
        else if(a[i] == 4) h++;
    }   
    if(e == 1 && f == 1 && g == 1 && h == 1) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


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

int main(void){
    int N,M;
    cin>>N>>M;
    vector<int>S(M);
    vector<int>C(M);
    for(int i=0;i<M;++i){
        cin>>S[i]>>C[i];
    }
    int ans=pow(10,N-1);
    if(ans==1)ans=0;
    int a_max=pow(10,N);
    for(;ans<a_max;ans++){
        int ok=1;
        string num = to_string(ans);
        for(int i=0;i<M;++i){
            if(num[S[i]-1]!=C[i]+'0'){
                ok=0;
            }
        }
        if(ok){
            break;
        }
    }
    if(ans==a_max)ans=-1;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
package main

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

type Alds14b struct {
}

func main() {
	a := &Alds14b{}
	a.main()
}

func (a *Alds14b) main() {
	scanner := bufio.NewScanner(os.Stdin)
	fmt.Println(a.solve(scanner))
}

func (a *Alds14b) solve(scanner *bufio.Scanner) int {

	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	S := make([]int, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		S[i], _ = strconv.Atoi(scanner.Text())
	}

	scanner.Scan()
	q, _ := strconv.Atoi(scanner.Text())
	T := make([]int, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		T[i], _ = strconv.Atoi(scanner.Text())
	}

	res := 0
	l := len(S)
	for i := 0; i < q; i++ {
		//left, right := 0, l - 1
		//for left <= right {
		//	mid := (left + right) / 2
		//	if S[mid] == T[i] {
		//		res++
		//		break
		//	} else if S[mid] < T[i] {
		//		left = mid + 1
		//	} else {
		//		right = mid - 1
		//	}
		//}
		left, right := 0, l
		for left < right {
			mid := (left + right) / 2
			if S[mid] == T[i] {
				res++
				break
			} else if S[mid] < T[i] {
				left = mid + 1
			} else {
				right = mid
			}
		}
	}

	return res
}



Measured memory_bytes: 5388
from sys import exit
# A,B,C = [int(n) for n in input().split()]
N = int(input())
# a = [int(input()) for _ in range(N)]
anss = 1
for i in range(1,N+1):
    if(i**2>N):
        anss = i-1
        break
print(anss**2)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] a = new int[N + 1];
		while (K-- > 0) {
			int x = sc.nextInt();
			while (x-- > 0) {
				a[sc.nextInt()] = 1;
			}
		}
		int count = 0;
		for (int i = 1; i < a.length; i++) {
			if (a[i] != 1)
				count++;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 46100
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: isize,
        m: isize,
        c:isize,
        bb: [isize; m],
        aaa: [[isize; m]; n]
    }

    let result = aaa.iter().filter(|aa| bb.iter().zip(aa.iter()).fold(c, |sum, (b, a)| sum + b * a) > 0).count();

    println!("{}", result);
}


Measured memory_bytes: 4352
package main

import (
	"fmt"
	"strconv"
)

func ct(s []string, i int, j int) int {
	if i < 0 || i >= len(s) || j < 0 || j >= len(s[i]) {
		return 0
	}

	if s[i][j] == '#' {
		return 1
	} else {
		return 0
	}
}

func main() {
	var H, W int
	fmt.Scan(&H, &W)
	S := make([]string, H)
	for i := 0; i < H; i++ {
		fmt.Scan(&S[i])
	}
	a := ""
	for i, v := range S {
		for j, vv := range v {
			if vv == '#' {
				a += "#"
				continue
			}
			ctBomb := ct(S, i-1, j-1) + ct(S, i-1, j) + ct(S, i-1, j+1) + ct(S, i, j-1) + ct(S, i, j+1) + ct(S, i+1, j-1) + ct(S, i+1, j) + ct(S, i+1, j+1)
			a += strconv.Itoa(ctBomb)
		}
		fmt.Println(a)
		a = ""
	}
}


Measured memory_bytes: 640
#include <iostream>

int main() {
	int a, b;
	std::cin >> a >> b;

	int c;
	c = a + b;

	if (c < a - b) {
		c = a - b;
	}
	if (c < a * b) {
		c = a * b;
	}
	std::cout << c << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    char cx[h][w];
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> cx[i][j];
        }
    }
    for(int i = 1; i <= h * 2; i++) {
        for(int j = 1; j <= w; j++) {
            cout << cx[(i + 1) / 2 - 1][j - 1];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
int n,m,r,s[2000][3],ans,ch[2000],t[3],L,A;
vector<P> v[2000];
void dfs(int a,int cnt,int tot){
    if(cnt==m){
        if(m!=2){
        	for(P y:v[a]){
            	if(y.F==A)tot+=y.S;
        	}
    }
        ans=max(ans,tot);
        return ;
    }
    for(P x:v[a]){
        if(ch[x.F]==0){
            ch[x.F]=1;
            dfs(x.F,cnt+1,tot+x.S);
            ch[x.F]=0;
        }
    }
    return ;
}
int main(void){
    while(1){
    cin>>n>>m>>r;
    if(n==0&&m==0&&r==0)return 0;
    for(int i=0;i<n;i++)v[i]={};
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=0;k<3;k++){
                t[k]=r-abs(s[i][k]-s[j][k]);
            }
            if(t[0]<0||t[1]<0||t[2]<0)continue;
            L=t[0]*t[1]*2+t[1]*t[2]*2+t[2]*t[0]*2;
            v[i].push_back({j,L});
            v[j].push_back({i,L});
        }
    }
    ans=-1;
    for(int i=0;i<n;i++){
        A=i;
        ch[i]=1;
        dfs(i,1,0);
        ch[i]=0;
    }
    if(ans==-1)cout<<-1<<endl;
    else cout<<r*r*6*m-ans<<endl;
    }
}



Measured memory_bytes: 3192
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;

const int N = 100005;
int n;
int a[N], b[N], c[N];
LL cnt[N];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i ++) scanf("%d", &b[i]);
	for (int i = 1; i <= n; i ++) scanf("%d", &c[i]);
	sort(a+1, a+1+n); sort(b+1, b+1+n); sort(c+1, c+1+n);
	int p = 1;
	for (int i = 1; i <= n; i ++){
		while (p <= n && c[p] <= b[i]) p ++;
		cnt[i] = n-p+1;
	}
	for (int i = n; i >= 1; i --) cnt[i] += cnt[i+1];
	LL ans = 0; p = 1;
	for (int i = 1; i <= n; i ++){
		while (p <= n && b[p] <= a[i]) p ++;
		ans += cnt[p];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    double x[110],y[110];
    cin>>n;
    rep(i,n)cin>>x[i]>>y[i];
    rep(i,n){
        vector<double>v;
        rep(j,n){
            if(i==j)continue;
            double X=x[j]-x[i];
            double Y=y[j]-y[i];
            v.pb(atan2(X,Y));
        }
        sort(all(v));
        v.pb(v[0]+2*pi);
        double res=0;
        rep(j,n-1){
            if(v[j+1]-v[j]+eps>pi)res=v[j+1]-v[j]-pi;
        }
        printf("%.12lf\n",res/(2*pi));
    }
    return 0;
}

Measured memory_bytes: 4284
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a%b);
}

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string N;
    cin >> N;
    reverse(N.begin(), N.end());

    int M = N.size();
    ll dp[M+1][2];
    dp[0][0] = 0;
    dp[0][1] = 10;

    REP(i, M) {
        int s = N[i] - '0';

        dp[i+1][0] = min(dp[i][0] + s, dp[i][1] + s + 1);

        dp[i+1][1] = min(dp[i][0] + 10 - s, dp[i][1] + 10 - s - 1);
    }

    cout << min(dp[M][0], dp[M][1] + 1) << endl;

}


Measured memory_bytes: 17052
N, M = (int(x) for x in input().split())
array = list(map(int, input().strip().split()))
list.sort(array, reverse = True)
sum = 0
for i in range(N):
  sum += array[i]
if array[M-1] * 4 * M >= sum:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
from operator import itemgetter
from itertools import *
from bisect import *
from collections import *
from heapq import *
import sys

sys.setrecursionlimit(10**6)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
int1 = lambda x: int(x)-1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def SCC(to, ot):
    n = len(to)

    def dfs(u):
        for v in to[u]:
            if com[v]: continue
            com[v] = 1
            dfs(v)
        top.append(u)

    top = []
    com = [0]*n
    for u in range(n):
        if com[u]: continue
        com[u] = 1
        dfs(u)

    def rdfs(u, k):
        for v in ot[u]:
            if com[v] != -1: continue
            com[v] = k
            rdfs(v, k)

    com = [-1]*n
    k = 0
    for u in top[::-1]:
        if com[u] != -1: continue
        com[u] = k
        rdfs(u, k)
        k += 1

    return k, com

class TwoSat:
    def __init__(self, n):
        # to[v][u]...頂点uの値がvのときの遷移先と反転の有無
        self.n = n
        self.to = [[] for _ in range(n*2)]
        self.ot = [[] for _ in range(n*2)]
        self.vals = []

    # uがu_val(0 or 1)ならばvはv_val(0 or 1)
    def add_edge(self, u, u_val, v, v_val):
        self.to[u*2+u_val].append(v*2+v_val)
        self.ot[v*2+v_val].append(u*2+u_val)

    # 条件を満たすかどうかをboolで返す。構成はself.valsに入る
    def satisfy(self):
        k, com = SCC(self.to, self.ot)
        for u in range(self.n):
            if com[u*2]==com[u*2+1]:return False
            self.vals.append(com[u*2]<com[u*2+1])
        return True

n, d = MI()
xy = LLI(n)
ts = TwoSat(n)

for i in range(n):
    x1, y1 = xy[i]
    for j in range(i):
        x2, y2 = xy[j]
        if abs(x1-x2) < d:
            ts.add_edge(i, 0, j, 1)
            ts.add_edge(j, 0, i, 1)
        if abs(x1-y2) < d:
            ts.add_edge(i, 0, j, 0)
            ts.add_edge(j, 1, i, 1)
        if abs(y1-x2) < d:
            ts.add_edge(i, 1, j, 1)
            ts.add_edge(j, 0, i, 0)
        if abs(y1-y2) < d:
            ts.add_edge(i, 1, j, 0)
            ts.add_edge(j, 1, i, 0)

if ts.satisfy():
    print("Yes")
    for j,xyi in zip(ts.vals,xy):print(xyi[j])
else:print("No")


Measured memory_bytes: 10256