akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=200005;

int n,a[MAXN],b[MAXN],c[MAXN];
ll s[MAXN];

int main()
{
	#ifndef ONLINE_JUDGE
//	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	ll sa=0,sb=0;
	readint(n);
	for(int i=1;i<=n;++i)
	{
		readint(a[i]),readint(b[i]);
		c[i]=a[i],c[i+n]=b[i];
		sa+=a[i],sb+=b[i];
	}
	ll ans=min(sa,sb);
	sort(c+1,c+2*n+1);
	for(int i=1;i<=n;++i)s[i]=s[i-1]+c[i];
	for(int i=1;i<=n;++i)
	{
		int x=lower_bound(c+1,c+2*n+1,a[i])-c,
			y=lower_bound(c+1,c+2*n+1,b[i])-c;
		if(x<=n && y<=n)chkmin(ans,s[n]);
		if(x<=n-1 && y>n-1)chkmin(ans,s[n-1]+c[y]);
		if(x>n-1 && y<=n-1)chkmin(ans,s[n-1]+c[x]);
		if(x>n-2 && y>n-2)chkmin(ans,s[n-2]+c[x]+c[y]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;
 
/**
 * Created by sonetsuyoshi on 2016/07/31.
 */
public class Main {
 
    static public void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] chs = sc.nextLine().toCharArray();
        chs[5] = ' ';
        chs[13] = ' ';
 
        for(char ch: chs) System.out.print(ch);
        System.out.println();
    }
}

Measured memory_bytes: 10196
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	string s;
	cin>>s;
	ll indexa=INF,indexz=0;
	rep(i,s.size()){
		if(s[i]=='A'){
			indexa=min((ll)i,indexa);
		}
		if(s[i]=='Z'){
			indexz=max((ll)i,indexz);
		}
	}
	cout<<indexz-indexa+1<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'
signed main() {
  int a, b;
  cin >> a >> b;
  string s, t;
  rep (i, b) s += '0' + a;
  rep (i, a) t += '0' + b;
  if (s < t) {
    cout << s << endl;
  }
  else {
    cout << t << endl;
  }
  return 0;
}

Measured memory_bytes: 256
///////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////
#define ll long long
#define ull insigned lon long
///////////////////////////////////////////////////////////
void input(vector<int>& vec);
void print(vector<int> vec);
void upsort(vector<int>& vec);
void downsort(vector<int>& vec);
int maxvec(vector<int> vec);
int minvec(vector<int> vec);
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int main()
{
    int n;
    cin >> n;
    int a=n/1000;
    int b=n/100-10*a;
    int c=n/10-100*a-10*b;
    int d=n-1000*a-100*b-10*c;
    if(a==b||b==c||c==d){
        cout<<"Bad"<<endl;
    }else{
        cout<<"Good"<<endl;
    }
    return 0;
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
void input(vector<int>& vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cin >> vec.at(i);
    }
}

void print(vector<int> vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

void upsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end());
}

void downsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end(), greater<int>());
}

int maxvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = max(m, vec.at(i));
    }
    return m;
}

int minvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = min(m, vec.at(i));
    }
    return m;
}
///////////////////////////////////////////////////////////

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	H, err := strconv.Atoi(scanner.Text())
	scanner.Scan()
	N, err := strconv.Atoi(scanner.Text())

	target := 0
	var errs error

	for i := 0; i < N; i++ {
		scanner.Scan()
		target, errs = strconv.Atoi(scanner.Text())
		if errs != nil {
			log.Fatal(err)
		}
		H -= target
	}

	if H <= 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 2360
package main;

import "fmt"

func main() {
	var N, K, X, Y int
	fmt.Scan(&N, &K, &X, &Y)
	l := (N - K)
	if l < 0 {
		l = 0
	}
	if N < K {
		K = N
	}
	fmt.Println(K * X + l * Y)

}



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

#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

ll vacation(vector<vector<ll>> &v,vector<vector<ll>> &dp,ll i,ll k)
{
    if(i==-1)
        return 0;
    if(dp[i][k]!=-1)
        return dp[i][k];

    return dp[i][k] = max(v[i][k]+vacation(v,dp,i-1,(k+1)%3),v[i][k]+vacation(v,dp,i-1,(k+2)%3));
}

