akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns #-}

import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap.Strict    as M
import qualified Data.Sequence         as S

readi :: B.ByteString -> Int
readi bs | Just (n, _) <- B.readInt bs = n

data Tree a
    = Empty
    | Node a (Tree a) (Tree a)
    deriving Show

insert :: Ord a => a -> Tree a -> Tree a
insert x Empty = Node x Empty Empty
insert x (Node y l r)
    | x < y     = Node y (insert x l) r
    | otherwise = Node y l (insert x r)

print' :: Show a => Tree a -> IO ()
print' t = do
    putStrLn . (' ' :) . unwords $ fmap show (inOrder t)
    putStrLn . (' ' :) . unwords $ fmap show (preOrder t)

preOrder :: Tree a -> [a]
preOrder Empty        = []
preOrder (Node x l r) = x : preOrder l ++ preOrder r

inOrder :: Tree a -> [a]
inOrder Empty        = []
inOrder (Node x l r) = inOrder l ++ [x] ++ inOrder r

find :: Int -> Tree Int -> Bool
find _ Empty = False
find x (Node y l r)
    | x == y    = True
    | x < y     = find x l
    | otherwise = find x r

solve :: Tree Int -> [[B.ByteString]] -> IO ()
solve _ [] = return ()
solve !t (bs:bss)
    | c == 'p' = do
        print' t
        solve t bss
    | c == 'f' = do
        let n = readi $ bs !! 1
        if find n t
            then putStrLn "yes"
            else putStrLn "no"
        solve t bss
    | otherwise = do
        let n = readi $ bs !! 1
        solve (insert n t) bss
  where
    c = B.head (head bs)

main :: IO ()
main = do
    B.getLine
    xss <- fmap B.words . B.lines <$> B.getContents
    solve Empty xss



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

int main()
{
    int a, b, c, d, e, f, min_sugar{}, min_all{};
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
    min_all = a * 100;
    for (int a_i = 0; a_i * a * 100 <= f; a_i++)
    {
        int rest_a = f - a_i * a * 100;
        for (int b_i = 0; b_i * b * 100 <= rest_a; b_i++)
        {
            int rest_b = rest_a - b_i * b * 100;
            for (int c_i = 0; c_i * c <= rest_b && c_i * c <= e * (a_i * a + b_i * b); c_i++)
            {
                int tmp_min_sugar = c_i * c + std::min(rest_b - c_i * c, e * (a_i * a + b_i * b) - c_i * c) / d * d;
                int tmp_min_all = f - rest_b + tmp_min_sugar;
                if (tmp_min_sugar * min_all > min_sugar * tmp_min_all)
                {
                    min_sugar = tmp_min_sugar;
                    min_all = tmp_min_all;
                }
            }
        }
    }

    printf("%d %d\n", min_all, min_sugar);
    return 0;
}

Measured memory_bytes: 256
class segment_tree:
    def __init__(self, N, operator_M, e_M):
        self.op_M = operator_M
        self.e_M = e_M
        
        self.N0 = 1<<(N-1).bit_length()
        self.dat = [self.e_M]*(2*self.N0)
    
    # 長さNの配列 initial で初期化
    def build(self, initial):
        self.dat[self.N0:self.N0+len(initial)] = initial[:]
        for k in range(self.N0-1,0,-1):
            self.dat[k] = self.op_M(self.dat[2*k], self.dat[2*k+1])

    # a_k の値を x に更新
    def update(self,k,x):
        k += self.N0
        self.dat[k] = x
        k //= 2
        while k:
            self.dat[k] = self.op_M(self.dat[2*k], self.dat[2*k+1])
            k //= 2

    # 区間[L,R]をopでまとめる
    def query(self,L,R):
        L += self.N0; R += self.N0 + 1 
        sl = sr = self.e_M
        while L < R:
            if R & 1:
                R -= 1
                sr = self.op_M(self.dat[R],sr)
            if L & 1:
                sl = self.op_M(sl,self.dat[L])
                L += 1
            L >>= 1; R >>= 1
        return self.op_M(sl,sr)

    def get(self, k): #k番目の値を取得。query[k,k]と同じ
        return self.dat[k+self.N0]

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
sys.setrecursionlimit(10**5)

n,*p = map(int,read().split())

INF = 1<<30
p += [INF,INF]

def argmin(i,j):
    if p[i] < p[j]: return i
    else: return j

