akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <stdio.h>

using namespace std;

struct Node {
  int key;
  Node *prev, *next;
};

Node *nil;

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  // x
  x->key = key;
  x->next = nil->next;
  x->prev = nil;
  // xの次
  nil->next->prev = x;
  // nilの次
  nil->next = x;
}

void deleteNode(Node *t) {
  // tが番兵の場合は処理しない
  if (t == nil) {
    return;
  }
  // tの前
  t->prev->next = t->next;
  // tの次
  t->next->prev = t->prev;
  // 解放
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void printList() {
  Node *cur = nil->next;
  while(cur != nil) {
    cout << cur->key;
    if (cur->next != nil) {
      cout << " ";
    }
    cur = cur->next;

  }
  cout << endl;
}

int main() {
  init();
  int n;
  cin >> n;
  for (int i = 0; i < n; i ++) {
    char command[20];
    int key;
    scanf("%s", command);
    if (command[0] == 'i') {
      scanf("%d", &key);
      insert(key);
    } else if (command[0] == 'd' && strlen(command) == 6) {
      scanf("%d", &key);
      deleteKey(key);
    } else if (command[0] == 'd' && command[6] == 'F') {
      deleteFirst();
    } else if (command[0] == 'd' && command[6] == 'L') {
      deleteLast();
    }
  }
  printList();
}



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

int *createList(int num)
{
	int i, *list = new int[num];
	for (i = 0; i < num; i++)
		cin >> list[i];
	return list;
}

void traceList(int num, int *list)
{
	int i;
	for (i = 0; i < num - 1; i++)
		cout << list[i] << " ";
	cout << list[num - 1] << endl;
}

void insertionSort(int num, int *list)
{
	int i, j, key;

	for (j = 1; j < num; j++)
	{
		traceList(num, list);
		
		key = list[j];
		i = j - 1;
		while (i >= 0 && list[i] > key)
		{
			list[i + 1] = list[i];
			i -= 1;
		}
		list[i + 1] = key;
	}
	traceList(num, list);
}

int main()
{
	int num, *list;
	cin >> num;
	list = createList(num);
	insertionSort(num, list);
	delete [] list;
	return 0;
}

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++){
    cin >> L[i];
  }
  int cnt = 1;
  int len = 0;
  for (int i = 0; i < N; i++){
    len += L[i];
    if (len > X)
    break;
    cnt += 1;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
	let mut S = vec!();
	let mut T = vec!();

	let N = read_line().parse::<i32>().unwrap();

	for _ in (0..N) {
		S.push(read_line());
	}

	let M = read_line().parse::<i32>().unwrap();

	for _ in (0..M) {
		T.push(read_line());
	}

	let mut ans:i32 = 0;
	for j in S.iter() {
		let mut c:i32 = 0;
		let s = S.iter().filter(|i|*i == j).count() as i32;
		let t = T.iter().filter(|i|*i == j).count() as i32;
		c+=s;
		c-=t;
		if c > ans {
			ans = c;
		}
	}
	println!("{}",ans);
}


