akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }return 0; }
#define all(a)  (a).begin(),(a).end()
#define rep(i, n) for (ll i = 1; i < n; i++)
#define vll vector<ll>
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
const ll INF =1LL << 62;

int main(){
  string S;
  cin >> S;
  int L=S.size();
  if(S[0] != 'A'){
    cout <<"WA" << endl;
    return 0;
  }
  int cnt=0;
  rep(i,L){
    if(isupper(S[i])){
      if(i == 1 || i == L-1 || S[i] != 'C'){
        cout << "WA" << endl;
        return 0;
      }
      cnt ++;
    }
  }
  if(cnt !=1)
    cout << "WA" << endl;
  else
    cout << "AC" << endl;
}
    

      


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

int main(){
  ll n,i,ans,m;
  ans=0;
  cin >> n;
  ll a[n];
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<ll>());
  ans+=a[0];
  for(i=1;i<n/2;i++){
    ans+=a[i]*2;
  }
  m=n%2;
  ans+=a[(n-1)/2]*m;
  cout << ans;
}

Measured memory_bytes: 5144
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int a, b; cin >> a >> b;
    vector<int> vTower(999+1); vTower[0] = 0;
    for(uint i=1; i<999+1; ++i){ vTower[i] = vTower[i-1] + i; }
    
    uint i=0;
    for(; i<vTower.size()-1; ++i){
        if(vTower[i] - a == vTower[i+1] - b){ break; }
    }
    
    cout << vTower[i] - a << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

int main(void)
{
	int N;
	char c;

	scanf("%d", &N);
	scanf("%c", &c);
	while(--N, N>=0){
		char instr[1001];
		char *t;

		gets(instr);
		while( (t = strstr(instr, "Hoshino")) != NULL){
			t += 6;
			*t = 'a';
		}

		printf("%s\n", instr);
	}


	return 0;
}

Measured memory_bytes: 1020
package main

import (
	"fmt"
)

func replaceAtIndex(in string, r rune, i int) string {
	out := []rune(in)
	out[i] = r
	return string(out)
}

func main() {
	var date string
	fmt.Scanf("%s",&date)
	date = replaceAtIndex(date,'8',3)
	fmt.Println(date)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void)
{
    string a,b;
    cin>>a>>b;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),[](char x,char y){return x>y;});
    if(a<b)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}



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

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

    char a[100][100];

    int del_h_c=0;
    for(int i=0;i<h;i++){
        string s;cin >> s;


        if(s.find('#')==string::npos) {
            del_h_c++;
            continue;
        }
        for(int j=0;j<s.size();j++){
            a[(i-del_h_c)][j] = s.at(j);
        }
    }

    bool isShow_j[100];
    for(int j=0;j<w;j++){
        isShow_j[j]=true;
        if(a[0][j]=='.'){
            isShow_j[j]=false;
            for(int i=1;i<h-del_h_c;i++){
                if(a[i][j]=='#'){
                    isShow_j[j]=true;
                    break;
                }
            }
        }
    }

    for(int i=0;i<h-del_h_c;i++){
        for(int j=0;j<w;j++){
            if(isShow_j[j]) cout << a[i][j];
        }
        cout << endl;
    }
} 

Measured memory_bytes: 256
//AtCoder 
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;
template<size_t SIZE, class T> inline size_t array_size(T (&arr)[SIZE]) {
    return SIZE;
}

bool month(int v) { return (v >= 1 && v <= 12); }

int main() {
#if LOCAL&0
  	std::ifstream in("input.txt");
  	std::cin.rdbuf(in.rdbuf());
#endif
    string S;
    cin>>S;
    int val = std::stoi(S);
    int h = val / 100;
    int f = val % 100;

    if (month(f) && month(h)) {
        cout<<"AMBIGUOUS"<<endl;
    } else if(month(h)) {
        cout<<"MMYY"<<endl;
    } else if(month(f)) {
        cout<<"YYMM"<<endl;
    } else {
        cout<<"NA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());

		HashSet<Integer> aSet = new HashSet<>();
		HashSet<Integer> bSet = new HashSet<>();

		for(int i=0; i<M; i++){
			int a = Integer.parseInt(sc.next());
			int b =  Integer.parseInt(sc.next());
			if (a == 1){
				bSet.add(b);
			}
			if (b == N){
				aSet.add(a);
			}
		}
		aSet.retainAll(bSet);
		if (aSet.size() == 0){
			System.out.println("IMPOSSIBLE");
		}else {
			System.out.println("POSSIBLE");
		}
	}
}

