akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=1e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,k;
struct Node{
	int a[MAXN];
	int&operator[](int x){return a[x];}
	inline Node Inv(){Node b;Rep(i,1,n)b[a[i]]=i;return b;}
	inline friend Node operator*(Node a,Node b){Node c;Rep(i,1,n)c[i]=a[b[i]];return c;}
	inline friend Node operator^(Node a,int k){
		static int vis[MAXN],p[MAXN];memset(vis,0,sizeof(vis));Node b;
		Rep(i,1,n)if(!vis[i]){
			int cnt=0;p[cnt=1]=i,vis[i]=1;
			for(int t=a[i];t!=i;t=a[t])vis[t]=1,p[++cnt]=t;
			Rep(j,1,cnt)b[p[j]]=p[(j+k-1)%cnt+1];
		}return b;
	}
}a[7],A,ans;
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),k=read();
	Rep(i,1,n)a[1][i]=read();Rep(i,1,n)a[2][i]=read();
	Rep(i,3,6)a[i]=a[i-1]*(a[i-2].Inv());
	A=a[2]*(a[1].Inv())*(a[2].Inv())*a[1];
	ans=(A^((k-1)/6))*a[(k-1)%6+1]*(A.Inv()^((k-1)/6));
	Rep(i,1,n)cout<<ans[i]<<" ";cout<<'\n';
	return 0;
}




Measured memory_bytes: 12460
#include <bits/stdc++.h>
const int maxn=2e5+10,mod=1e9+7;
typedef long long ll;
using namespace std;
int n,m,k,t;
struct node
{
    int x,l;
    bool operator<(const node&p)const
    {
        return x<p.x;
    }
}p[maxn];
int dp[maxn];
int dd[maxn];
void add(int x,int y)
{
    while(x<maxn)dd[x]=max(dd[x],y),x+=x&(-x);
}
int get(int x)
{
    int ret=0;
    while(x)ret=max(ret,dd[x]),x-=x&(-x);
    return ret;
}
int d[maxn];
int main()
{
    int i,j;
    //freopen("in.txt","r",stdin);
    scanf("%d",&n);
    int cnt=0;
    for(i=1;i<=n;i++)
    {
        scanf("%d%d",&p[i].x,&p[i].l);
        d[++cnt]=p[i].x+p[i].l;
        d[++cnt]=p[i].x-p[i].l;;
    }
    sort(d+1,d+cnt+1);
    cnt=unique(d+1,d+cnt+1)-d-1;
    sort(p+1,p+n+1);
    int ans=0;
    for(i=1;i<=n;i++)
    {
        int tx=p[i].x-p[i].l;
        tx=lower_bound(d+1,d+cnt+1,tx)-d;
        int ty=p[i].x+p[i].l;
        ty=lower_bound(d+1,d+cnt+1,ty)-d;
        int ret=get(tx)+1;
        dp[i]=ret;
        add(ty,dp[i]);
        ans=max(ans,ret);
    }
    printf("%d\n",ans);
    return 0;
}


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


int main(){
  string N;
  cin >> N;
  int len = N.size();
  char ans = N[0];
  for(int ii=1; ii<len; ii++){
    if(N[ii] < ans) break;
    if(N[ii] > ans){
      ans++;
      break;
    }
  }
  for(int ii=0; ii<len; ii++){
    cout << ans;
  }
  cout << endl;
  return 0;
}

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

#include <set>
#include <map>

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

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int MOD = 1e9+7;
const int INF = 1e9;
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
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;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif

template<typename T>struct SegTree {
  private:
    using F = function<T(T,T)>;
    int n;
    vector<T> node;
    const F f;
    const T init;
  public:
    SegTree(int size, T init, const F f) : init(init), f(f) {
      n = 1;
      while (n < size) n *= 2;
      node.resize(2*n-1, init);
    }
    void update(int index, T value) {
      index = n - 1 + index;
      node[index] = value;
      while (index != 0) {
        index = (index-1) / 2;
        node[index] = f(node[2*index+1], node[2*index+2]);
      }
    }
    T query(int left, int right, int k = 0, int l = 0, int r = -1) {
      if (r < 0) r = n;
      if (r <= left || right <= l) return init;
      if (left <= l && r <= right) return node[k];
      return f(query(left, right, 2*k+1, l, (l+r)/2), query(left, right, 2*k+2, (l+r)/2, r));
    }
};

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

  SegTree<ll> T(N, 0, [](ll a, ll b){return a | b;});

  rep(i, N) {
    char s; cin >> s;
    T.update(i, 1LL << ((int)(s - 'a')));
  }
  int Q; cin >> Q;


  rep(i, Q) {
    int q; cin >> q;
    if (q == 1) {
      int n; char c;
      cin >> n >> c;
      --n;
      T.update(n, 1LL << (c - 'a'));
    } else {
      int l, r;
      cin >> l >> r;
      --l, --r;
      cout << __builtin_popcount(T.query(l, r +1)) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 8448
var
	ans,x,y,mo:int64;
	F,I:Array[0..200000]of int64;
	n,k,id:Longint;
function p(a,b:int64):int64;
begin
	if b=0 then p:=1 else if b mod 2=0 then p:=p(a*a mod mo,b div 2) else p:=p(a,b-1)*a mod mo;
end;
begin
	read(n,k);
	F[0]:=1;
	mo:=1000000007;
	for id:=1 to n do F[id]:=F[id-1]*id mod mo;
	I[n]:=p(F[n],mo-2);
	for id:=n-1 downto 0 do I[id]:=I[id+1]*(id+1)mod mo;
	id:=0;
	while(id<n)and(id<=k)do begin
		inc(ans,F[n]*I[n-id]mod mo*I[id]mod mo*F[n-1]mod mo*I[n-1-id]mod mo*I[id]mod mo);
		inc(id);
	end;
	writeln(ans mod mo);
end.


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a[4][3][10] = {0};
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    a[b-1][f-1][r-1] += v;
  }
  for (int i = 0; i < 15; i++) {
    if (i % 4 == 3) {
      cout << "####################" << endl;
    }
    else {
      for (int j = 0; j < 10; j++) {
        if (j == 9) {
          cout << ' ' << a[i/4][i % 4][j] << endl;
        }
        else {
          cout << ' ' << a[i/4][i % 4][j];
        }
      }
    }
  }
} 


Measured memory_bytes: 3080
#include <stdio.h>