Measured memory_bytes: 4352
# coding: utf-8
def check(s):
    flag = True
    for i in range(len(s)//2):
        # print(s[i], s[-i-1])
        if s[i] != s[-i-1]:
            flag = False
    return flag
S = input()
if len(S) == 3:
    if S[0] != S[-1]:
        print("No")
    else:
        print("Yes")
    exit()
flag = True
if not check(S):
    flag = False
# print(check(S))
# if len(S) % 2 == 1:
#     cnt += 1
# if S[:len(S)//2] != S[len(S)//2 + cnt:]:
#     flag = False
# print(S[:len(S)//2], S[len(S)//2+1:])
s = S[:len(S)//2]
# print(check(s))
if not check(s):
    flag = False
# print(s)
# if s[:len(s)//2] != s[len(s)//2 + cnt:]:
#     flag = False
s = S[(len(S)+3)//2-1:]
# print(check(s))
# print(s)
if not check(s):
    flag = False
# print(s)
# if s[:len(s)//2] != s[len(s)//2 + cnt:]:
#     flag = False
# print(s[:len(s)//2], s[len(s)//2-cnt:])
print("Yes" if flag else "No")

Measured memory_bytes: 3064
var n,m,i,j,k,sum,now,a,b,c,d : longint ;
    cc,yo : array [0..1000001] of longint ;
    so,s1,s2 : ansistring ;
begin
 readln(n,a,b);
 for i:=1 to n do
  begin
   c:=i;
   now:=0;
   while c>0 do
    begin
     inc(now,c mod 10);
     c:=c div 10;
    end;
   if (now>=a)and(now<=b) then
    inc(sum,i);

 
  end;
 writeln(sum);
end.


Measured memory_bytes: 128
import sys
n,d = map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if((10000*i+5000*j+1000*(n-i-j))==d):
            print(str(i)+" "+str(j)+" "+str(n-i-j))
            sys.exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
    int H, W;
    while(cin >> H >>W)
    {
        if (!H && !W)
            break;
        
        int i = H;
        while (i--)
        {
            int j = W;
            while (j--)
            {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3088
import sys
sys.setrecursionlimit(4100000)
N = int(input())
tree = [[] for _ in range(N+1) ]
already_make = [-1]*(N+1)
for i in range(1,N):
    a,b = map(int,input().split(' '))
    tree[a].append([b,i])

last_color = 0
#bfs_use_coler = [[ -1 for _ in range(N+1) ] for _ in range(N+1) ] 

def solve_bfs(previous_colors,n_list,last_color):
    '''
    use_colers =[]
    for val in bfs_use_coler[0:n-2]:
        use_colers = use_colers + val
    '''
    next_colors = []
    next_n_list =[]
    for idx1,n in enumerate(n_list):
        use_color_num = 1
        for idx2,val in enumerate(tree[n]):
            if use_color_num == previous_colors[idx1]:
                use_color_num += 1
            already_make[val[1]] = use_color_num
            next_colors.append(use_color_num)
            next_n_list.append(val[0])
            last_color = max(use_color_num,last_color)
            use_color_num += 1
    if len(next_colors) > 0:
        return solve_bfs(next_colors,next_n_list,last_color)
    else:
        return last_color

last_color = solve_bfs([0],[1],last_color)
print(last_color)
for val in already_make[1:N]:
    print(val)

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

using namespace std;


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

const int MOD = 1000000007;



int main(){
    int n;   cin >> n;
    string s;   cin >> s;
    int a[s.size()];
    rep(i,s.size()) {
        s[i] = (s[i]+n);
        if(s[i]>=91) s[i] = s[i]%91+65;
        }
    cout << s << endl;
    
    


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define DBG(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define EN cout<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 200005
template<class T> ostream& operator<<(ostream &s,pair<T,ll> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}
int main()
{
    fastread;
    ll T=1;
//    cin>>T;
    for(ll qq=1;qq<=T; qq++)
    {
        ll n;
        cin>>n;
        vii ed;
        if(n%2)
        {
            for(int i=1;i<n;i++)
            {
                for(int j=i+1;j<=n;j++)
                {
                    if(j==n-i)continue;
                    ed.push_back(ii(i,j));
                }
            }
        }
        else
        {
            for(int i=2;i<n;i++)ed.push_back(ii(1,i)),ed.push_back(ii(i,n));
            for(int i=2;i<n;i++)
            {
                for(int j=i+1;j<n;j++)
                {
                    if(j==n-i+1)continue;
                    ed.push_back(ii(i,j));
                }
            }
        }
        cout<<ed.size()<<endl;
        for(auto x:ed)cout<<x.fi<<' '<<x.se<<endl;
    }
}

Measured memory_bytes: 512
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
string s;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>s;
	for(char ch: s)
	{
	    if(ch=='9')
	    {
	        cout<<"Yes";
	        return 0;
	    }
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
# import numpy as np
from collections import deque
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


N = _i()

move_in = [[[] for i in range(N)] for j in range(N)]
move_out = [[[] for i in range(N)] for j in range(N)]
cost = [[0] * N for _ in range(N)]
start_pair = []
for i in range(N):
    a_list = _li_()
    start_pair.append(a_list[0])
    for j in range(N-2):
        start = [min(i, a_list[j]), max(i, a_list[j])]
        end = [min(i, a_list[j+1]), max(i, a_list[j+1])]
        move_in[end[0]][end[1]].append((start[0], start[1]))
        move_out[start[0]][start[1]].append((end[0], end[1]))

count = 0
stack = deque([])
for i in range(N):
    pair = start_pair[i]
    if i < pair and i == start_pair[pair]:
        stack.append((i, start_pair[i]))
        cost[i][start_pair[i]] = 1
        count += 1


ans = 0
while stack:
    cand = stack.pop()
    for dest in move_out[cand[0]][cand[1]]:
        cost[dest[0]][dest[1]] = max(cost[dest[0]][dest[1]],
                                     cost[cand[0]][cand[1]] + 1)
        in_list = move_in[dest[0]][dest[1]]
        if in_list[0] == cand:
            del in_list[0]
        else:
            del in_list[1]
        if len(in_list) == 0:
            count += 1
            if len(move_out[dest[0]][dest[1]]) == 0:
                ans = max(ans, cost[dest[0]][dest[1]])
            else:
                stack.append(dest)

if count == (N * (N-1) // 2):
    print(ans)
else:
    print(-1)


Measured memory_bytes: 225180
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<long long> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}

  
double dp[301][301][301];
 
double findAnswer(int one, int two, int three, int n) {
	if((one < 0 || two < 0 || three < 0) || (one == 0 && two == 0 && three == 0))
		return 0;
	if(dp[one][two][three] > 0)
		return dp[one][two][three];
	return dp[one][two][three] = (n + one * findAnswer(one - 1, two, three, n) + two * findAnswer(one + 1, two - 1, three, n) + three * findAnswer(one, two + 1, three - 1, n)) / (one + two + three);
}
 
void solve() {
	int n, ele, ones = 0, twos = 0, threes = 0;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> ele;
		if(ele == 1)
			ones++;
		else if(ele == 2)
			twos++;
		else 
			threes++;
	}
	memset(dp, -1.0, sizeof(dp));
	cout << fixed << setprecision(14) << findAnswer(ones, twos, threes, n);
} 
int main()
 {  fast();
	solve();
 }
   
   

Measured memory_bytes: 213376
u,s,e,w,n,d=map(int,input().split())
a=[i for i in input()]
for i in a:
    if i=='N':
        n,d,s,u=u,n,d,s
    elif i=='S':
        s,d,n,u=u,s,d,n
    elif i=='E':
        e,d,w,u=u,e,d,w
    elif i=='W':
        w,d,e,u=u,w,d,e
print(u)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
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;}
//******************************************************************************
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}


signed main()
{
	//IOS();
	int N,M;
	cin>>N>>M;
	vector<int>a(N);
	int ans = 0;
	rep(i,0,N){
		cin>>a[i];
		if(i){
			if(a[i-1]<a[i])ans+=a[i]-a[i-1];
			else ans+=a[i]+M-a[i-1];
		}
	}
	vector<int>sum(M*2+10,0);
	vector<int>imos(M*2+10,0);
	rep(i,0,N-1){
		if(a[i]>a[i+1]){
			sum[a[i+1]+M]+=a[i+1]+M-a[i]-1;
			imos[a[i]+2]++;
			imos[a[i+1]+M+1]--;
		}else{
			sum[a[i+1]]+=a[i+1]-a[i]-1;
			imos[a[i]+2]++;
			imos[a[i+1]+1]--;
		}
	}
	rep(i,0,M*2){
		imos[i+1]+=imos[i];
	}
	vector<int>cnt(M*2+10,0);
	int ma = 0;
	rrep(i,0,imos.size()){
		cnt[i%M]+=sum[i];
		if(i)sum[i-1]+=sum[i]-imos[i];
		chmax(ma,cnt[i%M]);
	}
	cout<<ans-ma<<endl;
}


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

#define ll long long
#define pb push_back
#define mkp make_pair

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
        cout.tie(0);
	string s,t;
	cin>>s>>t;
	int count=0;
	for(int i=0;i<s.size();++i)
	{
		if(s[i]!=t[i])
			count++;
	}
	cout<<count<<'\n';
}


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

const int MAXN = 2000010;
int n, m, K;
char s1[MAXN], s2[MAXN];
int st[MAXN], top, li[MAXN], bak;
int main() {
	memset(s1, 48, sizeof s1);
	memset(s2, 48, sizeof s2);
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> m >> K >> s1 >> s2;
	std::reverse(s1, s1 + n); std::reverse(s2, s2 + m);
	s1[n] = s2[m] = '0';
	const int up = std::max(n, m);
	for (int i = up - 1; ~i; --i) {
		if (s1[i] == '1' && s2[i] == '1') {
			bak = 0;
			int n1 = 1, n2 = 1, now = i + 1, rest = K - 1;
			s1[i] = s2[i] = '0';
			while (top) {
				int t = st[top];
				if ((n1 != 1 || n2 != 1) && t != now) break;
				if (t - now <= rest) {
					--top;
					rest -= t - now; now = t;
					n1 += s1[now] & 1;
					n2 += s2[now] & 1;
					s1[now] = (n1 & 1) + '0';
					s2[now] = (n2 & 1) + '0';
					if (s1[now] != '1' || s2[now] != '1') {
						if (s1[now] || s2[now]) li[++bak] = now;
						++now;
						n1 >>= 1, n2 >>= 1;
					} else s1[now] = s2[now] = '0';
				} else break;
			}
			if (n1 != 0 || n2 != 0) {
				if (n1 == 1 && n2 == 1) now += rest;
				s1[now] = n1 + '0', s2[now] = n2 + '0';
				if (s1[now] != '1' || s2[now] != '1')
					st[++top] = now;
			}
			while (bak) st[++top] = li[bak--];
		} else if (s1[i] != '0' || s2[i] != '0') st[++top] = i;
	}
	int cur;
	cur = up + K + 1; while (s1[cur - 1] == 48) --cur;
	s1[cur] = 0; std::reverse(s1, s1 + cur);
	cur = up + K + 1; while (s2[cur - 1] == 48) --cur;
	s2[cur] = 0; std::reverse(s2, s2 + cur);
	std::cout << s1 << '\n' << s2 << '\n';
	return 0;
}


Measured memory_bytes: 15616
import fractions
from functools import reduce

def gcd_list(numbers):
  return reduce(fractions.gcd, numbers)

n,x = map(int, input().split())
a = list(map(int, input().split()))

if n == 1:
  print(abs(x-a[0]))
  exit()
  
b = []
for i in range(1,n):
  b.append(a[i]-a[i-1])
b.append(abs(a[0]-x))
print(gcd_list(b))



  

Measured memory_bytes: 16276
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  int count2 = 0;
  for (int i = 0; i < 4; i++) {
    int count = 0;
    for (int j = 0; j < 4; j++){
      if (S.at(i) == S.at(j)) {
        count++;
      }
    }
    if (count != 2) {
      cout << "No" << endl;
      count2++;
      break;
    }
  }

  if (count2 == 0){
    cout << "Yes" << endl;
  }
}

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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
//#define int long long
//#define double long double

bool vis[200001];
int n, val[200001], ans[200001], len;
vector<int> edge[200001];
vector<stack<int>> lis;

void dfs(int d)
{
    vis[d] = true;

    int l = 0, r = len + 1;
    while (l != r)
    {
        int m = (l + r) / 2;
        if (m >= len)
            r = m;
        else if (lis[m].top() < val[d])
            l = m + 1;
        else
            r = m;
    }

    bool pp = false;
    if (r == len)
        len++, pp = true;
    lis[r].push(val[d]);
    ans[d] = len;

    for (int i : edge[d])
        if (!vis[i])
            dfs(i);

    lis[r].pop();
    if (pp)
        len--;
}

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

    cin >> n, lis.resize(n);
    for (int i = 1; i <= n; i++)
        cin >> val[i];

    int a, b;
    for (int i = 1; i < n; i++)
        cin >> a >> b, edge[a].push_back(b), edge[b].push_back(a);
    dfs(1);

    for (int i = 1; i <= n; i++)
        cout << ans[i] << '\n';

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, m, cnt[maxn];
bool ans[maxn];

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

	cin >> n >> m;
	fill(cnt, cnt + n, 1);
	ans[0] = true;
	for (int i = 0; i < m; i++)
	{
		int x, y;
		cin >> x >> y;
		x--, y--;
		ans[y] |= ans[x];
		cnt[x]--;
		cnt[y]++;
		if (!cnt[x])
			ans[x] = false;
	}
	int tally = 0;
	for (int i = 0; i < n; i++)
		tally += ans[i];
	cout << tally << endl;
}



Measured memory_bytes: 768
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = i; j < n; j++) {
      sum += a[j]; 
      v.push_back(sum);
    }
  }
  sort(v.rbegin(), v.rend());
  int ans = 0;
  for (int b = 61; b >= 0; b--) {
    if ((v[0] & (int)pow(2, b)) == 0) {
      continue;
    }
    if ((v[k - 1] & (int)pow(2, b)) == 0) {
      int nt = (int) pow(2, 62) - 1 - (int) pow(2, b);
      for (int i = 0; i < sz(v); i++) {
        v[i] &= nt;
      }
      sort(v.rbegin(), v.rend());
    } else {
      ans += (int) pow(2, b);
    }
  }
  cout << ans << "\n";
}



