akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
  string s;
  cin >> s;
  int count=0;
  
  if(s[0]=='o') count++;
  if(s[1]=='o') count++;
  if(s[2]=='o') count++;
  
  cout << 700+100*count << endl;
  
}

Measured memory_bytes: 256
#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 h, n;
  cin >> h >> n;
  int sum = 0;
  rep(i,n){
    int a;
    cin >> a;
    sum += a;
  }
  
  if(sum >= h) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 256
while True:
    n,x=map(int,input().split())
    count=0
    if n==0 and x==0:
        break
    else:
        for i in range(1,n+1):
            for j in range(i+1,n+1):
                for k in range(j+1,n+1):
                    if i+j+k==x:
                        count+=1
        print(count)



Measured memory_bytes: 5596
#include <stdio.h>

int main(void)
{
    int n, i, j, k, sum, tempsum, start, end;
    int a[5000];
    
    while(1){    
        scanf("%d", &n);
        
        if(n == 0) break;
        for (i = 0; i < n; i++){
            scanf("%d", &a[i]);
        }
        sum = -100000;
        for (i = 0; i < n; i++){
            tempsum = 0;
            // start = j;
            // end = i + j;
            for (j = i; j < n; j++){
                tempsum += a[j];
                // if(end >= n) break;
                // for(k = start; k <= end; k++){
                //     //printf("window %d\n", end - start);
                //     tempsum += a[k];
                // }
                // //printf("temp %d\n", tempsum);
                if(tempsum > sum) sum = tempsum;
            }
            
        }
        printf("%d\n", sum);
    }
    return (0);

}


Measured memory_bytes: 1912
using namespace std;
#include <bits/stdc++.h>
int main(){
    int a,b,e,s,x;cin>>a>>b;
    e=a-b;
    s=max(a+b,a*b);
    x=max(e,s);
    std::cout << x << std::endl;
    return 0;
}

Measured memory_bytes: 3600
N = gets.to_i
A = gets.split.map(&:to_i)

l = [0] * (N+1)
r = [0] * (N+1)
N.times do |i|
  l[i+1]=l[i].gcd(A[i])
end

(N-1).downto(0) do |i|
  r[i]=r[i+1].gcd(A[i])
end

ans = 0
N.times do |i|
  ans = [ans, l[i].gcd(r[i+1])].max
end
puts ans



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

using ll=long long;
const int mod=1e9+7;

ll P(ll n) {
  ll i,x=1;
  for(i=2; i<=n; i++) {
    x *= i;
    x %= mod;
  }
  return x;
}

int main() {
  ll N,M;
  int x;
  cin >> N >> M;
  if(M<N)
    swap(N,M);
  if(M-N>1)
    x = 0;
  else if(M==N)
    x = 2;
  else
    x = 1;
  
  cout << P(N)*P(M)*x%mod << endl;
}

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

typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[300005];
int main(){
	scanf("%d",&n);
	repn(i,n) scanf("%d",&a[i]);
	if(n%2==0){
		ll c=0,b=0;
		repn(i,n){
			if(i%2==1) c+=a[i];
			else b+=a[i];
		}
		printf("%lld %lld\n",max(c,b),min(c,b));
	}
	else{
		ll c=0,b=0;
		repn(i,n){
			if(i%2==1) c+=a[i];
			else b+=a[i];
		}
		if(c-b >= 1005){
			printf("%lld %lld\n",max(c,b),min(c,b));
			return 0;
		}
		int lb = 0,ub = 1007;
		while(ub-lb>1){
			int mid = (lb+ub)/2;
			int dif = c-b;
			if(dif >= mid){
				lb = mid; continue;
			}
			int cur = 0;
			repn(i,n){
				if(i%2 == 1) cur += a[i];
				else{
					if(cur>=mid && cur-a[i]<=0){
						dif -= (cur-a[i]);
						cur = 0;
					}
					else{
						cur -= a[i];
					}
				}
				if(dif >= mid){
					lb = mid; goto nxt;
				}
			}
			ub = mid; nxt:;
		}
		printf("%lld %lld\n",lb+b,c-lb);
	}
}


Measured memory_bytes: 1408
fn main() {
    let scan = std::io::stdin();

    let mut line = String::new();

    let _ = scan.read_line(&mut line);

    let n:i32 = line.trim().parse().unwrap();

    let ans : &str =  if n/10==9 || n%10==9 { "Yes" } else { "No" };
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}

ll n;
priority_queue<ll, vector<ll>, greater<ll> > v;
bool check(ll m)
{
    bool flag3 = false, flag5 = false, flag7 = false;
    while(m >= 1){
        int t = m % 10;
        m /= 10;
        if(t == 3) flag3 = true;
        else if(t == 5) flag5 = true;
        else if(t == 7) flag7 = true;
    }
    if(flag3 && flag5 && flag7){
        return true;
    }
    else return false;
}

void dfs(ll l)
{
    if(l >= 1e10){
        return;
    }
    if(check(l)){
        v.push(l);
    }
    dfs(10*l+3);
    dfs(10*l+5);
    dfs(10*l+7);
}

