akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
using namespace std;

int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while ( a&&c )
	{
		c = c-b; 
		if ( c<=0 )
		{
			printf("Yes");
			break;
		}
		a = a-d;
		if ( a<=0 )
		{
			printf("No");
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll n,m,k;
  cin>>n>>m>>k;
  vector<ll> a(n),b(m+1);
  vector<ll> sum_a(n);
  for (int i = 0; i < n; ++i)
  {
    cin>>a[i];
  }
  sum_a[0]=a[0];
  for (int i = 1; i < n; ++i)
  {
    sum_a[i]=sum_a[i-1]+a[i];
  }
  b[0]=0;
  for (int i = 1; i <= m; ++i)
  {
    cin>>b[i];
  }
  ll ans=0;
  for (ll i = 0; i <= m; ++i)
  {
    k-=b[i];
    if(k<0) break;
    ll tmp=upper_bound(sum_a.begin(), sum_a.end(),k)-sum_a.begin();
    ans=max(tmp+i,ans);
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 7956
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String line1 = sc.nextLine();
		String[] string1 = line1.split(" ");
		int n = Integer.parseInt(string1[0]);
		int m = Integer.parseInt(string1[1]);

		String[][] gyouA = new String[n][m];
		int[][] A = new int[n][m];
		for (int i = 0; i < n; i++) {
			String line2 = sc.nextLine();
			for (int j = 0; j < m; j++) {
				String[] string = line2.split(" ");
				gyouA[i][j] = string[j];
				A[i][j] = Integer.parseInt(gyouA[i][j]);
			}

		}

		String[] retB = new String[m];
		int[] B = new int[retB.length];
		for (int i = 0; i < m; i++) {
			String line3 = sc.nextLine();
			retB[i] = line3;
			B[i] = Integer.parseInt(retB[i]);
		}

		int AB = 0;
		for (int j = 0; j < n; j++) {
			int C = 0;
			for (int k = 0; k < m; k++) {
				AB = A[j][k] * B[k];
				C += AB;
			}
			System.out.println(C);
		}

	}
}

Measured memory_bytes: 64332
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair

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

    ll n;
    cin>>n;

    vector<ll>h(n+1);
    for(ll i=1;i<=n;i++)
    {
        cin>>h[i];
    }

    vector<ll>cost(n+5);
    cost[1]=0;
    cost[2]=abs(h[2]-h[1]);

    for(ll i=3;i<=n;i++)
    {
        cost[i]=min( cost[i-1]+abs(h[i]-h[i-1]),
                     cost[i-2]+abs(h[i]-h[i-2]) );
    }

    cout<<cost[n]<<endl;

    return 0;
}


Measured memory_bytes: 1792
package main

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

const INFINITY = math.MaxInt64/2 - 1

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.ReadInt()
	sum := 0
	for i := 1; i <= n; i++ {
		if i%3 != 0 && i%5 != 0 {
			sum += i
		}
	}
	stdout.Println(sum)
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), INFINITY)
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}

func Min(a int, b ...int) int {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func Max(a int, b ...int) int {
	for _, v := range b {
		if a < v {
			a = v
		}
	}
	return a
}

func Abs(x int) int {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func Pow(x, y int) int {
	z := 1
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y -= 1
		}
	}
	return z
}

func CreateMatrix(x, y int) [][]int {
	matrix := make([][]int, x)
	for i := 0; i < x; i++ {
		matrix[i] = make([]int, y)
	}
	return matrix
}


Measured memory_bytes: 1768
#include<stdio.h>
#include<iostream>

using namespace std;

int main(){
	int H, W;
	while (true)
	{
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)
		{
			return 0;
		}
		for (int j = 0; j < W; j++)
		{
			cout << "#";
		}
		cout << endl;
		for (int i = 0; i < H-2; i++)
		{
			cout << "#";
			for (int l = 0; l < W-2; l++)
			{
				cout << ".";
			}
			cout << "#" << endl;
		}
		for (int k = 0; k < W; k++)
		{
			cout << "#" ;
		}
		cout <<  endl;
		cout <<  endl;
	}
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int a[2][10];
int b[10];
int c[2];

int main(){
	iota(b, b+10, 1);
	int n; scanf("%d", &n);
	REP(j, 2) REP(i, n) scanf("%d", a[j]+i);
	int x = 0;
	do{
		REP(j, 2){
			bool ok = true;
			REP(i, n) if(a[j][i] != b[i]) ok = false;
			if(ok) c[j] = x;
		}
		x++;
	}while(next_permutation(b, b+n));
	printf("%d\n", abs(c[0]-c[1]));
}


Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut ans = 0;
    let mut moves = 0;
    let mut last = 0;
    for _ in 0 .. n {
        let h = get!();
        if h <= last {
            moves += 1;
            ans = std::cmp::max(ans, moves);
        } else {
            moves = 0;
        }
        last = h;
    }
    
    println!("{}", ans);
}