Measured memory_bytes: 5744
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int n,m,query,l[200000],r[200000],p[100000],q[100000],arr[501][501]={0},i,j,k,ans;

    scanf("%d %d %d",&n,&m,&query);
    for ( i = 0; i < m; i++)
    {
        scanf("%d %d",l+i,r+i);
        arr[l[i]][r[i]]++;
    }
    for ( j = 0; j < query; j++)
    {
        scanf("%d %d",p+j,q+j);
    }

    for ( i = 0; i <= 500; i++)
    {
        for ( j = 1; j <= 500 ; j++)
        {
            arr[i][j]+=arr[i][j-1];
        }
    }

    for ( k = 0; k < query; k++)
    {
        ans=0;
        for ( i = p[k]; i <= q[k]; i++)
        {
            ans+=arr[i][q[k]]-arr[i][p[k]-1];
        }
        printf("%d\n",ans);
    }

    return 0;
}

Measured memory_bytes: 4224
#include<stdio.h>
int main(void)
{
   int a,b,d,r;
   double f;
   scanf("%d %d",&a,&b);
   d=a/b;
   r=a%b;
   f=(double)a/(double)b;
   printf("%d %d %lf\n",d,r,f);
   return 0;
}

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

"""
input:
aabaaa
aa

output:
0
3
4
"""