int main(){

    IOS;

    ll t,n,k,m;
    t=1;
    while(t--)
    {
        cin >> n ;
        vector<vector<ll>> v(n,vector<ll>(3));
        vector<vector<ll>> dp(n,vector<ll>(3,-1));
        for(ll i=0;i<n;i++)
        {
            cin >> v[i][0] >> v[i][1] >> v[i][2];
        }

        ll ans = max(vacation(v,dp,n-1,0),max(vacation(v,dp,n-1,1),vacation(v,dp,n-1,2)));
        cout << ans << endl;
    }
    return 0;
}


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


void solve(long long N, std::vector<long long> A){
	const int B = 2000001;
	bitset<B> bs;
	bs.set(0);
	long long S = 0;
	for(int i = 0;i < N;i++){
		bs |= (bs << A[i]);
		S += A[i];
	}
	for(int s = S/2;s>=0;s--){
		if(bs.test(s)){
			cout<< S - s<<endl;
			return;
		}
	}
}

// Generated by 1.1.6 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> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
const ll MAX = 16005;

bool dp0[MAX], dp1[MAX];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll X, Y;
    cin >> X >> Y;
    vector<ll> x, y;
    ll cnt = 0;
    bool rot = true;
    REP(i, S.length()) {
        if (S[i] == 'T') {
            if (rot)
                x.push_back(cnt);
            else
                y.push_back(cnt);
            cnt = 0;
            rot = !rot;
        }
        else
            cnt++;

        if (i == S.length() - 1) {
            if (rot)
                x.push_back(cnt);
            else
                y.push_back(cnt);
        }
    }
    
    {
        ll base = 8000;
        memset(dp0, 0, sizeof(dp0));
        dp0[base] = true;
        if (x.size() > 0) {
            dp0[base] = false;
            dp0[base + x[0]] = true;
        }
        FOR(i, x.size(), 1) {
            memset(dp1, 0, sizeof(dp1));
            REP(j, MAX) {
                if (!dp0[j])
                    continue;
                ll p = j - x[i], n = j + x[i];
                if (p >= 0)
                    dp1[p] = true;
                if (n < MAX)
                    dp1[n] = true;
            }
            swap(dp0, dp1);
        }

        if (!dp0[base + X]) {
            cout << "No" << endl;
            return 0;
        }
    }
    {
        ll base = 8000;
        memset(dp0, 0, sizeof(dp0));
        dp0[base] = true;
        REP(i, y.size()) {
            memset(dp1, 0, sizeof(dp1));
            REP(j, MAX) {
                if (!dp0[j])
                    continue;
                ll p = j - y[i], n = j + y[i];
                if (p >= 0)
                    dp1[p] = true;
                if (n < MAX)
                    dp1[n] = true;
            }
            swap(dp0, dp1);
        }

        if (!dp0[base + Y]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
int main(){
	long long a,b;
	scanf("%lld %lld",&a,&b);
	if(a<b){
		long long c = a;
		a = b;
		b = c;
	}
	if(a-b>=2){
		printf("Alice\n");
	}else{
		printf("Brown\n");
	}
}

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

typedef long long ll;


ll res(ll a,ll d)
{
    ll i, sum=0,k;



    for(i=1; i<=d; i=i+a)
    {

        sum++;

    }

    return sum;
}


int main()
{
    ll d,x,n,a,sum=0;




    cin >> n;

    cin >> d >> x;

    while(n--)
    {
        cin >> a;

        sum = sum+res(a,d);


    }

    cout << sum+x << endl;

    return 0;

}



Measured memory_bytes: 256
import sys
from collections import Counter

if __name__ == '__main__':
    # ??????????????\???
    # line = 'Thank you for your mail and your lectures'
    data = []
    for line in sys.stdin:
        data = line.strip().strip('.').lower().split(' ')

    # print(data)

    # ??????????¢??????????
    c = Counter(data)  # ????????????????¢????
    most_frequent_word = c.most_common(1)[0][0]
    # ???????????????????????¢???
    max_length_word = ''
    for w, freq in c.most_common():
        if len(w) > len(max_length_word):
            max_length_word = w

    # ???????????¨???
    print('{0} {1}'.format(most_frequent_word, max_length_word))

Measured memory_bytes: 7688
# frozen_string_literal: true

x, n = gets.split.map(&:to_i)
if n.zero?
  puts x
  exit
end
p = gets.split.map(&:to_i)
min = 1000
ans = 1000
0.upto(101) do |i|
  next if p.include?(i)

  d = (i - x).abs
  if d < min
    min = d
    ans = i
  end
end

puts ans


Measured memory_bytes: 14280
#include<bits/stdc++.h>
#define io std :: ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define M 1000000007;
using namespace std;
int main()
{
    io;
    int n,n1;
    cin>>n;
    if(n%2==0)
        n1=n/2;
    else
        n1=(n+1)/2;
    double d=(double)n1/n;
    printf("%.10f",d);
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 2e5 + 10;
ll ans[maxn];
int n, A[maxn];

vector <int> E[maxn], vec[maxn];

int fa[maxn], sz[maxn], bl[maxn], son[maxn], lst[maxn];

void dfs(int u, int f) {
  int x = lst[A[u]];
  fa[u] = f, bl[u] = son[x];
  vec[x].push_back(u), lst[A[u]] = u;
  for (int v : E[u]) if (v != f) {
    son[u] = v, dfs(v, u), sz[u] += sz[v];
  }
  lst[A[u]] = x, sz[u]++;
}

int T, vis[maxn], cnt[maxn];

int main() {
  cin >> n;
  rep(i, 1, n) A[i] = read();
  rep(i, 2, n) {
    int u = read(), v = read();
    E[u].push_back(v), E[v].push_back(u);
  }
  son[0] = 1;
  dfs(1, 0);
  rep(u, 1, n) {
    T++;
    for (int v : vec[u]) {
      if (vis[bl[v]] < T) vis[bl[v]] = T, cnt[bl[v]] = 0;
      cnt[bl[v]] += sz[v];
    }
    for (int v : E[u]) if (v != fa[u]) {
      if (vis[v] != T) {
        ans[A[u]] += 1ll * sz[v] * (sz[v] + 1) / 2;
      }
    }
    for (int v : vec[u]) {
      if (vis[bl[v]] == T) {
        int cur = sz[bl[v]] - cnt[bl[v]];
        ans[A[u]] += 1ll * cur * (cur + 1) / 2;
        vis[bl[v]] = 0;
      }
    }
  }
  memset(cnt, 0, sizeof cnt);
  for (int u : vec[0]) {
    cnt[A[u]] += sz[u];
  }
  rep(i, 1, n) if (A[1] != i) {
    int cur = n - cnt[i];
    ans[i] += 1ll * cur * (cur + 1) / 2;
  }
  rep(i, 1, n) printf("%lld\n", 1ll * n * (n + 1) / 2 - ans[i]);
  return 0;
}

Measured memory_bytes: 48052
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a;
  cin>>a;
  vector< double> b(a);
  rep(i,a)
    cin>>b.at(i);
   double d=0;
  rep(i,a)
    d+=1/b.at(i);
  
  cout<<setprecision(13)<<1/d;
}


Measured memory_bytes: 256
import sys
n,k=map(int,input().split())
s=input()
snum=[]
now_si=""
now_sinum=0
for i in range(len(s)):
    if(now_si!=s[i]):
        now_si=s[i]
        snum.append(now_sinum)
        now_sinum=1
    else:
        now_sinum+=1
else:
    snum.append(now_sinum)
snum.pop(0)

if(len(snum)<3):
    print(sum(snum)-1)
    sys.exit()

for i in range(k):
#    print(snum)
    if(len(snum)<3):
        snum=[sum(snum)]
        break

    snum[-3]+=snum[-2]+snum[-1]
    snum.pop(-1)
    snum.pop(-1)

print(sum(snum)-len(snum))

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

int main(){
	
	int A, B;
	cin >> A >> B;
	
	if ( A % 3 == 0 || B % 3 == 0 || ( A + B ) % 3 == 0 ){
		cout << " Possible " << endl;
	} else {
		cout << " Impossible " << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int S;
	std::cin >> S;

	int h, m, s;
	h = S / 3600;
	m = (S % 3600) / 60;
	s = (S % 3600) % 60;
	
	std::cout << h << ":" << m << ":" << s << std::endl;
	
	return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a;
  cin>>a;
  int b=a/11;
  int c=a%11;
  if(c>6)
    cout<<b*2+2<<endl;
  else if(c!=0)
    cout<<2*b+1<<endl;
  else
    cout<<2*b<<endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from collections import deque
INF = float('inf')


def main():
    import sys
    read = sys.stdin.read
    readline = sys.stdin.readline
    readlines = sys.stdin.readlines
    from collections import deque

    H, W, K = map(int, readline().split())
    x1, y1, x2, y2 = map(int, readline().split())
    x1 -= 1;
    y1 -= 1;
    x2 -= 1;
    y2 -= 1
    C = read().split()

    dist = [[-1] * W for i in range(H)]
    dist[x1][y1] = 0
    d = deque([[x1, y1]])
    dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]]
    while d:
        x, y = d.popleft()
        if (x, y) == (x2, y2):
            print(dist[x][y])
            quit()
        for dx, dy in dxy:
            xx = x;
            yy = y
            for i in range(K):
                xx += dx;
                yy += dy
                if 0 <= xx < H and 0 <= yy < W and C[xx][yy] != '@':
                    if 0 <= dist[xx][yy] <= dist[x][y]:
                        break
                    if dist[xx][yy] == -1:
                        d.append([xx, yy])
                    dist[xx][yy] = dist[x][y] + 1
                else:
                    break

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 119456
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int main() {
	int n, r = 10000000, c, j, k;
	scanf("%d", &n);
	REP(i, n + 1) {
		c = 0;
		k = i;
		j = n - i;
		for (c += k % 6; k; c += k % 6) k /= 6;
		for (c += j % 9; j; c += j % 9) j /= 9;
		r = min(r, c);
	}
	printf("%d", r);
	return 0;
}


Measured memory_bytes: 128
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Score = Tuple!(long, "p", long, "c");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto a = aryread();
    long f;
    foreach(e; a)
    {
        f += e - 1;
    }
    f.writeln();
}


Measured memory_bytes: 2428
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    bool operator<(const P &p) const {
        return l < p.l;
    }
    int l, r, c;
};