Measured memory_bytes: 6396
n, m, a, b = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
x.sort()
y.sort()



for z in range(a+1, b + 1):
  if max(x) < z <= min(y):
    print("No War")
    exit()

print("War")

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int N;
ll a[300100];
ll mx[300100];
ll mn[300100];

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

  cin>>N;
  for(int i=0;i<3*N;i++) cin>>a[i];

  {
    min_queue<ll> q;
    ll s=0;
    for (int i=0;i<2*N;i++) {
      q.push(a[i]), s+=a[i];
      if (q.size() > N) s-=q.top(),q.pop();
      if (i >= N-1) mx[i] = s;
    }
  }

  {
    priority_queue<ll> q;
    ll s=0;
    for (int i=3*N-1;i>=N;i--) {
      q.push(a[i]), s+=a[i];
      if (q.size() > N) s-=q.top(),q.pop();
      if (i <= 2*N) mn[i] = s;
    }
  }

  ll res=-1e18;

  for (int i=N-1;i<2*N;i++) res=max(res, mx[i]-mn[i+1]);

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 7916
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
const int MOD=1e9+7;
#define pb push_back
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define ci cout<<"impossible\n"
typedef unsigned long long int ull;
typedef long long int ll;
const int MAX=500005;
ll ar[MAX],br[MAX];
const int M=1e4;
ll cnt[M];
int main()
{
    ll n;
    cin>>n;
    ll ans10=1;
    for(int i=1;i<=n;i++)ans10=(ans10*10)%MOD;
    ll ans9=1;
    for(int i=1;i<=n;i++)ans9=(ans9*9)%MOD;
    ll ans8=1;
    for(int i=1;i<=n;i++)ans8=(ans8*8)%MOD;
    ll ans=ans10-ans9*2+ans8;
    ans%=MOD;
    ans=(ans+MOD)%MOD;
    cout<<ans<<endl;
}




Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
using namespace std;
#define INFTY 1<<21

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

Measured memory_bytes: 256
n=int(input())
list=list(map(int,input().split()))
min_tairyoku=10000000000000000000
tairyoku=[]
for i in range(min(list),max(list)+1):
    t=0
    for j in list:
        t += (j-i) ** 2
    tairyoku.append(t)
print(min(tairyoku))


Measured memory_bytes: 2940
/*
 *
 *  1. sprawdz corner cases
 *  2. sprawdz limity, jesli sie da pozamieniaj wszystkie lokalne zmienne na LL!
 *  3.  MINIMALNE I MAKSYMALNE WEJŚCIE I WYJŚCIE
 *  4. lokalne zmienne, iteracja po tablicach dwuwymiarowych uwazaj
 *  5. SPRAWDZ CZY input jest POSORTOWANY jaki jest niezmiennik
 *
 *
 */
#include <algorithm>
#include <cstdio>
#include <iomanip> // std::setprecision
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>
#define FOR(x, y, z) for (int x = (y); x < (z); x++)
#define FORD(x, y, z) for (int x = (y); x >= z; x--)
#define REP(r, n) for (int r = 0; r < (n); r++)
#define MP make_pair
#define ST first
#define ND second
#define SIZE(c) ((int)((c).size()))
#define FOREACH(i, x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define ALL(u) (u).begin(), (u).end()
#define RALL(u) (u).rbegin(), (u).rend()
#define PB push_back
#define PF push_front
#define SZ(x) long long((x).size())
#define IS_IN(x, t) (t.find(x) != t.end())
#define BIT(n, i) (((n) >> (i)) & 1)

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) \
    {              \
    }
#endif

#define TYPEMAX(type) std::numeric_limits<type>::max()
#define TYPEMIN(type) std::numeric_limits<type>::min()

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<LL> VI;
typedef pair<LL, LL> PR;

