akhauriyash/Code-Regression huggingface dataset:
#FiveDishes.py

time = [int(input())for _ in range(5)]
ans = 10000000


def up(n):
	s = list(str(n))
	if s[-1]!="0":
		s[-1] = "0"
		n = int("".join(s))
		n += 10
	return n

time_up = [int(up(time[i])) for i in range(5)]


for i in range(5):
	#print(time_up)
	t = sum(time_up)- time_up[i]
	#print(time[i])
	temp = time[i]+t
	ans = min(ans,temp)
	#print(ans)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;
int dp[110000][3];
int happy[110000][3];
// int dp[110][3];
// int happy[110][3];

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

    for(int i=0; i<N; ++i){
        for(int j=0; j<3; ++j){
            cin >> happy[i][j];
        }
    }
    
    //init
    for(int j=0; j<3; ++j) dp[0][j] = 0;
    
    // i:日数, j:どのタスクを選ぶか, k:前日何を行ったか　
    for(int i=1; i<=N; ++i){
        for(int j=0; j<3; ++j){
            for(int k=0; k<3; ++k){
                if(j!=k){
                    dp[i][k] = max(dp[i][k],dp[i-1][j] + happy[i-1][j]);
                }
            }
        }
    }
    int res;
    res = max(dp[N][0], dp[N][1]);
    res = max(res, dp[N][3]);

    cout << res << endl;
}

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

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

	string s;
	cin >> s;
	int N = s.length();
	int a, b;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'A') {
			a = i;
			break;
		}
	}
	for (int i = N-1; i>0; i--) {
		if (s[i] == 'Z') {
			b = i;
			break;
		}
	}
	cout << b - a + 1;
}

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

int r,c;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
string str[20], ans;
bool f[20][20][16][4];

void func(int y, int x, int cnt, int d){
  if(str[y][x] == '^') d = 2;
  else if(str[y][x] == '>') d = 1;
  else if(str[y][x] == '<') d = 3;
  else if(str[y][x] == 'v') d = 0;
  else if(str[y][x] == '_') d = cnt == 0 ? 1 : 3;
  else if(str[y][x] == '|') d = cnt == 0 ? 0 : 2;
  else if(str[y][x] >= '0' && str[y][x] <= '9') cnt = str[y][x] - '0';
  else if(str[y][x] == '+') cnt = (cnt + 1) % 16;
  else if(str[y][x] == '-') cnt = (cnt + 15) % 16;
  else if(str[y][x] == '@'){
    ans = "YES";
    return;
  } else if(str[y][x] == '?'){
    for(int i=0;i<4;i++){
      if(!f[y][x][cnt][i]){
        f[y][x][cnt][i] = true;
        func((y+dy[i])%r, (x+dx[i])%c, cnt, i);
      }
    }
  }

  /*
  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      if(i == y && j == x) cout << cnt;
      else cout << '.';
    }
    cout << endl;
  }
  cout << endl;
  */

  if(!f[y][x][cnt][d]){
    f[y][x][cnt][d] = true;
    func((y+dy[d])%r, (x+dx[d])%c, cnt, d);
  }
}

