akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
//#include<algorithm>
using namespace std;

int main(){
long long N,M, P;
long long count_AC = 0, count_WA = 0;
string C;
std::cin >> N >> M;

vector<long long> correct_list(N,0);
vector<long long> WA_list(N,0);

for(long long i = 0; i < M; i++){
    std::cin >> P >> C;
    if(C == "AC"){
        if(correct_list[P-1] == 0){
            count_AC++;
            count_WA = count_WA + WA_list[P-1];
            correct_list[P-1] = 1;
        }
    }else{
        if(correct_list[P-1] == 0){
            WA_list[P-1]++;
        }
    }
}

std::cout << count_AC << " " << count_WA;
}

Measured memory_bytes: 4820
s = input()
t = input()

sl = len(s)
tl = len(t)

ans = tl

for i in range(sl):
    if i < sl - tl + 1:
        ss = s[i:i+tl]
        num = 0
        for j in range(tl):
            if ss[j] != t[j]:
                num += 1
        if num < ans:
            ans = num

print(ans)


Measured memory_bytes: 73520
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
const long long MOD = 1e9 + 7;
char s[N];

int main(){
	int n;
	scanf("%d%s", &n, s);
	int L = 0, R = 0;
	long long ans = 1;
	for (int i = 0; i < 2 * n; i++){
		int t = 2 * n - i - 1 + (s[i] == 'B');
		//printf("%d\n", t);
		if (t % 2 == 0){
			L++;
		} else {
			R++;
			if (R > L) return 0 * printf("0");
			ans = ans * (L - R + 1) % MOD; 
		}
	}
	if (L != R) ans = 0;
	for (int i = 1; i <= n; i++) ans = ans * i % MOD;
	printf("%lld", ans);
	return 0;
}	 

//(())
//


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