int main()
{
    int ans = 0;
    cin >> n;
    dfs(0);
    for(int i = 0; i < v.size(); i++){
        ll t = v.top();
        v.pop();
        if(t > n){
            break;
        }
        ans++;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>                                                                              
using namespace std;
int main()
{
  int A,B;
  cin >> A >> B;
  int min,max;
  if(A>B){
    max=A;
    min=B;
  }
  else{
    max=B;
    min=A;
  }
  int d=max-min;
  if(d%2==0)
    cout << max-d/2 << endl;
  else
    cout <<"IMPOSSIBLE" << endl;
}

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

using namespace std;
#define endl "\n"

const int MOD = 1000000007;
int main()
{
	int a, b , c, d;
	cin >> a >> b >> c >> d;
	
	if(a < b) cout << a*c << endl;
	else cout << (b*c)+(a-b)*d << endl; 
	
	
	
	return 0;
}

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

using namespace std;

const double EPS = 1e-7;
const int N = 20, M = 1e4+5, OO = 0x3f3f3f3f;

int mx, co, h1, h2, n;

int main(){
    cin >> n;
    while(n--)
    {
        h2 = h1;
        scanf("%d", &h1);
        if(h1 <= h2)
        {
            co++;
            mx = max(mx, co);
        }else
        {
            co = 0;
        }
    }
    printf("%d", mx);
    return 0;
}


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

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

    int n, k;
    cin >> n >> k;

    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll res = 1LL << 60;
    rep(i, 1<<n){

        if(i%2==0) continue;

        vector<int> use_idx(n, 0);
        int use_cnt = 0;
        rep(j, n){
            if(i & (1<<j)){
                use_idx[j] = 1;
                ++use_cnt;
            }
        }
        if(use_cnt != k) continue;

        ll sum = 0;
        ll mx = a[0];
        rep1(j, n){
            if(use_idx[j]){
                
                if(mx >= a[j]) {
                    sum += mx+1 - a[j];
                    ++mx;
                }
            }

            if(mx < a[j]) mx = a[j];
        }

        res = min(res, sum);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma optimize GCC("Ofast")
#pragma comment(linker, "/STACK:1073741824")

#include<iostream>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<deque>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<fstream>
#include<iterator>
#include<functional>
#include<bitset>
#include<memory>
#include<sstream>
#include<new>
#include<cassert>
#include<iomanip>

using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<bool, bool> pbb;
typedef pair<ld, ld> pdd;

const int inf = (int)1e9 + 9;
const ll linf = (ll) 1e18;
const ld eps = 1e-7;
const int mod = (int) 1e9 + 7;

#define it(v) v.begin(), v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define scn second
#define sgn(x) (x > 0 ? 1 : (x == 0 ? 0 : -1))

const int sz = 100;
vector<vector<char>> mat(sz, vector<char>(sz, '.'));
bool flag = false;
set<pii> mb;

void donut(int x, int y)
{
	if (y != 0 && x == 0)
	{
		mb.emplace(0, y - 1);
	}
	if (x != 0)
	{
		mb.emplace(x - 1, y);
	}
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			mat[y + i][x + j] = '#';
		}
	}
	mat[y + 1][x + 1] = '.';
}

void print()
{
	cout << "100 100\n";
	for (int i = 0; i < sz; i++)
	{
		for (int j = 0; j < sz; j++)
		{
			if (flag)
			{
				cout << (mat[i][j] == '#' ? '.' : '#');
			}
			else
			{
				cout << mat[i][j];
			}
		}
		cout << "\n";
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	srand(time(0));
	cin.tie(0);
	cout.tie(0);
	int a, b;
	cin >> a >> b;
	if (b > a)
	{
		swap(a, b);
		flag = true;
	}
	int y = 0, x = 0;
	for (int i = 0; i < a - 1; i++)
	{
		donut(x, y);
		x += 4;
		if (x >= sz)
		{
			x = 0;
			y += 4;
		}
	}
	if (a == b)
	{
		mat[99][99] = '#';
		print();
		return 0;
	}
	int cur = a - 1;
	while (cur != b)
	{
		pii kek = *mb.begin();
		mb.erase(kek);
		mat[kek.scn][kek.fst] = '#';
		cur--;
	}
	print();
}

Measured memory_bytes: 256
/* Mere paradesiyaan ki yahi hai nishaani
   Ankhiyaan bilor ki, shishe ki jawaani
*/
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define LOG1(a)			  cerr<< #a << " = " << (a) << "\n"
#define LOG2(a, b)		  cerr<< #a << " = " << (a) << ", " << #b << " = " << (b) << "\n"
#define endl "\n"

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

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;

int n, arr[nax];
int main()
{
    ios::sync_with_stdio(0);
    int n, a, b;
    cin >> n >> a >> b;
    int diff = abs(a - b);
    if(diff % 2 == 1) cout << "Borys";
    else cout << "Alice";
    return 0;
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
ans=[]
for i in range(n)[::-1]:
  for j in range(i+1)[::-1]:
    if l[j]==j+1:
      a=l.pop(j)
      ans.append(a)
      break
    if j==0 and l[j]!=1:
      break
if l!=[]:
  print(-1)
else:
  for i in range(n)[::-1]:
    print(ans[i])


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

int main(void) {

    int a, b;
    cin >> a >> b;
    cout << a*b << " " << a*2+b*2 << endl;

}


Measured memory_bytes: 3080
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

import heapq

n = int(input())
T = [[] for _ in range(n)]
for i in range(1, n):
  a = int(input())
  a -= 1
  T[a].append(i)

def dfs(v):
  if not T[v]:
    return 0
  L = []
  for i in T[v]:
    heapq.heappush(L, dfs(i)+1)
  temp = heapq.heappop(L)
  while L:
    temp = max(temp+1, heapq.heappop(L))
  return temp

ans = dfs(0)
print(ans)

Measured memory_bytes: 112664
#ABC79-C
box=input()
l=len(box)
for i in range(pow(2,(l-1))):
    num=box[0]
    for j in range(1,l): #1～(l-1)
        if (i>>(j-1))&1:
            num+="+"+box[j]
        else:
            num+="-"+box[j]
    if eval(num)==7:
        print(num+"=7")
        break

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;
string s;

int main() {
	cin >> n >> s;
	
	int h = 0, l = 0;
	inc(i, n) {
		if(s[i] == '(') { h++; } else { h--; }
		setmin(l, h);
	}
	
	if(l < 0) { inc(i, -l) { s.insert(0, "("); } }
	inc(i, h - l) { s += ")"; }
	
	cout << s << endl;
	
	return 0;
}


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

int n,h[200010],a[200010],bit[200010],dp[200010];

int maxv(int p)
{
	int s=0;
	while(p>0){
		s=max(s,bit[p]);
		p-=p&(-p);
	}
	return s;
}

void update(int p,int v)
{
	while(p<=n){
		bit[p]=max(bit[p],v); 
		p+=p&(-p);
	}
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++) bit[i]=-INF;
	for(int i=1;i<=n;i++) cin>>h[i];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	dp[1]=a[1];
	update(h[1],a[1]);
	for(int i=2;i<=n;i++){
		int mx=maxv(h[i]-1);
		dp[i]=mx+a[i];
		update(h[i],dp[i]);
		//cout<<dp[i]<<endl;
	}
	int ans=0;
	for(int i=1;i<=n;i++) ans=max(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
void printarr(vector<int>& op)
{
    for(int i=0;i<op.size();i++)
        cout<<op[i]<<" ";
}
int main()
{
  int n;
  cin>>n;
  int ele;
  vector<int>ip;
  for(int i=0;i<n;i++)
  {
   cin>>ele;
    ip.push_back(ele);
  }
  vector<int>op(n,0);
  op[1] = abs(ip[1]-ip[0]);
  for(int i=2;i<n;i++)
  {
   op[i] = min((op[i-1]+abs(ip[i]-ip[i-1])), (op[i-2]+abs(ip[i]-ip[i-2])));
  }
//   printarr(op);
  cout<<op[n-1]<<endl;
  
 return 0; 
}

Measured memory_bytes: 1144
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
typedef long long ll;
#define MYINF (1000007)

static int A[MYINF];
static int n;
static int cnt;
static int m;
static int G[128];

void insertion_sort(int g) {
	int i, j, v;
	for (i = g; i < n; i++) {
		v = A[i];
		j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j+g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j+g] = v;
	}
}

void shell_sort() {
	int i, j;

	cnt = 0;
	for (i = 0, j = n/2; i < 127 && j > 0; i++, j /= 2) {
		G[i] = j;
	}
	if (i == 0) {
		G[i] = 1;
		m = 1;
	} else {
		if (G[i-1] == 2) {
			G[i++] = 1;
		}
		m = i;
	}
	for (i = 0; i < m; i++) {
		insertion_sort(G[i]);
	}
}

int main(int argc, char **argv)
{
	int i;
	const char *sp = "";
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	shell_sort();
	printf("%d\n", m);
	for (i = 0; i < m; i++) {
		printf("%s%d", sp, G[i]);
		sp = " ";
	}
	putchar('\n');
	printf("%d\n", cnt);
	for (i = 0; i < n; i++) {
		printf("%d\n", A[i]);
	}

	return 0;
}

Measured memory_bytes: 4508
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=2010;
char mat[N][N];
int ext[N][N];
int stk[N];
int tol[N],tor[N];
int main(){
	int n=ni,m=ni;
	for(int i=1;i<=n;i++){
		scanf("%s",mat[i]+1);
	}
	memset(ext,0,sizeof(ext));
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<m;j++){
			ext[i][j]=i!=1&&(mat[i-1][j]^mat[i-1][j+1])==(mat[i][j]^mat[i][j+1])?ext[i-1][j]+1:1;
		}
		int ss=0;
		stk[0]=0;
		for(int j=1;j<m;j++){
			for(;ss&&ext[i][stk[ss]]>=ext[i][j];ss--);
			tol[j]=stk[ss]+1;
			stk[++ss]=j;
		}
		stk[ss=0]=m;
		for(int j=m-1;j>=1;j--){
			for(;ss&&ext[i][stk[ss]]>=ext[i][j];ss--);
			tor[j]=stk[ss];
			stk[++ss]=j;
		}
		for(int j=1;j<m;j++){
			apmax(ans,(tor[j]-tol[j]+1)*ext[i][j]);
		}
	}
	printf("%d\n",max(ans,max(n,m)));
	return 0;
}

Measured memory_bytes: 19968
import java.util.*;

public class Main {
    
  private static long dfs(String input,long sum,int index){
      if(index >= input.length()){
          return sum;
      }
      long total = 0;
      
      for(int i = index + 1;i <= input.length();i++){
          total += dfs(input,sum + Long.parseLong(input.substring(index,i)),i);
      }   
      
      return total;
  }
        
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String input = sc.next();    
    System.out.println(dfs(input,0,0));
  }  
    
}


