akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define FOR(i,a,b) for (ll i = (a) ; i <= (b); ++i)
#define RFOR(i,a,b) for (ll i = (a) ; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	int a, b, c, K, cnt=0;
	cin >> a >> b >> c >> K;

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

	if(cnt <= K) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
#define llx(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len) {char ss[len];scanf("%s",ss);(st)=ss;}
using namespace std;
long long n,m,i,j,l,r,ans1,ans2,vis[100005],pos;
struct ii
{
	long long l,r,id;
}num1[100005],num2[100005];
bool cmpr(ii x,ii y)
{
	if (x.l>y.l) return 1;
	if (x.l<y.l) return 0;
	return x.r>y.r;
}
bool cmpl(ii x,ii y)
{
	if (x.r<y.r) return 1;
	if (x.r>y.r) return 0;
	return x.l<y.l;
}
long long mve(long long x,long long y,long long &p)
{
	long long s;
	if (p>=x&&p<=y)
	{
		return 0;
	}
	if (p>y)
	{
		s=p-y;
		p=y;
		return s;
	}
	if (p<x)
	{
		s=x-p;
		p=x;
		return s;
	}
}
int main()
{
	scanf("%lld",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%lld%lld",&l,&r);
		num1[i]=num2[i]=(ii){l,r,i};
	}
	pos=0;
	memset(vis,0,sizeof(vis));
	sort(num1+1,num1+n+1,cmpr);sort(num2+1,num2+n+1,cmpl);
	i=1;j=1;
	while (i<=n&&j<=n)
	{
		while (i<=n&&vis[num1[i].id]) i++;
		if (i>n) break;
		ans1+=mve(num1[i].l,num1[i].r,pos);
		vis[num1[i].id]=1;
		while (j<=n&&vis[num2[j].id]) j++;
		if (j>n) break;
		ans1+=mve(num2[j].l,num2[j].r,pos);
		vis[num2[j].id]=1;
	}
	while (i<=n)
	{
		while (i<=n&&vis[num1[i].id]) i++;
		if (i>n) break;
		ans1+=mve(num1[i].l,num1[i].r,pos);
		vis[num1[i].id]=1;
	}
	while (j<=n)
	{
		while (j<=n&&vis[num2[j].id]) j++;
		if (j>n) break;
		ans1+=mve(num2[j].l,num2[j].r,pos);
		vis[num2[j].id]=1;
	}
	ans1+=abs(pos);
	pos=0;
	memset(vis,0,sizeof(vis));
	sort(num1+1,num1+n+1,cmpl);sort(num2+1,num2+n+1,cmpr);
	i=1;j=1;
	while (i<=n&&j<=n)
	{
		while (i<=n&&vis[num1[i].id]) i++;
		if (i>n) break;
		ans2+=mve(num1[i].l,num1[i].r,pos);
		vis[num1[i].id]=1;
		while (j<=n&&vis[num2[j].id]) j++;
		if (j>n) break;
		ans2+=mve(num2[j].l,num2[j].r,pos);
		vis[num2[j].id]=1;
	}
	while (i<=n)
	{
		while (i<=n&&vis[num1[i].id]) i++;
		if (i>n) break;
		ans2+=mve(num1[i].l,num1[i].r,pos);
		vis[num1[i].id]=1;
	}
	while (j<=n)
	{
		while (j<=n&&vis[num2[j].id]) j++;
		if (j>n) break;
		ans2+=mve(num2[j].l,num2[j].r,pos);
		vis[num2[j].id]=1;
	}
	ans2+=abs(pos);
	cout<<max(ans1,ans2);
	return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <queue>
typedef long long ll;

int main(void) {
  ll i, j, h, w, k, x1, y1, x2, y2, a, b, now, d[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
  scanf("%lld%lld%lld%lld%lld%lld%lld", &h, &w, &k, &x1, &y1, &x2, &y2);
  int dis[h][w];
  char s[h + 2][w + 10];
  for(i = 0; i < h + 2; ++i) for(j = 0; j < w + 2; ++j) s[i][j] = '@';
  for(i = 0; i < h; ++i) {
    scanf("%s", s[i + 1] + 1);
    for(j = 0; j < w; ++j) dis[i][j] = 1e9;
  }
  std::queue<ll> q;
  dis[x1 - 1][y1 - 1] = 0;
  q.push(x1 * (w + 2) + y1);
  while(q.size()) {
    a = q.front() / (w + 2), b = q.front() % (w + 2), q.pop();
    now = dis[a - 1][b - 1] + 1;
    for(j = 0; j < 4; ++j) for(i = 1; i <= k; ++i) {
      if(s[a + i * d[j][0]][b + i * d[j][1]] != '.' || dis[a + i * d[j][0] - 1][b + i * d[j][1] - 1] < now) break;
      if(dis[a + i * d[j][0] - 1][b + i * d[j][1] - 1] == 1e9) {
        dis[a + i * d[j][0] - 1][b + i * d[j][1] - 1] = now;
        if(a + i * d[j][0] == x2 && b + i * d[j][1] == y2) {
          printf("%lld", now);
          return 0;
        }
        q.push((a + i * d[j][0]) * (w + 2) + b + i * d[j][1]);
      }
    }
  }
  printf("-1");
  return 0;
}

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

typedef long long LL;
const int MAXN=1e5+5;
const int MAXM=1e5+5;
const int mod=1e9+7;
const int INF=1e9+7;

int n,x[MAXN],ans[MAXN][2];

int main(){
    scanf("%d",&n);
    int mx=-INF,mi=INF,mxp,mip;
    for(int i=1;i<=n;i++){
        scanf("%d",&x[i]);
        if (x[i]>mx){
            mx=x[i];
            mxp=i;
        }
        if (x[i]<mi){
            mi=x[i];
            mip=i;
        }
    }
    int num=0;
    if (mi<0 && mx>0){
        if (-mi<mx){
            for(int i=1;i<=n;i++){
                if (x[i]<0){
                    x[i]+=mx;
                    num++;
                    ans[num][0]=mxp;
                    ans[num][1]=i;
                }
            }
            mi+=mx;
        }
        else{
            for(int i=1;i<=n;i++){
                if (x[i]>0){
                    x[i]+=mi;
                    num++;
                    ans[num][0]=mip;
                    ans[num][1]=i;
                }
            }
            mx+=mi;
        }
    }
    if (mx<=0){
        for(int i=n-1;i>=1;i--){
            num++;
            ans[num][0]=i+1;
            ans[num][1]=i;
        }
    }
    else{
        for(int i=2;i<=n;i++){
            num++;
            ans[num][0]=i-1;
            ans[num][1]=i;
        }
    }
    printf("%d\n",num);
    for(int i=1;i<=num;i++){
        printf("%d %d\n",ans[i][0],ans[i][1]);
    }
    return 0;
}

Measured memory_bytes: 256
using System;

public class Program
{
    public static void Main()
    {
        string input = Console.ReadLine();
        string[] split = input.Split(' ');
        int length = Int32.Parse(split[0]);
        int breadth = Int32.Parse(split[1]);
        int area = length * breadth;
        int perimeter = (length + breadth) * 2;
        Console.WriteLine("{0} {1}", area, perimeter);
    }
    
}


Measured memory_bytes: 9104
#include<stdio.h>

int main(){
  int D;
  scanf(" %d", &D);
  if(D == 25)
    printf("Christmas\n");
  else if(D == 24)
    printf("Christmas Eve\n");
  else if(D == 23)
    printf("Christmas Eve Eve\n");
  else
    printf("Christmas Eve Eve Eve\n");

  return 0;
}

Measured memory_bytes: 128
import numpy as np

N, K = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
f=list(map(int,input().split()))
ff=sorted(f, reverse=True)
F=np.array(ff)
#F = np.array(sorted(list(map(int, input().split()))))
#F = F[::- 1]

left = - 1
right = 10**12

'''
l=10//F
print(A)
print(l)
print(A[A>l])
print(A[A>l].sum())
'''

def f(x):
    l = x//F
    return A[A > l].sum() <= K + l[A > l].sum()
    

 
while right - left > 1:
    mid = (left + right)//2
    if f(mid):
        right = mid
    else:
        left = mid
    
print(right)


Measured memory_bytes: 37288
package main

import (
	"fmt"
)

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)

	var result string
	if A == B {
		if B == C {
			result = "No"
		} else {
			result = "Yes"
		}
	} else if B == C {
		result = "Yes"
	} else if A == C {
		result = "Yes"
	} else {
		result = "No"
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
static const int MAX=100;
static const int INF=(1<<21);
static const int APE=0;
static const int MID=1;
static const int BOT=2;

int n, M[MAX][MAX];

int prim(){
  int u, mv, i, v, sum=0;
  int d[MAX], p[MAX], c[MAX];
  for(i=0;i<n;i++){
    d[i]=INF;
    p[i]=-1;
    c[i]=APE;
  }
  d[0]=0;

  while(1){
    mv=INF;
    u=-1;
    for(i=0;i<n;i++){
      if(mv>d[i]&&c[i]!=BOT){
        u=i;
        mv=d[i];
      }
    }
    if(u==-1)break;
    c[u]=BOT;

    for(v=0;v<n;v++){
      if(c[v]!=BOT&&M[u][v]!=INF){
        if(d[v]>M[u][v]){
          d[v]=M[u][v];
          p[v]=u;
          c[v]=MID;
        }
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=-1){
      sum+=M[i][p[i]];
    }
  }
  return sum;
}

int main(){
  int i, j, e;
  cin>>n;

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      cin>>e;
      M[i][j]=(e==-1) ? INF : e;
    }
  }
  cout<<prim()<<endl;
  return 0;
}


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

int main(){
  
  int N, A, B;
  cin >> N >> A >> B;
  
  int sum;
  
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      for(int k = 0; k < 10; k++){
        for(int l = 0; l < 10; l++){
           
   if(i + j + k + l <= B && i + j + k + l >= A && 1000 * i + 100 * j + 10 * k + l <= N){
     sum += 1000 * i + 100 * j + 10 * k + l; 
   }
          if(A == 1 && i + j + k + l == 0 && N == 10000){
            sum += 10000;
          }
        }
      }
    }
  }
  
  cout << sum << endl;
}
      
      
      
      

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