Measured memory_bytes: 81152
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if(A==B){
            System.out.println(C);
        }
        if(A==C){
            System.out.println(B);
        }
        if(B==C){
            System.out.println(A);
        }
    }
}

Measured memory_bytes: 21588
#include <cstdio>
 
int main(void)
{
    double a, b, c, d, e, f;
 
    while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
        double y = (d * c - a * f) / (d * b - a * e);
        double x = (c - b * y) / a;
        printf("%.3f %.3f\n", x, y);
    }
 
    return 0;
}

Measured memory_bytes: 1080
import numpy as np


def main():
    MOD = 10**9 + 7
    A_UB = 2**60  # upper bound
    MAX_BIN_LENGTH = len('{:b}'.format(A_UB))

    N = int(input())
    A = list(map(int, input().split(' ')))
    A = np.array(A)

    bit = 1
    answer = 0
    for b in range(MAX_BIN_LENGTH):
        a_bits = A & 1
        one_num = np.count_nonzero(a_bits)
        answer += (one_num * (N - one_num) * bit) % MOD
        answer %= MOD
        bit *= 2
        bit %= MOD
        A >>= 1
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 48832
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void _main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, 0, N) cin >> A[i];

  map<ll,int> m;
  ll sum = 0;
  ++m[sum];

  rep(i, 0, N) {
    sum += A[i];
    ++m[sum];
  }

  ll ans = 0;
  fore(x, m)  ans += 1ll * x.second * (x.second-1) / 2;

  cout << ans << endl;
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n; cin >> n;
  vector<pair<string,int>> v(n);

  rep(i, n) cin >> v[i].fi >> v[i].se;
  string x; cin >> x;

  int ans = 0, ok = 0;
  rep(i, n) {
    if (ok) ans += v[i].se;
    if (v[i].fi == x) ok = 1;
  }

  cout << ans << endl;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
    int a[n],b[n],c[n];
    for (int i = 0; i < n; i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
   
    int dp[n+1][3];
    dp[0][0]=0;dp[0][1]=0;dp[0][2]=0;
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=max(dp[i-1][1]+b[i-1],dp[i-1][2]+c[i-1]);
        dp[i][1]=max(dp[i-1][0]+a[i-1],dp[i-1][2]+c[i-1]);
        dp[i][2]=max(dp[i-1][0]+a[i-1],dp[i-1][1]+b[i-1]);
    }
    cout<<max( dp[n][0] ,max(dp[n][1], dp[n][2]) )<<"\n";
    
}

Measured memory_bytes: 5948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1000005,INF=1<<30;
vector<ll> A,B;
int cnt1[MAX],cnt2[MAX];

void BFS(){
    cnt1[0]=0;
    cnt2[0]=0;
    
    queue<ll> Q;
    Q.push(0);
    
    while(!Q.empty()){
        ll a=Q.front();
        Q.pop();
        for(ll to:A){
            if(a+to<=1000000){
                if(cnt1[a+to]==INF){
                    cnt1[a+to]=cnt1[a]+1;
                    Q.push(a+to);
                }
            }
        }
    }
    
    Q.push(0);
    
    while(!Q.empty()){
        ll a=Q.front();
        Q.pop();
        for(ll to:B){
            if(a+to<=1000000){
                if(cnt2[a+to]==INF){
                    cnt2[a+to]=cnt2[a]+1;
                    Q.push(a+to);
                }
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    for(ll i=1;;i++){
        if(i*(i+1)*(i+2)/6>1000000) break;
        if((i*(i+1)*(i+2)/6)%2==1){
            B.push_back((i*(i+1)*(i+2))/6);
        }
        
        A.push_back((i*(i+1)*(i+2))/6);
    }
    
    for(int i=0;i<=1000000;i++){
        cnt1[i]=INF;
        cnt2[i]=INF;
    }
    
    BFS();
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        
        cout<<cnt1[N]<<" "<<cnt2[N]<<endl;
    }
    
}



Measured memory_bytes: 17688
open List
let i_inp_list : unit -> int list = fun () ->
  let inp_split = Str.split (Str.regexp " ") (input_line stdin) in
  map (fun x -> int_of_string x) (inp_split)
let () =
  let [n; l] = i_inp_list () in
  let last = n + l - 1 in
  let ans = 
    if last < 0 then
      (n - 1) * (l + last - 1) / 2
    else if l < 0 && last >= 0 then
      n * (l + last) / 2
    else
      (n - 1) * (l + 1 + last) / 2
  in
    print_int ans;
    
  print_newline ()
      


Measured memory_bytes: 384
#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 rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{	
	vector<int> ans;
	while (true)
	{
		int n, x; cin >> n >> x;
		if(n == 0 && x == 0)break;
		int tmp = 0;
		reps(i, n)reps(j, n)reps(k, n)
		{
			int s = i + j + k; 
			if(s == x && i != j && j != k && k != i)tmp++;
		}
		ans.push_back(tmp/6);
	}
	rep(i,sz(ans))cout << ans[i] << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



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

marchNum = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
march = ['M', 'A', 'R', 'C', 'H']
for i in range(N):
    str = input()
    if str[0] in march:
        marchNum[str[0]] += 1

comNum = 0
for i in range(0,5):
    for j in range(i+1,5):
        for k in range(j+1, 5):
            comNum += marchNum[march[i]] * marchNum[march[j]] * marchNum[march[k]]

print(comNum)


Measured memory_bytes: 3188
a,b,c,x = 4.times.map { gets.to_i }
count = 0

(0..a).each do |h|
  (0..b).each do |i|
    (0..c).each do |j|
     count += 1 if h * 500 + i * 100 + j *50 == x
    end
  end
end

puts count

Measured memory_bytes: 1788
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P,P> P2;
const int INF = 1 << 30;
const double EPS = 1E-9;

int main(){
	string s1, s2;
	while(cin >> s1 >> s2){
		if(s1 == "0" && s2 == "0") break;
		int h = 0, b = 0;
		for(int i = 0; i < 4; i++){
			if(s1[i] == s2[i]) h++;
		}
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
				if(i == j) continue;
				if(s1[i] == s2[j]) b++;
			}
		}
		cout << h << " " << b << endl;
	}
	return 0;
}

	

