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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 28;

int n,m,r;

int L[210][210];
int S[210][210];
int z[1010];

int dp[1010][210];

int main(void){
	while(cin >> n >> m,n|m){
		rep(i,n)rep(j,n) L[i][j]=S[i][j]=(i==j)?0:inf;
		rep(i,m){
			int a,b,c;
			char type;
			cin >> a >> b >> c >> type;
			a--,b--;
			if(type=='L')
				L[a][b]=L[b][a]=min(L[a][b],c);
			else
				S[a][b]=S[b][a]=min(S[a][b],c);
		}
		rep(k,n)rep(i,n)rep(j,n) L[i][j]=min(L[i][j],L[i][k]+L[k][j]);
		rep(k,n)rep(i,n)rep(j,n) S[i][j]=min(S[i][j],S[i][k]+S[k][j]);
		
		cin >> r;
		rep(i,r) cin >> z[i],z[i]--;
		rep(i,r)rep(j,n) dp[i][j]=inf;
		dp[0][z[0]]=0;
		rep(i,r-1)rep(j,n){
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]+L[z[i]][z[i+1]]);
			rep(k,n){
				int cost=L[z[i]][j]+S[j][k]+L[k][z[i+1]];
				dp[i+1][k]=min(dp[i+1][k],dp[i][j]+cost);
			}
		}
		int ans=inf;
		rep(i,n) ans=min(ans,dp[r-1][i]);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2324
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

