akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  int a,b,c;

  cin >> a >> b >> c;
  print(a*b/2);
  

 return 0;
}


Measured memory_bytes: 256
N,X = map(int,input().split())

def burger(n):#n次元バーガー出力(使わない)
    if n ==0:
        return "P"
    else:
        return "B" + burger(n-1) + "P" + burger(n-1) + "B"

def burger_size(n):#n次元バーガーのサイズ
    return 4*pow(2,n) - 3

def countP(n,x):#n次元バーガーのx層までのPの数を数えるよ
    if x <= 0:#一つも食わないとき
        return 0
    if burger_size(n)<=x:#全部食ったとき
        return 2*pow(2,n)-1
    else:
        return (1 if 2+burger_size(n-1)<=x else 0)+countP(n-1,x-1)+countP(n-1,x-2-burger_size(n-1))

print(countP(N,X))

Measured memory_bytes: 62092
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll N;
    cin >> N;
    vector<ll> W(N);
    REP(i, N) cin>>W[i];
    vector<ll> CS(N+1);
    for(ll i=0; i<N; i++){
        CS[i+1] = W[i] + CS[i];
    }
    ll res = INF;
    for(ll i=0; i<N; i++){
        res = min(res, abs(CS[i]-CS[0]-(CS[N]-CS[i]) ) );
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
using System;


class helloworld
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int[] a = new int[3];
        for(int i = 0; i < 3; i++)
        {
            a[i] = int.Parse(s[i]);
        }
        Array.Sort(a);
        Console.WriteLine($"{string.Join(" ", a)}");

        

    }
}


Measured memory_bytes: 16024
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z;
    return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n , m , k;
char s;

int main()
{
    _FastIO;

    cin >> s;
    n = char(s);
    if(n <= 90){
        cout << "A" << endl;
    }
    else
        cout << "a" << endl;
    return 0;
}


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

using namespace std;
#define rep(i,n) for(auto i=(n)*0;i<n;i++)
#define range(it,v) for(auto & it:v)


typedef double D;
typedef complex<D> P;
typedef vector<P> Poly;
#define IL inline
#define X real()
#define Y imag()
IL D dot(P a,P b){
    return a.X*b.X+a.Y*b.Y;
}
IL D cross(P a,P b){
    return a.X*b.Y-a.Y*b.X;
}


IL D ccw(P a,P b,P c){
    return cross(b-a,c-a);
}


IL D convex_area(Poly pp){
    D res=0;
    for(int i=2,n=pp.size();i<n;i++)
	res+=abs(ccw(pp[0],pp[i-1],pp[i]))/2,0;
    return res;
}

struct INIT{
    INIT(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed;
	cout<<setprecision(10);
    }
}init;

IL P convex_gravity_point(Poly& pp){
    P g(0,0);
    D s=0;
    for(int i=2,n=pp.size();i<n;i++){
	D t=convex_area({pp[0],pp[i-1],pp[i]});
	g+=t*(pp[0]+pp[i-1]+pp[i])/3.0;
	s+=t;
    }
    return g/s;
}
int main(){
    int N;
    cin>>N;
    Poly p(N);
    rep(i,N){
	double x,y;
	cin>>x>>y;
	p[i]=P(x,y);
    }
    auto g=convex_gravity_point(p);
    if(N&1)cout<<"NA"<<endl;
    else{
	int M=N/2;
	rep(i,M){
	    auto a=p[i]-g,b=g-p[i+M];
	    if(abs(a.X-b.X)>1e-8||abs(a.Y-b.Y)>1e-8){

		cout<<"NA"<<endl;
		return 0;
	    }
	}
	cout<<g.X<<" "<<g.Y<<endl;
    }
    return 0;
}