Measured memory_bytes: 916
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

const ll MOD = 998244353;

// あとで S+1 までループを回しているため
ll DP[3001][3001];

// A の部分集合 T、Tの部分集合 U で数える
int main() {
  int N, S;
  cin >> N >> S;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];

  DP[0][0] = 1;
  REP(i, N) REP(j, S + 1) {
    // Ai が T に選ばれない場合
    DP[i + 1][j] += DP[i][j];
    // Ai が T には選ばれているが U には選ばれていない場合
    DP[i + 1][j] += DP[i][j];
    DP[i + 1][j] %= MOD;
    // Ai が選ばれた場合
    if (A[i] + j <= S) {
      DP[i + 1][j + A[i]] += DP[i][j];
      DP[i + 1][j + A[i]] %= MOD;
    }
  }
  cout << DP[N][S] << endl;
}

Measured memory_bytes: 73924
// ITP1_7_A:   Grading
// 2017.7.27

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int m, f, r;
	int s;

	while (1) {
		scanf("%d%d%d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1) break;

		if (m < 0 || f < 0) puts("F");
		else {
			s = m + f;
			if (s >= 80) puts("A");
			else if (s >= 65) puts("B");
			else if (s >= 50) puts("C");
			else if (s < 30) puts("F");
			else puts(r >= 50 ? "C" : "D");
		}
	}
	return 0;
}

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

int main(){
  int k;
  cin >> k;
  string s;
  cin >> s;
  if (s.size() <= k){
    cout << s << endl;
  }
  else{
    cout << s.substr(0,k) + "..." << endl;
  }
  
}



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

int len(string &s,string &t,int i,int j,vector<vector<int> > &dp) {
    if(i >= s.length() || j >=t.length()) {
        return 0;
    }
    if(dp[i][j]!=-1) {
        return dp[i][j];
    }
    if(s[i]==t[j]) {
        return dp[i][j] = 1 + len(s,t,i+1,j+1,dp);
    }
    else {
        int option1 = len(s,t,i+1,j,dp);
        int option2 = len(s,t,i,j+1,dp);
        return dp[i][j] = max(option1,option2);
    }
}

string get_lcs(string &s,string &t,int l,vector<vector<int> > &dp) {
    string str;
    str.reserve(l);
    int i=0,j=0;
    while(l > 0) {
        if(s[i]==t[j]) {
            str.push_back(s[i]);
            ++i;
            ++j;
            --l;
        }
        else {
            if(dp[i+1][j] > dp[i][j+1]) {
                ++i;
            }
            else {
                ++j;
            }
        }
    }
    return str;
}

int main() {
	string s,t;
	cin>>s>>t;
	int n = s.length();
	int m = t.length();
	vector<vector<int> > dp(n+1,vector<int>(m+1,-1));
	int l = len(s,t,0,0,dp);
	cout<<get_lcs(s,t,l,dp);
	return 0;
}


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