int main(){
    string s;
    cin>>s;
    bool ok=true;
    rep(i,s.length()){
        if((i+1)%2==1){
            if(s[i]=='L') ok=false;
        }
        else{
           if(s[i]=='R') ok=false; 
        }
    }
    if(ok) cout<<"Yes"<<endl;
    else  cout<<"No"<<endl;
}

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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // int[] nx = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            string S = Console.ReadLine();
            // int a = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int h = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] AopB = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // for(int i = 0; i<A_num.Length;i++){
            //     A_num[i] = 0;
            // }
            S = S.Replace(","," ");
            Console.WriteLine(S);
        }
        //最小公倍数
        static long Lcm(long a, long b)
        {
            return a/Gcd(a,b)*b;
        }

        //最大公約数
        static long Gcd(long m, long n)
        {
            if(n==0)return m;
            return Gcd(n,m%n);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int N;
    cin >> N;

    int maxval = 0;
    vi b(N);
    for (int i = 0; i < N; i++) {
        cin >> b[i];
        maxval = max(maxval, b[i]);
    }

    int cnt = 0;
    vi c;
    while (cnt < N) {
        bool isin = false;
        for (int i = maxval; i >= 1; i--) {
            if ((int)b.size() >= i && b[i-1] == i) {
                c.push_back(i);
                b.erase(b.begin()+i-1);
                cnt++;
                isin = true;
                break;
            }
        }
        if (!isin) {
            // cout << cnt << endl;
            // for (int j = 0; j < (int)b.size(); j++) {
            //     cout << b[j] << endl;
            // }
            cout << -1 << endl;
            return;
        }
    }


    reverse(all(c));
    for (int i = 0; i < N; i++) {
        cout << c[i] << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
long long int a[90] = {2, 1}; 
long long int fip(int m){
  if(m == 0)
  return 2;
  if(a[m] != 0)
  return a[m];
  a[m] = fip(m - 1) + fip(m - 2);
  return a[m];
}
int main(){
  int n;
  cin>>n;
  cout<<fip(n)<<endl;
  return 0;
} 

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

using namespace std;

struct dir {
  int dy, dx;
};

template <class T>
ostream& operator<<(ostream& os, vector<T> const& vec) {
  for (auto& x : vec) os << x << ' ';
  os << endl;
  return os;
}

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

  vector<vector<int>> ans(H + 2);
  for (auto& row : ans) row.resize(W + 2, 0);

  cerr << ans[H + 1][5] << endl;

  for (int x = 0; x < W + 2; x++) {
    ans[0][x] = ans[H + 1][x] = -1;
  }
  for (int y = 0; y < H + 2; y++) {
    ans[y][0] = ans[y][W + 1] = -1;
  }

  array<dir, 4> dirs = {dir{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
  int nd = 0;

  int x = 1, y = 1;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    while (a > 0) {
      ans[y][x] = i + 1;
      if (ans[y + dirs[nd].dy][x + dirs[nd].dx] != 0) {
        nd = (nd + 1) % 4;
      }
      x = x + dirs[nd].dx;
      y = y + dirs[nd].dy;
      a--;
    }
  }

  for (int y = 1; y < H + 1; y++) {
    for (int x = 1; x < W; x++) {
      cout << ans[y][x] << ' ';
    }
    cout << ans[y][W] << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
#include<vector>
#define int long long int
#define mod 1000000007
int function(int arr[],int initial,int final,int curr,int memo[][3])
{
	if(initial>final)
	  return 0;
	if(memo[initial][curr]!=-1)
	{
		return memo[initial][curr];
	}
	else
	{
		if(curr==0)
		{
			int val=arr[initial]+function(arr,initial+2,final,curr,memo);
			memo[initial][curr]=val;
			return val;
		}
		else
		{
			int val1=arr[initial]+function(arr,initial+2,final,curr,memo);
			int val2=arr[initial]+function(arr,initial+3,final,curr-1,memo);
			memo[initial][curr]=max(val1,val2);
			return max(val1,val2);
		}
	}
}
int32_t main()
{
	int n;
	cin>>n;
	if(n%2==0)
	{
		int arr[n+1];
		int j;
		for(j=1;j<=n;j++)
		{
			cin>>arr[j];
		}
		int prefix[n+1]={0};
		int suffix[n+1]={0};
		for(j=1;j<=n;j++)
		{
			if(j%2!=0)
			{
				prefix[j]=arr[j];
			}
			else
			{
				suffix[j]=arr[j];
			}
		}
		for(j=3;j<=n;j+=2)
		{
			prefix[j]+=prefix[j-2];
		}
		for(j=n-2;j>=1;j-=2)
		{
			suffix[j]+=suffix[j+2];
		}
		int answer=prefix[n-1];
		for(j=n;j>=1;j-=2)
		{
			int answer2=suffix[j];
			if(j-3>=1)
			{
				answer2+=prefix[j-3];
			}
			answer=max(answer,answer2);
		}
		cout<<answer<<endl;
    }
    else
    {
		int arr[n+1];
		int j;
		for(j=1;j<=n;j++)
		{
			cin>>arr[j];
		}
		int memo[n+1][3];
		int i;
		for(i=0;i<=n;i++)
		{
			for(j=0;j<3;j++)
			{
				memo[i][j]=-1;
			}
		}
		int val1=function(arr,1,n,2,memo);
		int val2=function(arr,2,n,1,memo);
		int val3=function(arr,3,n,0,memo);
		int answer2=max(val1,max(val2,val3));
		cout<<answer2<<endl;
	}
}


Measured memory_bytes: 17628
N = gets.to_i
a = (gets.strip.split.map(&:to_i)).sort{|a,b| b <=> a}
Alice = 0
Bob = 0
while a.size > 0
    Alice += a[0]
    a.delete_at(0)
    if a.size > 0
        Bob += a[0]
        a.delete_at(0)
    end
end

puts (Alice-Bob)


Measured memory_bytes: 1916
#include <stdio.h>
int main(void){
    
    double w;
    double ww;
    double h;
    double hh;
    double x;
    double y;
    double s;
    
    scanf("%lf%lf%lf%lf", &w, &h, &x, &y);
    
    s = w * h;
    s /= 2;
    
    ww = w / 2;
    hh = h / 2;
    
    if(x==ww){
        
        if(y==hh){
            
            printf("%f 1", s);
            
            return 0;
            
        }
        
    }
    
    printf("%f 0", s);
    
    return 0;
    
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

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

int N, A;
vec<int> x;
int dp[55][55][2555];

int rec(int idx, int mai, int sum) {
  if (idx >= N) {
    return ((mai * A) == sum) && (sum != 0);
  }

  if (dp[idx][mai][sum] != -1) {
    return dp[idx][mai][sum];
  }

  int ret = 0;

  int yes = rec(idx + 1, mai + 1, sum + x[idx]);
  int no = rec(idx + 1, mai, sum);

  ret += yes + no;

  return dp[idx][mai][sum] = ret;
}

signed main() {
  cin >> N >> A;
  x.resize(N);
  rep (i, N) {
    cin >> x[i];
  }

  memset(dp, -1, sizeof(dp));
  int ans = rec(0, 0, 0);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 60672
#include<stdio.h>
main()
{
    int i, n;
    scanf("%d", &n);
    printf("%d:", n);
    for(i = 2; i * i <= n; i++){
        while(n % i == 0){
            n /= i;
            printf(" %d", i);
        }
    }
    if(n > 1){
        printf(" %d\n", n);
    }else{
        putchar('\n');
    }
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a=0,b=0,c=0;
      cin >> a >> b ;
      c=( 1.0-(a+b)/2.0 + (a+b)/2 )*((a+b)%2) + (a+b)/2.0;
      cout << c << endl;
    }

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define db(x) cerr<<#x<<" = "<<x<<endl;
using namespace std;
priority_queue<double> pq;
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;++i){
		double x;
		cin>>x;
		pq.push(-x);
	}
	while(pq.size()>=2){
		double x,y;
		x=pq.top();
		pq.pop();
		y=pq.top();
		pq.pop();
		pq.push((x+y)/2.0);
	}
	cout<<-pq.top();
	return 0;
}

Measured memory_bytes: 256
#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, cnt = 0;
    cin >> n;
    vector<int> p(n), a(n);
    rep(i,n) cin >> p[i];

    for (int i = 1; i <= n; i++) a[i-1] = i;

    rep(i,n) {
        if(p[i] != a[i]) cnt++;
    }

    if (cnt == 2 || cnt == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

int n;
void dfs(string s,char mx) { //mx=今までに使った一番後ろの文字種
	if (s.size() == n) {
		println(s);
		return;
	}
	for (char c = 'a'; c <= mx + 1; c++) {
		string t = s;
		t += c;
		dfs(t, max(c, mx));
	}

}

signed main() {
	cin >> n;
	dfs("", 'a' - 1);
}

Measured memory_bytes: 1536
h,w = list(map(int,input().split()))
a = []
a.append('.'*(w+2))
for i in range(h):
    a.append('.'+input()+'.')
a.append('.'*(w+2))
b = 1
c = ''
for i in range(h):
    for j in range(w):
        if a[i+1][j+1] == '.':
            c += '.'
        else:
            if a[i][j+1]=='#':
                b += 1
            if a[i+2][j+1]=='#':
                b += 1
            if a[i+1][j]=='#':
                b += 1
            if a[i+1][j+2]=='#':
                b += 1
            c += str(b)
            b = 1
if '1' in c:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



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

	int dig = 0;
	int sum = 0;
	{
		ll num = n;
		while (num > 0) {
			sum = num % 10;
			dig++;
			num /= 10;
		}
	}

	
	sum += (dig - 1) * 9;
	
	if (dig > 1) {
		for (int i = 0;i < dig-1;i++) {
			if (n % 10 != 9) {
				sum--;
				break;
			}
			n /= 10;
		}

	}
	

	cout << sum << endl;




}



Measured memory_bytes: 256
x,n=map(int,input().split())
if n!=0:
    p=list(map(int,input().split()))
    dif=1000
    ans=-1
    for i in range(0,102):
        if i not in p:
            if abs(x-i)<dif:
                ans=i
                dif=abs(x-i)
    print(ans)
else:
    print(x)

Measured memory_bytes: 9192
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $c);
$array1 = array($a,$b,$c);
$count5 = array_count_values($array1);
if($count5[5]== 2 && $count5[7]== 1 ){
  echo 'YES';
}else{
  echo 'NO';
}

Measured memory_bytes: 3700
n = int(input())
a = list(map(int, input().split()))

cnt = 0
for i in range(n):
    cnt = cnt | a[i]

j = 0
ans = 0
while 1:
    if (cnt >> j & 1 == 0):
        ans += 1
        j += 1
    else:
        break
print(ans)

Measured memory_bytes: 9180
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <cstring>

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const int N = 17, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll dp[1<<N];
ll group_sum[1<<N];

ll f(int mask) { // 1..not jet picked
    if (mask == 0) return 0;
    if (dp[mask] != -1) return dp[mask];
    ll ans = 0;
    for (int gr = mask; gr; gr = (gr-1) & mask) {
        int rest = mask ^ gr;
        ans = max(ans, group_sum[gr] + f(rest));
    }
    return dp[mask] = ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(n));
    rep (i, 0, n) rep (j, 0, n) cin >> a[i][j];
    for (int mask = 0; mask < (1<<n); ++mask) {
        for (int i = 0; i < n; ++i) {
            if (mask & (1<<i)) {
                for (int j = i; j < n; ++j) {
                    if (mask & (1<<j)) {
                        group_sum[mask] += a[i][j];
                    }
                }
            }
        }
    }
    memset(dp, -1, sizeof(dp));
    cout << f((1<<n)-1) << endl;
    return 0;
}

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

int main() {
 int a,b,k;
  cin >> a >> b >> k;
  int i;
  

  if((b-a+1)<=k*2){
    int h;
    for (h=0;h<=b-a;h++){
      cout << a+h << endl;
    }
  }
    
  else  {
    
  for (i=1;i<=k;i++){
    cout << a+i-1 << endl;
  }
  
  int r;
  for (r=k;r>=1;r--){
    cout << b-r+1 << endl;
  }
  }
}

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

using namespace std;

int main()
{
	int N;
	map<pair<int, int>, int> mp;

	scanf("%d", &N);

	for (int i = 0; i < N; i++){
		int x, y, w;
		scanf("%d %d %d", &x, &y, &w);
		mp[make_pair(x, y)] = w;
	}

	int dy[] = {1, 1, 0, 0};
	int dx1[] = {0, 1, 1, 0}, dx2[] = {0, -1, -1, 0};

	int ans = 0;

	for (auto pos : mp){
		int t1 = 0, t2 = 0;
		pair<int, int> base = pos.first;
		for (int i = 0; i < 4; i++){
			if (mp.count(make_pair(base.first + dy[i], base.second + dx1[i])))
				t1 += mp[make_pair(base.first + dy[i], base.second + dx1[i])];
			
			if (mp.count(make_pair(base.first + dy[i], base.second + dx2[i])))
				t2 += mp[make_pair(base.first + dy[i], base.second + dx2[i])];
		}
		ans = max({ans, t1, t2});
	}

	printf("%d / 1\n", ans);

	return (0);
}

Measured memory_bytes: 9428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll x, k, d;
 	cin >> x >> k >> d;
 	if (x >= 0) {
	 	ll temp = min(x / d, k);
	 	x -= temp * d;
	 	k -= temp;
	 	if (k % 2 == 1) {
	 		cout << abs(x - d) << endl;
	 	}
	 	else {
	 		cout << abs(x) << endl;
	 	}
 	}
 	else {
 		ll temp = min(abs(x) / d, k);
	 	x += temp * d;
	 	k -= temp;
	 	if (k % 2 == 1) {
	 		cout << abs(x + d) << endl;
	 	}
	 	else {
	 		cout << abs(x) << endl;
	 	}	
 	}
	return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  map<char,int> m;
  rep(i,n) m[s[i]]++;
  int ans = 1e9, ec = 0, wc = 0;
  rep(i,n) {
    int a = 0;
    if (s[i] == 'E') ec++;
    if (s[i] == 'W') {wc++; a = 1;}
    ans = min(ans, wc - a + m['E'] - ec);
  }
  cout << ans << endl;
  return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





void print(vector<int> a) {
    for (int i: a) cout<<i<<" ";
    cout<<endl;
}

int n,k;


vector<int> a;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    cin>>n>>k;
    a.resize(n);
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }
    k = min(51, k);

    while (k--) {
	vector<int> b(n);
	for (int i=0; i<n; i++) {
	    int lo = max(0,i-a[i]);
	    int hi = min(n-1,i+a[i]);
	    b[lo]++;
	    if (hi+1<n) b[hi+1]--;
	}

	for (int i=1; i<n; i++) {
	    b[i] += b[i-1];
	}
	
	swap(b,a);
    }

    

    print(a);
    
    return 0;
}


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

