akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int V;
	Pair[] es;
	void Solve()
	{
		var I = G;
		V = I[0]; var E = I[1] + V - 1;
		es = new Pair[E];
		for (var e = 0; e < E; e++) { I = G; es[e] = new Pair(I[0] - 1, I[1] - 1); }
		TopologicalSort();
		var rev = new Dictionary<int, int>();
		for (var i = 0; i < V; i++) rev[topo[i]] = i;
		var par = new int[V];
		for (var i = 0; i < V; i++) par[i] = -1;
		foreach (var e in es) par[e.Y] = Max(par[e.Y], rev[e.X]);
		for (var i = 0; i < V; i++) WriteLine(par[i] < 0 ? 0 : topo[par[i]] + 1);
	}
	List<int> topo = new List<int>();
	void TopologicalSort()
	{
		topo.Clear();
		var s = new Queue<int>();
		var g = new List<int>[V];
		var rg = new int[V];
		for (var i = 0; i < V; i++) g[i] = new List<int>();
		foreach (var e in es) { g[e.X].Add(e.Y); rg[e.Y]++; }
		for (var i = 0; i < V; i++) if (rg[i] == 0) s.Enqueue(i);
		while (s.Count > 0)
		{
			var n = s.Dequeue();
			topo.Add(n);
			foreach (var m in g[n]) if (--rg[m] == 0) s.Enqueue(m);
		}
	}
}
struct Pair
{
	public readonly int X, Y;
	public Pair(int x, int y) { X = x; Y = y; }
}

Measured memory_bytes: 36340
program ABC173D
    implicit none
    integer(8)::N,i,ans=0
    integer(8),allocatable,dimension(:)::A
    read*,N
    allocate(A(N))
    read*,A
    call heapsort(N,A)
    do i=1,N-1
        ans=ans+A(N-i/2)
    end do

    print'(i0)',ans
end program ABC173D

subroutine heapsort(n,array)
    implicit none
    integer(8),intent(in) :: n
    integer(8),intent(inout) :: array(1:n)
   
    integer(8) ::i,k,j,l
    integer(8) :: t
   
    if(n.eq.1)return
  
    l=n/2+1
    k=n
    do while(k.ne.1)
       if(l.gt.1)then
          l=l-1
          t=array(L)
       else
          t=array(k)
          array(k)=array(1)
          k=k-1
          if(k.eq.1) then
             array(1)=t
             exit
          endif
       endif
       i=l
       j=l+l
       do while(j.le.k)
          if(j.lt.k)then
             if(array(j).lt.array(j+1))j=j+1
          endif
          if (t.lt.array(j))then
             array(i)=array(j)
             i=j
             j=j+j
          else
             j=k+1
          endif
       enddo
       array(i)=t
    enddo
  
    return
end subroutine heapsort