int n;
vector<int> G[1 << 17];
bool ans = false;
int dfs(int v, int from) {
	int num = 0;
	rep(j, G[v].size()) {
		int to = G[v][j];
		if (to == from)continue;
		if (dfs(to, v))num++;
	}
	if (num >= 2)ans = true;
	return num ^ 1;
}
void solve() {
	cin >> n;
	rep(i, n - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	if (dfs(0, -1))ans = true;
	if (ans)cout << "First" << endl;
	else cout << "Second" << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 6528
import sys
import copy
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = [deque(lr()) for _ in range(N)]

answer = 0
match = 0

candidate = list(range(N))
while True:
    used = set()
    bool = False
    c = []
    for i in candidate:
        if len(A[i]) == 0:
            continue
        op = A[i][0] - 1
        if op in used or i in used:
            continue
        if A[op][0]-1 == i:
            used.add(i)
            used.add(op)
            match += 1
            c.extend([i, op])
            bool = True
            A[i].popleft()
            A[op].popleft()
    
    answer += 1
    candidate = c
    if match == N * (N-1) // 2:
        break
    if not bool:
        print(-1)
        exit()

print(answer)


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

using P = std::pair<uint64_t, uint64_t>;

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

    std::vector<P> ps;
    uint64_t A, B;
    for (int i = 0; i < N; ++i) {
        std::cin >> A >> B;
        ps.push_back({A, B});
    }

    std::sort(ps.begin(), ps.end(), [](const auto& lhs, const auto& rhs) {
        return lhs.second < rhs.second;
    });

    uint64_t sum = 0;
    for (const P& p : ps) {
        sum += p.first;
        if (sum > p.second) {
            std::printf("No\n");
            return 0;
        }
    }
     
    std::printf("Yes\n");

    return 0;
}


Measured memory_bytes: 6128
list = []
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break

    cnt = 0
    for a in range(1, n + 1):
        for b in range(a + 1, n + 1):
            for c in range(b + 1, n + 1):
                if a + b + c == x:
                    cnt += 1
    list.append(cnt)

for s in list:
    print(s)

Measured memory_bytes: 7660
N, M = map(int, input().split(' '))
path = [[False for i in range(N+1)] for j in range(N+1)]
connect_list = []
for i in range(M):
    a, b = map(int, input().split(' '))
    path[a][b] = True
    path[b][a] = True
    connect_list.append((a, b))
visit = []


def dfs(x):
    if visit[x]:
        return
    visit[x] = True
    for i in range(1, N+1):
        if path[x][i]:
            dfs(i)


ans = 0
for j in range(M):
    a, b = connect_list[j]
    path[a][b] = False
    path[b][a] = False
    visit = [False for i in range(N+1)]
    connect = True
    dfs(1)
    for i in range(1, N+1):
        if not visit[i]:
            connect = False
    if not connect:
        ans += 1
    path[a][b] = True
    path[b][a] = True
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    if (n==2){
        cout << 2 << endl;
        return 0;
    }
    for (int i=n; 1; i++)
    {
        for (int j=2; 1; j++)
        {
            if (i%j==0)
                break;
            if (j>=i/2)
            {
                cout << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long l[3] = {2, 1, 0};
    int n;
    cin >> n;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    for(int i = 2; i <= n; i++){
        l[2] = l[0] + l[1];
        l[0] = l[1];
        l[1] = l[2];
    }
    cout << l[2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<functional>
#include<queue>
#include<cstring>

using namespace std;
int main() {
	int r, d, x, xx;
	cin >> r >> d >> x;
	xx = x;
	for (int i = 0; i < 10; i++) {
		cout << r*xx - d << endl;
		xx = r*xx - d;
	}
	return 0;
}

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

int main(){
  ll n;
  cin >> n;
  
  vector<pair<ll,ll>> v;
  vector<ll> pta,ptb;
  
  ll x,y;
  for(ll i=0; i<n; i++){
    cin >> x >> y;
    
    v.push_back(make_pair(x+y,i));
    pta.push_back(x);
    ptb.push_back(y);
  }
  
  sort(v.begin(), v.end(), greater<>());
    
  ll ans1 = 0;
  ll ans2 = 0;
  ll pos = 0;

  while(1){
    ans1 += pta[v[pos].second];
    pos++;
    
    if(pos == n) break;
    
    ans2 += ptb[v[pos].second];
    pos++;
    if(pos == n) break;
  }
  
  cout << ans1 - ans2 << endl;
}

Measured memory_bytes: 4724
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<climits>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<string.h>
#include<algorithm>
#include<unordered_map>
#pragma GCC optimize "trapv"
using namespace std;

#define ld long double
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(int i=a;i<b;i++)
#define pp pair<int,pair<int,int>>
#define ppp pair<pair<int,int>,pair<int,int>>

const ll M=1e9,N=2e5+2;

struct hash_pair{
	template <class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const{
		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);
		return hash1 ^ hash2;
	}
};

void sieve(){
	bool prime[N+1];
	memset(prime,true,sizeof(prime));
	for(ll p=2;p*p<=N;p++){
		if(prime[p] == true){
			for(ll i=p*p;i<=N;i+=p)
				prime[i] = false;
		}
	}
}

ll power(ll x,ll y,ll p){
	ll res = 1;
	x = x%p;
	while(y > 0){
		if(y&1)
			res = (res*x)%p;
		y = y>>1;
		x = (x*x)%p;
	}
	return res;
}

int root(int i,int A[]){
	while(A[i] != i){
		A[i] = A[A[i]];
		i = A[i];
	}
	return i;
}

void unite(int a,int b,int A[],int B[]){
	int c = root(a,A);
	int d = root(b,A);
	if(c == d)
		return;
	if(B[c] < B[d]){
		A[c] = d;
		B[d] += B[c];
	}
	else{
		A[d] = c;
		B[c] += B[d];
	}
}

inline ll in()
{
	ll n=0;
	bool check=0;
	register char c=getchar();
	while(c<'0' || c>'9')
	{
		if(c=='-')
			check=1;
		c=getchar();
	}
	while(c>='0' && c<='9')
	{
		n = (n<<1)+(n<<3)+c-'0';
		c=getchar();
	}
	return n-2*n*check;
}

string ip()
{
    string i="";
    int temp=getchar();
    while(temp<'a'||temp>'z')
        temp=getchar();
    while(temp>='a'&&temp<='z')
    {
        i+=(char)temp;
        temp=getchar();
    }
    return i;
}

vector<int> V[N];
int P[N],H[N];
unordered_map<int,bool> U;
vector<pair<int,int>> B;

bool compare(pair<int,int> a,pair<int,int> b){
	return a.first > b.first;
}

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


	string S;
	cin>>S;
	if(S[2] == S[3] && S[4] == S[5])
		cout<<"Yes\n";
	else
		cout<<"No\n";

	return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <vector>
#include <map>

typedef long long ll;

using namespace std;

int main() {
    ll n, p = 0, a, ans = 0;
    map<ll, ll> d;
    ++d[0];
    scanf("%lld", &n);
    for (ll i = 0; i < n; ++i) {
        scanf("%lld", &a);
        p += a;
        ++d[p];
    }
    for (auto i = d.begin(); i != d.end(); ++i) ans += (*i).second * ((*i).second - 1) / 2;
    printf("%lld\n", ans);
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  ll a[n],b[n];
  ll suma=0,sumb=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    suma+=a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
    sumb+=b[i];
  }
  if(suma>sumb){
    cout<<"No"<<endl;
    return 0;
  }
  ll x=0,y=0;
  for(int i=0;i<n;i++){
    if(a[i]>b[i]){
      y+=a[i]-b[i];
    }
    if(a[i]<b[i]){
      x+=(b[i]-a[i])/2;
    }
  }
  if(x<y){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
}

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

bool dp[105][10005];

int main(){
    int n; cin>>n;
    vector<int> s(n);
    for(int i=0;i<n;i++) cin>>s[i];

    dp[0][0]=true;
    for(int i=0;i<n;i++){
        for(int j=0;j<=10000;j++){
            if(dp[i][j]){
                dp[i+1][j]=true;
                dp[i+1][j+s[i]]=true;
            }
        }
    }

    for(int i=10000;i>=0;i--){
        if(i%10!=0&&dp[n][i]){
            cout<<i<<endl;
            return 0;
        } 
    }
    cout<<0<<endl;
}

Measured memory_bytes: 1024
import sys
from collections import Counter
import bisect


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N=int(input())
    D,X=map(int,input().split())
    ans =0
    for i in range(N):
        a =int(input())
        ans+=1 + (D-1)//a


    print(ans+X)




if __name__ == "__main__":
    main()


Measured memory_bytes: 65000
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if N % 2 == 0:
    b = (B[N//2-1]+B[N//2])/2
    a = (A[N//2-1]+A[N//2])/2
    ans = (b-a)//0.5 +1
else:
    b = B[(N+1)//2-1]
    a = A[(N+1)//2-1]
    ans = b-a+1
print(int(ans))

Measured memory_bytes: 25576
//ITP1_5_D
//????????????

using System;
using System.Collections.Generic;

class ITP1_5_D
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());

        call(n);

    }

    private static void call(int n)
    {
        for(int i = 1;i <= n; i++)
        {
            string s = i.ToString();
            //i????????§?????????????????????3????????????????????????
            if ((i % 3) == 0 || s.IndexOf("3") >= 0)
            {
                Console.Write(" "+ i);
            }

        }
        Console.Write("\r\n");
    }
}

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

void solver() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int cnt = 0;
  while(a > 0 && c > 0) {
    if (cnt % 2 == 0) {
      c -= b;
    } else {
      a -= d;
    }

    cnt++;
  }

  if (a > 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

int main() {
  solver();
  return 0;
}


Measured memory_bytes: 3632
using System;

namespace aoj2b
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] array = str.Split(' ');
            int[] num = new int[3];

            for(int i = 0; i < 3; i++)
            {
                num[i] = int.Parse(array[i]); 
            }

            Array.Sort(num);

            Console.WriteLine(num[0] + " " + num[1] + " " + num[2]);


        }
    }
}

Measured memory_bytes: 9252
#include<stdio.h>
#include<stdlib.h>
struct node{
  int key;
  struct node *next;
};
typedef struct node *GG;

GG G[100000];
int color[100000];

GG MNode(int,GG);
void Insert(int,int);
void Dye(int,int);
int main()
{
  int p,i,s,t,id=1,q,n,m;
  scanf("%d%d",&n,&m);
  for(i=0;i<n;i++)G[i]=MNode(i,NULL);
  for(i=0;i<m;i++){
    scanf("%d%d",&s,&t);
    Insert(s,t);
    Insert(t,s);
  }
  for(i=0;i<n;i++)color[i]=0;
  for(i=0;i<n;i++){
    if(color[i]==0){
      Dye(i,id);
      id++;
    }
  }
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d%d",&s,&t);
    if(color[s]==color[t])printf("yes\n");
    else printf("no\n");
  }
  // for(i=0;i<n;i++)printf("%d ",color[i]);
  return 0;
}

GG MNode(int key,GG Node)
{
  GG n;
  n=(GG)malloc(sizeof(struct node));
  n->key=key;
  n->next=Node;
  return n;
}
void Insert(int s,int t)
{
  GG GGG;
  GGG=MNode(t,G[s]->next);
  G[s]->next=GGG;
}

void Dye(int c,int id)
{
  int S[100000],head=0,u,v;
  GG GGG;
  S[head]=c;
  head++;
  color[c]=id;
  while(head!=0){
    u=S[head-1];
    head--;
    for(GGG=G[u]->next;GGG!=NULL;GGG=GGG->next){
      v=GGG->key;
      if(color[v]==0){
        color[v]=id;
	S[head]=v;
	head++;
      }
    }
  }
}
    

Measured memory_bytes: 11188
N = int(input())
ans = 0
temp_ans = 0
for i in range(N):
    D1,D2 = map(int, input().split())
    if D1 == D2:
        temp_ans += 1
    else:
        if ans < temp_ans:
            ans = temp_ans
        temp_ans = 0
if ans < temp_ans:
    ans = temp_ans
temp_ans = 0
if ans >= 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9180
using System;
using System.Collections.Generic;
class E { static void Main() { new K(); } }
class K
{
	public K()
	{
		var N = int.Parse(Console.ReadLine());
		var ps = GetPrimes(100100);
		var p2 = new Dictionary<long, int>();
		foreach (var p in ps) p2.Add(p * (long)p, p);
		var z = new long[N];
		var cnt = new Dictionary<long, int>();
		var w = new Dictionary<long, long>();
		for (var i = 0; i < N; i++)
		{
			var num = long.Parse(Console.ReadLine());
			var fact = new List<int>();
			var t = 1L;
			for (var j = 0; j < ps.Count; j++)
			{
				var x = ps[j];
				var cube = x * (long)x * x;
				if (cube > num) break;
				if (num % x == 0)
				{
					fact.Add(x);
					while (num % cube == 0) num /= cube;
					if (num % (x * (long)x) == 0) t *= x;
					else if (num % x == 0) t *= x * (long)x;
				}
			}
			z[i] = num;
			if (!w.ContainsKey(z[i]))
			{
				foreach (var p in fact) while (num % p == 0) num /= p;
				var lim = 10000000100L;
				var lim2 = (int)(Math.Sqrt(lim) + 10);
				if (p2.ContainsKey(num)) { if (p2[num] < lim) t *= p2[num]; else t = -1; }
				else { if (num < lim2) t *= num * num; else t = -1; }
				w[z[i]] = t;
				cnt[z[i]] = 0;
			}
			cnt[z[i]]++;
		}
		var sum = 0;
		var set = new HashSet<long>(z);
		var done = new HashSet<long>();
		if (set.Contains(1)) { sum++; set.Remove(1); }
		foreach (var x in set)
		{
			if (done.Contains(x)) continue;
			var y = w[x];
			if (cnt.ContainsKey(y)) sum += Math.Max(cnt[x], cnt[y]);
			else sum += cnt[x];
			done.Add(x);
			done.Add(y);
		}
		Console.WriteLine(sum);
	}
	List<int> GetPrimes(int n)
	{
		var m = (n - 1) >> 1;
		var primes = new List<int>((int)(n / Math.Log(n)));
		primes.Add(2);
		var composites = new bool[m];
		composites[0] = false;
		for (var p = 0; p < m; p++)
			if (!composites[p])
			{
				var pnum = 2 * p + 3;
				primes.Add(pnum);
				for (var k = 3 * p + 3; k < m; k += pnum) composites[k] = true;
			}
		return primes;
	}
}

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;


ll sum(ll n) {
  ll m=0;
  FOR(i,0,12){
    m+=n%10;
    n/=10;
  }
  return m;
}


ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}


ll lcm(ll a,ll b){
  ll n;
  n=a*b/gcd(a,b);
  return n;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/


signed main() {
  vll A(3);
  FOR(i,0,3){
    ci(A[i])
  }
  SORT(A);
  co(A[2]-A[0])
}

Measured memory_bytes: 256
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        read();
        int c = 0;
        for (int i = 0; i < builder.length(); i++) {
            int n = Integer.parseInt(builder.substring(i, i + 1));
            c = (c + n) % 9;
        }

        if (c % 9 == 0) System.out.print("Yes");
        else System.out.print("No");
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 43076
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
using namespace std;

int main(){
  string S;
  cin>>S;
  
  int minIndex,finalAnswer;
  int num[S.size()];
  vector<int> answer;
  
  for(int i=0;i<S.size();i++){
    num[i] = S[i]-'0';
  }
  for(int i=0;i<S.size()-2;i++){
    answer.push_back(num[i]*100 + num[i+1]*10 + num[i+2]);
  }
  minIndex=0;
  for(int i=1;i<answer.size();i++){
    if(abs(answer[minIndex]-753)>abs(answer[i]-753)){
      minIndex=i;
    }
  }
  finalAnswer=answer[minIndex];
  cout<<abs(finalAnswer-753);
}

Measured memory_bytes: 256
#!/usr/bin/env python

# input
n, m = map(int, input().split())
t = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
k = [t[i][0] for i in range(m)]
s = [t[i][1:] for i in range(m)]

# calc
# bit full search
ans = 0 
for i in range(2**n):
    tmp = i 
    sw = []
    if i == 0:
        sw = [0] 
    while tmp > 0:
        sw.append(tmp&1)
        tmp = tmp>>1
    while len(sw) < n:
        sw.append(0)

    #print('sw =', sw)
    
    # check whether current sw satisfies the condision.
    ok = True
    # light bulb j
    for j in range(m):
        tmp = 0 
        for a in range(k[j]):
            tmp += sw[s[j][a]-1]
        if tmp%2 != p[j]:
            ok = False
            break
    if ok: 
        # print('sw =', sw)
        ans += 1

print(ans)


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<ll> c(26);
  for (auto e : s) {
    c[e - 'a']++;
  }
  ll r = 1;
  for (auto e : c) {
    r = (r * (e + 1)) % mod;
  }
  r -= 1;
  cout << r << endl;
}


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

struct BipartiteMatching {
	int V;
	vector<vector<bool> > G;
	vector<int> match;
	vector<bool> used;

	BipartiteMatching(int v) {
		V = v;
		G = vector<vector<bool> >(v, vector<bool>(v));
		match = vector<int>(v);
		used = vector<bool>(v);
	}

	void add_edge(int v, int u) {
		G[v][u] = G[u][v] = true;
	}

	bool dfs(int v) {
		used[v] = true;
		for(int i = 0; i < V; i++) {
			if(!G[v][i]) continue;
			int u = i, w = match[u];
			if(w < 0 || (!used[w] && dfs(w))) {
				match[v] = u;
				match[u] = v;
				return true;
			}
		}
		return false;
	}

	int calc() {
		int res = 0;
		fill(match.begin(), match.end(), -1);
		for(int v = 0; v < V; v++) {
			if(match[v] < 0) {
				fill(used.begin(), used.end(), false);
				if(dfs(v)) {
					res++;
				}
			}
		}
		return res;
	}
};

double tx[100];
double ty[100];
double tv[100];
double bx[100];
double by[100];

double d(double x1, double y1, double x2, double y2) {
	x1 -= x2, y1 -= y2;
	return sqrt(x1 * x1 + y1 * y1);
}

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

	int N, M;
	while(cin >> N >> M, N | M) {
		for(int i = 0; i < N; i++) {
			cin >> tx[i] >> ty[i] >> tv[i];
		}
		for(int i = 0; i < M; i++) {
			cin >> bx[i] >> by[i];
		}
		BipartiteMatching bp(N + M);
		double ng = 0, ok = 1e8;
		for(int lopp = 0; lopp < 200; lopp++) {
			double m = (ng + ok) / 2;

			for(int i = 0; i < N; i++) {
				for(int j = 0; j < M; j++) {
					double dist = d(tx[i], ty[i], bx[j], by[j]);
					bp.G[i][N + j] = bp.G[N + j][i] = (dist / tv[i] <= m);
				}
			}

			if(bp.calc() == M) {
				ok = m;
			}
			else {
				ng = m;
			}
		}

		if(abs(ok) < 1e-8) {
			cout << 0 << endl;
		}
		else {
			cout << setprecision(20) << ok << endl;
		}
	}
}

Measured memory_bytes: 3332
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N;
	ll ans = 0;

	cin >> N;

	repc(i, 1, N) {
		if (i % 3 != 0 && i % 5 != 0) ans += i;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3624
operand = []
for x in raw_input().split():
  if x.isdigit():
    operand.append(int(x))
  else:
    a1 = operand[len(operand)-1]
    operand.pop()
    a2 = operand[len(operand)-1]
    operand.pop()
    if  x == '+' :
      operand.append(a2 + a1)
    elif  x == '-':
      operand.append(a2 - a1)
    elif  x == '*':
      operand.append(a2 * a1)

print operand[0]

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

int w[42]; // 1-origin
int n;
static const int secToNum[6] = {0, 5, 7, 5, 7, 7};

bool solve(int x) {
  int sum;
  for (int sec = 1; sec <= 5; sec++) {
    sum = 0;
    while (sum < secToNum[sec]) {
      sum += w[x];
      x++;
    }
    if (sum > secToNum[sec]) {
      return false;
    }
  }
  return true;
}

int main() {
  while (1) {
    cin >> n;
    if (n == 0) {
      break;
    }

    string s;
    for (int i = 1; i <= n; i++) {
      cin >> s;
      w[i] = s.size();
    }

    for (int i = 1; i <= n; i++) {
      if (solve(i)) {
        cout << i << endl;
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3108
import sys

input = lambda :sys.stdin.readline().rstrip()

def main():
    n = int(input())
    A, B, C = [0 for _ in range(n)], [0 for _ in range(n)], [0 for _ in range(n)]
    for i in range(n):
        a, b, c = map(int, input().split())
        A[i], B[i], C[i] = a, b, c
    ans = solve(n, A, B, C)
    print(ans)


def solve(n, A, B, C):
    a, b, c = 0, 1, 2
    dp = [[0 for _ in range(3)] for _ in range(n)]
    dp[0][a], dp[0][b], dp[0][c] = A[0], B[0], C[0]
    for i in range(1, n):
        dp[i][a] = max(dp[i - 1][b], dp[i - 1][c]) + A[i]
        dp[i][b] = max(dp[i - 1][c], dp[i - 1][a]) + B[i]
        dp[i][c] = max(dp[i - 1][a], dp[i - 1][b]) + C[i]
    #print(*dp, sep = '\n')
    return max(dp[n - 1])


if __name__ == '__main__':
    main()

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

typedef long long int ll;


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

	ll i,j,t,k,l,m,n,x,y,z;

	ll a,b,c;

	cin >> a >> b >> c;
	cin >> k;

	l = 0;

	while(b <= a)
	{
		l++;
		b = b*2;
	}

	while(c <= b)
	{
		l++;
		c = c*2;
	}

	if(l <= k)
		cout << "Yes\n";
	else
		cout << "No\n";

	

	
	

}

Measured memory_bytes: 3608
n = int(input())
x = [int(i) for i in input().split()]
y,m = [],0
for i in range(1,n,2): m+=x[i]
p = sum(x)//2-m
for i in range(n):
    y.append(str(p*2))
    p = x[i]-p
print(" ".join(y))

Measured memory_bytes: 17224
import numpy as np
X, K, D = (list(map(int, input('').split(' '))))
X = np.abs(X)

if np.abs(X)/D <= K:
    new_K = K - int(X/D)
    new_X = X - D*int(X/D)
    if new_K%2==0:
        print(new_X)
    else:
        print(np.abs(new_X-D))
else:
    print(np.abs(X-D*K))

Measured memory_bytes: 27020
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << w * h / 2 << ' ' << (x == w / 2 && y == h / 2) << '\n';
}


Measured memory_bytes: 888
x = int(input())
ans = "0"

if 400 <= x <= 599:
  ans = "8"
elif 600 <= x <= 799:
  ans = "7"
elif 800 <= x <= 999:
  ans = "6"
elif 1000 <= x <= 1199:
  ans = "5"
elif 1200 <= x <= 1399:
  ans = "4"
elif 1400 <= x <= 1599:
  ans = "3"
elif 1600 <= x <= 1799:
  ans = "2"
elif 1800 <= x <= 1999:
  ans = "1"

print(ans)

Measured memory_bytes: 9188
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(){
    int a, b, c, num, eq=0;
    scanf("%d %d %d", &a, &b, &c);
    scanf("%d", &num);
    for(int i=0; i<num; ++i){
    if(a>=b && c>=a)
        b=b*2;

    else
        c=c*2;
    }
    if(b>a && c >b)
        printf("Yes");
    else    
        printf("No");
    
    ///printf("%d %d %d\n", a, b, c);
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 1720
#配点数、目標点を入力
d, g = map(int, input().split())
#問題数、ボーナスを入力
p = [0] * d
c = [0] * d
for i in range(d):
    p[i], c[i] = map(int, input().split())

min_count = 0 #最小問題数
for i in range(2 ** d):
    point = 0 #現在の得点
    count = 0 #現在の問題数
    s = bin(i)[2:].zfill(d)
    for j in range(d):
        # p_kについて2進数のk文字目が1のとき全問、0のとき0問解く
        if s[j] == "1":
            point += 100 * (j+1) * p[j] + c[j]
            count += p[j]
    #目標点を超えた場合
    if point >= g:
        #最小問題数を更新
        if min_count > count or min_count == 0:
            min_count = count
    #目標点を超えなかった場合
    else:
        #未解答中で配点が最大の問題を1問ずつ加算
        index = s.rindex("0")
        for j in range(p[index]-1):
            count += 1
            point += 100 * (index + 1)
            # 目標点を超えた場合
            if point >= g:
                # 最小問題数を更新しbreak
                if min_count > count or min_count == 0:
                    min_count = count
                break

#出力
print(min_count)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    ll neru = 60*H2+M2;
    ll okiru = 60*H1+M1;

    cout << (neru-K) - okiru<< endl;
}

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

int main() {
  
  int A , B , C;
  cin >> A;
  cin >> B;
  cin >> C;
  
  if (( A > C && C > B) || ( A < C && C < B)){
    cout << "Yes" <<endl;}
  
  else {
    cout << "No" <<endl;}}

Measured memory_bytes: 256
S = input()

def isLowerWithoutAC(s):
    l = list(s)
    l.remove('A')
    l.remove('C')
    return ''.join(l).islower()

if S[0] == 'A' and S[2:-1].count('C') == 1 and isLowerWithoutAC(S):
    print('AC')
else:
    print('WA')


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int gcd(int a,int b){//ユークリッドの互除法
  if(!(a&&b)) return max(a,b);
  while(b){
    a %= b;
    swap(a,b);
  }
  return a;
}
signed main(){
  int n;
  cin >> n;
  vi a(n);
  REP(i,n) cin >> a[i];
  //sumlは[0,i)の累積gcd
  //sumrは[i,n)の累積gcd
  vi suml(n+1,0),sumr(n+1,0);
  REP(i,n) suml[i+1] = gcd(a[i],suml[i]);
  RREP(i,n) sumr[i] = gcd(a[i],sumr[i+1]);
  int ans = 0;
  REP(i,n){
    ans = max(ans,gcd(suml[i],sumr[i+1]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
n, m, x, y = [int(x) for x in input().split()]
xlist = [int(x) for x in input().split()]
ylist = [int(x) for x in input().split()]

if max(xlist) >= min(ylist):
    print('War')
elif min(ylist) <= x or y < min(ylist):
    print('War')
else:
    print('No War')

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

const int MAX = numeric_limits<int>::max();

class Node{
public:
  int _id;
  bool _isFound;
  vector<int> _adj_index; // 隣接点のid
  vector<int> _adj_vertices;  // 隣接点との距離(重み)

  void init(int id, int n){
    _id = id;
    _isFound = false;
    for(auto i = 0; i < n; i++){
      _adj_vertices.push_back(MAX);
    }
  }
};

void inputGraph(vector<Node>& graph){
  for(auto i = 0; i < graph.size(); i++){
    graph[i].init(i, graph.size());
    for(auto j = 0; j < graph.size(); j++){
      int tmp;
      cin >> tmp;
      if(tmp != -1){
        graph[i]._adj_index.push_back(j);
        graph[i]._adj_vertices[j] = tmp;
      }
    }
  }
}

int mst(vector<Node>& graph, int search){
  auto sum = 0;
  vector<int> searched; // 木に追加済みのNodeのid
  searched.push_back(search);
  graph[searched[0]]._isFound = true;
  int minNodeIndex;

  while(searched.size() < graph.size()){
    auto compare = MAX;

    for(auto i = 0; i < searched.size(); i++){
      for(auto j = 0; j < graph[searched[i]]._adj_index.size(); j++){
//  cout << "call in for " << j << endl;
//  cout << compare << endl;
        Node searching = graph[searched[i]];
        if(!graph[searching._adj_index[j]]._isFound &&
           searching._adj_vertices[searching._adj_index[j]] < compare){
          // 木の隣接点で最短
          compare = searching._adj_vertices[searching._adj_index[j]];
          minNodeIndex = searching._adj_index[j];
 //         cout << "added" << endl;
        }
      }
    }
    if(compare != MAX){
      sum += compare;
      graph[minNodeIndex]._isFound = true;
      searched.push_back(minNodeIndex);
//      cout << endl << "minNodeIndex:" << minNodeIndex << endl;
    }

  }
  return sum;
}

int main(){
  int n;
  cin >> n;
  vector<Node> graph(n);

  inputGraph(graph);
  cout << mst(graph, 0) << endl;

  return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, pair<int, int>>> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;
 

 
 
int main(){
  long double n, k;
  cin >> n >> k;
  long double ans = 0;
  if(n < k){
  	for(long double i = 1; i <= n; i++){
      long double a = i;
      long double b = 1/n;
      while(a < k){
      	b = b * 1/2;
        a = a * 2;
      }
      ans += b;
    }
  }else{
  	ans += (n-k+1)/n;
      for(long double i = 1; i < k; i++){
      long double a = i;
      long double b = 1/n;
      while(a < k){
      	b = b * 1/2;
        a = a * 2;
      }
      ans += b;
    }
    
  }
  cout <<std::setprecision(10) << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{	int n,d,ans,nl;
 	cin>>n>>d;
 	nl=2*d+1;
 	if(n%nl==0)
    	ans=n/nl;
 	else
      	ans=n/nl+1;
 	cout<<ans;
return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int numShop = sc.nextInt();
		int numDrink = sc.nextInt();
		long sell[][] = new long[numShop][2];//price,max
		for(int i = 0; i < numShop; i ++) {
			sell[i][0] = sc.nextLong();
			sell[i][1] = sc.nextLong();
		}
		Arrays.sort(sell, (a, b) -> Long.compare(a[0], b[0]));
		long cost = 0;
		long rest = numDrink;
		for(int i = 0; i < numShop; i ++) {
			if(rest >= sell[i][1]) {
				cost += sell[i][0] * sell[i][1];
				rest -= sell[i][1];
			}else {
				cost += sell[i][0] * rest;
				break;
			}
		}
		System.out.println(cost);
	}
}

Measured memory_bytes: 94616
n=int(input())
h=list(map(int,input().split()))
dp=[0]*(n+1)
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])


Measured memory_bytes: 52208
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


const ll mod = 998244353;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll powMod(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return powMod(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

int main(){
    int N;
    cin >> N;
    cout << (N-1) / 2 << endl;

    return 0;
}




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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

ll a[16][16];
ll v[1 << 16]; // value of that submask
ll dp[1 << 16];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; read(n);
	rep(i, 0, n) rep(j, 0, n) read(a[i][j]);

	for (int b = 0; b < (1 << n); b++) {
		for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) if ((b >> i & 1) && (b >> j & 1))
			v[b] += a[i][j];
	}

	dp[0] = 0;
	for (int i = 1; i <= n; i++) for (int j = 0; j < (1 << n); j++) if (__builtin_popcount(j) == i) {
		dp[j] = v[j];
		for (int k = j; k > 0; k = (k - 1) & j) {
			chmax(dp[j], dp[j ^ k] + v[k]);
		}
	}

	write(dp[(1 << n) - 1]);
}


Measured memory_bytes: 1280
import java.io.*;
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        while (t --> 0) solver.solve(1, scan, out);
        out.close();
    }
 
    static class Task {
 
        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            int a = scan.nextInt(), b = scan.nextInt();
            out.println(a > 9 || a < 1 || b > 9 || b < 1 ? -1 : a*b);
        }
    }
 
    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
 
    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
 
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
}

Measured memory_bytes: 23380
n=int(input())
m=[]
m.append(int(input()))
count=1
for i in range(n-1):
  k=int(input())
  if k<=m[-1]:
    m.append(k)
    count+=1
  else:
    r=count-1
    l=0
    while l+1<r:
      try1=(r+l)//2
      if m[try1]>=k:
        l=try1
      else:
        r=try1
    if m[l]>=k:
      m[r]=k
    else:
      m[l]=k
print(count)

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll k,n,v[2000001],s[2000001],ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>k>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        if(i>=2)
            s[i]=s[i-1]+v[i]-v[i-1];
    }
    for(int i=1;i<=n;i++)
    {
        int next=i+1;
        if(next==n+1)
            next=1;
        int prv=i-1;
        if(prv==0)
            prv=n;
        ll d1=k-((v[i]-v[prv]+k)%k);
        ll d2=k-(v[next]-v[i]+k)%k;
        ll dst=min(d1,d2);
        if(i==1)
            ans=dst;
        else
            ans=min(ans,dst);
    }
    cout<<min(ans,k);
    return 0;
}


Measured memory_bytes: 5888
_n = gets.to_i
inputs = gets.strip.split(" ").map(&:to_i)
evens = inputs.select{|i| i.even?}
cnt = 0
while evens.length == inputs.length do
  evens = evens.map{ |e| e/2 }
  cnt += 1
  evens = evens.select{|e| e.even?}
end

puts cnt

Measured memory_bytes: 1916
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
   string s;
   cin>>s;
  if(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3])
    printf("Yes");
  else if(s[0]==s[3] && s[3]!=s[2] && s[2]==s[1])
    printf("Yes");
     else if(s[0]==s[2] && s[2]!=s[1] && s[1]==s[3])
    printf("Yes");
  else
    printf("No");
    return 0;
}