using namespace std;

bool predication(pair<int,int> arg1, pair<int,int> arg2){
    if(arg1.first == arg2.first){
        return arg1.second > arg2.second;
    }
    return arg1.first < arg2.first;
}

int main(){
    int n,a,b;
    vector<pair<int,int> > v;

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        v.push_back(make_pair(a,1));
        v.push_back(make_pair(b,-1));
    }
    sort(v.begin(),v.end(),predication);
    int cnt=1;
    int ret=-1;
    for(int i=0;i<v.size();i++){
        cnt += v[i].second;
        if(i+1==v.size() || v[i].first <= cnt && cnt <= v[i+1].first){
            ret = max(ret, cnt);
        }
    }
    cout << ret-1 << endl;
}

Measured memory_bytes: 2564
import sys

def resolve():
    input = sys.stdin.readline
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    grid=[list(map(int,input().split())) for i in range(M)]

    res = min(a) + min(b)

    for x, y, c in grid:
        res = min(res, a[x-1]+b[y-1]-c)

    print(res)
    
resolve()

Measured memory_bytes: 38436
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=2005,mod=924844033;

int c[N][N],fac[N],f[N],n,k;

il void inc(int &x,const int &y){
	x+=y;
	if(x>=mod) x-=mod;
}

il void dec(int &x,const int &y){
	x-=y;
	if(x<0) x+=mod;
}