even = segment_tree(n//2+1,argmin,n)
odd = segment_tree(n//2+1,argmin,n+1)

even.build(range(0,n+2,2))
odd.build(range(1,n+2,2))

ans = [0]*n

def get(i,j):
    return odd.query(i//2,(j-1)//2)  if i%2 else even.query(i//2,(j-1)//2)

from heapq import *
k = get(0,n-1)
q = [(p[k],k,0,n-1)]

for I in range(n//2):
    v,k,i,j = heappop(q)
    l = even.query((k+1)//2,j//2) if i%2 else odd.query((k+1)//2,j//2)
    
    #print(v,p[l])
        
    ans[2*I] = v
    ans[2*I+1] = p[l]
    
    if i < k+1:
        kk = get(i,k-1)
        heappush(q,(p[kk],kk,i,k-1))
    if k+1<l-1:
        kk = get(k+1,l-1)
        heappush(q,(p[kk],kk,k+1,l-1))
    if l+1 < j:
        kk = get(l+1,j)
        heappush(q,(p[kk],kk,l+1,j))
    
print(*ans)



#x = merge3([[1,0],[4,0]],[[2,0]],[[3,0],[6,0]])
#print(x)


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

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

const string YES = "";
const string NO  = "";

typedef long long ll;

#define MAX 1000100
string s;
int dp[MAX][2];

void solve() {
  reverse(ALL(s));
  s = s + "0";
  int n = s.size();
  rep(i,n+1) rep(j,2) dp[i][j] = INT_MAX;
  dp[0][0] = 0;
  rep(i,n) {
    int v = s[i] - '0';
    rep(j,2) {
      if( dp[i][j] == INT_MAX ) continue;
      int next_bit = 0;
      int val = v + j;
      if( val >= 10 ) {
	val -= 10;
	next_bit = 1;
      }
      // just pay
      if( dp[i+1][next_bit] > dp[i][j] + val ) {
	dp[i+1][next_bit] = dp[i][j] + val;
      }
      // pay + 1
      if( dp[i+1][1] > dp[i][j] + ( 10 - val ) ) {
	dp[i+1][1] = dp[i][j] + ( 10 - val );
      }
    }
  }
  int mini = INT_MAX;
  rep(i,2) mini = min(mini,dp[n][i]);
  cout << mini << endl;
}

int main() {
  cin >> s;
  solve();
  return 0;
}


Measured memory_bytes: 9180
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <climits>

using namespace std;

double EPS = 1e-12;

//誤差を考慮して足し算を行う
double add(double a, double b) {
	if( abs(a + b) < EPS * (abs(a) + abs(b))) {
		return 0;
	}

	return a + b;
}

//二次元ベクトル構造体
struct P {
	double x, y;

	P() {}
	P(double x, double y) : x(x), y(y) {
	}
	P operator + (P p) {
		return P(add(x, p.x), add(y, p.y));
	}
	P operator - (P p) {
		return P(add(x, -p.x), add(y, -p.y));
	}
	P operator * (double d) {
		return P(x * d, y * d);
	}
	double dot(P p) {	//　内積
		return add(x * p.x, y * p.y);
	}
	double det(P p) {	//　外積
		return add(x * p.y, -y * p.x);
	}
};

//　線分p1-p2上に点qがあるか判定
bool on_seg(P p1, P p2, P q) {
		return (p1 - q).det(p2 - q) == 0 && (p1 - q).dot(p2 - q) <= 0;
}

//　直線p1-p2と直線q1-q2の交点
P intersection(P p1, P p2, P q1, P q2) {
	return p1 + (p2 - p1) * ((q2 - q1).det(q1 - p1) / (q2 - q1).det(p2 - p1));
}


int main() {
	int n;

	cin >> n;

	P p, q, r, s;

	for(int i = 0; i < n; i++) {
		cin >> p.x >> p.y >> q.x >> q.y >> r.x >> r.y >> s.x >> s.y;
		if( (q - p).det(s - r) == 0) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}

}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define Rep(i,a,n) for (int i=a;i<=n;i++)
#define Per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int maxn = 200010;
ll a[maxn];

signed main(){
    ll n,k;cin>>n>>k;
    rep(i,0,n){
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    ll zheng=0,ling=0,fu=0;
    rep(i,0,n){
        if(a[i]>0) zheng++;
        if(a[i]==0) ling++;
        if(a[i]<0) fu++;
    }
    ll fgs=zheng*fu;
    ll lgs=ling*(ling-1)/2+ling*(n-ling);
    //cout<<fgs<<" "<<lgs<<endl;
    if(k>fgs&&k<=fgs+lgs){
        puts("0"); return 0;
    }
    if(k<=fgs){
        vector<ll> z,f;
        rep(i,0,n){
            if(a[i]>0) z.pb(a[i]);
            else if(a[i]<0) f.pb(-a[i]);
        }
        sort(all(z));sort(all(f));
        // di k da
        //zui xiao de bi ta da de shu buchao guo k ge
        ll l=0,r=1e18+1;
        while(l<r){
            ll mid=(l+r)>>1;
            ll sum=0;
            rep(i,0,SZ(z)){
                ll x=mid/z[i];
                ll b=(upper_bound(f.begin(),f.end(),x)-f.begin());
                //cout<<x<<" "<<b<<endl;
                b=f.size()-b;
                sum+=b;
            }
            //cout<<mid<<" "<<sum<<endl;
            if(sum<k){
                r=mid;
            }else{
                l=mid+1;
            }
        }
        cout<<-l<<endl;
        return 0;
    }else{
        k-=fgs;k-=lgs;
        //cout<<k<<endl;
        vector<ll> z,f;
        rep(i,0,n){
            if(a[i]>0) z.pb(a[i]);
            else if(a[i]<0) f.pb(-a[i]);
        }
        sort(all(z));sort(all(f));
        ll l=0,r=1e18+1;
        while(l<r)   {
            ll mid=(l+r+1)>>1;
            ll sum=0;
            rep(i,0,SZ(z)-1){
                ll x=mid/z[i];
                if(x*z[i]==mid) x--;
                ll b=(upper_bound(z.begin()+i+1,z.end(),x)-(z.begin()+i+1));
                sum+=b;
            }
            rep(i,0,SZ(f)-1){
                ll x=mid/f[i];
                if(x*f[i]==mid) x--;
                ll b=(upper_bound(f.begin()+i+1,f.end(),x)-(f.begin()+i+1));
                //cout<<f.size()<<" "<<b<<endl;
                sum+=b;
            }
            //cout<<sum<<endl;
            if(sum<k){l=mid;}
            else {r=mid-1;}
        }
        cout<<l<<endl;
    }
    return 0;
}

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

int main()
{
  int n,f,i,m;
  string s;
  cin>>n;
  while(n-->0){
    cin>>s;
    f=0;
    if(s[0]+s[1]=='>'+'\''){
      m=s.find('#');
      if(m!=string::npos){
	for(i=1;s[m-i]==s[m+i];)i++;
	if(i>1 && m-i==1 && m+i==s.size()-1 && s[m+i]=='~')f=1;
      }
    }else if(s[0]+s[1]=='>'+'^'){
      for(i=2;s[i]=='Q'&&s[i+1]=='=';)i+=2;
      if(i>2 && i==s.size()-2 && s[i]=='~' && s[i+1]=='~')f=2;
    }
    if(f)puts(f==1?"A":"B");
    else puts("NA");
  }
}

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

namespace ABC068
{
    class C
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];

            bool[] S = new bool[200010];
            bool[] G = new bool[200010];

            for (int i = 0; i < M; i++)
            {
                input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int a = input[0];
                int b = input[1];
                if (a == 1) S[b] = true;
                if (b == N) G[a] = true;
            }

            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] && G[i]) { Console.WriteLine("POSSIBLE"); return; }
            }
            Console.WriteLine("IMPOSSIBLE");
        }
    }
}