int main() {
  int A[100][100], b[100], c[100];
  int n, m;

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

  for (int i = 0; i < n; i++) {
    c[i] = 0;
    for (int j = 0; j < m; j++) {
      c[i] = c[i] + A[i][j]*b[j];
    }    
  }

  for (int i = 0; i < n; i++) {
    printf("%d\n", c[i]);
  }

  return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    int dp[n + 1][m + 1] = { };
    for(int i = n; i >= 0; --i) {
        for(int j = m; j >= 0; --j) {
            if (j == m || i == n) {
                dp[i][j] = 0;
            } else if( s[i] == t[j] ) {
                dp[i][j] = 1 + dp[i + 1][j + 1];
            } else {
                dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
    }
    /*
    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= m; ++j) {
            cout << dp[i][j] << ' ';
        }
        cout << '\n';
    }
    cout << dp[0][0] << '\n';
    */
    int a = 0, b = 0;
    while(a < n && b < m) {
        if (s[a] == t[b]) {
            cout << s[a];
            a++, b++;
        } else {
            if ( dp[a + 1][b] > dp[a][b + 1] ) {
                a++;
            } else {
                b++;
            }
        }
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 38836
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

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

	int p, q, r;
	cin >> p >> q >> r;

	cout << min(p + q, min(q + r, r + p)) << endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int main() {
    int h,w;cin>>h>>w;
    rep(i,w+2)cout<<'#';cout<<endl;
    rep(i,h) {
        cout<<'#';
        rep(i,w) {
            char c;cin>>c;
            cout<<c;
        }
        cout<<'#'<<endl;
    }
    rep(i,w+2)cout<<'#';cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int N, M;
    cin >> N >> M;
    int A[N];
    int sum = 0;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum += A[i];
    }
    for(int i = 0; i < N; i++){
        if(A[i]*4*M >= sum) cnt++;
    }
    if(cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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


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

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_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    vector<int> a(3);
    for(int i = 0 ; i < 3; i++) cin >> a[i];

    sort(a.begin(), a.end());
    int ans = a[1]-a[0] + a[2] - a[1];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ldb;
typedef unsigned int ui;
typedef unsigned long ul;
 
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
 
typedef priority_queue<pi> pq;
typedef priority_queue<int,vector<int>,greater<int>> pqg;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound


int n,k;

bool divide(int r, vi v){
	int counter=0;
	for(auto x:v){
		counter+=ceil(double(x)/double(r))-1;
	}
	return counter>k;
}

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

cin>>n>>k;

vi v(n);
int maxx=0;
for(int i=0; i<n; i++) {
	cin>>v[i];
	maxx=max(maxx,v[i]);
}

int ans=0;
for(int b=maxx; b>=1; b/=2){
	while(ans+b<=maxx && divide(ans+b,v)) ans+=b;
}

cout<<ans+1;
return 0;
}


Measured memory_bytes: 4700
#include <iostream>

using namespace std;

int main(){

    string s;
    cin >> s;

    int alph[26];

    for (int i = 0; i < 26; i++){
        alph[i] = 0;
    }

    for (int i = 0; i < s.size(); i++){
        alph[s[i] - 'a']++;
    }

    bool unique = true;

    for (int i = 0; i < 26; i++){
        if (alph[i] > 1) unique = false;
    }

    if (unique){
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }

    return 0;
}

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

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	if ((100 * r + 10 * g + b) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}



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

enum mark{
    S,
    H,
    C,
    D
};

int main(){
    int n, num;
    char m;
    bool card[4][13] = {false};
    
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> m >> num;
        
        if(m == 'S') card[S][num - 1] = true;
        else if(m == 'H') card[H][num - 1] = true;
        else if(m == 'C') card[C][num - 1] = true;
        else if(m == 'D') card[D][num - 1] = true;
    }
    
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            if(card[i][j] == false){
                if(i == 0) m = 'S';
                else if(i == 1) m = 'H';
                else if(i == 2) m = 'C';
                else if(i == 3) m = 'D';
                
                cout << m << " " << j+1 << endl;
            }
        }
    }
}


Measured memory_bytes: 3080
import math
def main():
  s = int(input())
  numarray=[s]
  ans=0
  i=1
  while True:
    if s%2==1:
      s=3*s+1
    else:
      s=int(s/2)
    if s in numarray:
      break
    else:
      numarray.append(s)
      i+=1
  print(i+1)
main()

Measured memory_bytes: 9180
n, x = map(int, input().split())
m = [0]*n
for i in range(n):
  	m[i] = int(input())
m.sort()
ans = 0
flag = False
while x > 0:
    for i in range(n):
        if x >= m[i]:
            x -= m[i]
            ans += 1
        else:
            flag = True
            break
    if flag:
        break
    key = m[0]
    while x > 0:
        if x >= key:
            x -= key
            ans += 1
        else:
            flag = True
            break
    if flag:
        break
print(ans)

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

int main(){
  int N;
  int d[50];
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> d[i];
  }
  int ans=0;
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      ans += d[i]*d[j];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// He always smiles :)
#include <bits/stdc++.h>
#define maxn 200005
#define mod 1000000007
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define task "main"
#define ll long long
#define reset(x, a) memset(x, a, sizeof(x))
#define endl "\n"

using namespace std;
struct data
{
    int x, y, pos;
};
data a[maxn], E[maxn];
int n, m;
ll ans;
int root[maxn];
bool cmp(data a, data b)
{
    return a.x < b.x;
}
bool cmp1(data a, data b)
{
    return a.y < b.y;
}
bool cmp2(data a, data b)
{
    return a.pos < b.pos;
}
int get_root(int u)
{
    return (root[u] ? root[u] = get_root(root[u]) : u);
}
void kruskal()
{
    sort(E + 1, E + m + 1, cmp2);
    for (int i = 1 ; i <= m ; i ++)
    {
        int p = get_root(E[i].x);
        int q = get_root(E[i].y);
        if(p != q)
        {
            root[p] = q;
            ans += E[i].pos;
        }
    }
    cout << ans;
}
int main()
{
    ios_base::sync_with_stdio(0);
//    freopen(task".inp", "r", stdin);
//    freopen(task".out", "w", stdout);
    cin >> n;
    for (int i = 1 ; i <= n ; i ++)
        cin >> a[i].x >> a[i].y, a[i].pos = i;
    sort(a + 1, a + n + 1, cmp);
    for (int i = 1 ; i < n ; i ++)
    {
        E[++m].pos = a[i + 1].x - a[i].x;
        E[m].x = a[i].pos, E[m].y = a[i + 1].pos;
    }
    sort(a + 1, a + n + 1, cmp1);
    for (int i = 1 ; i < n ; i ++)
    {
         E[++m].pos = a[i + 1].y - a[i].y;
        E[m].x = a[i].pos, E[m].y = a[i + 1].pos;
    }
    kruskal();
    return 0;
}


Measured memory_bytes: 4224
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

func bitCount(n uint) int {

        x := uint64(n)

        const m = 1<<64 - 1
        const m0 = 0x5555555555555555
        const m1 = 0x3333333333333333
        const m2 = 0x0f0f0f0f0f0f0f0f

        x = x>>1&(m0&m) + x&(m0&m)
        x = x>>2&(m1&m) + x&(m1&m)
        x = (x>>4 + x) & (m2 & m)
        x += x >> 8
        x += x >> 16
        x += x >> 32

        return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
        return ((n >> uint(i)) & 1) == 1
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
func chmax(dp []int, idx, n int) {
        if dp[idx] < n {
                dp[idx] = n
        }
}

func main() {
        line := nextLine()
        spl := intSprit(line)

        N := spl[0]
        M := spl[1]

        deg := make([]int, N)
        G := make([][]int, N)
        for i := 0; i < N; i++ {
                G[i] = []int{}
        }

        for i := 0; i < M; i++ {
                s := intSprit(nextLine())
                x, y := s[0], s[1]
                x--
                y--
                G[x] = append(G[x], y)
                deg[y]++
        }

        que := []int{}
        for i, v := range deg {
                if v == 0 {
                        que = append(que, i)
                }
        }

        dp := make([]int, N+100)
        var q int
        for len(que) > 0 {
                q, que = que[0], que[1:]
                for _, v := range G[q] {
                        deg[v]--
                        if deg[v] == 0 {
                                que = append(que, v)
                                chmax(dp, v, dp[q]+1)
                        }
                }
        }

        res := 0
        for i := 0; i < N; i++ {
                if res < dp[i] {
                        res = dp[i]
                }
        }
        fmt.Println(res)
}

Measured memory_bytes: 12544
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/9/2018
 
 22:15-22:30 analysis
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int N;
LL A[MAX_N];
int P[32];
int solve() {
  MINUS(P);
  REP(i,N) {
    REP(j,32) if((A[i]>>j)&1) {
      P[j]=i;
      break;
    }
  }
//  dumpAR(P);
  int res=0;
  for(int b=31; b>=0; --b) {
    int cnt=0;
    REP(i,N) cnt+=(A[i]>>b)&1;
    if((cnt&1)==1) {
//      dump3(b,cnt,P[b]);
      if(P[b]==-1) return -1;
      A[P[b]]-=1,res+=1;
    }
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N;
  REP(i,N) cin>>A[i];
  cout<<solve()<<endl;
  return 0;
}


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

int n;
vector<int> p, a, b;

int main(){
        //      cin.tie(0);
        //      ios::sync_with_stdio(false);
        cin >> n;
        for(int i=0; i<n; ++i){
                int t;
                cin >> t;
                p.push_back(t);
        }
        for(int i=0; i<n; ++i){
                a.push_back(1 + i * 30000);
                b.push_back(1 + i * 30000);
        }
        reverse(b.begin(), b.end());
        for(int i=0; i<n; ++i){
                a[p[i]-1] += i;
        }
        for(int i=0; i<n; ++i)
                cout << a[i] << (i == n-1 ? "\n" : " ");
        for(int i=0; i<n; ++i){
                cout << b[i] << (i == n-1 ? "\n" : " ");
        }
}

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

int main(){
  int n;
  string ans="";
  cin >> n;
  if(!n)ans="0";
  while(n!=0){
    if(n%2!=0){
      n--;
      ans="1"+ans;
    }
    else ans="0"+ans;
    n/=-2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
long long GCD(long long a, long long b)
{
    if (b == 0)
        return a;
    return GCD(b, a % b);
}
long long LCM(long long a, long long b)
{
    return a * b / GCD(a, b);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin>>n>>m;
    cout << LCM(n, m) << endl;
}


Measured memory_bytes: 888
n, m, q = map(int, input().split())
T = []
for i in range(q):
    a, b, c, d = map(int, input().split())
    T.append((a - 1, b - 1, c, d))

L = []
def f(l):
    if len(l) == n + 1:
        L.append(l[1:])
        return
    for i in range(l[-1], m + 1):
        f(l + [i])
f([1])

print(max(sum(d for a, b, c, d in T if l[b] - l[a] == c) for l in L))


Measured memory_bytes: 90680
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

#define _USE_MATH_DEFINES

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

//約数
void divisor(ll n, vector<ll>& ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
}


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

	double a, b, x;

	cin >> a >> b >> x;

	if (a * a * b == x*2) {
		cout << fixed << setprecision(8) << atan2(b, a) * 180.0 / 3.1415926534 << endl;
	}
	else if (a * a * b > x * 2) {
		double c = 2.0 * x / (a * b);
		cout << fixed << setprecision(8) << 90.0-atan2(c,b)*180.0/3.1415926534 << endl;
	}
	else {
		double xx = a * a * b - x;
		double c = xx * 2 / (a * a);
		cout<< fixed << setprecision(8) << atan2(c,a)*180.0/3.1415926534 << endl;

	}

	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

class UnionFind {
public:
  UnionFind(int n) {
    r.resize(n, 0);
    s.resize(n, 1);
    p.resize(n);
    for (int i = 0; i < n; ++i) {
      p[i] = i;
    }
  }
  void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if (a == b) {
      return ;
    }

    s[a] = (s[b] += s[a]);
    if (r[a] > r[b]) {
      p[b] = a;
    } else {
      p[a] = b;
      if(r[a] == r[b]) r[b]++;
    }
    return ;
  }
  int find(int a) {
    return (a == p[a]) ? a : p[a] = find(p[a]);
  }
  bool same(int a, int b) {
    return find(a) == find(b);
  }
  size_t size(int n) {
    return s[find(n)];
  }
private:
  vector<int> r, p, s;
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, m;
  while (cin >> n >> m) {
    vector<pair<int, int>> v(m);
    cin >> v;
    reverse(v.begin(), v.end());

    UnionFind uf(n + 1);

    vector<lli> u;
    lli x = (n - 1) * n / 2;
    each (e, v) {
      u.push_back(x);
      if (uf.same(e.first, e.second)) {
        continue;
      }

      x += (uf.size(e.first) - 1LL) * uf.size(e.first) / 2;
      x += (uf.size(e.second) - 1LL) * uf.size(e.second) / 2;

      uf.unite(e.first, e.second);

      x -= (uf.size(e.first) - 1LL) * uf.size(e.first) / 2;
    }
    reverse(u.begin(), u.end());
    each (i, u) cout << i << endl;
  }

  return 0;
}


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

/*Starry Sky Tree*/
/*Range Add Min(Max) Query*/
/*区間加算、区間Min,区間Max*/

class RSUQ{
public: 
  
  //遅延用の型  
  struct T{
    int type; //0 - empty   , 1 - update
    int value;
    T():type(0),value(0){}
    T(int type,int value):type(type),value(value){}
  };

  //マージ可能な主データ型
  struct D{
    int value;
    D():value(0){} /*適切な値にする!!!!!!*/
    D(int value):value(value){}
    bool operator < (D a)const {return value < a.value;} //merge用
  };
  
  int n;
  vector<D> dat;
  vector<T> td;
  D returnD = D(0); // 範囲外の時に返す値。
  
  RSUQ(){n=-1;}
  RSUQ(int n_){
    n=1;
    while(n < n_) n *= 2;
    td.resize(2*n-1,T());
    dat.resize(2*n-1,D());
  }
  
  D merge(D a,D b){return a.value + b.value;}
  
  void delay(int k,int len){
    if(td[k].type==0) return;
    int v = td[k].value;
    td[k].type = 0;
    td[k].value = 0;
    
    len /= 2;
    int l = k*2+1,r = k*2+2;
    dat[l].value = v * len; td[l].type = 1; td[l].value = v;
    dat[r].value = v * len; td[r].type = 1; td[r].value = v;
  }

  D write(int k,int x, int len){
    dat[k].value = x * len;
    td[k].type = 1;
    td[k].value = x;
    return dat[k];
  }
  
  //[a,b)の値をx変更　query(a,b,x)
  D update(int a,int b,int x,bool flg=true,int k=0,int l=0,int r=-1){
    if(r==-1) r=n, assert(a <= n && b <= n);
    if(r <= a||b <= l) return flg? dat[k]:returnD;
    if(a <= l && r <= b) return flg? write(k, x, r - l):dat[k];
    
    delay(k, r - l);
    D vl = update(a,b,x,flg,k*2+1,l,(l+r)/2);
    D vr = update(a,b,x,flg,k*2+2,(l+r)/2,r);
    if(flg) dat[k] = merge(vl, vr);
    return merge(vl, vr);
  }
  
  //[a,b)の合計値を得る　find(a,b);
  int find(int a,int b){
    D res = update(a,b,0,false);
    return res.value;
  }
};


signed main(){
  int n,q;
  cin>>n>>q;
  
  RSUQ rsuq(n);

  while(q--){
    int cmd;
    cin>>cmd;
    if(cmd == 0){
      int s,t,x;
      cin>>s>>t>>x;
      rsuq.update(s,t+1,x);
    }
    if(cmd == 1){
      int s,t;
      cin>>s>>t;
      cout<<rsuq.find(s,t+1)<<endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 8896
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <math.h>

using namespace std;

typedef long long ll;

int main()
{
    ll H;
    cin >> H;
    ll ans = 0;
    ll t = 1;
    while(H > 1){
        ans += t;
        H /= 2;
        t *= 2;
    }
    ans += t;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    x,y,s=map(int,input().split())
    if s==0:
        break
    else:
        p=0
        for i in range(1,s+1):
            for j in range(i,s+1):
                t=i+j+(i*x)//100+(j*x)//100
                if t>s:
                    break
                if t!=s:
                    continue
                t=i+j+(i*y)//100+(j*y)//100
                if t>p:
                    p=t
        print(p)


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

int main() {
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	int i = 0;
	for (; i < a; ++i) {
		if (s[i] < '0' || s[i] > '9') {
			cout << "No";
			return 0;
		}
	}
	if (s[i] != '-') {
		cout << "No";
		return 0;
	}
	++i;
	for (; i < a + b + 1; ++i) {
		if (s[i] < '0' || s[i] > '9') {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  char b;
  std::cin >> b;
  std::cout << (b == 'A' ? 'T' : b == 'C' ? 'G' : b == 'G' ? 'C' : 'A') << std::endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio,std.string,std.conv;

immutable int MAX = 50;
immutable int COUNT = 9;

void main(){
    char[] buf;
    int[] dataset;
    while(stdin.readln(buf)){
        if(buf.chomp().to!string().isNumeric){
            dataset ~= buf.chomp().to!int();
        }
        if(dataset.length > 50)
            break;
    }

    int[] ans;
    foreach(int num;dataset){
        ans ~= searchNum(num);
    }

    foreach(int num;ans){
        writeln(num);
    }
}

int searchNum(int x){
    int result = 0;
    for(int i = 0;i <= COUNT;i++){
        for(int j = 0;j <= COUNT;j++){
            for(int m = 0;m <= COUNT;m++){
                for(int k = 0;k <= COUNT;k++){
                    if(x == i + j + k + m){
                        result++;
                    }
                }
            }
        }
    }
    return result;
}

Measured memory_bytes: 2512
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    int posA,posZ;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            posA=i;
            break;
        }
    }
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='Z'){
            posZ=i;
            break;
        }
    }
    cout<<posZ-posA+1<<endl;
}


Measured memory_bytes: 640
import math

N=int(input())

list=[]

for i in range(N):
    list.append(int(input()))

max = None
maxinde = None

for i in range(len(list)):
    p = list[i]

    if max == None:
        max = p
        maxinde = i

    if max < p:
        max = p
        maxinde = i

sum = 0

for i in range(len(list)):
    p = list[i]

    if i == maxinde:
        sum += math.floor(p/2)
    else:
        sum += p
        
print(sum)

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

int gcd(int p, int q){
    if(q==0) return p;
    else return gcd(q, p%q);
}

int main() {
    int w, h, c, g;
    cin >> w >> h >> c;
    g = gcd(w,h);
    cout << w*h/(g*g)*c << endl;
    return 0;
}



Measured memory_bytes: 3124
rgb = set(["r","g","b"])
while 1:
	worm = raw_input()
	if worm == "0": break
	n = len(worm)
	L = 1
	cnt = flag = 0
	queset = set([worm])
	ref = set()
	while 1:
		que = list(queset)
		queset = set()
		for Worm in que:
			if len(set(Worm)) == 1:
				flag = 1
				break
			for i in range(n-1):
				if Worm[i] != Worm[i+1]:
					nextclr = list(rgb-set(Worm[i:i+2]))[0]
					worm = Worm[:i] + 2*nextclr + Worm[i+2:]
					queset.add(worm)
		queset = queset - ref
		ref = ref|queset
		L = len(queset)
		if flag: break
		cnt += 1
		if cnt > 15: break
	print cnt if flag else "NA"

Measured memory_bytes: 6764
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.Char

solve as bs n = VU.maximum $ VU.generate n $ \i -> VU.sum (VU.take (i+1) as) + VU.sum (VU.drop i bs)
main = do
    n <- readLn :: IO Int
    as <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    bs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    print $ solve as bs n

Measured memory_bytes: 508
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//関係性は隣接行列で記録
//過半数：N/2.0で判定
//ある量からある量を引く系の問題：端から定義してやる
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}


//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}


int main() {
	ll N; cin >> N;
	vector<ll> A(N); rep(i, N)cin >> A[i];

	ll ans = 1;
	rep(i, N) if (A[i] % 2 == 0) ans *= 2;
	
	cout << pow(3, N) - ans << endl;
}

Measured memory_bytes: 8064
n = int(input())
list_S = [input() for _ in range(n)]
m = int(input())
list_T = [input() for _ in range(m)]
ans = 0
set_S = list(set(list_S))
for c in set_S:
    if list_S.count(c)-list_T.count(c)>0:
       ans =  max(ans, list_S.count(c)-list_T.count(c))

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define m_p     make_pair
#define all(vi) vi.begin(),vi.end()
#define fi      first
#define se      second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef queue<ll> queuel;
ll cost[12];
ll all[12][12];
int main()
{
	ll n,m,x;
	cin>>n>>m>>x;
	for(int i=0;i<n;i++)
	{
		cin>>cost[i];
		for(int j=0;j<m;j++)
		{
			cin>>all[i][j];
		}
	} 
	ll mi = 1e18;
	for(ll i=1;i<(1 << n);i++)
	{
		vector<ll> he(m);
		ll cnt = 0;
		for(int j=0;j<n;j++)
		{
			if((i>>j)&1)
			{
				cnt+=cost[j];
				for(int k=0;k<m;k++)
					he[k]+=all[j][k];
			}
		}
		bool is_dayu = true;
		for(int j=0;j<m;j++)
		{
			if(he[j]<x)
				is_dayu = false;
		}
		if(is_dayu)
			mi = min(mi,cnt);
	}
	if(mi == 1e18)
		cout<<"-1\n";
	else
		cout<<mi<<endl;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main()
{
  int A,B,P;
  cin>>A>>B;
  P=A*B;
  if( (1<=A && A<=9)&&(1<=B && B<=9)){
    cout<<P;
  }
  else
{
    cout<<-1;
}
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> vArray = new ArrayList<Integer>();
		int idx;
		for (idx = 0; idx < N; idx++) {
			vArray.add(Integer.parseInt(sc.next()));
		}
		//sort
		Collections.sort(vArray);

		double value = vArray.get(0).doubleValue();
		for (idx = 1; idx < vArray.size(); idx++) {
			value = (value + vArray.get(idx).doubleValue()) / 2.0d;
		}

		System.out.println(value);

	}

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
struct BIT {
    int n; vector<LL> bit;
    void init(int _n) { n = _n; bit.assign(n + 1, 0); }
    void m(int x, LL d) {
        while (x <= n)
            bit[x] += d, x += x & (-x);
    }
    LL q(int x) {
        LL ret = 0;
        while (x > 0)
            ret += bit[x], x -= x & (-x);
        return ret;
    }
} solver;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, q; cin >> n >> q;
    solver.init(n);
    for (int i = 0 ; i < n ; i++) {
        LL v; cin >> v;
        solver.m(i + 1, v);
    }
    while (q--) {
        int t; cin >> t;
        if (t == 0) {
            int x; LL v; cin >> x >> v;
            solver.m(x + 1, v);
        } else {
            int l, r; cin >> l >> r;
            cout << solver.q(r) - solver.q(l) << '\n';
        }
    }
}

Measured memory_bytes: 8228
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define NOT_ZERO 1
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long ll;

int main()
{
    int n, i;
    
    scanf("%d",&n);
    int *a = (int*)malloc(sizeof(int)*n);
    int *b = (int*)malloc(sizeof(int)*n);
    int *c = (int*)malloc(sizeof(int)*n);
    int *A = (int*)malloc(sizeof(int)*n);
    int *B = (int*)malloc(sizeof(int)*n);
    int *C = (int*)malloc(sizeof(int)*n);
    

    for(i=0; i<n; i++) {
        scanf("%d %d %d",a+i, b+i, c+i);
    }

    A[0] = a[0];
    B[0] = b[0];
    C[0] = c[0];
    for(i=1; i<n; i++) {
        A[i] = MAX(B[i-1]+a[i], C[i-1]+a[i]);
        B[i] = MAX(A[i-1]+b[i], C[i-1]+b[i]);
        C[i] = MAX(A[i-1]+c[i], B[i-1]+c[i]);
    }

    int ans = MAX3(A[n-1], B[n-1], C[n-1]);

    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 2560
import numpy as np

N=int(input())
A=np.array( list(map(int, input().split())) )

divider = 10**9+7

ans = 0
for shift in range(0, 60):
    one_num = np.count_nonzero(A & 1)
    ans += (2**shift)*one_num*(N-one_num)
    A >>= 1
print(ans%divider)


Measured memory_bytes: 48828
#include<queue>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

#define   M             55
#define   ll            long long
#define   PI            atan(1.0)*4
#define   mst(x,v)      memset(x,v,sizeof(x))
#define   inf           (int)1e9

typedef   pair<int,int> P;

char a[M][M];

int go[4][2] = { { 1, 0},
				 {-1, 0},
				 { 0, 1},
				 { 0,-1}};

int vis[M][M];

struct node{
	int x,y,num;
};
int h,w;

bool check(int x,int y) {
	if(x<1 || y<1 || x>h || y>w || vis[x][y] || a[x][y]== '#')
		return false;
	return true;
}

int bfs() {
	mst(vis,0);
	queue<node> q;
	node t,p;
	t.x=1,t.y=1,t.num=0;
	q.push(t);
	
	while(!q.empty()) {
		
		t=q.front();
		q.pop();
		
	//	printf("%d %d %d\n",t.x,t.y,t.num);
		
		if(t.x == h && t.y == w)
			return t.num;
		
		for(int i=0;i<4;i++) {
			int dx=t.x + go[i][0];
			int dy=t.y + go[i][1];
			
			if(check(dx,dy)) {
				p.x = dx;
				p.y = dy;
				p.num = t.num + 1;
				vis[dx][dy]=1;
				q.push(p);
				
			}
		}
	}
	
	return -1;
}



int main() {

	scanf("%d %d",&h,&w);
	
	int res=0;
	for(int i=1;i<=h;i++) {
		for(int j=1;j<=w;j++) {
			cin>>a[i][j];
			if(a[i][j]=='.')
				res++;
		}
	}
	
	if(bfs()==-1) puts("-1");
	else printf("%d\n",res-bfs()-1);
	
	
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    vector<valarray<int>> C(3, valarray<int>(3));
    for(int i = 0; i < 3; i++){
        for(int k = 0; k < 3; k++){
            cin >> C[i][k]; 
        }
    }

    int MIN = C[0].min();
    for(int a0 = 0; a0 <= MIN; a0++){
        vector<valarray<int>> a(3); 
        a[0] = valarray<int>(a0, 3);
        valarray<int> b(3);
        b = C[0] - a[0];
        a[1] = C[1] - b;
        a[2] = C[2] - b;
        if(a[1].min() == a[1].max() && a[2].min() == a[2].max()){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
using System;

public class Hello{
    public static void Main(){
        string[] str = Console.ReadLine().Split();
       int a = int.Parse(str[0]);
       int b = int.Parse(str[1]);
       int c = int.Parse(str[2]);
       
       int x =0;
       int y =0;
       
      
       
       if(a>b){
           x=a;
           a=b;
           b=x;
        }
        if(b>c){
            x=b;
            b=c;
            c=x;
        }
        if(a>b){
            x=a;
            a=b;
            b=x;
        }
        
        Console.WriteLine(a+" "+b+" "+c);  
    }
}


Measured memory_bytes: 15944
import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,K = LI()
h = LI()
dp = [float('INF')]*N
dp[0] = 0
for i,j in itertools.product(range(N),range(1,K+1)):
    if i+j<=N-1:
        dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
print(dp[-1])


Measured memory_bytes: 57312
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
l = len(set(a))
c = Counter(a)
cnt = 0
for key in c.keys():
    cnt += c[key] - 1
print(l-1 if cnt%2 else l)

Measured memory_bytes: 87208
n = int(input())
a = list(map(int, input().split()))
ans = [0 for _ in range(n)]
for i in range(n):
    if n % 2 == 1:
        x = (n - 1) // 2
        if i % 2 == 0:
            ans[x - (i // 2)] = a[i]
        else:
            ans[x + ((i + 1) // 2)] = a[i]
    else:
        x = n // 2
        if i % 2 == 0:
            ans[x + (i // 2)] = a[i]
        else:
            ans[x - ((i + 1) // 2)] = a[i]
print(*ans)


Measured memory_bytes: 26180