akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    if (i % 3 == 0 || i % 5 == 0) continue;
    ans += i;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
n, a, b = map(int, input().split())
s_l = input()
ca = 0
cb = 0
for s in s_l:
    if s == 'a' and ca + cb < a+b:
        ca += 1
        print('Yes')
    elif s == 'b' and ca + cb < a+b and cb < b:
        cb += 1
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    if (s.find('R') != -1)
        cnt = 1;
    int mx = 0;
    for (int i = 0; i < 2; i++)
    {
        if (s[i] == 'R' && s[i + 1] == 'R')
            cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <map>
#include <vector>

using namespace std;
#define N 4

int main(void)
{
    ios::sync_with_stdio(false);
    int a[N], b[N];
    int hit, blow;

    while(cin >> a[0] >> a[1] >> a[2] >> a[3], !cin.eof()) {
        for(int i=0; i<N; i++) cin >> b[i];

        hit = blow = 0;
        for(int i=0; i<N; i++) {
            for(int j=0; j<N; j++) {
                if(a[i] == b[j]) {
                    if(i == j) hit++;
                    else blow++;
                }
            }
        }

        cout << hit << " " << blow << endl;
    }

    return 0;
}

Measured memory_bytes: 1192
n = gets.to_s.to_i
a = gets.to_s.split.map{|t| t.to_i }.sort
b = gets.to_s.split.map{|t| t.to_i }.sort
c = gets.to_s.split.map{|t| t.to_i }.sort

ans = i = j = 0

b.each do |m|
  
  while i < n && a[i] < m
    i += 1
  end
  
  while j < n && c[j] <= m
    j += 1
  end
  
  break if j == n 
    
  ans += i * (n-j)
  
end

puts ans

Measured memory_bytes: 24688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    string s;
    cin >> s;
    for(int i = 0; i < 3; i++) {
        if(s[i] == '1') s[i] = '9';
        else s[i] = '1';
    }
    cout << s << endl;
}

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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
  string s;
  cin >> s;
  cout << s.at(0) << s.size()-2 << s.at(s.size()-1) << endl;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int cnt = 0;
            for (int i =0;i<S.Length/2;i++)
            {
                if(S.Substring(i,1) != S.Substring(S.Length - i-1, 1))
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

Measured memory_bytes: 11092
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 3e5 + 1;
const long long MNN = 1e3 + 1;
const long long MOD = 998244353;
const long long INF = 1e18;
const long long OO = 1e15;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, x;
vector<int> q[MXN];
vector<int> v;

llong dfs(int x){
	vector<llong> v;
	for(int i = 0; i < q[x].size(); i++){
		v.pb(dfs(q[x][i]));
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	llong mx = 0;
	for(int i = 0; i < v.size(); i++){
		mx = max(v[i] + i + 1, mx);
	}
	return mx;
}

int main(){
	ios;
	cin >> n;
	for(int i = 2; i <= n; i++){
		cin >> x;
		q[x].pb(i);
	}
	cout << dfs(1);
	return 0;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll Mod = 1000000007;
int main() {
  ll A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  ll ans = 9999999999999999;
  for (int i = 0; i <= max(X,Y)+1; i++) {
    ll res = (C * i * 2) + (B * max((ll)(0),Y-i)) + (A * max((ll)(0),X-i));
    ans = min(ans,res);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int64_t n;
	cin >> n;
	vector<int64_t> a(n);
	map<int64_t, int64_t> vote;
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
		int64_t x = a.at(i);
		if (vote.count(x)) vote.at(x)++;
		else vote[x] = 1;
	}
	int64_t ans = 0;
	for (pair<int64_t, int64_t>p : vote) {
		int64_t value = p.second;
		ans += value * (value - 1) / 2;
	}
	for (int i = 0; i < n; i++) {
		int y = vote.at(a.at(i));
		ans -= y - 1;
		cout << ans << endl;
		ans += y - 1;
	}
}

Measured memory_bytes: 11008
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S, T;
  cin>>S>>T;
  map<char, vector<ll> > amap;
  for(int i=0;i<S.size();++i){
    amap[S[i]].push_back(i);
  }
  ll ans = 0;
  ll index = 0;
  int tmp;
  bool can = true;
  for(int i=0;i<T.size();++i){
    tmp = lower_bound(amap[T[i]].begin(), amap[T[i]].end(), index) - amap[T[i]].begin();
    if(amap[T[i]].size()==0){
      can = false;
      break;
    }
    else if(amap[T[i]].size()<=tmp){
      i--;
      ans += S.size()-index;
      index = 0;
      continue;
    }
    ans += amap[T[i]][tmp] - index + 1;
    index = amap[T[i]][tmp]+1;
  }
  if(can) cout<<ans<<endl;
  else cout<<-1<<endl;
}



Measured memory_bytes: 4628
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 998244353;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535 
 
ll dp[3001][3001];
 
int32_t main() {
    fastio;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    dp[a][b] = 1;
    for(ll i=a;i<=c;i++) {
        for(ll j=b;j<=d;j++) {
            if(i == a and j == b) continue;
            dp[i][j] = dp[i][j-1]*i + dp[i-1][j]*j - dp[i-1][j-1]*(i-1)*(j-1);
            dp[i][j] = (MOD + (dp[i][j]) % MOD) % MOD;
        }
    }
    cout<<dp[c][d]<<endl;
}

Measured memory_bytes: 73708
# -*- coding:utf-8 -*-

def cmb(n, r):
    if n == 0 or r == 0:
        return 1
    if n < r:
        return 0
    a = b = 1
    r = min(n-r,r)
    for i in range(1, r + 1):
        a *= i
    for i in range(n-r+1,n+1):
        b *= i
    return b//a

N = list(map(int,input().split()))
M = 10**9 + 7
red = N[0]-N[1]
for i in range(1,N[1]+1):
    x = cmb(red + 1, i) * cmb(N[1] - 1,i-1)
    print(x%M)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string t, s, u; cin >> t >> s >> u;
  cout << "A" << s.at(0) << "C\n";

  return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int main(){
    char s;
    cin >> s;
    if(s == 'A'){cout << 'T' << endl; return 0;}
    if(s == 'T'){cout << 'A' << endl; return 0;}
    if(s == 'C'){cout << 'G' << endl; return 0;}
    if(s == 'G'){cout << 'C' << endl; return 0;}

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  for (int i = 0; i < N; i++) {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    int max = 0;
    for (int i = 0; i < 3; i++) {
      max = a[i] > max ? a[i] : max;
    }

    for (int i = 0; i < 3; i++) {
      a[i] = a[i] == max ? 0 : a[i];
    }

    max *max == a[0] * a[0] + a[1] * a[1] + a[2] * a[2] ? cout << "YES" << endl
                                                        : cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 3016
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<stack>
using namespace std;
using LL = long long;
using Edge = pair<LL,LL>;

LL N;
vector<bool> seen(N);
vector<vector<Edge>> G;
vector<LL> color(N);
void dfs(LL v)
{
	seen[v] = true;
	for(auto e: G[v])
	{
		if(seen[e.first] == true) continue;
		if(e.second % 2 == 0)
		{
			color[e.first] = color[v];
			dfs(e.first);
		}
		else if(e.second % 2 == 1)
		{
			color[e.first] = 1 - color[v];
			dfs(e.first);
		}
	}
}
int main()
{
	cin >> N;
	LL i;
	G.resize(N);
	for(i = 0;i < N-1;i++)
	{
		LL tmpv1,tmpv2,tmpweight;
		cin >> tmpv1 >> tmpv2 >> tmpweight;
		tmpv1--; tmpv2--;
		G[tmpv1].push_back({tmpv2,tmpweight});
		G[tmpv2].push_back({tmpv1,tmpweight});
	}
	seen.assign(N,false);
	color.assign(N,0);
	dfs(0);
	for(i = 0;i < N;i++)
	{
		cout << color[i] << endl;
	}
	return 0;
}
	


Measured memory_bytes: 9984
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	a, b := 0, math.MaxInt32
	for i := 0; i < n; i++ {
		var tmp1, tmp2 int
		fmt.Scan(&tmp1, &tmp2)
		if b > tmp2 {
			b = tmp2
			a = tmp1
		}
	}
	fmt.Println(a + b)
}

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

using namespace std;

int main(){
  int a[10];
  
  cin >> a[1] >> a[2] >> a[3] >> a[4] >> a[5];
  
  for(int i=1;i<=5;i++){
    if(a[i] == 0){
      cout << i << endl;
    return 0;
    }
  }
  
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const ll MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    int count = 0;
    for(int i=1; i<=n; i++) {
        if (int(log10(i))%2==0) count++;
    }
    cout << count << endl;
}

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

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

int main()
{
    ll n;
    cin>>n;
    string c;
    cin>>c;
    ll lr=0,tr=0;
    for(ll i=0;i<n;i++)
    {
        if(c[i]=='R') tr++;
    }
    for(int i=0;i<tr;i++)
    {
        if(c[i]=='R') lr++;
    }
    cout<<tr-lr;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    int k, x;
    cin >> k >> x;
    if (k * 500 >= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
#define     ll          long long 
#define     MP          make_pair
#define     MT          make_tuple 
#define     endl        '\n'
#define     iscanf(a)   scanf("%d",&a)
#define     llscanf(a)  scanf("%lld",&a)
#define     inlp(n)     for(i=n-1;i>=0;i--)
#define     f0(i,n)     for(i=0;i<n;i++)
#define     f1(i,n)     for(i=1;i<=n;++i)
#define     f01(i,n)    for(i=1;i<n;i++)
#define     PB          push_back
#define     IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     inout       freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define     mset(arr,n) memset(arr,n,sizeof(arr))
#define     vci         vector<int>
#define     test        int t;cin>>t;while(t--)
ll gcd(ll a,ll b){ while(b^=a^=b^=a%=b); return a;}

ll comp(ll a,ll b){
	if(a>b)return a;
	return b;
}

int main(){
	IOS;
string s;
cin>>s;
int i,j,sum=0;
if(s[0]=='R' && s[1]=='R' && s[2]=='R')cout<<"3"<<endl;
else if((s[0]=='R' && s[1]=='R')||(s[1]=='R' && s[2]=='R'))cout<<"2"<<endl;
else if(s[0]=='R' || s[1]=='R' || s[2]=='R')cout<<"1"<<endl;
else cout<<"0"<<endl;
	return 0;
}

Measured memory_bytes: 3652
/*input
100 50 4
*/
#include <bits/stdc++.h>

using namespace std;

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int c = 0;
	int a, b, k;
	scanf("%d%d%d", &a, &b, &k);
	vector<int> aa;
	for (int i = 1; i <= min(a, b); i++) {
		if (a % i == 0 && b % i == 0) {
			aa.push_back(i);
		}
	}
	printf("%d\n", aa[(int) aa.size() - k]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  ll n,x,m;
  cin>>n>>x>>m;
  vector<ll>modulo(m+2);
  modulo[1]=x;
  vector<ll>b(m+2);
  rep(i,m+2)
    b[i]=0;
  b[x]=1;
  ll bound;
  ll cir;
  for(ll i=2;i<=m+1;i++){
    x=(x*x)%m;
    if(b[x]==0){
      modulo[i]=x;
      b[x]=i;
    }
    else{
      modulo[i]=x;
      bound=b[x];
      cir=i-bound;
      break;
    }
  }
  ll ans=0;
  for(ll i=1;i<=bound;i++)
    ans+=modulo[i];
  n-=bound;
  ll z=n/cir;
  ll y=n%cir;
  for(ll i=1;i<=cir;i++){
    if(i<=y)
      ans+=modulo[bound+i]*(z+1);
    else
      ans+=modulo[bound+i]*z;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4836
#include"bits/stdc++.h"
using namespace std;
#define int int64_t
 int ar[11000];
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;cin>>a>>b>>c;
    bool flag=true;
    int l1=c-a-b;
    if(l1<0)
        flag=false;
    l1*=l1;
    a*=b;
    a*=4;
    if(l1>a and flag)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int p=1e9+7;
const int N=2000+19;
const int M=N*N;

int Pow(int a,int b){
	int res=1;
	for (;b;b>>=1,a=1ll*a*a%p) if (b&1) res=1ll*res*a%p;
	return res;
}

int dp[2*N][N];
int fac[M],inv[M];
int n,k;

int C(int n,int m){
	return 1ll*fac[n]*inv[m]%p*inv[n-m]%p;
}
void upd(int &x,ll y){
	x=(x+y)%p;
}

int main(){
	fac[0]=1;
	For(i,1,M) fac[i]=1ll*fac[i-1]*i%p;
	inv[M-1]=Pow(fac[M-1],p-2);
	for (int i=M-1;i;i--) inv[i-1]=1ll*inv[i]*i%p;
	n=IN(),k=IN();
	if (k==1){
		puts("1");
		return 0;
	}
	dp[0][0]=1;
	For(i,0,2*n) For(j,0,n+1)
		if (dp[i][j]){
			if (i-j<j) upd(dp[i+1][j],dp[i][j]);
			if (j<n) upd(dp[i+1][j+1],1ll*dp[i][j]*C(j*(k-1)+k-2+i-j,k-2));
		}
	printf("%d\n",1ll*dp[2*n][n]*fac[n]%p);
}

Measured memory_bytes: 63744
fun main(args: Array<String>) {
    val (n, a, b) = readLine()!!.split(" ").map(String::toLong)
    if ((n == 1L && a != b) || a > b) {
        println(0)
        return
    }
    val mini = a * (n - 1) + b
    val maxi = a + b * (n - 1)

    println(maxi - mini + 1)
}


Measured memory_bytes: 37596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N; cin >> N;
    vector<ll> a(N+1);
    for (ll i = 1; i <= N; i++) {
        cin >> a[i];
    }
    if(N%2 == 1){
        for (ll i = N; i > 0; i -= 2) {
            printf("%lld ", a[i]);
        }
        for (ll i = 2; i < N; i += 2) {
            printf("%lld ", a[i]);
        }
    }
    else{
        for (ll i = N; i > 0; i -= 2) {
            printf("%lld ", a[i]);
        }
        for (ll i = 1; i < N; i += 2) {
            printf("%lld ", a[i]);
        }
    }

}


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        boolean[] safe = new boolean[n];
        for(int i=0;i<k;i++){
            int d = sc.nextInt();
            for(int j=0;j<d;j++){
                safe[sc.nextInt()-1] = true;
            }
        }
        int sum = 0;
        for(int i=0;i<n;i++){
            if(!safe[i]) {
                sum++;
            }
        }
        System.out.println(sum);

    }
}


Measured memory_bytes: 37308
object Main extends App{
    // Your code here!
    import scala.io.Source.stdin
    def sort(nums: Array[Int]): (Array[Int],Int) = {
        var times = 0
        var notSorted = true
        while(notSorted) {
            notSorted = false
            for(i <- 0 until nums.length - 1) {
                (nums(i) > nums(i+1)) match {
                    case true => {
                        var tmp = nums(i)
                        nums(i) = nums(i+1)
                        nums(i+1) = tmp
                        notSorted = true
                        times += 1
                    }
                    case false => -1
                }
            }
        }
        (nums,times)
    }
    /*val input = {for(line <- io.Source.stdin.getLines()) yield {
        line
    }}.toSeq*/
    scala.io.StdIn.readLine
    val inputarr = scala.io.StdIn.readLine.split(" ").map{_.toInt}
    val sorted = sort(inputarr)
    println(sorted._1.mkString(" ") + "\n" + sorted._2)
}



Measured memory_bytes: 44012
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[][] v = new int[N+1][N+1];
    for (int i = 0; i < M; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      v[a][b] = 1;
      v[b][a] = 1;
    }
    
    boolean[] visited = new boolean[N+1];
    visited[1] = true;
    int ans = dfs(v, 1, visited);

    System.out.println(ans);
  }
  
  private static int dfs(int[][] v, int n, boolean[] visited) {
    
    boolean allVisited = true;
    for (int i = 1; i < visited.length; i++) {
      if (!visited[i]) {
        allVisited = false;
        break;
      }
    }
    if (allVisited) {
      return 1;
    }

    int ret = 0;
    for (int i = 1; i < v[n].length; i++) {
      if (v[n][i] == 1 && !visited[i]) {
        visited[i] = true;
        ret += dfs(v, i, visited);
        visited[i] = false;
      }
    }
    return ret;
  }
}

Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;

int main() {
    int n,nums[50][26]={};
    cin >> n;
    string str;
    for(int i=0;i<n;i++){
        cin >> str;
        for(int j=0;j<str.size();j++)   nums[i][str[j]-'a']++;
    }
    for(int i=0;i<26;i++){
        int num=100;
        for(int j=0;j<n;j++){
            num = min(num,nums[j][i]);
        }
        while(num--)    cout << char('a'+i);
    }
    cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll solve()
{
    int A, B;

    cin >> A >> B;

    if (A + B >= 10)
        cout << "error" << endl;
    else
        cout << A + B << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}

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

int main()
{
int w, k;
vector<int> ws, ks;
ws.resize(10);
ks.resize(10);
for(int i = 0; i < 10; ++i)
scanf("%d", &ws[i]);
for(int i = 0; i < 10; ++i)
scanf("%d", &ks[i]);
sort(ws.rbegin(), ws.rend());
sort(ks.rbegin(), ks.rend());
w = ws[0] + ws[1] + ws[2];
k = ks[0] + ks[1] + ks[2];
printf("%d %d\n", w, k);
}

Measured memory_bytes: 1036
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

struct edge{ll from,to,weight;};
int vertex,num=1;
vector<edge> g;
vector<int> v;

void multi_2(){
    for(auto &elem : g){
        elem.weight *= 2;
    }
    vertex++;
    
    num *= 2;
    g.push_back({vertex,vertex+1,1});
    g.push_back({vertex,vertex+1,0});
}

void plus_1(){
    g.push_back({1,vertex+1,num});
    num++;
}

int main(){
    ll L;
    cin >> L;
    ll tmp = L;
    vertex=0;
    
    while(tmp > 0){
        v.push_back(tmp%2);
        tmp /= 2;
    }

    reps(i,1,v.size()){
        if(v[v.size()-1-i] == 0){
            multi_2();
        }else{
            multi_2();
            plus_1();
        }
    }
    cout << vertex+1 << " " << g.size() << endl;
    for(auto e : g){
        cout << e.from << " " << e.to << " " << e.weight << endl;
    }

    return 0;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc054/c.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int N, M;
    cin >> N >> M;
    vector<vector<int>> m(N, vector<int>(N, 0));
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        m[a][b] = 1;
        m[b][a] = 1;
    }

    ll ans = 0;
    vector<int> v(N);
    rep(i, N){
        v[i] = i;
    }

    do{
        if(v[0] != 0) break;
        int flag = 0;
        rep(i, N - 1){
            if(m[v[i]][v[i + 1]] == 0) flag = 1;
        }
        if(flag) continue;
        else ans++;
    }while(next_permutation(v.begin(), v.end()));

    cout << ans << "\n";
    return 0;
}

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

long long n, x;
long long res;
long long t;
deque <long long> per;

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

	for (int i = 1; i <= 2 * n - 1; i++)
		per.push_back(i);

	if (x == 1 || x == 2 * n - 1)
		return cout << "No" << '\n', 0;

	res = per[n - 1];
	
	while (res != x) {
		t = per.back();
		per.push_front(t);
		per.pop_back();
		res = per[n - 1];
	}

	cout << "Yes" << '\n';
	
	for (auto i: per)
		cout << i << " ";
	return 0;
}


Measured memory_bytes: 3200
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

#define X first
#define Y second

class union_find {
private:
	vector<int> uf;

public:
	union_find(int n) {
		uf.resize(n, -1);
	}
	
	inline int find(int x) {
		return uf[x] < 0 ? x : uf[x] = find(uf[x]);
	}
	
	inline bool unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y)
			return false;
		
		if(uf[x] > uf[y])
			swap(x, y);
		
		else if(uf[x] == uf[y])
			--uf[x];
		
		uf[y] = x;

		return true;
	}
};