import sys


class NaiveStringSearch(object):
    __slots__ = ('target', 'pattern')

    def __init__(self, in_data):
        """"""
        self.target, self.pattern = map(lambda x: x.strip(), _input)

    def brute_force(self):
        m, n = len(self.pattern), len(self.target)
        for i in range(n - m + 1):
            for j in range(m):
                if self.target[i + j] != self.pattern[j]:
                    break
                if j == m - 1:
                    print(i)
        return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    case = NaiveStringSearch(in_data=_input)
    case.brute_force()

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

int main() {
    ll N, M; cin >> N >> M;
    vector<bool>s(N), g(N);
    int a, b;
    for (int i = 0; i < N; i++){
        s[i] = false; g[i] = false;
    }
    for (ll i = 0; i < M; i++){
        cin >> a >> b;
        if (a == 1) {
            s[b-1] = true;
        }
        else if (b == 1) {
            s[a-1] = true;
        }
        else if (a == N) {
            g[b-1] = true;
        }
        else if (b == N){
            g[a-1] = true;
        }
    }

    for (int i = 0; i < N; i++){
        if (s[i] && g[i]) {
        cout << "POSSIBLE" << endl;
        return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}



Measured memory_bytes: 256
N=int(input())
F=[list(map(int,input().split())) for i in range(2*N)]
F,P=F[:N],F[N:]
from itertools import product
r=-10**9
for i in range(1,1024):
  x=[(i>>(9-j))%2 for j in range(10)]
  r=max(r,sum([P[j][sum([F[j][i]*x[i] for i in range(10)])] for j in range(N)]))
print(r)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

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

    sort(all(a));
    cout << abs(a[0] - a[a.size()-1]) << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define inf LLONG_MAX
#define bp __builtin_popcountll
#define pb push_back
#define ff first
#define ss second
#define P pair<ll,ll>
#define N 100001
#define all(a) a.begin(),a.end()
#define LG 20
#define int ll
#define nl '\n'
#define sp " "
#define vi vector<int>
#define f(n) for(int i=0;i<n;i++)
#define mod 1000000007
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define ps(x,y) fixed<<setprecision(y)<<x
#define F(i,a,b) for(int i = a ; i < b ; i++)
#define print_vector(v) cout<< #v << " " ; for(auto j:v) cout<<j<<sp; cout<<nl;
#define deb(x) cout<< #x << " " << x << endl;


vector<vector<int>> edges;
vector<bool> vis;
int nodes = 0;
// int dp[100002][6];


int power(int x, int y){
    if(y==0) return 1;
    int temp = power(x,y/2);

    int curr = (temp*temp)%mod;
    if(y%2) return (curr*x)%mod;
    else return curr;
}



void dfs(int curr){
    vis[curr] = true;
    nodes++;
    for(auto to:edges[curr]){
        if(!vis[to]){
            dfs(to);
        }
    }
}



void solve(){
    int n,k;
    cin>>n>>k;
    edges.resize(n+1);
    vis.resize(n+1);
    for(int i=0;i<k;i++){
        int x,y;
        cin>>x>>y;
        edges[x].pb(y);
        edges[y].pb(x);
    }

    int maxl = INT_MIN;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            nodes = 0;
            dfs(i);
            maxl = max(nodes,maxl);
        }
    }

    cout<<maxl<<nl;

    
}