Measured memory_bytes: 22996
#pragma GCC optimize("Ofast")
#include <stdio.h>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};
char ch[10];

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 8, stdin);
    if (ch[7] == '\n') {
        if (ch[0] == '3') {
            puti('4' - ch[2]);
        }
        else if (ch[0] == '2' && ch[1] == ' ') {
            puti(ch[2] - '0');
        }
        else
            puti(arr1[ch[0] - '0'][ch[6] - '0']);
    }
    else if (ch[6] == '9') {
        if (ch[0] == '6') {
            puti(22888);
        }
        else if (ch[0] == '9') {
            puti(25436);
        }
        else
            puti(arr1[ch[0] - '0'][ch[7] - '0']);
    }
    else
        puti(arr1[ch[0] - '0'][ch[7] - '0']);
    fputc('\n', stdout);
    return 0;
}

Measured memory_bytes: 1532
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    sumA = sum(A)
    
    ans = True
    for i in range(M):
        if (A[i] < sumA /(4*M)):
            ans = False

    if ans:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

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

int main(){
  int n,m; cin>>n>>m;
  vector<set<int>> s(m);
  for(int i=0; i<m; ++i){
    int k; cin>>k;
    for(int j=0; j<k; ++j){
      int ss; cin>>ss;
      s[i].insert(ss);
    }
  }
  vector<int> p(m);
  for(int i=0; i<m; ++i)cin>>p[i];

  int ans=0;
  for(int i=0; i<1<<n; ++i){
    vector<int> pp(m,0);
    for(int j=0; j<n; ++j){
      if(i>>j&1){
        for(int k=0; k<m; ++k){
          if(s[k].find(j+1)!=s[k].end())++pp[k];
        }
      }
    }

    bool fl=true;
    for(int j=0; j<m; ++j)if(pp[j]%2!=p[j])fl=false;
    if(fl)++ans;
  }

  cout<<ans<<endl;
}


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