Measured memory_bytes: 3268
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var x = int.Parse(line[0]);
        var y = int.Parse(line[1]);
        var ans = getPoint(x);
        ans += getPoint(y);
        Console.WriteLine(x == 1 && y == 1 ? ans + 400000 : ans);
    }
    static int getPoint(int a)
    {
        if (a == 1) return 300000;
        if (a == 2) return 200000;
        if (a == 3) return 100000;
        return 0;
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
long long n, r, c, a, pow10[15], ans, dist, b, nazo;
inline long long sart(long long a,long long b){
	if(a%b)return a/b;
	return a/b-1;
}
inline long long zu(long long a,long long b){
	return a/b+1;
}

inline long long qpow(long long a, long long b){
	long long ers=1;
	while(b)
	{
		if(b&1)
			ers=ers*a%1000000007;
		a=a*a%1000000007;
		b>>=1;
	}
	return ers;
}

inline void check(long long len){
	if(len<a) return;
	long long num=n/len, tot=9*qpow(10, len - 1)%1000000007;
	ans=(ans+(tot-num+1)%1000000007)%1000000007;
}
int main()
{
	r=2;
	a=b=nazo=1;
	c=dist=10;
	scanf("%lld",&n);
	pow10[0]=1;
	for(register int i=1; i<=8; ++i) pow10[i]=pow10[i-1]*10;
	if(n>9){
		for(register int i=1; ; ++i){
			if(i==c){
				c*=10;
				a++;
				if(a*pow10[a-1]*9>=n) break;
				
			}
			while(nazo<n){
				if(nazo+b>n) break;
				nazo+=b;
				++r;
				if(!(r^dist)){
					dist*=10;
					
					++b;
				}
			}
			if(!(nazo^n)){
				++ans;
				
				
				
				ans%=1000000007;
				
			}
			nazo-=a;
		}
	}
	for(register int i=1; i*i<=n; ++i){
		if(n%i==0){
			
			check(i);
			
			
			if(i*i!=n) check(n/i);
			
		}
	}
	for(register int i=a; i<=n/2; ++i){
		long long x=sart(n, i), y=zu(n, i+1);
		if(y<=x){
			ans=ans+x-y+1;
			ans%=1000000007;
		}
	}
	printf("%lld\n", (ans+1000000007)%1000000007);// を満たすものの個数を1000000007
	return 0;
}

Measured memory_bytes: 3784
import sys
sys.setrecursionlimit(1000000)

N = int(input())
adj = [[] for n in range(N)]
for i in range(N-1):
  a, b = [int(n)-1 for n in input().split()]
  adj[a].append(b)
  adj[b].append(a)



def dfs(now, cost, dic):
  dic[now] = cost
  for nx in adj[now]:
    if nx not in dic:
      dfs(nx, cost+1, dic)

dist_f = {}
dist_s = {}

dfs(0, 0, dist_f)
dfs(N-1, 0, dist_s)


f_cnt = 0
for  i in range(N):
  if dist_f[i] <= dist_s[i]:
    f_cnt += 1

if f_cnt > N-f_cnt:
  print("Fennec")
else:
  print("Snuke")

Measured memory_bytes: 205256
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

////////////////////////////////////////////////////////////////////////

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val K = sc.next().toInt()
        val V = Array(N) { sc.next().toLong() }
        var ans = 0L
        for (a in 0..arrayOf(N, K).min()!!) {
            for (b in 0..(arrayOf(N, K).min()!! - a)) {
                if (a + b == 0) continue
                val pq = PriorityQueue<Long>()
                pq.addAll(V.take(a))
                pq.addAll(V.drop(N - b))
                var s = pq.sum()
                if (ans < s) ans = s
                repeat(K - (a + b)) {
                    if (pq.isNotEmpty()) {
                        val n = pq.first()
                        pq.remove(n)
                        s -= n
                        if (ans < s) ans = s
                    }
                }
            }
        }
        pw.println(ans)
    }
}


Measured memory_bytes: 40400
import sys
from collections import Counter
try:
    from scipy.special import comb
except ImportError:
    from scipy.misc import comb

def main():
    input = sys.stdin.readline
    N, A, B = map(int, input().split())
    V = list(map(int, input().split()))
    V = sorted(V, key=lambda x: -x)

    m_ave = sum(V[:A]) / A
    b = A
    while b < B:
        if V[0] == V[b]:
            b += 1
        else:
            break

    if A == b:
        ans = 1
        c = Counter(V[:A])
        d = Counter(V)
        for key in c.keys():
            n = d[key]
            r = c[key]
            ans *= comb(n, r, exact=True)

    else:
        d = Counter(V)
        key = V[0]
        n = d[key]
        ans = 0
        for r in range(A, b+1):
            ans += comb(n, r, exact=True)

    print(m_ave)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14312
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

