akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

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

using namespace std;

int main(){
  int a,b;cin>>a>>b;

  int sum = stoi(to_string(a)+to_string(b));
  int t = (int)pow(sum, 0.5);
  
  if(pow(t,2)==sum){
    cout<<"Yes";
  }else{
    cout<<"No";
  }


  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));

    
    ll ans = 0;
    rep(i, n) {
        ll A = a.end() - lower_bound(all(a), b[i]);
        ll C = c.end() - lower_bound(all(c), b[i]+1);
        ans += (n-A)*C;
    }

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

Measured memory_bytes: 1408
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>

int main() {
  size_t N, M;
  std::vector<std::pair<size_t, size_t>> AB;

  scanf("%zu %zu", &N, &M);
  for (auto i = 0; i < N; i++) {
    size_t A, B;
    scanf("%zu %zu", &A, &B);
    AB.emplace_back(std::make_pair(A, B));
  }

  std::sort(AB.begin(), AB.end());

  std::priority_queue<size_t> J;
  auto p = AB.begin();
  size_t t = 0;
  for (auto i = 0; i <= M; i++) {
    while (p != AB.end() && p->first <= i) {
      J.push(p->second);
      p++;
    }

    if (J.size() != 0) {
      t += J.top();
      J.pop();
    }
  }

  printf("%zu\n", t);
}

Measured memory_bytes: 3568
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        ArrayList<Po>po=new ArrayList<>();
        for(int i=0;i<n;i++)po.add(new Po(sc.nextInt(),sc.nextInt()));
        Collections.sort(po,new Comparator<Po>(){
            public int compare(Po a,Po b){
                return a.b-b.b;
            }
        });
        long count=0;
        boolean b=true;
        for(int i=0;i<n;i++){
            Po p=po.get(i);
            count+=p.a;
            if(p.b<count){b=false;break;}
        }
        System.out.println((b)?"Yes":"No");
        
    }
    static class Po{
        int a,b;
        public Po(int a,int b){
            this.a=a;
            this.b=b;
        }
        public String toString(){
            return "a="+a+":b="+b;
        }
    }
}


