akhauriyash/Code-Regression huggingface dataset:
import bisect
#abs(a-b)<c<a+b
N=int(input())
L=sorted([int(i) for i in input().split()])
ans=0
#print(L)
for i in range(N):
    for j in range(i+1,N):
        A=bisect.bisect_left(L,L[i]+L[j])
        B=bisect.bisect_right(L,abs(L[i]-L[j]))
        tmp=A-B
        if B<=i<A:
            tmp-=1
        if B<=j<A:
            tmp-=1
        ans+=tmp
        #print(i,j,A,B,tmp)
print(ans//3)
        

Measured memory_bytes: 48348
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<vin> vvin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())

int main(){
  double n;
  cin>>n;
  cout<<fixed<<setprecision(10);
  double x=n/3;
  cout<<pow(x,3)<<endl;
  
}




Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){

   int N, A, B;
   string S;
   cin>> N>> A>> B>> S;

   int sa=0, sb=0;
   for(int i=0; i<N; i++){
      if(S[i]=='a'){
         if(sa+sb<A+B){
            cout<< "Yes"<< endl;
            sa++;
         }else{
            cout<< "No"<< endl;
         }
      }else if(S[i]=='b'){
         if(sa+sb<A+B&&sb<B){
            cout<< "Yes"<< endl;
            sb++;
         }else{
            cout<< "No"<< endl;
         }
      }else{
         cout<< "No"<< endl;
      }
   }

   return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<n;++i)
#define REP(i, k, n) for(int i=k; i<=n; ++i)
#define REPR(i, k, n) for(int i=k; i>=n; --i)
#define MAX 2001
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define r return
typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
typedef unsigned int long long uill;
int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);
	set<char> s1;
	vector<int> v;
	int flag=1;

	lli t, arr[1000], cnt=0, k=0;
	cin >> t;

	for(int i=0; i<t; ++i){
		cin >> arr[i];

		if(arr[i]%2!=0){
			cout << "0" << "\n";
			return 0;
		}
	}

	
	for(int i=0; ;++i){
		for(int j=0; j<t; ++j){
		if(arr[j]%2==0){
			arr[j] = arr[j]/2;
			
			//cout << arr[j] << " ";
		}else if(arr[j]%2!=0){
			
			 flag=0;
			break;
		}
		
	}

	if(flag==0){
		break;
	}else{
	cnt++;
    }

    }



    cout << cnt << "\n";
	
	

    return 0;


}

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

int main(){
    int N,K;cin>>N>>K;
    vector<long long>a(N);
    for(int i=0;i<N;i++)cin>>a[i];
    sort(a.begin(),a.end());
    long long res=1LL<<60;
    for(int i=0;i+K-1<N;i++)res=min(res,a[i+K-1]-a[i]);
    cout<<res<<endl;
}

Measured memory_bytes: 1152
while True:
    m, f, r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        print('F')
    elif m+f >= 80:
        print('A')
    elif m+f >= 65 and m+f < 80:
        print('B')
    elif m+f >= 50 and m+f < 65:
        print('C')
    elif m+f >= 30 and m+f < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    elif m+f < 30:
        print('F')


Measured memory_bytes: 5596
#include <cstdio>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int x;
  cin >> x;
  int best=1;
  for(int i=2; i<x; ++i) {
    for(int n=i*i; n<=x; n *= i) {
      if(n>best) best=n;
    }
  }
  cout << best << endl;
}


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

int main()
{
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3, y3, x4, y4;
  x3 = x2 + y1 - y2;
  y3 = x2 - x1 + y2;
  x4 = x1 + y1 - y2;
  y4 = y1 + x2 - x1;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	double a,temp,ans;
	while(scanf("%lf",&a)!=EOF){
		ans=0;
		for(int i=1;i<10;i++){
			ans+=a;
			if(i%2==1)
			a*=2;
			else
			a/=3;
		}
		printf("%.8lf\n",a+ans);
		
	}
	return 0;
}

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

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int N;
long long h[100010]; 