int main(){
  while(cin >> r >> c){
    for(int i=0;i<r;i++)
      for(int j=0;j<c;j++)
        for(int k=0;k<16;k++)
          for(int l=0;l<4;l++)
            f[i][j][k][l] = false;
    for(int i=0;i<r;i++) cin >> str[i];
    dy[2] = r - 1;
    dx[3] = c - 1;

    ans = "NO";
    func(0,0,0,1);
    cout << ans << endl;
  }
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9 + 7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(1e5+5)

ll dp[101][N];

ll wt[101],val[101];

ll fn(ll item , ll w)
{
    if(item<0)
        return 0;
    if(dp[item][w] != -1)
        return dp[item][w];

    ll ans = fn(item-1,w);
    if(wt[item] <= w)
        ans = max(ans , val[item] + fn(item-1,w-wt[item]));

    dp[item][w] = ans;
    return ans;
}

void solve()
{
    memset(dp,-1,sizeof dp);
    ll n,w;
    cin>>n>>w;

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

    ll ans = fn(n-1,w);
    cout<<ans<<"\n";
}

int main()
{
    fio;
    ll tc = 1;
   // cin>>tc;
    while(tc--)
    {
        solve();
    }
}


Measured memory_bytes: 79232
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

const int N = 2e5 + 10;
int n, P, M, ans;
int a[N], b[N];

bool cmp(int a, int b) {return a%M < b%M;}

int main() {
	int i, x, y1, y2, y3, now;
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d", &a[i]);
	rep(i, 1, n) scanf("%d", &b[i]);
	rep(i, 0, 29) {
		M = 1<<i+1;
		sort(a+1, a+n+1, cmp);
		sort(b+1, b+n+1, cmp);
		int j;
//		rep(j, 1, n) printf("%d ", a[j]); puts("");
//		rep(j, 1, n) printf("%d ", b[j]); puts("");
		
		P = 1<<i; now = 0;
		y1 = y2 = y3 = n;
		for(x = 1; x <= n; ++x) {
			while(y3 && a[x]%M+b[y3]%M >= P*3) --y3;
			while(y2 && a[x]%M+b[y2]%M >= P*2) --y2;
			while(y1 && a[x]%M+b[y1]%M >= P*1) --y1;
			now ^= (n-y3&1) ^ (y2-y1&1);
//			printf("%d %d %d\n", y1, y2, y3);
		}
		if(now) ans += P;
	} 
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main(){
	int ans;
	cin >> ans;
	while(1){
		int num;
		char x;
		cin >> x;
		if(x=='='){
			cout << ans << endl;
			return 0;
		}
		cin >> num;
		if(x=='+')	ans+=num;
		else if(x=='-')	ans-=num;
		else if(x=='*')	ans*=num;
		else ans/=num;
	}
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 200005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

bool vis[N];
int a[N];

void solve(){
    int n, k; cin>>n>>k;
    For(i, 1, n+1){
        cin>>a[i];
    }
    int cur = 1;
    while(!vis[cur]){
        vis[cur]=true;        
        cur = a[cur];
        k--;
        if(k==0){
            cout<<cur;
            return;
        }
    }
    vector<int> vect;
    int ep = cur;
    vect.pb(cur);
    cur = a[cur];
    while(cur!=ep){
        vect.pb(cur);
        cur=a[cur];
    }
    cout<<vect[k%sz(vect)];
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}





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

int main()
{
        ll A;
        ld B;
        cin >> A >> B;
        ll ans = (A * B * 100.0) + 0.4;
        cout << ans / 100 << endl;


}


Measured memory_bytes: 3744
#include<iostream>
#include<string>
#include<vector>


using namespace std;


int main() {

	int n;
	long long cnt = 0;
	cin >> n;

	for (int a = 1; a < 1000; a++) {
		for (int b = a; b <= 1000000; b++) {
			if (a * b >= n)break;
			if (a == b)cnt++;
			else cnt += 2;
		}
	}
	cout << cnt << endl;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  bool flag=false;
  for(int i=0;i<=b;i++){
    if(a*i%b==c){
      flag=true;
      //break;
    }
  }

  cout<<(flag?"YES":"NO")<<endl;
  return 0;

}


Measured memory_bytes: 256
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

A,B,C = MI()

if A == B == C or (A != B and A != C and B != C):
    print("No")
else:
    print("Yes")

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 5000000000000000;
constexpr auto MOD = 1000000007;


int main() {
	int n;
	string s;
	cin >> n >> s;
	
	int ans = 0;
	rep(i, 10)rep(j, 10)rep(k, 10) {

		bool ii = false, jj = false, kk = false;

		rep(h, s.size()) {
			if (!ii && s[h] - '0' == i) {
				ii = true;continue;
			}
			if (ii&&!jj && s[h] - '0' == j) {
				jj = true;continue;
			}
			if (ii && jj && !kk && s[h] - '0' == k) {
				kk = true;break;
			}
		}

		if (kk)ans++;
	}

	cout << ans << endl;
}

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

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

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e18;
const int mod = 1e9+7;
typedef pair<int,int> P;
#define fi first
#define se second

int dp[302][302][302];
int calc(int k, int n){
	int res = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			if(k == 0)res += dp[n][i][j];
			if(k == 1)res += dp[i][n][j];
			if(k == 2)res += dp[i][j][n];
			res %= mod;
		}
	}
	return res;
}

int MAX(int a, int b, int c){
	return max({a, b, c});
}

int MIN(int a, int b, int c){
	return min({a, b, c});
}

signed main(){
	int n, m;
	scanf("%lld%lld", &n, &m);
	vector<vector<P> > v(n+1);
	for(int i = 0;i < m;i++){
		int l, r, x;
		scanf("%lld%lld%lld", &l, &r, &x);
		v[r].push_back(P(l, x));
	}
	
	dp[0][0][0] = 1;
	for(int i = 0;i <= n;i++){
		for(int j = 0;j <= n;j++){
			for(int k = 0;k <= n;k++){
				int r = MAX(i, j, k), l = MIN(i, j, k);
				int mid = (i+j+k)-r-l;
				if(l != 0 && (mid == l || mid == r || l == r))continue;
				for(int p = 0;p < v[r].size();p++){
					P pp = v[r][p];
					if(pp.se == 1){
						if(pp.fi <= mid)dp[i][j][k] = 0;
					}else if(pp.se == 2){
						if(pp.fi <= l)dp[i][j][k] = 0;
						if(pp.fi > mid)dp[i][j][k] = 0;
					}else{
						if(pp.fi > l)dp[i][j][k] = 0;
					}
				}
				dp[r+1][j][k] += dp[i][j][k] %= mod;
				dp[i][r+1][k] += dp[i][j][k] %= mod;
				dp[i][j][r+1] += dp[i][j][k] %= mod;
			}
		}
	}
	
	int ans = 0;
	for(int i = 0;i < 3;i++)ans += calc(i, n);
	printf("%lld\n", ans%mod);
	return 0;
}


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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b == c){
        cout << 1 << endl;
    }else if((a==b && b != c) || (a==c && b != c) || (c==b && a != c)){
        cout << 2 << endl;
    }else{
        cout << 3 << endl;
    }
    return 0;
    
}




Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;
  cin >> n;
  int ans = INF;
  rep(i,n){
    int tmp,count = 0;
    cin >> tmp;
    while(tmp % 2 == 0){
      count++;
      tmp /= 2;
    }
    ans = min(ans,count);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A, B, C, D, E, F := sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()
	dp := make([]bool, F+1)
	dp[0] = true
	for i := 1; i <= F; i++ {
		a, b := false, false
		if A*100 <= i {
			a = dp[i-A*100]
		}
		if B*100 <= i {
			b = dp[i-B*100]
		}
		dp[i] = a || b
	}
	waters := []int{}
	for water, b := range dp {
		if b {
			waters = append(waters, water)
		}
	}
	ansTotal := 100 * A
	ansSuger := 0
	for _, water := range waters {
		restForSuger := min(F-water, E*water/100)
		dp := make([]bool, restForSuger+1)
		dp[0] = true
		max := 0
		for i := 1; i <= restForSuger; i++ {
			c, d := false, false
			if C <= i {
				c = dp[i-C]
			}
			if D <= i {
				d = dp[i-D]
			}
			dp[i] = c || d
			if dp[i] {
				max = i
			}
		}
		if float64(ansSuger)/float64(ansTotal) < float64(max)/(float64(water)+float64(max)) {
			ansSuger = max
			ansTotal = water + max
		}
	}

	fmt.Fprintln(wtr, ansTotal, ansSuger)
	wtr.Flush()
}


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

