akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

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

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func main() {
	W := oneInt()
	H := oneInt()
	x := oneInt()
	y := oneInt()

	ww := float64(W)
	hh := float64(H)

	var j int
	if x*2 == W && y*2 == H {
		j = 1
	}
	fmt.Printf("%f %v", ww*hh/2.0, j)
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>

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

using namespace std;
int a;
int b[2000];

int main(){
  cin >> a;
  REP(i,a) cin >> b[i];
  sort(b,b+a);
  reverse(b,b+a);
  int wa=0;
  REP(i,a-1) wa += b[i+1];
  if(wa > b[0]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

const int maxn=50005;
const int maxm=100005;
int n,m,T;
int x[maxm],y[maxm];
char s1[maxm],s2[maxm];
bitset<maxn>b[maxn],tot,cur;
set<int>now;
vector<int>diff;
pair<int,int>ans1,ans2;

int main(){
	scanf("%d%d%d",&n,&m,&T);
	for(int i=1;i<=m;i++)scanf("%d%d",&x[i],&y[i]);
	if(T==1){
		for(int i=1;i<=n;i++)b[i][i]=tot[i]=1;
		for(int i=m;i>=1;i--){
			b[x[i]]|=b[y[i]];
			b[y[i]]|=b[x[i]];
		}
		for(int i=1;i<=n;i++)tot&=b[i];
		for(int i=1;i<=n;i++)if(tot[i]){
			cur[i]=1;
			for(int j=m;j>=1;j--){
				if(cur[x[j]])s1[j]='^',cur[y[j]]=1;
				else if(cur[y[j]])s1[j]='v',cur[x[j]]=1;
				else s1[j]='^';
			}
			printf("%s\n",s1+1);
			return 0;
		}
		puts("-1");
	}
	else{
		if(n==2){
			puts("-1");
			return 0;
		}
		for(int i=1;i<=n;i++)now.insert(i);
		for(int i=1;i<=m;i++){
			if(!now.count(x[i])){
				s1[i]=s2[i]='v';
				continue;
			}
			if(!now.count(y[i])){
				s1[i]=s2[i]='^';
				continue;
			}
			if(int(now.size())>3){
				s1[i]=s2[i]='^';
				now.insert(x[i]);
				now.erase(now.find(y[i]));
			}
			else if(ans1.first==0){
				int c;
				for(set<int>::iterator it=now.begin();it!=now.end();it++)
					if((*it)!=x[i]&&(*it)!=y[i])c=(*it);
				diff.push_back(i); 
				ans1=make_pair(x[i],c);
				if(ans1.first>ans1.second)swap(ans1.first,ans1.second);
				s1[i]='^';
				ans2=make_pair(y[i],c);
				if(ans2.first>ans2.second)swap(ans2.first,ans2.second);
				s2[i]='v';
			}
			else{
				if(x[i]==ans1.first&&y[i]==ans1.second){
					for(int j=0;j<int(diff.size());j++)s1[diff[j]]=s2[diff[j]];
					diff.clear();
					int a,b,c;
					if(x[i]==ans2.first)a=x[i],b=y[i],c=ans2.second;
					else if(x[i]==ans2.second)a=x[i],b=y[i],c=ans2.first;
					else if(y[i]==ans2.first)a=y[i],b=x[i],c=ans2.second;
					else a=y[i],b=x[i],c=ans2.first;
					if(a==x[i])s2[i]='^',s1[i]='v';
					else s2[i]='v',s1[i]='^';
					ans1=make_pair(b,c);
					if(ans1.first>ans1.second)swap(ans1.first,ans1.second);
					now.clear();
					now.insert(a);now.insert(b);now.insert(c);
				}
				else if(x[i]==ans2.first&&y[i]==ans2.second){
					for(int j=0;j<int(diff.size());j++)s2[diff[j]]=s1[diff[j]];
					diff.clear();
					int a,b,c;
					if(x[i]==ans1.first)a=x[i],b=y[i],c=ans1.second;
					else if(x[i]==ans1.second)a=x[i],b=y[i],c=ans1.first;
					else if(y[i]==ans1.first)a=y[i],b=x[i],c=ans1.second;
					else a=y[i],b=x[i],c=ans1.first;
					if(a==x[i])s1[i]='^',s2[i]='v';
					else s1[i]='v',s2[i]='^';
					ans2=make_pair(b,c);
					if(ans2.first>ans2.second)swap(ans2.first,ans2.second);
					now.clear();
					now.insert(a);now.insert(b);now.insert(c);
				}
				else{
					if(x[i]==ans1.first||x[i]==ans1.second)s1[i]='^';
					else s1[i]='v';
					if(x[i]==ans2.first||x[i]==ans2.second)s2[i]='^';
					else s2[i]='v';
				}
				diff.push_back(i);
			}
		}
		printf("%s\n",s1+1);
	}
	return 0;
}

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

#define int long long
const int MOD=998244353;
int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)(res*=n)%=MOD;
    (n*=n)%=MOD;
    k>>=1;
  }
  return res;
}
int blo[450],wa[450],s[223456],K[450];