Measured memory_bytes: 99372
# -*- coding: utf-8 -*-
"""
https://abc058.contest.atcoder.jp/tasks/abc058_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(O, E):
    ans = ''
    for o, e in zip(O, E):
        ans += o + e
    if len(O) > len(E):
        ans += O[-1]
    return ans


def main(args):
    O = input().strip()
    E = input().strip()
    ans = solve(O, E)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    rep(i, N) cin >> A[i] >> B[i] >> C[i];
    int DP[3][N];
    memset(DP, 0, sizeof(DP));
    DP[0][0] = A[0];
    DP[1][0] = B[0];
    DP[2][0] = C[0];
    for (int i = 1; i < N; i++) {
       DP[0][i] = max(DP[1][i-1]+A[i], DP[2][i-1]+A[i]);
       DP[1][i] = max(DP[0][i-1]+B[i], DP[2][i-1]+B[i]);
       DP[2][i] = max(DP[0][i-1]+C[i], DP[1][i-1]+C[i]);
    }
    cout << max(max(DP[0][N-1], DP[1][N-1]), DP[2][N-1]) << endl;;
}

Measured memory_bytes: 2560
// https://atcoder.jp/contests/abc083/tasks/abc083_b

#include <iostream>

using  namespace std;

int64_t digit_total(int64_t x) {
    int64_t ret = 0;
    while(x > 0) {
        ret += x % 10;
        x /= 10;
    }
    return ret;
}
int main() {
    int64_t N, A, B, R=0;
    cin >> skipws;
    cin >> N >> A >> B;
    for(int64_t i=1; i <= N; ++i) {
        auto t = digit_total(i);
        if (t >= A && t <=B) {
            R += i;
        }
    }
    cout << R << endl;
}


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

int N, M, Q, X[505][505], C[509][509];

int main(){
    
    cin >> N >> M >> Q;
    
    int l, r;
    for ( int i = 0; i<M; i++) {
        scanf("%d%d", &l, &r);
        X[l][r]++;
    }
    
    for ( int i = 1; i <= N; i++) {
        for ( int j = 1; j <= N; j++ ) C[i][j] = C[i][j-1] + X[i][j];
    }
    
    
    for ( int i = 0; i < Q; i++ ) {
        scanf("%d%d", &l, &r);
        int sum = 0;
        for ( int i = l; i <= r; i++ ) sum += C[i][r] - C[i][i-1];
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int MX = 2e5+5;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

int in[MX],out[MX],t[MX],k;
vector<int> to[MX];
int dfs(int v , int p = -1){
	in[v] = k++;
	for(int u: to[v]){
		if(u==p)
			continue;
		t[v] += dfs(u,v);
	}
	out[v] = k;
	return t[v];
}

vector<int> vs[MX];
ll c2(ll n){ return n*(n+1)/2;}
int main(){
	int n; cin >> n;
	vector<int> c(n);
	for(int i = 0 ; i < n ; i++){
		cin >> c[i];
	}
	for(int i = 1 ; i < n ; i++){
		int a , b;
		cin >> a >> b;
		a--;b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	dfs(0);
	for(int i = 0 ; i < n ; i++){
		vs[c[i]-1].push_back(i);
	}
	ll tot = c2(n);
	BIT<int> d(n);
	for(int i = 0 ; i < n ; i++){
		d.add(i,1);
	}
	for(int i = 0 ;i < n ; i++){
		ll ans = tot;
		vector<int>& nvs = vs[i];
		sort(nvs.begin(),nvs.end(),[&](int a , int b){
			return in[a] > in[b];
		});
		vector<pair<int,int>> history;
		for(int v : nvs){
			int cnt = 1;
			for(int u : to[v]){
				if(in[u] < in[v]) continue;
				int num = d.sum(in[u],out[u]);
				ans -= c2(num);
				cnt += num;
			}
			d.add(in[v],-cnt);
			history.emplace_back(in[v],cnt);
		}
		ans -= c2(d.sum(0,n));
		for(auto p:history){
			d.add(p.first,p.second);
		}
		cout<<ans<<"\n";
	}
	return 0;
}


Measured memory_bytes: 39116
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a=0,b=0;
    cin>>a>>b;
    if(a>b){
        cout<<"a > b"<<endl;
    }else{
        if(a==b){
            cout<<"a == b"<<endl;
        }else{
            cout<<"a < b"<<endl;
        }
    }
    return 0;
}


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

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

    if(R < 1200)
        cout << "ABC" << endl;
    else if(R < 2800)
        cout << "ARC" << endl;
    else
        cout << "AGC" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a[26]={};
  int i;
  for(i=0;i<s.length();i++){
    a[s[i]-'a']++;
  }
  for(i=0;i<26;++i){
    if(a[i]==0){
      cout<<char('a'+i);
      return 0;
    }
  }
  cout<<"None";
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<stack>
#include<vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int sc = 0;
	int m = 0, u = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '(')sc++;
		else sc--;

		if (sc < 0)m++, sc++;
	}
	u += sc;
	for (int i = 0; i < m; i++)cout << '(';
	cout << s;
	for(int i=0;i<u;i++)cout << ')';
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>
#include <bitset>

using namespace std;


int main(){
    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0;
    for (int i = 1; i < N+1; i++) cin >> t[i] >> x[i] >> y[i];
    
    bool flag = true;
    for(int i = 1; i < N+1; i++){
        int dt = t[i] - t[i-1];
        int dist = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);

        if(dt < dist) flag = false;
        if(dt % 2 != dist % 2) flag = false;
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <vector>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) ((int) (a).size())

const int N = 300;
int color[2][2 * N][2 * N], n, d[2];
vector< pair<int, int> > dirs[2], all[2][2];

void dfs(int c, int x, int y, int cur) {
	color[c][x][y] = cur;
	for (int i = 0; i < sz(dirs[c]); ++i) {
		int nx = x + dirs[c][i].fs, ny = y + dirs[c][i].sc;
		if ((nx >= 0) && (ny >= 0) && (nx < 2 * n) && (ny < 2 * n) && (color[c][nx][ny] == -1)) {
			dfs(c, nx, ny, cur ^ 1);
		}
	}
}

int main() {
	scanf("%d%d%d", &n, &d[0], &d[1]);
	for (int c = 0; c < 2; ++c) {
		for (int dx = -2 * n + 1; dx < 2 * n; ++dx) {
			for (int dy = -2 * n + 1; dy < 2 * n; ++dy) {
				int cd = dx * dx + dy * dy;
				if (cd == d[c]) {
					dirs[c].pb(mp(dx, dy));
				}
			}
		}
	}
	memset(color, -1, sizeof(color));
	for (int c = 0; c < 2; ++c) {
		for (int i = 0; i < 2 * n; ++i) {
			for (int j = 0; j < 2 * n; ++j) {
				if (color[c][i][j] == -1) {
					dfs(c, i, j, 0);
				}
			}
		}
	}
	for (int i = 0; i < 2 * n; ++i) {
		for (int j = 0; j < 2 * n; ++j) {
			vector< pair<int, int> > &who = all[color[0][i][j]][color[1][i][j]];
			who.pb(mp(i, j));
			if (sz(who) == n * n) {
				for (int k = 0; k < n * n; ++k) {
					printf("%d %d\n", who[k].fs, who[k].sc);
				}
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 34776
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        
        while(!("0 0".equals(str))){
            String[] input = str.split(" ");
            int h = new Integer(input[0]);
            int w = new Integer(input[1]);
            StringBuilder sb = new StringBuilder();
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if((i+j)%2==0) sb.append("#");
                    else sb.append(".");
                }
                sb.append("\n");
            }
            str = sc.nextLine();
            System.out.println(sb);
        }
    }
}


Measured memory_bytes: 27712
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=100;
int N;
int L[MAX_N];
int main(){
	cin>>N;
	REP(i,N)cin>>L[i];
	sort(L,L+N);
	int sm=0;
	REP(i,N-1)sm+=L[i];
	cout<<(sm>L[N-1] ? "Yes" : "No")<<endl;
}

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

const int MAX = 1000010;
int tbl[MAX];

void intialize(const string &str)
{
  int n = str.size();

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

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

void kmp(const string &str, const string &ptn)
{
  intialize(ptn);
  int m = 0, i = 0, n = str.size();

  while (m+i < n) {
    if (ptn[i] == str[m+i]) {
      if (++i == ptn.size()) {
        cout << m << endl;
        m += i - tbl[i];
        i = tbl[i];
      }
    } else {
      m += i - tbl[i];
      i = (i==0?0:tbl[i]);
    }
  }
}

int main()
{
  string s1, s2;

  cin >> s1 >> s2;
  kmp(s1, s2);

  return EXIT_SUCCESS;
}




Measured memory_bytes: 3980
#include <stdio.h>
#define MAX 100000
int main()
{
	int n,num=0;
	int a[MAX];
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	  i=1;
	  while(1)
	  {
  		num++;
  		if(a[i]==2)
  		{
		  	printf("%d",num);
		  	break;
		  }
		  i=a[i];
		  if(num>n)
		  {
  			printf("-1");
  			break;
  		}
  	}
	
	

}

Measured memory_bytes: 512
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var n = long.Parse(Console.ReadLine().Trim());
        var c1 = getC(s);
        if (n <= c1) Console.WriteLine(1);
        else Console.WriteLine(s[c1]);
    }
    public static int getC (string s)
    {
        var ret = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == '1') ret++;
            else break;
        }
        return ret;
    }
}

Measured memory_bytes: 11092
using System;
using System.IO;

class Program{
    static void Main(string[] args){
        var A1 = Console.ReadLine().Split();
        var A2 = Console.ReadLine().Split();
        var A3 = Console.ReadLine().Split();
        var sheet = new[] {A1, A2, A3};
        var N = int.Parse(Console.ReadLine());
        var isHoles = new bool[3, 3];
        for (int i = 1; i <= N; i++){
            var b = Console.ReadLine();
            for (int r = 0; r < 3; r++){
                for (int c = 0; c < 3; c++){
                    if (b == sheet[r][c]) isHoles[r,c] = true;}}}
        var isBingo = false;
        for (int r = 0; r < 3; r++) if (!isBingo) isBingo = isHoles[r, 0] && isHoles[r, 1] && isHoles[r, 2];
        for (int c = 0; c < 3; c++) if (!isBingo) isBingo = isHoles[0, c] && isHoles[1, c] && isHoles[2, c];
        if (!isBingo) isBingo = isHoles[0, 0] && isHoles[1, 1] && isHoles[2, 2];
        if (!isBingo) isBingo = isHoles[0, 2] && isHoles[1, 1] && isHoles[2, 0];
        var answer = isBingo ? "Yes" : "No";
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 27440
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 101010
void build(){

}
int n , a[ N ];
void init(){
  n = getint();
  for( int i = 0 ; i < n ; i ++ )
    a[ getint() ] ++;
}
int c[ N ] , cnt;
vector<int> v;
bool okay( int lft , int rgt ){
  return c[ rgt ] - c[ lft - 1 ] > 0;
}
int cal(){
  if( cnt == 0 ) return 0;
  if( cnt == 2 ){
    if( okay( v[ 0 ] , v[ 1 ] ) )
      return 0;
    return 1;
  }
  int sz = (int)v.size();
  if( c[ v[ sz - 1 ] ] - c[ v[ 1 ] - 1 ] > 0 )
    return 0;
  if( c[ v[ sz - 2 ] ] - c[ v[ 0 ] - 1 ] > 0 )
    return 0;
  return 1;
}
void solve(){
  for( int i = 1 ; i < N ; i ++ ){
    if( a[ i ] ){
      if( a[ i ] > 1 )
        v.push_back( i );
      cnt += a[ i ] - 1;
      c[ i ] = a[ i ] % 2;
    }
    c[ i ] += c[ i - 1 ];
  }
  if( cnt % 2 )
    printf( "%d\n" , n - cnt - 1 );
  else
    printf( "%d\n" , n - cnt - cal() );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


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

//const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

const int MAX_N = 100010;
ll K[MAX_N+1];
ll inv[MAX_N+1];

ll mul(ll _a, ll _b) {
  if (_b == 0) return 1LL;
  if (_b == 1) return _a;
  ll ans = mul(_a, _b/2);
  ans *= ans;
  ans %= MOD;
  if (_b&1) ans *= _a;
  return ans % MOD;
}

ll C(ll _n, ll _k) {
  return (K[_n] * ((inv[_k] * inv[_n-_k]) % MOD)) % MOD;
}

void init() {
  K[1] = 1;
  inv[1] = 1;
  inv[0] = 1;
  for (ll i = 2; i <= MAX_N; i++) {
    K[i] = K[i-1]*i;
    K[i] %= MOD;
    inv[i] = mul(K[i], MOD-2);
  }
}

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

  init();
  int n;
  cin >> n;
  int a[n+1];
  int b[n+1] = {};
  int l = 0, r = 0;
  REP(i,n+1) {
    cin >> a[i];
    if (b[a[i]] == 0) b[a[i]] = i+1;
    else {
      l = b[a[i]]-1;
      r = i;
    }
  }
  int L = n-r+l;
  REP(i,n+1) {
    if (i == 0) cout << n << endl;
    else {
      ll ans = C(n+1, i+1);
      if (L >= i) {
        ans = ans + MOD - C(L,i);
        ans %= MOD;
      }
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3584
n = gets.to_i
dp = Array.new(n).map{Array.new(4).map{Array.new(4).map{Array.new(4,0)}}}
mod = 10**9+7
4.times do |i|
    dp[0][0][0][i] = 1
end
4.times do |i|
    4.times do |j|
        dp[1][0][i][j] = 1
    end
end
4.times do |i|
    4.times do |j|
        4.times do |k|
            dp[2][i][j][k] += dp[1][0][i][j] if !(i == 0 && j == 2 && k == 1) && !(i == 0 && j == 1 && k == 2) && !(i == 2 && j == 0 && k == 1)
        end
    end
end
for i in 3..n-1
    4.times do |j|
        4.times do |k|
            4.times do |l|
                4.times do |m|
                    dp[i][j][k][l] += dp[i-1][m][j][k] if !(j == 0 && k == 2 && l == 1) && !(j == 0 && k == 1 && l == 2) && !(j == 2 && k == 0 && l == 1) && !(m == 0 && j == 2 && l == 1) && !(m == 0 && k == 2 && l == 1)
                    dp[i][j][k][l] %= mod
                end
            end
        end
    end
end
ans = 0
4.times do |i|
    4.times do |j|
        4.times do |k|
            ans += dp[n-1][i][j][k]
            ans %= mod
        end
    end
end
puts ans

Measured memory_bytes: 1916
from bisect import bisect_right, bisect_left

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0

for bi in range(N):
    ai_max = bisect_left(A, B[bi])
    ci_min = bisect_right(C, B[bi])
    ans += (ai_max) * (N - ci_min)

print(ans)


Measured memory_bytes: 23232
#include <iostream>
#include <cstdlib>
#include <vector>
#include <map>

using namespace std;

using ll = long long;

int main() {
    int k;
    cin >> k;
    
    vector<int> a(k);
    
    for (int i = 0; i < k; i++) {
        cin >> a[i];
    }
 
    ll l1 = 0, r1 = 1LL << 60;
    
    while (r1 - l1 > 1) {
        ll m = (r1 + l1) / 2;
        
        ll x = m;
        for (int i = 0; i < k; i++) {
            x = x / a[i] * a[i];   
        }
        
        if (x > 2) {
            r1 = m;   
        } else {
            l1 = m;
        }
    }
    
    ll l2 = 0, r2 = 1LL << 60;
    
    while (r2 - l2 > 1) {
        ll m = (r2 + l2) / 2;
        
        ll x = m;
        for (int i = 0; i < k; i++) {
            x = x / a[i] * a[i];   
        }
        
        if (x >= 2) {
            r2 = m;   
        } else {
            l2 = m;
        }
    }
    
    if (l1 - r2 > 0) {
        cout << r2 << ' ' << l1 << endl;   
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 640
#include <stdio.h>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <string.h>
#include <time.h>
#include <algorithm>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

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

	vector<vector<int>> arr(3, vector<int>(n));

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

		sort(arr[i].begin(), arr[i].end());
	}

	i64 res = 0;

	for (int i = 0; i < n; i++)
	{
		auto aiter = lower_bound(arr[0].begin(), arr[0].end(), arr[1][i]);
		auto biter = upper_bound(arr[2].begin(), arr[2].end(), arr[1][i]);

		i64 acount = 0, bcount = 0;

		acount = aiter - arr[0].begin();
		bcount = n - (biter - arr[2].begin());

		res += acount * bcount;
	}

	printf("%lld", res);

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;

void solve(void){

  long long int N,M;
  cin >> N >> M;
  
  int ans=0;
  
  if(N==0) N=1;
  if(M==0) M=1;
  ans=N*(N-1)/2+M*(M-1)/2;
  
  cout << ans << endl;
  
return;
}

int main(void){
  
	solve();
	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int d;
	cin>>d;
	switch(d){
		case 22:
			cout<<"Christmas Eve Eve Eve"<<endl;
			break;
		case 23:
			cout<<"Christmas Eve Eve"<<endl;
			break;
		case 24:
			cout<<"Christmas Eve"<<endl;
			break;
		case 25:
			cout<<"Christmas"<<endl;
			break;
		default:break;
	}
	return 0;
}


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

int main(){

    string s;
    cin >> s;

    string t[4];
    t[0]="dream";
    t[1]="dreamer";
    t[2]="erase";
    t[3]="eraser";

    int pos=s.size();
    int l=4;
    while(pos>0){
        l++;
        string te=s.substr(pos-l,l);
        rep(i,4){
            if(t[i]==te){
                pos-=l;
                l=4;
                break;
            }
        }
        if(l==7){
            cout << "NO" <<endl;
            return 0;
        }
        
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 512
$N=<>;/ /,push@{$`},$' for<>;map$q[$_]+=$q[$i]/@$i,@{$i=$_}for++$q[1]..$N;while(--$N){$s=$m=0;$m=$_>$m?$_:$m,$s+=$_ for@e[@$N];$e[$N]=1+$s/@$N;$a<($t=$q[$N]*=$#$N&&($s-$m)/$#$N-$s/@$N)or$a=$t}print"@e"+$a

Measured memory_bytes: 42368
k,n=map(int,input().split())
a=list(map(int,input().split()))

max_n=0

for i in range(n-1):
  range_n=a[i+1]-a[i]
  if range_n >max_n:
    max_n=range_n

range_n=k-(a[n-1]-a[0])
if range_n > max_n:
  max_n=range_n
print(k-max_n)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, N;
    cin >> H >> W >> N;
    cout << (N + (max(H,W) - 1)) / max(H,W) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		String str=s.next();
		
		for(int i=0;i<3;i++)
		{
			System.out.print(str.charAt(i));
		}
		
	}
	
}

Measured memory_bytes: 35640
#include <iostream>
#include <string>
#include <sstream>
#include <math.h>
#include <vector>

using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::vector;

int main()
{
    vector<int>  vec = {1,2,3,4,5};
    int x;
    cin >> x;
    string str = std::to_string(x);
    
    if (x < 100) {
        cout << 0;
        return 0;
    }
    
    int last = atoi(str.substr(str.length()-2).c_str());
    int top = atoi(str.substr(0, str.length()-2).c_str());
    
    if (last <= top) {
        cout << 1;
        return 0;
    }
    
    
    int temp = 0;
    int i = last;
    int count = 0;
    for (; count < top; ++count) {
        for (int j = 4; j >= 0; --j) {
            temp = i - vec[j];
            if (temp >= 0) {
                i = temp;
                break;
            }
        }
        if (i == 0) {
            cout << 1;
            return 0;
        }
    }
    cout << 0;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
 
const ll oo = 1e15 + 7;
const int mod = 1e9 + 7, maxn = (2 * 1e3) + 10;
const long double PI = acos(-1);

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N, W;

    cin >> N >> W;

    vector<vector<ll>> dp(N+1, vector<ll>(3*N + 1, -oo));
    vector<ll> w(N), v(N);

    dp[0][0] = 0;

    for (int i=0; i<N; i++){
        cin >> w[i] >> v[i];
    }

    ll base = w[0];

    for (int i=0; i<N; i++){
        ll sobra = w[i] - base;
        for (int j=N; j>=1; j--){
            for (int k=N*3; k>=sobra; k--){
                if (dp[j-1][k-sobra] != -oo){
                    dp[j][k] = max(dp[j-1][k-sobra] + v[i], dp[j][k]);
                }
            }
        }
    }
    ll ans = 0;

    for (int i=0; i<=N; i++){
        for (int j=0; j<=N*3; j++){
            if (i*base + j > W) break;
            ans = max(dp[i][j], ans);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3005;
const int mod = 998244353;
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
int t;
int n,m; 
int c[maxn];
int f[maxn];
int add(int a,int b){ a+=b; return a>=mod?a-mod:a;}  

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

Measured memory_bytes: 256
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

int tab[100005];
int dp[100005];

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    int n, k;
	
	cin >> n >> k;
	
	for(int i = 0; i < n; i++){
		cin >> tab[i];
	}
	
	for(int i = 0; i < 100005; i++){
		dp[i] = INF;
	}
	
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= k; j++){
			if(i + j < n){
				dp[i+j] = min(dp[i+j], dp[i] + abs(tab[i] - tab[i+j]));
			}
		}
	}    

    cout << dp[n-1] << endl;
    
    
  
	
	return 0;
}


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int N;

  while(cin >> N){
    vector<i64> A(N); cin >> A;

    map<i64, int> m;

    i64 ans = 0;

    REP(i,N){
      ans += m[i - A[i]];

      m[i + A[i]] += 1;
    }
    
    pout(ans);
  }


  return 0;
}


Measured memory_bytes: 27384
m1 = [31,28,31,30,31,30,31,31,30,31,30,31]
m2 = [31,29,31,30,31,30,31,31,30,31,30,31]
while 1:
    try:d = list(map(int, input().split(".")))
    except:break
    if len(d) == 3:
        days = -734858
        days += (d[0] - 1) * 365 + (d[0] - 1) // 4 - (d[0] - 1) // 100 + (d[0] - 1) // 400
        if d[0] % 4 == 0 and (d[0] % 100 != 0 or d[0] % 400 == 0):days += sum(m2[:d[1] - 1])
        else:days += sum(m1[:d[1] - 1])
        days += d[2]
        maya = [0,0,0,0,0]
        maya[0] = days // 144000 % 13
        maya[1] = days // 7200 % 20
        maya[2] = days // 360 % 20
        maya[3] = days // 20 % 18
        maya[4] = days % 20
        print(".".join(map(str, maya)))
    else:
        days = d[0] * 144000 + d[1] * 7200 + d[2] * 360 + d[3] * 20 + d[4] + 734858
        sei = [1,0,0]
        sei[0] += (days  - 1) // 146097 * 400
        days -= (days  - 1) // 146097 * 146097
        sei[0] += min(3, (days  - 1)// 36524) * 100
        days -=  min(3, (days  - 1)// 36524) * 36524
        sei[0] += min(24, (days  - 1) // 1461) * 4
        days -= min(24, (days  - 1) // 1461) * 1461
        sei[0] += min(3, (days  - 1) // 365)
        days -= min(3, (days  - 1) // 365) * 365
        if sei[0] % 4 == 0 and (sei[0] % 100 != 0 or sei[0] % 400 == 0):
            for i in range(12):
                if sum(m2[:i + 1]) >= days:
                    sei[1] = i + 1
                    days -= sum(m2[:i])
                    break
        else:
            for i in range(12):
                if sum(m1[:i + 1]) >= days:
                    sei[1] = i + 1
                    days -= sum(m1[:i])
                    break
        sei[2] = days
        print(".".join(map(str, sei)))


Measured memory_bytes: 5636
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        flag = True
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] != b[k][l]:
                    flag = False
                    break
            if not flag:
                break
        if flag:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 38256
/**
  @date Time-stamp: <2019-05-26 21:04:25 tagashira>
  @file a.cpp
  @title A - Apple Pie
  @brief https://atcoder.jp/contests/abc128/tasks/abc128_a
**/

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
  uint A, P;
  cin >> A >> P;

  cout << (int)((A * 3 + P) * 0.5) << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MyWeekMath;

namespace AtCoder137C
{
    class KoregaOrenoKotaeDa
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            Dictionary<string, long> strs = new Dictionary<string, long>();

            long ans = 0;

            for(long a = 0; a < n; a++)
            {
                string str = new string(Console.ReadLine().ToCharArray().OrderBy(x => x).ToArray());

                if (strs.ContainsKey(str))
                {
                    ans -= MyMath.Combination(strs[str], 2);
                    strs[str]++;
                    ans += MyMath.Combination(strs[str], 2);
                }
                else
                {
                    strs.Add(str, 1);
                }
            }

            Console.WriteLine(ans);
        }
    }
}

namespace MyWeekMath
{
    class MyMath
    {
        public static long Combination(long n, long r)
        {
            return Permutation(n, r) / Permutation(r, r);
        }

        public static long Permutation(long n, long r)
        {
            long ans = n;
            for (int a = 1; a < r; a++)
            {
                ans *= n - a;
            }
            return ans;
        }
    }
}

Measured memory_bytes: 29980
from collections import deque


def main():
    sequence = input()
    stack = deque()
    pools = deque()
    for i, e in enumerate(sequence):
        if e == '\\':
            stack.append(i)
        elif e == '_':
            continue
        else:
            if len(stack) == 0:
                continue
            pre = stack.pop()
            s = 0
            while len(pools) > 0 and pre < pools[-1][1]:
                tmp = pools.pop()
                s += tmp[0]
            pools.append((s + i - pre, i))
    length = str(len(pools))
    results = list(map(lambda x: x[0], pools))
    print(sum(results))
    print(' '.join([length] + [str(r) for r in results]))


if __name__ == '__main__':
    main()



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

using namespace std;

#define ll long long

signed main() {
	int m, d;
	cin >> m >> d;
	int ans = 0;
	for (int i = 1; i <= m; ++i) { // i月
		for (int j = 1; j <= d; ++j) { // j日
			int d1 = j % 10;
			int d10 = j / 10;
			if (d1 < 2 || d10 < 2)
				continue;
			if (d1 * d10 == i)
				++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)



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

	int N;
	cin >> N;
	vector<ll>a(N);
	vector<ll>b(N);
	vector<int>p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		p[i]--;
	}

	a[0] = 1;
	b[N - 1] = 1;
	for (int i = 1; i < N; i++)a[i] = a[i - 1] + 30000LL;
	for (int i = N - 2; i >= 0; i--)b[i] = b[i + 1] + 30000LL;
	for (int i = 0; i < N; i++)a[p[i]] += i;
	for (int i = 0; i < N; i++)cout << a[i] << " ";
	cout << endl;
	for (int i = 0; i < N; i++)cout << b[i] << " ";
	cout << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <list>

using namespace std;

int main(){
	int x, n, l = 0, sum = 0;
	list<int> array;
	cin >> n;
	while (cin >> x){
		array.push_back(x);
		if (x > l)
			l = x;
		sum += x;
	}
	list<int>::iterator it;
	if (sum > 2 * l)cout << "Yes" << endl;
	else cout << "No" << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int f(int n)
{
	if(n%4 == 0)
		return n;
	if(n%4 == 1)
		return 1;
	if(n%4 == 2)
		return n + 1;
	return 0;
}

int32_t main()
{
	IOS;
	int a, b;
	cin>>a>>b;
	int ans = f(b) ^ f(max(0LL, a - 1));
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = map(int, input().split())
    ans = float("inf")
    for a in A:
        tmp = 0
        while a % 2 == 0:
            a //= 2
            tmp += 1
        ans = min(ans, tmp)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mxn=2e5+5;

int main() {
	ll n;
	cin>>n;
	ll a[n],i,x=0;
	for(i=0;i<n;i++) {
		cin>>a[i];
		x ^= a[i];
	}
	ll b[n];
	for(i=0;i<n;i++) {
		b[i] = a[i]^x;
	}
	for(i=0;i<n;i++)
		cout<<b[i]<<" ";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 6688
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    string x,y;
    cin >> x >> y;
    int A = 10;
    int B = 11;
    int C = 12;
    int D = 13;
    int E = 14;
    int F = 15;
    if(x > y)cout << ">" << endl;
    else if(x == y)cout << "=" << endl;
    else cout << "<" << endl;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int num[] = new int[n];

		for (int i = 0; i < n; i++) {
			num[i] = scan.nextInt();
		}

		int count = 0;

		for (int i = 0; i < n; i++) {
			for (int j = n - 1; j >= i + 1; j--) {
				if (num[j] < num[j - 1]) {
					int tmp = num[j];
					num[j] = num[j - 1];
					num[j - 1] = tmp;
					count++;
				}
			}
		}

		for (int i = 0; i < n; i++) {
			System.out.print(num[i]);
			if (i != n - 1)
				System.out.print(" ");
		}

		System.out.println();
		System.out.println(count);
		scan.close();
	}

}

Measured memory_bytes: 19636
a, b, c, x, y = list(map(int, input().split()))

ans = float("INF")
for i in range(max(x, y)+1):
  t = c*2*i
  if x>i:
    t += (x-i)*a
  if y>i:
    t += (y-i)*b
  ans = min(ans, t)
print(ans)

Measured memory_bytes: 3064
#include <stdlib.h>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
#include <set>


using namespace std;
int n,k,x;
vector<int> vec;
int main() {
    cin>>n>>k;
    for(int i=0;i<n;i++) {
        cin>>x;
        vec.push_back(x);
    }
    sort(vec.begin(),vec.end());
    long long int res = 0;
    for(int i=0;i<k;i++) {
        res+=vec[i];
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3588
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int ans;

main(){
	int a,b,c;
	cin>>a>>b>>c;
	while(clock()<=1.995*CLOCKS_PER_SEC){
		if(a&1||b&1||c&1){
			//debug(a,b,c,a%2,b%2,c%2,(a%2||b%2||c&2,(0||0||0));
			dans;return 0;
		}
		int ta,tb,tc;
		ta=b/2+c/2;
		tb=a/2+c/2;
		tc=a/2+b/2;
		a=ta;b=tb;c=tc;
		//debug(a,b,c);
		ans++;
	}
	dump(-1);
}

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

n, k = map(int, input().split())
A = list(map(int, input().split()))
dp = [0]*(k+1)
for i in range(k+1):
  for a in A:
    if i-a >= 0 and not dp[i-a]:
      dp[i] = 1
      break
result = dp[k]
if result:
  print("First")
else:
  print("Second")

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

using namespace std;
using ll = long long;
#define int long long

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  int tot[10][10];
  memset(tot, 0, sizeof tot);
  for(int i = 1; i <= n; ++i) {
    string s = to_string(i);
    if(s.back() == '0') continue;
    tot[s.front() - '0'][s.back() - '0']++;
  }
  int res = 0;
  for(int i = 1; i <= n; ++i) {
    string s = to_string(i);
    if(s.back() == '0') continue;
    res += tot[s.back() - '0'][s.front() - '0'];
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <memory>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
typedef long long int ll;
using namespace std;
int main(){
	ll n,k; cin >>n >>k;
	vector<int> a(n),b(n);
	cinf(n,a,b);
	map<ll,ll> mp;
	for(int i=0;i<n;i++){
		mp[a[i]]+=b[i];
	}
	ll cnt=0;
	ll ans=-1;
	for(auto p:mp){
		cnt+=p.second;
		if(cnt>=k){
			ans=p.first;
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 4992
def rollDice(dice, direction):
    buf = [x for x in dice]
    if direction == "S":
        buf[0] = dice[4]
        buf[1] = dice[0]
        buf[4] = dice[5]
        buf[5] = dice[1]
    elif direction == "E":
        buf[0] = dice[3]
        buf[2] = dice[0]
        buf[3] = dice[5]
        buf[5] = dice[2]
    elif direction == "W":
        buf[0] = dice[2]
        buf[2] = dice[5]
        buf[3] = dice[0]
        buf[5] = dice[3]
    elif direction == "N":
        buf[0] = dice[1]
        buf[1] = dice[5]
        buf[4] = dice[0]
        buf[5] = dice[4]

    for i in range(6):
        dice[i] = buf[i]


def rollDiceSide(dice):
    buf = [x for x in dice]
    buf[1] = dice[2]
    buf[2] = dice[4]
    buf[3] = dice[1]
    buf[4] = dice[3]

    for i in range(6):
        dice[i] = buf[i]


d = list(map(int, input().split()))
n = int(input())

for i in range(n):
    q1, q2 = list(map(int, input().split()))

    wq = d.index(q1)
    if wq == 1:
        rollDice(d, "N")
    elif wq == 2:
        rollDice(d, "W")
    elif wq == 3:
        rollDice(d, "E")
    elif wq == 4:
        rollDice(d, "S")
    elif wq == 5:
        rollDice(d, "S")
        rollDice(d, "S")

    wq = d.index(q2)
    if wq == 2:
        rollDiceSide(d)
    elif wq == 3:
        rollDiceSide(d)
        rollDiceSide(d)
        rollDiceSide(d)
    elif wq == 4:
        rollDiceSide(d)
        rollDiceSide(d)

    print(d[2])




Measured memory_bytes: 5620