inline LL GCD(LL a, LL b)
{
    LL r;
    while (b) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
};
inline LL LCM(LL a, LL b) { return a / GCD(a, b) * b; };
inline LL fpow(LL n, LL k, LL p)
{
    LL r = 1;
    for (; k; k >>= 1) {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
};
inline LL inv(LL a, LL p) { return fpow(a, p - 2, p); }

[[maybe_unused]] const LL MOD = (LL)1e9 + 7;
[[maybe_unused]] const LL MAXUS = 100001;//TYPEMAX(LL);
[[maybe_unused]] const LD PI = acos((LD)-1);
[[maybe_unused]] const LD epsilon = 1e-9;

template <typename T>
T input()
{
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e)
{
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}
 
LL F[MAXUS];
LL ccnk(LL n, LL k) {
    cout << n << " " << k;
  if (k < 0 || k > n) return 0;
  return F[n] / F[k] / F[n-k];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    string buffer = "";
    for (auto command: s) {
      if (command == '1' || command == '0') {
        buffer += command;
      } else if (buffer.size() != 0) {
          buffer.pop_back();
      }
    }
    cout << buffer << endl;
    return 0;
}


Measured memory_bytes: 256
input_list = raw_input().split(" ")
N = int(input_list[0])
A = int(input_list[1])
B = int(input_list[2])
MAX=0
MIN=0
if A == 0 or B == 0:
	MAX = 0	
else:
	_max = max(A, B)
	_min = min(A, B)
	MAX = _min
	if A+B < N:
		MIN = 0
	else:
		buf = N - _max
		MIN = _min - buf
		
print("{0} {1}".format(MAX, MIN))

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

using namespace std;
using ll = long long;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	int cur = 0;
	int used = 0;
	for(int i = s.length() - 1; i >= 0; --i){
		int num = s[i] - '0';
		num += cur;
		// cout <<"num: " <<num;
		if(num == 5 && i > 0 && s[i - 1] >= '5'){
			cur = 1, used += 5, s[i - 1] = s[i - 1];
			//cout << s[i - 1] <<" ";
			continue;
		}

		if(num > 5){
			used += 10 - num;
			// s[i] = '0';
			cur = 1;
		}
		else{
			cur = 0;
			// s[i] = num + '0';
			used += num;
		}
	}
	// cout << cur <<"\n";
	// cout << used;
	if (cur == 1) used ++;
	cout << used;
}