using namespace std;

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

	vector<int> P;
	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		P.push_back(p);
	}

	vector<int> P_rev = P;
	sort(P_rev.begin(), P_rev.end());

	int count = 0;
	for (int i = 0; i < N; i++) {
		if (P[i] != P_rev[i]) {
			count++;
		}
	}
	if (count == 2 || count==0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}





Measured memory_bytes: 3596
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int t=26;


    char x;
    cin >> x;
    if (x > 90) {
        x -= 32;
        cout << "a";
    } else {
        x += 32;
        cout << "A";
    }
    cout<<endl;

}

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

int main() {
  long long x;
  long long ans;
  int fh, f;


  cin >> x;

  fh=x/500;
  f=x%500/5;

  //cout << fh<<" "<< f<< endl;

  ans = fh*1000 + f*5;

  cout << ans << endl;

  return 0;
}


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    int x;
    cin >> x;
    cout << 1000 * (x / 500) + 5 * (x % 500 / 5);

    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
x=[0]*n
s1=sum(a)
s2=0
for i in range(1,n-1,2):
  s2+=a[i]

x[0]=s1-s2*2

for i in range(1,n):
    x[i]=-x[i-1]+2*a[i-1]

x=[str(a) for a in x]
x=' '.join(x)
print(x)

Measured memory_bytes: 23960
//138 B - Resistors in Parallel 2019/08/18

#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    long double sum=0.0;
    rep(i,n){
        sum+=(long double)(1.0/a[i]);
    }
    cout << (long double)(1.0/sum) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
 
  int x,y,r,tmp;

  scanf("%d %d",&x,&y);
  if(x < y){
    tmp = x;
    x = y;
    y = tmp;
  }
 
  r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  printf("%d\n",y);
  return 0;
}

Measured memory_bytes: 592
#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#ifdef DEBUG
	#include "debug.hpp"
#endif

using namespace std;

#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back


#ifdef DEBUG
	#define debug(x...) {dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals);}
	#define light_debug(x) {dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0;}
#else
	#define debug(x...)
	#define light_debug(x) 
#endif


using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;


signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	#ifdef DEBUG
		freopen("debug", "w", stderr);
	#endif
		
	int n, m, k;
	cin >> n >> m >> k;
	ll A[n + 1], B[m + 1];
	A[0] = B[0] = 0;
	
	rep1(i, n){
		cin >> A[i];
		A[i] += A[i - 1];
	}

	rep1(i, m){
		cin >> B[i];
		B[i] += B[i - 1];
	}

	ll ans = 0;
	rep(i, n + 1){
		if(A[i] > k)
			break;
		ans = max(ans, i + (upper_bound(B, B + m + 1, k - A[i]) - B - 1LL));
	}

	cout << ans << '\n';

	#ifdef DEBUG
		dbg::dout << "\nExecution time: " << clock() << "ms\n";
	#endif

	return 0;
}