const long long INF = 1LL << 60;

long long dp[100010];

int main(){
  int N ; cin >> N;
  for (int i = 0; i < N; ++i) cin >> h[i];
  for (int i = 0; i < 100010; ++i) dp[i] = INF;

  dp[0] = 0;
  for (int i = 0; i < N; ++i){
    chmin(dp[i], dp[i-1] + abs(h[i]-h[i-1]));
    if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i]-h[i-2]));
  } 

  cout << dp[N-1] << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

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

  ld n;
  cin >> n;
  n /= 3;
  n = n * n * n;
  cout << fixed << setprecision(6) << n << "\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.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 DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
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 namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    const int n = 4;
    vi x(n);
    rep(i, n-1){
    	int a, b; cin >> a >> b;
    	a--, b--;
    	x[a]++, x[b]++;
    }

    cout << (*max_element(_all(x)) == 2 ? "YES":"NO") << endl;

    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val n = StdIn.readLine()
    val inputs = StdIn.readLine().split(" ").map(_.toInt).toList
    val min = inputs.foldLeft(Int.MaxValue)(Math.min(_, _))
    val max = inputs.foldLeft(Int.MinValue)(Math.max(_, _))
    val sum = inputs.foldLeft(0L)(_ + _)
    println(s"$min $max $sum")
  }
}

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

using namespace std;

int main(){
    int N,M,a,b,res;
    vector<int> v[51];

    scanf("%d%d",&N,&M);

    for(int i=0;i<M;i++){
        scanf("%d%d",&a,&b);
        v[a].push_back(b);
        v[b].push_back(a);
    }

    for(int i=1;i<=N;i++){
        res = v[i].size();
        printf("%d\n",res);
    }

    return 0;
}

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

int main(){
  string A, B;
  cin >> A >> B;
  if(A.at(0)==B.at(2) && A.at(1)==B.at(1) && A.at(2)==B.at(0)){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: String,
    }
    let mut acc = 0;
    for c in n.chars() {
        acc += c as i32 - 48;
    }
    if acc % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; ll m; cin>>n>>m;
    ll g = 1;
    vll a(n); bool ok=1;
    forn(i,n)
    {
        cin>>a[i];
        if(a[i]&1) ok=0;
        ll h = a[i]/2;
        if(g<0){ cout<<0; return 0; }
        g = (g*h)/gcd(g,h);
    }
    if(!ok){ cout<<0; return 0; }
    forn(i,n)
    {
        ll h = g/(a[i]/2);
        if(~h&1){ ok=0; break; }
    }
    if(!ok) cout<<0;
    else
    {
        ll f = m/g;
        cout<<(f+1)/2;
    }
    

	return 0;
}


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