int main(){
//	fileio("test");
	scanf("%d%d",&n,&k);
	c[0][0]=1;
	rep(i,1,n){
		c[i][0]=1;
		rep(j,1,i){
			c[i][j]=c[i-1][j-1]+c[i-1][j];
			if(c[i][j]>=mod) c[i][j]-=mod;
		}
	}
	fac[0]=1;
	rep(i,1,n) fac[i]=(ll)fac[i-1]*i%mod;
	f[0]=1;
	rep(i,1,k){
		int len=(n-i)/k,d=(len+1)>>1;
		per(i,n,1){
			rep(j,qmax(0,i-d),i-1){
				inc(f[i],(ll)f[j]*c[len-(i-j)+1][i-j]%mod);
			}
		}
		per(i,n,1){
			rep(j,qmax(0,i-d),i-1){
				inc(f[i],(ll)f[j]*c[len-(i-j)+1][i-j]%mod);
			}
		}
	}
	int ans=0;
	rep(i,0,n){
		if(i&1) dec(ans,(ll)f[i]*fac[n-i]%mod);
		else inc(ans,(ll)f[i]*fac[n-i]%mod);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
const int N=1e7+5;
bool jay;
int l,r,n,m,opt,x;
int a[N];
char str[N];
int main(){
	scanf("%s",str+1);
	l=1e6+1; r=1e6;
	n=strlen(str+1);
	for (register int i=1; i<=n; ++i)
	{
		r++;
		a[r]=str[i]-'a';
	}
	int jay=1;
	scanf("%d",&m);
	while (m--)
	{
		scanf("%d",&opt);
		if (opt==1) jay^=1;
		else
		{
			scanf("%d",&x);
			char ch;
			cin>>ch; 
			if (jay)
			{
				if (x==1) l--,a[l]=ch-'a';
				else r++,a[r]=ch-'a';
			}
			else
			{
				if (x==1) r++,a[r]=ch-'a';
				else l--,a[l]=ch-'a';
			}
		}
	}
	if (jay) for (register int i=l; i<=r; ++i) putchar((char)a[i]+'a');
	else for (register int i=r; i>=l; --i) putchar((char)a[i]+'a');
return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;






int main(){

  string S; cin>>S;
  string front;
  string behind;
  ll Q; cin>>Q;
  ll rev = 0;

  for(int i=1;i<=Q;i++){
      int T;
      scanf("%d",&T);

      if(T == 1){
          rev++;
      }

      if(T==2){
          int F;
          scanf("%d",&F);
          char text[1];
          scanf("%s",text);
          string C = text;
          if(rev % 2 == 1) F++;

          if(F % 2 == 0){behind = behind + C; } // S =S + C;
          else {front = C + front;}//S = C + S;

      }
      
  }

  S = front + S + behind;

  if(rev % 2 == 1) reverse(S.begin(),S.end());

  cout<<S<<endl;
  

return 0;
  

}

Measured memory_bytes: 1512
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string a = Console.ReadLine();
                string[] array = a.Split(' ');

                int x = int.Parse(array[0]);
                int y = int.Parse(array[1]);

                if (x > y)
                {
                    int w;
                    w = x;
                    x = y;
                    y = w;
                }

                if (x == 0 && y == 0)
                    break;

                Console.WriteLine(x + " " + y); 
            }
        }
    }
}