int main() {
    int a, b;
    cin >> a >> b;
    int s = 0;
    vector<int> h(b,0);
    REP(i,a) {
        int t = 0;
        REP(j,b) {
            int k;
            cin >> k;
            cout << k << " ";
            t += k;
            h[j] += k;
        }
        cout << t << endl;
        s += t;
    }
    REP(i,b) {
        cout << h[i] << " ";
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <stdlib.h>

#define INF 1000000001

int main() {
	int n, x, k;
	long long ans;

	scanf("%d", &n);
	x = INF;
	ans = k = 0;
	while (n--) {
		int a;

		scanf("%d", &a);
		if (a <= 0)
			k++;
		a = abs(a);
		ans += a;
		if (x > a)
			x = a;
	}
	printf("%lld\n", k % 2 == 0 ? ans : ans - x * 2);
	return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const int INF=1e9;


int main()
{
    int n;
    cin>>n;
    int updown=0;
    int pa=-1;
    int ans=0;
    REP(i,n)
    {
        int a;
        cin>>a;
        switch(updown)
        {
            case -1:
                if(a-pa>0)
                {
                    updown=0;
                    ans++;
                }
            break;
            case 0:
                if(pa<0)
                {

                }
                else
                {
                    if(a-pa<0)
                        updown=-1;
                    else if(a-pa>0)
                        updown=1;
                }
            break;
            case 1:
                if(a-pa<0)
                {
                    updown=0;
                    ans++;
                }
            break;
        }
        pa=a;
    }
    cout<<ans+1<<endl;
}



Measured memory_bytes: 256
N = int(input())
L = []
S = 0
K = 0
for i in range(N):
  L.append(int(input()))
L.sort()
if N == 2:
  print(abs(L[0]-L[1]))
elif N == 3:
  print(max(abs(L[2]+L[1]-2*L[0]),abs(2*L[2]-L[1]-L[0])))
elif N == 4:
  print(abs(2*L[3]+L[2]-L[1]-2*L[0]))
elif N%2 == 0:
  for i in range((N-2)//2):
    S += 2*(L[N-i-1]-L[i])
  S += L[N//2]-L[(N-2)//2]
  print(S)
else:
  for i in range((N-3)//2):
    S += 2*L[N-i-1]
  for j in range(N//2):
    S -= 2*L[j]
  S += L[N//2]+L[N//2+1]
  for k in range(N//2):
    K += L[N-k-1]*2
  for m in range((N-3)//2):
    K -= 2*L[m]
  K -= (L[N//2]+L[N//2-1])
  print(max(S,K))

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    string A, B, C;
    cin >> A >> B >> C;
    int a = 0, b = 0, c = 0;
    char n = 'a';

    while (1) {
        if (n == 'a') {
            n = A[a];
            a++;
        } else if (n == 'b') {
            n = B[b];
            b++;
        } else {
            n = C[c];
            c++;
        }

        if (a > A.size()) {
            cout << 'A' << endl;
            return 0;
        }
        if (b > B.size()) {
            cout << 'B' << endl;
            return 0;
        }
        if (c > C.size()) {
            cout << 'C' << endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;
  
int main(){
    int x,y,z;
    cin>>x>>y>>z;


      int t;
      t=x;
      x=y;
      y=t;
      int w;
      w=x;
      x=z;
      z=w;

      cout<<x<<" "<<y<<" "<<z;



}

Measured memory_bytes: 256
package main

import (
    "fmt"
)

func main() {
    var b []byte
    fmt.Scan(&b)
    switch b[0] {
    case 'A':
        fmt.Println("T")
    case 'T':
        fmt.Println("A")
    case 'C':
        fmt.Println("G")
    case 'G':
        fmt.Println("C")
    }   
}


Measured memory_bytes: 512
#include <iostream>

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

using namespace std;



int main() {
    string s;
    cin >> s;
    int ans = 0;
    int n = s.size();
    rep(i,(n+1)/2) {
        if(s[i] != s[n-1-i]) { ans++;}
    }
    cout << ans << endl;

    return 0;
}


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

#define watch(x) cout<<#x<<" -> "<<x<<endl
#define ALL(x) x.begin() , x.end()
#define INF 100000
typedef long long ll;
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
        long long a , b, c;
        cin>>a>>b>>c;
        if (b * c>=a){
            cout<<"Yes"<<endl;
            return 0;
        }
        cout<<"No"<<endl;
}

Measured memory_bytes: 3652
s,t=input(),input()
S,T=len(s),len(t)
dp=[[0]*(T+1) for _ in range(S+1)]
for i in range(1,S+1):
    for j in range(1,T+1):
        if s[i-1]==t[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])

i,j=S,T
ans=''
while min(i,j)>0:
        if dp[i][j]==dp[i][j-1]:
            j-=1
        elif dp[i][j]==dp[i-1][j]:
            i-=1
        else:
            ans+=s[i-1]
            i-=1 ; j-=1
print(ans[::-1])

Measured memory_bytes: 112476
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
vint primes;
vll div(ll N)
{
    vll yakusuu;
    for (ll i = 1; i * i <= N; i++)
    {
        if (N % i == 0)
        {
            yakusuu.push_back(i);
            if (i * i != N)
                yakusuu.push_back(N / i);
        }
    }
    return yakusuu;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vint A(N);
    set<int> s;
    vint cnt(1e6+1);
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
        s.insert(A[i]);
        cnt[A[i]]++;
    }
    int ans = N;
    for (size_t i = 0; i < A.size(); i++)
    {
        if(cnt[A[i]]>=2)
        {
            ans--;
            continue;
        }
        auto divs = div(A[i]);
        for (auto &&j : divs)
        {
            if(j != A[i] and s.count(j) == 1)
            {
                ans--;
                break;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 17124
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clz(x) - 1;	}


//Variables Declaration
int N ;
std::vector<int> stones;

int dp[(int)1e5+10];

int solve(int n ){

	if(dp[n]>=0) return dp[n];
	int ans = 0;
	if(n-1 >= 1){
		ans = 	abs(stones[n]-stones[n-1]) + solve(n-1);
	}
	if(n-2 >= 1){
		ans =	min(ans, abs(stones[n]-stones[n-2]) + solve(n-2));
	}

	return dp[n] = ans ;
}

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

	memset(dp,-1,sizeof(dp));
 	cin >> N ;
 	stones.resize(N+1);

 	for(int i = 1 ; i <= N ; ++i){
 		cin >> stones[i];
 	}
/*
 	dp[1]=0;	
 	for(int i = 2 ; i <= N ; ++i){
 		int ans = abs(stones[i] - stones[i-1]) + dp[i-1];
 		if(i>2){
 			ans = min(ans, abs(stones[i] - stones[i-2]) ) + dp[i-2];
 		}
 		dp[i]  = ans;
 	}*/

// 	cout << dp[N] << endl;
 	cout << solve(N) << endl;
 	




	return 0;
}


Measured memory_bytes: 5760
import itertools
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
i=0
for x in itertools.permutations(range(1,n+1)):
    i+=1
    if list(x) == a:
        a=i
    if list(x) == b:
        b=i
print(abs(a-b))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <limits>
#include <queue>
#include <map>
using namespace std;

#define rip(i,n,s) (int i=(s);i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
long long mod = 1000000007;

long long powr(long long n, long long p, long long k) {//n^k(mod p)
	if (k != 0) {
		if (p % 2 == 0) {
			long long x = powr(n, p, k / 2);
			return (long long)x*x%p;
		}
		else {
			long long x = powr(n, p, k - 1);
			return (long long)x*n%p;
		}
	}
	return 1;
}

long long rev(long long n, long long p) {//nの逆元
	return powr(n, p, p - 2);
}

long long bino(long long n, long long m, long long p) {//nCm(mod p)
	long long me = 1;
	long long ans = 1;
	for (int i = 0;i < n + m;i++) {
		me = (long long)(i + 1) * ans % p;
		if (i == m - 1) {
			ans = (long long)rev(me, p) * ans%p;
		}
		if (i == m - n - 1) {
			ans = (long long)(rev(me, p))*ans%p;
		}
	}
	ans = (long long)(ans*me%p);
	return ans;
}

struct modint {
	long long num;
	long long p;
	modint() {
		num = 0;
		p = 1000000007;
	}
	modint(int x) {
		num = (long long)x%p;
		p = 1000000007;
	}
	modint operator+(const modint &other) {
		modint ret;
		ret.p = p;
		ret.num = (num + other.num) % p;
		return ret;
	}
	modint operator+(const long long &other) {
		modint ret;
		ret.p = p;
		ret.num = (num + (other%p)) % p;
		return ret;
	}
	modint operator-(const modint &other) {
		modint ret;
		ret.p = p;
		ret.num = (num - other.num + p) % p;
		return ret;
	}
	modint operator-(const long long &other) {
		modint ret;
		ret.p = p;
		ret.num = (num - (other%p) + p) % p;
		return ret;
	}
	modint operator*(const modint &other) {
		modint ret;
		ret.p = p;
		ret.num = (num*other.num) % p;
		return ret;
	}
	modint operator*(const long long &other) {
		modint ret;
		ret.p = p;
		ret.num = (num*(other%p)) % p;
		return ret;
	}
	modint operator/(const modint &other) {
		modint ret;
		ret.p = p;
		ret.num = (num*rev(other.num, p)) % p;
		return ret;
	}
	modint operator/(const long long &other) {
		modint ret;
		ret.p = p;
		ret.num = (num*rev(other%p, p)) % p;
		return ret;
	}
};

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	long long mad=1;
	for rip(i, n, 0) {
		mad = mad * (i + 1) % mod;
	}
	vector<bool> da(n * 2);
	for rip(i, n * 2, 0) {
		da[i] = (s[i] == 'B');
	}
	vector <bool> dir(n * 2);
	dir[0] = da[0];
	for rip(i, n * 2, 1) {
		dir[i] = !(da[i] ^ da[i - 1] ^ dir[i-1]);
	}
	long long co = 0;
	long long ans=1;
	for (int i = n * 2 - 1;i > -1;i--) {
		if (!dir[i]) {
			co++;
		}
		else {
			ans = (ans * co)%mod;
			co--;
		}
	}
	ans = (ans * mad)%mod;
	if (co==0) {
		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}
}

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

using pint = pair<int,int>;
typedef long long ll;

ll H, W, K;
vector<string> v(6);

int main() {
    cin >> H >> W >> K;
    for(ll i = 0; i < H; i++) {
        cin >> v.at(i);
    }

    int res = 0;
    for (int h = 0; h < (1<<H); ++h) {
        for (int w = 0; w < (1<<W); ++w) {
            ll count = 0;
            for(ll i = 0; i < H; i++) {
                if( h & (1 << i)) continue;
                for(ll j = 0; j < W; j++) {
                    if( w & (1 << j)) continue;
                    if( v.at(i)[j] == '#') count++;
                }
            }
            if (count == K) res++;
        }
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 3564
#include <iostream>

int main () {
  int h, w;
  while(std::cin >> h >> w) {
    if (h == 0 && w == 0)
      break;
    for (int i = 0; i < h; i++)
    {
      for (int j = 0; j < w; j++)
      {
        if (i > 0 && i < h - 1) {
          if (j > 0 && j < w - 1) {
            std::cout << ".";
          } else {
            std::cout << "#";
          }
        } else {
          std::cout << "#";
        }
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
  return 0;
}


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

std::vector<int> enum_div(int n)//nの約数を列挙
{
	std::vector<int> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
long long a[500000];
int ac;
int main(void){
	long long N;
	cin >> N;
	for(long long i=1;i*i<=N;i++){
		if(N%i==0){
			a[ac]=i;
			ac++;
			if(i*i!=N){
				a[ac]=(N/i);
				ac++;
			}
		}
	}
	sort(a,a+ac);
	long long ans =0;
	for(int i=ac-1;i>=1;i--){
		if(a[i]-1 == 0 )continue;
		if(N%(a[i]-1)==N/(a[i]-1)){
			ans+=a[i]-1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
    char a,b;
    cin >> a >> b;
    if(a=='H' && b=='H' || a=='D' && b=='D'){
        cout << "H" << endl;
    }else{
        cout << "D" << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll mod = 1000000007;
const ll INF = 1ll << 50;


ll d,g;
ll p[10];
ll c[10];
ll ans = INF;

void solve(ll x){
  ll mem = 0;
  ll score = 0;
  for(ll i = 1,j = 0;i < (1 << d);i <<= 1,j++){
    if((x&i) != 0){
      mem += p[j];
      score += p[j]*100*(j+1)+c[j];
    }
  }
  for(ll i = (1 << (d-1)),j = d-1;i > 0;i >>= 1,j--){
    if((x&i) == 0){
      for(ll k = 0;k < p[j];k++){
        if(score < g){
          mem += 1;
          score += (j+1)*100;
        }else{
          break;
        }
      }
    }
  }
  if(score >= g){
    ans = min(ans,mem);
  }
}

int main(){
  cin >> d >> g;
  for(ll i = 0;i < d;i++){
    cin >> p[i] >> c[i];
  }
  for(ll i = 0;i < (1 << d);i++){
    solve(i);
  }
  cout << ans << endl;
}


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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

//========================================================================//

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int cnt = n;
	Loop1(i, n - 1) {
		if (s[i] == s[i - 1]) {
			cnt--;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 512
#from collections import Counter

#import numpy as np

input = raw_input
n = int(input())
#nums = np.zeros(2001, dtype=int)
nums = [0] * 2001
#nums = np.zeros(2001, dtype=int)

ls = map(int, input().split(" "))
#ls = Counter(map(int, ls))
#vals = ls.keys()
ls = sorted(ls)
for l in ls:
    #print(l)
    nums[l] += 1

set_vals = [val for val in range(2001) if nums[val] >= 1]
#print(vals)

#cumsum = np.cumsum(nums)

#print(set_vals)
len_set = len(set_vals)
out = 0
for i in range(len_set):
    val1 = set_vals[i]
    num_i = nums[val1]
    if num_i >= 3:
        out += (num_i * (num_i-1) * (num_i-2) // 6)
    
    if num_i >= 2:
        val2 = set_vals[i]
        for j in range(i+1, len_set):
            val3 = set_vals[j]
            num_h = nums[val3]
            if 2 * val1 <= val3:
                break

            out += ((num_i * (num_i-1)) // 2) * num_h

    for j in range(i+1, len_set):
        val2 = set_vals[j]
        num_j = nums[val2]

        if num_j >= 2:
            out += (num_i *  num_j * (num_j - 1) // 2 )

        for h in range(j+1, len_set):
            val3 = set_vals[h]
            #print(val1, val2, val3)
            num_h = nums[val3]
            if val1 + val2 <= val3:
                break

            #print("num", num_i, num_j, num_h)
            out += (num_i * num_j * num_h)

print(out)

Measured memory_bytes: 33640
#include<stdio.h>
#include<memory.h>
int main(){
	int n;
	int i,j,a[110][110]={0};
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				scanf("%d",&a[i][j]);
				a[i][n+1]+=a[i][j];
				a[n+1][j]+=a[i][j];
			}
		}
		for(j=1;j<=n;j++){
			a[n+1][n+1]+=a[n+1][j];
		}
		for(i=1;i<=n+1;i++){
			for(j=1;j<=n+1;j++){
				printf("%5d",a[i][j]);
			}
			printf("\n");
		}
		memset(a,0,sizeof(a));
	}
	return 0;
}

Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;

int main(){
    int N, X;
    while(cin >> N >> X, N != 0){
        int ans = 0;
        for(int i = 1; i <= N; i++){
            for(int j = i+1; j + i <= X && j <= N; j++){
                int k = X - i - j;
                if(i < k && j < k && k <= N) ans++;
            }
        }
        cout << ans << endl;
    }
}


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

int main(){
  string s;
  cin >> s;
  int gap=0;
  int n=s.size();
  for(int i=0;i<n-1;i++){
    if(s[i]!=s[i+1]){
      gap++;
    }
  }
  cout << gap << endl;
}

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

int main(){
	string a,b;
	int c,d;
	string e;
    
    cin >>a>>b>>c>>d>>e;
    if(a==e)cout<<c-1<<' '<<d<<endl;
    else cout<<c<<' '<<d-1<<endl;

}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc() {
        int pointCount = int.Parse(Reader.ReadLine());
        this.Timestamp = new int[pointCount][];
        for (int i = 0; i < pointCount; i++) {
            int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a) - 1).Skip(2).ToArray();
            if(inpt.Length > 0) {
                Path.Add(i, inpt.ToList());
            }
        }
        int stamp = 1;
        while(Timestamp.Any(a=>a==null)) {
            int idx = Timestamp.ToList().IndexOf(null);
            stamp = this.SetStamp(idx, stamp) + 1;
		}
        for (int i = 0; i < pointCount; i++) {
            Console.WriteLine((i+1) + " " + Timestamp[i][0] + " " + Timestamp[i][1]);
        }
    }

    private int SetStamp(int pos, int tm) {
        Timestamp[pos] = new int[2];
        Timestamp[pos][0] = tm;
        int subTm = tm + 1;
        if(Path.ContainsKey(pos)) {
            Path[pos].ForEach(a =>
            {
                if (Timestamp[a] == null)
                {
                    subTm = SetStamp(a, subTm) + 1;
                }
            });
        }
        Timestamp[pos][1] = subTm;
        return subTm;
    }
    private int[][] Timestamp;

    private Dictionary<int, List<int>> Path = new Dictionary<int, List<int>>();



    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine() {
            if(IsDebug) {
                if(sr == null) {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


6
1 2 2 4
2 1 5
3 2 5 6
4 0
5 1 4
6 1 6


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
	}
}

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

int main() {
  long long x;
  cin>>x;
  long long a,b;
  a=0;
  b=0;
  while(a*a*a*a*a-b*b*b*b*b!=x){
    a++;
    b=a-1;
    while(a*a*a*a*a-b*b*b*b*b<=x){
      if(a*a*a*a*a-b*b*b*b*b==x) break;
      else b--;
    }
  }
  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <cmath>



int main(void){
    int n,y;
    std::cin >> n >> y;


    int itiman = 0,gosen = 0,sen = 0;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            bool flag = false;
            int saif = 10000*i + 5000*j;
            if((y-saif)%1000 == 0  && n-(i + j) >= 0 && (y-saif) == 1000*(n-(i+j))){
                flag = true;
            }
            if(flag){
                itiman = i;
                gosen = j;
                sen = n - (i + j);
                std::cout << itiman << " " << gosen << " " << sen;
                return 0;
            }
        }
    }

    std::cout << -1 << " " << -1 << " " << -1;
    return 0;
}


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

#define INF 1e9
vector<double> p, q;

double memo[504][504];
double psum[504];
double qsum[504];

// [l,r)の木を構成した時に含まれる p,qの和
double sum(int l, int r) {
  assert(r > l);
  return psum[r] - psum[l] + qsum[r] - qsum[l - 1];
}

// [l, r)の区間について木にした時のコスト期待値
double dfs(int l, int r) {
  // 1個の時
  if (l + 1 == r) {
    // 今の深さ × p, 次の深さ x q (ダミーノード分)
    return p[l] + 2 * (q[l - 1] + q[l]);
  }
  if (memo[l][r] != -1) return memo[l][r];

  double ret = INF;
  // m を根にする分け方
  for (int m = l; m < r; m++) {
    double root, left, right;
    // 根の分
    root  = p[m];
    // 左部分木
    if (l == m) left  = 2 * q[l - 1];          // 端なのでダミー
    else        left  = dfs(l, m) + sum(l, m); // [l,m)の木の解 + l~mまでの和([l,m)の木の深さを1つ増やす)

    // 右部分木
    if (r - 1 == m) right = 2 * q[r - 1];      // 端なのでダミー
    else            right = dfs(m + 1, r) + sum(m + 1, r);
    
    ret = min(ret, root + left + right);
  }
  return memo[l][r] = ret;
}

int main(void) {
  int n;
  cin >> n;
  p = vector<double>(n + 1);
  q = vector<double>(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> p[i + 1];
    psum[i + 2] += psum[i + 1] + p[i + 1];
  }
  for (int i = 0; i < n + 1; i++) {
    cin >> q[i];
    qsum[i + 1] += qsum[i] + q[i];
  }

  for (int i = 0; i < 502; i++) for (int j = 0; j < 502; j++) {
    memo[i][j] = -1;
  }

  cout << fixed << setprecision(10) << dfs(1, n + 1) << endl;

  return 0;
}


Measured memory_bytes: 5316
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <utility>
#include <set>

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

using namespace std;

int main() {

  int r, c;
  cin >> r >> c;

  vector<vector<int>> sheet(r + 1, vector<int>(c + 1, 0));

  rep(i, r) rep(j, c) cin >> sheet[i][j];

  rep(i, r) {
    sheet[i][c] = accumulate(sheet[i].begin(), sheet[i].end(), 0);
    rep(j, c) {
      sheet[r][j] += sheet[i][j];
    }
  }
  sheet[r][c] = accumulate(sheet[r].begin(), sheet[r].end(), 0);

  rep(i, r + 1) {
    rep(j, c + 1) {
      cout << sheet[i][j];
      cout << (j < c ? " " : "\n");
    }
  }

  return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifdef ONLINE_JUDGE
const int maxn = 1e5+23;
#else
const int maxn = 1e5+23;
#endif
vector<int> g[maxn];
int n,s,t;
int d[2][maxn];

void dfs(int p,int fa,int id,int dep)
{
    d[id][p]=dep;
    for(int i:g[p]){
        if(i==fa) continue;
        dfs(i,p,id,dep+1);
    }
}

int main()
{
    cin>>n>>s>>t;
    for(int i=0,u,v;i<n-1;i++){
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(s,0,0,0);
    dfs(t,0,1,0);
    int ans=0;
    for(int i=1;i<=n;i++){
        if(d[0][i]<d[1][i]) ans=max(ans,d[1][i]-1);
    }
    cout<<ans;
}


Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    auto h=s.substr(0,n/2);
    if(h+h==s)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
namespace AtCoderBeginnerContest152
{
	class Program
	{
		static void Main(string[] args)
		{

			var u = Console.ReadLine();

			var ans = "";

			for (var i = 0; i < u.Length; i++)
			{
				ans += "x";
			}

			System.Console.WriteLine(ans);

		}
	}
}

Measured memory_bytes: 13140
n = int(input())
if n<10:
    print(n)
elif n<100:
    print(9)
elif n<1000:
    print(n-99+9)
elif n<10000:
    print(909)
elif n<100000:
    print(n-9999+909)
elif n==100000:
    print(90909)
    

Measured memory_bytes: 38256
"use strict";
const main = arg => {
  const Nums = arg.split("\n");
  const amount = Nums[0]*1;
  const arr = Nums[1].split(" ").map(x=> x*1).sort((a, b) => a - b);
  let ans = arr[0];
  for(let i = 1;i < amount; i++){
  	ans = (ans + arr[i])/2
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	int N; cin >> N;
	int x; cin >> x;
	vector<int>a(N);
	rep(i, 0, N)cin >> a[i];
	sort(all(a));
	int ans = 0;
	rep(i, 0, N) {
		if (x >= a[i]) {
			if (i != N - 1) {
				x -= a[i];
				++ans;
			}
			else {
				if (x == a[i]) {
					++ans;
				}
			}
		}
		else break;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

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 = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    map<string,int> map;
    map["SUN"] = 7;
    map["MON"] = 6;
    map["TUE"] = 5;
    map["WED"] = 4;
    map["THU"] = 3;
    map["FRI"] = 2;
    map["SAT"] = 1;
    string S;
    cin>>S;
    cout<<map[S]<<endl;
}

Measured memory_bytes: 256
/**
 *      purpose : CODE FESTIVAL 2016 Final
 *      author  : kyomukyomupurin
 *      created : 2018-11-14 16:41:46
**/

#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
#define print(x) cout << (x) << '\n'

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int H, W; cin >> H >> W;
    string S[H][W];
    for (int i = 0; i < H; ++i){
        for (int j = 0; j < W; ++j){
            cin >> S[i][j];
        }
    }

    char a[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

    for (int i = 0; i < H; ++i){
        for (int j = 0; j < W; ++j){
            if (S[i][j] == "snuke"){
                cout << a[j] << i + 1 << '\n'; return 0;
            }
        }
    }
    
    return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  string a,b;
  string res = "No";
  char q;
  cin>>a>>b;
  FOR(i,0,a.size()+1){
    q=a[0];
    a.erase(a.begin());
    a.push_back(q);
    if(a==b) res="Yes";
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int sum;
		int n = scan.nextInt();
		int m = scan.nextInt();
		
		int matrix_A[][] = new int[n][m];
		int Vector_b[] = new int[m];
		int Vector_c[] = new int[n];
		
		for( int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				matrix_A[i][j] = scan.nextInt();
			}
		}
		
		for( int i = 0; i < m; i++) {
			Vector_b[i] = scan.nextInt();
		}
		
		for( int i = 0; i < n; i++) {
			sum = 0;
			for( int j = 0; j < m; j++) {
				sum += matrix_A[i][j] * Vector_b[j];
			}
			Vector_c[i] = sum;
			System.out.println(Vector_c[i]);
		}
		
	}
}



Measured memory_bytes: 40476
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	float x1,y1,x2,y2,x3,y3,r1,r2;
	
	scanf("%f",&x1);
	while(scanf("%f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3)!=EOF){
		calc1(2*(x1-x2),2*(y1-y2),x1*x1-x2*x2+y1*y1-y2*y2,2*(x1-x3),2*(y1-y3),x1*x1-x3*x3+y1*y1-y3*y3,&r1,&r2);
		printf("%.3f %.3f %.3f\n",r1,r2,sqrt( (x1-r1)*(x1-r1)+(y1-r2)*(y1-r2) ));
	}
	//for(i=0;i<=1000000000;i++);
	return 0;
}

int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y){

	if(a*e-b*d==0)
		return 0;
	*x=(c*e-b*f)/(a*e-b*d);
	*y=(a*f-d*c)/(a*e-b*d);
	return 1;
}

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


def main():
    X, Y = map(int, input().split())
    crane = (4*X-Y) / 2
    turtle = (-2*X + Y) / 2
    print("Yes") if crane.is_integer() and crane >= 0 and turtle.is_integer(
    ) and turtle >= 0 else print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val l = List.fill(n, 2)(sc.next)

  val indexedSeq = l.zipWithIndex

  val ans = indexedSeq.sortBy(r => (r._1.head, -r._1.last.toInt))

  ans.foreach(e => println(e._2 + 1))

//  println(ans._1)

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 25400
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

/*int par[100000];

void init(int n){
    for(int i=0; i<n; i++) par[i] = i;
}

int find(int x){
    if(par[x] == x) return x;
    else{
        par[x] = find(par[x]);
        return par[x];
    }
}

int min(int a, int b){
    if(a > b) return b;
    else return a;
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    par[x] = y;
}*/

int main(){

	int N;
	cin >> N;

	int problem[100];
	int answer = 0;

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

	for(int i=1;i<N+1;i++){
		int count =0;
		for(int j=0;j<N;j++){
			if(problem[j] >= i){
				count++;
			}
		}
		if(count >= i){
			answer = i;
		}
	}

	cout << answer << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  int n, q;

  cin >> n >> q;

  vector<vector<int>> to(n);
  vector<ll> ans(n);

  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    --a;--b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  rep(i, q) {
    int p, x;
    cin >> p >> x;
    --p;
    ans[p] += x;
  }

  auto dfs = [&](auto dfs, int v, int p) -> void {
    for(int u : to[v]) if(u != p) {
      ans[u] += ans[v];
      dfs(dfs, u, v);
    }
  };

  dfs(dfs, 0, -1);

  rep(i, n) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 21888
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
int main(){
    int n;
    while(cin>>n,n){
        pii ans=pii(-INF,INF);
        vi v(n+1,0);
        rep(i,n){rep(j,5){int temp;cin>>temp;v[i]+=temp;}ans=pii(max(ans.first,v[i]),min(ans.second,v[i]));}
        cout<<ans.first<<" "<<ans.second<<endl;
        
    }
}

Measured memory_bytes: 3076