akhauriyash/Code-Regression huggingface dataset:
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = [1]*n
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] > h[b-1]:
        ans[b-1] = 0
    elif h[a-1] == h[b-1]:
        ans[a-1] = ans[b-1] = 0
    else:
        ans[a-1] = 0
print(ans.count(1))

Measured memory_bytes: 19964
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			int ans = a+b;
			System.out.println(ans>=24?ans-24:ans);

		}
	}
}


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

const int INF = 300000;
int N, M;
int blank;
vector<int> A, C, L;

void del_cnt(int a) {
	int b = max(L[a], 0);
	if (C[b] > 0) {
		--C[b];
		if (C[b] == 0)
			++blank;
	}
	++L[a];
	if (L[a] == a)
		L[a] = -INF;
}

void add_cnt(int a) {
	if (L[a] == -INF)
		L[a] = a - 1;
	else
		--L[a];
	int b = max(L[a], 0);
	if (C[b] == 0)
		--blank;
	++C[b];
}

void input_data(void) {
	cin >> N >> M;
	A.resize(N + 1);
	C.resize(N + 1, 0);
	L.resize(N + 1, -INF);
	blank = N;
	for (int i = 1; i <= N; ++i) {
		int a;
		cin >> a;
		A[i] = a;
		add_cnt(a);
	}
}

int main(void) {
	input_data();

	for (int i = 0; i < M; ++i) {
		int x, y;
		cin >> x >> y;
		del_cnt(A[x]);
		add_cnt(y);
		A[x] = y;
		cout << blank << '\n';
	}

	return 0;
}