Measured memory_bytes: 4616
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            Console.WriteLine(2 * N / Gcd(N, 2));
        }

        static int Gcd(int a, int b)
        {
            if (a < b) Gcd(b, a);
            if (b == 0) return a;
            return Gcd(b, a % b);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;


int main()
{
    int n;
    cin>>n;
    map<int,int>mp;
    ll sum=0;
    rep(i,n){
        int a;
        cin>>a;
        mp[a]++;
        sum+=a;
    }
    int Q;
    cin>>Q;
    vector<ll>ans(Q);
    rep(i,Q){
        int b,c;
        cin>>b>>c;
        sum-=(ll)b*mp[b];
        sum+=(ll)c*mp[b];
        mp[c] += mp[b];
        mp[b]=0;
        ans[i]=sum;
    }

    rep(i,Q)cout<<ans[i]<<endl;
    return 0; 
}


Measured memory_bytes: 8432
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>

using namespace std;

const int N = 200010;
int preT[N], preS[N];
char s[N];
int main() 
{
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        preS[i] = preS[i - 1] + (s[i] == 'S');
        preT[i] = preT[i - 1] + (s[i] == 'T');
        ans = max(ans, s[i] == 'T' ? preT[i] - preS[i] : 0);
    }
    printf("%d\n", ans << 1);
    // system("pause");
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

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

vector< vector<int> > Graph;
vector< int > value;



int main(int argc, const char * argv[]) {
    
    

    cin.tie(0);
    ios::sync_with_stdio(false);
   
    
    int n; cin >> n;
    vector<ll> Lucas(100);
    Lucas[0] = 2;
    Lucas[1] = 1;
    
    for (int i = 2; i <= 86; i++) {
        Lucas[i] = Lucas[i-1] + Lucas[i-2];
    }
    
    cout << Lucas[n] << endl;
    
    
}


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

int main(){
int n; cin >> n; int f=0;
string s; cin >> s;
if(n%2==0){
    if(s.substr(0,n/2)==s.substr(n/2,n/2)){
        cout << "Yes" << endl;
    }
else cout << "No" << endl;
}
else cout << "No" << endl;
return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String line;
		while ((line = reader.readLine()) != null) {
			if (line.isEmpty())
				break;
			double a = Double.parseDouble(line);

			double sum = a;
			for (int i = 0; i < 9; i++) {
				if (i % 2 == 0) {
					a = a * 2;
				} else {
					a = a / 3;
				}
				sum += a;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 16912
class Position
	attr_accessor :x, :y
	
	def initialize(x, y)
		@x = x
		@y = y
	end
	
	def +(move)
		@x += move.x
		@y += move.y
	end
end

DIRECTIONS = {
	'N' => Position.new(0, 1),
	'E' => Position.new(1, 0),
	'S' => Position.new(0, -1),
	'W' => Position.new(-1, 0),
}

while (gems_number = gets.to_i) != 0
	current_position = Position.new(10, 10)
	gems = []
	
	gems_number.times do
		x, y = gets.split.map(&:to_i)
		gems << Position.new(x, y)
	end
	
	order_number = gets.to_i
	
	order_number.times do
		direction, amount = gets.split
		
		amount.to_i.times do
			current_position + DIRECTIONS[direction]
			gems.reject! { |gem| gem.x == current_position.x && gem.y == current_position.y }
		end
	end
	
	if gems.empty?
		puts "Yes"
	else
		puts "No"
	end
end


Measured memory_bytes: 6852
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    set<int> st;
    while(k--) {
        int d;
        cin >> d;
        for (int i = 0, a; i < d; ++i) {
            cin >> a;
            st.insert(a);
        }
    }
    cout << n - st.size() << '\n';
    return 0;
}



Measured memory_bytes: 3648
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.nextInt
  val result = new Array[Int](N + 1)
  
  for {
    x <- (1 to 100)
    y <- (1 to 100)
    z <- (1 to 100)
    f = x * x + y * y + z * z + x * y + y * z + z * x
    if f <= N
  } result(f) += 1

  println(result.tail.mkString("\n"))
}

Measured memory_bytes: 57504
N = int(input())
data = [tuple(map(int, input().split())) for _ in range(N)]
data.sort(key=lambda x: -x[2])
for cx in range(101):
    for cy in range(101):
        h0 = None
        for x, y, h in data:
            if h:
                h_tmp = h + abs(cx - x) + abs(cy - y)
                if h_tmp != h0 and h0 is not None:
                    break
                h0 = h_tmp
            else:
                if abs(cx - x) + abs(cy - y) < h0:
                    break
        else:
            print(cx, cy, h0)
            exit()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC130(void);
void ABC131(void);
void ABC132(void);
void ABC133(void);
void ABC134(void);
void ABC135(void);
void ABC136(void);
void ABC137(void);
void ABC138(void);
void ABC139(void);

int main(void){
    int n,i,j,sum=0;
    cin>>n;
    vector<int> vec(n);
    for(i=0;i<n;i++){
        cin>>vec[i];
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            sum+=vec[i]*vec[j];
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)cout<<c<<endl;
    else if(b==c)cout<<a<<endl;
    else cout<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b;
	int i;
	for (i = 0; i < 7; i++) {
		scanf("%d%d", &a, &b);
		if( a > b)
			printf("%d\n", a - b);
		else
			printf("%d\n", b - a);
	}
	return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

struct Point {
	double x, y;
};

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

	int x;
	cin >> x;

	if (x < 1200) {
		cout << "ABC" << endl;
	} else {
		cout << "ARC" << endl;
	}
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  vector<int> vec2(N-1);
  rep(i, N) {
    if(i == 0) {
      cin >> vec.at(i);
    }
    else {
      cin >> vec.at(i);
      if(vec.at(i-1) < vec.at(i)) {
        vec2.at(i-1) = 1;
      }
      else {
        vec2.at(i-1) = -1;
      }
    }
  }
  int ans = 0;
  rep(i, N-2) {
    if(vec2.at(i) + vec2.at(i+1) != 0) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3576
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<complex>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

vector<vector<long double> > cost;	// cost[u][v] ?????? e = (u, v) ????????????(?????¨???????????´?????? INF)
vector<long double> mincost;		// ?????? X ???????????????????°??????????
vector<bool> used;			// ?????? i ??? X ????????????????????????
ll V;						// ????????°
long double prim() {
	REP(i, V) {
		mincost[i] = INF;
		used[i] = false;
	}
	mincost[0] = 0;
	long double res = 0;
	while(true) {
		ll v = -1;
		REP(u, V) {
			if(!used[u] && (v == -1 || mincost[u] < mincost[v])) v =u;
		}
		if(v == -1) break;
		used[v] = true;
		res += mincost[v];
		REP(u, V) {
			mincost[u] = min(mincost[u], cost[v][u]);
		}
	}
	return res;
}


int main(void) {
	while(true) {
		cin>>V;
		if(V == 0) break;
		long double p[V][4];
		cost.resize(0);
		cost.resize(V);
		REP(i, V) cost[i].resize(V);
		mincost.resize(0);
		mincost.resize(V);
		used.resize(0);
		used.resize(V);
		REP(i, V) cin>>p[i][0]>>p[i][1]>>p[i][2]>>p[i][3];
		REP(i, V) {
			REP(j, V) {
				if(i == j) cost[i][j] = INF;
				else {
					long double dist = sqrt( pow(p[i][0] - p[j][0], 2) + pow(p[i][1] - p[j][1], 2) +
											pow(p[i][2] - p[j][2], 2) );
					if(p[i][3] + p[j][3] - dist > EPS) cost[i][j] = 0;
					else cost[i][j] = dist - (p[i][3] + p[j][3]);
				}
			}
		}
		cout<<fixed<<showpoint<<setprecision(3)<<prim()<<endl;
	}
}

Measured memory_bytes: 3328
from math import factorial

N,M=map(int,input().split())
if abs(N-M)>1:
    print(0)
else:
    if N==M:
        mod=10**9+7
        n=factorial(N)%mod
        m=factorial(M)%mod
        print(n*m*2%mod)
    else:
        mod=10**9+7
        n=factorial(N)%mod
        m=factorial(M)%mod
        print(n*m%mod)

Measured memory_bytes: 4096
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;
int main(void) {
	int A, B;
	cin >> A >> B;
	if ((A + B) % 2 == 0) {
		cout << (A + B) / 2;
	}
	else {
		cout << "IMPOSSIBLE";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int x,n;
    cin>>x>>n;
    vector<int> p(n,0);
    for(int i=0;i<n;i++) cin>>p[i];
    sort(full(p));
    int ans=-1000,ab=abs(-1000-x);
    for(int i=-110;i<=110;i++){
        if(!binary_search(full(p),i) && abs(x-i)<ab){
            ab=abs(x-i);
            ans=i;
        }
    }
    cout<<ans<<"\n";
}

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

    solve();
    return 0;
}

Measured memory_bytes: 3644
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
template <typename T>
using Vec3 = vector<Vec2<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repe(i, n) REPN(i, 0, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define reper(i, n) REPNR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];
	Vec c(4);
	rep(i, n) c[a[i]]++;

	Vec3<Pld> dp(301, Vec2<Pld>(301, Vec1<Pld>(301)));

	dp[c[1]][c[2]][c[3]].sc = 1;

	reper(k, 300){
		reper(j, 300){
			reper(i, 300){
				if(dp[i][j][k].sc == 0.) continue;
				ll s = i+j+k;
				if(i){
					dp[i-1][j][k].fs += (dp[i][j][k].fs+(ld)n/s*dp[i][j][k].sc)*i/s;
					dp[i-1][j][k].sc += dp[i][j][k].sc*i/s;
				}
				if(j){
					dp[i+1][j-1][k].fs += (dp[i][j][k].fs+(ld)n/s*dp[i][j][k].sc)*j/s;
					dp[i+1][j-1][k].sc += dp[i][j][k].sc*j/s;
				}
				if(k){
					dp[i][j+1][k-1].fs += (dp[i][j][k].fs+(ld)n/s*dp[i][j][k].sc)*k/s;
					dp[i][j+1][k-1].sc += dp[i][j][k].sc*k/s;
				}
			}
		}
	}
	setp(15);
	co(dp[0][0][0].fs);

	return 0;
}


Measured memory_bytes: 861052
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

bool binary_search(vector<int> v, int kay){
    int left = 0;
    int right = SZ(v);
    int mid;
    while(left < right){
        mid = (left + right)/2;
        if (v[mid] == kay) return true;
        else if (kay < v[mid]) right = mid;
        else left = mid+1; 
    }
    return false;
}

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

    int n;
    cin >> n;

    vector<int> v;
    int t;
    REP(_, n){cin >> t; v.PB(t);}

    cin >> n;
    int count = 0;
    REP(_, n){
        cin >> t;
        if (binary_search(v, t)) count++;
    }

    cout << count << endl;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }


void bf(int n) {
  vector<int> vec;
  rep(i,n) vec.push_back(i+1);
  ll maxi = 0;
  vector<vector<int>> tmp;
  do {
    ll sum = 0;
    REP(i,1,n+1) {
      sum += ( i % vec[i-1] );
    }
    if( sum == maxi ) tmp.push_back(vec);
    else if( sum > maxi ) {
      tmp.clear();
      tmp.push_back(vec);
      maxi = sum;
    }
  } while( next_permutation(ALL(vec)) );
  cout << "maxi : " << maxi << endl;
  cout << "n : " << tmp.size() << endl;
  rep(i,(int)tmp.size()) {
    rep(j,(int)tmp[i].size()) {
      cout<<tmp[i][j] << " ";
    } puts("");
  }
}

int main() {
  ll n;
  cin >> n;
  //bf(n);
  cout << (ll)(n * (n-1LL) / 2LL) << endl;
  return 0;
}


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

#define FOR(x,y) for(x=0; x < y; x++)



int main() {
    int x, y;
    cin >> x;
    if(x%2==0){
        cout << x/2;
    }
    else{
        cout << x/2 + 1;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int x, y;
    cin >> x >> y;
    if (y % 2 == 1 or x * 2 > y or x * 4 < y) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  cout << C << " " << A << " " << B << endl;
  return 0;
}


Measured memory_bytes: 256
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
 
    ll n,m,i,sum=0,ans;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
    	ll x;
    	cin>>x;
    	sum += x;
    }
    if(sum>n) ans = -1;
    else ans = n - sum;
    cout<<ans;
}

Measured memory_bytes: 3652
s = input()
n = len(s)
ans = [ 0 for _ in range(n) ]

# solve about "R"
cnt = 0
for i in range(n):
    if s[i] == "R":
        cnt += 1
    else:
        ans[i] += cnt//2
        ans[i-1] += (cnt+1)//2
        cnt = 0


# solve about "L"
cnt = 0
for i in range(n-1, -1, -1):
    if s[i] == "L":
        cnt += 1
    else:
        ans[i] += cnt//2
        ans[i+1] += (cnt+1)//2
        cnt = 0

print(*ans, sep = " ")

Measured memory_bytes: 6400
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
n = ii()
a = li()
aco = a
aco = list(set(aco))
lis = [0]*(10**3)
rootn = 10**3
for i in range(len(aco)):
    for nm in range(2,rootn):
        if aco[i] % nm != 0:
            continue
        ima = 0
        while(aco[i]%nm == 0):
            ima += 1
            aco[i] = aco[i] //nm
        lis[nm] = max(lis[nm],ima)
aco = list(set(aco))
mod = 10**9 + 7
gcd = 1
for i in range(2,rootn):
    gcd *= (i ** lis[i]) % mod
for i in range(len(aco)):
    gcd *= aco[i] % mod

ans = 0
for i in range(n):
    ans += pow(a[i],mod-2,mod) * gcd % mod
print(ans% mod)
    




Measured memory_bytes: 43864
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int,int> P;

int main()
{
  int w, h;
  while (cin >> w >> h && w != 0) {
    vector<string> grid(h);
    P start;
    for (int i = 0; i < h; i++) {
      cin >> grid[i];
      for (int j = 0; j < w; j++) {
        if (grid[i][j] == '@') {
          start = make_pair(i, j);
          grid[i][j] = '#';
        }
      }
    }

    queue<P> q;
    q.push(start);
    int ans = 0;
    while (!q.empty()) {
      const P p = q.front();
      q.pop();

      ans++;
      for (int d = 0; d < 4; d++) {
        static const int dir_h[] = {-1, 1, 0, 0};
        static const int dir_w[] = {0, 0, -1, 1};
        const int next_h = p.first+dir_h[d];
        const int next_w = p.second+dir_w[d];
        if (next_h >= 0 && next_h < h && next_w >= 0 && next_w < w
            && grid[next_h][next_w] == '.') {
          q.push(make_pair(next_h, next_w));
          grid[next_h][next_w] = '#';
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(b%a==0){
        cout << a+b <<endl;
    }else{
        cout << b-a <<endl;
    }
}

Measured memory_bytes: 256
P = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

print(P[K - 1])

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  string S; cin >> S;
  int ans = 0, cnt = 0;
  for (int i = 0; i < 3; i++){
    if (S[i] == 'R') cnt++;
    else {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3640
/*
大小関係
*/

#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);

  if(a < b)
    printf("a < b\n");
  else
    if(a > b)
      printf("a > b\n");
    else
      printf("a == b\n");
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

int v[45], w[45];
pair<ll, ll> ps[1<<20];
signed main(void)
{
  int n, W;
  cin >> n >> W;
  REP(i, n) cin >> v[i] >> w[i];

  int n2 = n/2;
  REP(i, 1<<n2) {
    int sw = 0, sv = 0;
    REP(j, n2) {
      if(i>>j&1) {
        sw += w[j];
        sv += v[j];
      }
    }
    ps[i] = MP(sw, sv);
  }
  sort(ps, ps+(1<<n2));
  int m=1;
  REP(i, 1<<n2) {
    if(ps[m-1].second < ps[i].second) {
      ps[m++] = ps[i];
    }
  }
  int res = 0;
  REP(i, 1<<(n-n2)) {
    int sw = 0, sv = 0;
    REP(j, n-n2) {
      if(i>>j&1) {
        sw += w[n2+j];
        sv += v[n2+j];
      }
    }
    if(sw <= W) {
      int tv = (lower_bound(ps, ps+m, MP(W-sw, INF))-1)->second;
      res = max(res, sv+tv);
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 19476
n, m = map(int, input().split())
A = []
b = []

for i in range(n):
    A.append(list(map(int, input().split())))

for k in range(m):
    x = int(input())
    b.append(x)

for j in A:
    ans = []
    for k in range(m):
        ans.append(j[k]*b[k])
    print(sum(ans))


Measured memory_bytes: 5980
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

using ll = long long;

int main(){
	double w;
	double h;
	double x;
	double y;

	cin >> w;
	cin >> h;
	cin >> x;
	cin >> y;

	double size = w * h / 2.0;
	int ways = 0;
	if (x == w / 2.0 && y == h / 2.0) {
		ways = 1;
	}
	
	int return_value;

	cout << setprecision(10) << size << " " << ways << endl;
	
	return 0;
}

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

int knapsack(int wt[], int val[], int n, int W)
{
    if(n==0) return 0;
    if(W==0) return 0;

    if(wt[n-1]<=W)
    {
        int take=val[n-1]+knapsack(wt,val,n-1,W-wt[n-1]);
        int nott=knapsack(wt,val,n-1,W);
        return max(take, nott);
    }
    else
    {
        return knapsack(wt,val,n-1,W);
    }

}

int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

        int n,i,j,k,W; cin>>n>>W;
        int wt[n],val[n];

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

        //cout<<knapsack(wt,val,n,W);

        vector<int> dp(sum+1,INT_MAX);
        dp[0]=0;

        for(i=0;i<n;i++)
        {
            for(j=sum-val[i];j>=0;j--)
            {
                dp[j+val[i]]=min(dp[j+val[i]], dp[j]+wt[i] );
            }
        }

        int ans;
        for(i=0;i<=sum;i++)
        {
            if(dp[i]<=W)
            {
                ans=i;
            }
        }

        cout<<ans;


//        int dp[n+1][100001];
//        memset(dp,0,sizeof(dp));
//
//        for(i=1;i<=n;i++)
//        {
//
//            for(j=1;j<=W;j++)
//            {
//                if(j-wt[i-1]>=0)
//                {
//                    dp[i][j] = max(dp[i-1][j], val[i-1]+dp[i-1][j-wt[i-1]]);
//                }
//                else
//                    dp[i][j]=dp[i-1][j];
//
//            }
//
//        }

//        for(i=0;i<=n;i++)
//        {
//            for(j=0;j<=W;j++)
//            {
//                cout<<dp[i][j]<<"  ";
//            }
//            cout<<endl;
//        }


//        cout<<dp[n][W];

    return 0;
}






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

#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int

using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod = 998244353;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
const double pi = 3.14159265359;
const double eps = 0.00000001;

bool vis[MAXN];
vector<vector<ii>> g;
int n;

void dfs(int node) {
    vis[node] = 1;
    for (auto e : g[node]) {
        if (!vis[e.F]) {
            dfs(e.F);
        }
    }
    
}

int32_t main() {

    $
    
    int m;

    cin >> n >> m;

    g.assign(n + 1, vector<ii>());

    int u, v, w;

    while (m--) {
        cin >> u >> v >> w;
        w &= 1;
        g[u].push_back({v, w});
        g[v].push_back({u, w});
    }

    int ans = 0;

    forn (1, n + 1) {
        if (!vis[i]) {
            dfs(i);
            ++ans;
        }
    }

    cout << ans << '\n';
    
}

Measured memory_bytes: 8960
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C&lang=jp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, j) for(int i = 0; i < (int)(j); i++)
constexpr int INF = 1 << 28;
struct Edge{
    int to;
    ll cost;
    Edge(int to, ll cost):to(to), cost(cost){}
};
using EdgeList = vector<vector<Edge>>;
using Vatex = int;
constexpr ll INFL = 1LL << 60;
// O(V^3)
vector<vector<ll>> warshall_floyd(const EdgeList &G) {
    int N = G.size();
    vector<vector<ll>> dist(N, vector<ll>(N, INFL));
    rep(i, N) for(const Edge &e : G[i]) dist[i][e.to] = e.cost;
    rep(k, N) rep(i, N) rep(j, N)
            if(dist[i][k] < INFL and dist[k][j] < INFL)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    return dist;
}
// warshall floyd?????????????????????????????????
bool has_negative_cycle(vector<vector<ll>> &dist) {
    rep(i, dist.size()) if(dist[i][i] < 0) return true;
    return false;
}
int main() {
    int N, M; cin >> N >> M;
    EdgeList E(N);
    rep(i, M) {
        int a, b, c; cin >> a >> b >> c;
        E[a].push_back(Edge(b, c));
    }
    rep(i, N) E[i].push_back(Edge(i, 0));
    auto dist = warshall_floyd(E);
    if(has_negative_cycle(dist)) {
        cout << "NEGATIVE CYCLE" << endl;
    } else {
        rep(i, N) {
            rep(j, N) cout << (dist[i][j] < INFL ? to_string(dist[i][j]) : "INF") << (j == N - 1 ? "\n" : " ");
        }
    }
    return 0;
}

Measured memory_bytes: 3340
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pint pair<int,int>
#define pll pair<ll,ll>
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

    int triangleNumber(vector<int>& nums) {
        if (nums.size() < 3) return 0;
        int res = 0;
        sort(nums.begin(), nums.end());
        for (int lo = 0; lo < nums.size() - 2; lo++) {
            for (int hi = lo + 2, mid = lo + 1; hi < nums.size(); hi++) {
                while (nums[mid] <= nums[hi] - nums[lo] && mid < hi) mid++;
                res = res + hi - mid;
            }
        }
        return res;
    }

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n)cin >> l[i];
  cout << triangleNumber(l) << endl;
return 0;}

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

int main() {
  string dance;
  string msg="Yes";
  cin >> dance;
  bool isEasy =true;
  for (int i=0; i<dance.size(); i=i+2){
    if(dance.at(i)=='L'){
      isEasy=false;
    }
  }
  for (int i=1; i<dance.size(); i=i+2){
    if(dance.at(i)=='R'){
      isEasy=false;
    }
  }
  if(isEasy){
    msg="Yes";
  }else{
    msg="No";
  }
  cout << msg << endl;
  
}





Measured memory_bytes: 256
#include <set>
#include <string>
#include <iostream>

int X,Y,Z;
std::multiset<std::string> s;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0),std::cout.tie(0);
    std::cin>>X>>Y>>Z;
    while(X--)s.insert(std::string("a"));
    while(Y--)s.insert(std::string("b"));
    while(Z--)s.insert(std::string("c"));
    while((int)s.size()>1)
    {
        std::string s1=*s.begin(),s2=*--s.end();
        s.erase(s.begin()),s.erase(--s.end());
        s.insert(s1+s2);
    }
    std::cout<<*s.begin()<<std::endl;
    return 0;
}

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

#define ll long long
#define ii pair<ll, ll>
#define dd pair<double, double>
#define pb(i) push_back(i)
const double PI = 3.14159265359;
const ll inf = 1e18;
const int mod = 1e9+7;
const double eps = 1e-7;
//int dir1[8] = {0, 0, 1, -1, 1, -1, 1, -1};
//int dir2[8] = {1, -1, 0, 0, 1, 1, -1, -1};
int dir1[4] = {0, 0, 1, -1};
int dir2[4] = {1, -1, 0, 0};

const int N = 1<<22;

int mat[20][20];
ll val[1<<17];
ll dp[1<<17];

int main()
{
    int i, j, k;

    int n;
    cin >> n;

    for(i = 0; i < n; i++)
        for(j = 0; j < n; j++)
            cin >> mat[i][j];

    memset(val, 0, sizeof(val));
    memset(dp, 0, sizeof(dp));

    for(i = 0; i < (1<<n); i++)
    {
        for(j = 0; j < n; j++)
            if( (1<<j)&i )
                for(k = j+1; k < n; k++)
                    if( (1<<k)&i )
                        val[i] += mat[j][k];
    }

    //for(i = 0; i < (1<<n); i++)
    //    cout << val[i] << '\n';

    for(i = 0; i < (1<<n); i++)
    {
        //not yet selected. Let's form another group with it.
        vector<int> pos;
        for(j = 0; j < n; j++)
            if(!( (1<<j)&i ))
                pos.pb(j);
        
        int tam = (int)pos.size();
        for(j = 0; j < (1<<tam); j++)
        {
            int mask = 0;
            for(k = 0; k < tam; k++)
                if( (1<<k)&j )
                    mask |= (1<<pos[k]);
        
            dp[mask|i] = max(dp[mask|i], dp[i] + val[mask]);
        }
    }

    cout << dp[(1<<n)-1] << '\n';

}




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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < 0 && b < 0 && (b - a + 1) % 2 == 0) cout << "Positive" << endl;
  else if (a < 0 && b < 0) cout << "Negative" << endl;
  else if (a <= 0 && b >= 0) cout << "Zero" << endl;
  else cout << "Positive" << endl;
}

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

min = []
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] < h[b-1]:
        min.append(a)
    if h[a-1] == h[b-1]:
        min.append(a)
        min.append(b)
    if h[a-1] > h[b-1]:
        min.append(b)

print(len(h)-len(set(min)))


Measured memory_bytes: 20112
/*  -*- coding: utf-8 -*-
 *
 * 3055.cc: Don't Burn Kotatsu Turtle
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 1000;
const int MAX_W = 1000;
const int INF = (int)((1LL << 31) - 1);

const int dxs[] = { 1, 1, 0, -1, -1, -1, 0, 1 };
const int dys[] = { 0, -1, -1, -1, 0, 1, 1, 1 };

/* typedef */

struct Stat {
  int d, x, y;
  Stat() {}
  Stat(int _d, int _x, int _y): d(_d), x(_x), y(_y) {}
  bool operator<(const Stat &s) const { return d > s.d; }
  void print() { printf("Stat(%d,%d,%d)\n", d, x, y); }
};

/* global variables */

char flds[MAX_H][MAX_W + 4];
int ds[MAX_H][MAX_W], dis[8];

/* subroutines */

inline bool inside(int x, int y, int w, int h) {
  return (x >= 0 && x < w && y >= 0 && y < h);
}

/* main */

int main() {
  int h, w, a, b;
  scanf("%d%d%d%d", &h, &w, &a, &b);

  int sx, sy, gx, gy;
  for (int y = 0; y < h; y++) {
    scanf("%s", flds[y]);
    for (int x = 0; x < w; x++)
      switch (flds[y][x]) {
      case 's': flds[y][x] = '.', sx = x, sy = y; break;
      case 'g': flds[y][x] = '.', gx = x, gy = y; break;
      }
    fill(ds[y], ds[y] + w, INF);
  }

  ds[sy][sx] = 0;
  priority_queue<Stat> q;
  q.push(Stat(0, sx, sy));

  while (! q.empty()) {
    Stat u = q.top(); q.pop();
    //u.print();
    if (u.d != ds[u.y][u.x]) continue;
    if (u.x == gx && u.y == gy) break;

    int vd = u.d + a, din = 0;
    bool bmb = (flds[u.y][u.x] == '*');
    for (int di = 0; di < 8; di++) {
      int vx = u.x + dxs[di], vy = u.y + dys[di];
      if (inside(vx, vy, w, h)) {
	char &vf = flds[vy][vx];
	// normal move
	if (! (di & 1) && vf != '#' && ds[vy][vx] > vd) {
	  ds[vy][vx] = vd;
	  q.push(Stat(vd, vx, vy));
	}

	// bomb
	if (vf == '*') bmb = true;
	else if (vf == '#')
	  dis[din++] = di;
      }
    }
    //printf("  bmb=%d\n", bmb);

    if (! bmb)
      for (int i = 0; i < din; i++) {
	int di = dis[i];
	int vx = u.x + dxs[di], vy = u.y + dys[di];
	int vd = u.d + ((di & 1) + 1) * a + b;

	if (ds[vy][vx] > vd) {
	  ds[vy][vx] = vd;
	  q.push(Stat(vd, vx, vy));
	}
      }
  }

  if (ds[gy][gx] >= INF) puts("INF");
  else printf("%d\n", ds[gy][gx]);
  return 0;
}



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

long long n, k, rsp[3];
string t;
vector<vector<long long>> dp;

long long calc(char x) {
  if(x == 'r') return 0;
  if(x == 's') return 1;
  return 2;
}

long long solve();

int main() {
  cin >> n >> k >> rsp[0] >> rsp[1] >> rsp[2] >> t;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0;
  dp.assign(n + 1, vector<long long>(3, 0));
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < 3; ++j) {
      long long now = 0, nowhand = calc(t[i]);
      if(i >= k)
        for(int l = 0; l < 3; ++l)
          if(j != l) now = max(now, dp[i - k][l]);
      if((j + 1) % 3 == nowhand) now += rsp[j];
      dp[i][j] = now;
    }
  for(int i = 0; i < k; ++i) {
    long long now = 0;
    for(int j = 0; j < 3; ++j)
      now = max(now, dp[n - 1 - i][j]);
    res += now;
  }
  return res;
}

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