int main(void) {
    int N,K;cin>>N>>K;
    string S;cin>>S;
    for (int i = 0; i < N; i++) {
        if (i != K - 1) printf("%c", S[i]);
        else printf("%c", S[i] + 'a' - 'A');
    }
    cout << endl;
    return 0;
}

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

int main(){
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned long> p{0};
    copy_n(istream_iterator<unsigned long>(cin), N, back_inserter(p));
    const auto& perm_mul = [](vector<unsigned long>& x, const vector<unsigned long>& p) -> void {
        vector<unsigned long> k(x), r(p);
        transform(k.begin(), k.end(), x.begin(), [&r](auto i){return r[i];});
    };
    vector<unsigned long> r(p.size());
    iota(r.begin(), r.end(), 0UL);
    while(K){
        if(K & 1)perm_mul(r, p);
        perm_mul(p, p);
        K >>= 1;
    }
    cout << r[1] << endl;
    return 0;
}

Measured memory_bytes: 9488
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 100000;
struct node{
	int R, C, A;
	friend bool operator < (node a, node b) {
		return a.A < b.A;
	}
}nd[MAXN + 5];
int fa[2*MAXN + 5], key[2*MAXN + 5], siz[2*MAXN + 5];
int find(int x) {
	return fa[x] = (fa[x] == x ? x : find(fa[x]));
}
int N, H, W;
int main() {
	long long ans = 0;
	scanf("%d%d%d", &N, &H, &W);
	for(int i=1;i<=H;i++) fa[i] = i, siz[i] = 1, key[i] = 0;
	for(int i=1;i<=W;i++) fa[i + H] = i + H, siz[i + H] = 1, key[i + H] = 0;
	for(int i=1;i<=N;i++)
		scanf("%d%d%d", &nd[i].R, &nd[i].C, &nd[i].A);
	sort(nd + 1, nd + N + 1);
	for(int i=N;i>=1;i--) {
		int fx = find(nd[i].R), fy = find(nd[i].C + H);
		if( fx == fy ) {
			if( siz[fx] >= key[fx] + 1 ) {
				key[fx]++;
				ans += nd[i].A;
			}
		}
		else {
			if( siz[fx] + siz[fy] >= key[fx] + key[fy] + 1 ) {
				siz[fx] += siz[fy], key[fx] += key[fy] + 1, fa[fy] = fx;
				ans += nd[i].A;
			}
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4992
import math
import heapq
import sys
import re
from collections import Counter
import datetime
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

#N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

S=input()
T=input()
for i in range(len(S)):
    if S!=T:
        S=S[-1]+S[:-1]
    else:
        print('Yes')
        sys.exit()
        
print('No')
    

Measured memory_bytes: 5204
#include <iostream>
#include <vector>

using namespace std;

long long merge(vector<int> &v, vector<int> &vl, vector<int> &vr) {
  long long count = 0;
  size_t n = v.size();
  size_t i = 0, j = 0, k = 0;
  for (; i < v.size(); ++i) {
    if (j == vl.size()) v[i] = vr[k++];
    else if (k == vr.size()) v[i] = vl[j++];
    else if (vl[j] <= vr[k]) v[i] = vl[j++];
    else {
      v[i] = vr[k++];
      count += n / 2 - j;
    }
  }
  return count;
}

long long mergesort(vector<int> &v) {
  long long count = 0;
  size_t n = v.size();
  if (n > 1) {
    int mid = n / 2;
    vector<int> vl(v.begin(), v.begin() + mid);
    vector<int> vr(v.begin() + mid, v.end());
    count += mergesort(vl);
    count += mergesort(vr);
    count += merge(v, vl, vr);
  }

  return count;
}

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  int n;
  vector<int> a;

  cin >> n;
  a.reserve(n);
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  cout << mergesort(a) << "\n";

  return 0;
}




Measured memory_bytes: 5364
package main

import (
	"fmt"
	"math"
)

func main() {
	var x, a, b float64
	fmt.Scan(&x, &a, &b)

	if math.Abs(x-a) < math.Abs(x-b) {
		fmt.Println("A")
	} else {
		fmt.Println("B")
	}
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define rep(i,n) for(i=0;i<n;i++)
#define PI 3.14159265358979323846264338327950L
int main(){
    int n,i;
    scanf("%d",&n);
    int a[n],cnt[200010]={0};
    for(i=2;i<=n;i++){
        scanf("%d",&a[n]);
        cnt[a[n]]=cnt[a[n]]+1;
    }
    for(i=1;i<=n;i++){
        printf("%d\n",cnt[i]);
    }
    return 0;
}

Measured memory_bytes: 2516
/*
Author :Ashraful Mehmet Fuad
date :23 Jan 2020
TODO --list
Hey What's up Mr . Spy ?
*/
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define input freopen("input.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#include<bits/stdc++.h>
using namespace std;
int tc,cs=1;
typedef long long ll;
const int N=10000+5;
 

class Game{
  private:
  int n,k;
  
  public:
  Game(int n,int k)
  {
    this->n=n;
    this->k=k;
  }

  int solve()
  {
    if(1==this->k)return 0;

    return this->n-this->k;
  }
};

 
int main()
{
  fastio
  // input
  // output
  int n,k;
  cin>>n>>k;
  Game *obj;

  obj=new Game(n,k);

  cout<<obj->solve()<<endl;

  
  
  return 0;
}// end func

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		if(c.equals("a")||c.equals("i")||c.equals("u")||c.equals("e")||c.equals("o")){
			System.out.println("vowel");
		}else{
			System.out.println("consonant");
		}
	}
		
}

Measured memory_bytes: 21844
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=3005;
const double PI=acos(-1.0);
int n;double a[2*MAXN],L;
int main()
{
	n=read();L=read();
	for(int i=1;i<=n;i++)a[i]=read();
	double fx=0,fy=0;
	double frac=6.0/n/(n-1)/(n-2);
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)
	{
		double nq=(a[i]+a[j])/2;
		double qx=cos(2*PI*nq/L),qy=sin(2*PI*nq/L);
		nq+=L/2;
		double px=cos(2*PI*nq/L),py=sin(2*PI*nq/L);
		fx+=qx*frac*(n-j+i-1);fy+=qy*frac*(n-j+i-1);
		fx+=px*frac*(j-i-1);fy+=py*frac*(j-i-1);
	}
	printf("%.9lf %.9lf\n",fx,fy);
	return 0;
}


Measured memory_bytes: 256
#![allow(unused)]

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Self {
        Self { reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get_str(&mut self) -> &str {
        if let Some(t) = self.iter.next() {
            return t;
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get_str()
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        self.get_str().parse().ok().expect("Parse error")
    }
}

fn main() {
    let stdin = std::io::stdin();
    solve(Scanner::new(stdin.lock()));
}

fn solve<R: std::io::BufRead>(mut sc: Scanner<R>) {
    let n: usize = sc.get();
    let m: usize = sc.get();
    let ways: Vec<(usize, usize)> =
        (0..m).map(|_| (sc.get(), sc.get())).collect();

    let mut g = vec![vec![]; n];
    for (u, v) in ways {
        g[u - 1].push(v - 1);
        g[v - 1].push(u - 1);
    }

    let mut parents = vec![None; n];
    let mut q = std::collections::VecDeque::new();
    q.push_back(0);
    parents[0] = Some(0); // dummy to show that this is visited

    while let Some(u) = q.pop_front() {
        for &v in &g[u] {
            if parents[v].is_none() {
                parents[v] = Some(u);
                q.push_back(v);
            }
        }
    }

    if parents.iter().any(|p| p.is_none()) {
        println!("No");
    } else {
        println!("Yes");
        for p in &parents[1..] {
            println!("{}", p.unwrap() + 1);
        }
    }
}


Measured memory_bytes: 13864
#include <bits/stdc++.h>
using namespace std;
const int N = 42;
int n;
string s[N];
typedef long long ll;
ll ans, f[N][N][N], g[N][N][N][N];
ll F(int l, int r, int p);
ll G(int a, int b, int c, int d) {
  if (~g[a][b][c][d]) return g[a][b][c][d];
  ll ret = 0;
  for (int i = a; i <= b; i++) {
    for (int j = c; j <= d; j++) if (s[i][j] == '1') {
      ret += F(a, b, i) * F(c, d, j);
    }
  }
  return g[a][b][c][d] = ret;
}
ll F(int l, int r, int p) {
  if (l == r) return 1;
  if (~f[l][r][p]) return f[l][r][p];
  ll ret = 0;
  for (int i = l + 1; i <= p; i++) {
    for (int j = p; j < r; j++) {
      ret += G(l, i - 1, j + 1, r) * F(i, j, p);
    }
  }
  return f[l][r][p] = ret;
}
int main() {
  memset(f, -1, sizeof f);
  memset(g, -1, sizeof g);
  cin >> n;
  n <<= 1;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int p = 1; p < n; p++) if (s[0][p] == '1') {
    ans += F(1, n - 1, p);
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 25088
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		int W,H,x,y,r;
		Scanner br=new Scanner(System.in);
		W=br.nextInt();
		H=br.nextInt();
		x=br.nextInt();
		y=br.nextInt();
		r=br.nextInt();
		if((r<=x)&&(x<=W-r)&&(r<=y)&&(y<=H-r)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26264
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    ll ans = n*(n-1)/2LL;

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

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

ac_check = [0 for _ in range(n)]
wa_check = [0 for _ in range(n)]

for i in range(m):
    i, judge = input().split()
    i = int(i)-1
    if judge == 'AC':
        if ac_check[i] == 0:
            ac_check[i] = 1

    elif judge == 'WA':
        if ac_check[i] == 0:
            wa_check[i] += 1
wa = 0
for i in range(n):
    if ac_check[i] == 1 and wa_check != 0:
        wa += wa_check[i]

print(sum(ac_check), wa)


Measured memory_bytes: 4760
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void){

int z,i,j,r;

int B,C,N;

int A[100];

r=0;

scanf("%d", &N);

for (i = 0; i < N; i++){

scanf("%d", &A[i]);

}


for (i = 0; i < N; i++){

if(A[i]%2==0){

if((A[i]%3)!=0){

   if((A[i]%5)!=0){

r=r+1;

   }
   
}   

}

}

if(r==0){

printf("APPROVED");


}else{

printf("DENIED");

}



}




Measured memory_bytes: 128
fun main(args: Array<String>) {
    val sl = readLine()!!.split("")
    var max = 0
    var c = 0

    for(i in 0 until sl.size){
        val tmpl = sl.drop(i)
        val count = check(tmpl, c)
        if(max < count){
            max = count
        }
        if(tmpl.size <= max)break
    }
    println(max)
}

fun check(sl: List<String>, c: Int): Int{
    var c0 = c
    if(isACGT(sl.first())){
        c0 += 1
        c0 = check(sl.drop(1), c0)
    }
    return c0
}

fun isACGT(s: String) = when(s){
    "A", "C", "G", "T" -> true
    else -> false
}


Measured memory_bytes: 37572
package main

import (
    "bufio"
    "fmt"
    "os"
)

var r = bufio.NewReader(os.Stdin)

func main() {
    var a, b, c int
    fmt.Fscan(r, &a)
    fmt.Fscan(r, &b)
    fmt.Fscan(r, &c)
    if a <= b && b <= c {
        fmt.Println(a, b, c)
    } else if a <= c && c <= b {
        fmt.Println(a, c, b)
    } else if b <= a && a <= c {
        fmt.Println(b, a, c)
    } else if b <= c && c <= a {
        fmt.Println(b, c, a)
    } else if c <= a && a <= b {
        fmt.Println(c, a, b)
    } else {
        fmt.Println(c, b, a)
    }
}


Measured memory_bytes: 1172
#include <stdio.h>

int main(void){
	int A, B, N, NA;
	
	scanf("%d%d%d", &N, &A ,&B);
	
	NA = A * N;
	
	if(NA >= B){
		printf("%d", B);
	}else{
		printf("%d", NA);
	}
	
	return 0;
}

Measured memory_bytes: 128
#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;
    int pre = 0;
    int sum = 0;
    rep(i,N) {
        int H;
        cin >> H;
        if (pre <= H) sum++;
        pre = max(pre, H);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
from functools import reduce

# 入力
L = input()

MOD = 10**9 + 7


# 最上位ビットから順に、0にする場合と1にする場合の個数を求める
# 最上位ビットが0の場合、直ちに解が求められる（3のべき乗になる）ことに注意
class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(
                pow(self.x, other.x, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    def __radd__(self, other):
        return ModInt(other + self.x)

    def __rsub__(self, other):
        return ModInt(other - self.x)

    def __rmul__(self, other):
        return ModInt(other * self.x)

    def __rtruediv__(self, other):
        return ModInt(other * pow(self.x, MOD - 2, MOD))

    def __rpow__(self, other):
        return ModInt(pow(other, self.x, MOD))


ans = reduce(
    lambda acc, t: (
        ModInt(3)**t[0] + 2 * acc if t[1] == '1' else
        acc
    ),
    enumerate(reversed(L)),
    ModInt(1)
)

# 出力
print(ans)


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

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

  if (N * A < B) {
    cout << N * A << endl;
  }
  else if (N * A > B) {
    cout << B << endl;
  }  
  else if (N * A == B) {
    cout << B << endl;
  }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
const long long mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    double ave = (v[0] + v[1]) / 2;
    for (int i = 2; i < n; i++)
    {
        ave = (ave + v[i]) / 2;
    }
    cout << ave << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int a,b;
	
	scanf("%d",&a);

	scanf("%d",&b);	
	
	if(a < b){
		printf("a < b\n");
	}
	else if(a > b){
		printf("a > b\n");
	}
	else if(a == b){
		printf("a == b\n");
	}
	return 0;
}

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

int main() {
  int a, b; cin >> a >> b;
  int price;
  if (a >= 13) price = b;
  else if (a >= 6 && a <= 12) price = b/2;
  else price = 0;
  
  cout << price << endl;
  
  return 0;
}

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

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library
//

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ab = abs(b - a);
    int bc = abs(b - c);
    int ac = abs(c - a);
    if( ac <= d || (ab <= d && bc <= d)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;



int main(){
    string n;
    cin >> n;
    rep(i, 3){
        if(n[i]=='1') n[i]='9';
        else if(n[i]=='9') n[i]='1';
    }
    cout << n[0] << n[1] << n[2] << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 200200
#define rep(x, a, b) for(int x=a; x<=b; x++)
long long ans;
int f[N<<1], q, n;
struct data{
	int u, v, w;
	bool operator < (const data &rhs) const { return w<rhs.w; }
}e[N<<1];
int fa[N];
int find(int k){
	return fa[k]^k?fa[k]=find(fa[k]):k;
}
int main(){
	scanf("%d%d", &n, &q);
	rep(i, 1, n) f[i]=2e9;
	rep(i, 1, q){ int a, b, c; scanf("%d%d%d", &a, &b, &c); a++, b++; e[i]=(data){a, b, c}; f[a]=min(f[a], c+1), f[b]=min(f[b], c+2); }
	rep(i, 1, n) f[i+n]=f[i];
	rep(i, 1, 2*n-1) f[i+1]=min(f[i+1], f[i]+2);
	rep(i, n+1, 2*n) e[++q]=(data){ i-n, i-n+1, f[i] };
	e[q].v=1;
	sort(e+1, e+q+1);
	rep(i, 1, n) fa[i]=i;
	rep(i, 1, q)
		if(find(e[i].u)!=find(e[i].v)) fa[find(e[i].u)]=find(e[i].v), ans+=e[i].w;
	printf("%lld\n", ans);
}

Measured memory_bytes: 10368
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    
    if(!S.substring(0, 1).equals("A")){
      System.out.println("WA");
    } else if(!S.substring(2, S.length()-1).contains("C")) {
      System.out.println("WA");
    } else  {
      String newS = S.substring(1, S.length()).replaceFirst("C", "c");
      if(!newS.equals(S.substring(1, S.length()).toLowerCase())) {
        System.out.println("WA");
      } else {
        System.out.println("AC");
      }
    } 
  }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
typedef  long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
ll pow1(ll n,ll p)
{
	if(p==0)	return 1;
	ll x=pow1(n, p/2);
	x=(x*x);
	if(p%2==0)
		return x;
	else
		return (x*n);
}
int main()
{
    fast;
   ll t;
   t=1;
   while(t--)
   {
       string s,t,u;
       cin>>s;
       ll n=s.length();
       fr(i,0,n)
       cout<<"x";
       cout<<"\n";
       
   }
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)


int Check(tuple<long, int, int>& ans, vector<tuple<long, int, int, bool>>& hint_collection)
{
	int correct = 0;

	for (const auto& e : hint_collection)
	{
		if (get< 3 >(e))
		{
			if (get< 0 >(e) == 0)
			{
				if (0 < get< 0 >(ans) - abs(get< 1 >(ans) - get< 1 >(e)) - abs(get< 2 >(ans) - get< 2 >(e)))
					break;
			}
			else if (get< 0 >(e) != get< 0 >(ans) - abs(get< 1 >(ans) - get< 1 >(e)) - abs(get< 2 >(ans) - get< 2 >(e)))
				break;

			correct++;
		}
	}

	return correct;
}

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

	vector<tuple<long, int, int, bool>> hint_collection;
	hint_collection.resize(101 * 101);
	loop(x, 101)
	{	// ヒントコンテナの初期化
		loop(y, 101)
		{
			tuple<long, int, int, bool> t = make_tuple(0, x, y, false);
			hint_collection[x * 101 + y] = t;
		}
	}

	loop(i, n)
	{	// ヒントコンテナを作る
		int x; cin >> x;
		int y; cin >> y;
		long h; cin >> h;
		tuple<long, int, int, bool> t = make_tuple(h, x, y, true);
		hint_collection[x * 101 + y] = t;
	}

	tuple<long, int, int, bool> max = make_tuple(-1, 0, 0, false);
	loop(i, 101 * 101)
	{	// ヒントのうち最大の高さを調べる
		if (get< 3 >(hint_collection[i]) && get< 0 >(max) < get< 0 >(hint_collection[i]))
			max = hint_collection[i];
	}

	vector<tuple<long, int, int>> ans_collection;
	ans_collection.resize(101 * 101);
	loop(x, 101)
	{	// 答えを予想するコンテナの作成
		loop(y, 101)
		{
			long h = get< 0 >(max) + abs(x - get< 1 >(max)) + abs(y - get< 2 >(max));
			tuple<long, int, int> t = make_tuple(h, x, y);
			ans_collection[x * 101 + y] = t;
		}
	}

	loop(x, 101)
	{	// 予想したコンテナから答えを探す
		loop(y, 101)
		{
			if (Check(ans_collection[x * 101 + y], hint_collection) == n)
			{
				cout << get< 1 >(ans_collection[x * 101 + y]) << " " << get< 2 >(ans_collection[x * 101 + y]) << " " << get< 0 >(ans_collection[x * 101 + y]);
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int N = sc.nextInt();
		for (int i=0;i<N;i++ ) {
			int temp = sc.nextInt();
			H -=temp;
			if (H<=0) {
				System.out.println("Yes");
				return ;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 58308
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}//ちいさい順
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);


int main (void)
{
	int n,count=0;
	char s[210000],t[210000];
	scanf("%s%s",s,t);
	n=W_Length(s);
	for(int i=0; i<n;i++){
if(s[i]!=t[i]){
count++;
  }
	}


printf("%d\n",count);
return 0;
}


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

int main() { 
  int n, m, k, s_, ans = 0;
  cin >> n >> m;
  int s[m] = {0}, p[m] = {0};
  for(int i = 0; i < m; ++i) {
    cin >> k;
    for(int j = 0; j < k; ++j) {
      cin >> s_;
      s[i] += pow(2, s_-1);
    }
  }
  for(int i = 0; i < m; ++i) {
    cin >> p[i];
  }

  for(int j = 0; j < (1<<n); ++j) {
    int cm = 0;

    for(int i = 0; i < m; ++i) {
      int bit = j & s[i];
      int on = 0;

      while(bit) {
        if(bit%2 == 1) on++;
        bit >>= 1;
      }

      if(p[i] == on%2) {
        cm++;
      } else {
        break;
      }
    }

    if(cm == m) {
      ans++;
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

int main(){

	int n,buf;
	vector <int> a;

	cin >> n;

	for (int i = 0; i < n; i++){
		cin >> buf;
		a.push_back(buf);
	}

	for (int i = n - 1; i > 0; i--){
		cout << a[i] << " ";
	}
	cout << a[0] << endl;


	return 0;
}

Measured memory_bytes: 1216
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
if x == sum(a):
    ans = n
elif x > sum(a):
    ans = n-1
else:
    for i in range(n):
        if x - a[i] >= 0:
            x -= a[i]
            ans += 1
        else:
            break
print(ans)

Measured memory_bytes: 3064
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

#define sint(x) int x; scanf("%d",&x);
#define sint2(x,y) int x,y; scanf("%d %d",&x,&y);
#define lint(x) long long x; scanf("%lld",&x);
#define vint(v,n) vector<int> v(n); rep(i,n) scanf("%d", &v[i]);
#define vlint(v,n) vector<lint> v(n); rep(i,n) scanf("%lld", &v[i]);
#define sdouble(x) double x; scanf("%lf",&x);
#define vdouble(v,n) vector<double> v(n); rep(i,n) scanf("%lf", &v[i]);
#define schar(x) char x; scanf(" %c", &x);
#define sstring(x) string x; cin >> x;

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <climits>
using namespace std;



int main(int argc, char** argv) {
	sint(N);
	vint(a, 3 * N);

	vector<int> left(N), right(2 * N);
	copy(a.begin(), a.begin() + N, left.begin());
	copy(a.begin() + N, a.end(), right.begin());
	sort(all(left));
	sort(all(right));

	ll leftSum = accumulate(all(left), (ll)0);
	ll rightSum = accumulate(right.begin(), right.begin() + N, (ll)0);
	ll max = leftSum - rightSum;
	int leftOffset = 0;
	int rightOffset = 0;
	rep(i, N) {
		int m = a[N + i];
		if (m > left[leftOffset]) {
			leftSum = leftSum - left[leftOffset] + m;
			left.insert(lower_bound(left.begin() + leftOffset, left.end(), m), m);
			leftOffset++;
		}
		if (m < right[N + rightOffset]) {
			rightSum = rightSum - m + right[N + rightOffset];
			rightOffset++;
		}
		else {
			right.erase(lower_bound(right.begin() + N + rightOffset, right.end(), m));
		}
		ll score = leftSum - rightSum;
		if (max < score) {
			max = score;
		}
	}
	printf("%lld\n", max);
}

Measured memory_bytes: 2944
N, M = map(int, input().split())
H = list(map(int, input().split()))
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
ans = 0
for i in range(N):
    for v in G[i]:
        if H[i] <= H[v]:
            break
    else:
        ans += 1
print(ans)


Measured memory_bytes: 92764
# https://atcoder.jp/contests/jsc2019-qual/tasks/jsc2019_qual_b

# Aに対する転倒数はすぐ求まる
# Aが繰り返されたときに転倒数はどのように増えるのか？
# Aのn_invは少なくとも*Kされる
# 繰り返しの分で増えるものは(K-1)K/2倍される
# 繰り返しの分はどうやって求める？→2倍にしたAに対して n_inv_2A-2n_invすればよい

import sys
read = sys.stdin.readline
ra = range
enu = enumerate
MOD = 10**9 + 7


def read_ints():
    return list(map(int, read().split()))


def ret_n_inv(ls):
    n_inv = 0
    N = len(ls)
    for i in ra(N):
        for j in ra(i + 1, N):
            if ls[i] > ls[j]:
                n_inv += 1
    return n_inv


N, K = read_ints()
A = read_ints()

# 愚直に転倒数を求める
n_A = ret_n_inv(A)
if K == 1:
    print(n_A)
    exit()
n_2A = ret_n_inv(A + A)
mul = (K - 1) * K // 2 % MOD
n_skip = (n_2A - 2 * n_A) * mul % MOD
print((n_A * K + n_skip) % MOD)


Measured memory_bytes: 41580
#include <iostream>
#include <cmath>
#include <math.h>
#include <cstring>
#define ll long long 
using namespace std;
ll dp[51][51][101];
int arr[51];
ll solve (int cura,int curb,int rem)
{
	
	if(rem<=0||cura>curb)return 0;
	if(dp[cura][curb][rem]!=-1)return dp[cura][curb][rem];
	ll x= solve(cura,curb,rem-1);
	x=max(x,max(solve(cura+1,curb,rem-1)+arr[cura],solve(cura+1,curb,rem-2)));
	x=max(x,max(solve(cura,curb-1,rem-1)+arr[curb],solve(cura,curb-1,rem-2)));
	return dp[cura][curb] [rem]=x;
}
int main()
{
int n,k;
cin>>n>>k;
for(int i=0;i<n;i++)
{
	cin>>arr[i];
}
memset(dp,-1,sizeof(dp));
cout<<solve(0,n-1,k);
    return 0;
}

Measured memory_bytes: 5696
# ABC087D
# https://atcoder.jp/contests/abc087/tasks/arc090_b

def Find(x, par, diff_weight):
    if par[x] < 0:
        return x
    else:
        px = Find(par[x], par, diff_weight)
        diff_weight[x] += diff_weight[par[x]]
        par[x] = px
        return px

def Unite(x, y, par, rank, diff_weight, w):
    w += diff_weight[x] - diff_weight[y]
    x = Find(x, par, diff_weight)
    y = Find(y, par, diff_weight)

    if x != y:
        if rank[x] < rank[y]:
            x, y =  y, x
            w = -w
        if rank[x] == rank[y]:
            rank[x] += 1
        par[x] += par[y]
        par[y] = x
        diff_weight[y] = w

def Same(x, y, par, diff_weight):
    return Find(x, par,diff_weight) == Find(y, par, diff_weight)

def Size(x, par, diff_weight):
    return -par[Find(x, par, diff_weight)]

def Weight(x, par, diff_weight):
    Find(x, par, diff_weight)
    return diff_weight[x]

def Diff(x, y, par, diff_weight):
    return Weight(y, par, diff_weight)  - Weight(x, par, diff_weight)

import sys
input = sys.stdin.readline

n, m = map(int, input().split())

par = [-1]*n
rank = [0]*n
diff_weight = [0]*n
for i in range(m):
    l, r, d = map(int, input().split())
    l, r = l-1 ,r-1
    if not Same(l, r, par, diff_weight):
        Unite(l, r, par, rank, diff_weight, d)
    else:
        if d != Diff(l, r, par, diff_weight):
            print('No')
            exit()
print('Yes')


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

using namespace std;

int a[100100];


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

    int a,c;
    while(cin>>a>>c&&a&&c)
    {
        for(int i=0;i<a;i++)
            {
                for(int j=0;j<c;j++)
            cout<<"#";
        cout<<endl;

            }
            cout<<endl;

    }
}



Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		
		
		String str;
		String x=br.readLine();
		int count=0;
		for(;!((str=br.readLine()).equals("END_OF_TEXT"));){
			String[] stg=str.split(" ");
			for(String i:stg){
				if(i.equalsIgnoreCase(x))count++;
			}
		}System.out.println(count);
		}
		
		}

Measured memory_bytes: 16916
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> w(n);
    int right = 0;
    int left = 0;

    rep(i,n){
        cin >> w[i];
        right += w[i];

    }

    int ans = right;

    rep(i,n){
        right -= w[i];
        left += w[i];
        ans = min(ans,abs(left-right));
        if(left > right) break;
    }

    dunk(ans);
}

Measured memory_bytes: 256
#include <numeric> /* gcd, lcm, partial_sum, reduce*/
#include <iostream>

long long lcm(long long a, long long b){
  long long x = a*b;
  if(a<b){
    long long t=a;
    a=b;
    b=t;
  }
  long long r=a%b;
  for(long long r=a%b; r; r=a%b){
    a=b;
    b=r;
  }
  return x/b;
}

int main(){
  long long a, b, x;
  std::cin >> a >> b;
  x = a*b;
  std::cout << lcm(a,b) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <cstdio>
#include <math.h>
#include <utility>
#include <list>
#include <functional>
using namespace std;

#define ll long long
#define vecint vector<int>
#define Pii pair<int, int>

#define REP(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define print(a) cout << a << endl

#define MOD 1000000007
#define NIL -1

int main(){
  vector<string> v;
  int N,L;

  cin>>N>>L;
  rep(i,N){
    string x;
    cin>>x;
    v.push_back(x);
  }
  sort(v.begin(),v.end());
  rep(i,N){
    cout<<v[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256