signed main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast;
    // int t;
    // cin>>t; 
    // while(t--){
        solve();
    // }
}

Measured memory_bytes: 20340
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int K = scan.nextInt();
			double [] s = new double[N+1]; 
			int[]p = new int[N];
			for(int i = 0;i<N;i++) p[i] = scan.nextInt();
			
			for(int i = 0;i<N;i++) {
				s[i+1] = s[i]+(p[i]+1)/2.0; 
			}
			
			double max = 0;
			
			for(int i = 0;i<=N-K;i++) {
				double a = s[i+K]-s[i];
				
				if(max<a)max = a;
			}
			
			
			BigDecimal d = new BigDecimal(max);
			String str = String.format("%1$.7f", d);
			
			System.out.println(str);
			
			
 			
		}
		
		
	}
		

}

Measured memory_bytes: 86260
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;

void main()
{
  auto n = readln.chomp.to!int;
  auto a = readln.chomp.split.map!(to!int);
  auto b = new int[](n);
  int cnt;
  foreach (i; 0..n) {
    if (a[i] < i+1) {
      if (b[a[i]-1] == i+1) {
        cnt++;
      }
    } else {
      b[i] = a[i];
    }
  }
  cnt.writeln;
}


Measured memory_bytes: 3004
#include <stdio.h>

int main(void)
{
	int n, d, x, i, j, c;
  int a[110];
  int b;
	scanf("%d %d %d",&n, &d, &x);

  for(i = 0; i < n ; i++){/*入力*/
		scanf("%d", &a[i]);
		}

  c = 0;

  for (j  = 0; j < n; j++) {
    b = 0;

    for ( i = 1; b <= d ; i++) {
      b = a[j] * i - a[j] + 1;
      if (b <= d) {
      c++;
      }
    }

}
	printf("%d\n", c + x);
	return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")
 
 
def solve(N: int, K: int, C: int, S: str):
 
    L = []
    c = 0
    for i, d in enumerate(S):
        if d == "o" and c == 0:
            L.append(i)
            c = C
        elif c > 0:
            c -= 1
    R = []
    c = 0
    for i, d in enumerate(S[::-1]):
        if d == "o" and c == 0:
            R.append(N-i-1)
            c = C
        elif c > 0:
            c -= 1
 
    if len(L) != K:
        print()
        return
    for l, r in zip(L, R[::-1]):
        if l == r:
            print(l+1)
    return
 
 
def main():
 
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, C, S)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 22380
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MX=1e18;
main()
{
    int n,k;
    scanf("%lld%lld",&n,&k);
    int dp[n+1];
    dp[0]=0;
    int a[n+1];
    a[0]=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }dp[1]=0;
    for(int i=2;i<=n;i++){
        int l=i-k,mn=MX;
        if(l<=0)l=1;
        for(int j=l;j<i;j++){
            mn=min(mn,abs(a[i]-a[j])+dp[j]);
        }
        dp[i]=mn;
    }
    printf("%lld",dp[n]);
}


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

using namespace std;

void Main()
{
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    cout << (H - h) * (W - w);
}

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

    std::cout << std::fixed << std::setprecision(10);

#ifdef DEBUG_BUILD
    while (true)
    {
        Main();
        cout << std::endl;
    }
#endif

    Main();
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n, i, po[2] = {0}, ca[2];
	
	while(scanf("%d", &n)){
		if(!n)break;
	po[0] = 0;
	po[1] = 0;
	for(i = 0; n > i; i++){
		scanf("%d%d", &ca[0], &ca[1]);
		if(ca[0] > ca[1]) po[0] += ca[0]+ca[1];
		else if(ca[0] < ca[1]) po[1] += ca[0]+ca[1];
		else{ po[0] += ca[0]; po[1] += ca[1];}
	}
	printf("%d %d\n",po[0],po[1]);
	}
	return 0;
}

