akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

const div = 1000000007

func Powmod(x, n int) int {
	res := 1
	for i := 0; i < n; i++ {
		res = (res * x) % div
	}
	return res
}

func main() {
	var n int
	fmt.Scan(&n)
	ans := Powmod(10, n) - 2*Powmod(9, n) + Powmod(8, n)
	ans %= div
	ans = (ans + div) % div
	fmt.Println(ans)
}


Measured memory_bytes: 1788
function Main(input) {
  input = input.split(" ");
  var a = parseInt(input[0], 10);
  var b = parseInt(input[1], 10);

  if ((a * b) % 2 == 0) {
    console.log('Even');
  } else {
    console.log('Odd');
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string s;
    int i;
    cin>>s;
    int ans=0,cnt=0;
    for (i=0;i<s.size();i++)
    {
        if (s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')
            cnt++;
        else
        {
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    ans=max(ans,cnt);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] ary = {1, 2, 3, 4, 5, 6};
        int sum = 1;
        while (sc.hasNext()) {
            int n = sc.nextInt();
            if (n == 0) break;
            for (int i = 0; i < n; i++) {
                rotate(sc.next(), ary);
                sum += ary[0];
            }
            
            System.out.println(sum);
            
            // ?????????
            sum = 1;
            ary[0] = 1;
            ary[1] = 2;
            ary[2] = 3;
            ary[3] = 4;
            ary[4] = 5;
            ary[5] = 6;
        }
        
    }
    
    public static void rotate(String inStr, int[] inAry) {
        int tmp;
        switch(inStr) {
            case "North":
                tmp = inAry[0];
                inAry[0] = inAry[1];
                inAry[1] = inAry[5];
                inAry[5] = inAry[4];
                inAry[4] = tmp;
                break;
            case "East":
                tmp = inAry[0];
                inAry[0] = inAry[3];
                inAry[3] = inAry[5];
                inAry[5] = inAry[2];
                inAry[2] = tmp;
                break;
            case "West":
                tmp = inAry[0];
                inAry[0] = inAry[2];
                inAry[2] = inAry[5];
                inAry[5] = inAry[3];
                inAry[3] = tmp;
                break;
            case "South":
                tmp = inAry[0];
                inAry[0] = inAry[4];
                inAry[4] = inAry[5];
                inAry[5] = inAry[1];
                inAry[1] = tmp;
                break;
            case "Right":
                tmp = inAry[1];
                inAry[1] = inAry[2];
                inAry[2] = inAry[4];
                inAry[4] = inAry[3];
                inAry[3] = tmp;
                break;
            case "Left":
                tmp = inAry[1];
                inAry[1] = inAry[3];
                inAry[3] = inAry[4];
                inAry[4] = inAry[2];
                inAry[2] = tmp;
                break;
            default:
                break;
        }
    }
}

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

using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n],ans,anss;
    for(int i=0; i<n; i++){
       cin >> a[i];   
    }
    int count = 0;
    for(int i=1; i<n-1; i++){
       ans = max(max(a[i-1],a[i]),a[i+1]);
       anss = min(min(a[i-1],a[i]),a[i+1]);
       if(ans == a[i] || anss == a[i])
         continue;
       else
         count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3592
N = int(input())
lst = []
for _ in range(N):
    A = int(input())
    items = []
    for _ in range(A):
        x, y = [int(x) for x in input().split()]
        x -= 1
        items.append((x, y))
    lst.append(items)

num_max = 0
for pat in range(1<<N):
    cond = True
    num = 0
    for i in range(N):
        # i番目の人が正直者の場合
        if (pat>>i) & 1 == 1:
            if all(pat>>x & 1 == y for x, y in lst[i]):
                num += 1
            else:
                cond = False
                break
    if cond:
        num_max = max(num, num_max)

print(num_max)

Measured memory_bytes: 49884
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
prev = None

for i in range(n):
#    print("\n i: " + str(i))
    idx = a[i] - 1
#    print('idx: ' + str(idx))
    ans += b[idx]
#    print('ans: ' + str(ans))
    if i > 0 and idx == prev + 1:
        ans += c[prev]
    prev = idx
#    print('prev: ' + str(prev))

print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;


int main()
{
    string S;
    cin >> S;
    int zero = 0, one = 0;
    for (auto c : S)
    {
        if (c == '0') zero++;
        else one++;
    }
    cout << min(zero, one) * 2 << endl;
    return 0;
}


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

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

    vector<string> v = {"dream", "dreamer", "erase", "eraser"};

    int i=(int)s.size()-1;

    string ans = "YES";

    while (i >= 4) {
        if (s.at(i) == 'r') {
            if (i-6 >= 0) {
                if (s.substr(i-6, 7) == "dreamer") {
                    i -= 7;
                } else if (s.substr(i-5, 6) == "eraser") {
                    i -= 6;
                } else {
                    ans = "NO";
                    break;
                }
            } else if (i-5 >= 0) {
                if (s.substr(i-5, 6) == "eraser") {
                    i -= 6;
                } else {
                    ans = "NO";
                    break;
                }
            } else {
                ans = "NO";
                break;
            }
        } else if (s.at(i) == 'm') {
            if (i-4 >= 0) {
                if (s.substr(i-4, 5) == "dream") {
                    i -= 5;
                } else {
                    ans = "NO";
                    break;
                }
            } else {
                ans = "NO";
                break;
            }
        } else if (s.at(i) == 'e') {
            if (i-4 >= 0) {
                if (s.substr(i-4, 5) == "erase") {
                    i -= 5;
                } else {
                    ans = "NO";
                    break;
                }
            } else {
                ans = "NO";
                break;
            }
        } else {
            ans = "NO";
            break;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX=100000;
static const int INFTY=2000000000;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;
int n;
vector<pair<int,int> > adj[MAX];
void dijkstra(){
    priority_queue<pair<int,int> >PQ;
    int d[MAX],color[MAX];
    for(int i=0;i<n;i++){
        d[i]=INFTY;
        color[i]=WHITE;
    }
    d[0]=0;
    PQ.push(make_pair(0,0));
    color[0]=GRAY;
    while(!PQ.empty()){
        pair<int,int> f=PQ.top();PQ.pop();
        int u=f.second;
        color[u]=BLACK;
        if(d[u]<f.first*(-1))continue;
        for(int j=0;j<adj[u].size();j++){
            int v=adj[u][j].first;
            if(color[v]==BLACK)continue;
            if(d[v]>d[u]+adj[u][j].second){
                d[v]=d[u]+adj[u][j].second;
                PQ.push(make_pair(d[v]*(-1),v));
                color[v]=GRAY;
            }
        }
    }
    for(int i=0;i<n;i++)
        cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<"\n";
}
int main(){
    int k,u,v,c;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>v>>c;
            adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra();
    return 0;
}




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

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

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int f(const vector<long long int>& v, long long int num) {
    if (v[0] >= num) return v.size();
    if (v.back() < num) return 0;
    int b = 0, e = v.size() - 1;
    while (b < e) {
        int m = (b + e) / 2;
        if (v[m] >= num) {
            e = m;
        } else {
            b = m + 1;
        }
    }
    return v.size() - b;
}

int main() {
    long long int n, m;
    cin >> n >> m;
    vector<long long int> v(n, 0), pre(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    pre = v;
    for (int i = n - 2; i >= 0; i--) {
        pre[i] += pre[i + 1];
    }
    long long int b = 2, e = 200000;
    while (b < e) {
        long long int mm = (b + e) / 2 + 1;
        long long int c = 0;
        for (int i = 0; i < n; i++) {
            int ret = f(v, mm - v[i]);
            c += ret;
        }
        if (c > m) {
            b = mm;
        } else if (c < m) {
            e = mm - 1;
        } else {
            b = mm;
        }
    }
    long long int res = 0;
    long long int c = 0;
    for (int i = 0; i < n; i++) {
        int ret = f(v, b - v[i]);
        c += ret;
        if (ret == 0) continue;
        res += pre[n - ret] + ret * v[i];
    }
    if (c > m) res -= (c - m) * b;
    cout << res << endl;
}









Measured memory_bytes: 4840
def main():
	length = int(input())
	target = list(map(int,input().split()))
	bubbleSort(target)

def bubbleSort(target):
	flag = True
	count = 0
	while flag:
		flag = False
		for i in range(len(target)-1,0,-1):
			if target[i] < target[i-1]:
				tmp = target[i]
				target[i] = target[i-1]
				target[i-1] = tmp
				flag = True
				count += 1


	print(*target,sep=' ')
	print(count)


if __name__ == '__main__':
	main()


Measured memory_bytes: 5608
#include <cstdio>
#include <algorithm>

long long cnt(long long a, long long b)
{
  long long ans = a * b;
  for (int i = 1; i < a; ++i)
  {
    long long top = i * b;
    long long left = (a - i) * (b / 2);
    long long right = a * b - top - left;
    long long dif = std::max(top, std::max(left, right)) - std::min(top, std::min(left, right));
    if (ans > dif) ans = dif;
  }
  return ans;
}

int main()
{
  long long h, w;
  scanf("%lld%lld", &h, &w);
  
  if (h % 3 == 0 || w % 3 == 0)
  {
    puts("0");
    return 0;
  }
  
  printf("%lld\n", std::min(std::min(h, w), std::min(cnt(h, w), cnt(w, h))));
  return 0;
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/abc153/tasks/abc153_b
//
#![allow(unused_imports)]
use std::io::*;
use std::io::Write;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, switch) => {
        {
            let ty = read_value!($iter, i32);
            if ty == 1 {
                vec![ty, read_value!($iter, i32), read_value!($iter, i32)]
            } else if ty == 2 {
                vec![ty, read_value!($iter, i32)]
            } else {
                vec![ty, read_value!($iter, i32)]
            }
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

// ===

fn main() {
    input! {
        h: i32, n: usize,
        a: [i32; n]
    };

    let sum = a.into_iter().fold(0, |a,c| a+c);
    println!("{}", ifv!(sum >= h, "Yes", "No"));
}


Measured memory_bytes: 4352
def multiples(l,r,d):
  
    c = 0
    if d == 0:
      return 0
    if d==1:
        return r-l+1
    i = l
    while i<=r:
        
        if i%d==0:
            c += 1
            i += d
            continue

        i += 1
        
    return c


if __name__ == '__main__':

    lrd = input().split()
    
    l = int(lrd[0])
    r = int(lrd[1])
    d = int(lrd[2])

    result = multiples(l,r,d)
    print(result)

Measured memory_bytes: 9136
#include <iostream>
#include <string.h>
using namespace std;
#define N 200005

int n,k,i,j,ans;
int a[N],f[N][20],g[N][20];

void build(){
    memset(g,60,sizeof(g));
    for(int i=1;i<=n;i++)f[i][0]=g[i][0]=a[i];
    for(int i=1;i<=18;i++)
    for(int j=(1<<i);j<=n;j++)
        f[j][i]=max(f[j][i-1],f[j-(1<<(i-1))][i-1]),
        g[j][i]=min(g[j][i-1],g[j-(1<<(i-1))][i-1]);
    return;
}
int askmin(int x){
    int now=k-1,ans=n;
    for(int i=18;i>=0;i--)
        if((1<<i)&now)ans=min(ans,g[x][i]),x-=(1<<i);
    return ans;
}
int askmax(int x){
    int now=k-1,ans=0;
    for(int i=18;i>=0;i--)
        if((1<<i)&now)ans=max(ans,f[x][i]),x-=(1<<i);
    return ans;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++)scanf("%d",&a[i]);
    build();
/*    for(i=1;i<=n;i++){
        for(j=0;j<=18;j++)
            printf("%d ",g[i][j]);
        putchar(10);
    }*/
    ans=1;
    for(i=k+1;i<=n;i++){
      //  printf("%d %d %d\n",i-1,askmax(i-1),askmin(i-1));
        if(a[i]>askmax(i-1)&&a[i-k]<askmin(i-1))ans--;
        ans++;
    }int num=0;
	for(i=2,j=1;i<=n;i++)
		if(a[i]>a[i-1])j++;
			else{if(j>=k)num++;j=1;}
	if(j>=k)num++;
	if(num)num--;
	printf("%d",ans-num);
    
    return 0;
}

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

using namespace std;

int n;

int v[100001];

int cautBin()
{
    int i = 0;
    int pas = 1 << 20;
    int nr = (v[n] + 1) / 2;
    while(pas != 0)
    {
        if(i + pas < n && v[i + pas] <= nr)
            i += pas;

        pas >>= 1;
    }

    //cout << v[i] << " " << v[n] - v[i + 1] << "\n";

    if(i + 1 == n || v[i] > v[n] - v[i + 1])
        return v[i];

    else
        return v[i + 1];

    return 0;
}

int main()
{
    cin >> n;

    int i;
    for(i = 1; i <= n; i ++)
        cin >> v[i];

    sort(v + 1, v + n + 1);

    cout << v[n] << " ";

    cout << cautBin() << "\n";

    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    
    static Scanner cin = new Scanner();
    static void Main() {
        int N = cin.Int();
        int M = cin.Int();

        var box = new int[100010]; //箱の中のボールの個数
        var flag = new bool[100010]; //赤いボールがある可能性
        flag[1] = true;

        for (int i = 1; i <= N; i++) {
            box[i] = 1;
        }
        for (int i = 0; i < M; i++) {
            int x = cin.Int();
            int y = cin.Int();
            if (flag[x]) flag[y] = true;
            if (box[x] == 1) flag[x] = false;
            box[x]--;
            box[y]++;
        }

        Console.WriteLine(flag.Count(x => x == true));
        Console.ReadLine();
    }
}

Measured memory_bytes: 15580
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 200000;

int kk[N];

int main() {
	int n; cin >> n;
	for (int i = 1; i < n; i++) {
		int a; cin >> a, a--;
		kk[a]++;
	}
	for (int i = 0; i < n; i++)
		cout << kk[i] << '\n';
	return 0;
}


Measured memory_bytes: 4412
/* ITP1_11_D: Dice IV */
/* 20181201 AOJ */

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

enum Direction {top, front, right, left, back, bottom};

typedef struct {
	int d[6];
} Dice;

void RotateWE(int* dice);
void RotateSN(int* dice);

int main(void) {
	int i, j, k, m, n, p, q;
	Dice *dice = NULL;
	
	scanf("%d", &q);
	dice = (Dice *)malloc(sizeof(Dice) * q);
	for(i = 0; i < q; i++) {
		for(j = 0; j < 6; j++) scanf("%d", dice[i].d + j);
	}

	for(i = 0; i < q - 1; i++)
	{
		for(j = i + 1; j < q; j++)
		{
			for(k = 0; k < 2; k++)
			{	
				for(m = 0; m < 4 ; m++)
				{
					for(n = 0; n < 4 ; n++)
					{
						for(p = 0; p < 6; p++)
						{
							if(dice[i].d[p] != dice[j].d[p]) break;
						}
						if(p == 6)
						{
							puts("No");
							return 0;
						}
						RotateWE(dice[i].d);
					} 
					RotateSN(dice[i].d);
				}
			    RotateWE(dice[i].d);
			}						
		}
	}

	puts("Yes");
	
	return 0;
}

void RotateWE(int* dice) {
	int temp = temp = dice[top];	
	dice[top] = dice[left];
	dice[left] = dice[bottom]; 
	dice[bottom] = dice[right];
	dice[right] = temp;
}

void RotateSN(int* dice){
	int temp = dice[top];
	dice[top] = dice[back];
	dice[back] = dice[bottom]; 
	dice[bottom] = dice[front];
	dice[front] = temp;
}


Measured memory_bytes: 2084
#include<stdio.h>
#include<stdlib.h>
void insertionSort(int *A,int N);
int main(){
  int *A,i,N,v,j;
  scanf("%d\n",&N);
  A=(int *)malloc(N*sizeof(int));
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
for(i=0;i<N-1;i++){
    printf("%d",A[i]);
    printf(" ");
  }
  printf("%d\n",A[N-1]);

  insertionSort(A,N);
  
  return 0;
}
void insertionSort(int *A,int N){
  int i,k,j,v;
  for(i=1;i<=N-1;i++){
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    
    for(k=0;k<N-1;k++){
    printf("%d",A[k]);
    printf(" ");
    }
    printf("%d\n",A[N-1]);
    
  }
}



Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int ans;
  if(a>=b&&a>=c){
    ans=min(abs(b-a)+abs(b-c),abs(c-a)+abs(b-c));
  }
  else if(b>=a&&b>=c){
    ans=min(abs(a-b)+abs(a-c),abs(c-b)+abs(a-c));
  }
  else{
    ans=min(abs(a-c)+abs(a-b),abs(b-c)+abs(a-b));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    int x, y;
    cin >> x >> y;
    Yes(y%2==0 && x*2<=y && x*4>=y);
}


Measured memory_bytes: 3620
N=int(input())
A=list(map(int,input().split()))
ans=[0]*N
for i in range(N):
  n=N-i
  add=A[n-1]
  n_tmp=n
  while True:
    n_tmp+=n
    if n_tmp>N:break
    if ans[n_tmp-1]:
      add=0 if add else 1
  if add:
    ans[n-1]=1
print(ans.count(1))
ans2=[]
for i,v in enumerate(ans):
  if v:
    ans2.append(i+1)
print(*ans2)

Measured memory_bytes: 17612
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	for(int n;cin>>n,n;){
		vector<vector<int>> p(n);
		for(int i=0;i<n;i++){
			int m; cin>>m;
			p[i].resize(m);
			for(int j=0;j<m;j++)
				cin>>p[i][j];
		}
		int k; cin>>k;
		vector<int> l(k);
		for(int i=0;i<k;i++)
			cin>>l[i];
		
		for(int i=0;i<n;i++)
			sort(p[i].begin(),p[i].end());
		sort(l.begin(),l.end());
		
		vector<int> c;
		for(int i=0;i<n;i++)
			if(includes(p[i].begin(),p[i].end(),l.begin(),l.end()))
				c.push_back(i);
		
		if(c.size()==1)
			cout<<c[0]+1<<endl;
		else
			cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1260
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
            if i==0 or i==H-1 or j==0 or j==W-1:
                print('#' , end='')
            else:
                print('.' , end='')
        print( )
    print()



Measured memory_bytes: 7004
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            string input;
            int count = 0;
            Regex[] winPattern = new Regex[]{
                new Regex(@"^(?:...){0,2}([ox])\1{2}"),
                new Regex(@"([ox])(..\1){2}"),
                new Regex(@"(?:([ox]).)(\1.){2}"),
                new Regex(@"(?:([ox])...)(\1...){1}\1"),
            };
            Dictionary<char, Action> action = new Dictionary<char, Action>{
                { 'o' , () => ++count },
                { 'x' , () => --count },
                { 's' , () => { return;} },
            };
            while((input = Console.ReadLine()) != null){
                string winner = "d";
                count = 0;
                foreach(Regex reg in winPattern) {
                    if(reg.IsMatch(input)) {
                        foreach(char c in input) {
                            action[c]();
                        }
                        winner = (count > 0 ? "o" : "x");
                        break;
                    }
                }
                Console.WriteLine(winner);
            }
        }
    }
}

Measured memory_bytes: 8112
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

#define mega 300005

signed main(){
	string s;
	cin>>s;
	int maxv,min_maxv=mega;
	int n=(int)s.size();
	rep(i,n-1){
		if(s[i]!=s[i+1]){
			maxv=max(i+1,n-(i+1));
			min_maxv=min(maxv,min_maxv);
		}
	}
	if(min_maxv==mega)min_maxv=n;
	cout<<min_maxv<<endl;
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

long long mod(long long a,long long b){
	long long i,sum=0,syou;
	while(1){
		
		i=a%b;
		syou=a/b;
		
		sum+=syou*b;
		
		a=b;
		b=i;
		
		if(i==0){
			return sum;
		}
	}
}

int main(){
	long long n,x,i;
	scanf("%lld %lld",&n,&x);
	
	if(2*x<n)
	i=mod(n-x,x);
	else
	i=mod(x,n-x);
	
	printf("%lld",i*3);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>

using namespace std;

int main()
{
	int a,b,c;
	scanf("%d %d %d", &a, &b,&c);

	if (a < b&&b < c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2616
/**
 *    author:  tourist
 *    created: 02.06.2019 16:00:27       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long x;
  cin >> n >> x;
  vector<long long> b(n), l(n), u(n);
  long long loss = 0;
  for (int i = 0; i < n; i++) {
    cin >> b[i] >> l[i] >> u[i];
    loss += b[i] * l[i];
  }
  vector<long long> value(n);
  for (int i = 0; i < n; i++) {
    value[i] = x * u[i] - b[i] * (u[i] - l[i]);
  }
  vector<int> order(n);
  iota(order.begin(), order.end(), 0);
  sort(order.begin(), order.end(), [&](int i, int j) {
    return value[i] > value[j];
  });
  vector<long long> pref(n + 1);
  for (int i = 0; i < n; i++) {
    pref[i + 1] = pref[i] + value[order[i]];
  }
  long long ans = (long long) 9e18;
  for (int it = 0; it < n; it++) {
    int i = order[it];
    for (long long coeff : {l[i], u[i]}) {
      int low = 0, high = n;
      while (low <= high) {
        int mid = (low + high) >> 1;
        long long cur = loss;
        if (coeff == u[i]) {
          cur += b[i] * (u[i] - l[i]);
        }
        long long can_get = pref[mid];
        long long vals = mid;
        if (it < mid) {
          can_get -= value[i];
          vals -= 1;
        }
        can_get += x * coeff;
        if (can_get >= cur) {
          can_get -= x * coeff;
          long long need = 0;
          if (can_get < cur) {
            need = (cur - can_get + coeff - 1) / coeff;
          }
          ans = min(ans, vals * x + need);
        }
        if (low == high) {
          break;
        }
        if (can_get >= cur) {
          high = mid;
        } else {
          low = mid + 1;
        }
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


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

double distance (vector<int> A, vector<int> B){
    int n = A.size();
    int ans = 0;
    for (int i = 0; i < n; i++){
        ans += (A.at(i) - B.at(i)) * (A.at(i) - B.at(i));
    }
    return sqrt(ans);
}

int main(){
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X (N, vector<int>(D));
    for (int i = 0; i < N; i++){
        for (int j = 0; j < D; j++){
            cin >> X.at(i).at(j);
        }
    }
    int count = 0;
    for (int i = 0; i < N; i++){
        for (int j = i + 1; j < N; j++){
            double d;
            d = distance(X.at(i), X.at(j));
            if (d == (int) d){
                count++;
            }
        }
    }
    cout << count << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

struct UnionFind {
  vector<int> parent;
  vector<int> num_node;

  UnionFind(int N) : parent(N), num_node(N, 1) {
    for (int i = 0; i < N; i++) {
      parent[i] = i;
    }
  }

  // 根を求める
  int root(int x) {
    if (parent[x] == x) {
      return x;
    }

    // 経路圧縮
    parent[x] = root(parent[x]);
    return parent[x];
  }

  // 同一判定
  bool is_same(int x, int y) {
    return this->root(x) == this->root(y);
  }

  // 併合
  void unite(int x, int y) {
    x = this->root(x);
    y = this->root(y);

    // すでに一緒ならなにもしない
    if (x == y) {
      return;
    }
    parent[x] = y;
    num_node[y] += num_node[x];
  }

  // 同一グループのノード数
  int size(int x) {
    return num_node[root(x)];
  }
};

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

  ll n, k, l;
  cin >> n >> k >> l;

  vector<UnionFind> uf(2, UnionFind(n + 1));

  rep(i, k) {
    ll p, q;
    cin >> p >> q;
    uf[0].unite(p, q);
  }

  rep(i, l) {
    ll r, s;
    cin >> r >> s;
    uf[1].unite(r, s);
  }

  map<P, ll> m;
  REP(i, n + 1) {
    P p = make_pair((ll)uf[0].root(i), (ll)uf[1].root(i));
    m[p]++;
  }

  REP(i, n + 1) {
    P p = make_pair((ll)uf[0].root(i), (ll)uf[1].root(i));
    cout << m[p] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 15136
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  string s;
  cin>>s;
  if(s[0]!='A'){
    cout<<"WA\n";
    return;
  }
  int c=0;
  rep(i,2,s.length()-1){
    if(s[i]=='C') c++;
  }
   // cout<<1<<endl;
  if(c!=1){
    cout<<"WA\n";
    return;
  }
  //
  rep(i,0,s.length()){
    if(isupper(s[i])){
      if((s[i]!='A' && s[i]!='C')) {
        cout<<"WA\n";
        return;
      }
    }
  }
  cout<<"AC\n";
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3656
# include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	pair < int , int > a[n];
	for(int i = 1; i <= n; i ++){
		cin >> a[i].first;
		a[i].second = i; 
	}
	sort(a + 1 , a + n + 1);
	for(int i = 1; i <= n; i ++) cout << a[i].second << " \n"[i == n];
}

Measured memory_bytes: 1536
#include <iostream>

 

using namespace std;

 

int main()
{
   int x, y, z;
   cin >> x >> y >> z;
   if (x < y && y < z) {
       cout << "Yes" << endl;
   }
   else {
      cout << "No" << endl; 
   }
       
   return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;


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


void solve(){
	int t1[2],t2[2];
	// for(int i=0;i<2;i++)
		cin >> t1[0] >> t1[1];
	// for(int i =0;i<2;i++)
		cin >> t2[0] >> t2[1];
	int k;
	cin >> k;
	// cout << t1[0] << t2[0] << k << endl;
	int ans;
	if(t1[0]*60+ t1[1] <= t2[0]*60 + t2[1]){
		int totalwake = abs(t1[0]*60+ t1[1] - t2[0]*60 - t2[1]);
		// cout << totalwake << endl;
		 ans = totalwake - k;
	}
	else{
		int totalwake = (24*60 - t1[0]*60 - t1[1] + t2[0]*60 + t2[1]);
		// cout << totalwake << endl;
		ans = totalwake - k;
	}
	// cout << k << endl;

	cout << ans << endl;

}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Arrays;
import java.util.Scanner;
import java.util.HashMap;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            HashMap<Integer, List<Integer>> map = new HashMap<>();
            int[] indegree = new int[n];
            for (int i = 0; i < m; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;
                List<Integer> t = map.getOrDefault(a, new ArrayList<>());
                t.add(b);
                map.put(a, t);
                indegree[b]++;
            }
            int[] dist = new int[n];
            Arrays.fill(dist, -1);
            for (int i = 0; i < n; i++) {
                if (dist[i] == -1 && indegree[i] == 0) {
                    dist[i] = 0;
                    dfs(dist, i, map, indegree);
                }
            }
            int ans = 0;
            for (int dd : dist) ans = Math.max(ans, dd);

            out.println(ans);
        }

        private void dfs(int[] dist, int from, HashMap<Integer, List<Integer>> map, int[] indegree) {
            int d = dist[from];
            for (int j = 0; j < map.getOrDefault(from, new ArrayList<>()).size(); j++) {
                int to = map.get(from).get(j);
                dist[to] = Math.max(dist[to], d + 1);
                indegree[to]--;
                if (indegree[to] == 0) dfs(dist, to, map, indegree);
            }
        }

    }
}



Measured memory_bytes: 123476
#include <bits/stdc++.h>
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; }

int n, m;
vector<long long> xcnt(100100, 0);
vector< vector<long long> > xmodcnt(100100, vector<long long>());
vector<long long> xmodsum(100100, 0);

long long lrmodsum(int l, int r) {
    long long lrcnt = 0;
    long long lsum = xmodsum.at(l); long long rsum = xmodsum.at(r);
    if(lsum < rsum) {
        // 余りの小さい方が要素数が少ないとき
        for(int i = 0; i < xmodcnt.at(r).size(); ++i) {
            long long xmcnt = xmodcnt.at(r).at(i);
            while(xmcnt > 1) {
                if(rsum-2 < lsum) break;
                else {
                    xmcnt -= 2;
                    rsum -= 2;
                    lrcnt++;
                }
            }
        }
        lrcnt += lsum;
    }else {
        // 余りの小さい方が要素数が多いとき
        for(int i = 0; i < xmodcnt.at(l).size(); ++i) {
            long long xmcnt = xmodcnt.at(l).at(i);
            while(xmcnt > 1) {
                if(lsum-2 < rsum) break;
                else {
                    xmcnt -= 2;
                    lsum -= 2;
                    lrcnt++;
                }
            }
        }
        lrcnt += rsum;
    }
    return lrcnt;
}

int main() {
    cin >> n >> m;
    vector<long long> x(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> x.at(i);
        xcnt.at(x.at(i))++;
    }
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    int xlen = x.size();
    for(int i = 0; i < xlen; ++i) {
        int mx = x.at(i) % m;
        xmodcnt.at(mx).push_back(xcnt.at(x.at(i)));
    }

    for(int i = 0; i < m; ++i) {
        for(int j = 0; j < xmodcnt.at(i).size(); ++j) {
            xmodsum.at(i) += xmodcnt.at(i).at(j);
        }
    }

    long long cnt = 0;
    if(m % 2 == 0) {
        for(int i = 0; i < m/2; ++i) {
            if(i == 0) {
                cnt += xmodsum.at(0)/2;
                cnt += xmodsum.at(m/2)/2;
            }else {
                int lch = i; int rch = m-i;
                cnt += lrmodsum(lch, rch);
            }
        }
    }else {
        for(int i = 0; i <= m/2; ++i) {
            if(i == 0) {
                cnt += xmodsum.at(i)/2;
            }else {
                int lch = i; int rch = m-i;
                cnt += lrmodsum(lch, rch); 
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 8064
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
struct Edge
{
	int to;
	int nxt;
}e[200005];
int n,m,edgenum,head[100005],pa[100005],d[100005],sum[100005];
int f0[100005],f1[100005],f2[100005];
char c[100005];
bool flag[100005];
queue<int>q;
void add(int u,int v)
{
	e[++edgenum].to=v;
	e[edgenum].nxt=head[u];
	head[u]=edgenum;
}
void dfs(int node)
{
	sum[node]=(c[node]=='W');
	f2[node]=1000000000;
	bool ff=0;
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		if(flag[to])continue;
		pa[to]=node;
		dfs(to);
		sum[node]+=sum[to];
		if(sum[to])
		{
			f2[node]=min(f2[node]+f0[to],f0[node]+f2[to]+d[node]+((d[node]&1)^(c[node]=='W')));
			f2[node]=min(f2[node],f1[node]+f1[to]+d[node]-((d[node]&1)^(c[node]=='W')));
			f1[node]=min(f1[node]+f0[to],f0[node]+f1[to]);
			f0[node]+=f0[to];
			ff=1;
		}
	}
	f0[node]+=d[node]+((d[node]&1)^(c[node]=='W'));
	f1[node]+=d[node]-((d[node]&1)^(c[node]=='W'));
	if(!ff)f1[node]=1;
//	printf("%d %d %d %d\n",node,f0[node],f1[node],f2[node]);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
		d[u]++,d[v]++;
	}
	scanf("%s",c+1);
	for(int i=1;i<=n;i++)
	  if(d[i]==1&&c[i]=='B')
		q.push(i);
	while(!q.empty())
	{
		int node=q.front();
		q.pop();
		flag[node]=1;
		for(int hd=head[node];hd;hd=e[hd].nxt)
		{
			int to=e[hd].to;
			d[to]--;
			if(d[to]==1&&c[to]=='B')q.push(to);
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(c[i]=='W')
		{
			dfs(i);
			printf("%d\n",min(f1[i],f2[i]));
			return 0;
		}
	}
	printf("0\n");
	return 0;
}

Measured memory_bytes: 9344
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,A = LI()
x = LI()

# dp[i][j][k]：i枚目まで見て，j枚のカードを使って，和がk
dp = [[[0]*(50*N+1) for _ in range(N+1)] for _ in range(N)]
dp[0][0][0] = 1
dp[0][1][x[0]] = 1

for i in range(1,N):
    for j in range(N+1):
        for k in range(50*N+1):
            dp[i][j][k] = dp[i-1][j][k]
            if k-x[i] >= 0:
                dp[i][j][k] += dp[i-1][j-1][k-x[i]]

ans = 0
for j in range(1,N+1):
    ans += dp[N-1][j][A*j]

print(ans)

Measured memory_bytes: 91868
w, h, x, y = map(int, input().split())


if x in [0, w] or y in [0, h]:
    print(w * h/2, 0)
else:
    if x * 2 == w and y * 2 == h:
        print(w * h / 2, 1)
    else:
        print(w * h/2, 0)

Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdint>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
  string O,E , d; cin >> O >> E;
  if(O.size() > E.size()){
    rep(i,E.size()){
      cout << O[i] << E[i];
    }
    cout << O[O.size()-1] << endl;
  }
  else{
    rep(i,E.size()){
      cout << O[i] << E[i];
    }
    cout << endl;    
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int A[100],N,i,j,minj,b,c=0;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	for(i=0;i<N;i++){
		minj=i;
		for(j=i;j<N;j++){
			if(A[j]<A[minj]){
				minj=j;
			}
		}
		if(A[i]>A[minj]){
			b=A[i];
			A[i]=A[minj];
			A[minj]=b;
			c++;
		}
	}
	for(i=0;i<N;i++){
		if(i>0){
			printf(" ");
		}
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",c);
	return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n;
int a;

int main(void) {
  // Here your code !
  scanf("%d", &n);
  scanf("%d", &a);

  if (n % 500 > a) {
    printf("No\n");
  }
  else {
    printf("Yes\n");
  }

  return 0;
}


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

int n;
int arr[MAX];
ll sum[MAX];
bool sePuede[MAX];
int main(){

    cin>>n;

    sum[0] = 0;
    for(int i = 0; i < n; i++){

        cin>>arr[i];
    }

    sort(arr, arr + n);

    for(int i = 1; i <= n; i++)
        sum[i] = sum[i - 1] + arr[i - 1];

    int ans = 1;

    sePuede[n - 1] = true;
    for(int i = n - 2; i >= 0; i--){

        if(arr[i + 1] <= 2 * sum[i + 1] && sePuede[i + 1]){

            ans++;
            sePuede[i] = true;
        }
        else
            break;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <string>
#define REF(n, m) for(int j = n; j < m; j++)

int main()
{
	int a, count, max = 0;
	std::string b;
	std::cin >> a >> b;
	for(int i = 1; i < a; i++)
	{
		count = 0;		
		for(char c = 'a'; c <= 'z'; c++)
		{
			bool left = false, right = false;
			REF(0, i)
			{
				if(b[j] == c)
					left = true;
			}
			REF(i, a)
			{
				if(b[j] == c)
					right = true;
			}
			if(left && right)
				count++;
		}
		if(max < count)
			max = count;
	}
	std::cout << max << std::endl;
}

Measured memory_bytes: 256
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


yn = 'YNeos'
ynflg = False
cnt = 0
ans = None

def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



A, B, C = mulinputs()

# 出力
if A == B:
    ynflg = A == C
elif B == C:
    ynflg = A == B
elif C == A:
    ynflg = B == C
else:
    ynflg = True

print(yn[ynflg::2])




Measured memory_bytes: 5688
#include <iostream>
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
using namespace std;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m,sum=0;
    cin>>n>>m;
    vector<ll> v(n);
    for(ll i=0;i<n;i++){
        cin>>v[i];
        sum+=v[i];
        v[i]=v[i]*4*m;
    }
    for(int i=0;i<n && m>0;i++){
        if(v[i]>=sum){
            m--;
        }
    }
    if(m==0){
        cout<< "Yes"<<endl;
    }else{cout<< "No"<<endl;}
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 

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

        String D[] = new String [K];
        for (int i=0; i<D.length; i++) {
            D[i] = sc.next();
        }
 
        while (check(N, D)){
            Integer tmp = Integer.parseInt(N);
            tmp++;
            N = tmp.toString();
        }
        System.out.println(N);
    }
 
    private static boolean check(String str, String[] nums){
        for (int i=0; i<nums.length; i++){
            if(str.indexOf(nums[i])!=-1) return true;
        }
        return false;
    }
}

Measured memory_bytes: 26580