int main() {
  string s;
  cin >> s;
  bool d = true;
  for (int i = 0; i < 3; i = i + 1) {
    if (s.at(i) == s.at(i + 1)) {
      cout << "Bad" << endl;
      d = false;
      break;
    }
  }
  
  if (d) {
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int f(int a){
	if(a&1){
		return 3*a+1;
	}
	else{
		return a/2;
	}
}
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int s;
	cin>>s;
	map<int,int>mp;
	mp[s]=1;
	int prev=s,ind=1;
	while(1){
		ind++;
		int next=f(prev);
		//Bcout<<next<<" ";
		if(mp.find(next)==mp.end()){
			mp[next]=ind;
			prev=next;
		}
		else{
			cout<<ind<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
//A[i] = 文字列SとS[i:|S|]の最長共通接頭辞の長さ
array<ll,5005> z_algo(string S){
    int c=0,n=S.size();
    array<ll, 5005> z={0};
    for(int i=1;i<n;++i){
        int l=i-c;
        if(i+z[l]<c+z[c]) z[i]=z[l];
        else{
            int j=max(0ll,c+z[c]-i);
            for(;i+j<n&&S[j]==S[i+j];++j);
            z[i]=j;c=i;
        }
    }
    z[0]=n;
    return z;
}

int main() {
    init();
    ll N;
    string s;
    cin>>N>>s;

    ll ans = 0;

    rep(i,N-1){
        array<ll,5005> A = z_algo(s.substr(i,N-i));
        repe(j,i,N){
            chmax(ans, min(j - i, A[j - i]));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
	int n, T, c, t, mini=1001;
	
	scanf("%d %d", &n, &T);
	while(n--){
		scanf("%d %d", &c, &t);
		if(t > T) continue;
		
		mini = min(mini, c);
	}
	
	if(mini == 1001) printf("TLE");
	else printf("%d", mini);
	
	return 0;
}

Measured memory_bytes: 128
from itertools import permutations
from sys import stdin
N = int(stdin.readline().rstrip())
P = tuple([int(_) for _ in stdin.readline().rstrip().split()])
Q = tuple([int(_) for _ in stdin.readline().rstrip().split()])
pidx, qidx = 0, 0
for idx, p in enumerate(list(permutations(i for i in range(1, N+1))), start=1):
    if p == P:
        pidx = idx
    if p == Q:
        qidx = idx
print(abs(pidx - qidx))

Measured memory_bytes: 8052
X, N = map(int, input().split())


p = list(map(int, input().split()))

p.sort()

q=list(range(-200,200))

for i in range(len(q)):
    if q[i] in p:
        q[i]=1000

d=[]
for i in range(len(q)):
    d.append(abs(X-q[i]))

a=min(d)

if X-a in q:
    print(X-a)
else:
    print(X+a)

























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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

vector<vector<int>> g(100001);
vector<int> dp(100001, -1);

int rec(int v) {
  if(dp[v] != -1) return dp[v];
  int &ret = dp[v];
  ret = 0;
  for(auto u : g[v]) {
    chmax(ret, rec(u)+1);
  }
  return ret;
}

int main()
{
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int x, y; cin >> x >> y;
    g[x].push_back(y);
  }

  int ans = 0;
  for(int v = 1; v <= n; ++v) chmax(ans, rec(v));
  cout << ans << endl;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

signed main(){
	int sum=0;
	int n;
	cin>>n;
	int a[n];
	r(i,n){
		cin>>a[i];
		sum+=a[i];
	}

	int ans=sum;
	int s=0;

	for(int i=0;i<n;i++){
		s+=a[i];
		sum-=a[i];
		ans=min(ans,abs(s-sum));
	}

	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
long long a=0;
int main()
{

    cin>>n;

    for(int i=1;i<=n;++i)
    {
        if(i%3 && i%5) a=a+1ll*i;
    }
    cout<<a;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
int a[100005];
int main(int argc, char *argv[])
{
    int k,n;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    long long ans=a[k-1]-a[0];
    for(int i=k;i<n;i++)
    {
        long long b=a[i]-a[i-k+1];
        if(b<ans)ans=b;
    }
    cout<<ans<<endl;
	return 0;

}


Measured memory_bytes: 640
{-# OPTIONS_GHC -O2 #-}

import qualified Data.ByteString.Char8 as C
import Data.Bits
import qualified Data.ByteString.Builder as B
import Data.List
import qualified Data.Vector.Unboxed as U
import System.IO

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

printV :: (Show a, U.Unbox a) => U.Vector a -> IO ()
printV v =
    let showB = B.string8 . show
    in  B.hPutBuilder stdout $ 
            U.foldl' (\ac a -> ac <> B.char8 ' ' <> showB a) (showB $ U.head v) (U.tail v)
                <> B.char8 '\n'

main :: IO ()
main = do
    n <- readLn
    as <- r n
    let x = U.foldr1' xor as
    printV $ U.map (xor x) as

Measured memory_bytes: 46064
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
        string s;
        cin >> s;
        int x = s.size();
        int flag=0,flag2=0,flag3=0;

        if(x>=4 && s[0]=='A' && isupper(s[1])==0&&isupper(s[x-1])==0) {
                for(int i=2; i<x-1; i++) {
                        if(isupper(s[i])!=0) {//oomozidattara
                                if(s[i]=='C') {
                                        flag=1;
                                        flag2++;
                                        flag3=1;
                                }else{
                                        flag2++;
                                }
                        }
                }
        }
        if(flag==1&&flag2==1&&flag3==1) {
                cout << "AC" << endl;
        }else{
                cout << "WA" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
K=int(input())
S=input()
mod=10**9+7

FACT=[1]
for i in range(1,2*10**6+3):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**6+2,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]*FACT_INV[a-b]%mod
    else:
        return 0


LEN=len(S)
ANS=0
for i in range(K+1):
    ANS+=Combi(i+LEN-1,LEN-1)*pow(25,i,mod)*pow(26,K-i,mod)
print(ANS%mod)
    


Measured memory_bytes: 180936
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

#include <bits/stdc++.h>
using namespace std;

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

bool pal (string s)
{
	bool ans = true;
	for (int i = 0; i < s.size () / 2 && ans; ++i)
		ans = (s[i] == s[s.size () - i - 1]);
	return ans;
}

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll tc = 1; //cin >> tc;
	while (tc--)
	{
		ll i, j, n;
		string s;
		cin >> s;
		if (pal (s) &&
				pal (s.substr (0, s.size ()/2)) &&
				pal (s.substr ((s.size () + 1)/2, s.size ()/2)))
			cout << "Yes\n";
		else cout << "No\n";
	}

	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(auto a,long long b){
    long long ans=1;
    //cout<<ans;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    ///cout<<ans<<" ";    
    return ans;
        
}
void maxi(auto &a,auto b){
    a=max(a,b);
}
void mini(auto &a,auto b){
    a=min(a,b);
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x,y;
    cin>>x>>y;
    cout<<(y-1+x-2)/(x-1)<<endl;
    return 0;
}

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

int A[200010];
 
int main() {
	int K, N;
	cin >> K >> N;
	for(int i=0; i<N; ++i) cin >> A[i];
	int mx=(K-A[N-1])+A[0];
	for(int i=1; i<N; ++i){
		mx=max(mx, A[i]-A[i-1]);
	}
	cout << K-mx << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
  int n,a[1000];

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

  for(int i=0; i<n; ++i){
    int v = a[i];
    int j = i-1;
    
    while( j >= 0 && a[j] > v ){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;

    for(int k=0; k<n; ++k){
      cout << a[k];
      if(k<n-1)
	cout << " ";
    }
    cout << endl;
  }


  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <boost/algorithm/string/join.hpp>
#include <boost/range/irange.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using boost::irange;
using boost::algorithm::join;

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

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;

  if (A1+A2+A3>=22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
int main()
{
    // long double pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692;
    double pi = acos(-1);
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double rm;
    rm = double(M * 6);
    double rh;
    rh = double(H * 60 + M) / 2;
    // cout << rh << endl;
    // cout << rm << endl;

    double angle;
    angle = abs(rm - rh);
    // cout << angle << endl;
    // cout << fixed << setprecision(20) << sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(pi * angle / 180)) << endl;
    // cout << fixed << setprecision(20) << static_cast<long double>(sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(pi * angle / 180))) << endl;
    // printf("%.10f\n", double(A));
    // printf("%.10f\n", double(A * A + B * B));
    // printf("%.10f\n", double(2 * A * B) * cos(pi * angle / 180));
    // printf("%.20f\n", double(sqrt(double(A * A + B * B) - double(2 * A * B) * cos(double(pi * angle) / 180))));
    // printf("%.20f\n", double(sqrt(double(A * A + B * B) - double(2 * A * B) * cos(double(pi * angle) / 180))));
    cout << fixed << setprecision(10) << sqrt(double(A * A + B * B) - double(2 * A * B) * cos(pi * angle / 180)) << endl;
    // cout << fixed << setprecision(20) << sqrt(A * A + B * B - 2 * A * B * cos(pi * angle / 180)) << endl;
    // long double rad = (pi * angle) / 180;
    // double c = cos(rad);
    // double x = A * A + B * B - 2 * A * B * c;
    // // cout << fixed << setprecision(20) << static_cast<long double>(rad) << endl;
    // // cout << fixed << setprecision(20) << c << endl;
    // // cout << fixed << setprecision(20) << x << endl;
    // // cout << fixed << setprecision(20) << sqrt(x) << endl;
    // cout << fixed << setprecision(20) << static_cast<double>(sqrt(x)) << endl;
    return 0;
}

Measured memory_bytes: 4192
program Alchemist
    implicit none
    integer(4):: n,i
    integer(4),allocatable:: v(:)
    real(8):: ans
    
    read*, n
    allocate(v(n))
    read*, v(:)

    call merge_sort(v,1,n)
    ans=dble(v(1))
    do i=2,n
        ans=(ans+dble(v(i)))/2d0
    end do
    print*, ans
contains
    recursive subroutine merge_sort(ar, fst, lst)
        integer(4),intent(inout):: ar(:)
        integer(4),intent(in):: fst,lst
        integer(4):: mdl

        if (lst-fst < 2) then
            if (ar(fst) > ar(lst)) call swap(ar(fst),ar(lst))
            return
        end if

        mdl = (fst+lst)/2
        call merge_sort(ar, fst, mdl)
        call merge_sort(ar, mdl+1, lst)
        call merge_(ar, fst, mdl, lst)
    end subroutine

    subroutine merge_(ar, fst, mdl, lst)
        integer(4),intent(inout):: ar(:)
        integer(4),intent(in):: fst, mdl, lst
        integer(4),allocatable:: tmp(:)
        integer(4):: li, ri, ti

        allocate(tmp(lst-fst+1))

        li=fst
        ri=mdl+1   
        ti=1

        do while (li <= mdl .and. ri <= lst)
            if (ar(li) <= ar(ri)) then
                tmp(ti) = ar(li)
                li=li+1
            else
                tmp(ti) = ar(ri)
                ri=ri+1
            end if
            ti=ti+1
        end do

        if (li <= mdl) then
            tmp(ti:) = ar(li:mdl)
        else
            tmp(ti:) = ar(ri:lst)
        end if

        ar(fst:lst) = tmp(:)
        deallocate(tmp)
    end subroutine

    subroutine swap(x,y)
        integer(4),intent(inout):: x,y
        integer(4):: tmp
        tmp = x
        x = y
        y = tmp
    end subroutine
end program Alchemist

Measured memory_bytes: 512
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
import copy

n,k = getList()
buff = []
for i in range(n):
    buff.append(getList())

def calc(width, cutbuf, k):
    nn= len(cutbuf)
    cutbuf.sort(key=lambda x: x[1])
    ret = 10**19
    for ii in range(nn-k+1):
        tmptmp = abs(cutbuf[ii][1] - cutbuf[ii+k-1][1])
        #print("here")
        if ret > tmptmp:
            #print("here")
            ret = tmptmp
    #print(ret, cutbuf)
    return ret*width
buff.sort()
ans = 10**19
for i in range(n):
    for j in range(i+1, n):
        width = abs(buff[i][0] - buff[j][0])
        tmp = calc(width, buff[i:j+1], k)

        if ans > tmp:
            ans = tmp

print(ans)

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


signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	
	int n, i, j;
	cin>>n;
	long double p[n+1];
	for(i=1;i<=n;i++)
		cin>>p[i];
	long double dp[n+5][n+5];
	for(i=0;i<n+2;i++)
		for(j=0;j<n+2;j++)
			dp[i][j]=0;
	dp[0][0]=1;
	for(i=1;i<=n;i++)
		dp[i][0]=dp[i-1][0]*(1-p[i]);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=i;j++)
		{
			dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
		}
	}
	long double sum=0;
	for(j=(n+1)/2;j<=n;j++)
		sum += dp[n][j];
	cout<<fixed<<setprecision(15)<<sum<<endl;
}


Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
string n; int k;
int digit[111];
LL dp[111][111];
LL dfs(int pos, int nonzero, bool limit) {
    if (pos==n.size()) {
        return nonzero == k;
    }
    if (!limit && dp[pos][nonzero] != -1) return dp[pos][nonzero];
    int up = limit ? digit[pos] : 9;
    LL ret = 0;
    for (int i = 0; i <= up; i++) {
        ret += dfs(pos + 1, nonzero + (i != 0), limit && i == digit[pos]);
    }
    if (!limit) dp[pos][nonzero] = ret;
    return ret;
}
int main() {
    memset(dp, -1L, sizeof dp);
    cin >> n >> k;
    for (int i = 0; i < n.size();i++) digit[i] = n[i]-'0';
    cout << dfs(0, 0, true) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string s[1000], t[1000];
	int n, m,kane=0,saikou;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> s[i];
	cin >> m;
	for (int i = 0; i < m; i++)cin >> t[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (s[i] == s[j])kane++;
		}
		for (int k = 0; k < m; k++) {	
			if (s[i] == t[k])kane--;
		}
		if (i == 0)saikou = kane;
		if (saikou < kane)saikou = kane;
		kane = 0;
	}
	if(saikou>=0)cout << saikou << endl;
	else cout << "0" << endl;
	int x;
	cin >> x;
	return 0;
}

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

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

using namespace std;

int A, B;

int compare(int a, int b) {
    if (a == b) return 0;
    if (a == 1) return 1;
    if (b == 1) return -1;
    return a - b;
}

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

    int result = compare(A, B);
    if (result > 0) {
        cout << "Alice" << endl;
    } else if (result < 0) {
        cout << "Bob" << endl;
    } else {
        cout << "Draw" << endl;
    }
}


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

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

  vector<ll> a(n);
  vector<vector<ll>> x(n);
  vector<vector<ll>> y(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    x[i].resize(a[i]);
    y[i].resize(a[i]);
    for (ll j = 0; j < a[i]; j++) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  ll ans = 0;
  for (ll mask = 0; mask < 1ll << n; mask++) {
    bool ok = true;
    for (ll i = 0; i < n; i++) {
      if (!(mask >> i & 1ll)) continue; 
      for (ll j = 0; j < a[i]; j++) {
        if ((mask >> x[i][j] & 1ll) != y[i][j]) ok = false;
      }
    }
    if (ok) ans = max(ans, (ll)__builtin_popcountll(mask));
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int x;
int main(){
	cin>>s;
	for (int i=0;i<s.size();i++) x+=s[i]-'0';
	if (x%9==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define pb(x) push_back(x)
#define fi first
#define se second
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

int a[100010];
signed main(){
	int n, x;
	scanf("%lld%lld", &n, &x);
	rep(i,n)scanf("%lld", &a[i]);
	int ans = 0;
	rep(i,n){
		if(a[i]+a[i+1] > x){
			int d = a[i]+a[i+1]-x;
			ans += d;
			a[i+1] -= d;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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

int main(void){
	int n;
	scanf("%d",&n);

	int k;
	scanf("%d",&k);

	int h[n];
	for(int i = 0; i < n; i++){
		scanf("%d",&h[i]);
	}

	int ans = 0;
	for(int i = 0; i < n; i++){
		if(h[i] >= k){
			ans += 1;
		}
	}

	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	int i;
	for (i = 0; i < 100 * b; i++)
	{
		if (8 * i / 100 == a && i / 10 == b)
		{
			printf("%d\n", i);
			return 0;
		}
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 128
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
t1 = N
t2 = 0
t3 = 0
t4 = 0
t5 = 0
t6 = 0
w = 0
while(t6 != N):
    w += 1
    if t5 > 0:
        t6 += min(t5, E)
        t5 = max(0, t5 - E)
    if t4 > 0:
        t5 += min(t4, D)
        t4 = max(0, t4 - D)
    if t3 > 0:
        t4 += min(t3, C)
        t3 = max(0, t3 - C)
    if t2 > 0:
        t3 += min(t2, B)
        t2 = max(0, t2 - B)
    if t1 > 0:
        t2 += min(t1, A)
        t1 = max(0, t1 - A)
    if t6 >= 1:
        break
print(int(math.ceil(N / t6)) + 5 - 1)

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

int main() {
    int N, K, Q;  cin >> N >> K >> Q;
    long long minus = 0;
    vector<long long> plus(N);
    for (int i = 0; i < Q; ++i) {
        int a;  cin >> a;
        ++minus;
        ++plus[a - 1];
    }
    for (int i = 0; i < N; ++i) {
        if (K - minus + plus[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}


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

int A, B, C, K;
int ans;

void solve() {
  if (K >= A) {
    K -= A;
    ans += A;
  } else {
    ans += K;
    return;
  }
  if (K >= B) {
    K -= B;
  } else {
    return;
  }
  ans -= K;
  return;
}

int main() {
  std::cin >> A >> B >> C >> K;
  solve();
  std::cout << ans << std::endl;
}


Measured memory_bytes: 3632
#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 <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>
#include <chrono>

#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 = asin (1) * 2;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin >> n;
	int s = 0;
	fl (i, 1, n + 1) {
		if (i % 3 && i % 5) s += i;
	}
	cout << s;







}

Measured memory_bytes: 3184
n = int(input())
v = list(map(int,input().split()))

v1 = []
v2 = []
for i in range(n):
    if i%2 == 0:
        v1.append(v[i])
    else:
        v2.append(v[i])
v1.sort()
v2.sort()

v1num = []
v2num = []
cnt1 = []
cnt2 = [] 
for x in v1:
    if x not in v1num:
        v1num.append(x)
        cnt1.append(1)
    else:
        cnt1[-1] += 1
for x in v2:
    if x not in v2num:
        v2num.append(x)
        cnt2.append(1)
    else:
        cnt2[-1] += 1
#print(v1num,v2num,cnt1,cnt2)

res = 0
m1 = max(cnt1)
m2 = max(cnt2)
maxc1ind = cnt1.index(m1)
maxc2ind = cnt2.index(m2)
maxc1 = v1num[maxc1ind]
maxc2 = v2num[maxc2ind]
if maxc1 != maxc2:
    res = n - m1 - m2
else:
    if len(cnt1) == 1 and len(cnt2) == 1:
        res = n // 2
    else:    
        cnt1.sort(reverse=True)
        cnt2.sort(reverse=True)
        x1 = cnt1[0] + cnt2[1]
        x2 = cnt1[1] + cnt2[0]
        res = n - max(x1,x2)
print(res)

Measured memory_bytes: 57196
#include<bits/stdc++.h>
  using namespace std;
  #define magic ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)


 
  int32_t main()
  {        


     magic

      string s;
      cin >> s;


      int ans = 0;


      int i = 0,j = s.length() - 1;


      while(i < j)
      {
        if(s[i] != s[j])
        {
          ans++;
        }
        i++;
        j--;

      }

      cout << ans;  


    return  0;
     }



Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

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


int GCD(int a, int b){
    if(a < b) swap(a, b);
    if(b==0) return a;
    return GCD(b, a%b);
}

LL pow(LL x, LL n){
    LL res = 1;
    while(n>0){
        if(n&1){
            res *= x;
        }

        x = x*x;
        n >>= 1;
    }
    return res;
}
int main() {
    cout << fixed << setprecision(15);

    int N, K; cin >> N >> K;

    long double ans = 0.0;

    for(int i=1; i<=N; ++i){
        int t=i;
        int cn = 1;
        while(t<K){
            t *= 2;
            cn <<= 1;
        }

        ans += (double)1/N / cn;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C,D,E,ans=0;
    cin>>A>>B>>C>>D>>E;
    if(A<0){
        ans=(0-A)*C+D+B*E;}
    else{
        ans=(B-A)*E;}
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
int main(){
    int i,j;
    int n,m,c; cin>>n>>m>>c;
    int b[m]; rep(i,m)cin>>b[i];
    int ans=0;
    int fake;
    rep(i,n){
        fake=0;
        rep(j,m){
            int a; cin>>a;
            fake+=a*b[j];
        }
        if(fake+c>0)ans++;
    }




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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
int main()
{
  int t;
  ll a[310],b[310],c[310],d[310],tmp,r,x,y;
  cin >> t;
  rep(i,t)cin >> a[i] >> b[i] >> c[i] >> d[i];
  rep(i,t){
    x=b[i];
    y=d[i];
    if(x<y){
      tmp=x;
      x=y;
      y=tmp;
    }
    r=x%y;
    while(r!=0){
      x=y;
      y=r;
      r=x%y;
    }
    if(b[i]<=d[i]&&a[i]>=b[i]&&a[i]%y<=c[i]%y&&b[i]/y<c[i]/y+2)printf("Yes\n");
    else if(b[i]<=d[i]&&a[i]>=b[i]&&a[i]%y>c[i]%y&&b[i]/y<c[i]/y+1)printf("Yes\n");
    else printf("No\n");
  }
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
    ll n,x,t;
    cin>>n>>x>>t;
    if(n%x==0)
    cout<<(n/x)*t;
    else
    cout<<((n/x)+1)*t;
    
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		System.out.println(a*b/2);
	}

}


Measured memory_bytes: 21716
//
// Created by Naman Bhalla on 2019-05-26.
//

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <utility>
#include <climits>
#include <iostream>

using namespace std;

long long int dp[1001][1001];
const int mod {1000000007};
int main(){
    memset(dp, 0, sizeof dp);
    int h, w;
    cin >> h >> w;

    char n;

    for(int i = 1; i <= h; ++i){
        for(int j = 1; j <= w; ++j){
            cin >> n;
            if(n == '.'){
                dp[i][j] = 1;
            } else {
                dp[i][j] = 0;
            }
        }
    }

    dp[0][1] = 1;
    for(int i = 1; i <= h; ++i){
        for(int j = 1; j <= w; ++j){
            if(dp[i][j]){
                dp[i][j] = dp[i - 1][j] % mod + dp[i][j - 1] % mod;
                dp[i][j] %= mod;
            }
//            cout << dp[i][j] << " ";
        }
//        cout << endl;
    }
    
    cout << dp[h][w] << endl;
    return 0;
}

Measured memory_bytes: 8064
#「探索候補スタック」「探索済みリスト」「現在地点」の３点セットでとらえる
while 1:
    w,h=map(int,input().split())
    if w==h==0:
        break
    c=[list(map(int,input().split())) for _ in range(h)]
    dxdy=[[1,0],[-1,0],[0,1],[0,-1],[1,1],[1,-1],[-1,1],[-1,-1]]
    ans=0
    for y in range(h):
        for x in range(w):
            if c[y][x]:
                ans+=1
                stack=[]
                stack.append([x,y])
                while stack:
                    xx,yy=stack.pop()
                    for dx,dy in dxdy:
                        nx=xx+dx
                        ny=yy+dy
                        if 0<=nx<w and 0<=ny<h:
                            if c[ny][nx]:
                                c[ny][nx]=0
                                stack.append([nx,ny])
    print(ans)


Measured memory_bytes: 5720