Measured memory_bytes: 3840
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define LEN(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
using ll = long long;
using llu = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vpii = vector<pii>;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod(ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

////////////////////////// Solution starts below. //////////////////////////////

int n;
string str;
deque<char> dq;

int main () {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // cout.precision(10);
	cin >> n;
	cin >> str;
	for(int i = 0; i < LEN(str); i++) dq.push_back(str[i]);
	while(!dq.empty() and dq.front() == 'R') dq.pop_front();
	while(!dq.empty() and dq.back() == 'W') dq.pop_back();
	int qW = 0;
	for(int i = 0; i < LEN(dq); i++) qW += dq[i] == 'W';
	int ans = 0;
	for(int i = LEN(dq)-1; i > LEN(dq)-1-qW; i--)
		ans += dq[i] == 'R';
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3800
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	ab := strings.Fields(nextLine())
	a, _ := strconv.Atoi(ab[0])
	b, _ := strconv.Atoi(ab[1])
	if a < 13 {
		if a <= 5 {
			fmt.Println(0)
		} else {
			fmt.Println(b / 2)
		}
	} else {
		fmt.Println(b)
	}
}


Measured memory_bytes: 640
N, K, Q = map(int, input().split())
points = [K]*(N+1)
man = {i:0 for i in range(1, N+1)}
for a in range(Q):
    man[int(input())] += 1
for i in range(1, N+1):
    if points[i] - (Q-man[i]) > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 15920
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<String> list = new ArrayList<String>();
		boolean flag = false;
		int[] tri = new int[3];
		int N = scan.nextInt();
		for(int a = 0; a < N; a++){
			for(int i = 0; i < 3; i++){
				tri[i] = scan.nextInt();
			}
			for(int i = 0; i < 3 - 1; i++){
				for(int j = 3 - 1; j > i; j--){
					if(tri[i] < tri[j]){
						int big = tri[j];
						tri[j] = tri[i];
						tri[i] = big;
					}
				}
			}
			// System.out.printf("%d %d %d\n", tri[0], tri[1], tri[2]);
			if(Math.pow(tri[0], 2) == Math.pow(tri[1], 2) + Math.pow(tri[2], 2)){
				// System.out.println("YES");
				flag = true;
			} else{
				// System.out.println("NO");
				flag = false;
			}
			list.add(flag? "YES" : "NO");
		}

		for(String s : list){
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 35012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n;
	cin >> n;
	map<string, int> mp;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (mp.count(s)) mp[s]++;
		else mp[s] = 1;
	}

	int max_value = 0;
	for (auto item : mp) {
		max_value = max(max_value, item.second);
	}

	for (auto item : mp) {
		if (item.second == max_value) {
			cout << item.first << endl;
		}
	}
}

Measured memory_bytes: 25216
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int x,y,z,n;
vvi a;

int main(){
	cin>>x>>y>>z;
	n=x+y+z;
	a=vvi(n,vi(3));
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		sum+=a[i][2];
	}
	sort(a.begin(),a.end(),[](vi x,vi y){
		return x[1]-x[0]<y[1]-y[0];
	});
	priority_queue<pll> q;
	vi b(n);
	vl res(n,sum);
	for(int i=0;i<n;i++) q.push({a[i][0]-a[i][2],i});
	ll tmp=0;
	for(int i=0;i<x;i++){
		pll p=q.top();
		q.pop();
		tmp+=p.first;
		b[p.second]=1;
	}
	for(int i=n-1;i>=x-1;i--){
		res[i]+=tmp;
		if(b[i]&&i!=x-1){
			tmp-=a[i][0]-a[i][2];
			while(1){
				pll p=q.top();
				q.pop();
				int I=p.second;
				if(!b[I]&&I<i){
					b[I]=1;
					tmp+=p.first;
					break;
				}
			}
		}
	}
	priority_queue<pll> q1;
	b=vi(n);
	for(int i=0;i<n;i++) q1.push({a[i][1]-a[i][2],i});
	tmp=0;
	for(int i=0;i<y;i++){
		pll p=q1.top();
		q1.pop();
		tmp+=p.first;
		b[p.second]=1;
	}
	for(int i=0;i<=n-y;i++){
		if(i) res[i-1]+=tmp;
		if(b[i]&&i!=n-y){
			tmp-=a[i][1]-a[i][2];
			while(1){
				pll p=q1.top();
				q1.pop();
				int I=p.second;
				if(!b[I]&&I>i){
					b[I]=1;
					tmp+=p.first;
					break;
				}
			}
		}
	}
	ll ans=0;
	for(int i=x-1;i<n-y;i++) ans=max(ans,res[i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 11496
n = gets.to_i
numbers = gets.chomp.split.map(&:to_i)


top = 1
swap_count = 0
until top == numbers.size
    (n - 1).downto(top){|j|
        if numbers[j] < numbers[j - 1]
            numbers[j], numbers[j - 1] = numbers[j - 1], numbers[j]
            swap_count += 1
        end
    }
    top += 1
end

puts numbers.join(" ")
puts swap_count

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

int main(){
  int N,M,C,answer;
  cin >> N >> M >> C;
  answer = 0;
  vector<int> B(M),S(N,C);
  vector<vector<int>> A(N,vector<int>(M));
  for(int i=0;i<M;i++){
    cin >> B.at(i);
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin >> A.at(i).at(j);
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      S.at(i) += B.at(j)*A.at(i).at(j);
    }
  }
  for(int i=0;i<N;i++){
    if(S.at(i)>0){
      answer++;
    }
  }
  cout << answer << endl;
}
  

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

int main() {
	uint32_t N;
	cin >> N;
	
	vector<vector<double>> dp(2, vector<double>(N+1, 1));	
	for(uint32_t i=1; i<=N; i++) {
		double p;
		cin >> p;
		
		bool ic = i&1;
		bool ip = !ic;
		
		dp[ic][0] = dp[ip][0] * (1 - p); // all ura
		
		for(uint32_t j=1; j<i; j++) dp[ic][j] = dp[ip][j-1] * p + dp[ip][j] * (1 - p);

		dp[ic][i] = dp[ip][i-1] * p; // all omote
	}

	// N is always odd
	double ans = accumulate(dp[1].begin() + N/2 + 1, dp[1].end(), (double)0);
	cout << setprecision(10) << ans << endl;
	
	return 0;

}

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

const int N = 200000 + 10, S = 4000 + 10, M = 1e9 + 7;

int dp[S][S], C[S][S];
int A[N], B[N];
int n;

void run() {
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::cin >> A[i] >> B[i];
    dp[-A[i] + 2000][-B[i] + 2000] += 1;
    dp[A[i] + 2000][B[i] + 2000] -= 1;
  }
  for (int i = 0; i < S; ++i) {
    for (int j = 0; j < S; ++j) {
      if (!i && !j) C[i][j] = 1;
      else {
        if (i) C[i][j] += C[i - 1][j];
        if (j) C[i][j] += C[i][j - 1];
        C[i][j] %= M;
      }
    }
  }
  int ret = 0;
  for (int i = 0; i < S; ++i) {
    for (int j = 0; j < S; ++j) {
      int now = 0;
      if (i) now += dp[i - 1][j];
      if (j) now += dp[i][j - 1];
      if (dp[i][j] < 0) {
        ret += 1ll * now * (-dp[i][j]) % M;
        dp[i][j] = now % M;
        ret %= M;
      }
      else dp[i][j] = (dp[i][j] + now % M) % M;
    }
  }
  for (int i = 0; i < n; ++i) {
    ret -= C[A[i] * 2][B[i] * 2];
    ret += M;
    ret %= M;
  }
  ret = ret * 500000004ll % M;
  std::cout << ret << std::endl;
}

int main() {
  run();
  return 0;
}


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

typedef long long ll;

vector<pair<ll,ll> >g[100005]; 
bool color[100005];
ll dis[100005];

void bfs(ll start)
{
	for(int i=0;i<100005;i++) color[i]=false,dis[i]=0;
	
	color[start]=1;
	queue<ll>q;
	
	ll u;
	
	q.push(start);
	
	while(!q.empty())
	{
		u=q.front();
		q.pop();
		
		for(int i=0;i<g[u].size();i++)
		{
			ll adj=g[u][i].second;
			ll d=g[u][i].first;
			if(!color[adj])
			{
				color[adj]=1;
				dis[adj]=dis[u]+d;
				q.push(adj);
			}
		}
	}
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    int n;
    cin>>n;
    
    pair<ll,ll>p;
    
    for(int i=1;i<n;i++)
    {
    	ll a,b,c;
    	cin>>a>>b>>c;
    	p.first=c;
    	p.second=b;
    	g[a].push_back(p);
    	
    	p.second=a;
    	g[b].push_back(p);
    }
    
    ll q,k;
    cin>>q>>k;
    
    bfs(k);
    
    while(q--)
    {
    	ll a,b;
    	cin>>a>>b;
    	cout<<dis[a]+dis[b]<<"\n";
    }
        
    return 0;

}

Measured memory_bytes: 10112
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()

    val kList = readLine()!!.split(" ").map(String::toInt)

    println(abc142c(n, kList))
}