Measured memory_bytes: 6748
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

ans = 0
ans_1 = 0
n = inp()
initial_list = ['None']*n
for i in range(n):
    temp = np.array(inpl())
    initial_list[i] = temp

my_abs = lambda x:  math.sqrt((x[0]**2+x[1]**2))
for i in range(n):
    ans_1 += sum([my_abs(x-initial_list[i]) for x in initial_list[i:]])

ans = ans_1*2/float(n)
print(ans)

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

int main() {
  int count=0;
  int H,W;
  cin>>H>>W;
  vector<int>tate(H,0);
  vector<int>yoko(W,0);
  vector<vector<int>>hyou;
  hyou.resize(H);
  rep(i,H) hyou[i].resize(W);
  rep(i,H){
    rep(j,W){
      char x;
      cin>>x;
      if(x=='#')
        hyou[i][j]=1;
      else
        hyou[i][j]=0;
    }
  }
  rep(i,H){
    rep(j,W){
      tate[i]+=hyou[i][j];
    }
  }
  rep(i,W){
    rep(j,H){
      yoko[i]+=hyou[j][i];
    }
  }
  rep(i,H){
    rep(j,W){
      if(tate[i] and yoko[j]){
        if(hyou[i][j]){
          cout<<"#";
        }
        else cout<<".";
      }
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
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;};



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

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << a + b + c + d << endl;
  return 0;
}



Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};


vector<int> G[1<<17];

const int M_V=100001;
const int logV=21;

int parent[logV][M_V];
int depth[M_V];

void dfs(int v,int p,int d){
    parent[0][v]=p;
    depth[v]=d;
    for(int i=0;i<G[v].size();i++){
        if(G[v][i]!=p) dfs(G[v][i],v,d+1);
    }
}

void init(int V,int root){
    dfs(root,-1,0);
    for(int k=0;k<logV-1;k++){
        for(int v=0;v<V;v++){
            if(parent[k][v]<0) parent[k+1][v]=-1;
            else parent[k+1][v]=parent[k][parent[k][v]];
        }
    }
}

int lca(int u,int v){
    if(depth[u]>depth[v]) swap(u,v);
    for(int k=0;k<logV;k++){
        if((depth[v]-depth[u])>>k&1){
            v=parent[k][v];
        }
    }
    if(u==v) return u;
    for(int k=logV-1;k>=0;k--){
        if(parent[k][u]!=parent[k][v]){
            u=parent[k][u];
            v=parent[k][v];
        }
    }
    return parent[0][u];
}