struct edge {
	int u, v;
	double cost;
	edge(int u_, int v_, double c):u(u_), v(v_), cost(c){}

	bool operator> (const edge& o) const {
		return cost > o.cost;
	}
};


vector<edge> es;

double kruskal(int V) {
	sort(es.begin(), es.end(), greater<edge>());
	union_find uf(V);

	double res = 0.0;
	for(int i = 0; i < es.size(); ++i)
		if(uf.unite(es[i].u, es[i].v))
			res += es[i].cost;

	return res;
}

template<typename T> inline T square(T x) {
	return x * x;
}

inline double dist(pair<int, int> u, pair<int, int> v) {
	return sqrt(square(u.X - v.X) + square(u.Y - v.Y));
}

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

	vector<pair<int, int> > piles(n);
	for(int i = 0; i < n; ++i)
		scanf("%d %d", &piles[i].X, &piles[i].Y);

	double sum = 0.0;
	for(int i = 0; i < m; ++i) {
		int p, q;
		scanf("%d %d", &p, &q);
		--p;
		--q;

		const double d = dist(piles[p], piles[q]);
		sum += d;
		es.push_back(edge(p, q, d));
	}

	printf("%.3lf\n", sum - kruskal(n));

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1856
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,c=1,ans=0; cin>>n;
    for(int i=1;i<10;i++){
        c*=3;
        rep(j,c){
            int q=j,num=0,d=1;
            int a3=0,a5=0,a7=0;
            rep(k,i){
                int f=2*(q%3)+3;
                q/=3;
                if(f==3) a3=1;
                if(f==5) a5=1;
                if(f==7) a7=1;
                num+=d*f;
                d*=10;
            }
            if(a3*a5*a7!=0 && n>=num) ans++;
        }
    }
    cout<<ans<<endl;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
  int a, b;
  cin >> a >> b;
  int c = 6;
  cout << c - a - b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
   
