akhauriyash/Code-Regression huggingface dataset:
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe
import Data.List

main :: IO ()
main = do
  [a1,a2,a3] <- readInts
  print . showAnswer $ solve (a1,a2,a3)

type Input  = (Int, Int, Int)
type Output = Int

solve :: Input -> Output
solve (a1,a2,a3) = sum (zipWith (-) xs (tail xs))
  where
    xs = sortOn negate [a1,a2,a3]

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int r = fs.nextInt();
		int g = fs.nextInt();
		int b = fs.nextInt();
		
		int k = fs.nextInt();
		
		int num = 0;
		
		while(r >= g) {
			g = g * 2;
			num++;
		}
		
		while(g >= b) {
			b = b * 2;
			num++;
		}
		
		if(num <= k) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 32796
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define gt(n) scanf("%d", &n)
#define gtll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
fast;
int n,x;
cin>>n>>x;
if((n*500)>=x)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <algorithm>


using namespace std;

int main(void){
    int X, A, B;
    cin >> X >> A >>B;

    if(A - B >= 0){
        cout << "delicious" << endl;
    }
    else if((A - B + X) >= 0){
        cout << "safe" << endl;
    }
    else{
        cout << "dangerous" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int i,j;
  int n;
  while(cin>>n,n){
    int a[16][17];
    for(i=0;i<n;i++)
      for(j=0;j<n+1;j++)
	cin>>a[i][j];
    int b[1<<16];
    for(i=0;i<(1<<n);i++)
      b[i]=1<<30;
    priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > c;
    for(i=0;i<n;i++)
      c.push(make_pair(a[i][0],1<<i));
    for(;;){
      int p,q;
      p=c.top().first;
      q=c.top().second;
      if(q==(~((~0)<<n)))
	break;
      c.pop();
      if(b[q]>p){
	b[q]=p;
	for(i=0;i<n;i++){
	  if((q&(1<<i))==0){
	    int mn=0;
	    for(j=0;j<n;j++){
	      if((q&(1<<j))&&a[i][mn]>a[i][j+1])
		mn=j+1;
	    }
	    if(b[q|(1<<i)]>p+a[i][mn])
	      c.push(make_pair(p+a[i][mn],q|(1<<i)));
	  }
	}
      }
    }
    cout<<c.top().first<<endl;    
  }
  return 0;
}

Measured memory_bytes: 2260
import numpy as np


A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = np.array([])
for _ in range(N):
    b = np.append(b, int(input()))
    
A = np.array([A1, A2, A3])
index = np.zeros((3,3))
for i in b:
  index += np.array(A==i, dtype=np.int)
retu = np.sum(index, axis=0)
gyou = np.sum(index, axis=1)
if np.any(retu >= 3):
  ans1 = 1
else:
  ans1 = 0

if np.any(gyou >= 3):
  ans2 = 1
else:
  ans2 = 0
  

if np.trace(index) >= 3:
  ans3 = 1
else:
  ans3 = 0
index = index[:, ::-1]
if np.trace(index) >= 3:
  ans4 = 1
else:
  ans4 = 0

y = ans1 + ans2 + ans3 + ans4
if y == 0:
  print("No")
else:
  print("Yes")
      
  

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

int main() {

    ll N;
    cin >> N;

    vl A(2e5+9);
    vl B(2e5+9, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        B[A[i]]++;
    }

    ll ans = 0;
    for (int i = 1; i <= N; ++i) {
        ans += B[i]*(B[i]-1)/2;
    }

    for (int k = 0; k < N; ++k) {
        int n = B[A[k]];
        cout << ans - n*(n-1)/2 + (n-1)*(n-2)/2 << endl;;
    }

    return 0;
}


Measured memory_bytes: 5760
class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n
    
    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            return self.root(self.parents[x])
    
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return
        else:
            if x > y:
                x, y = y, x
            self.parents[x] += self.parents[y]
            self.parents[y] = x
            return

n, m, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
cd = [list(map(int, input().split())) for _ in range(k)]

u = UnionFind(n)
f = [set() for _ in range(n)]
l = [set() for _ in range(n)]
for a, b in ab:
    a, b = a-1, b-1
    f[a].add(b)
    f[b].add(a)
    u.unite(a, b)
for c, d in cd:
    c, d = c-1, d-1
    l[c].add(d)
    l[d].add(c)
ans = [0] * n
for i in range(n):
    r = u.root(i)
    bl = 0
    for j in l[i]:
        if u.root(j) == r:
            bl += 1
    ans[i] = -u.parents[r] - len(f[i]) - bl - 1
print(' '.join(list(map(str, ans))))

Measured memory_bytes: 142448
#include <stdio.h>
int main(void){
	int a=0,i;
	char s[4],t[4];
	scanf("%s%s",s,t);
	for(i=0;i<3;i++){
		if(s[i]==t[i])a++;
	}
	printf("%d",a);
	return 0;
}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

int vector_finder(vector<int> vec, int number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}


int main() {
	int n, k;
	cin >> n >> k;
	VI v(k);
	REP(i, k) {
		cin >> v[i];
	}
	SORT(v);

	string s;
	int f = 1;
	FOR(i, n, 10 * n) {
		s = to_string(i);
		f = 1;
		REP(j, s.size()) {
			if (vector_finder(v, s[j] - '0')==1) {
				f = 0;
				break;
			}
		}
		if (f == 1) {
			cout << i << endl;
			return 0;
		}

	}




	return 0;
}



Measured memory_bytes: 632
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int s = sc.nextInt();
		int cnt = 0;
	    
		for(int x=0;x<=k;x++) {
			for(int y=0;y<=k;y++) {
				int z = s-x-y;
				if( 0<=z && z<=k ) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}


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

void cal(int N,int m,string str){
	if(m==0){
		for(int i=0;i<str.size();i++){
			int in;
			in=str[i];
			cout<<in;
			if(i+1==str.size())cout<<endl;
			else cout<<" ";
		}
	}
	else{
		for(int i=min(N,m);i>0;i--){
			
			string ka=str;
			char cc;
			cc=i;
			ka+=cc;
			cal(i,m-i,ka);
		}
	}
	
}



int main(){
	
	int n;
	
	while(cin>>n,n){
		for(int i=n;i>0;i--){
			string STR;
			char ch;
			ch=i;
			STR+=ch;
			cal(i,n-i,STR);
		}
		
		
	}
	
	
	
	return 0;
}


Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int K,A,B;
    cin>>K>>A>>B;
    if(K<=A) {
        cout<<1<<endl;
        return 0;
    }
    if(A<=B) {
        cout<<-1<<endl;
        return 0;
    }
    K-=A;
    int l=K/(-B+A);
    if((-B+A)*l>=K) {
        cout<<l*2+1<<endl;
    } else {
        cout<<(l+1)*2+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')

#2211
#import numpy as np

def main():
	a,b,k=MI()

	a1=max(0,a-k)
	a2=min(b,max(0,a+b-k))

	print(a1,a2)



if __name__ == "__main__":
	main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define Maxn 30
#define NIL -1
using namespace std;
typedef struct{
	int parent, left, right;
}Node;
Node T[Maxn];
void init(int n){
	for(int i = 0; i < n; i++) T[i].left = T[i].parent = T[i].right = -1;
}
void Inorder(int u){
	if(T[u].left != NIL) Inorder(T[u].left);
	printf(" %d", u); 
	if(T[u].right != NIL) Inorder(T[u].right);
}
void Preorder(int u){
	printf(" %d", u);
	if(T[u].left != NIL) Preorder(T[u].left);
	if(T[u].right != NIL) Preorder(T[u].right);
}
void Postorder(int u){
	if(T[u].left != NIL) Postorder(T[u].left);
	if(T[u].right != NIL) Postorder(T[u].right);
	printf(" %d", u);
} 
int main()
{
	int n, id, l, r;
	scanf("%d", &n);
	init(n);
	for(int i = 0; i < n; i++){
		scanf("%d%d%d", &id, &l, &r);
		T[id].left = l;
		T[id].right = r;
		if(l != NIL) T[l].parent = id;
		if(r != NIL) T[r].parent = id;
	}
	int root = 0;
	while(T[root].parent != NIL) root++;
	printf("Preorder\n");
	Preorder(root);
	printf("\nInorder\n");
	Inorder(root);
	printf("\nPostorder\n");
	Postorder(root);
	printf("\n");
	return 0;
}


Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		if (n % 2 == 0) {
			System.out.println(n);
		} else {
			System.out.println(n * 2);
		}

		sc.close();
	}
}

Measured memory_bytes: 21332
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[2000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a*2;i++){
		scanf("%d",b+i);
	}
	std::sort(b,b+a*2);
	int ret=0;
	for(int i=0;i<a;i++){
		ret+=min(b[i*2],b[i*2+1]);
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 128
<?php
$odd = str_split(trim(fgets(STDIN)));
$even = str_split(trim(fgets(STDIN)));
$count = count($odd);
$text = "";
$i = 0;
while($i < $count){
    $text .= $odd[$i];
    if(!(empty($even[$i]))){
        $text .= $even[$i];
    }
    ++$i;
}
echo $text;

Measured memory_bytes: 3700
if __name__ == "__main__":
    n = int(input())
    csf = list()
    for i in range(n-1):
        csf.append(list(map(int, input().split())))

    for i in range(n):
        ans = 0
        for j in range(i, n-1):
            if ans <= csf[j][1]:
                ans = csf[j][1]
                ans += csf[j][0]
            else:
                tmp = (csf[j][2] - ans % csf[j][2]) % csf[j][2]
                ans += tmp
                ans += csf[j][0]
        print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, const char *argv[]) {
  int N;
  double res = 0;
  cin >> N;
  vector<long int> V(N);
  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }

  sort(V.begin(), V.end());
  res = (V[0] + V[1]) / 2.0;
  for (int i = 2; i < N; i++) {
    res = (res + V[i]) / 2.0;
  }
  printf("%f\n", res);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(1 << n);
    for (auto &e : a) std::cin >> e;
    std::vector<std::pair<int, int>> dp(1 << n, std::make_pair(-1, -1));
    for (int i = 0; i < (1 << n); i++) {
        dp[i].first = i;
    }
    for (int i = 0; i < n; i++) for (int j = 0; j < (1 << n); j++) {
        if (j & (1 << i)) {
            int k = j ^ (1 << i);
            if (a[dp[j].first] < a[dp[k].first]) {
                dp[j].second = dp[j].first;
                dp[j].first = dp[k].first;
            } else if (dp[j].second < 0 || a[dp[j].second] < a[dp[k].first]) {
                dp[j].second = dp[k].first;
            }

            if (dp[k].second >= 0 && a[dp[j].second] < a[dp[k].second]) {
                dp[j].second = dp[k].second;
            }
        }
    }

    int max = 0;
    for (int i = 1; i < (1 << n); i++) {
        max = std::max(max, a[dp[i].first] + a[dp[i].second]);
        std::cout << max << std::endl;
    }

    return 0;
}