int main(){
    int n;cin >> n;
    for (int i = 1; i < n; i++) {
        int p;cin>>p;p--;
        G[i].pb(p);
        G[p].pb(i);
    }
    init(n,0);
    priority_queue<pair<P,int>> q;
    LL ans = 0;
    int bv = 0;
    q.push(mp(mp(0,0),0));
    map<int,int> ma;
    int cnt = 0;
    while(!q.empty()){
        auto p = q.top();q.pop();
        int d = -p.first.first, par = ma[-p.first.second], v = -p.second;
        ans += depth[v] + depth[bv] - 2*depth[lca(v,bv)];
        ma[cnt] = v;
        for(auto g:G[v]){
            if(g==par) continue;
            q.push(mp(mp(-(d+1),-cnt),-g));
        }
        cnt++;
        bv = v;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 28828
package main

import "fmt"

func main() {
	var sTime, fTime, exists, eSTime, eFTime int

	fmt.Scan(&sTime, &fTime)
	fmt.Scan(&exists)

	var flag bool

	for i := 0; i < exists; i++ {
		fmt.Scan(&eSTime, &eFTime)

		if sTime > eSTime && sTime < eFTime {
			flag = true
		}
		if fTime > eSTime && fTime < eFTime {
			flag = true
		}
		if eSTime >= sTime && eFTime <= fTime {
			flag = true
		}
	}

	if flag {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}



Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int one[2];
    int two[2];
    cin >> one[0] >> one[1] >> two[0] >> two[1];

    int three[2], four[2];
    three[0] = two[0] - (two[1] - one[1]);
    three[1] = two[1] + (two[0] - one[0]);
    four[0] = three[0] - (two[0] - one[0]);
    four[1] = three[1] - (two[1] - one[1]);
    
    cout << three[0] << " " << three[1] << " " << four[0] << " " << four[1];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define Get(x,y) scanf("%I64d%I64d",&x,&y);
#define get(x) scanf("%I64d",&x);
#define Gett(x,y) scanf("%d%d",&x,&y);
#define gett(x) scanf("%d",&x);																																														
#define f(i,a,b) for(int i=a;i<b;i++)
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define print(v,r) f(i,0,r) cout<<v[i]<<" "; cout<<endl;
#define ll long long
#define pb push_back
#define maxm(a,b) a=max(a,b);
#define minm(a,b) a=min(a,b);
#define S second
#define F first
#define mp make_pair
const int N=3e5+20;
ll n,m,yk=1,doo=2;
int main(){
	cin>>n>>m;
	cout<<((n*(n-yk))+(m*(m-yk)))/doo;
}

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	N := nextInt(sc)
	H := make([]int, N)
	for i := range H {
		H[i] = nextInt(sc)
	}
	maxH := H[len(H)-1]
	for i := len(H) - 2; i >= 0; i-- {
		if H[i] <= maxH {
			maxH = H[i]
		} else if H[i]-1 == maxH {
			H[i]--
			maxH = H[i]
		} else {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 3072
h,w=map(int,input().split())
dp=[[0]*w for i in range(h)]
s=[input()for i in range(h)]
if s[0][0]=="#":
    dp[0][0]=1
for i in range(1,w):
    if s[0][i]=="#" and s[0][i-1]==".":
            dp[0][i]=dp[0][i-1]+1
    else:
        dp[0][i]=dp[0][i-1]
for i in range(1,h):
    for j in range(w):
        if j==0:
            if s[i][j]=="#" and s[i-1][j]==".":
                dp[i][j]=dp[i-1][j]+1
            else:
                dp[i][j]=dp[i-1][j]
            continue
        if s[i][j]=="#":
            p,q=0,0
            if s[i-1][j]=="#":
                p=1
            if s[i][j-1]=="#":
                q=1
            dp[i][j]=min(dp[i-1][j]-p,dp[i][j-1]-q)+1
        else:
            dp[i][j]=min(dp[i-1][j],dp[i][j-1])
print(dp[-1][-1])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n,k;
  cin >> n >> k;
  int memo,qw;
  rep(i,0,n) {
    cin >> qw;
    if(qw == 1) memo = i;
    break;
  }
  int ans = 0;
  
  if( (n-memo-1)%(k-1) == 0 ) ans += (n-memo-1)/(k-1);
  else {
    ans += (n-memo-1)/(k-1) + 1;
    memo -= (n-memo-1)%(k-1);
  }
  
  if(memo <= 0) ;
  else if( memo%(k-1) == 0 ) ans += memo/(k-1);
  else ans += memo/(k-1) + 1;
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define fur(i,x,y) for(i=x;i<=y;i++)
#define fdr(i,x,y) for(i=x;i>=y;i--)
#define Fur(i,x,y) for(ll i=x;i<=y;i++)
#define Fdr(x,y) for(ll i=x;i>=y;i--)
#define in2(x,y) in(x);in(y)
#define in3(x,y,z) in2(x,y);in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define clr(x,y) memset(x,y,sizeof(x))
#define cpy(x,y) memcpy(x,y,sizeof(x))
#define fl(i,x) for(ll i=head[x],to;to=e[i].to,i;i=e[i].next)
#define inf 233333333
using namespace std;
/*---------------------------------------*/
namespace fib{char b[300000]= {},*f=b;}
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
inline void in(ll &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
struct foce{~foce(){pob;fflush(stdout);}} _foce;
namespace ib{char b[100];}
inline void out(ll x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}
inline void outn(ll x){out(x);pc('\n');}
inline void swap(ll &x,ll &y){ll t=x;x=y;y=t;}
inline ll jdz(ll x){return x>=0?x:-x;}
/*------------------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------------------------*/
#define N 55555
ll k[N+1],n,d=0;
bool b[N+1];
int main(){
	in(n);
	Fur(i,2,N)
	if(!b[i]){
		if(i%10==1)k[++d]=i;
		for(ll x=i*2;x<=N;x+=i)b[x]=1;
	}
	Fur(i,1,n)out(k[i]),pc(' ');pc('\n');
}

/*

*/

Measured memory_bytes: 256
n,k = map(int,input().split())
import math
if k%2!=0:
    count = 0
    i = 1
    check = True
    while check:
        if n < k * i:
            check = False
        else:
            count += 1
            i += 1
    print(int(count**2*count))
elif k%2==0:
    count = 0
    i = 1
    check = True
    while check:
        if n < (k/2) * i:
            check = False
        else:
            count += 1
            i += 1
    if count%2!=0:
        ans_1 = math.ceil(count/2)
        ans_2 = math.ceil(count/2)-1
        print(int(ans_1**2*ans_1+ans_2**2*ans_2))
    elif count%2==0:
        ans = count/2
        print(int(ans**2*ans)*2)

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

int main(){
long int A, V, B, W, T;
cin >> A >> V >> B >> W >> T;

long int tumeru = (V-W)*T;
long int genzai;
  if(A > B){
    genzai = A-B;
  }
  else{
    genzai = B-A;
  }

if(A == B){
  cout << "YES" << endl;
}
  else if(tumeru >= genzai){
    cout << "YES" << endl;
  }
  
  else{
    cout << "NO" << endl;
  }
    
 return 0;
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int a, b, h;
    cin >> a >> b >> h;

    cout << (a+b)*h/2 << endl;

    return 0;
}



Measured memory_bytes: 256
s = input()
n = len(s)

ans = 0

for i in range(2**(n-1)):
  f = s[0]
  for j in range(n-1):
    if i & (1<<j):
      f += '+'
    f += s[j+1]
    
  ans += sum(map(int, f.split('+')))
  
print(ans)

Measured memory_bytes: 9168
n=int(input())
x=list(map(int,input().split()))
ave=0
for i in range(n):
  ave+=x[i]
ave//=n
ave2=ave+1
ans1=0
ans2=0
for i in range(n):
  ans1+=(x[i]-ave)**2
  ans2+=(x[i]-ave2)**2
print(min(ans1,ans2))

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   int a,b,i,j;
   while(1){
   scanf("%d%d",&a,&b);
   if(a==0 && b==0)
    break;
   for(i=0;i<a;i++)
   {
       for(j=0;j<b;j++)
       {

        printf("#");
       }
       printf("\n");
   }
   printf("\n");

   }



}



Measured memory_bytes: 2128
#include <iostream>

using namespace std;
using ll = long long;

int main() {
	int A, B;
	cin >> A >> B;

	int mul = min(A, B);
	int div = max(A, B);
	ll ans = mul;
	while (true) {
		ans += mul;
		if (ans % div == 0) {
			cout << ans << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3564
import math

#数値ひとつ
#I = int(input())
#数値空白区切りで欲しいとき
#A, B, N = map(int, input().split())
#文字欲しいとき
N = input()
#それをListにしたいとき
#list = list(N)
#数値を受け取る数が未定かつリストにしたいとき
#list = list(map(int, input().split()))
#受け取る文字列が未定かつリストにしたいとき(Iは回数)
#list = [input() for i in range(I)]
#list初期化
#list = []

if N == "ABC":
    print("ARC")
else:
    print("ABC")


Measured memory_bytes: 9104
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	int a, b, c, d; CI a >> b >> c >> d;

	if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))CO "Yes" EN;
	else CO "No" EN;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); ++i)
using namespace std;
int main()
{
	int N; cin >> N;
	vector<int> A(N), B(N), C(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	rep(i, N) cin >> C[i];
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());
	ll ans = 0;
	rep(i, N) {
		int a = lower_bound(A.begin(), A.end(), B[i]) - A.begin();	//a<bの数
		int c = C.end() - upper_bound(C.begin(), C.end(), B[i]);	//c>bの数
		ans += (ll)a * c;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3992
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    ll n, m, sum = 0;
    cin >> n >> m;
    ll a[n];
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a + n);
    if(a[n-m] < sum  / (4.0 * m)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	ll n; cin>>n;
	vl v(1e7);
	for(ll i=1;i*i<=n;i++){
		for(ll j=1;j*j<=n;j++){
			for(ll k=1;k*k<=n;k++){
				ll h=(i+j+k);
				h*=h;
				h-=(i*j)+(j*k)+(i*k);
				if(h<=n)v[h]++;
			}
		}
	}
	rep(i,1,n+1){
		cout<<v[i]<<endl;
	}
				
	
	return 0;
}

Measured memory_bytes: 81336
grid = [[0 for i in xrange(3)] for j in xrange(3)]
for i in xrange(3):
    grid[i] = map(int, raw_input().strip().split())

ans = [[0 for i in xrange(3)] for j in xrange(3)]

q = input()
for _ in xrange(q):
    num = input()
    for i in xrange(3):
        for j in xrange(3):
            if grid[i][j] == num:
                ans[i][j] = 1

yes = "No"
for i in xrange(3):
    if ans[i] == [1, 1, 1]:
        yes = "Yes"

for i in xrange(3):
    if [ans[j][i] for j in xrange(3)] == [1, 1, 1]:
        yes = "Yes"

if [ans[i][i] for i in xrange(3)] == [1, 1, 1]:
    yes = "Yes"

if [ans[2][0], ans[1][1], ans[0][2]] == [1, 1, 1]:
    yes = "Yes"

print yes
        
    
    


Measured memory_bytes: 28524
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n;
   string s, first, second;
   cin >> n;
   cin >> s;
   
   for(int i = 0; i < n; ++i){
     
     if (i < (n / 2)) {
       
       first += s[i];
     } else {
       second += s[i];
     }
   }
   
   if (first == second) {
       cout << "Yes" << endl;
   } else {
       cout << "No" << endl;
   }
   
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


class BipartiteMatching:
    def __init__(self, N, M):
        self.N = N
        self.M = M
        self.pairA = [-1] * N
        self.pairB = [-1] * M
        self.edge = [[] for _ in range(N)]
        self.was = [0] * N
        self.iter = 0

    def add(self, s, t):
        self.edge[s].append(t)

    def _DFS(self, s):
        self.was[s] = self.iter
        for t in self.edge[s]:
            if self.pairB[t] == -1:
                self.pairA[s] = t
                self.pairB[t] = s
                return True
        for t in self.edge[s]:
            if self.was[self.pairB[t]] != self.iter and self._DFS(self.pairB[t]):
                self.pairA[s] = t
                self.pairB[t] = s
                return True
        return False

    def solve(self):
        res = 0
        while True:
            self.iter += 1
            found = 0
            for i in range(self.N):
                if self.pairA[i] == -1 and self._DFS(i):
                    found += 1
            if not found:
                break
            res += found
        return res


def inp(num):
    it = (num + 9) // 10
    res = []
    for _ in range(it):
        res.extend(list(map(int, input().split())))
    return res


if __name__ == "__main__":
    ans = []
    while True:
        M, N = map(int, input().split())
        if M == 0 and N == 0:
            break
        match = BipartiteMatching(M, N)
        Blue = inp(M)
        Red = inp(N)
        for i, b in enumerate(Blue):
            for j, r in enumerate(Red):
                if gcd(b, r) != 1:
                    match.add(i, j)
        ans.append(match.solve())

    print(*ans, sep="\n")



Measured memory_bytes: 8956
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	P[] tre=new P[1001];
	public P move(P p){
		return p.a(P.Xunit.rotate(p.arg()+Math.PI/2));
	}

	public void run() {
		tre[1]=P.Xunit;
		for(int i=2;i<=1000;i++){
			tre[i]=move(tre[i-1]);
		}

		while(sc.hasNext()){
			int n=sc.nextInt();
			if(n==-1)break;
			ln(tre[n].x);
			ln(tre[n].y);
		}

	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}
class P {
	double x;
	double y;
	P(double _x,double _y){
		x=_x;
		y=_y;
	}

	public static  final P Xunit=new P(1,0);
	public static  final P Yunit=new P(0,1);

	public static double dot(P a,P b){
			return a.x*b.x+a.y*b.y;
	}
	public static  double cross(P a,P b){
		return a.x*b.y-a.y*b.x;
	}
	public static boolean isParallel(P a1,P a2,P b1,P b2){
		return Math.abs(cross(a2.s(a1),b2.s(b1)))<Double.MIN_NORMAL;
	}
	public static boolean isVertical(P a1,P a2,P b1,P b2){
		return Math.abs(dot(a2.s(a1),b2.s(b1)))<Double.MIN_NORMAL;
	}

	public P a(P a){
		return new P(x+a.x,y+a.y);
	}
	public P s(P a){
		return new P(x-a.x,y-a.y);
	}

	public double norm(){
		return Math.sqrt(x*x+y*y);
	}

	public double arg(){
		double s=Math.acos(x/norm());
		return y>0?s:2*Math.PI-s;
	}

	public P rotate(double t){
		return new P(Math.cos(t)*this.x-Math.sin(t)*this.y,Math.sin(t)*this.x+Math.cos(t)*this.y);
	}

	public static int ccw(P a,P b,P c){
		if(P.cross(b.s(a),c.s(a))>Double.MIN_NORMAL){
			return 1;
		}
		if(P.cross(b.s(a),c.s(a))<-Double.MIN_NORMAL){
			return -1;
		}
		if(P.dot(b,c)<-Double.MIN_NORMAL)return 2;
		if(b.norm()<c.norm()-Double.MIN_NORMAL)return -2;
		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof P){
			P p=(P)obj;
			return x==p.x && y==p.y;
		}
		return false;
	}
	public String toString(){
		return "("+x+","+y+")";
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;

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

    if ((a*b) % 2 == 0) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    vector<ll> num(N);
  	ll sos[26]={1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
    for(int i=0;i<N;i++){
        string s;
        cin >> s;
        ll sum=1;
        for(int j=0;j<10;j++){
            sum=sum*sos[s[j]-'a'];
        }
        num[i]=sum;
    }
    sort(num.begin(),num.end());
    ll ans=0;
    ll cou=0;
    for(int i=1;i<N;i++){
        if(num[i]==num[i-1])cou++;
        if(num[i]!=num[i-1] || i==N-1){
            ans+=cou*(cou+1)/2;
            cou=0;
        }
    }
    cout << ans;


}

/*



 */



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

using namespace std;

int main() {
    vector<string> s(3);
    for (int i = 0; i < 3; ++i)
        cin >> s[i];

    for (int i = 0; i < 3; ++i)
        cout << s[i][i];
    cout << '\n';
}


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

using namespace std;

#define ll long long

const int mod  = 1e9 + 7;
const int INF = 1e9;

void solve(){

    int n, x, t;
    cin >> n >> x >> t;

    cout << t * (n / x + ((n % x) ? 1 : 0)) << "\n";

    return;
}


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

	return 0;
}



Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

int main() {
  int n;
  while(cin >> n, n) {
    vector<int> v(n);
    REP(i,n)
      cin >> v[i];
    int a;
    cin >> a;

    sort(ALL(v));
    int lb = 0, ub = n - 1;
    int res = 0;
    while(ub-lb>=0) { // ツつアツつアツづ債適ツ督鳴づ可。
      int mid = (lb+ub)/2;
      //cout << mid << endl;
      ++res;
      if (v[mid] < a) lb = mid + 1; 
      else if (v[mid] > a) ub = mid - 1;
      else break;
    }
    // if (v[lb] != a)
    //   ++res;
    cout << res << endl;
  }
}

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

int main()
{
	int N;

	cin >> N;

	int d[100];

	for (int i = 0; i < N; i++)
	{
		cin >> d[i];
	}
	
	int a = 0;

	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			a = a + d[i] * d[j];
		}
	}

	cout << a;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#define ll long long
using namespace std;

int main() {
	ll n, r, b;
	char s[300];
	cin >> n;
	scanf("%s", s);
	r = 0;
	b = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R')r++;
		else b++;
	}
	if (r > b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256