using namespace std;
     
#define PB(x) push_back(x)
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x) make_pair(x);
    
#define debug(x) cerr << #x << '=' << x << endl;
#define debug2(x, y) cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(a) for (string& x: a) cerr << x << ' '; cerr << endl;
#define debugm(a, n, m) for (int i = 0; i < n; i++, cout << endl)           \
						for (int j = 0; j < m; j++) cout << a[i][j] << ' ';

#define int long long
     
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 1000000007;

int32_t main()
{
	int n;
	cin >> n;
	
	vs s(n);
	for (string& ss: s) cin >> ss;
	for (int i = 0; i < (int)s.size(); i++)
		sort(ALL(s[i]));
	sort(ALL(s));
	
	int cnt = 1;
	int ans = 0;
	for (int i = 0; i < n-1; i++) {
		if (s[i+1] == s[i])
			cnt++;
		else {
			ans += (cnt*(cnt-1))/2;
			cnt = 1;
		}
	}
	ans += (cnt*(cnt-1))/2;
	cout << ans << endl;
	
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


Measured memory_bytes: 7296
#include <iostream>
#include <string.h>
#include <vector>

using namespace std;

#define MAX 114

vector<int> G[MAX];
int visited[MAX];
bool found;

void dfs(int v)
{
    visited[v] = 0;
    for(int i = 0 ; i < (int)G[v].size() ; i++){
	int to = G[v][i];
	if(visited[to] == -1){
	    dfs(to);
	}else if(visited[to] == 0){
            found = true;            
	    return;
	}
    }
    visited[v] = 1;
}
    
int main()
{
    int M, N;
    cin >> M >> N;
    
    auto canGraph = [=](){
        int lb[MAX][MAX], ub[MAX][MAX];
        for(int i = 0 ; i < MAX ; i++){
            for(int j = 0 ; j < MAX ; j++){
                lb[i][j] = -1;
                ub[i][j] = 101;
            }
        }
        int K, s, t;
        string cond;
        bool possible = 1;
        for(int i = 0 ; i < M ; i++){
            cin >> K;
            for(int j = 0 ; j < K ; j++){
                cin >> s >> cond >> t;
                --s;
                if(cond == ">="){
                    lb[i][s] = max(lb[i][s], t);
                }else{
                    ub[i][s] = min(ub[i][s], t);
                }
            }
            for(int j = 0 ; j < N ; j++){
                if(lb[i][j] > ub[i][j]){
                    possible = 0;
                    break;
                }
            }
        }

        if(!possible) return false;

        auto isConnect = [=](int from, int to){
            for(int i = 0 ; i < N ; i++){
                if(ub[from][i] < lb[to][i]){
                    return true;
                }
            }
            return false;
        };
        
        for(int from = 0 ; from < M ; from++){
            for(int to = 0 ; to < M ; to++){
                if(from == to) continue;
                if(isConnect(from, to)){
                    G[from].push_back(to);
                }
            }
        }
        found = false;
        memset(visited, -1, sizeof(visited));
        for(int i = 0 ; i < M ; i++){
            if(visited[i] == -1){
                dfs(i);
            }
        }                                       
        return !found;
    };
    
    cout << (canGraph() ? "Yes" : "No") << endl;
    return 0;
}

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

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

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
n = int(input())
s = 0
f = False
m = 10**9
for i in range(n):
  a,b = map(int,input().split())
  s += a
  if a < b:
    f = True
  if a > b:
    f = True
    m = min(m,b)
if f:
  print(s-m)
else:
  print(0)

Measured memory_bytes: 9204
#include<bits/stdc++.h>
#define fi first #define se second
using namespace std; typedef long long ll;
const int MAXN = 10 + 1e6;
const ll oo = 1 + 1e18, mod = 7 + 1e9;

long long n, k; long long a[MAXN];

bool check(long long mid){
    long long pos = 0;
    for (int i = 1; i <= n; i++){
        if (a[i] < 0){
            pos += n - (upper_bound(a + 1, a + 1 + n, (long double)mid / a[i]) - a) + 1ll;
        }
        else if (a[i] > 0){
            pos += lower_bound(a + 1, a + 1 + n, (long double)mid / a[i]) - a - 1ll;
        }
        else {
            if (mid > 0) pos += n;
        }
        if (a[i] * a[i] < mid) pos--;
    }
  //  cerr << pos << '\n';
    return pos < k * 2;
}

int main(){
    #define TASK "ABC"
    #ifndef ONLINE_JUDGE
    freopen(TASK".inp","r",stdin),freopen(TASK".out","w",stdout);
    #endif ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);

    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];

    sort (a + 1, a + 1 + n);

    long long lo = -1e18 - 1, hi = 1e18 + 1;
    while (lo < hi){
        long long mid = (lo + hi + 1) / 2;
      //  cerr << mid << '\n';
        if (check(mid)) lo = mid;
        else hi = mid - 1;
    }

    cout << lo;


    return 0;
}


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

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

    string s,s2;
    cin>>s>>s2;

    char c[200];
    memset(c,'1',sizeof(c));
    int j=0;

    for(int i=0;i<s.size(); i++){
        c[j]=s[i];
        j+=2;
    }
    j=1;
    for(int i=0; i<s2.size(); i++){
        c[j]=s2[i];
        j+=2;
    }
    for(int i=0; i<200; i++){
        if(c[i]!='1')
             cout<<c[i]<<"";
    }
    return 0;
}