Measured memory_bytes: 1948
#include <stdio.h>
#include<string.h>
#include<stdbool.h>
int main()
{
 
  int a,b,c,k;
  scanf("%d%d%d%d",&a,&b,&c,&k);
 
  int ans=0;
  
  if(k<=a)
  {
    ans=k;
  }
  else
  {
    ans=a;
    if(b<=k-a)
    {
      if(k-a-b<=c)
      {
        ans-=(k-a-b);
      }
      else
      {
        ans-=c;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

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

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

  int N = str.size();

  //全文回文であるか
  for (int i = 0; i < N / 2; i++) {
    if (str[i] != str[N - i - 1]) {
      cout << "No" << endl;
      return 0;
    }
  }

  //前半の最後は何もじめか
  int z = (N - 1) / 2;
  //後半の最初は何もじめか
  int k = (N + 3) / 2;

  //前半も後半も調べる文字数は同じなので同じ回数回るforでおｋ
  for (int i = 0; i < z / 2; i++) {
    //前半回文
    if (str[i] != str[z - i - 1]) {
      cout << "No" << endl;
      return 0;
    }

    //後半回文
    if (str[k + i - 1] != str[N - i - 1]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	char a;int b,sum=0;
	while(1){
		a=cin.get();
		b=(int)a-48;
		if(b>=10||b<0)break;
		sum+=b;
		
	}
	if(sum%9==0)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3560
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

/*int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

struct BIT{
    vector<int> dat;
    int sz;
    BIT(int n){
        for(sz=1;sz<n;sz *= 2);
        dat.resize(++sz);
    }
    int q(int n){
        int ret = 0;
        for(int i=n;i>0;i-=i&-i)ret +=dat[i];//和の計算　iから最後の１のbit(i&-i 多分＆はビット積)を減算
        for(int i=n;i<sz;i+=i&-i) dat[i]++;//値の加算　iから最後mの１のbitを加算
        return ret;
    }
};

int main(){
    int n,m,c;
    cin >> n>> m>> c;
    int b[m],a[n][m];
    rep(i,m){
        cin >> b[i];
    }
    int ans=0;
    rep(i,n){
        int temp=0;
        rep(j,m){
            cin >> a[i][j];
            temp+=a[i][j]*b[j];
        }
        temp+=c;
        if(temp>0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
S = input()

if S[0] == "A" and S[2:-1].count("C") == 1:
    count = 0
    for i in range(len(S)):
        if S[i].islower():
            count += 1

    if count == len(S) - 2:
        print("AC")
    else:
        print("WA")
else:
    print("WA")


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

int main(){
	int n, m;
	for(;;){
		cin >> n >> m;
		if(n==0&&m==0) break;
		int c = m-n;
		int s1000 = c/1000;
		c -= s1000*1000;
		int s500 = c/500;
		c -= s500*500;
		int s100 = c/100;
		c -= s100*100;
		cout << s100 << " " << s500 << " " << s1000 << endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>

int H;

void maxHeapify(int *A,int i){
  int largest,ch,l,r;
  l = 2*i;
  r = 2*i+1;

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;

  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i){
    ch = A[i];
    A[i] = A[largest];
    A[largest] = ch;
    maxHeapify(A,largest);
  }
}

void buildMaxHeap(int *A){
  int i;
  for(i = H/2;i >= 1; i--) maxHeapify(A,i);
}

int main(){
  int A[500000];
  int i;

  scanf("%d",&H);
  for(i = 1;i <= H; i++) scanf("%d",&A[i]);

  buildMaxHeap(A);

  for(i = 1; i <= H; i++) printf(" %d",A[i]);
  printf("\n");
 
  return 0;
}



Measured memory_bytes: 3688
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
b = 0
c = 2
f = 0


while True:
    for i in a:
        if i % c > 0:
            f = f +1
            break
    if f == 1:
        break

    b = b + 1
    c = c * 2



print(b)


Measured memory_bytes: 3060
n,k = gets.chomp.split.map(&:to_i)
as = gets.chomp.split.map(&:to_i).sort
array_abs = Array.new(n-1)
mod = as[0]
as.each_cons(2).with_index do |(a,b),i|
  if a - b != 0
    mod = [mod,(a - b).abs].min
  end
end
flag = false

as.each do |a|
  if a % mod == k % mod
    flag = true
    break
  end
end

if flag && as[-1] >= k
  puts "POSSIBLE"
else
  puts "IMPOSSIBLE"
end

Measured memory_bytes: 13564
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

bool check(string s)
{
  bool res = true;
  int sz = s.size();
  REP(i, sz-1) if (s[i] != s[sz-1-i]) res = false;
  return res;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool flg = true;
  if (!check(s)) flg = false;
  string tmp = "";
  int roop = (s.size()-1)/2;
  REP(i, roop) tmp += s[i];
  if (!check(tmp)) flg = false;
  tmp = "";
  roop = (s.size()+3)/2-1;
  REP2(i, roop, s.size()) tmp += s[i];
  if (!check(tmp)) flg = false;
  if (flg) cout << "Yes";
  else cout << "No";

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    vector<int>num(n+1,0);
    set<int>s;
    for(int i=0;i<n;i++){
        num[a[i]]++;
        s.insert(a[i]);
    }
    if(s.size() <= k)cout << 0 << endl;
    else{
        priority_queue<int,vector<int>,greater<int> >que;
        for(int i=1;i<=n;i++){
            if(num[i] != 0)que.push(num[i]);
        }
        int nn = s.size();
        int ans = 0;
        while(nn > k){
            ans += que.top();
            que.pop();
            nn--;
        }
        cout << ans << endl;
    }

}


Measured memory_bytes: 12284
#include<stdio.h>
long long R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(long long a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  long long n,i,d[200010];
  long long s=0,a,b=-1,c=1,e;
  scanf("%lld",&n);
  for(i=0;i<n;i++)scanf("%lld",&d[i]);
  for(i=0;i<n;i++){
    d[i+1]+=d[i];
    hin(d[i]);
  }
  for(i=0;i<n;i++){
    a=N[hout()];//printf("%lld\n",a);
    if(b==a){
      c++;
    }
    else{
      if(b==0)c++;//printf("C%lld\n",c);
      s+=c*(c-1)/2;
      c=1;
    }
    b=a;
  }//printf("%lld %lld\n",s,c);
  if(b==0)c++;
  s+=c*(c-1)/2;
  printf("%lld\n",s);
  return 0;
}


Measured memory_bytes: 7424
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
typedef long long int ll;
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<10&&b<10){
    PRN(a*b);
  }else{
    PRN(-1);
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<bitset>
#include<functional>
#include<iterator>
#include<complex>
#include<fstream>
#include<random>
#include<ctype.h>
#include<stdio.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using PII = pair<ll, ll>;
using piii = pair<pii, pii>;
using Pi = pair<int, pii>;
using Graph = vector<vector<int>>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
bool check(int x, int y) {
	if (0 <= x && x<55 && 0 <= y && y<55)return true;
	else return false;
}
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;

//iの逆元mod inf
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const double PI = 3.14159265358979323846;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
double Euclidean_distance(double x1, double y1, double x2, double y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

//素因数分解
map<int, int>prime_factor(int n) {
	map<int, int>res;
	for (int i = 2; i*i <= n; ++i) {
		while (n%i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1)res[n] = 1;
	return res;
}


ll powmod(ll a, ll k, ll mod) {
	ll ap = a, ans = 1;
	while (k) {
		if (k & 1) {
			ans *= ap;
			ans %= mod;
		}
		ap = ap * ap;
		ap %= mod;
		k >>= 1;
	}
	return ans;
}
ll invi(ll a, ll mod) {
	return powmod(a, mod - 2, mod);
}
#define PI 3.14159265358979323846  // 円周率
//逆元Aを足したときのmodで割った余りは
//+=invi(A)
//Yで割ることはY^(10^9+7)-2を掛けることは同値
///////////////////////////////////////

int main() {
	string s, t; cin >> s >> t;
	int ans = INF;
	for (int i = 0; i <= s.size()-t.size(); ++i) {
		int cnt = 0;
		for (int j = i; j < i + t.size(); ++j) {
			if (t[j - i] != s[j])cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3720
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n, k;
    scanf("%ld%ld", &n, &k);

    vector<long> a(n);
    vector<ll> s(n+1);
    long i, j;
    s[0]=0;
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
        s[i+1]=s[i]+a[i];
    }

    long num=n*(n+1)/2;
    vector<ll> z(num);
    long cnt=0;
    for(i=0; i<n; i++) {
        for(j=i+1; j<n+1; j++) {
            z[cnt]=s[j]-s[i];
            cnt++;
        }
    }

    ll ans=0;
    for(i=39; i>=0; i--) {
        vector<ll> z1;
        z1.reserve((long)z.size());
        for(j=0; j<(long)z.size(); j++) {
            if(z[j] & ((ll)1<<i)) {
                z1.push_back(z[j]);
            }
        }
        if((long)z1.size()<k) continue;

        ans += ((ll)1<<i);
        z.swap(z1);
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 6780
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  lint N;
  cin >> N;
  lint A[N];
  rep(i,N){
    cin >> A[i];
    A[i]-=i+1;
  }
  sort(A,A+N);
  lint mid=A[N/2];
  lint ans=0;
  rep(i,N) ans+=abs(A[i]-mid);
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

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

    ll i,j,ii,jj;
    ll h,w,k;
    cin>>h>>w>>k;
    ll cnt = 0;
    vector<vector<char>> a(h, vector<char>(w));
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            cin>>a[i][j];
            if(a[i][j]=='#') 
            {
                cnt++;
            }
        }
    }
    // for(i=0;i<h;i++)
    // {
    //     for(j=0;j<w;j++) cout<<a[i][j]<<" ";
    //     cout<<"\n";
    // }
   
    ll r = (1<<h);
    ll c = (1<<w);
    // cout<<r<<" "<<c<<"\n";
    ll ans = 0;
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            ll black = 0;
            for(ii=0;ii<h;ii++)
            {
                for(jj=0;jj<w;jj++)
                {
                    if(((i>>ii)&1) or  ((j>>jj)&1))
                    {
                        if(a[ii][jj]=='#') black++; 
                    }
                }
            }
            // cout<<i<<" "<<j<<" "<<black<<"\n";
            if(cnt-black==k) {ans++;}
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int rgb = 100 * sc.nextInt() + 10 * sc.nextInt() + sc.nextInt();
		System.out.println((rgb % 4 == 0)? "YES" : "NO");
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007ll
#define mod1 998244353ll
#define endl "\n"
using namespace std::chrono;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,W;
    cin>>n>>W;
    ll w[n],v[n];
    for(ll x=0;x<n;x++){
        cin>>w[x]>>v[x];
    }
    ll dp[2][W+1];
    for(ll x=0;x<2;x++){
        dp[x][0]=0;
    }
    for(ll x=0;x<=W;x++){
        dp[0][x]=0;
    }
    dp[0][w[0]]=v[0];
    ll maxi=v[0];
    for(ll x=1;x<n;x++){
        for(ll y=1;y<=W;y++){
            dp[x%2][y]=dp[(x-1)%2][y];
            if(w[x]<=y){
                dp[x%2][y]=max(dp[x%2][y],dp[(x-1)%2][y-w[x]]+v[x]);
            }
            maxi=max(maxi,dp[x%2][y]);
        }
    }
    cout<<maxi<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, int b, int _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

int n, k;
vector<vector<int> > G;
vector<int> cnt;

void dfs(int v, int p) {
  int c = 0;
  for (int nv : G[v]) {
    if (nv == p) continue;

    cnt[nv] = k - (p != -1) - 1 - c++;
    dfs(nv, v);
  }
}
void solve() {
  cin >> n >> k;
  if (n == 1) { // debuged, やってもた
    cout << k << endl;
    return;
  }
  G.resize(n);

  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].eb(b);
    G[b].eb(a);
  }

  cnt.resize(n);
  rep(i, n) {
    if (sz(G[i]) == 1) {
      cnt[i] = k;
      dfs(i, -1);
      ll ans = 1;
      rep(j, n) {
        if (cnt[j] <= 0) {
          cout << 0 << endl;
          return;
        }
      }
      rep(j, n) (ans *= cnt[j]) %= mod;
      // rep(j, n) cout << j + 1 << " " << cnt[j] << endl;
      cout << ans << endl;
      return;
    }
  }
}


Measured memory_bytes: 10752
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
n, k  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

snuke = [0] *n

for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for idx in a:
        snuke[idx-1] += 1    

ans = 0
for snuke_ in snuke:
    if snuke_ == 0:
        ans += 1

print(ans)


Measured memory_bytes: 9476
#include<stdio.h>
#define INFTY 2000000000
#define MAX 200000

int L[MAX / 2 + 2],R[MAX / 2 + 2];
long long merge(int A[], int left, int mid,int right){
	long long count = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	int i,j,k;
	for(i = 0; i < n1; i++){
		L[i] = A[left + i];
	}
	for(i = 0; i < n2; i++){
		R[i] = A[mid + i];
	}
	L[n1] = INFTY;
	R[n2] = INFTY;
	i = 0;
	j = 0;
	for(k = left; k < right; k++){
		if(L[i] <= R[j]){
			A[k] = L[i++];
		}
		else{
			A[k] = R[j++];
			count += n1 - i;
		}
	}
	return count;
}

long long mergeSort(int A[], int left, int right){
	long long v1,v2,v3;
	if(left + 1 < right){
		int mid = (left + right)/2;
		v1 = mergeSort(A,left,mid);
		v2 = mergeSort(A,mid,right);
		v3 = merge(A,left,mid,right);
		return v1 + v2 + v3;
	}
	else{
		return 0;
	}
}

int main(void){
	int n,i;
	scanf("%d",&n);
	int S[200000];
	for(i = 0; i < n;i ++){
		scanf("%d",&S[i]);
	}
	long long ans = mergeSort(S,0,n); 
	printf("%lld\n",ans);
	return 0;
}




Measured memory_bytes: 3360
#include<bits/stdc++.h>
using namespace std;
int n,k;
bool d[15];
int num[7];
int main(){
	scanf("%d%d",&n,&k);
	int tmp,minNum=10,minNumN=10,dig=0;
	for(int i=1;i<=k;i++){
		scanf("%d",&tmp);
		d[tmp]=true;
	}
	bool flag=false;
	for(int i=0;i<=9;i++){
		if(!d[i]){
			minNum=i;break;
		}
	}
	for(int i=1;i<=9;i++){
		if(!d[i]){
			minNumN=i;break;
		}
	}
	tmp=n;
	while(tmp){
		num[++dig]=tmp%10;
//		printf("num:%d\n",num[dig]);
		if(d[num[dig]]){
			flag=true;
		}
		tmp/=10;
	}
	/*
	for(int i=1;i<=dig;i++)
		printf("%d",num[i]);
	printf("\n");
	*/
	if(!flag){
		printf("%d\n",n);
		return 0;
	}
	flag=false;
	for(int i=dig;i>=1;i--){
		tmp=num[i];
		if(d[tmp]){
			int t=tmp;
			for(int j=tmp+1;j<=9;j++){
				if(!d[j]){
					t=j;
					break;
				}
			}
			if(t==tmp){
				num[dig+1]=minNumN;
				flag=true;
				for(int j=1;j<=dig;j++)
					num[j]=minNum;
				dig++;
				break;
			}
			else{
				num[i]=t;
				for(int j=1;j<i;j++)
					num[j]=minNum;
				break;
			}
		}
	}
	for(int i=dig;i>=1;i--)
		printf("%d",num[i]);
	printf("\n");
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<random>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;
 
/////////////////////////////////////////////
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
////////////////////////////////
 
 
 
//#define int long long
const int mod = 1e9 + 7;
void solve(){

	int n;
	cin>>n;
	int a[n][n];

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

	int k = (1<<n);

	vector<int>dp(k , 0);
	//memset(dp , 0 , sizeof dp);
	dp[0] = 1;

	for(int mask = 0 ; mask < k-1 ; ++mask){

		int x = __builtin_popcount(mask);

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

			if(a[x][i] && (!(mask&(1<<i))))
				dp[mask|(1<<i)] += dp[mask];

			dp[mask|(1<<i)]%=mod;
		}
	}

	cout<<dp[k-1]<<endl;
}

 
signed main(){
 
    fast;
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 8448
#include <algorithm>
#include <iostream>
#include <complex>
#include <cstdio>
#include <cmath>
#include <utility>
#include <vector>
using namespace std;
using W = double;
using P = complex<W>;
using L = pair<P,P>;
using C = pair<P,W>;
using Poly = vector<P>;
#define X real()
#define Y imag()
const W EPS = (1e-10), pi = acos(-1);

double dot(P a, P b){ return a.X * b.X + a.Y * b.Y;}
W cross(P a, P b){ return a.X * b.Y - a.Y * b.X;}
P projection(P a, P b){ return dot(a, b)/abs(b)/abs(b)*b;}

//直線aと直線bの交点
P intersection(L a, L b){
  P af = a.first, as = a.second, bf = b.first, bs = b.second;
  return af + cross(bs-bf,af-bf)/(-cross(bs-bf,as-bf)+cross(bs-bf,af-bf))*(as-af);
}

//cがa/bと重なってる時は0を返す
//cがa/bと重なってる時+-2を返して欲しいなら+-2のところのEPSの符号を逆にする
int ccw(P a, P b, P c){
  b -= a; c -= a;
  if(cross(b,c) > EPS) return +1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < -EPS) return +2;
  if(norm(b) < norm(c)-EPS) return -2;
  return 0;
}

//凸多角形を直線で切る
//ccwが必要
Poly convex_cut(const Poly &p, L l){
  Poly ret;
  int n = p.size();
  for(int i = 0; i < n; ++i){
    P cur = p[i], nex = p[(i+1)%n], lf = l.first, ls = l.second;
    if(ccw(lf, ls, cur) != -1)
      ret.push_back(cur);
    if((ccw(lf, ls, cur) != -1) ^ (ccw(lf, ls, nex) != -1))
      ret.push_back(intersection(L(cur, nex), l));
  }
  return ret;
}

W area(const Poly &p){
  int n = p.size();
  W s = 0;
  for(int i = 0; i < n; ++i) s += cross(p[i],p[(i+1)%n])/2;
  return s;
}

int main(){
  int N;
  cin >> N;
  Poly pol;
  for(int i = 0; i < N; ++i){
    W x, y;
    cin >> x >> y;
    pol.emplace_back(x,y);
  }
  const W INF = 1e9;
  auto calc = [&](Poly t){
                W ret = 0;
                W l = min({0.0,t[1].X,t[2].X}), r = max({0.0,t[1].X,t[2].X});
                for(W x = l; x < r; x += 1){
                  Poly tt = convex_cut(t,L(P(x+0.5,-INF),P(x+0.5,INF)));
                  ret += area(tt);
                  t = convex_cut(t,L(P(x+1,INF),P(x+1,-INF)));
                }
                return abs(ret);
              };
  W s = 0;
  for(int i = 0; i < N; ++i){
    if(abs(P(0,0)-pol[i]) < EPS) continue;
    if(abs(P(0,0)-pol[(i+1)%N]) < EPS) continue;
    Poly t;
    t.push_back(P(0,0));
    t.push_back(pol[i]);
    t.push_back(pol[(i+1)%N]);
    W ds = calc(t);
    if(area(t) > 0) s += ds;
    else s -= ds;
  }
  W ans = max(s,area(pol)-s);
  printf("%.12f\n",ans);
}



Measured memory_bytes: 3344
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  double a,c,d,e,f,g=0,h=100000000;cin>>a;
  vector<pair<int,int>> b(a);
  vector<int>z(a);
  int x=1;
  rep(i,a){
    x*=i+1;
    z[i]=i;
    cin>>b[i].first>>b[i].second;
  }
  do{
    c=b.at(z[0]).first;
    d=b[z[0]].second;
  for(int i=1;i<a;i++){
    e=b[z[i]].first;
    f=b[z[i]].second;
    g+=sqrt((c-e)*(c-e)+(d-f)*(d-f));
    c=e;
    d=f;
  }
  }while(next_permutation(z.begin(),z.end()));
  cout<<fixed<<setprecision(12)<<g/x;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<algorithm>
#include<vector>
#include<stack>
#define INF 0x3f3f3f3f
#define eps 1e-6
typedef long long ll;
const double pi=acos(-1.0);
using namespace std;
int main()
{
    int a,b,c,x,y,an1,an2,an3;
    cin>>a>>b>>c>>x>>y;
    an1=a*x+b*y;
    if(x>y)
    {
        an3=x*2*c;
        an2=(y*c*2+(x-y)*a);
    }
    else
    {
        an2=(x*c*2+(y-x)*b);
        an3=y*2*c;
    }
    int ans=min(an1,min(an2,an3));
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
s = input()

ans = 1
cur = 0
tmp = s[0]

for i in range(len(s)-1):
    #print(cur)
    if cur == len(s)-1:
        break
    if cur >= len(s)-2:
        if tmp == s[cur+1]:
            break
        else:
            ans += 1
            break
    if tmp == s[cur+1]:
        tmp = s[cur+1] + s[cur+2]
        cur += 2
        ans += 1
    else:
        tmp = s[cur+1]
        cur += 1
        ans += 1
        
print(ans)

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

int main(){
    int n, k; cin >> n >> k;
    vector<ll> v(n); rep(i,n) cin >> v[i];
    priority_queue<ll,vector<ll>,greater<ll>> have;
    int r = min(n,k);
    ll ans = -100000000;
    ll tmp = 0;
    for(int a = 0; a <= r; ++a){
        for(int b = 0; a+b <= r; ++b){
            tmp = 0;
            rep(i,a) have.push(v[i]);
            rep(i,b) have.push(v[n-i-1]);
            rep(i,k-(a+b)) if(!have.empty() && have.top() < 0) have.pop();
            int tmp_have_size = have.size();
            rep(i,tmp_have_size){
                tmp += have.top();
                have.pop();
            }
            ans = max(ans, tmp);
            while(!have.empty()) have.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100

int main( void ){
	
	int M[N][N];
	int n , u , k , v;
	
	scanf( "%d" , &n );
	
	for( int i = 0; i < n; i++ ){
		for( int j = 0; j < n; j++ ){
			M[i][j] = 0;
		}
	}
	
	for( int i = 0; i < n; i++ ){
		
		scanf( "%d" , &u );
		scanf( "%d" , &k );
		u--;
		
		for( int j = 0; j < k; j++ ){
			scanf( "%d" , &v );
			v--;
			M[u][v] = 1;
		}
	}
	
	for( int i = 0; i < n; i++ ){
		for( int j = 0; j < n; j++ ){
			if(j){
				printf( " " );
			}
			printf( "%d" , M[i][j] );
		}
		printf( "\n" );
	}
	
	return 0;
}
			


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cout << "[" << __LINE__ << "] ";
#define dump(i) cout << #i ": " << i << " ";
#define dumpl(i) cout << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    while (n != 0)
    {
        string l[n];
        int p[n], a[n], b[n], c[n], d[n], e[n], f[n], s[n], m[n];
        rep(i, n) cin >> l[i] >> p[i] >> a[i] >> b[i] >> c[i] >> d[i] >> e[i] >> f[i] >> s[i] >> m[i];
        pair<double, string> pi[n];
        rep(i, n)
        {
            pi[i].second = l[i];
            pi[i].first = -((double)f[i] * s[i] * m[i] - p[i]) / (double)(m[i] * (d[i] + e[i]) + a[i] + b[i] + c[i]);
        }
        sort(pi, pi + n);
        rep(i, n)
        {
            cout << pi[i].second << endl;
        }
        cout << "#" << endl;
        cin >> n;
    }
    return 0;
}



Measured memory_bytes: 3012
import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        long a = sc.nextLong();
        long b = sc.nextLong();

        System.out.println(a*b/ gcd(a, b));
    }

    private static long gcd(long m, long n) {
        if(m<n) return gcd(n,m);
        if(n == 0) return m;
        return gcd(n,m%n);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int n,l;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>l;
    int sum=(2*l+n-1)*n/2;
    int m=100000;
    rep(i,l,l+n){
        m=min(m, abs(int(i)));
    }
    rep(i,l,l+n){
        if(abs(i)==m){
            sum-=i;
            break;
        }
    }
    cout <<sum<<"\n";
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int N;
    
    const ll mod = 1e18;

    cin >> N;

    vector<ll> A(N);

    rep(i,N) {
        cin >> A[i];
        if(A[i]==0) {
            cout << 0 << endl;
            return 0;
        }       
    }

    __int128_t ans = 1;

    rep(i,N) {
        ans *= A[i];
        if(ans>mod) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << int64_t(ans) << endl;

    return 0;
    
}

Measured memory_bytes: 3980
import java.util.*;
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int A = sc.nextInt();
    int B = sc.nextInt();
    int sum =0;
 
    for(int i=0;i<2;i++){
      if(A > B){
        sum+= A;
        A-=1;
      }else{
        sum+= B;
        B-=1;
    }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 23508