fun abc142c(n: Int, kList: List<Int>): Any? {

    val map = mutableMapOf<Int, Int>()

    for ((index, k) in kList.withIndex()) {
        map[index + 1] = k
    }

    return map.toList().sortedBy { it.second }.map { it.first }.joinToString (" ")
}


Measured memory_bytes: 103208
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1001001001
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    int N,K; cin >> N >> K;
    vector<int> p(N);
    REP(i,N) cin >> p[i];

    sort(p.begin(), p.end());
    int sum=0;
    REP(i,K){
        sum += p[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 3604
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n=3;
	vvi in(n,vi(n));
	rep(i,n)rep(j,n)cin>>in[i][j];
	bool h=false;
	rep(i,400)rep(j,400)rep(k,400){
		bool H=true;
		rep(q,3)if(in[0][q]-i>=0&&in[0][q]-i==in[1][q]-j&&in[0][q]-i==in[2][q]-k);
		else H=false;
		if(H)h=true;
	}
	if(h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}








Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<deque>
using namespace std;

int main() {
  int Y, X; cin >> Y >> X;
  vector< vector<char> > maze(Y, vector<char>(X));
  for (int i = 0; i < Y; i++) {
    for (int j = 0; j < X; j++) cin >> maze[i][j];
  }

  int ans = 0;
  for (int sy = 0; sy < Y; sy++) {
    for (int sx = 0; sx < X; sx++) {
      // 壁からスタートしない
      if (maze[sy][sx] == '#') continue;

      // 初期設定
      vector< vector<int> > dist(Y, vector<int>(X, -1));
      dist[sy][sx] = 0;
      deque<pair<int, int> > q;
      q.push_back(make_pair(sy, sx));
      
      // 探索
      while (!q.empty()) {
        int cy, cx;
        pair<int, int> curr;
        curr = q.front();
        q.pop_front();
        cy = curr.first;
        cx = curr.second;
        for (int dir = 0; dir < 4; dir++) {
          int ny, nx;
          if (dir == 0) {
            ny = cy;
            nx = cx + 1;
          }
          if (dir == 1) {
            ny = cy;
            nx = cx - 1;
          }
          if (dir == 2) {
            ny = cy + 1;
            nx = cx;
          }
          if (dir == 3) {
            ny = cy - 1;
            nx = cx;
          }
          if (ny >= 0 && nx >= 0 && ny < Y && nx < X && dist[ny][nx] == -1 && maze[ny][nx] != '#') {
            dist[ny][nx] = dist[cy][cx] + 1;
            if (dist[ny][nx] > ans) ans = dist[ny][nx]; 
            q.push_back(make_pair(ny, nx));
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

pint p[200001];
const int mod=1000000007;
int main(){
    int n,m,ai;
    cin>>n;
    rep(i,n){
        cin>>ai;
        p[i]={ai,0};
    }
    rep(i,n){
        cin>>ai;
        p[i+n]={ai,1};
    }
    sort(p,p+n+n);
    ll mul=1;
    int c0=0,c1=0;
    rep(i,n+n){
        if(p[i].second==0){
            if(c1>0){
                mul*=c1;--c1;
                mul%=mod;
            }
            else ++c0;
        }
        else{
            if(c0>0){
                mul*=c0;--c0;
                mul%=mod;
            }
            else ++c1;
        }
    }
    cout<<mul<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        boolean b = true;
        for (int i = 0; i < N; i++) {
            int a = in.i();
            b = b != ((a & 1) == 1);
        }
        out.println(b ? "YES" : "NO");
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 35388
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
// #pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
 
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2e5 + 20;
#endif

//tg: @galebickosikasa
 
const ll inf = (ll) 2e9;
const ld pi = 3.14159265358979323846264;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

random_device rd;
mt19937 SuperRandom(rd());

int ans = 2;
unordered_set <int> a;

void kek (int x) {
	for (int i = 1; i * i <= x; ++i) {
		if (x % i == 0) a.insert (i), a.insert (x / i);
	}
}

void kek1 (int x) {
	for (int i = 2; i * i <= x; ++i) {
		int y = x;
		while (y % i == 0) y /= i;
		if (y % i == 1) a.insert (i);
		// if (x % i == 0 && (x / i - 1) % i == 1) {
		// 	a.insert (i);
		// }
	}
}

signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int x;
	cin >> x;
	kek (x - 1);
	kek1 (x);
	a.insert (x);
	a.erase (1);
	for (auto& x: a) dbg (x);
	cout << sz (a);






}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	v1 := a * c
	v2 := a * d
	v3 := b * c
	v4 := b * d

	ans := max(v1, max(v2, max(v3, v4)))
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 1768
#include<stdio.h>

struct Data{
	int number[3];
	int point;
};

int main(){
	struct Data data[200];
	int i,j,n;
	int flag[3][100] = {0};

	scanf("%d",&n);

	for(i=0;i<n;i++){
		data[i].point = 0;
		scanf("%d %d %d",&data[i].number[0],&data[i].number[1],&data[i].number[2]);
		for(j=0;j<3;j++){
			flag[j][data[i].number[j]]++;
		}
	}

	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			if(flag[j][data[i].number[j]] < 2)data[i].point += data[i].number[j];
		}
	}


	for(i=0;i<n;i++){
		printf("%d\n",data[i].point);
	}
	return 0;
}

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

const int maxn = 110;
int n, ans, a[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 1, j; i <= n; i = j) {
        for (j = i; a[i] == a[j]; j++);
        ans += (j - i) >> 1;
    }
    printf("%d\n", ans);
    return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n; cin >> n;
    vii g(n);
    rep(i,n) {
        int u,v,k; cin >> u >> k;
        --u;
        rep(j,k) {
            cin >> v;
            --v;
            g[u].push_back(v);
        }
    }

    vi dist(n, -1);
    queue<int> que;
    que.emplace(0);
    dist[0] = 0;

    while(que.size()) {
        int u = que.front(); que.pop();
        for(auto v : g[u]) {
            if(dist[v] != -1) continue;
            dist[v] = dist[u] + 1;
            que.emplace(v);
        }
    }

    for(int i = 0; i < n; ++i) {
        cout << i+1 << ' ' << dist[i] << '\n';
    }

    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3168
X[]={1,0,-1,0},Y[]={0,1,0,-1},s[19][19];char *D="RDLU";
main(x,y,i,j,z,k){
	memset(s,11,sizeof(s));
	x=y=5;
	for(j=1;j<=2*y+1;j++)for(i=1;i<=2*x+1;i++)s[i][j]=0;
	for(j=2;j<=2*y;getchar(),j++)
		for(i=(j&1)?2:3;i<2*x+1;i+=2){
			s[i][j]=getchar()-'0';
		}
	putchar('R');
	for(z=0,x=4,y=2;x!=2||y!=2;){
		z=(z+3)%4;
		for(;!s[x+X[z]][y+Y[z]];z=(z+1)%4);
		x+=X[z]*2,y+=Y[z]*2;
		putchar(D[z]);
	}
	puts("");exit(0);
}

Measured memory_bytes: 524
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

set<int> P[100];

bool suspect(const set<int> &P, const vector<int> &L){
  REP(i, L.size()){
    if(P.count(L[i]) == 0) return false;
  }
  return true;
}

int main(){
  int N, M, K, p, l;
  while(cin >> N && N){
    REP(i, N){
      P[i].clear();
      cin >> M;
      REP(j, M) {
        cin >> p;
        P[i].insert(p);
      }
    }
    cin >> K;

    vector<int> L;
    REP(i, K){
      cin >> l;
      L.push_back(l);
    }
    vector<int> res;
    REP(i, N){
      if(suspect(P[i], L)) res.push_back(i + 1);
    }
    if(res.size() == 1){
      cout << res.back() << endl;
    }else{
      cout << -1 << endl;
    }
    
  }
  return 0;
}

Measured memory_bytes: 1644
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;
/*
thx
http://wk1080id.hatenablog.com/entry/2017/02/11/154313
*/
void solve(){
	int N;
	cin >> N;
	vector<LL> A(N),order(N+1);
	for(int i=0;i<N;++i){
		cin >> A[i];
		order[ A[i]-1 ] = i;//値がある位置を記録
	}
	
	set<LL> S;
	S.insert(-1);//左の番兵
	S.insert(N);//右の番兵、値は[0,N-1]を使用している
	LL ans = 0;

	for(LL i=0;i<N;++i){//値が小さいほうから
		LL pos = order[i];//i番目に小さい値の位置
		set<LL>::iterator itr;
		itr = S.lower_bound( pos );//自分は入っていないので次に大きい位置
		
		/*
		(*itr)は自分より小さい値なので範囲に入らない-1
		個数+1(0個も数える)
		(*itr)-1 - pos + 1
		*/
		LL R = (*itr) - pos;
		--itr;//位置で左側、ループ順から自分より小さい値の位置
		LL L = pos - (*itr);
		LL temp = A[pos] * L * R;
		ans += temp;
		S.insert( pos );
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 12800
import java.util.*;
public class Main{
 static ArrayList<Integer> adj[];
public static void main(String args[]){  
  Scanner sc=new Scanner(System.in);
  int ver=sc.nextInt();
  int edg=sc.nextInt();
  adj=new ArrayList[ver];
  for(int i=0;i<ver;i++){
  adj[i]=new ArrayList<Integer>();
  }
  for(int i=0;i<edg;i++){
    int a=sc.nextInt();
    int b=sc.nextInt();
    adj[a-1].add(b-1);
   }
  boolean visited[]=new boolean[ver];
  int dp[]=new int[ver];
  for(int i=0;i<ver;i++){
  if(!visited[i])
    dfs(dp,visited,i,adj);
  }
  
  int max=0;
  for(int i=0;i<dp.length;i++){
    if(dp[i]>max)
      max=dp[i];
  }
  System.out.println(max);
}
        public static void dfs(int dp[],boolean visited[],int node,ArrayList<Integer> adj[]){
        visited[node]=true;
          for(int i=0;i<adj[node].size();i++){
              if(!visited[adj[node].get(i)])
                          dfs(dp,visited,adj[node].get(i),adj);
                          
               dp[node]=Math.max(dp[node],1+dp[adj[node].get(i)]);           
          }
          
        }
}

Measured memory_bytes: 101704
import sys
input = sys.stdin.readline

def main():
    S = input()[:-1]
    Q = int(input())
    li = [[] for _ in range(2)]
    now = 0
    for _ in range(Q):
        x = input()
        if(x[0] == '2'):
            if(x[2]=='1'):
                li[1-now].append(x[4])
            else:
                li[now].append(x[4])
        else:
            now = 1-now

    s = ''.join(li[1-now][::-1]) + S[::-(now*2-1)] + ''.join(li[now])
    print(s)

if __name__ == '__main__':
    main()

Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <math.h>

using namespace std;

int main() {
 string date;
  cin >> date ;
  if(date=="MON"){
  cout << "6" << endl;
  }else if(date=="TUE"){
  cout << "5" << endl;
  }else if(date=="WED"){
  cout << "4" << endl;
  }else if(date=="THU"){
  cout << "3" << endl;
  }else if(date=="FRI"){
  cout << "2" << endl;
  }else if(date=="SAT"){
  cout << "1" << endl;
  }else if(date=="SUN"){
  cout << "7" << endl;
  }
}

Measured memory_bytes: 256
from sys import stdin
readline = stdin.readline


def main():
    q = int(readline())
    for i in range(q):
        xy = map(int, readline().split())
        p0, p1, p2, p3 = [x + y * 1j for x, y in zip(*[xy] * 2)]
        c1 = intersection(p0, p2, p1, p3)
        print('{:.10f} {:.10f}'.format(c1.real, c1.imag))


# http://imagingsolution.blog107.fc2.com/blog-entry-137.html
def intersection(p1, p2, p3, p4):
    a1 = p4 - p2
    b1 = p2 - p3
    b2 = p1 - p2
    s1 = cross(a1, b2) / 2
    s2 = cross(a1, b1) / 2
    c1 = p1 + (p3 - p1) * s1 / (s1 + s2)
    return c1


def cross(a, b):
    return a.real * b.imag - a.imag * b.real
main()

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 100005;
const int inf = 1e8;
int A[N], dp[N][3];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		cin>>A[i];
		if(A[i]&1){
			ans += A[i]>>1;
			A[i] = 1;
		}else if(A[i] > 0){
			ans += (A[i]>>1) - 1;
			A[i] = 2;
		}
	}
	dp[0][0] = 0;
	dp[0][1] = dp[0][2] = -inf;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= 2; j++){
			dp[i][j] = -inf;
		}
		dp[i][A[i]] = max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]});
		if(A[i] == 2){
			dp[i][0] = max(dp[i][0], max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]}) + 1);
		}
		if(A[i] > 0){
			dp[i][A[i] - 1] = max(dp[i][A[i] - 1], max({dp[i - 1][1], dp[i - 1][2]}) + 1);
		}
	}
	ans += max({dp[n][0], dp[n][1], dp[n][2]});
	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;