Measured memory_bytes: 9308
import java.util.*;
public class Main{

     public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        String x1 = s.substring(0,(n-1)/2);
        int y = (n+3)/2;
        y -= 1;
        String x2 = s.substring(y);
        if(!ispal(s)) System.out.println("No");
        else if(!ispal(x1)) System.out.println("No");
        else if(!ispal(x2)) System.out.println("No");
        else System.out.println("Yes");
        
     }
     public static boolean ispal(String s){
         int n = s.length();
         if(n==1) return true;
         for(int i=0;i<n/2;i++){
             if(s.charAt(i)!=s.charAt(n-i-1)) return false;
         }
         return true;
     }
}

Measured memory_bytes: 22356
package main

import (
	"fmt"
	"os"
)

func main() {
	var N, Y int
	fmt.Scan(&N, &Y)
	for ix := 0; ix <= N; ix++ {
		for iy := 0; iy <= N; iy++ {
			iz := N - ix - iy
			if iz < 0 {
				continue
			}
			if Y == 10000*ix+5000*iy+1000*iz {
				fmt.Println(ix, iy, iz)
				os.Exit(0)
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef	long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef pair<ll, pll> plll;
typedef vector<pair<int, pii>> viii;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tc int tt;cin>>tt;while(tt--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fio ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#define RED "\033[31m"
#define GREEN "\033[32m"
#define RESET "\033[0m"
#define sleep for (int i = 1, a;i < 100000000;i++, a = a * a)
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ranked_pairset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_map;

const int N = 1e6+1;

int main() {
	fio;
	vb p(N, 1);
	vi pf[N];
	for (int i = 2;i < N;i++)
		if (p[i])
			for (int j = i;j < N;j += i) {
				p[j] = 0;
				pf[j].pb(i);
			}
	int n;
	cin >> n;
	vb vis(N);
	int g = 0;
	bool pc = 1;
	for (int i = 0;i < n;i++) {
		int a;
		cin >> a;
		g = __gcd(g, a);
		for (auto x : pf[a])
			if (!vis[x])
				vis[x] = 1;
			else
				pc = 0;
	}
	if (pc)
		cout << "pairwise coprime\n";
	else if (g == 1)
		cout << "setwise coprime\n";
	else
		cout << "not coprime\n";
}


Measured memory_bytes: 58904
import sys
def primes(m):
    N = range(1,m+1,2)
    r = int(m**.5)
    h = len(N)
    N[0] = 0
    i=0
    while N[i]<=r:
        x = N[i]
        if x and i+x<h: N[i+x:h:x] = [0]*((h-1-i-x)/x+1)
        i += 1
    x = [2] + filter(None,N)
    return x

PRIMES = primes(50030)
for s in sys.stdin:
    n = int(s)
    for a in PRIMES:
        if a>n: break
        elif a<n: b = a
    print b,a

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

using namespace std;

typedef pair<int,int> ii;

int n,t;
ii a[3001];
int f[3001][3001];

int dp(int pos,int cur_t)
{
	if (pos > n)
		return 0;
	if (cur_t >= t)
		return 0;
	if (f[pos][cur_t] != -1)
		return f[pos][cur_t];
	int cur = dp(pos+1,cur_t);
	cur = max(cur,dp(pos+1,cur_t + a[pos].first) + a[pos].second);
	return f[pos][cur_t] = cur;
}

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

	cin >> n >> t;
	for (int i=1;i<=n;i++)
		cin >> a[i].first >> a[i].second;
	sort(a+1,a+1+n);
	for (int i=0;i<=3000;i++)
		for (int j=0;j<=3000;j++)
			f[i][j] = -1;
	cout << dp(1,0);
}

Measured memory_bytes: 35584
#include <iostream>

using namespace std;

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, x[4] = { 0 }, y[4] = { 0 }, Y, X;
	cin >> x[0]>>y[0]>>x[1]>>y[1];


		x[2] = x[1] - (y[1] - y[0]);	x[3] = x[2] - (x[1] - x[0]);
		y[2] = y[1] + (x[1] - x[0]);	y[3] = y[2] - (y[1] - y[0]);
	


	cout << x[2]<< endl;
	cout << y[2] << endl;
	cout << x[3] << endl;
	cout << y[3] << endl;

	return 0;
}

Measured memory_bytes: 256
from itertools import product

# input
N = int(input())

# check
if N < 357:
    print(0)
else:
    max_dig = len(str(N))
    dig = 3
    sgs_nuns = []
    sgs = {"7", "5", "3"}
    str_join = "".join
    for n in range(3, max_dig + 1):
        sgs_nuns += [
            str_join(n)
            for n in product(["7", "5", "3"], repeat=n)
            if set(str_join(n)) == sgs and int(str_join(n)) <= N
        ]

    cnt = len(sgs_nuns)
    print(cnt)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/11  Problem: ABC 091 D / Link: http://abc091.contest.atcoder.jp/tasks/abc091_d  ----- */


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

	LL N; cin >> N;
	vector<LL> a(N), b(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < N; ++i) {
		cin >> b[i];
	}


	LL ans = 0;
	auto A = a;
	auto B = b;
	auto cnt = [&](int L,int R) {
		return lower_bound(ALL(B), R) - lower_bound(ALL(B), L);
	};
	FOR(k, 0, 30) {
		const int base2 = 1 << k;
		const int base22 = 1 << (k + 1);
		FOR(i, 0, N) {
			A[i] = a[i] % base22;
			B[i] = b[i] % base22;
		}
		SORT(B);
		LL ret = 0;
		FOR(i, 0, N) {
			if (A[i] <= base2) {
				ret += cnt(base2 - A[i], base22 - A[i]);
			}
			else {
				ret += cnt(0, base22 - A[i]);
				ret += cnt(base22 + base2 - A[i], base22);
			}
		}
		ans += base2 * (ret & 1);
	}

	cout << (ans) << "\n";

	return 0;
}


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

const int mod = 1e9 + 7;
const int N = 2e5 + 10;

int n , m , a , b , inv[N] , fac[N] , ans;

int Add(int a , int b){
	return a + b > mod ? a + b - mod : a + b;
}

int Mul(int a , int b){
	return 1ll * a * b % mod;
}

int C(int n , int m){
	int p = n + m - 2 , q = n - 1;
	return Mul(fac[p] , Mul(inv[q] , inv[p - q]));
}

int Pow(int a , int k){
	if(k == 1) return a;
	int S = Pow(a , k >> 1);
	if(k & 1) return Mul(a , Mul(S , S));
	else return Mul(S , S);
}

int main(){
	scanf("%d %d %d %d" , &n , &m , &a , &b);
	fac[0] = 1;
	for(int i = 1; i < N; i++) fac[i] = Mul(fac[i - 1] , i);
	inv[N - 1] = Pow(fac[N - 1] , mod - 2);
	for(int i = N - 2; i >= 0; i--)
		inv[i] = Mul(inv[i + 1] , i + 1);
	for(int i = 1; i <= m - b; i++)
		ans = Add(ans , Mul(C(b + i , n - a) , C(m - b - i + 1 , a)));
	printf("%d" , ans);
	return 0;
}

Measured memory_bytes: 5324
#include <string.h>
#include <stdio.h>

int main()
{   char s[27];
    scanf("%s",s);
    int l=strlen(s),alp[26]={0};
    if(strcmp(s,"zyxwvutsrqponmlkjihgfedcba")==0){
        printf("-1");
        return 0;
    }
    
    if(l<26){
    for(int i=0;i<l;i++){
        alp[s[i]-'a']++;
        }
        printf("%s",s);
        for(int i=0;i<26;i++){
            if(alp[i]==0){
                printf("%c",'a'+i);
                return 0;
            }
        }
    }
    int p;
    for(int i=25;i>0;i--){
        if(s[i]-'a'>s[i-1]-'a'){
            p=i-1;
            break;
        }
    }
    for(int i=0;i<p;i++){
        alp[s[i]-'a']++;
        printf("%c",s[i]);
    }
    for(int i=0;i<26;i++){
        if(alp[i]==0&&s[p]-'a'<i){
            printf("%c",'a'+i);
            return 0;
        }
    }
    return 0;
}


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

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

	if (s == "Sunny") {
		cout << "Cloudy" << "\n";
	}
	else if (s == "Cloudy") {
		cout << "Rainy" << "\n";
	}
    else {
    	cout << "Sunny" << "\n";

	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    if (a == 1) {
        a = 14;
    }

    if (b == 1) {
        b = 14;
    }

    if (a == b) {
        cout << "Draw" << endl;
    } else if (a < b) {
        cout << "Bob" << endl;
    } else {
        cout << "Alice" << endl;
    }
}


Measured memory_bytes: 256
module moduel1
  sub main()
    Dim N as Integer = Console.ReadLine()
    Dim i, S
    Dim ans(4) as Integer
    for i = 0 To N
    	S = Console.ReadLine()
    	ans(0) = ans(0) - (S = "AC")
    	ans(1) = ans(1) - (S = "WA")
    	ans(2) = ans(2) - (S = "TLE")
    	ans(3) = ans(3) - (S = "RE")
  	Next
  	
	Console.writeLine("AC x " & ans(0))
  	Console.writeLine("WA x " & ans(1))
  	Console.writeLine("TLE x " & ans(2))
  	Console.writeLine("RE x " & ans(3))
end sub
end module

Measured memory_bytes: 48340
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

#define A 0
#define C 1
#define G 2
#define T 3

const int mod=1e9+7;
int dp[110][4][4][4];

signed main()
{
    int N; cin>>N;
    REP(i,4) REP(j,4) REP(k,4){
        if(i==A and j==G and k==C or i==G and j==A and k==C or i==A and j==C and k==G) continue;
        dp[3][i][j][k]=1;
    }
    for(int i=3;i<=N-1;i++){
        REP(j,4) REP(k,4) REP(l,4) REP(m,4){
            if(k==A and l==G and m==C or k==G and l==A and m==C or k==A and l==C and m==G) continue;
            if(j==A and k==G and m==C or j==A and l==G and m==C) continue;
            dp[i+1][k][l][m]+=dp[i][j][k][l];
            dp[i+1][k][l][m]%=mod;
        }
    }
    int ans=0;
    REP(i,4) REP(j,4) REP(k,4) ans=(ans+dp[N][i][j][k])%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m,c;
int main()
{
	scanf("%d%d%d",&n,&m,&c);
	for(int i = 0;i <= n;i++)
		for(int j = 0;j <= m;j++)
			if(n * m - i * j - (n - i) * (m - j) == c)
			{
				printf("Yes\n");
				return 0;
			}
	printf("No\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<utility>
#include<tuple>
#include<set>
#include<list>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long

const long long MAXN = 1e6;
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

int hoge[MAXN];

signed main(){
    size_t N;
    vector<int> As, Bs, Cs;
    cin >> N;
    As.reserve(N); Bs.reserve(N); Cs.reserve(N);
    for (size_t i = 0; i < N; i++)
    {
      int n; cin >> n;
      As.push_back(n);
    }
    for (size_t i = 0; i < N; i++)
    {
      int n; cin >> n;
      Bs.push_back(n);
    }
    for (size_t i = 0; i < N; i++)
    {
      int n; cin >> n;
      Cs.push_back(n);
    }

    vector<int> BsPossibility;

    sort(As.begin(), As.end());
    sort(Bs.begin(), Bs.end());
    sort(Cs.begin(), Cs.end());
    int i = 0;

    for(int B : Bs)
    {
      while (As[i] < B && (size_t)i < N) i++;
      BsPossibility.push_back(i);
    }

    int ans = 0;
    int current_possibility = 0;
    int j = 0;
    for(int C : Cs)
    {
      while (Bs[j] < C && (size_t)j < N) {
        current_possibility += BsPossibility[j];
        j++;
      }
//        debug(current_possibility);
        ans += current_possibility;
    }

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


Measured memory_bytes: 3704
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))

def InsertionSort(A,g):
    n = len(A)
    global cnt
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v

def ShellSort(A):
    global cnt
    cnt = 0
    Grev = []
    g = 1
    while g < n:
        Grev.append(g)
        g = 3*g + 1
    m = len(Grev)
    G = []
    for i in range(m):
        G.append(Grev[m-i-1])
    for i in range(m):
        InsertionSort(A,G[i])
    print(m)
    for k in range(m-1):
        print(G[k], end = " ")
    print(G[m-1])
    print(cnt)
    for i in range(n):
        print(A[i])

if n > 1:
    ShellSort(A)
else:
    print(1)
    print(1)
    print(0)
    print(A[0])



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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


int main() {
    int s, w;
    cin >> s >> w;
    if (w >= s) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

}



Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>



int main(void)
{
	char s[4];
	
	scanf("%s",s);
	
	int n1 = (s[0] - '0')*10 + (s[1] - '0');
	
	int n2 = (s[2] - '0')*10 + (s[3] - '0');
	
	if(0 < n1 && n1 < 13 && 0 < n2 && n2 < 13){
		printf("AMBIGUOUS\n");
	}else if(0 < n1 && n1 < 13){
		printf("MMYY\n");
	}else if(0 < n2 && n2 < 13){
		printf("YYMM\n");
	}else{
		printf("NA\n");
	}
	
	return 0;
}
	
	

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int main() {
    int n;
    cin >> n;

    int cnt = 0;
    // もっと効率良くできると思うが
    REP(i, 1, n+1){
        if(i < 10){
            cnt += 1;
        }else if(100 <= i && i <= 999){
            cnt += 1;
        }else if(10000 <= i && i <= 99999){
            cnt += 1;
        }
    }
    OP(cnt);
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <string.h>

using namespace std;

// NG

int N;
int a[10000];

int main(int argc, char** argv) {
    cin >> N;
    for (int i=0; i < N; i++) cin >> a[i];
    int ans = 0;
    for (int i=0; i < N; i++) for (int j=i+1; j < N; j++) {
        ans = max(ans, abs(a[i] - a[j]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using LL = long long;    // Poland
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
template<class T> int size(T &&x) {
	return int(x.size());
}
template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto it = x.begin(); it != x.end(); ++it)
		out << *it << (it == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dump() {}
template<class T, class... Args> void dump(T &&x, Args... args) {
	cerr << x << ";  ";
	dump(args...);
}
#ifdef DEBUG
  struct Nl{~Nl(){cerr << '\n';}};
# define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dump(x), Nl(), cerr << ""
#else
# define debug(...) 0 && cerr
#endif
mt19937_64 rng(0);
int rd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(rng);
}
// end of templates

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for(int &ai : a)
		cin >> ai;
	int sum = accumulate(a.begin(), a.end(), 0);

	int ans = 0;
	for(int ai : a)
		if(ai * 4 * m >= sum)
			++ans;
	cout << (ans >= m ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 256
d = dict()
n = int(input())
a = list(map(int,input().split()))
for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
r = 0
for k,v in d.items():
    if k < v:
        r += v-k
    elif k > v:
        r += v
print(r)


Measured memory_bytes: 17780
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
#define endl "\n"
#define Matrix vector<vector<int> >
using namespace std;
const int MOD = 1e9+7;
const int MOD2 = 1e9 + 9;
const int INF = 5e18;
 
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
 
 
inline long long mod(long long n, long long m){
    long long ret = n%m;
    if(ret < 0) ret += m;
    return ret;
}
 
int exp(int a, int b){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = result*a;
 
        b >>= 1;
        a = a*a;
    }
    return result;
}

void solve(){
    double r; cin>>r;
    double res=1;
    res = 2.0*3.14159265*r;
    cout<<fixed<<setprecision(5);
    cout<<res<<endl;
}
signed main(){
    fastio; 
    // int x=0;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}

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

int main() {
  int A, B, k;
  cin >> A >> B >> k;
  if (B - A + 1 > 2 * k - 1) {
    for (int i = 0; i < k; i++) {
      cout << A + i << endl;
    }
    for (int i = 0; i < k; i++) {
      cout << B - k + 1 + i << endl;
    }
  }
  else {
    for (int i = 0; i < B - A + 1; i++) {
      cout << A + i << endl;
    }
  }
}




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

int main(){
  int N , K;
  cin >> N >> K;
  int d;
  
  
  int x; //x(x <N)番目の人がお菓子をもらう
  
  set<int> S; //お菓子を持っている人の番号を入れるset
  for(int i = 1; i<= K; i++){ //K種類のお菓子の
    cin >> d;
    for(int j = 1; j <= d; j++){ //i種目のお菓子を持っている人
      cin >> x;
      S.insert(x);
    }
  }
  
  int y = S.size(); //お菓子を1つ以上持っている人数
  
  cout << N - y<< endl;
}
  

Measured memory_bytes: 3628