Measured memory_bytes: 256
def solve():
    N, M = map(int, input().split())

    if N == 1 and M == 1:
        print(1)
        return

    if N == 1:
        print(M-2)
        return

    if M == 1:
        print(N-2)
        return

    print((N-2) * (M-2))


if __name__ == "__main__":
    solve()




Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcnt(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define eps 1e-12
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 200005

int n, a[maxn];
ll fact[maxn], inv[maxn];
map<int, int> M;

ll mu(ll x, ll k){
	if(k == 0) return 1;
	if(k & 1) return mu(x, k - 1) * x % mod;
	ll T = mu(x, k >> 1);
	return T * T % mod;
}

ll C(int A, int B){
	if(A > B) return 0;
	return fact[B] * inv[A] % mod * inv[B - A] % mod;
}

int main()
{
//	freopen("in.txt", "r", stdin);

	ios::sync_with_stdio(0);
	cin.tie(0);
	fact[0] = 1;
	inv[0] = 1;
	For(i, 1, maxn - 1) {
		fact[i] = fact[i - 1] * i % mod;
		inv[i] = mu(fact[i], mod - 2);
	}
	cin >> n;
	int m;
	For(i, 1, n + 1){
		cin >> a[i];
		if(M[a[i]]){
			m = n - i + M[a[i]];
		}
		M[a[i]] = i;
	}
//	cout << n << " " << m << endl;

	For(i, 1, n + 1){
		ll res = (C(i, n + 1) - C(i - 1, m) + mod) % mod;
		cout << res << "\n";
	}

	return 0;
}


Measured memory_bytes: 9472
#include <iostream>

long euclid_algo(long x, long y){
	if(x % y == 0){
		return y;
	}else{
		return euclid_algo(y, x%y);
	}
}

int main(){
	int n;
	std::cin >> n;
	int num[n];
	int ans=0;
	int gcd = 1;
	for(int i = 0; i < n; i++){
	std::cin >> num[i];
	}
	ans = num[0];
	for(int i = 1; i < n; i++){
		gcd = euclid_algo(ans, num[i]);
		ans = ans * num[i] / gcd;
	}
	std::cout << ans <<std::endl;
	return 0;
}

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

using namespace std;


int main(){
    int h,w,n,boro,choto,vag;
    cin>>h>>w>>n;

    boro=max(h,w);
    choto=min(h,w);

    vag= n/boro;
    if(boro*vag==n) cout<<vag<<endl;
    else cout<<vag+1<<endl;


    return 0;
}


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

using namespace std;

int main(){
  long long n;
  long long ans=0;
  cin >> n;
  for(int i=1;i<=n;i++){
    long long nn=n/i;
    ans += nn*(nn+1)/2*i;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3628
h,w = map(int, input().split())
if h ==1 or w == 1:
    print('1')
else:
    if h % 2 != 0:
        if w % 2 != 0:
            ans = (h * w) // 2 + 1
        else:
            ans = w / 2 * h
    else:
        ans = h / 2 * w
    print(int(ans))

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

void f(int *d, int k, int c) {
    if(!k) {
        *d = 1;
        return;
    }
    while(!(k & c))
        c >>= 1;
    f(d + c, k ^ c, c >> 1);
    for(int i = 0; i <= (k ^ c); i++)
        d[i] = d[i + c];
}
int d[1111111];
int main() {
    int n;
    string a;
    cin >> n >> a;
    int t = 1;
    for(auto c : a)
        if(c == '2')
            t = 0;
    f(d, n - 1, 1 << 30);
    int r = 0;
    for(int i = 0; i < n; i++) {
        if(t && a[i] == '3')
            a[i] = '2';
        r ^= a[i] - '1' & d[i];
    }
    cout << (t ? r + r : r) << endl;
    return 0;
}


Measured memory_bytes: 5252
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL unsigned long long
#define MOD 1000000007
#define inf 1999999999



int main() {
	int a, b;
	cin >> a >> b;
	if (a > 9 || b > 9)cout << -1 << endl;
	else cout << a * b << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  int ret = INF;
  for (int i = 0; i < n; ++i) {
    int c, t;
    cin >> c >> t;
    if (t <= m) {
      ret = min(ret, c);
    }
  }
  if (ret == INF) {
    cout << "TLE" << endl;
  } else {
    cout << ret << endl;
  }
  return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	double ans = 0;
	for (int i = 1; i <= N; i++) {
		int point = i;
		double prob = 1;
		while (point < K) {
			point *= 2;
			prob *= 0.5;
		}
		ans += prob / N;
	}
	printf("%.10f\n", ans);
}

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

public class Main {
	static long numFactor(long N){
		long ret = 1;
		List<Integer> factors = new ArrayList<Integer>();
		for(long i = 2 ; i * i <= N ; ++i){
			int f = 0;
			while(N % i == 0){
				N = N / i;
				++f;
			}
			if(f > 0){
				factors.add(f);
			}
		}
		if(N != 1){
			factors.add(1);
		}
		for(int f : factors){
			ret = ret * (long)(f + 1);
		}
		return ret - 1;
	}
	static long rec(List<Long> primes, List<Integer> factors , int cur , long val , long N){
		if(cur == primes.size()){
			if(val == 1){
				return 0;
			}
			while(N % val == 0){
				N = N / val;
			}
			if(N == 1){
				return 1;
			}
			if(val > N){
				return 0;
			}
			N = N - val * (N / val);
			if(N == 1){
				return 1;
			}
			return 0;
		}
		int F = factors.get(cur);
		long P = primes.get(cur);
		long pi = 1;
		long ret = 0;
		for(int i = 0 ; i < F ; ++i){
			ret += rec(primes, factors , cur + 1 , pi * val , N);
			pi = pi * P;
		}
		ret += rec(primes, factors , cur + 1 , pi * val , N);
		return ret;
	}
	static long calc(List<Long> primes, List<Integer> factors, long N){
		return rec(primes , factors , 0 , 1 , N);
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long ret = numFactor(N - 1);
		long originalN = N;
		List<Long> primes = new ArrayList<Long>();
		List<Integer> factors = new ArrayList<Integer>();
		for(long i = 2 ; i * i <= N ; ++i){
			int f = 0;
			while(N % i == 0){
				N = N / i;
				++f;
			}
			if(f > 0){
				primes.add(i);
				factors.add(f);
			}			
		}
		if(N != 1){
			primes.add(N);
			factors.add(1);
		}
		ret += calc(primes , factors, originalN);
		System.out.println(ret);
	}
}


Measured memory_bytes: 22484
import java.math.BigDecimal;
import java.util.Scanner;

/**
 * 0007:Debt Hell
 * 
 * @author MS14A
 * @version 2015/04/08
 */
public class Main {

    /** 初期借金額：10万円 */
    private static final BigDecimal INITIAL_DEBT = new BigDecimal("100000");

    /** 利子：5% */
    private static final BigDecimal INTEREST_RATE = BigDecimal.valueOf(0.05);

    /** 繰り上げ計算用 */
    private static final BigDecimal DIVISOR = BigDecimal.valueOf(1000);

    /**
     * 某国に住んでいる友達がお金に困って、あるヤミ金融業者から 10 万円の借金をしたまま、<br>
     * 全く返済していないといいます。<br>
     * この業者は、一週間ごとに 5% の利子を借金に加え、さらに借金の 1,000 円未満を切り上げます。<br>
     * n を入力したとき、n 週間後の借金の残高を出力し終了するプログラムを作成して下さい。<br>
     * n は 100 以下とします。
     * 
     * @param args
     */
    public static void main(String[] args) {
        // 標準入力読み取り
        int weeks = getN();

        // n週間後の借金額計算
        calcDebt(weeks);
    }

    /**
     * n週間後の借金額を計算する。
     * 
     * @param weeks
     */
    private static void calcDebt(int weeks) {
        BigDecimal finalDebt = INITIAL_DEBT;

        for (int i = 0; i < weeks; i++) {
            // 利子額計算。1000で割った小数部を繰り上げる。
            BigDecimal interestAmount = finalDebt.multiply(INTEREST_RATE)
                    .divide(DIVISOR, 0, BigDecimal.ROUND_UP);

            // 借金額 = 前週の借金額 + 利子額
            finalDebt = finalDebt.add(interestAmount.multiply(DIVISOR));
        }

        System.out.println(finalDebt);
    }

    /**
     * 標準入力を読み取り、"n"の値を返す。
     * 
     * @return n：入力値
     */
    private static int getN() {
        Scanner scanned = new Scanner(System.in);
        return scanned.nextInt();
    }

}

Measured memory_bytes: 17304
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int keta(int n)
{
    int cnt = 0;
    while (n > 0)
    {
        n /= 10;
        cnt++;
    }
    return cnt;
}

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

    int a, b;
    cin >> a >> b;
    int n = keta(b);
    rep(i, n) a *= 10;
    a += b;
    for (int i = 1;; i++)
    {
        if (i * i == a)
        {
            cout << "Yes" << endl;
            return 0;
        }
        if (i * i > a)
            break;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define maxn 200010
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int a[maxn],b[maxn];
int f[maxn];
int s[maxn],top;
bool check(int x)
{
    for(int i=1;i<=2*n-1;i++)  f[i]=(a[i]>=x);
    f[0]=f[2*n]=-1;
    top=0;
    for(int i=1;i<=2*n-1;i++)
    {
        if(f[i]!=f[i-1]&&f[i]!=f[i+1])  s[++top]=i;
    }
    for(int i=1;i<=top;i++)
    {
        int l=i,r=i;
        while(s[r+1]==s[r]+1&&r<top)  r++;
        i=r;
        l=s[l];r=s[r];
        if(l==1)
        {
            if((r-l+1)&1){
                int a1=f[1],a2=(f[1]^1);
                for(int j=1;j<=(r+1)/2;j++)  f[j]=a1;
                for(int j=(r+1)/2+1;j<=r;j++)    f[j]=a2;
            }
            else{
                int a1=f[1];
                for(int j=1;j<=r;j++)  f[j]=a1;
            }
            continue;
        }
        if(r==2*n-1)
        {
            if((r-l+1)&1){
                int a1=f[2*n-1],a2=(f[2*n-1]^1);
                for(int j=2*n-1-(r-l+1)/2;j<=2*n-1;j++)  f[j]=a1;
                for(int j=l;j<=l+(r-l+1)/2-1;j++)    f[j]=a2;  
            }
            else{
                int a1=f[2*n-1];
                for(int j=l;j<=r;j++)  f[j]=a1;
            }
            continue;
        }
        if((r-l+1)&1){
            int a1=(f[l]^1);
            for(int j=l;j<=r;j++)  f[j]=a1;
        }
        else{
            int a1=(f[l]^1),a2=(f[r]^1);
            for(int j=l;j<=l+(r-l+1)/2-1;j++) f[j]=a1;
            for(int j=l+(r-l+1)/2;j<=r;j++)   f[j]=a2;
        }
    }
    return f[n];
}
int ans;
int main()
{
    n=read();
    for(int i=1;i<=2*n-1;i++)   a[i]=read();
    for(int i=1;i<=2*n-1;i++)   b[i]=a[i];
    sort(b+1,b+2*n);
     int l=1,r=2*n-1;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(check(b[mid]))
        {
            l=mid+1;
            ans=mid;
        }
        else  r=mid-1;
    }
    printf("%d\n",b[ans]);
    return 0;
}

Measured memory_bytes: 3328