signed main(){
  int n,q;cin>>n>>q;
  for(int i=0,tmp=0;i<n;i++){
    s[i]=1;
    tmp=((tmp*10)+1)%MOD;
    if(i%450==449||i==n-1){
      blo[i/450]=tmp;
      tmp=0;
    }
  }
  K[0]=1;
  for(int i=1;i<450;i++)K[i]=(K[i-1]*10)%MOD;
  const int A=pw(10,450);
  const int C=(A-1)*pw(9,MOD-2)%MOD;
  while(q--){
    int l,r,d;cin>>l>>r>>d;
    l=n-l+1,r=n-r;swap(l,r);
    int res=0;
    for(int i=0,CC=1;i<450;i++){
      if(l<=i*450&&(i+1)*450<=r){
        wa[i]=d;
        blo[i]=C*d;
      }
      else if((i*450<=l&&l<(i+1)*450)||(i*450<r&&r<=(i+1)*450)){
        int tmp=0;
        for(int j=i*450,t=0;j<(i+1)*450;j++,t++){
          if(wa[i])s[j]=wa[i];
          if(l<=j&&j<r)s[j]=d;
          tmp=(tmp+s[j]*K[t])%MOD;
        }
        blo[i]=tmp;
        wa[i]=0;
      }
      res=(res+blo[i]*CC)%MOD;
      (CC*=A)%=MOD;
    }
    cout<<res<<endl;
  }
}


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