Measured memory_bytes: 17624
#include<bits/stdc++.h>
using namespace std;
#define N 100
#define K 100005

int n, k;
int arr[N];

int dp[K];

int calc(int ki){
	//cout << ki << " ";
	if(dp[ki]!=-1){
		return dp[ki];
	}
	dp[ki] = 0;
	for (int i = 0; i < n; ++i){
		if(dp[ki]==0){
			if(ki-arr[i]>=0) dp[ki] = 1-calc(ki-arr[i]);
		}
		else{
			return dp[ki];
		}
	}
	return dp[ki];
}

int main(){

	cin >> n >> k;	

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

	memset(dp, -1, sizeof(dp));


	string ans = calc(k) ? "First":"Second";
	cout << ans << endl; 


}

Measured memory_bytes: 5376
#include <cstdio>
#include <iostream>
#include <queue>
#define ROP(i,n) for(int i=0;i<n;i++)
#define ROPP(i,n) for(int i=1;i<=n;i++)
#define NIL -1
using namespace std;
typedef pair<int,int> P;
int N,M,G,gx[10],gy[10];
char MAP[1005][1005];
int DX[4]={1,0,-1,0},DY[4]={0,1,0,-1},FAR[1005][1005];
int BFS(int u){
  queue<P> que;
  ROPP(i,N){ROPP(j,M) FAR[j][i]=NIL;}
  que.push(P(gx[u],gy[u]));
  FAR[gx[u]][gy[u]]=0;
  while(que.size()){
    P p=que.front();que.pop();
    if(p.first==gx[u+1]&&p.second==gy[u+1]) break;
    ROP(i,4){
      int nx=p.first+DX[i],ny=p.second+DY[i];
      if(1<=nx&&nx<=M&&1<=ny&&ny<=N
        &&MAP[nx][ny]!='X'&&FAR[nx][ny]==NIL){
        que.push(P(nx,ny));
        FAR[nx][ny]=FAR[p.first][p.second]+1;
      }
    }
  }
  return FAR[gx[u+1]][gy[u+1]];
}
void solve(){
  int res=0;
  ROP(i,G) res+=BFS(i);
  printf("%d\n",res);
}
int main(){
  scanf("%d %d %d",&N,&M,&G);
  ROPP(i,N){
    ROP(j,M+1){
      scanf("%c",&MAP[j][i]);
      if(MAP[j][i]=='S') gx[0]=j,gy[0]=i;
      if(MAP[j][i]=='1') gx[1]=j,gy[1]=i;
      if(MAP[j][i]=='2') gx[2]=j,gy[2]=i;
      if(MAP[j][i]=='3') gx[3]=j,gy[3]=i;
      if(MAP[j][i]=='4') gx[4]=j,gy[4]=i;
      if(MAP[j][i]=='5') gx[5]=j,gy[5]=i;
      if(MAP[j][i]=='6') gx[6]=j,gy[6]=i;
      if(MAP[j][i]=='7') gx[7]=j,gy[7]=i;
      if(MAP[j][i]=='8') gx[8]=j,gy[8]=i;
      if(MAP[j][i]=='9') gx[9]=j,gy[9]=i;
    }
  }
  solve();
  return 0;
}

Measured memory_bytes: 8072
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	string n; cin >> n;
	rep(i, 3) {
		if (n[i] == '1') n[i] = '9';
		else if (n[i] == '9')n[i] = '1';
	}

	cout << n << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int a,b,c,x,y;
   x=y=0;
   while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
      int ;

      if(a==b)y++;
      else if(a*a+b*b==c*c)x++;

   }
   printf("%d\n%d\n",x,y);
   return 0;

}

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