int main(){
    int n;double m;
    cin >> n >> m;
    vector<double> a(n);
    rep(i,n) cin >> a[i];
    double sum = 0;
    rep(i,n) sum += a[i];

    int cnt=0;//得票数が条件を満たす個数
    rep(i,n){
        if(a[i] >=sum/4/m){
            cnt++;
        }
    }

    if(cnt >= m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define int long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1*1e5+5;

int32_t main() {
	map<string, int> mapa;
	string s1, s2;
	cin >> s1 >> s2;
	int a, b;
	cin >> a >> b;
	mapa[s1] = a;
	mapa[s2] = b;
	string s;
	cin >> s;
	mapa[s]--;
	cout << mapa[s1] << " " << mapa[s2] << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main(){
    string s;
    cin >> s;

    int l = s.length();

    int i;
    int count = 0;
    rep(i, l){
        if (i % 2 == 0){
            if (s[i] == '0')
                count++;
        }else{
            if (s[i] == '1')
                count++;
        }
    }

    cout << min(count, l-count) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<int> a(1000001);
  int k;
  cin>>k;
  a[1]=7%k;
  for(int i=2;i<=1000000;i++){
    a[i]=(a[i-1]*10+7)%k;
  }
  for(int i=1;i<=1000000;i++){
    if(a[i]==0){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

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

bool isOdd(int i) {
    int counter = 0;
    while (i > 0) {
        counter++;
        i /= 10;
    }
    return counter % 2 == 1;
}

int main() {
    int N;
    cin >> N;
    int ans = 0;
    rep(i, N) {
        if (isOdd(i+1)) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		long x=ir.nextLong();
		long y=ir.nextLong();
		long ret=0;
		while(x<=y){
			ret++;
			x<<=1;
		}
		out.println(ret);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m; cin>>m;
    cout<<48-m<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>//

using namespace std;

int main() {
    int n, t;
    cin >> n;
    t = n;
    int ans = 0;
    while (n) {
        ans += n % 10;
        n /= 10;
    }

    cout << (t % ans == 0 ? "Yes" :"No");
    return 0;
}
// Created by Kevin Weng on 2019/11/4.
//



Measured memory_bytes: 256
s=input()
k=int(input())
s0=s[0]
s1=s[-1]
cs=[]
p=s[0]
c=1
for i in range(1,len(s)):
      if p==s[i]:
            c+=1
      else:
            cs.append(c)
            p=s[i]
            c=1
cs.append(c)
if len(cs)==1:
      print((cs[0]*k)//2)
      exit()
ans=0
if s0!=s1:
      for csi in cs:
            ans+=csi//2
      ans*=k
      print(ans)
      exit()
else:
      for i in range(1,len(cs)-1):
            ans+=cs[i]//2
      ans*=k
      ans+=cs[0]//2+cs[-1]//2
      ans+=((cs[0]+cs[-1])//2)*(k-1)
      print(ans)




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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vector<string>arr(n);
    map<string,ll>m;
    ll d=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        m[arr[i]]++;
        d=max(d,m[arr[i]]);
    }
    set<string>s;
    for(int i=0;i<n;i++){
        if(m[arr[i]]==d)
            s.insert(arr[i]);
    }
    for(auto it=s.begin();it!=s.end();it++){
        cout<<(*it)<<"\n";
    }

    return 0;
}


Measured memory_bytes: 34816
#include <bits/stdc++.h>
#define maxn 100000
using namespace std;

int n,k;
int h[maxn];
int dp[maxn];

int main() {
	cin >> n >> k;
	for( int i = 0 ; i < n ; i++ )
		cin >> h[i];
	for( int i = 1 ; i < n ; i++ ) {
		dp[i] = (1 << 30);
		for( int j = max( i-k , 0 ) ; j < i ; j++ )
			dp[i] = min( dp[i] , dp[j] + abs( h[i] - h[j] ) );
	}
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>

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

int main()
{
    int max;
    std::cin >> max;
    long long int result = 0;

    for (int i = 1; i <= max; ++i)
    {
        for (int j = i; j <= max; ++j)
        {
            for (int k = j; k <= max; ++k)
            {
                if (i == j && j == k)
                {
                    result += i;
                }
                else if (i == j)
                {
                    result += (3 * gcd(k, i));
                }
                else if (j == k)
                {
                    result += (3 * gcd(i, j));
                }
                else if (k == i)
                {
                    result += (3 * gcd(j, k));
                }
                else
                {
                    result += (6 * gcd(k, gcd(j, i)));
                }
            }
        }
    }

    std::cout << result << std::endl;
}


Measured memory_bytes: 3172
import sys
import numpy as np 

n, m = map(int, sys.stdin.readline().split())
x = np.array(sys.stdin.readline().split(), dtype=np.int64)
x.sort()

def main():
    if n >= m:
        print(0)
        return
    d = x[1:] - x[:-1]
    d = np.sort(d)[::-1]
    np.cumsum(d, out=d)
    res = d[-1]
    res -= 0 if n == 1 else d[n-2]
    print(res)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 22252
using System;
using System.Linq;
    class Program
    {
        static void Main(string[] args)
        {
            var ABC = Console.ReadLine().Split(' ').ToList();
            Console.WriteLine(ABC.Count(s => s == "5") == 2 && ABC.Count(s => s == "7") == 1 ? "YES" : "NO");
        }
    }

Measured memory_bytes: 13268
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        int x[] = new int[n]; 
        int ans = 0;
        for(int i = 0; i < n; i++){
        	x[i] = sc.nextInt();
        }
        Arrays.sort(x);
        for(int i = 0; i < n; i++){
            int count = 1;
        	for(int j = i + 1; j < n; j++){
            	if(x[i] == x[j]){
                	count++;
                    i++;
                }else{
                    break;
                }
            }
            if(count % 2 == 1){
            	ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 60032
#Exponential

#入力
X = int(input())
ans = []
#計算
for j in range(2,11,1):
	for i in range(1,X+1,1):
		if pow(i,j) > X:
			ans.append(pow(i-1,j))
			break
		if pow(i,j) == X:
			ans.append(pow(i,j))
			break

print("{}".format(max(ans)))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>

using namespace std;

#define NIL -2000000001

struct Node {
	int key;
	int left = NIL;
	int right = NIL;
};

Node tree[500000];

void preorder(int s) {
	if (s != NIL) {
		cout << " " << tree[s].key;
		if (tree[s].left != NIL) {
			preorder(tree[s].left);
		}
		if (tree[s].right != NIL) {
			preorder(tree[s].right);
		}
	}
}

void inorder(int s) {
	if (s != NIL) {
		if (tree[s].left != NIL) {
			inorder(tree[s].left);
		}
		cout << " " << tree[s].key;
		if (tree[s].right != NIL) {
			inorder(tree[s].right);
		}
	}
}

void insert(int s) {
	int y = NIL;
	int x = 0;

	while (x != NIL) {
		y = x;
		if (tree[s].key < tree[x].key) {
			x = tree[x].left;
		}
		else {
			x = tree[x].right;
		}
	}

	if (s == 0) {
		return;
	}

	if (tree[s].key < tree[y].key) {
		tree[y].left = s;
	}
	else {
		tree[y].right = s;
	}
}

int main() {
	int n, value;
	string str;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> str;
		if (str == "insert") {
			cin >> value;
			tree[i].key = value;
			insert(i);
		}
		else if (str == "print") {
			inorder(0);
			cout << endl;
			preorder(0);
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 8964
import java.util.*;
public class Main{public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int a=sc.nextInt();
  int b=sc.nextInt();
  int c=sc.nextInt();
  boolean po=false;
  for(int i=1;i<=b;i++){
  	if((a*i)%b==c)po=true;
  }
  System.out.println(po?"YES":"NO");
  }}


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

int main() {
        char c;
        cin >> c;
        
        switch (c) {
                case 'a':
                case 'e':
                case 'i':
                case 'o':
                case 'u':
                        cout << "vowel" << endl;
                        break;
                default:
                        cout << "consonant" << endl;
                        break;
        }               
        
        return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  set<int> b;
  rep(i,n) b.insert(a[i]);
  if(a.size() == b.size()) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;

int main(){
    ll A, B, C; cin >> A >> B >> C;
    ll MIN;
    if(A%2 == 0 || B%2 == 0 || C%2 == 0) {
        cout << 0 << endl;
        return 0;
    }
    MIN = min(A*B, B*C);
    MIN = min(MIN, C*A);

    cout << MIN << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    ll k;
    cin >> k;
    for (int i = 0; i < k; i++) {
        if (s[i] != '1') {
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void change(int&x, int &y)
{

    int aux;
    aux = x;
    x=y;
    y=aux;
}
    int main()
    {
        int a,b,c;
        int aux;
        cin>>a>>b>>c;
        if(a>b)
        change(a,b);
        if(a>c)
        change(a,c);
        if(b>c)
        change(b,c);

        cout<<a<<" "<<b<<" "<<c<<endl;

        return 0;
}



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

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

#define ll long long
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

void solve(){
  int n,k;cin>>n>>k;
  vt<ll> V(n+1),W(n+1);
  vt<ll> dp(k+1),dp2(k+1);
  FOR(i,1,n+1) cin>>W[i]>>V[i];

  FOR(i,1,n+1){
    dp2.assign(k+1,0);
    FOR(j,k+1){
      dp2[j]=max(dp2[j],dp[j]);
      if(W[i]<=j){
        dp2[j]=max(dp2[j],V[i]+dp[j-W[i]]);
      }
    }
    dp=dp2;
  }
  
  cout<<dp[k]<<endl;
}

//void main(){int t;cin>>t;while(t--)solve();}
int main(){solve();}


Measured memory_bytes: 4796
#include<iostream>
#define inf 2000000000
#define f first
#define s second
using namespace std;

int w;
int a[1000000],b[1000000],c[1000000];

int main()
{
  pair<int,int> u;
  cin>>w;
  for(int i=0;i<w;i++)cin>>a[i];
  for(int i=0;i<w;i++){
    if(a[i]==0){
      b[i]=0;
      c[i]=0;
    }
    else {
      b[i]=0;
      c[i]=0;
    }
  }
  u.f=inf;u.s=inf;
  for(int i=0;i<w-1;i++){
    if(a[i+1]==0){
      u.f=inf;u.s=inf;
      b[i+1]=inf;
      continue;
    }
    u.s--;
    if(u.s<0)u.s=0;
    if(a[i+1]>0){
      if(a[i]>0){
	if(a[i]==b[i])b[i+1]=max(0,min(a[i+1],u.s));
        else b[i+1]=max(0,min(b[i]-1,a[i+1]));
      }
      if(a[i]<0){
	b[i+1]=max(0,min(b[i]-1,a[i+1]));
      }
      if(a[i]==0)b[i+1]=a[i+1];
    }

    if(a[i+1]<0){

      if(a[i]>0){
	if(a[i]==b[i])b[i+1]=max(0,min(-a[i+1],u.s));
	else b[i+1]=max(0,min(b[i]-1,-a[i+1]));
      }
      if(a[i]<0){
	b[i+1]=max(0,min(b[i]-1,-a[i+1]));
      }
      if(a[i]==0)b[i+1]=-a[i+1];
      u.f=-a[i+1];
      u.s=b[i+1];
    }
  }
  
  u.f=inf;u.s=inf;
  for(int i=w-1;i>=1;i--){
    if(a[i-1]==0){
      u.f=inf;u.s=inf;
      c[i-1]=inf;
      continue;
    }
    
    u.s--;
    if(u.s<0)u.s=0;
    if(a[i-1]>0){
      if(a[i]>0){
	
	if(a[i]==c[i])c[i-1]=max(0,min(a[i-1],u.s));
        else c[i-1]=max(0,min(c[i]-1,a[i-1]));
      }
      if(a[i]<0){
	c[i-1]=max(0,min(c[i]-1,a[i-1]));
      }
      if(a[i]==0)c[i-1]=a[i-1];
    }
    
    if(a[i-1]<0){
      if(a[i]>0){
	if(a[i]==c[i])c[i-1]=max(0,min(-a[i-1],u.s));
	else c[i-1]=max(0,min(c[i]-1,-a[i-1]));
      }
      if(a[i]<0){
	c[i-1]=max(0,min(c[i]-1,-a[i-1]));

      }
      if(a[i]==0)c[i-1]=-a[i-1];
	u.f=-a[i-1];
	u.s=c[i-1];
    }
  }
/*
  for(int i=0;i<w;i++){
  if(c[i]!=inf)cout<<c[i]<<" ";
  else cout<<"I ";
  }*/
  int ans=0;
  for(int i=0;i<w;i++){
    if(a[i]>0)ans+=max(b[i],c[i]);
    }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 9744
// myfirstatcoder.cpp : アプリケーションのエントリ ポイントを定義します。

#include "bits/stdc++.h"
#define rep(i,cc,n) for(int i=cc;i<(n);++i)
#define drep(i,cc,n) for(int i=cc;i>(n);--i)
#define llrep(i,cc,n) for(long long i=cc;i<(n);++i)
using namespace std;
using ll = long long;

int main()
{
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	long double rad,ans;
	double b_rad = m / 60.0;
	double a_rad = (h + b_rad) / 12.0;
	rad = (a_rad - b_rad) * 2*M_PI;
	if (rad < 0)
		rad = -rad;
	ans = a * a + b * b - 2 * a * b * cosl(rad);
	ans = sqrtl(ans);
	//ans = pow(ans, 0.5);
	cout << fixed << setprecision(20) << ans << endl;
}



Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    string s;
    cin >> s;

    for (int i = 0; i < s.length(); i++)
    {
        s[i] = 'x';
    }
    Cout(s);

    return 0;
}

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


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string s,t;
    cin>>s>>t;
    
    ll n=s.length();
    ll m=t.length();
    
    ll ma=0;
    
    for(ll i=0;i<=(n-m);i++)
    {
        ll x=0;
        for(ll j=i;j<i+m;j++)
        {
            if(s[j]==t[j-i])
            x++;
        }
        ma=max(ma,x);
        
    }
    
    cout<<m-ma;
    return 0;

}

Measured memory_bytes: 3660
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int H, W, N;
    cin >> H >> W >> N;
    int color[N];
    rep(i, N)
    {
        cin >> color[i];
    }

    int ans[H][W];
    int index = 0;
    rep(i, H)
    {
        if (i % 2 == 0)
        {
            for (int j = 0; j < W; j++)
            {
                if (color[index] == 0)
                {
                    index++;
                }
                ans[i][j] = index + 1;
                color[index]--;
            }
        }
        else
        {
            for (int j = W - 1; j >= 0; j--)
            {
                if (color[index] == 0)
                {
                    index++;
                }
                ans[i][j] = index + 1;
                color[index]--;
            }
        }
    }

    rep(i, H)
    {
        rep(j, W)
        {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	int N;
	while (cin >> N, N) {
		bool na = true;
		int k, res = 1;
		for (int i=0; i<N; ++i) {
			cin >> k;
			if (0 < k) ++ res;
			if (2 <= k) na = false;
		}
		if (na) {
			cout << "NA" << endl;
		} else {
			cout << res << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int a,b,c;
    
    cin>> a>>b;
    
   
   c=a+b;
   
   if(c>=24){
       
       c=c-24;
       
   }
   
   
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int X, A, B;
	scanf("%d %d %d", &X, &A, &B);
	int T, Y;
	T = A - X;
	Y = B - X;
	if ( T < 0 ) {
		T *= -1;
    }
	if ( Y < 0 ) {
		Y *= -1;
	}
	if (T < Y) {
		printf("A");
	} else {
		printf("B");
	}
	return 0;
}

Measured memory_bytes: 1656
n=int(input())
A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]
C=[int(x) for x in input().split()]
a=sorted(A)
b=sorted(B)
c=sorted(C)
ans=0
import bisect
from bisect import bisect_right
from bisect import bisect_left
for j in range(n):
  p=bisect.bisect_left(a,b[j])
  q=n-bisect.bisect_right(c,b[j])
  ans+=p*q
print(ans)

Measured memory_bytes: 29540
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

const int MAX_N = 110;
const int MAX_V = 100100;
int N, W, weight[MAX_N], value[MAX_N];
int dp[MAX_N][MAX_V];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> W;
	for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

	// 初期化
	for (int i = 0; i < MAX_N; ++i) for (int j = 0; j < MAX_V; ++j) dp[i][j] = INF;

	// 初期条件
	dp[0][0] = 0;

	// DPループ
	for (int i = 0; i < N; ++i) {
		for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {

			// i 番目の品物を選ぶ場合
			if (sum_v - value[i] >= 0) chmin(dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]);

			// i 番目の品物を選ばない場合
			chmin(dp[i + 1][sum_v], dp[i][sum_v]);
		}
	}

	// 最適値の出力
	long long res = 0;
	for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
		if (dp[N][sum_v] <= W) res = sum_v;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 86400
def solve(s, t):
    s = s.split('"')
    t = t.split('"')

    if s == t:
        return "IDENTICAL"

    if len(s) == len(t):
        cnt = 0
        for i in range(len(s)):
            if s[i] != t[i] and i % 2 == 1:
                cnt += 1
            elif s[i] != t[i]:
                cnt += 2
        if cnt == 1:
            return 'CLOSE'

    return 'DIFFERENT'

while True:
    s1 = raw_input()

    if s1 == '.': break

    s2 = raw_input()

    print solve(s1, s2)



Measured memory_bytes: 4652
#include <iostream>
#include <queue>
#include <set>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define mp(a, b) make_pair(a, b)
const int dx[] = {0, -1, -1, 0, 1, 1}, dy[] = {1, 0, -1, -1, 0, 1};

void solve(set<pair<int, int> >& vis, int x, int y, int t){
    const int sep = 1 << 16;
    queue<pair<int, int> > q;
    q.emplace(x, y);
    q.emplace(sep, 0);
    while(!q.empty()){
        x = q.front().first; y = q.front().second; q.pop();
        if(x == sep){
            q.emplace(sep, 0);
            if(--t == 0)break; else continue;
        }
        rep(k, 6){
            int nx = x + dx[k], ny = y + dy[k];
            if(/*!vis.emplace(nx, ny)*/!vis.insert(mp(nx, ny)).second)continue;
            q.emplace(nx, ny);
        }
    }
}

int main(){
    int t, n;
    while(cin >> t >> n, t|n){
        set<pair<int, int> > vis;
        int x, y;
        rep(i, n+1){
            cin >> x >> y;
            vis.insert(mp(x, y)); // vis.emplace(x, y);
        }
        solve(vis, x, y, t);
        cout << (int)vis.size() - n << '\n';
    }
    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ((A + B) - (C + D) > 0) {
    cout << "Left" << endl;
  }
  
  else if ((A + B) - (C + D) == 0) {
    cout << "Balanced" << endl;
  }
           
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 3644
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Control.Monad.ST
import Data.List
import Data.Array.Unboxed
import Data.Array.ST
import Control.Monad.Trans.State.Strict
import Data.Char (isSpace)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as B

type Parser a = StateT B.ByteString Maybe a

parseInt :: Parser Int
parseInt = StateT (B.readInt . B.dropWhile isSpace)

parseInt2 :: Parser (Int,Int)
parseInt2 = liftM2 (,) parseInt parseInt

parse :: Parser (Int, [(Int,Int)], [(Int,Int)])
parse = do
  n<-parseInt
  m<-parseInt
  q<-parseInt
  lrs<-replicateM m parseInt2
  pqs<-replicateM q parseInt2
  return (n,lrs,pqs)

main=do
  (n,lrs,pqs) <- fromJust.evalStateT parse <$> B.getContents
  let !ar = f n lrs
  putStr.unlines $ map (\(p,q)->show $ ar ! (p,q)) pqs
--
f n lrs = runSTUArray $ do
  ar <- newArray ((1,1),(n+1,n)) 0 :: ST s (STUArray s (Int,Int) Int)
  forM_ lrs $ \(l,r) -> do
    writeArray ar (1,r) =<< succ <$> readArray ar (1,r)
    writeArray ar (l+1,r) =<< pred <$> readArray ar (l+1,r)
  forM_ [(l,r)|l<-[2..n],r<-[1..n]] $ \(l,r) -> do
    writeArray ar (l,r) =<< (+) <$> readArray ar (l,r) <*> readArray ar (l-1,r)
  forM_ [(l,r)|l<-[1..n],r<-[2..n]] $ \(l,r) -> do
    writeArray ar (l,r) =<< (+) <$> readArray ar (l,r) <*> readArray ar (l,r-1)
  pure ar


Measured memory_bytes: 48252
import itertools
N,M=map(int,input().split())
edges={tuple(sorted(map(int,input().split()))) for i in range(M)}
ans=0
for i in itertools.permutations(range(2,N+1)):
    l=[1]+list(i)
    ans+=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
class Dice {
private:
    void shift(int i, int j, int k, int l) {
        // i<-j<-k<-l<-i
        int t=a[i];a[i]=a[j];a[j]=a[k];a[k]=a[l];a[l]=t;
    }
public:
    int a[7]={0};
    void move(char d) {
        if(d=='N') shift(1,2,6,5);
        else if(d=='E') shift(1,4,6,3);
        else if(d=='W') shift(1,3,6,4);
        else if(d=='S') shift(1,5,6,2);
    }
};
int main() {
    Dice d1, d2;
    for(int i = 1; i <= 6; ++i) cin >> d1.a[i];
    for(int i = 1; i <= 6; ++i) cin >> d2.a[i];
    string r[2][7] = {
        // 1<-1,2(fix),3,4,5(fix),6
        {"","","","W","E","","WW"},
        // 2<-1,2,3,4,5,6
        {"","S","","WS","ES","SS","N"}
    };
    int p, q;
    for(int j = 1; j <= 6; ++j) if(d2.a[j]==d1.a[2]) {q=j;break;}
    for(int j = 0; j < r[1][q].length(); ++j) d2.move(r[1][q][j]);
    for(int j = 1; j <= 6; ++j) if(d2.a[j]==d1.a[1]) {p=j;break;}
    for(int j = 0; j < r[0][p].length(); ++j) d2.move(r[0][p][j]);
    string ans = "Yes";
    for(int j = 1; j <= 6; ++j) if(d1.a[j]!=d2.a[j]) {ans="No";break;}
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3208
#include<iostream>
using namespace std;
int k,a,b,gg;
int main(){
	cin>>k>>a>>b;
	for (int i=1;i<=1000;i++){
		gg=k*i;
		if (a<=gg && gg<=b){
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int a,b;
    cin>>a>>b;
    if((a+b)&1){
        cout<<"IMPOSSIBLE"<<endl;
    }
    else{
        cout<<(a+b)/2<<endl;
    }
}

Measured memory_bytes: 256