#define all(x) (x).begin(),(x).end()
#define init() \
  ios::sync_with_stdio(false); \
  cin.tie(0)

#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) {
  return a == 0 ? b
    : b == 0 ? a
    : gcd(b, a % b);
}

template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

template <long long MAX>
class CombinationCalculator {
  long long mod_;
  long long fac[MAX];
  long long finv[MAX];
  long long inv[MAX];

public:
  CombinationCalculator(long long mi = MOD): fac(), finv(), inv() {
    mod_ = mi;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i - 1] * i % mod_;
      inv[i] = mod_ - inv[mod_ % i] * (mod_ / i) % mod_;
      finv[i] = finv[i - 1] * inv[i] % mod_;
    }
  }

  long long c(long long n, long long k) const {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod_) % mod_;
  }
};

template <long long MAX = 210000>
using CC = CombinationCalculator<MAX>;

template<typename T>
T modpow(T a, T n, T mod = MOD) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template<typename T>
T modinv(T a, T m = MOD) {
    T b = m, u = 1, v = 0;
    while (b) {
        T t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main() {
  init();

  int a, p;

  cin >> a >> p;
  int k = a * 3 + p;
  cout << k / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

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

int main() {
    int n;
    cin >> n;
    unordered_map<string, int> memo;
    rep(i, n) {
        string s;
        cin >> s;  
        memo[s]++;
    }
    int ans = memo.size();
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 17648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000001ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.14159265358979323

int main() 
{
    FAST;
    ll n;
    cin>>n;
    ll a,x;
    x=LLONG_MIN;
    multiset<ll> s;
    n=powl(2,n);
    for(int i=0;i<n;i++)
    {
    	cin>>a;
    	s.insert(a);
    	x=max(x,a);
    }
    ve<ll> d;
    d.pb(x);
    auto p=s.find(x);
    s.erase(p);
    while(s.size()!=0)
    {
    	ll co=d.size();
    	for(int i=0;i<co;i++)
    	{
    		p=s.lb(d[i]);
    		if(p==s.begin())
    		{
    			cout<<"No";
    			cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    			return 0;
    		}
    		p--;
    		d.pb((*p));
    		s.erase(p);
    	}
    }
    cout<<"Yes";
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 14836
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int dp[10005];
int main(){
	int n;
	scanf("%d", &n);
	dp[0] = 1;
	for(int i = 1; i <= n; i++){
		int v;
		scanf("%d", &v);
		for(int i = 10000; i >= v; i--){
			dp[i] = max(dp[i], dp[i - v]);
		}
	}
	int ans = 0;
	for(int i = 10000; i >= 0; i--){
		if(i % 10 != 0 && dp[i]) ans = max(ans, i);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
from collections import defaultdict
import sys
sys.setrecursionlimit(1000000)

def dfs(graph, visited, x, c):
  visited[x] = c
  for nx in graph[x]:
    if visited[nx] == c:
      return False
    if visited[nx] == 0 and not dfs(graph, visited, nx, -c):
      return False
  return True


while True:
  n, m = list(map(int, input().split()))
  if n==0:
    break

  graph = defaultdict(list)
  visited = [0 for i in range(n+1)]
  for i in range(m):
    u, v = list(map(int, input().split()))
    graph[u].append(v)
    graph[v].append(u)

  f = dfs(graph, visited, 1, 1)
  if f == False:
    print(0)
  else:
    ans1, ans2 = 0, 0
    for i in range(1, n+1):
      if visited[i]>0:
        ans1 += 1
      elif visited[i]<0:
        ans2 += 1
    ans = set()
    if ans1%2==0:
      ans.add(ans1//2)
    if ans2%2==0:
      ans.add(ans2//2)
    print(len(ans))
    for e in sorted(ans):
      print(e)


Measured memory_bytes: 6424
#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<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 19;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

void solve() {
	int x; cin >> x;
	int ans = 1 + (1999 - x) / 200;
	cout << ans << "\n";
}




signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//cout << grandy(2, 3, false, false) << "\n";
	//init();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}


Measured memory_bytes: 11856
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

ll sum(ll n){
    ll ret = 1;
    rep(i, n)   ret *= 26;
    ret--;
    ret *= 26;
    ret /= 25;
    return ret;
}

ll pow(ll a, ll n){
    ll ret = 1;
    rep(i, n)   ret *= a;
    return ret;
}

int main(){
    ll n;   cin >> n;
    string s;
    ll i = 0;
    for(; !(sum(i-1) < n && n <= sum(i)); i++);
    n -= sum(i-1);
    for(; i > 0; i--){
        ll ptr = 1;
        for(; !((ptr-1)*pow(26, i-1) < n && n <= ptr*pow(26, i-1)); ptr++);
        n -= (ptr-1)*pow(26, i-1);
        s.push_back((char)('a'+ptr-1));
    }
    cout << s << endl;
}


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

int main(void) {
	int a, b, i;
	int *c;
	scanf("%d", &b);
	c = (int *)calloc(b, sizeof(int));
	for (i = 0; i < b; ++i) {
		scanf("%d", &a);
		c[i] = a;
	}
	while (--b) {
		printf("%d ", c[b]);
	}
	printf("%d\n", c[0]);
	return 0;
}

Measured memory_bytes: 608
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 黒のマスを代表する文字 */
	private static final char BLACK = '#';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt(), w = scanner.nextInt(), k = scanner.nextInt();
			boolean[][] c = new boolean[h][w];
			IntStream.range(0, h).forEach(i -> {
				char[] ci = scanner.next().toCharArray();
				IntStream.range(0, w).forEach(j -> c[i][j] = (BLACK == ci[j]));
			});
			System.out.println(IntStream
					.range(0, 1 << (h + w)).filter(
							i -> k == IntStream.range(0, h).filter(j -> 0 == (i & (1 << j)))
									.map(j -> (int) IntStream.range(0, w)
											.filter(l -> (0 == (i & (1 << (l + h))) && c[j][l])).count())
									.sum())
					.count());
		}
	}
}


Measured memory_bytes: 44824
#include<bits/stdc++.h>
using namespace std;
int dp[2100][2100],a[2100],b[2100],c1[2100][2100],c2[2100][2100];
int main(){
	  int n,m,i,j,k,x;
	  char ch;
	  cin>>n;
	  for(i=1;i<=2*n;i++){
	  	 cin>>ch>>x;
	  	 if(ch=='B'){
	  	 	a[x]=i;
	  	 }else {
	  	 	b[x]=i;
	  	 }
	  }
	  for(i=1;i<=n;i++){
	  	 for(j=1;j<i;j++)
	  	    if(a[i]<a[j])c1[i][0]++;
	  	 for(j=1;j<=n;j++){
	  	 	c1[i][j]=c1[i][j-1];
	  	 	if(b[j]>a[i])c1[i][j]++; 
	  	 }
	  }
	  for(i=1;i<=n;i++){
	  	 for(j=1;j<i;j++)
	  	    if(b[i]<b[j])c2[0][i]++;
	  	 for(j=1;j<=n;j++){
	  	 	c2[j][i]=c2[j-1][i];
	  	 	if(a[j]>b[i])c2[j][i]++;
	  	 }
	  }
	  int wh1=0,wh2=0;
	  for(i=1;i<=n;i++){
	  	 wh1+=c1[i][0];
	  	 wh2+=c2[0][i];
	  	 dp[i][0]=wh1;
	  	 dp[0][i]=wh2;
	  }
	  for(i=1;i<=n;i++)
	     for(j=1;j<=n;j++)
	        dp[i][j]=min(dp[i-1][j]+c1[i][j],dp[i][j-1]+c2[i][j]);
	  cout<<dp[n][n]<<endl;
	  return 0;
}

Measured memory_bytes: 51456
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    int n;
    cin>>n;
    int a[n];int c=0;
    ll ans=1;
    REP(i,n)
    {
        cin>>a[i];
        if(a[i]&1){ans*=1;}
        else
        {
            ans*=2;
        }
    }
    cout<<binpow(3,n)-ans;

  }  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

public class a{
 static void Main(){
   var misaki = Console.ReadLine();
   int count = 0;
   for(int i=0; i< misaki.Length;i++){
    if(misaki.Count(x=>x==misaki[i])==2){
     count++;
   }
  }
   Console.WriteLine(count==4?"Yes":"No");
 }
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n, w;
    cin >> n >> w;
    const int N = (int)1e5 + 5;
    vector<int> v(N, M);
    v[0] = 0;
    for(int j=0;j<n;j++)
    {
        int a, b;
        cin >> a >> b;
        for(int i=N-1;i>=0;i--)
        {
            if(v[i] != M and v[i] + a <= w and i+b < N)
            {
                v[i+b] = min(v[i] + a, v[i+b]);
            }
        }
    }
    for(int i=N-1;i>=0;i--)
    {
        if(v[i] != M)
        {
            cout << i << "\n";
            return 0;
        }
    }
    cout << "0\n";
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int main() {
    int N; cin >> N;
    ll sum = 0;
    ll mn = INF;
    int odd = 0;
    for(int i=0; i<N; i++){
        int a; cin >> a;
        sum += abs(a);
        if(a<0) odd++;
        mn = min(mn, (ll)abs(a));
    }
    
    if(odd%2==0) cout << sum << endl;
    else cout << sum - 2 *mn << endl;
    
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
  sc.Scan()
  return sc.Text()
}


func main()  {
  line := nextLine()
  s := strings.Split(line, " ")
  if s[0] == "H" {
    fmt.Println(s[1])
  } else {
    if s[1] == "H" {
      fmt.Println("D")
    } else {
      fmt.Println("H")
    }
  }
}


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

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s, t, u; cin >> s >> t >> u;
	cout << s[0] << t[0] << u[0] << endl;

	return 0;
}

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

int main() {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes";
	} 
	else
	{
		cout << "No";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e12;
const int MOD = 1e9 + 7;

int N;
ll h[100001];
ll dp[100001];

ll rec(int n){
    if(dp[n] != -1){
        return dp[n];
    }
    if(n == 0){
        return 0;
    }
    ll res = INF;
    res = min(res, rec(n - 1) + abs(h[n] - h[n - 1]));
    if(n > 1){
        res = min(res, rec(n - 2) + abs(h[n] - h[n - 2]));
    }
    return dp[n] = res;
}

signed main(){
    cin >> N;
    REP(i,N){
        cin >> h[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << rec(N - 1) << endl;
}

Measured memory_bytes: 4992
using System;

class ITP1_2_C {
    public static void Main() {
        string[] Input = Console.ReadLine().Split(' ');

        int a = int.Parse(Input[0]);
        int b = int.Parse(Input[1]);
        int c = int.Parse(Input[2]);

        int tmp = 0;

        if (a > b) {
            tmp = a;
            a = b;
            b = tmp;
        }
        if (b > c)
        {
            tmp = b;
            b = c;
            c = tmp;
        }
        if (a > b)
        {
            tmp = a;
            a = b;
            b = tmp;
        }

        Console.WriteLine(a + " " + b + " " + c);
    }
}

Measured memory_bytes: 9096
h,w = map(int,input().split())
maze = [["#"]*(w+2)]+[["#"]+list(input())+["#"] for _ in range(h)]+[["#"]*(w+2)]
import copy

def f(i,j):
  arr = []
  if done[i][j+1] == 0 and maze[i][j+1] == ".":
    arr.append([i,j+1])
    done[i][j+1] = 1
  if done[i][j-1] == 0 and maze[i][j-1] == ".":
    arr.append([i,j-1])
    done[i][j-1] = 1
  if done[i+1][j] == 0 and maze[i+1][j] == ".":
    arr.append([i+1,j])
    done[i+1][j] = 1
  if done[i-1][j] == 0 and maze[i-1][j] == ".":
    arr.append([i-1,j])
    done[i-1][j] = 1
  return arr

ans = 0
#print(maze)
for i in range(1,h+1):
  for  j in range(1,w+1):
    if maze[i][j] == "#":
      continue
    done = [[1]*(w+2)]+[[1]+[0]*w +[1] for _ in range(h)]+[[1]*(w+2)]
    next_wait = [[i,j]]
    done[i][j] = 1
    cnt = 0
    while next_wait:
      wait = copy.copy(next_wait)
      next_wait = []
      #print(wait)
      while wait:
        now = wait.pop()
        next_wait += f(now[0],now[1])
      cnt += 1
    ans = max(ans,cnt)
print(max(0,ans-1))

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

#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)                                      \
  cout << #v << ":";                                      \
  for (int i = 0; i < v.size(); i++) cout << " " << v[i]; \
  cout << endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int> >
#define vll vector<vector<ll> >
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
const int inf = 1000000001;
const ll INF = 1e18;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout << setprecision(15) << fixed << p << endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main() {
  vs c(2);
  cin>>c[0]>>c[1];
  for (int i = 0; i < 3; i++) {
    if(c[0][i] != c[1][2-i]) {
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}


Measured memory_bytes: 256
l = [0,0,0,0]
for i in range(int(input())):
  data  = input()
  if data == 'AC':
    l[0] += 1
  elif data == 'WA':
    l[1] += 1
  elif data == 'TLE':
    l[2] += 1
  else:
    l[3] += 1
print('AC x {}'.format(l[0]))
print('WA x {}'.format(l[1]))
print('TLE x {}'.format(l[2]))
print('RE x {}'.format(l[3]))

Measured memory_bytes: 9208
#include <cstdio>


void print_sharp_dot(int h, int w)
{
	int i,j;

	for (i = 0; i < h; i++) {
		if (i == 0 || i == (h-1)) {
			for (j = 0; j < w; j++)
				printf("#");
		} else {
			for (j = 0; j < w; j++) {
				if (j == 0)
					printf("#");
				else if (j != (w-1))
					printf(".");
				else if (j == (w-1)) {
					printf("#");
				}
			}
		}

		printf("\n");
	}
}

int main()
{
	int h,w;

	while (true) {
		scanf("%d %d", &h, &w);

		if (h == 0 && w == 0)
			break;

		print_sharp_dot(h, w);

		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2552
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int H, W;
string S[12], T[12], R[12];
int nums=0;

void hoge(){
    set<string> U;
    int left=0;
    rep(x,W){
        if(U.count(R[x])){
            U.erase(R[x]);
        }else{
            U.insert(T[x]);
        }
    }
    
    if(U.empty()){
        cout1("YES");
        exit(0);
    }
    if(U.size()==1){
        string s=*U.begin();
        string t=s;
        reverse(all(s));
        if(t==s){
            cout1("YES");
            exit(0);
        }
    }
}

void add(int l){
    rep(x,W){
        T[x].push_back(S[l][x]);
        R[x][H-T[x].size()]=S[l][x];
    }
}

void del(){
    rep(x,W) T[x].pop_back();
}

void dfs(int mask,int last){
    if(__builtin_popcount(mask)>=(H+1)/2){
        int num=0;
        rep(i,H){
            if((mask&(1<<i))==0){
                num++;
                add(i);
            }
        }
        hoge();
        rep(i,num) del();
        return;
    }
    rep(i,H) if((mask&(1<<i))==0){
        add(i);
        dfs(mask^(1<<i),i);
        del();
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>H>>W;
    rep(x,W) R[x].resize(H);
    rep(i,H) cin>>S[i];
    vector<int> V;
    dfs(0,-1);
    cout1("NO");
}

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

ans = 0
for i in range(1, n - 1 ):
  l=[p[i-1], p[i], p[i+1]]
  if ((max(l) != p[i]) and (min(l) != p[i])):
      ans+=1

print(ans)

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define vi vector<int>

#define ll long long
#define vl vector<ll>
#define vll vector<vl>

const int INF = 1e9;

ll mod=1000000007;

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,p,q,k,s[99],e[99],a,b,cm,ans,prev,sum;
	while(cin>>n>>p>>q,n){
		p=p/100*60+p%100,q=q/100*60+q%100;sum=0;
		rep(j,n){
			cin>>k;
			rep(i,k)cin>>a>>b,s[sum+i]=a/100*60+a%100,e[sum+i]=b/100*60+b%100;
			sum+=k;
		}
		sort(s,s+sum);sort(e,e+sum);
		cm=0;ans=0;prev=p;
		for(int si=0,ei=0;si<sum||ei<sum;){
			if(si<sum&&s[si]<e[ei]){
				cm++;
				if(cm==n&&ans<s[si]-prev)ans=s[si]-prev;
				si++;
			}else{
				cm--;if(cm==n-1)prev=e[ei];ei++;
			}
		}
		if(ans<q-prev)ans=q-prev;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

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

    ll r = 0;
    int j = 0, s = 0;
    for (int i = 0; i < n; i++) {
        for (; j < n; j++) {
            if (s & a[j]) break;
            s ^= a[j];
        }
        r += j - i;
        s ^= a[i];
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),ans;
        int[] p = new int[n];
        int[] q = new int[n];
        for(int i = 0;i < n;i++){
            p[i] = sc.nextInt();
        }
        for(int i = 0;i < n;i++)
            q[i] = sc.nextInt();
        ans = Math.abs(rank(p) - rank(q));
        System.out.println(ans);

    }

    static int rank(int[] array){
        int ret = 0;
        int len = array.length;
        for(int i = 0;i < len-1;i++){
            int add = 0;
            for(int j = i + 1;j < len;j++){
                if(array[i] > array[j])
                    add++;
            }
            ret += add;
            ret *= (len - i -1);
        }
        return ret;
    }
}

Measured memory_bytes: 21844
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll X;
    cin >> X;
    ll ans = 1;
    ll sum = ans * (ans + 1) / 2;
    while (sum < X)
    {
        ans++;
        sum += ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
    vector<int> vec;
    int n, k;
    REP(i,3){
        cin >> n;
        vec.push_back(n);
    }
    cin >> k;
    REP(i,k)*max_element(ALL(vec))*=2;
    cout << SUM(vec) <<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int ma = 1e7;
main()
{
    vector< bool > is_prime(ma,1);
    is_prime[0] = is_prime[1] = 0;
    for( int i = 0; i < ma; i++ )
    {
        if( is_prime[i] )
        {
            for( int j = 2; i*j < ma; j++ )
            {
                is_prime[i*j] = 0;
            }
        }
    }
    int n;
    while( cin >> n, n )
    {
        for( int i = n; i >= 0; i-- )
        {
            if( is_prime[i] && is_prime[i - 2] && is_prime[i - 6] && is_prime[i - 8])
            {
                cout << i << endl;
                break;
            }
        }
    }    
    return 0;
}


Measured memory_bytes: 3976
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Long a = sc.nextLong();
        int h =  (int) Math.floor(a / 60 / 60);
        int hh = (int) (a - (h * 60 * 60));
        int m = (int) Math.floor(hh / 60);
        int s = (int) (a - (h * 60 * 60) - (m * 60));
        System.out.println(h + ":" + m + ":" + s );

    }

}


Measured memory_bytes: 26168
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; string S; cin >> N >> S;
    int M = S.length();
    vector<char> C(52, '0');
    for (int i = 0; i < 26; ++i) {
        C[i] = (char)i + 65;
    }
    for (int i = 0; i < 26; ++i) {
        C[i + 26] = (char)i + 65;
    }

    for (int i = 0; i < M; ++i) {
        int x = (char)S[i] - 65;
        S[i] = C[x + N];
    }
    cout << S << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 5

int main(void){
    int cooktime[N], totaltime = 0, minfrac = -1;
    int i;
    for(i=0; i<N; i++){
        scanf("%d", &cooktime[i]);
        getchar();

        if(cooktime[i]%10 == 0){
            totaltime += cooktime[i];
        }else if(minfrac == -1){
            minfrac = cooktime[i]%10;
            totaltime += cooktime[i] - minfrac;
        }else if(cooktime[i]%10 < minfrac){
            totaltime += 10;
            minfrac = cooktime[i]%10;
            totaltime += cooktime[i] - minfrac;
        }else {
            totaltime += (cooktime[i]/10 + 1)*10;
        }
    }
    if(minfrac != -1) totaltime += minfrac;
    printf("%d", totaltime);

    return 0;
}

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

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n,k;
string s;
ll fac[10000007];
//<<-----Implemen;t Functions Here---->>//
ll mult(ll a,ll b){return (a*b)%MOD;}
ll add(ll a,ll b){return (a+b)%MOD;}
ll sub(ll a,ll b){return (a-b+MOD)%MOD;}
ll fastpow(ll x,ll y)  
{  
    ll res = 1;     x = x % MOD; 
  	if (x == 0) return 0; ; 
 	while (y > 0)  
    {  
      
        if(y&1)res = (res*x) % MOD; 
        y = y>>1;x = (x*x) % MOD;  
    }  
    return res;  
}  
ll fastmod(ll x){
    ll res=1;
    ll y=MOD-2;
    while(y){
        if(y&1)res=mult(res,x);
        y>>=1;x=mult(x,x);
    }
    return res;
}


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>k>>s;
		n = s.size()+k;
		ll tot = fastpow(26,n);
		ll len1 = s.size();
		//overcount
		ll ans = 0;
		for(ll m=0;m<len1;m++)
		{
			ll ncm = mult(fac[n],fastmod(mult(fac[n-m],fac[m])));
			ll other = fastpow(25,n-m);
			ans = add(ans,mult(ncm,other));
		}
		cout<<sub(tot,ans)<<endl;

}

int main(){
	fastio;randomINIT;
	fac[0] = 1;
	for(ll i=1;i<=10000000;i++)fac[i] = (fac[i-1]*i)%MOD;
	//cin>>t;
	while(t--){
		MAIN();
	}

   
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 10;

int p[N], l[N];

void solve() {
  int n, a, b, c; scanf("%d%d%d%d", &n, &a, &b, &c);
  for (int i = 0; i < n; ++i) scanf("%d", l+i);
  int ans = 1e9;
  for (int i = 0, lmt = 1 << (n*2); i < lmt; ++i) {
    int h[4] = {0};
    int z[4] = {0};
    int cur = 0;
    for (int x = i, j = 0; j < n; ++j) {
      p[j] = x%4;
      x /= 4;
      ++h[p[j]];
      if (p[j] == 3) continue;
      cur += 10;
      z[p[j]] += l[j];
    }
    if (!h[0] || !h[1] || !h[2]) continue;
    ans = min(ans, cur+abs(a-z[0])+abs(b-z[1])+abs(c-z[2])-30);
  }
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3832
#coding: utf-8   
while 1:
    try:
        v = input()
        h = input()
        n = range(1, v+1)
        for i in xrange(h):
            vl = map(int, raw_input().split(","))
            n[vl[0]-1], n[vl[1]-1] = n[vl[1]-1], n[vl[0]-1]
        for i in xrange(v):
            print n[i]
            
    except EOFError:
        break

Measured memory_bytes: 52000
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;


const int MAX = 105;
const int SIZE = 1e6;

int main(){
  
    int n;
    cin >> n;
    vector <int> v(SIZE,0);
    for (int i = 1; i <= MAX; ++i){
        for (int j = 1; j <= MAX; ++j){
            for (int k = 1; k <= MAX; ++k){
                if (i*i + k*k + j*j + i*j + i*k + j*k <= 10001)
                v[i*i + k*k + j*j + i*j + i*k + j*k]++;
                
            }
        }
    }
    for (int i = 1; i <= n; ++i) cout << v[i] << endl;


}

Measured memory_bytes: 6668
#include<iostream>
#include<string>

using namespace std;

int main(){
    string s;
    int n;
    cin >> s;
    if(s == "SUN") n = 7;
    else if(s == "SAT") n = 1;
    else if(s == "MON") n = 6;
    else if(s == "TUE") n = 5;
    else if(s == "WED") n = 4;
    else if(s == "THU") n = 3;
    else if(s == "FRI") n = 2; 
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
//Name-Deepesh Bhatt
//Institute-IIT Dhanbad

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

ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a ,ll b)
{
    return a/gcd(a,b)*b;
}
ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
ll combination(ll x)
{
    if(x==0||x==1)
        return 0;
    return (x*(x-1))/2;
}
int main()
{
    ios_base::sync_with_stdio(false);    //for fast I/O operation
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
    return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		string s; cin>>s;
		map<char,int> f;
		for(char c:s) f[c]++;
		ll res=1;
		for(auto p:f)
			(res*=p.second+1)%=MOD;
		cout<<res-1<<endl;
	}
}


Measured memory_bytes: 512