int main(){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    string ans{};
    rep(i, n){
        ans.push_back(s[i]);
        ans.push_back(t[i]);

    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(ll)>
using namespace std;
#define All(v) (v).begin(),(v).end()
typedef long long ll;
const ll mod = 1000000007;
const ll inf = mod*mod;
const ll d5 = 114514;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1.0);

int main(){    
    ll D,G;
    cin>>D>>G;
    vector<pair<ll,ll>> P(D);
    for(ll i=0;i<D;i++){
        cin>>P[i].first>>P[i].second;
    }
    ll res = inf;
    //完全に解く問題について全探索
    for(ll i=0;i<(1<<D);i++){
        ll score=0;//得点
        ll q=0;//解いた数
        bool solve[11];
        for(ll d=0;d<D;d++){
            solve[d]=false;
            if(i>>d&1){
                solve[d]=true;
                score+=P[d].first*(d+1)*100+P[d].second;
                q+=P[d].first;
            }
        }
        if(score>=G){
            res=min(res,q);
        }
        else{
            for(ll d=D-1;d>=0;d--){
                if(solve[d])continue;
                ll get = (d+1)*100;
                ll tmp=(G-score+get-1)/get;
                if(tmp>=P[d].first)continue;//完全に解くのと同じかそれ以上を要求するので無視
                q+=tmp;
                res=min(res,q);
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;

typedef long long ll;
ll INF = 1LL << 60;

int 
main() {

  int H, W; cin >> H >> W;
  vector<vector<char>> arr(H);
  rep(i, 0, H)rep(k, 0, W){
    char tmp; cin >> tmp;
    arr[i].push_back(tmp);
  }


  vector<bool> row(H, 0);
  vector<bool> col(W, 0);
  rep(i, 0, H){
    rep(k, 0, W){
      if(arr[i][k] != '.') row[i] = true, col[k] = true;
    }
  }


  rep(i, 0, H){
    if(row[i]){
      rep(k, 0, W){
        if(col[k]) cout << arr[i][k];
      }
      cout << endl;
    }
  }
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long MOD = (long)Math.pow(10, 9) + 7;
    int n = sc.nextInt();
    long[] m0 = new long[60];
    long[] m1 = new long[60];
    for(int i = 0; i < n; i++) {
      long a = sc.nextLong();
      for(int j = 0; j < 60; j++) {
        if((a % 2) == 0) {
          m0[j]++;
        } else {
          m1[j]++;
        }
        a /= 2;
      }
    }
    long ans = 0;
    for(int i = 0; i < 60; i++) {
      long t = (long)Math.pow(2, i) % MOD;
      t = (t * m0[i]) % MOD;
      t = (t * m1[i]) % MOD;
      ans = (ans + t) % MOD;
    }
    System.out.println(ans);
  }
}

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

using namespace std;

signed main()
{
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int cnt[3] = {0};
    int n;
    cin >> n;
    while(n--)
    {
        int t;
        cin >> t;
        if(t % 4 == 0)
            cnt[0]++;
        else if(t % 2 == 0)
            cnt[1]++;
        else
            cnt[2]++;
    }
    cout << (cnt[2] <= cnt[0] || cnt[2] == cnt[0] + 1 && cnt[1] == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> s(n);
  for(int i=0;i<n-1;i++){
    int a;
    cin>>a;
    s[a-1]++;
  }
  for(int i=0;i<n;i++){
    cout<<s[i]<<endl;
  }
}

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

int main (){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  
  const int dx = tx - sx;
  const int dy = ty - sy;
  
  cout << string(dx, 'R') << string(dy, 'U');
  
  cout << string(dx, 'L') << string(dy, 'D');
  
  cout << 'D' << string(dx + 1, 'R') << string(dy + 1, 'U') << 'L';
  
  cout << 'U' << string(dx + 1, 'L') << string(dy + 1, 'D') << 'R';
  
  return 0;
}

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

#define fi first
#define se second
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> pint;

const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

int main(){
	ios::sync_with_stdio(0);

	int n, m; cin >> n >> m;
	cout << (1 << m) * (m * 1900 + (n - m) * 100);

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void){
        char s[100000];
        scanf("%s", s);
        for (int i = 0; i < ceil((float)strlen(s)/2); i++) {
                printf("%c",s[i*2]);
        }
        printf("\n");
        return 0;
}

Measured memory_bytes: 256
//写経：https://atcoder.jp/contests/keyence2020/submissions/9573205
#include <bits/stdc++.h>
using namespace std;

//感想：2020/01/09時点で全く手が付けられないため，bit DPなるものを学習した後再チャレンジの必要あり．

//dp[i][j] = i:用いるカードの集合？，j:?
int dp[(1 << 19)][51];

void solve(){

	//配列dpを1e9で初期化
	for(int i = 0; i < (1 << 19); i++){
		for(int q = 0; q < 51; q++){
			dp[i][q] = 1e9;
		}
	}

	dp[0][0] = 0;

	//入力を受け取る
	int n; cin >> n;
	vector<pair<int, int>> inputs;
	for(int i = 0; i < n; i++){
		int a; cin >> a;
		inputs.push_back(make_pair(a, 1));
	}
	for(int i = 0; i < n; i++){
		cin >> inputs[i].second;
	}

	//dpのiループ
	for(int i = 0; i < (1 << n)-1; i++){

		//何番目のカードが裏返っているかを格納するための配列？
		int is_B[20] = {};

		//今回のループで用いられているカードの集合？
		int taken[20] = {};

		//右からq番目のカードが用いられていたらインクリメント
		for(int q = 0; q < n; q++){
			if((1 << q) & i){
				is_B[q]++;
				taken[q] = 1;
			}
		}

		//右から数えて偶数番目かどうかを判定
		for(int q = n-2; q >= 0; q--){
			is_B[q] += is_B[q+1];
			is_B[q] %= 2;
		}

		//表裏を判定するための端からの距離を格納
		int dist = 0;

		//次のカードを選択するjループ
		for(int j = 0; j < n; j++){

			//カードが既に用いられていなければ
			if(taken[j] == false){

				//用いているカードの集合に次のカードを追加
				int next_go = i + (1 << j);

				//
				int cost = dist;

				//次のカードが表裏どちらの状態か判定
				int nexe_value = (is_B[j] + dist) % 2;

				//次のカードの値を格納
				if(nexe_value == 0) nexe_value = inputs[j].first;
				else nexe_value = inputs[j].second;

				//dpを更新
				for(int q = 0; q < nexe_value + 1; q++){
					dp[next_go][nexe_value] = min(dp[next_go][nexe_value], dp[i][q] + cost);
				}

				//端からの距離を更新
				dist++;
			}
		}
	}

	//ansを求める
	int ans = 1e9;
	for(int q = 0; q < 51; q++){
		ans = min(ans, dp[(1 << n) - 1][q]);
	}
	if(ans == 1e9) ans = -1;

	//出力
	cout << ans << endl;
}

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

Measured memory_bytes: 104704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define INF 1000000000000000000
#define all(x) x.begin(), x.end()
#define PI 3.141592653589793

int main() {
    int N, M;
    cin >> N >> M;
    int sum = 0;
    rep(i, M) {
        int a;
        cin >> a;
        sum += a;
    }

    int res = N - sum;
    if (res >= 0)
        cout << res << endl;
    else
        cout << -1 << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int maxn=200005;
int x[maxn],y[maxn];
 
int main(int argc, char const *argv[])
{
	int n,m;
	while(~scanf("%d %d",&n,&m)){
		int a,b;
		memset(x,0,sizeof(x));
		memset(y,0,sizeof(y));
		int ans=0;
		for(int i=0;i<m;i++){
			scanf("%d %d",&a,&b);
			if(a==1) x[b]=1;
			if(b==n) y[a]=1;
			// if(a==1&&b==n){
			// 	ans=1;
			// }
		}
		if(!ans){
			for(int i=1;i<=n;i++){
				if(x[i]&&y[i]){
					ans=1;
					break;
				}
			}
		}
		if(ans){
			printf("POSSIBLE\n");
		}
		else{
			printf("IMPOSSIBLE\n");
		}
	}
	return 0;
}

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

int main(){
    int64_t N,A,B;
    cin >> N >> A >> B;
    int64_t C = N / (A + B),D = N - C * (A + B);
    D = (D > A ? A : D);
    cout << C * A + D << endl;
}


Measured memory_bytes: 256
import functools

N = int(input())
march = ["M","A","R","C","H"]
S = {}
for m in march:
    S[m] = 0

for i in range(N):
    s = input()
    if s[0] in march:
        S[s[0]] += 1

aS = []
for s in S.values():
    if s != 0:
        aS.append(s)

mul = 1
ans = 0
sum = 0
for s in aS:
    mul = mul * s
    sum += 1
if sum == 3:
    ans = mul
elif sum == 4:
    # ans = mul * 4
    for s in aS:
        ans = ans + mul / s
elif sum == 5:
    # ans = mul * 5
    for i in range(5):
        for j in range(i+1,5):
            ans = ans + mul / aS[i] / aS[j]
print(int(ans))

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
	if(b&1)
		r=(r*a)%m;
	b=b/2;
	a=(a*a)%m;
	}
	return r%m;
}

int main() {
   ll n; cin>>n;
   if(n%2)
   {
       cout<<0<<endl;
   }
   else
   {
       n = n/2;
       ll a = n, b =0;
       rep(i,1,68)
       {
           a+=(n/(ll)(pow(2,i)+0.5));
       }
       rep(i,1,28)
       {
           b+=(n/(ll)(pow(5,i)+0.5));
       }
       cout<<min(a,b)<<endl;
   }
   return 0;
}
/*

*/


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>

using namespace std;

struct Node{
  int key;
  Node *prev, *next;
};

Node *nil;

Node* search(int k){
  Node *x = nil->next;

  while(x != nil && x->key != k) x = x->next;

  return x;
}

void insert(int k){
  Node *x = (Node *)malloc(sizeof(Node));

  x->key = k;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

void deleteNode(Node *x){
  if(x == nil) return;
  x->prev->next = x->next;
  x->next->prev = x->prev;

  free(x);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

int main(){

  int n, k;
  char command[20];

  nil = (Node *)malloc(sizeof(Node));
  nil->prev = nil;
  nil->next = nil;

  scanf("%d", &n);
  for(int i = 0;i < n;i++){
    scanf("%s", command);
    if(strcmp(command, "insert") == 0){
      scanf("%d", &k);
      insert(k);
    }else if(strcmp(command, "delete") == 0){
      scanf("%d", &k);
      deleteNode(search(k));
    }else if(strcmp(command, "deleteFirst") == 0){
      deleteFirst();
    }else if(strcmp(command, "deleteLast") == 0){
      deleteLast();
    }
  }

  k = 0;
  Node *x = nil->next;
  while(x != nil){
    printf((k?" ":""));
    printf("%d", x->key);
    k++;
    x = x->next;
  }
  printf("\n");

  return 0;
}




Measured memory_bytes: 34432
import collections

N, X = map(int, input().split())
x = [int(i) for i in input().split()]

y = [abs(X-i) for i in x]
y.append(0)
y.sort()
z = [(y[i+1] - y[i]) for i in range(0, N)]
zz = []
for i in range(0, N):
    if z[i] != 0 and not(z[i] in zz):
        zz.append(z[i])
a = collections.Counter(zz).keys()
D = min(a)
f = True
for i in range(D, 0, -1):
    f = True
    for j in range(0, N):
        if y[j]%D != 0:
            f = False
            break
    if f:
        break
    D = i
print(D)

Measured memory_bytes: 15260
#include "iostream"
#include "list"

using namespace std;

int main(){
long long int n;
cin>>n;
if(!n){
cout<<0<<endl;
return 0;
}
long long int c=1;
list<int>ans;
while(n){
if((n-c)%(-c*2)==0){
n-=c;
ans.push_front(1);
}
else{
ans.push_front(0);
}
c*=-2;
}

for(auto i:ans)cout<<i;
cout<<endl;
}

Measured memory_bytes: 256
loop do
  m, f, r = gets.split.map(&:to_i)
  break if m == -1 && f == -1 && r == -1
  if m == -1 || f == -1
    puts "F"
  else
    if m + f >= 80
      puts "A"
    elsif m + f >= 65
      puts "B"
    elsif m + f >= 50
      puts "C"
    elsif m + f >= 30
      if r >= 50
        puts "C"
      else
        puts "D"
      end
    else
      puts "F"
    end
  end
end

Measured memory_bytes: 8700
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXL = 8e3 + 100;
bool dp[2][MAXL * 2];

int main() {
	string S;
	int x, y;
	cin >> S >> x >> y;
	VI X, Y;
	int type = 0;
	for (int i = -1; i < SZ(S); ) {
		int j = i + 1;
		while (j < SZ(S) && S[j] == 'F')
			j++;
		if (type)
			Y.PB(j - i - 1);
		else
			X.PB(j - i - 1);
		i = j;
		type ^= 1;
	}
	bool canX = false, canY = false;
	do {
		memset(dp, 0, sizeof(dp));
		bool *now = dp[0], *nxt = dp[1];
		now[MAXL + X[0]] = true;
		bool pass = true;
		for (int dx : X) {
			if (pass) {
				pass = false;
				continue;
			}
			for (int i = 0; i < MAXL + MAXL; i++) {
				if (!now[i]) continue;
				nxt[i - dx] = true;
				nxt[i + dx] = true;
			}
			swap(now, nxt);
			fill(nxt, nxt + MAXL + MAXL, false);
		}
		canX = now[MAXL + x];
	} while (0);
	do {
		memset(dp, 0, sizeof(dp));
		bool *now = dp[0], *nxt = dp[1];
		now[MAXL] = true;
		for (int dy : Y) {
			for (int i = 0; i < MAXL + MAXL; i++) {
				if (!now[i]) continue;
				nxt[i - dy] = true;
				nxt[i + dy] = true;
			}
			swap(now, nxt);
			fill(nxt, nxt + MAXL + MAXL, false);
		}
		canY = now[MAXL + y];
	} while (0);

	if (canX && canY)
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>	
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int main()
{
	IO;
	int ans{100000000};
	string s;
	cin>>s;
	s=" "+s;
	For(i,1,s.size()-2)
	{
		ans=min(ans,abs(stoi(s.substr(i,3))-753));
	}
	cout<<ans<<'\n';
	//system("pause");
	return 0;
}

Measured memory_bytes: 3592
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
double n; 
int main(){
	cin>>n;
	cout<<2.00000*n*3.1415926;
	return 0;
}

Measured memory_bytes: 3232
#include<stdio.h>
int main(){
   int n;
   double result;
   scanf("%d",&n);
   if(n == 1){
       puts("1.0000000000");
   }
   else{
       if(n%2 ==0){
           puts("0.5000000000");
       }
       else{
           result = n/2 + 1;
           printf("%lf",result/n);
       }
   }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;

ll H;
int main() {
    cin >> H;

    ll div = 0;
    ll tmp = 1;
    while (H > 0) {
        H = H / 2;
        div++;
        tmp *= 2;
    }

    ll ans = -1 * (1 - tmp);
    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused)]

use proconio::{input, fastout};
use proconio::marker::{Chars, Usize1};

#[fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    println!("{}", s.iter().zip(t.iter()).filter(|&(a, b)| a != b).count());
}



Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
const int maxn = 550001;
typedef long long ll;
int a[maxn / 5], b[maxn / 5];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i <= n; ++i)
    {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &b[i]);
    }
    b[n] = 0;
    ll ans = 0;
    if (b[0] > a[0])
    {
        b[0] -= a[0];
        ans += a[0];
    }
    else
    {

        ans += b[0];
        b[0] = 0;
        //a[0]白给
    }
    for (int i = 1; i <= n; i++)
    {
        if (i > 0 && b[i - 1])
        {
            if (a[i] <= b[i - 1])
            {
                ans += a[i];
                a[i]=0;
            }
            else
            {
                ans += b[i - 1];
                a[i]-=b[i-1];
            }
        }
        if (b[i] >= a[i])
        {
            b[i] -= a[i];
            ans += a[i];
        }
        else
        {
            a[i] -= b[i];
            ans += b[i];
            b[i] = 0;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= putStrLn . showRes . solve
    where
        showRes b 
            | b = "YES"
            | otherwise = "NO"
        solve [n, k] = (n + 1) `div` 2 >= k

readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
#include <iostream>
#include <cstdint>
#include <string>
#include <vector>

int main() {
  std::string s;
  std::cin >> s;
  std::int_fast32_t n = static_cast<std::int_fast32_t>(s.size());
  std::vector<char> answer(n, '\0');
  for (std::int_fast32_t i = 0; i < n; ++i) {
    if (s[i] == 'p') {
      answer[i] = 'p';
    }
  }

  std::int_fast32_t left_p = 0;
  for (std::int_fast32_t i = n - 1; i >= 0; --i) {
    switch (answer[i]) {
    case 'p':
      ++left_p;
      break;
    case '\0':
      if (left_p > 0) {
        answer[i] = 'g';
        --left_p;
      }
      break;
    }
  }

  left_p = 0;
  std::int_fast32_t win_count = 0;
  for (std::int_fast32_t i = 0; i < n; ++i) {
    switch (answer[i]) {
    case 'g':
      ++left_p;
      break;
    case 'p':
      --left_p;
      break;
    case '\0':
      if (left_p > 0) {
        answer[i] = 'p';
        --left_p;
        ++win_count;
      } else {
        answer[i] = 'g';
        ++left_p;
      }
      break;
    }
  }

  std::cout << win_count << std::endl;
  return 0;
}

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

int main() {
  ll n,ans,gc = 0,bc = 0,rc = 0;
  string s;
  cin >> n >> s;
  ans = n*(n-1)*(n-2)/6;
  for(int i = 0;i < n-2;i++){
    for(int j = i+1;j < n-1;j++){
      if(i+2*(j-i) >= n) break;
      if(s[i] != s[j] && s[j] != s[i+2*(j-i)] && s[i] != s[i+2*(j-i)]) ans--;
    }
  }
  for(int i = 0;i < n;i++){
    if(s[i] == 'R') rc++;
    if(s[i] == 'G') gc++;
    if(s[i] == 'B') bc++;
  }
  ans -= rc*(rc-1)*(rc-2)/6+gc*(gc-1)*(gc-2)/6+bc*(bc-1)*(bc-2)/6;
  ans -= rc*(rc-1)*gc/2+rc*(rc-1)*bc/2+gc*(gc-1)*rc/2+gc*(gc-1)*bc/2+bc*(bc-1)*gc/2+bc*(bc-1)*rc/2;
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <iterator>
#define r(i,n) for(int i=0;i<n;i++)
#define R(i,c,n) for(int i=c;i<n;i++)
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

int main(){
  ios::sync_with_stdio(false);
	cin.tie(0);
  int n,k;
  cin >> n >> k;
  vector<int> h;
  int tmp;
  r(i,n){
    cin >> tmp;
    h.emplace_back(tmp);
  }
  sort(h.begin(),h.end());
  long long int mindiff = 1000000000 - 1;
  r(i,n-k+1){
    mindiff = h[i+k-1] - h[i] < mindiff ? h[i+k-1] - h[i] : mindiff;
  }
  cout << mindiff << endl;
  return 0;
}

Measured memory_bytes: 892
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    }
    println!("{}",a+b+c-max(a,max(b,c)))
}

Measured memory_bytes: 2076
#include <iostream>
#include <cstdio>
#include <cmath>
#include <stack>

#define rep(i,x) for(int i=0;i<x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rep_to(a,i,x) for(int i=a;i<x;i++)

using namespace std;

int main()
{
	int num[1000]={};
	int add[1000]={};
	int n;
	while(1){
	cin>>n;
	if(n==0)break;
	double sum=1;
	rep(i,n)
	{
		if(i<=3)add[i]=i;
		else add[i]=(add[i-3]+add[i-2]+add[i-1]);
		sum+=add[i];
	}
	cout<<ceil(sum/3650)<<endl;
}

	return 0;
}

Measured memory_bytes: 1240
S = input()
T = input()
n = 0
ans = ''
flag = False
cnt = 0
for i in range(len(S)-len(T)+1):
  for j in range(len(T)):
    if S[len(S)-i-j-1] == T[len(T)-j-1] or S[len(S)-i-j-1] == '?':
      cnt += 1
  if cnt == len(T):
    n = i
    flag = True
    break
  else:
    cnt = 0
if not flag:
  print('UNRESTORABLE')
else:
  S = S.replace('?','a')
  ans = S[0:len(S)-len(T)-i]+T+S[len(S)-i:len(S)]
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
	
	int a,b,c ;
	
	scanf("%d %d", &a, &b);
	if (a<10){
			c = 100*(10-a);
		printf("%d", b + c);
		}
	else {
		printf("%d", b);
	}
		return 0;
	}

Measured memory_bytes: 3188
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#include <map>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int n;

map<int, int> a;

void input() {
  a.clear();

  cin >> n;

  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;

    a[t]++;
  }
}

void solve() {
  int ans = 0;

  for (auto&& [key, val] : a) {
    if (val < key) {
      ans += val;
    } else {
      ans += val - key;
    }
  }

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

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  _times = 5;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 8132
#include <stdio.h>

#define MOD 1000000007;

int main() {
  int n;
  scanf("%d", &n);
  long dp[101][64];
  for (int i=0; i<101; i++) for (int j=0; j<64; j++) dp[i][j] = 0;
  for (int i=0; i<16; i++) dp[2][63-i] = 1;
  for (int i=3; i<n+1; i++) {
    for (int j=0; j<64; j++) {
      if (j == 6) continue;
      if (j == 18) continue;
      if (j == 9) continue;
      if (j%16 == 6) {
        for (int idx=1; idx<4; idx++) {
          dp[i][j] += dp[i-1][idx*16+j/4];
          dp[i][j] %= MOD;
        }
      }
      else if (j/16 == 1 && j%4 == 2) {
        for (int idx=1; idx<4; idx++) {
          dp[i][j] += dp[i-1][idx*16+j/4];
          dp[i][j] %= MOD;
        }
      }
      else {
        for (int idx=0; idx<4; idx++) {
          dp[i][j] += dp[i-1][idx*16+j/4];
          dp[i][j] %= MOD;
        }
      }
    }
  }
  long ans = 0;
  for (int i=0; i<64; i++) {
    ans += dp[n][i];
    ans %= MOD;
  }
  printf("%ld\n", ans);
  return 0;
}


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

using namespace std;

int num = 1000000007;

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

    long long power = 1;
    for (int i = 1; i <= N; ++i) {
        power = power * i;
        power = power % num;
    }

    cout << power;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int r;

int main(){
  cin >> r;

  if(r < 1200){
    cout << "ABC" << endl;
  }
  else if(r < 2800){
    cout << "ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	var l []int

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		l = append(l, tmp)
	}

	sort.Ints(l)
	max := l[len(l)-1]
	var sum int
	for i := 0; i < len(l)-1; i++ {
		sum += l[i]
	}

	if max < sum {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
//////////////////

void solve(){
  ini(N);
  vi a(N); in(a); each(x,a)x--;
  vi inv(N);
  rep(i , N) inv[a[i]] = i;
  set<int> s;
  s.emplace(-1); s.emplace(N);
  ll ans = 0;
  rep(i , N){
    // iを挿入
    auto it = s.upper_bound(inv[i]);
    ll r = *it;
    it--;
    ll l = *it;
    ans += (1LL * (r - inv[i]) * (inv[i] - l)) * (i + 1);
    s.emplace(inv[i]);
    trc(l , r , inv[i] , ans);
    
  }
  out(ans);
}

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define mod 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()

int main() {
  int M, D;

  cin >> M >> D;

  int count = 0;
  int d = 0;

  for (int m = 1; m <= M; m++) {
    for (int i = 11; i <= D; i++) {
      if (i / 10 < 2 ||
          i % 10 < 2) {
        continue;
      }
      d = (i / 10) * (i % 10);

      if (m == d) {
        count++;
      }
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
  
#define EPS 1e-6
#define INF 1e8
typedef complex<double> P;
  
double dot(P a,P b){
    return real(conj(a)*b);
}
  
double cross(P a,P b){
    return imag(conj(a)*b);
}
  
struct Point{
    double x,y;
};
  
int main(){
    double D;
  
    while(scanf("%lf",&D), D){
	Point v,p;
      
	scanf("%lf%lf%lf%lf",&p.x,&p.y,&v.x,&v.y);
	P np = P(p.x,p.y), nv = P(v.x,v.y);
	double dist = INF;
  
	if(abs(cross(np,nv)) < EPS){
	    if(dot(np,nv) < -EPS){
		dist = abs(np);
	    }else{
		dist = 2-abs(np);
	    }
	}
     
	if(dist < D){
	    printf("%.8f\n",dist);
	}else{
	    printf("impossible\n");
	}
    }
    return 0;
}

Measured memory_bytes: 3212
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
    char s[160];
    while(cin>>s)
    {
        int len=strlen(s);
        int pos=len,flag=0;
        int ans=0;
        if(len==1)
            ans=s[0]-'0';
        else if((int)(s[0]-'0')!=9){
            for(int i=1;i<len;i++)
            if((int)(s[i]-'0')!=9){
                flag=1;break;
            }
            if(!flag){
                ans=s[0]-'0';
                ans+=(len-1)*9;
            }else{
                ans=s[0]-'0'-1;
                ans+=(len-1)*9;
            }
        }else{
            for(int i=1;i<len;i++){
                if((int)(s[i]-'0')!=9){
                    pos=i;
                    break;
                }
            }
            ans=(pos-1)*9+s[pos-1]-'0'-1;
            ans+=(len-pos)*9;
            if(pos==len)
                ans=len*9;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin>>N;
  double cnt=0;
  REP(i,1,N+1){
    if(i%2==1)cnt++;
  }
  cout<<cnt/N<<endl;

  return 0;
}


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

int main()
{
  int n, ans = 0;
  cin >> n;
  int p[n], q[n];
  bool p_bigger = true;
  for (int i = 0; i < n; ++i)
  {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++)
  {
    cin >> q[i];
  }
  for (int i = 0; i < n; ++i)
  {
    if (p[i] == q[i])
    {
      continue;
    }
    else if(p[i] > q[i])
    {
      p_bigger = true;
      break;
    }
    else
    {
      p_bigger = false;
      break;
    }
  }

  if (p_bigger)
  {
    do {
      ans += 1;
      if (equal(q, q + n, p))
      {
        cout << ans - 1 << endl;
        break;
      }
    } while(next_permutation(q, q + n));
  }
  else
  {
    do {
      ans += 1;
      if (equal(p, p + n, q))
      {
        cout << ans - 1 << endl;
        break;
      }
    } while(next_permutation(p, p + n));
  }
}


Measured memory_bytes: 256