Measured memory_bytes: 3648
/*
author : seryu
title : ABC173A_"Payment"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
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; }

void solve()
{
	int n;
	cin >> n;
	n %= 1000;
	int ans = (n == 0)?0 : 1000 - n;
	cout << ans << endl;
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7, MAX = 1e9, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = 0, max_index = 0;
long long min_value = MAX, min_index = 0;
long long sum = 0;

typedef pair<int, int> Pa;
typedef long long ll;

int main() {
    cin >> A >> B;
    if(A<=8&&B<=8) cout << "Yay!";
    else cout << ":(";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int A[300][300];
int H,W,D;
typedef pair<int,int> pii;
pii points[90000];
vector<int> ans[90000];
int main()
{
    int i,j,Q;
    scanf("%d%d%d",&H,&W,&D);
    for(i=0;i<H;i++)
    {
        for(j=0;j<W;j++) scanf("%d",&A[i][j]);
    }
    for(i=0;i<H;i++)
    {
        for(j=0;j<W;j++)
            points[A[i][j]-1]=make_pair(i,j);
    }
    for(i=0;i<D;i++)
    {
        ans[i].push_back(0);
        for(j=i+D;j<H*W;j+=D)
        {
            int dist=abs(points[j].first-points[j-D].first)
                     +abs(points[j].second-points[j-D].second);
            ans[i].push_back(ans[i].back()+dist);
        }
    }
    scanf("%d",&Q);
    for(i=0;i<Q;i++)
    {
        int L,R;
        scanf("%d%d",&L,&R);
        L--;R--;
        int rem=L%D;
        int q1=L/D;
        int q2=R/D;
        printf("%d\n",ans[rem][q2]-ans[rem][q1]);
    }
    return 0;
} 

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
#define N 100010
using namespace std;
ll n,a[N],b[N],c[N],dp[N][3];
int main(){
	ll i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	memset(dp,0,sizeof(dp));
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i][0],max(dp[i-1][1],dp[i-1][2])+a[i]);
		dp[i][1]=max(dp[i][1],max(dp[i-1][0],dp[i-1][2])+b[i]);
		dp[i][2]=max(dp[i][2],max(dp[i-1][0],dp[i-1][1])+c[i]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}

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

int main() {
  int N;
  int a;
  cin >> N;
 a = 0; 
  vector<int> L(N);
for (int i = 0; i < N; i++) {
  cin >> L.at(i);
}
 sort(L.begin(), L.end());
  for (int i = 0; i < N; i++) {
  for(int j = i + 1; j < N; j++){
  for(int k = j + 1; k < N; k++){
								
  if ( L.at(i) != L.at(j)  &&  L.at(j)!= L.at(k) && L.at(k) != L.at(i) &&
      L.at(i) < L.at(j) + L.at(k) &&
      L.at(j) < L.at(i) + L.at(k) &&
      L.at(k) < L.at(i) + L.at(j) ) {
      a = a + 1;
  }
  }
  }
  }
 cout << a << endl; 
   return 0;
}


Measured memory_bytes: 3628