Measured memory_bytes: 6272
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a == b){
        if(a !=c)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else{
        if(a == c)cout<<"Yes"<<endl;
        else{
            if(b == c)cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 int main() {
   string A,B,C;
   cin >>A>>B>>C;
   char x,y,z;
   x = A.at(0)-0x20;
   y = B.at(0)-0x20;
   z = C.at(0)-0x20;

   cout << x <<y << z<<endl;
}

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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define pb push_back
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e6 + 7;
const int MX = 1e9 + 7;
const LL INF = 1e18 + 9LL;

int n, x;
int tab[N];

int main(){
	scanf("%d %d", &n, &x);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &tab[i]);
	sort(tab + 1, tab + n + 1);
	
	int res = 0;
	for(int i = 1; i <= n; ++i){
		if(x >= tab[i]){
			++res;
			x -= tab[i];
		}
		else{
			x = 0;
			break;
		}
	}
	
	if(x > 0)
		--res;
	printf("%d\n", res);
	return 0;
}

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

int main()
{
  int a, b, c, d;
  int rnd = 1;
  cin >> a >> b >> c >> d;

  while(a > 0 && c > 0) {
    if (rnd % 2 == 1) c -= b;
    else a -= d;
    rnd++;
  }
  if (a > 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

typedef long long ll;

ll N;
deque<ll> B;
bool Normal = true;

int main() {
  cin >> N;
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    if (Normal)
      B.push_back(a);
    else
      B.push_front(a);
    Normal = !Normal;
  }
  for (ll i = 0; i < N; ++i)
    cout << (i == 0 ? "" : " ") << B[Normal ? i : N - 1 - i];
  return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int box[100000];
	int cnt;
	int MAX;
	int i;
	cin>>n;
	for(i=0;i<n;i++)	cin>>box[i];
	cnt=0;
	MAX=-1;
	for(i=n-1;i>0;i--){
		if(box[i]<=box[i-1])	cnt++;
		else{
			MAX=max(MAX,cnt);
			cnt=0;
		}
	}
	MAX=max(MAX,cnt);
	cout<<MAX<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

long long act(int kukki) {
	if (kukki % 2 != 0) {
		kukki = kukki - 1;
	}
	kukki = kukki / 2;
	return kukki;
}

int main() {
	long long A,B,N;
	cin >> A>>B>>N;
	bool flg = true;
	for (int i = 0; i < N; i++) {
		if (flg == true) {
			A = act(A);
			B = B + A;
		}
		else {
			B = act(B);
			A = A + B;
		}
		flg = !flg;
	}
	cout << A <<" "<<B;
	return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            var s = new string(n.Reverse().ToArray());
            if (n == s.ToString())
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


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

int main(){
  int n;
  cin >> n;
  
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  
  for(int i = 0;i < n;i ++){
    string s;
    cin >> s;
    if(s == "AC")ac ++;
    else if(s == "WA")wa ++;
    else if(s == "TLE")tle ++;
    else if(s == "RE")re ++;
  }
  
  cout << "AC x " << ac << endl <<
          "WA x " << wa << endl <<
          "TLE x " << tle << endl <<
          "RE x " << re << endl;
}

Measured memory_bytes: 3624
N = gets.to_i
A, B = N.times.map{ gets.split.map(&:to_i) }.transpose
A.sort!
B.sort!
if N.odd?
  ma = A[N/2]
  mb = B[N/2]
  puts (mb - ma).abs + 1
else
  ma = (A[N / 2 - 1] + A[N / 2]) 
  mb = (B[N / 2 - 1] + B[N / 2])
  puts (mb - ma).abs + 1
end

Measured memory_bytes: 32832
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int sub(int i,int j){
  int b=1;
  if(j==3)return 0;
  for(int a=1;a<=i;a++){
    b*2;
  }
  return 1/b+(i+1)*sub(i+1,j+1);
}
int main() {
  int a,b;
  int c,d=1;
  cin>>a>>b;
  cout<<a*a-b;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int a,b,c;cin>>a>>b>>c;
  cout<<max(max(a*10+b+c,b*10+a+c),c*10+a+b)<<endl;

  return 0;
}


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

vector<ll> A;
 
signed main(){
	int N;
	cin >> N;
	A = vector<ll>(N);
	for(int i = 0; i < N; i++){
		cin >> A.at(i);
	}
	ll money = 1000;
	for(int i = 0; i < N-1; i++){
		if(A.at(i) < A.at(i+1)){
			money = money%A.at(i)+money/A.at(i)*A.at(i+1);
		}
	}
	cout << money << endl;
 
	return 0;
}

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

int main() {
int N; int A; int B;
  cin>>N>>A>>B;
  string S;
  cin>>S;
  int X=0; int C=0; //XはBのかず　CはA+Bのかず
  for(int i=0; i<N; i++){
    
if(S.at(i)=='c')
  cout<<"No"<<endl;
  else if(S.at(i)=='a'){
   
if(C<=A+B-1){
  cout<<"Yes"<<endl;
    C++;
  }
    else cout<<"No"<<endl;
  }
    else{
      
      if(C<=A+B-1&&X<=B-1){
        cout<<"Yes"<<endl;
      X++;
      C++;
    }
      else cout<<"No"<<endl;
    }
  }
}


Measured memory_bytes: 896
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

int main(){
    ll n;
    cin>>n;
    string s[n];
    rep(i,0,n-1) cin>>s[i];
    sort(s,s+n);
    ll cnt = 0;
    pair<string ,ll> hoge[n];
    int piyo = 0;
    int max = 0;
    rep(i,0,n-1){
        if(s[i]==s[i+1]) cnt++;
        else {
            hoge[piyo].first = s[i];
            hoge[piyo].second = cnt;
            piyo++;
            if(max<cnt){
                max = cnt;
            }
            cnt = 0;
        }
    }
    rep(i,0,piyo-1){
        if(hoge[i].second==max) cout<<hoge[i].first<<endl;
    }
    return 0;
}

Measured memory_bytes: 17408
#!/usr/bin/env pypy3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import math,sys

a,b,c,d = map(int,sys.stdin.readline().split())
print(max([a*c,a*d,b*c,b*d]))


Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n,a=0,rem;
    cin>>n;
    while(n>0)
    {
        rem=n%10;
        if(rem==7)
        {
            a=1;
            cout<<"Yes";
            break;
        }
        n=n/10;
    }
    if(a==0)
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3600
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back
#define MAX 5000000000000000
using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
// ll po(ll a){
// 	ll res=1,b=MAX;
// 	while(b>0){
// 		if(b&1){
// 			res=res*a;
// 		}
// 		a=a*a;
// 		if(a>=1e18){
// 			return a;
// 		}
// 		b=b>>1;
// 		cout<<"res="<<res<<"a="<<a<<"b="<<b<<endl;
// 	}
// 	return res;
// }
// ll solve(string s,ll ind){
// 	if(s[ind]=='1'){
// 		return ind+1;
// 	}
// 	int cd=s[ind]-'0';
// 	ll count=po(cd);
// 	cout<<"count"<<count<<"cd="<<cd<<endl;
// 	return ind+count;
// }
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	string s;int k;cin>>s>>k;
	if(k==1){
		cout<<s[0]<<endl;
		return 0;
	}
	for(int i=0;i<s.size();i++){
		if(s[i]!='1'){
			cout<<s[i]-'0'<<endl;
			return 0;
		}
		else if(s[i]=='1'){
			if(k<=i+1){
				cout<<1<<endl;
				return 0;
			}
		}
		else if(i==s.size()-1){
			cout<<s[i]-'0'<<endl;
		}
	}
}

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

typedef long long ll;

const int N = 3001;
const int MOD = 998244353;
int a[N];
int n, s;
ll dp[N];

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

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

    for (int i = 0; i < n; ++i) {
        dp[0]++;
        for (int j = s; j >= a[i]; --j) {
            dp[j] += dp[j - a[i]];
            dp[j] %= MOD;
        }
        ans = (ans + dp[s]) % MOD;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	string s; cin >> s;
	string a[] = { "dreamer", "dream", "eraser", "erase" };
	for (int i = 0; i < 4; ++i) reverse(a[i].begin(), a[i].end());
	reverse(s.begin(), s.end());
	for (int i = 0; i < (int)s.length(); ++i) {
		bool flag = false;
		for (int j = 0; j < 4; ++j) {
			if (s.substr(i, a[j].length()) == a[j]) {
				i += a[j].length() - 1;
				flag = true;
				break;
			}
		}
		if (!flag) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 512
A = int(input())
B = int(input())
if (A == 1 and B == 2) or ( A == 2 and B == 1):
    print(3)
elif ( A == 2 and B == 3) or (A ==3 and B == 2):
    print(1)
elif ( A == 1 and B == 3) or (A ==3 and B == 1):
    print(2)



Measured memory_bytes: 3060
import numpy as np
# Me


def f():
    i = int(input())
    nums = np.array(list(map(int, input().split())))
    # nums = [int(x) for x in input().split()]
    c = 0
    while True:
        if any(nums % 2 == 1):
            break
        c += 1
        nums = nums / 2
    print(c)


f()


# Other


Measured memory_bytes: 17932
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec() -> Vec<i32> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect()
}

fn main() {
    let N: i32 = read_line().parse().unwrap();
    let A: Vec<i32> = read_vec();
    let B: Vec<i32> = read_vec();
    let C: Vec<i32> = read_vec();
    let mut satisfaction = 0;
    let mut prev = -1;
    for i in A {
        satisfaction += B[(i-1) as usize];
        if prev + 1 == i {
            satisfaction += C[(prev-1) as usize];
        }
        prev = i;
    }
    println!("{}", satisfaction);
}


Measured memory_bytes: 4352
from collections import defaultdict, deque
N,M=map(int,input().split())

outs = defaultdict(list)
outs_rev = defaultdict(list)
ins = defaultdict(int)
for _ in range(N+M-1):
  v1,v2=map(int,input().split())
  outs[v1].append(v2)
  outs_rev[v2].append(v1)
  ins[v2] += 1
#print(outs,ins)
#print(outs_rev)

q = deque(v1 for v1 in range(1,N+1) if ins[v1] == 0)
res = []
while q:
  v1 = q.popleft()
  res.append(v1)
  for v2 in outs[v1]:
    ins[v2] -= 1
    if ins[v2] == 0:
      q.append(v2)
#print(res)

res_rev=[0]*N
for i in range(N):
  res_rev[res[i]-1]=i
#print(res_rev)

answer_list=[0]*N
for i in range(N):
  r=res[i]
  if not outs_rev[r]:
    answer_list[r-1]=0
  else:
    max_v=-1
    max_index=-1
    for rr in outs_rev[r]:
      ind=res_rev[rr-1]
      if ind>max_index:
        max_v=res[ind]
        max_index=ind
  
    answer_list[r-1]=max_v
    
#print(answer_list)
for ans in answer_list:
  print(ans)

Measured memory_bytes: 142436
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  int d, n;
  cin >> d >> n;

  vector<int> a;
  vector<int> b;
  vector<int> c;

  if(d==0){
    if(n==100) cout << n+1 << endl;
    else cout << n << endl;
  }

  if(d==1){
    if(n==100) cout << n*100+100 << endl;
    else cout << 100*n  << endl;
  }

  if(d==2){
    if(n==100) cout << n*n*100+n*n << endl;
    else cout << 100*100*n << endl;
  }
  return 0;
}

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

// 抽象化したセグメント木
template <class Monoid>
struct SegTree {
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func F;
  const Monoid UNITY;
  int SIZE_R;
  vector<Monoid> dat;

  SegTree(int n, const Func f, const Monoid &unity) : F(f), UNITY(unity) {
    init(n);
  }
  void init(int n) {
    SIZE_R = 1;
    while (SIZE_R < n) SIZE_R *= 2;
    dat.assign(SIZE_R * 2, UNITY);
  }

  /* set, a is 0-indexed */
  void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
  void build() {
    for (int k = SIZE_R - 1; k > 0; --k) dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
  }

  /* update a, a is 0-indexed */
  void update(int a, const Monoid &v) {
    int k = a + SIZE_R;
    dat[k] = v;
    while (k >>= 1) dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
  }

  /* get [a, b), a and b are 0-indexed */
  Monoid get(int a, int b) {
    Monoid vleft = UNITY, vright = UNITY;
    for (int left = a + SIZE_R, right = b + SIZE_R; left < right;
         left >>= 1, right >>= 1) {
      if (left & 1) vleft = F(vleft, dat[left++]);
      if (right & 1) vright = F(dat[--right], vright);
    }
    return F(vleft, vright);
  }
  inline Monoid operator[](int a) { return dat[a + SIZE_R]; }

  /* debug */
  void print() {
    for (int i = 0; i < SIZE_R; ++i) {
      cout << (*this)[i];
      if (i != SIZE_R - 1) cout << ",";
    }
    cout << endl;
  }
};

// 最長増加部分列の長さを求める
int LIS(const vector<int> &a, int k) {
  int n = (int)a.size();

  // セグメント木 (区間取得を max としたもの)
  SegTree<int> dp(
      300050, [](int a, int b) { return max(a, b); }, 0);

  // 更新
  int res = 0;
  rep(i, n) {
    int h1 = max(a[i] - k, 0);
    int h2 = min(a[i] + k, 300040);
    // 値取得
    int A = dp.get(h1, h2 + 1);

    // 更新
    if (dp.get(a[i], a[i] + 1) < A + 1) {
      dp.update(a[i], A + 1);
      res = max(res, A + 1);
    }
  }
  return res;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  cout << LIS(a, k) << endl;
}

Measured memory_bytes: 8472
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
using namespace std;


long long gcd(long long a, long long b){
    long long tmp;
    if (a < b){
        tmp = b;
        b = a;
        a = tmp;
    }
    while(b > 0){
        tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}

int main(){
    int n;
    cin >> n;
    long long answer, a;
    cin >> answer;
    for (int i = 1; i < n; i++){
        cin >> a;
        answer = gcd(a, answer);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
import std;
import core.bitop;

// dfmt off
ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
void aryWrite(T = long)(T[] ary){ ary.map!(x => x.text()).join(' ').writeln(); }
alias Pair = Tuple!(long, "H", long, "W", long, "cost");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto s = lread();
    auto dp = new long[](s + 1);
    foreach (i; iota(3, s + 1))
    {
        dp[i] += 1;

        foreach (j; iota(i))
        {
            if (i - j >= 3)
            {
                dp[i] += dp[j];
                dp[i] %= MOD;
            }
        }
        dp[i] %= MOD;
    }
    // dp.writeln();
    dp[s].writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define fi first
#define se second
#define pb push_back
#define mp make_pair 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
#define all(x) (x).begin(),(x).end()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using vll = vector<ll>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}


clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
const int N = 100100;
ll mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	startTime = clock();
	int n;
	cin>>n;
	vll a(n);
	rep(i,n)cin>>a[i];
	ll pr = 1;
	rep(i,n){
		if(a[i]==0) {
			cout<<"0"<<nl;
			return 0;
		}
	}
	rep(i,n){
		if(pr*(double)a[i] > (ll)1e18){
			cout<<"-1"<<nl;

			return 0;
		}
		pr = pr*a[i];
	}
	
	if(pr > (ll)1e18)cout<<"-1";
	else
	cout<<(ll)pr<<nl;
	return 0;
}



Measured memory_bytes: 4044
from collections import deque
import sys
input=sys.stdin.readline

n=int(input())
lst=[i for i in input().split()]
q=deque([])
for i in range(n):
    if n%2==1:
        if i%2==0:
            q.appendleft(lst[i])
        else:
            q.append(lst[i])
    else:
        if i%2==0:
            q.append(lst[i])
        else:
            q.appendleft(lst[i])

print(" ".join(q))

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

int n, cnt = 0;

void solve(int x) {
  int cntn = 0;
  for(int i = 1; i <= x; ++i)
    if(x % i == 0) ++cntn;
  if(cntn == 8 && x % 2 == 1) ++cnt;
}

int main() {
  cin >> n;
  for(int i = 1; i <= n; ++i) solve(i);
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter

s = input()
snotx = "".join([ch for ch in s if ch != 'x'])

if s == s[::-1]:
    print(0)
    exit()

if snotx != snotx[::-1]:
    print(-1)
    exit()

# 回数を合わせる
# print(s)
# print(snotx)

# xのrun-length
rl = []
i = 0
while i < len(s): 
    j = i
    while j < len(s) and s[j] == 'x':
        j += 1
    rl.append(j - i)
    i = j + 1
if s[-1] != 'x':
    rl.append(0)

# run-lengthの左右を見て合わせる
res = 0
i = 0
while i * 2 < len(rl):
    res += max(rl[i], rl[len(rl) - i - 1]) - min(rl[i], rl[len(rl) - i - 1])
    i += 1
print(res)


Measured memory_bytes: 47216
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,k;
	cin>>k>>n;
	ll a[n];
	vii dis;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	for(ll i=1;i<n;i++){
		dis.pb({a[i]-a[i-1] ,i});
	}
	dis.pb({a[0]+k-a[n-1] ,0});
	sort(dis.begin(),dis.end());
	ll ans=0;
	for(ll i=0;i<n-1;i++){
		ans+=dis[i].first;
	}
	cout<<ans;
	
	
	return 0;
}

Measured memory_bytes: 8104
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;

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

    cout << n * n * n << endl;
    return 0;
}



Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
# S = input()
#n = int(input())
N, P = map(int, input().split())
#a = list(map(int, input().split()))
# LR = [list(map(int, input().split())) for _ in range(M)]

def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

ans = 1
innsuu = prime_factors(P)

innsuu.sort()

if (N == 1):
    print(P)
else:
    count = 1
    count_num = 0
    for i in innsuu:
        if (count_num == i):
            count += 1
        else:
            count_num = i
            count = 1

        if (count == N):
            ans *= count_num
            count = 1
            count_num = 0

    print(ans)

Measured memory_bytes: 5788
N, K = map(int, input().split())
arr = list(map(int, input().split()))
def f(x):
    res = 0
    for i in range(N):
        if arr[i] % x != 0:
            res += arr[i]//x
        else:
            res += max((arr[i]//x)-1,0)
    return res
left = 0
right = max(arr)
while abs(left-right) > 1:
    tmp = (left+right)//2
    if f(tmp) > K:
        left = tmp
    else:
        right = tmp
print(right)

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

int main(){
  int n;
  cin >> n;
  int x = 0;
  int y = 0;
  int k=0;
  int m=0;
  for(int i=0; i<n; i++){
    cin >> y;
//    cout << x << y << endl;
    if(x >= y){
      k += 1;
      m = max(m,k);
    } else {
      k = 0;
    }
    x = y;
  }
  cout << m;
}

Measured memory_bytes: 256
// AOJ 0070 Combination of Number Sequences

#include <iostream>

using namespace std;

void set_count(int n, int sum, int used);

const int MAX_N = 10;
const int MAX_SUM = 330;

int count_s[MAX_N + 1][MAX_SUM + 1];

int
main()
{
    int n, s;

    set_count(1, 0, 0);

    while (cin) {
        cin >> n >> s;
        if (cin.eof()) break;

        if (1 <= n && n <= 10 && 0 <= s && s <= 330)
            cout << count_s[n][s] << endl;
        else
            cout << 0 << endl;
    }

    return 0;
}

void
set_count(int depth, int sum, int used)
{
    int new_sum;
    int i, used_i;

    for (i = 0; i < 10; i++) {
        used_i = 1 << i;
        if (used & used_i) continue;

        new_sum = sum + depth * i;
        count_s[depth][new_sum] += 1;

        if (depth < MAX_N)
            set_count(depth + 1, new_sum, used | used_i);
    }
}

Measured memory_bytes: 1172
n,k = map(int,input().split())
d = [0 for _ in range(k)]
a = []
for i in range(k):
    d[i] = int(input())
    a.append(list(map(int,input().split())))
sn = [0 for _ in range(n)]
for i in range(k):
    for j in range(d[i]):
        sn[a[i][j]-1] = 1
ans = 0
print(sn.count(0))

Measured memory_bytes: 9288
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){

  int n;
  for(;cin>>n,n;)
    {
      int fire=0;
      int two=0;
      for(int i=2;i<=n;i++)
	{
	  int tmp=i;
	  while(tmp%2==0)
	    {
	      tmp=tmp/2;
	      two++;
	    }
	  while(tmp%5==0)
	    {
	      tmp=tmp/5;
	      fire++;
	    }
	}
      cout<<min(two,fire)<<endl;
    }

}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li k, n;
    cin >> k >> n;

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

    li ans = k - as[0] - (k - as[n - 1]); 
    for (int i = 0; i < n - 1; ++i) {
        ans = min(ans, k - (as[i + 1] - as[i]));
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
	int n,k,i=1,j,num,ans;
	cin >> n;
	cin >> k;
	while(1){
		num = 1;
		for(j = 0; j < i; j++){
			num = num*k;
		}
		if(n < num){
			ans = i;
			break;
		}
		i++;
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

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

const int mod = 1e9 + 7;
const int maxn = 105;
int dp[maxn][2], pd[maxn][2];

void add(int& a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}

int main() {
    string s;
    int d;
    cin >> s >> d;
    int n = s.size();
    pd[0][0] = 1;
    REP(i, n) {
        memset(dp, 0, sizeof(dp));
        REP(j, d) REP(can_bigger, 2) REP(digit, 10) {
            if (digit > s[i] - '0' && !can_bigger) break;
            int x = can_bigger || (digit < s[i] - '0');
            add(dp[(j + digit) % d][x], pd[j][can_bigger]);
        }
        REP(j, d) REP(k, 2) pd[j][k] = dp[j][k];
    }
    int ans = (dp[0][0] + dp[0][1] - 1 + mod) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> PL;
typedef long double ldouble;

void solve(){
	int n, c, k;
	int A[100010];
	cin >> n >> c >> k;
	rep(i, n)scanf("%d", A+i);
	sort(A, A+n);
	int ans = 0;
	for(int i=0, p=-1e9, cn=0;i<n;i++){
		if(p < A[i] || cn == c)++ans, p = A[i] + k, cn = 1;
		else ++cn;
	}
	printf("%d\n", ans);
}

int main(){
	int Tc = 1; // scanf("%d", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		//printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <cmath>
#include <queue>
using namespace std;
using PP = pair<int, int>;
const int INF = 1e9;

template <class T> T Next() { T t; cin >> t; return t; }

const int MOD = 1000000007;
int h, w, k;
vector<int> v;
long DP[101][8];
long calc() {
  DP[0][0] = 1;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      for (int s : v) {
        if (s & (1 << j)) {
		  DP[i + 1][j + 1] += DP[i][j];
		  DP[i + 1][j + 1] %= MOD;
        } else if (j > 0 && (s & (1 << (j - 1)))) {
		  DP[i + 1][j - 1] += DP[i][j];
		  DP[i + 1][j - 1] %= MOD;
        } else {
		  DP[i + 1][j] += DP[i][j];
		  DP[i + 1][j] %= MOD;
        }
      }
    }
  }
  return DP[h][k - 1];
}

void pre() {
  for (int s = 0; s < (1 << w) / 2; ++s) {
    bool ok = true;
    for (int k = 0; k < w - 2; ++k) {
      bool a = s & (1 << k);
      bool b = s & (1 << (k + 1));
      if (a && b) ok = false;
    }
    if (ok) v.push_back(s);
  }
}

int main() {
  cin >> h >> w >> k;
  pre();
  cout << calc() << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

void chmax(ll& a, ll b) {
    if (a < b) a = b;
}

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

    ll N;
    cin >> N;

    vll A(N);
    REP(i, N) cin >> A[i];

    vector<vll> dp(N, vll(3, -INF));
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = A[0];
    REP(i, N - 1) {
        auto &nxt = dp[i+1], &cur = dp[i];
        if (N & 1) {
            if (i & 1) {
                chmax(nxt[0], cur[1]);
                chmax(nxt[0], cur[2]);
                chmax(nxt[1], cur[0] + A[i+1]);
                chmax(nxt[2], cur[2] + A[i+1]);
            } else {
                chmax(nxt[0], cur[0]);
                chmax(nxt[0], cur[1]);
                chmax(nxt[1], cur[0] + A[i+1]);
                chmax(nxt[2], cur[2]);
            }
        } else {
            if (i & 1) {
                chmax(nxt[0], cur[0]);
                chmax(nxt[0], cur[2]);
                chmax(nxt[2], cur[0] + A[i+1]);
            } else {
                chmax(nxt[0], cur[2]);
                chmax(nxt[2], cur[0] + A[i+1]);
            }
        }
    }

    if (N&1) print(max(dp[N-1][0], dp[N-1][1]));
    else print(max(dp[N-1][0], dp[N-1][2]));

}


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

int n, A, B, C, l[9], INF = 1e9;

int rec(int i, int a, int b, int c){
    if (i == n){
        if (!a || !b || !c) return INF;
        return abs(a - A) + abs(b - B) + abs(c - C);
    }
    return min({rec(i + 1, a, b, c), rec(i + 1, a + l[i], b, c) + (a ? 10 : 0), rec(i + 1, a, b + l[i], c) + (b ? 10 : 0), rec(i + 1, a, b, c + l[i]) + (c ? 10 : 0)});
}

int main(){
    cin >> n >> A >> B >> C;
    for (int i = 0; i < n; i++) cin >> l[i];
    cout << rec(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256