typedef long long ll;
typedef unsigned long long ull;

#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(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  while(n > 1000){
    n -= 1000;
  }
  cout << 1000 - n << endl;
  return 0;
}



Measured memory_bytes: 3656
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    vi a(n);
    forn(i,n)   cin>>a[i];
    bool flag = true;
    int maxi = INT_MIN;
    //vi diff_max(n);
    forn(i,n){
        maxi = max(maxi,a[i]);
        //diff_max[i] = maxi - a[i];
        if(maxi-a[i]>1){
            flag = false;
            break;
        }
        /*
        if(a[i]<a[i-1]){
            cnt++;
            if(a[i-1]-a[i]>1){
                flag = false;
                break;
            }
            //if(cnt>1){
            //    flag = false;
            //    break;
            //}
        }
        */
    }
    if(!flag)   cout<<"No\n";
    else        cout<<"Yes\n";
    return 0;
}



Measured memory_bytes: 3736
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define PI            (acos(-1.0))
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,a,n)    for(int i=a;i<n;i++)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define w(t)          int t;cin>>t;while(t--)
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;

const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    int s,w;
    cin>>s>>w;
    s-=w;
    if(s>0)cout<<"safe"<<nl;
    else cout<<"unsafe"<<nl;
    return 0;
}


Measured memory_bytes: 3532