struct Q {
    bool operator<(const Q &q) const {
        return c != q.c ? c > q.c : i < q.i;//逆
    }
    int i;
    ll c;
};

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

    int n, m;
    cin >> n >> m;

    vector<P> p(m);
    for (int j = 0; j < m; j++) {
        int l, r, c;
        cin >> l >> r >> c;
        l--; r--;//[l, r]

        p[j] = { l, r, c };
    }
    sort(p.begin(), p.end());

    priority_queue<Q> pq;
    pq.push({ 0, 0 });

    int j = 0;
    while (!pq.empty()) {
        Q q = pq.top(); pq.pop();
        if (q.i == n - 1) {
            cout << q.c << endl;
            exit(0);
        }

        for (; j < m; j++) {
            if (p[j].r < q.i) continue;
            if (p[j].l > q.i) break;
            ll c1 = q.c + p[j].c;
            int i1 = p[j].r;
            pq.push({ i1, c1 });
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3572
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
n = int(input())
l = [0]*n
for i in range(n):
    l[i] = int(input())
    for j in range(3):
        if l[i] == a[j]:
            a[j] = 0
        elif l[i] == b[j]:
            b[j] = 0
        elif l[i] == c[j]:
            c[j] = 0
ans = 'No'
if a[0]+a[1]+a[2] == 0 or b[0]+b[1]+b[2] == 0 or c[0]+c[1]+c[2] == 0:
    ans = 'Yes'
if a[0]+b[0]+c[0] == 0 or a[1]+b[1]+c[1] == 0 or a[2]+b[2]+c[2] == 0:
    ans = 'Yes'
if a[0]+b[1]+c[2] == 0 or a[2]+b[1]+c[0] == 0:
    ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;




int a[3][3];
int main(){
  rep(i,3) rep(j,3) cin>>a[i][j];
  int n;
  cin>>n;
  rep(num,n){
    int b;
    cin>>b;
      
    rep(i,3){
      rep(j,3){
        if (a[i][j]==b) a[i][j]=0;
      }
    }
  }
  
  bool ans=false;
   
  rep(i,3){
    if(a[i][1]+a[i][2]+a[i][0]==0) ans=true;
    if(a[1][i]+a[2][i]+a[0][i]==0) ans=true;
  }
  if(a[0][0]+a[1][1]+a[2][2]==0) ans=true;
  if(a[2][0]+a[1][1]+a[0][2]==0) ans=true;
  
  if(ans==true) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
 
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>
using namespace std;

const int INF = 1 << 20;
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

struct coo {
    int x;
    int y;
};

int main() {
    int H, W, K;
    cin >> H >> W >> K;

    string S[H];
    coo s;
    for (int x = 0; x < H; ++x) {
        cin >> S[x];
        for (int y = 0; y < W; ++y) {
            if (S[x][y] == 'S') {
                s = {x, y};
            }
        }
    }

    int d[H][W];
    fill(d[0], d[H], INF);

    queue<coo> que;
    que.push(s);
    d[s.x][s.y] = 0;

    // 壁を避けてK回移動
    while (!que.empty()) {
        coo v = que.front();
        que.pop();

        // K回以内で出られる場合
        if (v.x == 0 || v.x == H - 1 || v.y == 0 || v.y == W - 1) {
            cout << 1 << endl;
            return 0;
        }

        if (d[v.x][v.y] == K) continue;

        for (int i = 0; i < 4; ++i) {
            coo sv = {v.x + dx[i], v.y + dy[i]};

            // 境界外なら上で弾かれている
            if (S[sv.x][sv.y] == '#' || d[sv.x][sv.y] < INF) continue;

            d[sv.x][sv.y] = d[v.x][v.y] + 1;
            que.push(sv);
        }
    }

    // 外までの最短距離
    // ここまで来たら壁ガン無視でOK
    int mi = INF;
    for (int x = 0; x < H; ++x) {
        for (int y = 0; y < W; ++y) {
            if (d[x][y] == INF) continue;
            mi = min(mi, min(x, H - x - 1));
            mi = min(mi, min(y, W - y - 1));
        }
    }

    cout << (mi + K - 1) / K + 1 << endl;
    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>
#include<stack>

using namespace std;

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

vector<pair<int, int> > pita[20000];
vector<int> yaku[20000];

void prep(){
	for(int i=1;i<20000;i++){
		for(int j=2;j*j<=i;j++){
			if(i%j==0)yaku[i].push_back(j);
		}
	}
	for(int k=0;k*k<20000;k++){
		for(int l=k;l*l+k*k<20000;l++){
			pair<int, int> m;
			m.first = k;
			m.second = l;
			pita[l*l+k*k].push_back(m);
		}
	}
}

int main(){
	int i, j, a, p, q;
	prep();
	cin >> a;
	REP(i,a){
		string ans = "P";
		cin >> p >> q;
		REP(j,yaku[p*p+q*q].size()){
			REP(k,pita[yaku[p*p+q*q][j]].size()){
				int m = pita[yaku[p*p+q*q][j]][k].first;
				int n = pita[yaku[p*p+q*q][j]][k].second;
				if((m*p+n*q)%(m*m+n*n)==0 && (abs(m*q-n*p))%(m*m+n*n)==0) ans = "C";
				if((n*p+m*q)%(m*m+n*n)==0 && (abs(n*q-m*p))%(m*m+n*n)==0) ans = "C";
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

struct LazySegmentTree {
  vector<long long> data, lazy;
  int n;
  long unit = -(1<<30);

  LazySegmentTree(int n_) {
    for(n = 1; n < n_; n *= 2);
    data.assign(n*2 - 1, unit);
    lazy.assign(n*2 - 1, 0);
  }

  void propagate(int i, int l, int r) {
    if(data[i] == unit) data[i] = 0;

    if(lazy[i] != 0) {
      data[i] += lazy[i];

      if(r - l > 1) {
        lazy[i*2+1] += lazy[i];
        lazy[i*2+2] += lazy[i];
      }
    }

    lazy[i] = 0;
  }

  void update(int a, int b, long long x, int i = 0, int l = 0, int r = -1) {
    if(r < 0) r = n;

    propagate(i, l, r);

    if(b <= l || r <= a) return;
    if(a <= l && r <= b) {
      lazy[i] += x;
      propagate(i, l, r);
    } else {
      update(a, b, x, i*2+1, l, (l+r)/2);
      update(a, b, x, i*2+2, (l+r)/2, r);
      data[i] = max(data[i*2+1], data[i*2+2]);
    }
  }

  long long query(int a,int b,int i = 0,int l = 0, int r = -1) {
    if(r < 0) r = n;
    if(b <= l || r <= a) return unit;

    propagate(i, l, r);
    if(a <= l && r <= b) return data[i];
    long long vl = query(a, b, i*2+1, l, (l+r)/2);
    long long vr = query(a, b, i*2+2, (l+r)/2, r);
    return max(vl, vr);
  }
};

long n, m, l, r, a;
#define left first
#define score second
vector<pair<long, long>> intervals[200010];

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for(int i = 0; i < m; ++i) {
    cin >> l >> r >> a;
    intervals[r].emplace_back(l, a);
  }
  LazySegmentTree dp(n + 1);

  for(int i = 1; i <= n; ++i) {
    dp.update(i, i + 1, dp.query(0, i));
    for(auto itv: intervals[i]) {
      dp.update(itv.left, i + 1, itv.score);
    }
  }
  cout << dp.query(0, n + 1);
  return 0;
}

Measured memory_bytes: 19456
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] m = new int[n];
        int mmax = 0;
        int ans = n;
        for(int i = 0;i < n;i++){
            m[i] = sc.nextInt();
            mmax += m[i];
        }
        x -= mmax;
        Arrays.sort(m);
        while(x >= m[0]){
            x -= m[0];
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22100
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod.m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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


int main(){
    int k;
    cin >> k;
    int remain = 7;
    rep(i,5*10e6){
        remain = remain%k;
        if(remain == 0){
            cout << i+1 << endl;
            return 0;
        }else{
            remain = remain*10 + 7;
        }
    }
    cout << "-1" <<endl;
}



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

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

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> vi(n);
    int cnt=0;
    REP(i,n){
        cin>>vi[i];
        cnt+=vi[i];
    }
    sort(ALL(vi));
    if(vi[vi.size()-m]*4*m<cnt){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 3592
import java.io.*;
import java.util.*;
class Main{
	public static void main(String[] args) throws Exception{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		//Buffered
		int t = 1;
		// t = Integer.parseInt(reader.readLine());
		// long[] list = Arrays.stream(reader.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
		for(int u = 0;u<t;u++){
			String s = reader.readLine();
			long[] list = Arrays.stream(reader.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
			long last = list[0];
			long ans = 0;
			for(int i = 1;i<list.length;i++){
				if(list[i]>=last) last = list[i];
				else{
					ans += (last-list[i]);
				}
			}
			System.out.println(ans);
		}
	
	}
	
}
class pair implements Comparable<pair>{
		long a = 0;
		int b = 0;
		public pair(long a,int b){
			this.a = a;
			this.b = b;
		}
		@Override
		public int compareTo(pair p){
			if(this.a == p.a) return -(Integer.compare(this.b,p.b));
			else return -(Long.compare(this.a,p.a));
		}
		@Override
		public String toString(){
			return a+" "+b;
		}
	}

Measured memory_bytes: 63196
import java.util.Scanner;

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

	public static void main(String[] args) {

		int n = sc.nextInt();
		int num[] = new int[10];
		String str = "YES";

		for (int s = 0; s < n; s++) {
			int max = 0;
			int min = 0;
			for (int i = 0; i < 10; i++) {
				num[i] = sc.nextInt();
			}
			max=num[0];
			for (int i = 1; i < 10; i++) {
				max=Math.max(max, min);
				min=Math.min(max, min);
				if (max < num[i] ) {
					max = num[i];
				} else if (min < num[i]) {
					min = num[i];
				} else {
					str = "NO";
					break;
				}
			}
			System.out.println(str);

		}

	}

}

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

int main(){
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a<=k){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(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_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}

// 約数列挙
template<typename T>
vector<T> calc_divisor(T n) {
   vector<T> res;
   for (T i = 1LL; i*i <= n; ++i) {
       if (n % i == 0) {
           res.push_back(i);
           T j = n / i;
           if (j != i) res.push_back(j);
       }
   }
   sort(res.begin(), res.end());
   return res;
}

// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


using pint = pair<int, int>;
using pll = pair<ll, 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};


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    int ans = round_up(n, 2);
    print(ans);
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	
	public void run() {
		while (true) {
			int x = in.nextInt(), y = in.nextInt(), s = in.nextInt();
			if (x == 0) break;
			
			int res = 0;
			for (int a = 1; a <= 1000; a++) {
				for (int b = 1; b <= 1000; b++) {
					int ba = (a * (100 + x)) / 100;
					int bb = (b * (100 + x)) / 100;
					if (ba + bb == s) {
						int aa = (a * (100 + y)) / 100;
						int ab = (b * (100 + y)) / 100;
						res = Math.max(res, aa + ab);
					}
				}
			}
			System.out.println(res);
		}
		out.close();
	}

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

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();

			return array;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();

			return array;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();

			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

Measured memory_bytes: 18892
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let m = 60;
    let mut cnt = vec![0; m];
    let mut a: Vec<usize> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    for &a in &a {
        for i in 0..m {
            cnt[i] += (a >> i) & 1;
        }
    }
    let mut ans = 0;
    for i in 0..m {
        if cnt[i] % 2 == 0 {
            continue;
        }
        ans += 1 << i;
        for a in &mut a {
            *a &= !(1 << i);
        }
    }
    a.sort();
    let mut b = vec![];
    for i in (0..m).rev() {
        if (a[n - 1] >> i) & 1 == 0 {
            continue;
        }
        b.push(a[n - 1]);
        for j in 0..n {
            if (a[j] >> i) & 1 == 1 {
                a[j] ^= a[n - 1];
            }
        }
        a.sort();
    }
    let mut v = 0;
    for b in b {
        if (b ^ v) > v {
            v ^= b;
        }
    }
    ans += 2 * v;
    println!("{}", ans);

}

fn main() {
    run();
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
string a[105];
int n,k;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		cout<<a[i];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#define PI 3.14159265358979

using namespace std;
typedef long long int lint;

void answer()
{
	int a, b;
	char op;
	while (1) {
		cin >> a >> op >> b;
		if (op == '?') break;
		if (op == '+') cout << a + b;
		if (op == '-') cout << a - b;
		if (op == '*') cout << a * b;
		if (op == '/') cout << a / b;
		cout << endl;
	}
}

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

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

int main ()
{
	string input;
	bool isConnected = false;
	char firstChar;

	cin >> input;

	firstChar = input[0];

	for (int i = 1; i < input.length(); i++)
	{
		if (firstChar != input[i])
		{
			isConnected = true;
		}
	}

	if (isConnected)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
import collections
n, m = map(int, input().split())

ab = []
v = [[] for _ in range(n+1)]
for _ in range(m):
  a, b = map(int, input().split())
  ab.append([a, b])
  v[a].append(b)
  v[b].append(a)

ans = 0
for a, b in ab:
  visited = set()
  q = collections.deque()
  q.append(1)
  visited.add(1)
  while q:
    c = q.pop()
    for i in v[c]:
      if i in visited:
        continue
      if (a == i and b == c) or (a == c and b == i):
        continue
      q.append(i)
      visited.add(i)
  if len(visited) != n:
    ans += 1
    
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>

int main(void){
    char s[12];
    scanf("%s",s);
    int j,i=0,sum = 0;
    double N = 0,ten = 1.0/10.0;
    while(1){
        if(s[i] == '\0'){
            break;
        }
        sum += ((int)s[i])-48;
        i++;
    }
    for(j = i-1;j>=0;j--){
        N += ((int)s[j]-48.0)*ten*10.0;
        ten = ten*10.0;
    }
    if(((int)N)%((int)sum) == 0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,ans,k,sum=0;
    cin>>n>>k;
    int a[n+2];
    for(i=0; i<n; i++)
    {
        cin>>a[i];

    }
    sort(a,a+n);
   for(i=0;i<k;i++)
    {//cout<<a[i]<<" ";
        sum=sum+a[i];
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  int h[100005] = {};
  int dp[100005] = {};
  int until;
  cin >> n >> k;

  for(int i=0; i<n; i++) cin >> h[i];

  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  until = 1;
  for(int i=2; i<n; i++){
    until = 1;
    dp[i] = abs(h[i] - h[i-1]) + dp[i-1];
    for(int j=2; j<=k; j++){
      if(i - j < 0) break;
      if(abs(h[i] - h[i - j]) + dp[i - j] < abs(h[i] - h[i - until]) + dp[i - until] ){
	dp[i] = abs(h[i] - h[i - j]) + dp[i - j];
	until = j;
      }
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> l, r;
  rep(i,n) {
    if(s[i] == 'W') l.push_back(i);
    else r.push_back(i);
  }
  sort(r.begin(),r.end(),greater<int>());
  int sr = r.size(), sl = l.size();
  int ans = 0;
  int pr = 0;
  rep(i,sl) {
    if(pr < sr and r[pr] > l[i]) {
      ans++; pr++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4860
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    vector<vector<int>> vviNum(n,vector<int>(n, 0));
    for(int i = 0; i < n; i++){
        string str;
        cin >> str;
        for(int j = 0; j < n; j++){
            vviNum[i][j] = str[j] - 'a';
        }
    }
    int nAns = 0;
    for(int k = 0; k < n; k++){
        bool bJudge = true;
        for(int i = 0; i < n - 1; i++){
            int iTmp = (i + k) % n;
            for(int j = i + 1; j < n; j++){
                int jTmp = (j + k) % n;
                if(vviNum[iTmp][j] != vviNum[jTmp][i]){
                    bJudge = false;
                    break;
                }
            }
            if(!bJudge){
                break;
            }
        }
        if(bJudge){
            nAns++;
        }
    }
  
    printf("%d", nAns * n);
    return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()
#define fi first
#define se second
#define sqrt(x) sqrt(abs(x))
#define sqr(x) ((x) * (x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define fill(x, y) memset(x, y, sizeof(x))
#define mp make_pair
#define pb emplace_back
#define popcnt __builtin_popcount
#define ctz __builtin_ctz

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;

template <class T> using indexed_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

template <class T>
istream& operator >> (istream &in, vector <T> &a) {
    for (T &i: a) in >> i;
    return in;
}

template <class T>
ostream& operator << (ostream &out, vector <T> &a) {
    for (T &i: a) out << i << ' ';
    out << '\n';
    return out;
}

template <class T>
ostream& operator << (ostream &out, set <T> &a) {
    for (auto &i: a) out << i << ' ';
    out << '\n';
    return out;
}

template <class T, class U>
istream& operator >> (istream &in, pair <T, U> &p) {
    in >> p.first >> p.second;
    return in;
}

template <class T, class U>
ostream& operator << (ostream &out, pair <T, U> &p) {
    out << p.first << ' ' << p.second << '\n';
    return out;
}

void fastIO() {
    ios_base:: sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
}

void solve();

int x, y, a, b, c;
vector <int> g, r, p;
ll sum;

struct apple {
    int x, type;
    apple(){};
    apple(int x, int type): x(x), type(type){};
};

bool f(apple x, apple y) {
    return x.x > y.x;
}

signed main() {
    fastIO();

    cin >> x >> y >> a >> b >> c;
    r.resize(a); g.resize(b); p.resize(c);
    cin >> r >> g >> p;

    vector <apple> v;
    for (auto i: r) v.pb(apple(i, 1));
    for (auto i: g) v.pb(apple(i, 2));
    for (auto i: p) v.pb(apple(i, 0));

    sort(all(v), f);

    int i = 0;
    int cnt_red = 0, cnt_gr = 0, cnt_who = 0;

    /*for (auto i: v) {
        cout << i.x << ' ' << i.type << '\n';
    }*/

    while (i < sz(v) && cnt_red + cnt_gr + cnt_who < x + y) {
        if (v[i].type == 0) {
            sum += v[i].x;
            cnt_who++;
        }

        else if (v[i].type == 1) {
            if (cnt_red < x) {
                sum += v[i].x;
                cnt_red++;
            }
        }

        else {
            if (cnt_gr < y) {
                sum += v[i].x;
                cnt_gr++;
            }
        }

        i++;
    }

    cout << sum;

    return 0;
}

/// ЗАПУСКАЕМ ГУСЯ:
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */



Measured memory_bytes: 7280