Measured memory_bytes: 1028
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> C;
    for (decltype(N) i = 1; i <= N; ++i) {
        int64_t t;
        std::cin >> t;
        C.push_back(t - i);
    }

    std::sort(std::begin(C), std::end(C));

    const auto b = C[N/2];

    int64_t sum = 0;
    for (auto c : C) {
        sum += std::abs(c - b);
    }

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
 
int main () {
	int n;
	cin >> n;
	int sum =0;
	rep(i,n) {
		sum += i+1;
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n,i,j,tmp;
    int min = 1000000;
    int x[100];
    
    scanf("%d",&n);
    for(i = 0 ; i < n ; i++) scanf("%d",&x[i]);
    
    for(i = 1 ; i <= 100 ; i++){ //集会の座標
        for(j = 0 ; j < n ; j++){
            tmp += (x[j] - i) * (x[j] - i);
        }
//        printf("if %d sum is %d\n",i,tmp);
        if(tmp < min) min = tmp; //体力の最小値の更新
        tmp = 0;
    }
    
    printf("%d\n",min);
    return 0;
}


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

int N, W;
vector<int> w, v;

int main() {
  cin >> N >> W;
  w.resize(N), v.resize(N);

  rep(i, N) cin >> w[i] >> v[i];

  vector<ll> dp(W + 1, 0);

  rep(i, N) for (int j = W; j >= 0; --j) {
    if (j - w[i] >= 0) dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
  }

  cout << dp[W] << endl;
  return 0;
}


Measured memory_bytes: 1024
x, y = map(int, input().split())
while not(x == 0 and y == 0):
	print(y*'#')
	print((x-2)*(('#' + (y-2)*'.' + '#')+'\n'), end ="")
	print(y*'#')
	print()
	x, y = map(int, input().split())


Measured memory_bytes: 5636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int gcd(int a,int b){
  int tmp;
  while(a!=0){
  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }
  a=a%b;
  } 
  return b;
}
int main(){
  ll a,b;cin>>a>>b;
  ll ans=a*b;
  ans/=gcd(a,b);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 384
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def solve(A, N, b):
    l = [[(0, 0), (0, 1), (0, 2)], 
        [(1, 0), (1, 1), (1, 2)],
        [(2, 0), (2, 1), (2, 2)],
        [(0, 0), (1, 0), (2, 0)],
        [(0, 1), (1, 1), (2, 1)],
        [(0, 2), (1, 2), (2, 2)],
        [(0, 0), (1, 1), (2, 2)],
        [(0, 2), (1, 1), (2, 0)]]

    for k in l:
        if all(A[i][j] in b for i, j in k):
          return 'Yes'
    return 'No'


def main():
    A = [read_int_list() for i in range(3)]
    N = read_int()
    b = [read_int() for k in range(N)]
    
    res = solve(A, N, b)
    print(res)


main()


Measured memory_bytes: 3572
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(int, char**)
{
	string S;
	cin >> S;
	long long len = S.size();
	vector<long long> grids(len, 0);
	char before = 'R';
	long long from = 0;
	for (long long i = 0; i < len; ++i)
	{
		if (before != S[i])
		{
			if (before == 'R')
			{
				if ((i - from) % 2 == 0)
				{
					grids[i] += (i - from) / 2;
					grids[i - 1] += (i - from) / 2;
				}
				else
				{
					grids[i] += (i - from) / 2;
					grids[i - 1] += (i - from) / 2 + 1;
				}
			}
			else
			{
				if ((i - from) % 2 == 0)
				{
					grids[from] += (i - from) / 2;
					grids[from - 1] += (i - from) / 2;
				}
				else
				{
					grids[from] += (i - from) / 2 + 1;
					grids[from - 1] += (i - from) / 2;
				}
			}
			from = i;
			before = S[i];
		}
	}
	if ((len - from) % 2 == 0)
	{
		grids[from] += (len - from) / 2;
		grids[from - 1] += (len - from) / 2;
	}
	else
	{
		grids[from] += (len - from) / 2 + 1;
		grids[from - 1] += (len - from) / 2;
	}
	for (long long i = 0; i < len; ++i)
	{
		cout << grids[i];
		if (i != len - 1)
		{
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;

int main(){
	while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        long long a[5000] = {0};
        long long int number;
        long long int jun[5000] = {0};
        long long tanka,kazu;
        for(int i = 1; i <= n; i++){
            cin >> number >> tanka >> kazu;
            a[number] += tanka * kazu;
            jun[i] = number;
        }
        for(int i = 0; i < 4000; i++){
            for(int j = i+1; j <= 4000; j++){
                if(jun[i] == jun[j]) jun[j] = 0;
            }
        }

        bool flg = 0;
        for(int i = 1; i <= 4000; i++){
            if(a[jun[i]] >= 1000000){
                cout << jun[i] << endl;
                flg = 1;
            }
        }


        if(!flg) cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1248
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

	
int dp[100005];
int n,G,w[5005],p[5005];
int ans;
 
int32_t main(){_
    cin >> n >> G;
    for(int i = 1;i<=n;i++)
    {
        cin >> w[i] >> p[i];
    }
    for(int i = 1;i<=n;i++)
    {
		for(int j = G;j >= w[i];j--)
		{
			if(dp[j] < dp[j - w[i]] + p[i])
			{
				dp[j] = dp[j - w[i]] + p[i];
				ans = max(ans,dp[j]);
			}
		}
    }
	rc(ans);
}

Measured memory_bytes: 1024
#include<stdio.h>

int isGCD(int a, int b){
	while(1){
		int tmp = a % b;
		a = b;
		b = tmp;
		if(!b){
			break;
		}
	}
	return a;
}

int main(void){
	int a, b, i, GCD;
	long LCM;
	
	while(scanf("%d %d", &a, &b) != EOF){
		if(a < b){
			int tmp = a;
			a = b;
			b = tmp;
		}
		GCD = isGCD(a, b);
		
		LCM = ((long)a * b) / GCD;
		
		printf("%d %lu\n", GCD, LCM);
	}
	return 0;
}

Measured memory_bytes: 600
// ALDS1_2_A Bubble Sort

#include <iostream>
#include <vector>

using namespace std;

namespace alds1_2_a
{
	void bubbleSort(vector<int> &A, int &swapCount)
	{
		swapCount = 0;
		int n = A.size();
		
		for (int i = 0; i < n; ++i) {
			for (int j = n - 1; j > i; --j) {
				if (A[j - 1] > A[j]) {
					int temp = A[j];
					A[j] = A[j - 1];
					A[j - 1] = temp;

					++swapCount;
				}
			}
		}
	}

	void solve(istream &sin, ostream &sout)
	{
		int n;
		sin >> n;

		int buf;
		vector<int> A;
		for (int i = 0; i < n; ++i) {
			sin >> buf;
			A.push_back(buf);
		}

		int swapCount;
		bubbleSort(A, swapCount);

		for (int i = 0; i < n - 1; ++i) {
			sout << A[i] << " ";
		}
		sout << A[n - 1] << endl << swapCount << endl;
	}
}

int main()
{
	alds1_2_a::solve(cin, cout);
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define INF (1<<29) //53687091
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=1e5;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
int N,a,cunt,cunt_even;

void solve(){
    for(auto u:mp){
        if(u.second%2)cunt++;
        else cunt_even++;
    }
    
    cout<<cunt + (cunt_even==1?0:cunt_even/2*2)<<"\n";
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>N;
    for(int i=0;i<N;i++) {
        cin>>a;
        mp[a]++;
    }
    solve();
    
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    VL a(n),b(n),c(n);
    fr(i,0,n)
        cin>>a[i];
    fr(i,0,n)
        cin>>b[i];
    fr(i,0,n)
        cin>>c[i];
    sort(ALL(a));
    sort(ALL(b));
    sort(ALL(c));
    //cout<<*upper_bound(ALL(b),1)<<endl;
    ll ans=0;
    fr(i,0,n)
    {
        auto low=lower_bound(ALL(a),b[i]);
        if(low!=a.begin())
        {
            low--;
            ll x=low-a.begin();
            x++;
            low=upper_bound(ALL(c),b[i]);
            if(low!=c.end())
            {
                ll y=n-(low-c.begin());
                ans+=(x*y);
            }
        }
    }
    cout<<ans<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

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

namespace problem
{
  class Test
  {
    static void Main()
    {
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int count = 0;
        for (int i = a[0]; i <= a[1]; i++)
        {
            if (a[2] % i == 0) count++;
        } 
        Console.WriteLine(count);
    }
  }
}


Measured memory_bytes: 9584
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll sum=0;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
        sum+=s[i]-'0';
    if(sum==0)
        {cout<<"Yes"<<endl;return 0;}
    if(sum%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3740
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    long h[n];
    for(int i = 0;i<n;i++) cin >> h[i];
    int now = 1;
    int ans = 1;
    for(int i = 1;i<n;i++){
        if(h[i]<=h[i-1]) now++;
        else{
            ans = max(ans,now);
            now = 1; 
        }
    }
    ans = max(ans,now);
    cout << ans-1 << endl;
}

Measured memory_bytes: 1024
import math
import numpy

a,b,h,m= map(int,input().split())

#const angle = Math.atan2(y, x);
if h <= 3:
    hs = 90 - (h*30 + 30/60*m)
elif h <= 6:
    hs = h*30 + 30/60*m -90
elif h <= 9:
    hs = 270 - (h*30 + 30/60*m)
else:
    hs = h*30 + 30/60*m -270

if m <= 15:        
    ms = 90 - m*6
elif m <= 30:        
    ms = m*6 - 90
elif m <= 45:        
    ms = 270 - m*6
else:        
    ms = m*6 - 270
#print(hs)
#print(ms)
#const newX = r * Math.cos(angle + rotation);

hx = a * math.cos(math.radians(hs))
#const newY = r * Math.sin(angle + rotation);
hy = a * math.sin(math.radians(hs))
mx = b * math.cos(math.radians(ms))
#const newY = r * Math.sin(angle + rotation);
my = b * math.sin(math.radians(ms))
if hs == 90:
    hx = 0
if ms == 90:
    mx = 0

if h <= 3:
    hy = hy * 1
elif h <= 6:
    hy = hy * -1
elif h <= 9:
    hx = hx * -1
    hy = hy * -1
else:
    hx = hx * -1

if m <= 15:        
    mx = mx * 1
elif m <= 30:        
    my = my * -1
elif m <= 45:        
    mx = mx * -1
    my = my * -1
else:        
    mx = mx * -1

#print(hx)
#print(hy)
#print(mx)
#print(my)


c = numpy.array([hx, hy])
d = numpy.array([mx, my])
u = d - c
print(numpy.linalg.norm(u))




Measured memory_bytes: 27320
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

ll comb_count(int n, int m) {
  if (m == 0)
    return 1;
  if (n == 0)
    return 0;
  return (n * comb_count(n - 1, m - 1) / m);
}

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

  int n, p;
  cin >> n >> p;
  vector<int> a(n);
  int eve = 0, odd = 0;
  rep(i, 0, n) {
    cin >> a[i];
    if (a[i] & 1)
      odd++;
    else
      eve++;
  }

  ll eves = pow(2, eve);
  ll odds = 0;
  int start = 1;
  if (p == 0)
    start = 0;
  for (int i = start; i <= odd; i += 2) {
    odds += comb_count(odd, i);
  }

  cout << eves * odds << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int S ;	
  int Y ;
  int Z ;
  cin >> S ;
  Y = S - (S/100)*100 ; //下二けたを抽出
  Z = Y - (Y/10)*10 ;  //一の位を抽出
  
  cout << (S/100) + (Y/10) + Z << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long

int main(){
    int n,a[100100];
    cin>>n;
    rep(i,n) cin>>a[i];
    ll cnt=0,s=0;
    int b[100100];
    rep(i,n){
        if(a[i]<0) cnt++;
        b[i]=abs(a[i]);
    }
    sort(b,b+n);
    rep(i,n){
        s=s+b[i];
    }
    if(cnt%2==0) cout<<s<<endl;
    else cout<<s-2*b[0]<<endl;
}

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

const int N = 110000;

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n, K; cin >> n >> K;
	cout << (n - 2) / (K - 1) + 1 << "\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int n=s.size();
	s="."+s;
	if(s[1]=='0'||s[n]=='1'){
		cout << -1 << endl;
		return 0;
	}
	for(int i=1;i<n;i++){
		if(s[i]!=s[n-i]){
			cout << -1 << endl;
			return 0;
		}
	}
	queue<int> q;
	s[n]='1';
	for(int i=1;i<=n;i++){
		if(s[i]=='1'){
			q.push(i);
		}
	}
	for(int i=1;i<n;i++){
		if(i==q.front()){
			q.pop();
		}
		cout << i << " " << q.front() << endl;
	}
}

Measured memory_bytes: 1900
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d", &n);
    int t = n % 10;
    if(t == 2 || t == 4 || t == 5 || t == 7 || t == 9) printf("hon\n");
    else if(t == 0 || t == 1 || t == 6 || t == 8) printf("pon\n");
    else printf("bon\n");
    return 0;
}


Measured memory_bytes: 3688
n = gets.to_i
pieces = gets.split.map(&:to_i)
m = gets.to_i
moves = gets.split.map(&:to_i)

moves.each do |i|
  pieces[i - 1] += 1 if !pieces.include?(pieces[i - 1] + 1) && pieces[i - 1] != 2019
end

puts pieces



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


def main():
    n, a, b = map(int, input().split())
    ans = sum([
        i for i in range(1, n + 1)
        if sum([int(d) for d in str(i)]) in range(a, b + 1)
    ])
    print(ans)


if __name__ == '__main__':
    main()


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

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

    if(N%2!=0){
        cout << "No" << endl;
        return 0;
    }else{
        for(int i = 0;i<N/2;i++){
            if(S[i]!=S[i+(N/2)]){
                cout << "No" <<endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    
    return 0;
}

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

using namespace std;

void solve();

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

void solve() {
    int n;
    cin >> n;
    int x,y,z;
    cin >> x;
    int a[x];
    for(int i = 0; i < x; i++) {
        cin >> a[i];
    }
    cin >> y;
    int b[y];
    for(int i = 0; i < y; i++) {
        cin >> b[i];
    }
    cin >> z;
    int c[z];
    for(int i = 0; i < z; i++) {
        cin >> c[i];
    }
    bool a_c[n],b_c[n],c_c[n];
    for(int i = 0; i < n; i++) {
        a_c[i] = false;
        b_c[i] = false;
        c_c[i] = false;
    }
    for(int i = 0; i < x; i++) {
        a_c[a[i]-1] = true;
    }
    for(int i = 0; i < y; i++) {
        b_c[b[i]-1] = true;
    }
    for(int i = 0; i < z; i++) {
        c_c[c[i]-1] = true;
    }
    int sum = 0;
    for(int i = 0; i < n; i++) {
        if(c_c[i] && (!a_c[i] || b_c[i])) sum++;
    }    
    cout << sum << endl;



}

Measured memory_bytes: 3204