const double PI = acos(-1.0);

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;
    modint(): num(0) {};
    modint(ll _n): num((_n + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }
    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }
    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }
    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }
    static modint fact(int n){
        if((int)factorial.size() <= n) factorial.resize(n+1);
        if(factorial[n]) return factorial[n];
        if(n == 0) return 1;
        return factorial[n] = modint(n) * fact(n-1);
    }
    static modint C(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial;
#define fact(n) modint::fact(n)
#define C(n,r) modint::C(n,r)
#define H(a,b) C(a+b, a)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll x,y;
    cin>>x>>y;
    ll z = min(x,y);
    ll ans = 0;
    if((x + y)%3 == 0){
        ll n = (x + y)/3;
        ll l = z-n;
        if(l >=0){
            cerr<<n<<"C"<<l<<endl;
            modint a = C(n,l);
            ans = a;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 27860
#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000
#define INF 1000000000
#define EPS 1e-9
using namespace std;

set<int> skup;

int main() {
    int n; scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        lld x; scanf("%lld", &x);
        if(skup.find(x) == skup.end()) skup.insert(x);
        else skup.erase(x);
    }
    printf("%d", sz(skup));
    return 0;
}


Measured memory_bytes: 4864
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;


void solve(long long N, std::vector<long long> d){
    int ans = 0;
    REP(i, N) for (int j = i + 1; j < N; ++j) {
        ans += d[i] * d[j];
    }
    cout << ans << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const pid_t pid = getpid();
// Problem Specific Parameter:

ll solve(const vector<ll> &ary){
	vector<ll> a = ary;
	const int n = ary.size();
	const int m = 60;
	
	int c = 0;
	rep(i, n - 1){
		int pivot = i;
		for(; c < m; ++c){
			int cmax = 0;
			rep(k, i, n) {
				const int bit = (a[k] >> (m - 1 - c)) & 1;
				if(chmax(cmax, bit)) pivot = k;
			}
			if(cmax > 0) break;
		}

		if(c == m) break;
		if(pivot != i) swap(a[i], a[pivot]);
		rep(k, i + 1, n){
			const int flag = (a[k] >> (m - 1 - c)) & 1;
			if(flag) a[k] ^= a[i];
		}
		c++;
	}

	ll ret = 0LL;
	rep(i, n) if((ret^a[i]) > ret) ret ^= a[i];
	return ret;
}


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

	ll xorsum = 0LL;
	rep(i, n) xorsum ^= a[i];

	const int m = 60;
	rrep(j, m){
		const int bit = (xorsum >> j) & 1;
		if(bit == 0) continue;
		rep(i, n) if(a[i] >> j & 1) a[i] ^= (1LL << j);
	}

	const ll amax = solve(a);
	const ll bmax = xorsum ^ amax;

	cout << amax + bmax << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define ll long long 
#define N 1005
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define piii pair<int, pii>
#define print(x) cout << #x << "=" << x << "\t";
#define endl "\n"
#define newline cout << endl;

int m;
int n;
char s[N][N];
int dp[N][N];

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL); 
    cin >> m >> n;
    for(int i=1;i<=m;i++)
        cin >> s[i] + 1;
    dp[1][1] = (s[1][1] != '#');
    for(int i=1;i<=m;i++)
        for(int j=1;j<=n;j++)
            if ((i != 1 || j != 1) && s[i][j] != '#')
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
    cout << dp[m][n];
    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

long int highestOneBitPosition(long int a) {
    long int bits = 0;
    while (a) {
        ++bits;
        a >>= 1;
    };
    return bits;
}

bool multiplication_is_safe(long int a, long int b) {
    long int a_bits = highestOneBitPosition(a);
    long int b_bits = highestOneBitPosition(b);
    return (a_bits + b_bits < 63);
}

bool addition_is_safe(long int a, long int b) {
    long int a_bits = highestOneBitPosition(a);
    long int b_bits = highestOneBitPosition(b);
    return (a_bits < 63 && b_bits < 63);
}

bool exponentiation_is_safe(long int a, long int b) {
    long int a_bits = highestOneBitPosition(a);
    return (a_bits * b <= 62);
}

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int x,k,d;
   cin>>x>>k>>d;

   x = llabs(x);
   long int ans = LLONG_MAX;

   if(multiplication_is_safe(k,d) && k * d <= x){
   	 x -= k * d;
   	 ans = x;
   }
   else{
   		long int minX = x % d;
   		long int stepsGone = x / d;
   		long int stepsLeft = k - stepsGone;

   		if(stepsLeft % 2 == 0)
   			ans = min(ans, minX);
   		else
   			ans = min(ans,llabs(minX + d));

   		if(stepsLeft){
   			minX = d - minX;
   			stepsLeft--;

   			if(stepsLeft % 2 == 0)
   				ans = min(ans,minX);
   			else
   				ans = min(ans, llabs(minX + d));
   		}
   }

   cout<<ans;
   return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

class UnionFind{

  vector<int> parent;
  vector<int> rank;
  vector<int> weight;  
public:
  
  UnionFind(int N) : parent(vector<int>(N)),
                     rank(vector<int>(N, 0)),
                     weight(vector<int>(N, 1)){
    for(int i = 0; i < N; i++) parent[i] = i;
  }
  
  int find(int x){
    if(x == parent[x]) return x;
    else return parent[x] = find(parent[x]);
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }

  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(rank[x] < rank[y]){
      parent[x] = y;
      weight[y] += weight[x];
    }else{
      parent[y] = x;
      weight[x] += weight[y];
      if(rank[x] == rank[y]) rank[y]++;
    }
  }

  int get_weight(int v){
    return weight[find(v)];
  }
};


int main(){
  int n, a, b, c;
  vector<pair<ll, P> > es;
  cin >> n;
  UnionFind uf(n);
  REP(i, n - 1){
    cin >> a >> b >> c;
    es.PB(MP(c, P(a, b)));
  }

  sort(ALL(es));

  ll ans = 0;
  REP(i, n - 1){
    pair<ll, P> p = es[i];
    ll cost = p.first;
    a = p.second.first;
    b = p.second.second;
    ans += cost * uf.get_weight(a) * uf.get_weight(b);
    
    uf.unite(a, b);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    int n;
    cin >> n;
    int odds = ceil(n/2.0);
    cout << setprecision(10) << odds * 1.0/ n << endl;

}

Measured memory_bytes: 256
/*package whatever //do not write package name here */
import java.util.*;
import java.io.*;

class Main {
    public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i<n; i++) a[i] = sc.nextInt();
		int count = 0;
		for(int i = 0; i<n; i++) {
		    for(int j = i+1; j<n; j++) {
		        for(int k = j+1; k<n; k++) {
		            if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k] && a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i]) count++;
		        }
		    }
		}
		System.out.println(count);
	}
}

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

int main() {
  int i;
  string S;
  cin >> S;
  int a;
  a = S.size();
  string ans="No";
  for(i=0;i<a-1;i++) {
    if(S[i]=='A'&&S[i+1]=='C') ans="Yes";
  }
  cout << ans << endl;
  return 0;  
}

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

using namespace std;

vector<string> mm = {
	"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"
};

int main() {
	string s;
	cin >> s;
	string bef, aft;
	bef += s[0];
	bef += s[1];
	aft += s[2];
	aft += s[3];
	bool bef_mm=false, aft_mm=false;
	for (int i=0; i<mm.size(); ++i) {
		if (bef == mm[i]) {
			bef_mm = true;
		}
		if (aft == mm[i]) {
			aft_mm = true;
		}
	}
	if (bef_mm and aft_mm) {
		cout << "AMBIGUOUS" << endl;
	} else if (bef_mm and !aft_mm) {
		cout << "MMYY" << endl;
	} else if (!bef_mm and aft_mm) {
		cout << "YYMM" << endl;
	} else {
		cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 256