int main() {
  int n = 9;
  vector<char> vec(9);
  for(int i = 0;i<9;i++){
    cin >> vec.at(i);
    if(i == 0|| i==4 || i== 8){
      cout << vec.at(i);
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
/*
 * I won't be broken
 * I won't be tortured
 * I won't be beaten down
 * I have the answer
 * I can take the pressure
 * I will turn it all around
 * Lift me up above this
 * The flames and the ashes
 * Lift me up and help me to fly away
*/
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main(){
        scanf("%d%d",&a,&b);
        if(a*b%2)
                printf("Odd\n");
        else
                printf("Even\n");
        return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll a, b;

int main()
{
  std::cin >> a >> b;

  puts( (a*b)&1 ? "Odd" : "Even" );

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int A, B, C;
    cin >> A >> B>>C;
    
    string ans="Yes";
    if(A+B<C) ans="No";


    cout << ans << endl;

   return 0;
}

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

using namespace std;

using ll = long long;

int main(){
  ll n;
  cin >> n;
  cin.ignore();

  vector <ll> h;

  ll tmp;

  for(ll i = 0; i < n; i++){
    cin >> tmp;
    h.push_back(tmp);

  }

  if(n == 1){
    cout << "Yes" << endl;
    return 0;
  }

  h[0] -= 1;
  
  for (ll i = 0; i < n - 1; i++){
    tmp = h[i];
    if(h[i + 1] > tmp){
      h[i+1] -= 1;
    }
    if(h[i + 1] < tmp){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,ll,ll> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> P;
ll n,m,combs[100100][55];
vector<ll> primes;
int pows[100100];
ll ans=1;
ll combsinit(ll num)
{
  memset(combs,0,sizeof(combs));
  combs[0][0]=1;
  for(ll i=1;i<=num;i++)
    {
      combs[i][0]=1;
      for(ll j=1;j<=50;j++)
	{
	  combs[i][j]=(combs[i-1][j-1]+combs[i-1][j])%MOD;
	}
    }
  return 0;
}

void Primes(ll num)
{
  for(ll i=2;i*i<=num;i++)
    {
      ll cnt=0;
      while(num%i==0)
	{
	  num/=i;
	  cnt++;
	}
      if(cnt)
	{
	  ans*=combs[n-1+cnt][cnt];
	  ans%=MOD;
	}
    }
  if(num>1)
    {
      ans*=n;
      ans%=MOD;
    }
}

int main(int argc,char const* argv[])
{
  cin >> n >> m;
  combsinit(n+50);
  Primes(m);
  cout << ans << endl;
  return 0;
}



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

using namespace std;

int main(){
   string s;
   int k = 0;

   cin>>s;
    int n = (int)s.size();
   if(n%2 == 0){
     for (int i = 0; i < n/2; i++)
     {
         if(s[i] != s[n-i-1]) k++;
     }}
     else{
        for (int i = 0; i < n/2; i++){
         if(s[i] != s[n-i-1]) k++;
     }   
   }
    cout<<k<<"\n";
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  if((s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(0) != s.at(2)) || (s.at(0) == s.at(2) && s.at(1) == s.at(3) && s.at(0) != s.at(1)) || (s.at(0) == s.at(3) && s.at(1) == s.at(2) && s.at(0) != s.at(1)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using namespace  std;

int n,k;
ll res;

int main() {
    cin>>n>>k;
    if (k==0) cout<<1ll*n*n;
    else {
        for (int b=k+1;b<=n;b++) res+=(b-k)*(n/b) + max(n%b-k+1,0);
        cout<<res;
    }
}


Measured memory_bytes: 256
#include <iostream>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define endl '\n'
const int INF = (1 << 30);
using namespace std;
typedef long long int ll;

void solve(){
    int n, a, b;
    cin >> n >> a >> b;
    int rank=0, frank=1;
    REP(i,n){
        char c;
        cin >> c;
        if(c == 'c'){
            cout << "No" << endl;
        }
        else if(c == 'b')
        {
            if(rank < (a+b) && frank <= b){
                cout << "Yes" << endl;
                rank++;
            frank++;
            }else{
            cout << "No" << endl;
            }
        }
        else{
            if(rank < (a+b) ){
                cout << "Yes" << endl;
            rank ++;
            }else{
            cout << "No" << endl;
            }
        }
    }
}

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

    solve();
}


Measured memory_bytes: 640
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, K);
    IN(string, S);
    if (S.size() <= K)
    {
        OUT(S);
    }
    else
    {
        OUT(S.substr(0, K) + "...");
    }
}

Measured memory_bytes: 3640
def theater():
    total = 0
    try:
        N = int(input())
        l_r = (list(map(lambda x: int(x), input().split(' '))) for elem in range(N))
    except:
        return
    if not (1 <= N and N <= 1000): return
    for l, r in l_r:
        if 1 <= l and l <= 100000 or 1 <= r and r <= 100000:
            total += r - l + 1
        else:
            return
    print(total)

if __name__ == "__main__":
    theater()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  int a,b,c;
  long long k;
  cin>>a>>b>>c>>k;
  int ans;
  if(k%2 == 0){
    ans = a-b;
  }else{
    ans = b-a;
  }
  cout<<ans<<endl;
  return 0; 
}


Measured memory_bytes: 256
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}

import Debug.Trace
import Data.Maybe
import qualified Data.IntSet as S
import qualified Data.List as L
import qualified Data.IntMap as M
import qualified Data.ByteString.Char8 as B
import qualified Data.Foldable as F

type Index = Int
type StartPoints = S.IntSet
type Board = (M.IntMap B.ByteString)
type Memo = (M.IntMap (M.IntMap Int))
type Point = (Index, Index)

d = [(-1, 0), (1, 0), (0, -1), (0, 1)]

toI (y, x) = y * 1000 + x
fromI p = (floor(fromIntegral p / 1000), p `mod` 1000)

bfs b k p@(sy, sx) h w = toStartPoints queue
  where
    inner (y, x) = not (y < 0 || y >= h || x < 0 || x >= w)
    walk _ _ 0 _ = []
    walk b visited m ((k', (y, x)) : q) =
      let
        ok p k' = not (S.member (toI p) visited || v b p /= '.' || k' == 0)
        nexts = map (\(dy, dx) -> (y + dy, x + dx)) d
        neighbors = [(k'-1, p) | p <- nexts, inner p, ok p k']
        visited' = L.foldl' (\z (_, p) -> S.insert (toI p) z) visited neighbors
        m' = m + length neighbors - 1
      in
        neighbors ++ walk b visited' m' q
    queue = (k, p) : walk b (S.fromList [toI (sy, sx)]) 1 queue
    toStartPoints q = S.fromList (map (\(_, p) -> toI p) q)


listStart :: Board -> Int -> Int -> Int -> StartPoints
listStart b k = bfs b k s
  where s = find b 'S'

solve :: [B.ByteString] -> Int
solve (xs:xss) = 1 + ceiling (fromIntegral m / fromIntegral k)
  where
    [h, w, k] = map readInt $ B.words xs
    b = M.fromList $ zip [0..] xss
    s = listStart b k h w
    m = S.foldl' (\z p -> let (y,x) = fromI p
                          in min z (minimum [y, x, h-y-1, w-x-1])) 1000000000 s

readInt = fst . fromJust . B.readInt
main = B.getContents >>= print . solve .  B.lines

--------------------------------------------------
-- Matrix
--------------------------------------------------
class (Show a) => Matrix a b | a -> b, b -> a where
   v :: a -> (Int, Int) -> b
   find :: a -> b -> (Int, Int)
   findAll :: a -> b -> [(Int, Int)]
   update :: a -> Int -> Int -> b -> a
   initMat :: Int -> Int -> b -> a

instance Matrix Memo Int where
  v b (i, j) = (b M.! i) M.! j
  update b i j c = M.update (Just . M.update (\x -> Just c) j) i b
  initMat i j c = M.fromList $ zip [0..(i-1)] $ L.replicate i xs
    where xs = M.fromList $ zip [0..(j-1)] $ L.replicate j c
  findAll b c = concatMap (\(y, xs) -> zip [y, y..] xs) $ M.toList $ M.map (map fst . M.toList . M.filter (== c)) b

instance Matrix Board Char where
  v b (i, j) = B.index (b M.! i) j
  find b c = head tmp3
    where
      tmp = M.map (B.elemIndex c) b
      tmp2 = M.filterWithKey (\i x -> isJust x) tmp
      tmp3 = map (\(i, x) -> (i, fromJust x)) (M.toList tmp2)
  update b i j c = M.update (Just . replace) i b
    where
      replace x = B.append (B.take j x) $ B.cons c (B.drop (j+1) x)

pp b d = M.foldl' (\z' xs -> z' ++ M.foldl' (\z y -> z ++ (if y == d then "x" else show y)) "" xs ++ " ") "" b


Measured memory_bytes: 6524
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}

int main(){
    ll n,a;
    cin >> n >> a;
    n%=500;
    if (n<=a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
	int m, f, r;
	cin >> m >> f >> r;
	while(m != -1 || f != -1 || r != -1) {
		if(m == -1 || f == -1) {
			cout << "F" << endl;
		}
		else if(m + f >= 80) {
			cout << "A" << endl;
		}
		else if(m + f >= 65) {
			cout << "B" << endl;
		}
		else if(m + f >= 50) {
			cout << "C" << endl;
		}
		else if(m + f >= 30) {
			if(r >= 50) {
				cout << "C" << endl;
			}
			else {
				cout << "D" << endl;
			}
		}
		else {
			cout << "F" << endl;
		}
		cin >> m >> f >> r;
	}
}


Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin

#define lset(h, n) memset(h, n, sizeof(h));
    

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    int n;
    cin >> n;

    int h[n];
    rep(i,n) cin >> h[i];
    
    int cnt=0;
    int ans=0;
    rep(i,n){
        if(i==n-1){
            ans = max(ans,cnt);
            break;
        }
        ans = max(ans,cnt);
       if(h[i] >= h[i+1]) {
            cnt++; 
       }else{
            ans = max(ans,cnt);
            cnt=0;
       }
    }
    pri(ans);



    return 0;
}



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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    int n; cin >> n;
    vll a(n+1);
    REP(i, n+1) cin >> a[i];

    vll b = a;
    RREP(i, n) {
        b[i] += b[i+1] / 2;
        b[i+1] %= 2;
    }
    if (b[0] > 1 or (b[0] == 1 and accumulate(ALL(b), 0ll) > 1)) {
        cout << -1 << endl;
        return 0;
    }

    vll s(n+2);
    RREP(i, n+1) s[i] = s[i+1] + a[i];

    ll ans = 0;
    ll prev = 1;
    REP(i, n+1) {
        ans += min(prev, s[i]);
        if (prev < LINF) {
            prev -= a[i];
            prev <<= 1;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5576
# coding: utf-8
N,A,B,C=map(int,input().split())
flg=True
M=[]
SS=[]
for i in range(N):
    SS.append(input())
    
for i in range(N):
    S=SS[i]
    if S=="AB":
        if A==0 and B==0:
            flg=False
            break
        elif A==0:
            m="A"
        elif B==0:
            m="B"
        elif A==1 and B==1:
            if i+1<=N-1:
                if SS[i+1]=="AC":
                    m="A"
                elif SS[i+1]=="BC":
                    m="B"
                else:
                    m="A"
        elif A>=B:
            m="B"
        elif B>A:
            m="A"
            
        M.append(m)
        if m=="A":
            A+=1
            B-=1
        if m=="B":
            A-=1
            B+=1
################
    elif S=="AC":
        if A==0 and C==0:
            flg=False
            break
        elif A==0:
            m="A"
        elif C==0:
            m="C"
        elif A==1 and C==1:
            if i+1<=N-1:
                if SS[i+1]=="AB":
                    m="A"
                elif SS[i+1]=="BC":
                    m="C"
                else:
                    m="A"
        elif A>=C:
            m="C"
        elif C>A:
            m="A"
            
        M.append(m)
        if m=="A":
            A+=1
            C-=1
        if m=="C":
            A-=1
            C+=1
################
    elif S=="BC":
        if B==0 and C==0:
            flg=False
            break
        elif B==0:
            m="B"
        elif C==0:
            m="C"
        elif B==1 and C==1:
            if i+1<=N-1:
                if SS[i+1]=="AB":
                    m="B"
                elif SS[i+1]=="AC":
                    m="C"
                else:
                    m="B"
        elif B>=C:
            m="C"
        elif C>B:
            m="B"
            
        M.append(m)
        if m=="B":
            B+=1
            C-=1
        if m=="C":
            B-=1
            C+=1

if flg:
    print("Yes")
    for i in range(N):
        print(M[i])
else:
    print("No")

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

class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        int n = input.Length;
        long res = 0;
        string prev = "";
        for (long bit = 1; bit < (1<<n); bit++)
        {
            string t = input;
            int count = 0;
            for (int i = 1; i < n; i++)
            {
                if ((bit & (1 << i)) > 0)
                {
                    t = t.Insert(i + count, " ");
                    count++;
                }
            }
                
            t = t.Trim();
            if (t != prev)
                res += t.Split(' ').Select(s => long.Parse(s)).ToArray().Sum();
            prev = t;
        }
        Console.WriteLine(res);
    }
}

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

int main() {
  string S;
  cin >> S;
  int N, joken = 0;
  N = S.size();
  for (int i = 0; i<N/2+1 ; i++) {
    if (S.at(i)==S.at(N-1-i)) {
      continue;
    }
    else {
      joken++;
    }
  }
  for (int i = 0; i < N/4; i++) {
    if (S.at(i)==S.at((N-1)/2-1-i)) {
      continue;
    }
    else {
      joken++;
    }
  }
  for (int i = 0; i < N/4; i++) {
    if (S.at((N+3)/2-1+i)==S.at(N-1-i)) {
      continue;
    }
    else {
      joken++;
    }
  }
  
  if (joken==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n;
	cin>>n;
	string s[n];
	for(int i=0;i<n;i++){
		cin>>s[i];
		sort(s[i].begin(),s[i].end());
	}
	sort(s,s+n);
	ll ans=0;
	for(int i=0;i<n;i++){
		string p=s[i];
		ll l=0;
		for(; i< n;i++){
			if(s[i] != p) break;
			l++;
		}
		i--;
		ans+=(l*(l-1))/2;
	}
	cout<<ans;
}

Measured memory_bytes: 5760
/*
	"We know what we are, but know not what we may be."
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

/*
	"You never know how strong you are until being strong is the only choice you have."
*/

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
	
/*
	"With self-discipline most anything is possible."
*/
	
	long long a, b, c, d; cin >> a >> b >> c >> d;
	long long n; cin >> n;
	
	long long minQuarter = a, minHalf = min(a * 2, b);
	long long minEntire = min({a * 4, b * 2, c}), minDual = min({a * 8, b * 4, c * 2, d});
	
	long long ans = 0;
	ans += (minDual * (n / 2));
	n %= 2;
	ans += (minEntire * n);
	
	cout << ans;
	
	return 0;
}

/*
	"Reach for it. Push yourself as far as you can."
*/

Measured memory_bytes: 256
import sys

# sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


N, M = read_int_list()
A = [read_str() for i in range(N)]
B = [read_str() for j in range(M)]


def g(n, m, a, b, i, j):
    for k in range(m):
        for l in range(m):
            if a[i + k][j + l] != b[k][l]:
                return False
    return True


def f(N, M, A, B):
    for i in range(0, N - M + 1):
        for j in range(0, N - M + 1):
            if g(N, M, A, B, i, j):
                return 'Yes'
    return 'No'

print(f(N, M, A, B))


Measured memory_bytes: 3064
import fractions

a,b,c,d=map(int,open(0).read().split())

e=c*d//fractions.gcd(c,d)

nc=b//c-(a-1)//c
nd=b//d-(a-1)//d
ne=b//e-(a-1)//e

print(b-a+1-nc-nd+ne)

Measured memory_bytes: 72980
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	s := intScanner()
	w := intScanner()
	if s > w {
		fmt.Println("safe")
	} else {
		fmt.Println("unsafe")
	}
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int n ;
  cin >> n ;
  if(n%10 == 7 || (n/10)%10 == 7 || (n/100)%10 == 7)cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int a,b;
  cin>>a>>b;
  int s=a+b;
  if(s%2==0){
    cout<<s/2<<endl;
  }
  else{
    cout<<"IMPOSSIBLE"<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
ma = lambda :map(int,input().split())
n = int(input())
opens = []
for i in range(n):
    opens.append(list(ma()))
P = []
for i in range(n):
    P.append(list(ma()))

ans = -10**9

for i in range(2**10):
    tmp = 0
    cnts = [0]*n
    if i==0:continue
    for j in range(10):
        if i>>j &1:
            for shop in range(n):
                if opens[shop][j] ==1:
                    cnts[shop]+=1
    for shop in range(n):
        tmp+=P[shop][cnts[shop]]

    ans = max(tmp,ans)
print(ans)


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

int main() {
    int n; cin >> n;
    for(int i = 0; i < n; i++) {
        int x; cin  >> x;
        if(x % 2 == 0 && (x % 3 != 0 && x % 5 != 0)){
            cout << "DENIED";
            return 0;
        }
    }
    cout << "APPROVED";
    return 0;
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     std::begin(_obj), std::end(_obj)
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define ceilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define has(_obj, _val)               ((_obj).find(_val) != (_obj).end())
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
string gr[1000];
int dp[1005][1005];

int Add(int x, int y) {
    x += y;
    return x < MOD ? x : x - MOD;
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n, m;
    cin >> n >> m;
    loop(n) {
        cin >> gr[i];
    }
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (gr[i][j] == '#') {
                continue;
            }
            dp[i + 1][j] = Add(dp[i][j], dp[i + 1][j]);
            dp[i][j + 1] = Add(dp[i][j], dp[i][j + 1]);
        }
    }
    cout << dp[n - 1][m - 1] << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;

int main(){
    int n,k;
    cin >> n >> k;
    REP(i,INF){
        if (pow(k,i)>n){
            cout << i << endl;
            return 0;
        }
        
        
    }

}

Measured memory_bytes: 256
h, w, k = gets.chomp.split.map(&:to_i)

mat = []

h.times do
  mat << gets.chomp.gsub(".", "0").gsub("#", "1")
end

count = 0
0.upto((1 << h) - 1) do |i|
  0.upto((1 << w) - 1) do |j|
    selected_row = mat.select.with_index { |row, idx| (1 << idx) & i > 0 }
    sharp_num = 0
    selected_row.each do |row|
      sharp_num += (row.to_i(2) & j).to_s(2).count("1")
    end

    count += 1 if k == sharp_num
  end
end

puts count


Measured memory_bytes: 14328
#include<bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> vis;
int n,cap;
int cost[101],weight[101];
int func(int i,int w)
{
    int p1,p2;
    if(vis[{ i, w }])
        return vis[{ i, w }];
    if(i==n+1)
    {
        vis[{ i, w }] = 0;
        return 0;
    }

    if(w+weight[i-1]<=cap)
     {
         p1 =cost[i-1] + func(i+1,w + weight[i-1]);
     }
    else
        p1=0;

      p2 = func(i+1,w);

       vis[{ i, w }] = max(p1,p2);

    return vis[{ i, w }];

}

int main()
{
    int w,i,a,b,ans=0;
    cin>>n>>cap;
    for(i=0;i<n;i++)
    {
        cin>>cost[i]>>weight[i];
    }
    ans=func(1,0);
    printf("%d\n",ans);
}



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

using namespace std;

/******************************************************************************
	Main
******************************************************************************/
int main()
{
	int n = 0;
	cin >> n;
	assert(n >= 1 && n <= 2e5);

	map<string, int> word_count;
	int max_count = 1; // n >= 1 だから
	string s_i = "";
	for (int i = 0; i < n; i++) {
		cin >> s_i;
		assert(s_i.size() >= 1 && s_i.size() <= 10);
		// string tmp_s_1 = s_i;
		// transform(tmp_s_1.begin, tmp_s_1.end, tmp_s_1.begin, tolower;
		// assert(tmp_s_1 == s_i);

		auto itr = word_count.find(s_i);
		if (itr == word_count.end()) {
			word_count.insert(make_pair(s_i, 1));
		} else {
			itr->second += 1;
			if (max_count < itr->second) max_count = itr->second;
		}
		// cout << max_count << endl;
	}

	vector<string> answer;
	for (auto itr : word_count)	{
		if (itr.second == max_count) answer.push_back(itr.first);
	}
	sort(answer.begin(), answer.end());
	for (auto v : answer) {
		cout << v << endl;
	}

	return 0;
}


Measured memory_bytes: 26868
t = input('')

tlist = list(t)
for i in range(len(tlist)):
    if tlist[i] == '?':
        if i==0:
            tlist[i] = 'D'
        elif i==len(tlist)-1:
            tlist[i] = 'D'
        else:
            if tlist[i-1] == 'P':
                if tlist[i+1] == 'P':
                    tlist[i] = 'D'
                elif tlist[i+1] == 'D':
                    tlist[i] = 'D'
                elif tlist[i+1] == '?':
                    tlist[i] = 'D'
            else:
                # 1つ前が'D'
                if tlist[i+1] == 'P':
                    tlist[i] = 'D'
                elif tlist[i+1] == 'D':
                    tlist[i] = 'P'
                elif tlist[i+1] == '?':
                    tlist[i] = 'P'

print("".join(tlist))

Measured memory_bytes: 10860
n = int(input())
As = list(map(int, input().split()))

As = sorted(As,reverse=True)

def d(*arg):
    # print(' '.join(map(str,arg)))
    pass

last = 0
ret = 0
leng = len(As)
for idx,a in enumerate(As):
    if 2*a < last:
        if 2*sum(As[idx:])>=last:
            ret += 1
            d('\t',last,ret,leng,idx,a)
        else:
            d('\t',last,ret,leng,idx,a)
            break
            # pass
    else:
        d('\t',last,ret,leng,idx,a)
        ret += 1
    d('\t\t',last,ret,leng,idx,a)
    last = a
print(ret)


Measured memory_bytes: 14320
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

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

const int N = 300 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int DP[N][N], F[N][N], POW[N][N], n, m, nCr[N][N];

inline int minu(int a, int b){
	a -= b;
	if (a < 0) a += MOD;
	return a;
}

inline int mul(int a, int b){
	return a * 1ll * b % MOD;
}

inline int P2(int a, int b){
	int res = 1;
	while (b){
		if (b & 1) res = res * 1ll * a % MOD;
		b >>= 1;
		a = a * 1ll * a % MOD;
	}
	return res;
}

inline int add(int a, int b){
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i < N; i++){
		POW[i][0] = 1;
		for (int j = 1; j < N; j++) POW[i][j] = POW[i][j - 1] * 1ll * i % MOD;
	}
	for (int i = 0; i < N; i++) for (int j = 0; j <= i; j++) nCr[i][j] = (j == 0?1:(nCr[i - 1][j - 1] + nCr[i - 1][j]) % MOD);
//	cout << nCr[6][3] << '\n';
	for (int i = 1; i <= m + 1; i++) for (int j = 1; j <= min(n, i); j++){
		DP[i][j] = POW[j][i];
		int sm = 0;
		for (int k = 1; k < i; k++) for (int x = 1; x <= min(j - 1, k); x++) sm = add(sm, mul(mul(F[k][x], nCr[j][x]), POW[j - x][i - k]));
		DP[i][j] = minu(DP[i][j], sm);
		F[i][j] = DP[i][j];
		for (int k = j - 1; k >= 1; k--){
			F[i][j] = minu(F[i][j], mul(F[i][k], nCr[j][k]));
		}
//		cout << i << ' ' << j << ' ' << F[i][j] << '\n';
	}
//	cout << F[m + 1][n] << '\n';
//	cout << P2(n, MOD - 2) << '\n';
	cout << mul(F[m + 1][n], P2(n, MOD - 2));



	return 0;
}


Measured memory_bytes: 5112
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;

    int n = s.size();
    uint64_t result = 0;
    for (int p = 0; p < (1 << (n - 1)); p++)
    {
        uint64_t tmp = 0;
        uint64_t sum = 0;
        for (int i = 0; i < n; i++)
        {
            tmp = 10 * tmp + (s[i] - '0');
            if ((p & (1 << i)) != 0)
            {
                sum += tmp;
                tmp = 0;
            }
        }
        sum += tmp;
        result += sum;
    }

    cout << result << endl;

    return 0;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,vis[202],h[202];
string s[202];
vii edges;
vi a[202];
void bfs(int node){
    memset(vis,0,sizeof vis);
    queue<int> q;
    q.push(node);
    vis[node]=1;
    h[node]=0;
    while(!q.empty()){
        int d=q.front();
        q.pop();
        for(auto i:a[d]){
            if(vis[i]) continue;
            q.push(i);
            vis[i]=1;
            h[i]=h[d]+1;
        }
    }
}
void solve(){
    cin>>n;
    rep(i,0,n) cin>>s[i];
    rep(i,0,n){
        rep(j,0,n){
            if(s[i][j]=='1'){
                a[i+1].pb(j+1);
                edges.pb({i+1,j+1});
            }
        }
    }
    int ans=-1;
    rep(i,1,n+1){
        bfs(i);
        int f=1;
        for(auto j:edges){
            if(abs(h[j.x]-h[j.y])!=1){
                f=0;
            }
        }
        if(f==0) continue;
        rep(j,1,n+1){
            ans=max(ans,h[j]+1);
        }
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  if (N%10==2 || N%10==4 || N%10==5 || N%10==7 || N%10==9) {
    cout << "hon" << endl;
  } else if (N%10==0 || N%10==1 || N%10==6 || N%10==8) {
    cout << "pon" << endl;
  } else {
    cout << "bon" << endl;
  }
  
  return 0;
}

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

int main() {
    std::vector<int> v{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1,
                       51};
    int n;
    std::cin >> n;
    std::cout << v[n - 1] << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    int n,k;
    cin >> n >> k;
    vector<int> d(k);
    vector<int> p(k);
    for(int i=1; i<k; i++) d[i]=i;
    for(int index=1; index<=25; index++){
        for(int i=1; i<k; i++){
            if(d[i]<k) {
                d[i] *= 2;
                if(d[i]>=k) p[i] = index;
            }
        }
    }
    
    vector<int> pow2(25);
    pow2[0] = 1;
    for(int i=1; i<25; i++) pow2[i] = pow2[i-1]*2;
    long double ans = 0;
    for(int i=1; i<=n; i++){
        if(k<=i){
            ans += 1.0;
        }
        else{
            ans += 1.0 / (long double)pow2[p[i]];
        }
    }
    ans /= (long double)n;
    printf("%.12Lf\n",ans);
    return 0;
}

Measured memory_bytes: 4040
#include<iostream>
using namespace std;
int main(){
  int w,a,b;
  cin >> w >> a >> b;
  if(w+a<b)cout<<b-(w+a)<<endl;
  else if(b+w<a)cout<<a-(b+w)<<endl;
  else cout << "0\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static void swap(int[] data,int x){
		int tmp=data[x];
		data[x]=data[x-1];
		data[x-1]=tmp;
	}
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int data[]=new int[N];
		int count=0;
		for(int i=0;i<N;i++){
			data[i]=scan.nextInt();
		}
		for(int i=0;i<N;i++){
			for(int j=N-1;i+1<=j;j--){
				if(data[j]<data[j-1]){
					swap(data,j);
					count++;
				}
			}
		}
		for(int i=0;i<N;i++){
			if(i==0) System.out.print(data[i]);
			else System.out.print(" "+data[i]);
		}
		System.out.println();
		System.out.println(count);
		scan.close();
		
	}
	
}

Measured memory_bytes: 19072
C = str(input())

if C == "a":
    print("b")
if C == "b":
    print("c")
if C == "c":
    print("d")
if C == "d":
    print("e")
if C == "e":
    print("f")
if C == "f":
    print("g")
if C == "g":
    print("h")
if C == "h":
    print("i")
if C == "i":
    print("j")
if C == "j":
    print("k")
if C == "k":
    print("l")
if C == "l":
    print("m")
if C == "m":
    print("n")
if C == "n":
    print("o")
if C == "o":
    print("p")
if C == "p":
    print("q")
if C == "q":
    print("r")
if C == "r":
    print("s")
if C == "s":
    print("t")
if C == "t":
    print("u")
if C == "u":
    print("v")
if C == "v":
    print("w")
if C == "w":
    print("x")
if C == "x":
    print("y")
if C == "y":
    print("z")

Measured memory_bytes: 3064
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
   string a , b ; 
   cin >> a >> b ; 
   int cnt = 0 ; 
   for(int i = 0 ; i < a.length() ; i++)
        if(a[i] == b[i])cnt++ ; 
   cout << cnt ; 






















return 0 ;
}


Measured memory_bytes: 3616
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.20 21:11:44
**/

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

int main() {
    int n;cin >> n;
    ll k;cin >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    vector<vector<int>> doubling(64,vector<int>(n));
    for (int i = 0; i < n; i++) {
        doubling[0][i] = a[i];
    }
    for (int i = 1; i < 64; i++) {
        for (int j = 0; j < n; j++) {
            doubling[i][j] = doubling[i-1][doubling[i-1][j]];
        }
    }
    int now = 0;
    int t = 0;
    while(k >= (1LL << t)) {
        if (k & (1LL << t)) {
            now = doubling[t][now];
        }
        t++;
    }
    cout << now + 1 << endl;
    return 0;
}

Measured memory_bytes: 54956