akhauriyash/Code-Regression huggingface dataset:
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
void bye1()
{
    printf("Yes\n");
    exit(0);
}
void bye2()
{
   printf("No\n");
   exit(0);
}
 main()

{

    int n;
    scanf("%lld",&n);
    int pa[n+2],pb[n+2];
    int a[n+2],b[n+2];
    f(i,1,n)
    {
        scanf("%lld",&a[i]);
        pa[i]=a[i];
    }
    f(i,1,n)
    {
        scanf("%lld",&b[i]);
        pb[i]=b[i];
    }
    sort(pa+1,pa+n+1);
    sort(pb+1,pb+n+1);
    map<int,int>yo;
    f(i,1,n)
    {
        if(pa[i]>pb[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
        yo[pa[i]]=pb[i];
    }
    f(i,1,n-1)
    {
        if(pa[i+1]<=pb[i])
        {
            bye1();
        }
    }
    map<int,int>bidx;
    map<int,int>ses;
    f(i,1,n)
    {
        bidx[b[i]]=i;
    }
    f(i,1,n)
    {
        int x=i;
        int y=bidx[yo[a[i]]];
        ses[x]=y;
    }
    map<int,int>vis;
    int cur=1,cnt=1;
    while(1)
    {
        cur=ses[cur];
        if(cur==1)break;
        cnt++;
    }
    if(cnt!=n)
    {
        bye1();
    }
    bye2();
    return 0;

}




































Measured memory_bytes: 25404
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

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

const ll LINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9+7;

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){

    fastio;
    int n;
    cin >> n;
    ll sum = 0;
    for(int a = 1; a <= n; a++){
    	for(int b = 1; b <= n; b++){
    		for(int c = 1; c <= n; c++){
    			sum += 1LL*__gcd(a, __gcd(b, c));
    		}
    	}
    }
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 3612
use std::io;

fn main() {
    let mut target_str = String::new();
    io::stdin().read_line(&mut target_str).unwrap();
    let target_str = target_str.trim();

    let mut count: usize = 0;

    loop {
        match target_str.chars().nth(count) {
            Some('h') => match target_str.chars().nth(count + 1) {
                Some('i') => {
                    count += 2;
                }
                _ => {
                    println!("No");
                    break;
                }
            },
            None => {
                println!("Yes");
                break;
            }
            _ => {
                println!("No");
                break;
            }
        };
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <numeric>
using namespace std;
int gcd(int a,int b)
{
  int r;
  r=a%b;
  while(r!=0)
  {
    a=b;
    b=r;
    r=a%b;
  }
  return b;
}
int main()
{
  long int N,X;
  cin>>N>>X;
  long int x[N];
  int d[N];
  for(int i=0;i<N;i++)
    cin >> x[i];
    int g=gcd(abs(x[0]-X),abs(x[1]-X));
  if(N>1){

  for(int j=2;j<N-1;j++)
  g=gcd(g,abs(x[j]-X));
}
  else
    g=abs(x[0]-X);


  cout << g <<endl;
  return 0;
}


Measured memory_bytes: 1024
s=input()
l=['+']*3+['']
for k in range(7):
  a=''.join([i+j for i,j in zip(s,l)])
  if eval(a)==7:
    print(a+'=7')
    break
  l=list(bin(k+1)[2:].zfill(3).replace('0','+').replace('1','-'))+['']

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include <iostream>
#define ll long long
using namespace std;
ll a[300010];
ll dp[70][2];
#define MOD 1000000007
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
		int tmp = 2;
		for (int j = 0; j <= 60; j++) {
			if (a[i] % tmp == 1)
				dp[j][1]++;
			else
				dp[j][0]++;
			a[i] /= 2;
		}
	}
	ll tmp = 1;
	ll res = 0;
	for (int i = 0; i <= 60; i++) {
		res += (tmp * ((dp[i][0] * dp[i][1]) % MOD)) % MOD;
		res %= MOD;
		tmp *= 2;
		tmp %= MOD;
	}
	printf("%lld\n", res);
}


Measured memory_bytes: 2560
N = int(input())
H = list(map(int,input().split()))
max_count = 0
count = 0
for i in range(N-1):
    if H[i]-H[i+1]>=0:
        count+=1
    else:
        if max_count<count:
            max_count = count
        count = 0
if max_count<count:
    max_count = count
print(max_count)
        

Measured memory_bytes: 15020
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

if 1 not in A:
    print(-1)
    exit()

p = 0
ans = 0
for i in range(1, N + 1):
    while p < N and A[p] != i:
        p += 1
        ans += 1
    p += 1
print(ans)


Measured memory_bytes: 31708
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {

    string s;
    
    cin >> s;
    
    if(s == "SUN") cout << 7 << endl;
    else if (s == "MON") cout << 6 << endl;
    else if (s == "TUE") cout << 5 << endl;
    else if (s == "WED") cout << 4 << endl;
    else if (s == "THU") cout << 3 << endl;
    else if (s == "FRI") cout << 2 << endl;
    else if (s == "SAT") cout << 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

    if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
		printf("res:%lld a:%lld\n", res,a);
	}
	return res;
}


lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long 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] % MOD) % MOD;
}
*/

int d(long long int N)
{
    int count = 0;

    while (N > 0)
    {
        N /= 10;
        count++;
    }

    return count;
}

int main()
{
    int L,M,N,K;

    scanf("%d", &N);

    if (N % 10 == 3)
        printf("bon");
    else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)
        printf("pon");
    else
        printf("hon");

}

Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

int n, m;

bool Spojna(vector< vector<int> >& G, int x, int y)
{
    vector<bool> odw(n, false);
    odw[0] = true;
    stack<int> S;
    S.push(0);
    while (!S.empty())
    {
        int akt = S.top();
        S.pop();
        for (int i = 0; i < G[akt].size(); ++i)
        {
            if (!((akt == x && G[akt][i] == y) || (akt == y && G[akt][i] == x)) && !odw[G[akt][i]])
            {
                odw[G[akt][i]] = true;
                S.push(G[akt][i]);
            }
        }
    }
    for (int i = 0; i < n; ++i)
        if (!odw[i])
            return false;
    return true;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    vector< vector<int> > G(n);
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int odp = 0;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < G[i].size(); ++j)
            if (!Spojna(G, i, G[i][j]))
                ++odp;
    cout << odp / 2;
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
using namespace std;
int n;
int main() {
	scanf("%d", &n);
	if (n < 1200) printf("ABC");
		else printf("ARC");
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n= in.nextInt();
            long sum = 0;
            int[] arr = new int[n];
            for (int i = 0; i <n ; i++) {
                arr[i] = in.nextInt();
                sum+=arr[i];
            }
            long ans = -1;
            long v = 0;
            for (int i = 0; i <n && v+arr[i]<=sum/2 ; i++){
                v+=arr[i];
            }
            ans =(sum-2*v);
            v=0;
            for (int i = n-1; i >=0 &&v+arr[i]<=sum/2 ; i--) {
                v+=arr[i];
            }
            ans =Math.min(ans , sum-2*v);
            System.out.println(ans);



        }


    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


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

using namespace std;

const int MAX = 1e9 + 7;
int h, w;
bool grid[1001][1001];
int dp[1001][1001];

int main()
{
    cin >> h >> w;
    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            char t;
            cin >> t;
            if(t == '#') grid[i][j] = true;
        }
    }

    dp[1][1] = 1;

    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            if(grid[i][j]) continue;
            
            if(!grid[i][j-1]) dp[i][j] += dp[i][j-1];
            dp[i][j] %= MAX;

            if(!grid[i-1][j]) dp[i][j] += dp[i-1][j];
            dp[i][j] %= MAX;
        }
    }

    cout << dp[h][w] << endl;
}

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

int main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  for (string &x : s)
    cin >> x;

  sort(s.begin(), s.end());

  vector<int> check(n);
  int count = 0, max = 0;

  check.at(0) = 0;
  for (int i = 1; i < n; i++)
  {
    if (s.at(i) == s.at(i - 1))
      count++;
    else
      count = 0;
    check.at(i) = count;
    if (count > max)
      max = count;
  }

  for (int i = 0; i < n; i++)
  {
    if (check.at(i) == max)
      cout << s.at(i) << endl;
  }
}

Measured memory_bytes: 15104
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define drp(i,st,ed) for (int i=st;i>=ed;--i)
#define fi first
#define se second

typedef std:: pair <int,int> pair;
const int N=1000005;

std:: vector <pair> p[4];

int ins[N],out[N],s[N],r[N],tot;
int n,m,k;

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):v,ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

void get(int i,int x,int y) {
	if (!x) p[0].push_back(pair(y,i));
	else if (y==m) p[1].push_back(pair(x,i));
	else if (x==n) p[2].push_back(pair(y,i));
	else p[3].push_back(pair(x,i));
}

int main(void) {
	n=read(),m=read(),k=read();
	rep(i,1,k) {
		int x1=read(),y1=read(),x2=read(),y2=read();
		if ((!x1||x1==n||!y1||y1==m)&&(!x2||x2==n||!y2||y2==m)) {
			get(i,x1,y1),get(i,x2,y2);
		}
		r[i]=1LL*rand()*rand()+1;
	}
	rep(i,0,3) std:: sort(p[i].begin(),p[i].end());
	rep(j,0,1) {
		for (int i=0;i<p[j].size();++i) {
			int x=p[j][i].se; ++tot;
			s[tot]=s[tot-1]^r[x];
			if (!ins[x]) ins[x]=tot;
			else out[x]=tot;
		}
	}
	rep(j,2,3) {
		std:: reverse(p[j].begin(),p[j].end());
		for (int i=0;i<p[j].size();++i) {
			int x=p[j][i].se; ++tot;
			s[tot]=s[tot-1]^r[x];
			if (!ins[x]) ins[x]=tot;
			else out[x]=tot;
		}
	}
	rep(i,1,k) {
		if (out[i]<ins[i]) std:: swap(out[i],ins[i]);
		if (s[ins[i]-1]!=s[out[i]]) {
			puts("NO"); return 0;
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 12824
<?php
function init($a, $b) {
    return array_pad(array(), $a, array_pad(array(), $b, 0));
}
 
list($a[], $a[], $a[], $N) = explode(" ", trim(fgets(STDIN)));
$size_a = count($a);

$dp = init($size_a + 1, $N + 1);

$dp[0][0] = 1;

for($i = 1; $i <= $size_a; $i++){
    for($j = 0; $j <= $N; $j++){
        $dp[$i][$j] = $dp[$i - 1][$j];
        if (isset($dp[$i][$j - $a[$i - 1]])) {
            $dp[$i][$j] += $dp[$i][$j - $a[$i-1]];
        }
    }
}
echo $dp[3][$N];

Measured memory_bytes: 4728
#include<iostream>

using namespace std;

int main(void){

    int i, n, b;

    char a;

    int S[13] = {0}, H[13] = {0}, C[13] = {0}, D[13] = {0};

    cin >> n;

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

        cin >> a >> b;
        
        if(a == 'S') S[b - 1]++;

        if(a == 'H') H[b - 1]++;
        
        if(a == 'C') C[b - 1]++;

        if(a == 'D') D[b - 1]++;

    }//?????????????????????????????£???(?????????????????????)

    for(i = 0; i < 13; i++){
        if(S[i] == 0)cout << "S " << i + 1 << endl;
    }//???????????????????????????
     for(i = 0; i < 13; i++){
        if(H[i] == 0)cout << "H " << i + 1 << endl;
    }//????????????????????????
     for(i = 0; i < 13; i++){
        if(C[i] == 0)cout << "C " << i + 1 << endl;
    }//????????????????????????
     for(i = 0; i < 13; i++){
        if(D[i] == 0)cout << "D " << i + 1 << endl;
    }//????????????????????????

return 0;

}

Measured memory_bytes: 1160
# 別解: 総当たり(Brute Force)で解く

n, m = [int(i) for i in input().split()]
s = []
c = []
for _ in range(m):
    i, k = [int(i) for i in input().split()]
    s.append(i)
    c.append(k)

res = -1
start = 10**(n-1) if n > 1 else 0
for i in range(start, 10**n):
    i2s = str(i)
    for ss, cc in zip(s, c):
        if i2s[ss-1] != str(cc):
            break
    else:
        res = i
        break

print(res)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

string s;

int main(){
	cin.sync_with_stdio(false);
  cin>>s;
  int n=s.length();
  if((n%2==0)==(s[0]==s[n-1]))cout<<"First"<<endl;
  else cout<<"Second"<<endl;
	return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<Integer> place = new HashSet<>();
        int[] pieces = new int[n];
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            pieces[i] = x;
            place.add(x);
        }
        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            int idx = sc.nextInt() - 1;
            if (pieces[idx] != 2019 && !place.contains(pieces[idx] + 1)) {
                place.remove(pieces[idx]);
                pieces[idx]++;
                place.add(pieces[idx]);
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int x : pieces) {
            sb.append(x).append("\n");
        }
        System.out.print(sb);
     }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X;
  cin >> X;
  if(X == 7 || X == 5 || X == 3) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  [n,m,x] <- map (read::String->Int) . words <$> getLine
  as <- map (read::String->Int) . words <$> getLine
  let to0 = length [s|s<-as, s<x]
  let toN = length [t|t<-as, x<t]
  print $ min to0 toN

Measured memory_bytes: 4200
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n, w;
    cin >> n >> w;
    ll items[n][2];
    for (ll i = 0; i < n; i++)
    {
        cin >> items[i][0] >> items[i][1];
    }

    ll dp[n + 1][w + 1];

    for (ll i = 0; i <= n; i++)
    {
        for (ll j = 0; j <= w; j++)
        {
            if (i == 0 || j == 0)
            {
                dp[i][j] = 0;
            }
            else
            {
                if (items[i - 1][0] <= j)
                {
                    dp[i][j] = max(items[i - 1][1] + dp[i - 1][j - items[i - 1][0]], dp[i - 1][j]);
                }
                else
                {
                    dp[i][j] = dp[i - 1][j];
                }
            }
        }
    }

    cout << dp[n][w];
}

Measured memory_bytes: 82472
#include <bits/stdc++.h>
typedef long long ll;

int main(int argc, char const *argv[]) {
    std::set<ll> S;
    ll a;
    for (size_t i = 0; i < 3; i++) {
        std::cin >> a;
        S.insert(a);
    }
    std::cout << S.size() << '\n';
    return 0;
}


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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S; bool check = true;	vector<ll> v;



int main() {
	//Code Line
cin >> S;
for(int i = 0;i < S.size();i++){
cout << "x";
}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define xmod int(1e9)
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pi 3.14159265358
#define inf long long(1e18)
using namespace std;

int n,a[200005],ct[200005];
vector <int> p;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for (int i=n;i>=1;i--){
		if (a[i] != ct[i]%2){
			p.pb(i);
			for (int j=1;j*j<=i;j++){
				if (i%j == 0){
					ct[j]++;
					if (j != i/j)
					ct[i/j]++;
				}
			}
		}
	} 
	printf("%d\n",p.size());
	for (int i=0;i<p.size();i++){
		printf("%d",p[i]);
		if (i < p.size()-1)
		printf(" ");
	}
	printf("\n");
	return 0;
}
//4 11

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LLINF 1<<63-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define MOD 1000000007
#define NUM 100001
void swap(int* x,int* y){
  int tmp=*x;*x=*y;*y=tmp;
}

int main() {
  int N,A,B,C,D,i,ans;
  scanf("%d%d%d%d%d",&N,&A,&B,&C,&D);
  A--;B--;C--;D--;
  char S[N+1];
  scanf("%s",S);
  if(D<C){
    ans=0;
    for(i=B-1;i<D;i++)if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.')ans=1;
    for(i=A+1;i<C-1;i++)if(S[i]=='#'&&S[i+1]=='#')ans=0;
  }else if(C<B){
    ans=1;
    for(i=A+1;i<C-1;i++)if(S[i]=='#'&&S[i+1]=='#')ans=0;
    for(i=B+1;i<D-1;i++)if(S[i]=='#'&&S[i+1]=='#')ans=0;
  }else{
    ans=1;
    for(i=A+1;i<D-1;i++)if(S[i]=='#'&&S[i+1]=='#')ans=0;
  }
  if(ans==1)printf("Yes");
  else printf("No");

  //printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

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

   int sum = 0;
   int mas = 0;
   for (int i = 0; i < N; i++) {
      int tmp;
      cin >> tmp;
      sum += tmp;
      if (tmp > mas) mas = tmp;
   }
   cout << sum - mas / 2 << endl;
   return 0;
}


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

int dis(int i, int j, int x, int y){
  
  if((i < x)&&(j <= x))
    return j - i;
  
  if((i <= x)&&(x < j)&&(j <= y)){
    int p1 = j - i;
    int p2 = (x - i) + (y - j) + 1;
    return min(p1, p2);
  }
  
  if((i <= x)&&(y < j))
    return (j - i - y + x + 1); 
  
  if(x < i){
    if(i <= y){
      
      if(j <= y){
        int p1 = j - i;
        int p2 = (i-x) + (y-j) + 1;
        return min(p1, p2);
      }
      
      else{
        int p1 = j - i;
        int p2 = (i-x) + (j-y) + 1;
        return min(p1, p2);
      }
    }

    if(y < i)
      return j - i;
  }
}
      
int main(){
  int n, x, y;
  cin >> n >> x >> y;
  
  vector<int> count(n-1);
  
  for(int i = 1; i < n; i++){
    for(int j = i+1; j < n+1; j++){
      int res = dis(i, j, x, y)-1;
      count.at(res)++;
    }
  }
  
  for(int i = 0; i < n-1; i++)
    cout << count.at(i) << endl;  
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    while(true){
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) return 0;
 
        int d = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                for (int k = j + 1; k <= n; k++)
                    if (i + j + k == x) d++;
            }
        }
 
        cout << d << endl;
    }
    return 0;
}

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;

typedef pair<int, int> pii;

typedef struct V {
	int x1, y1, x2, y2;
}V;

int R, C;
int get_num(int x, int y) {
	int ret = -1;
	if (y == C && x < R) ret = 1;
	else if (x == R && y > 0) ret = 2;
	else if (y == 0 && x > 0) ret = 3;
	else if (x == 0 && y < C) ret = 4;
	// printf("(%d, %d): %d\n", x, y, ret);
	return ret;
}
/*
		t
	----------
	|        |
  l |        | r
	|        |
	----------
		b
*/

bool is_in(int x, int l, int r) {
	if (l < x && x < r) return true;
	return false;
}

vector<pii> l, r, b, t;

int main() {
	scanf("%d %d", &R, &C);

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int x1, y1, x2, y2;
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

		int num1 = get_num(x1, y1);
		int num2 = get_num(x2, y2);
		if (num1 == -1 || num2 == -1) continue;

		if (x1 == 0) {
			l.push_back({ y1, i });
		}
		else if (x1 == R) {
			r.push_back({ y1, i });
		}
		else if (y1 == 0) {
			b.push_back({ x1, i });
		}
		else
			t.push_back({ x1, i });

		if (x2 == 0) {
			l.push_back({ y2, i });
		}
		else if (x2 == R) {
			r.push_back({ y2, i });
		}
		else if (y2 == 0) {
			b.push_back({ x2, i });
		}
		else
			t.push_back({ x2, i });
	}

	sort(l.begin(), l.end());
	sort(r.rbegin(), r.rend());
	sort(b.rbegin(), b.rend());
	sort(t.begin(), t.end());

	bool inv = false;
	
	vector<int> A;
	for (auto cur : t)
		A.push_back(cur.second);
	for (auto cur : r)
		A.push_back(cur.second);
	for (auto cur : b)
		A.push_back(cur.second);
	for (auto cur : l)
		A.push_back(cur.second);

	stack<int> st;
	for (auto cur : A) {
		if (st.empty()) {
			st.push(cur);
		}
		else {
			if (st.top() == cur)
				st.pop();
			else
				st.push(cur);	
		}		
	}

	if (st.empty()) {
		puts("YES");
	}
	else{
		puts("NO");
	}
	return 0;
}

Measured memory_bytes: 3688
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
    map<char,long long> m;
    long long n;
    cin >> n;
    string S;
    for(char c='a'; c<='z';++c){
        m[c]=10000000;
    }   
    for(int i=0;i<n;++i){
        cin >> S;
        for(char c='a';c<='z';++c){
            m[c]=min(m[c],(long long)count(ALL(S),c));
        }
    }
    for(char c='a';c<='z';++c){
        for(long long i=1;i<=m[c];++i){
            cout << c;
        }
    }
}

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

int main() {
	string s;cin>>s;
	long long sum=0;
	for(int i=0;i<s.size();i++)
	sum+=s[i]-'0';
	
	sum%9==0?cout<<"Yes":cout<<"No";
	return 0;
}

Measured memory_bytes: 3692
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef pair<string, pair<int, int>> Data;

int main()
{
    int N;
    cin >> N;
    Data list[N+5];
    for(int i= 0; i < N; ++i) {
        string stmp; int ptmp;
        cin >> stmp >> ptmp;
        list[i].first = stmp;
        list[i].second.first = i+1;
        list[i].second.second = ptmp;
    }

    sort(list,
        list + N,
        [](const Data& x, const Data& y){
            if(x.first == y.first) { return x.second.second > y.second.second; }
            else { return x.first < y.first; }
        }
    );

    for(int i = 0; i < N; ++i) {
        cout << list[i].second.first << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int l,i,j;
int main(){
    cin>>s;
    l=s.size();
    for(i=0;i<l;i++)
        if(s[i]=='C')
            for(j=i+1;j<l;j++)
                if(s[j]=='F'){
                    cout<<"Yes";
                    return 0;
                }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
   int k;
   cin >> k;
   ll ans=1;
   ll n=7;
   bool a=true;
   rep(i,k+1){
       if(n%k==0){
           cout << ans << endl;
           a=false;
           break;
       }
       else{
           n=10*n+7;
           ans++;
           n%= k;
       }
   }
   if(a)cout << -1 << endl;
}

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

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> II;
typedef vector<II> VII;

#define REP(x, n) for (int x = 0; x < (n); ++x)
#define INF (1e9 + 1)
#define EPS 1e-9
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n, d, covered = 0, c = 0;
    cin >> n >> d;
    while (covered < n) {
        covered += 2 * d + 1;
        ++c;
    }
    cout << c << '\n';
    return 0;
}

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

using namespace std;

bool comparejobs(pair<int,int> j1, pair<int,int> j2) {
    if(j1.first == j2.first) {return j1.second < j2.second;}
    return j1.first < j2.first;
}


int main() {
    int N; cin >> N;
    vector<int> Numbs(N);
    int t1;
    int m1 = -1, ind1;
    for(int i = 0; i < N; ++i) {
        cin >> t1;
        Numbs[i] = t1;
        if(m1 < t1) {
            m1 = t1;
            ind1 = i;
        }
    }
    int m2 = -1;
    for(int i = 0; i < N; ++i) {
        if(Numbs[i] > m2 && i != ind1) {
            m2 = Numbs[i];
        }
    }
    
    for(int i = 0; i < N; ++i) {
        if(i != ind1) {
            cout << m1 << endl;
        }
        else{cout << m2 << endl;}
    }

}

Measured memory_bytes: 4032
from bisect import bisect_left

A, B, Q = list(map(int, input().split()))
S = [-10**11] + [int(input()) for _ in range(A)] + [10**11]
T = [-10**11] + [int(input()) for _ in range(B)] + [10**11]

for q in range(Q):
    x = int(input())
    i = bisect_left(S, x)
    j = bisect_left(T, x)

    sl, sr = x-S[i-1], S[i]-x
    tl, tr = x-T[j-1], T[j]-x

    print(min(max(sl, tl),
              max(sr, tr),
              sl*2 + tr,
              tl*2 + sr,
              sr*2 + tl,
              tr*2 + sl))

Measured memory_bytes: 12800
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())

const int INF = 1e9;


// code
// ------------------------------------------------
int main() {

  int k,n;
  cin >> k >> n;

  vector<int> a(n);
  vector<int> b(n);

  rep(i,n)
  {
    cin >> a[i];
  }

  rep(i,n)
  {
    int x = x + 1;
    if (i == n - 1) 
    {
      b[i] = (k - a[n - 1]) + a[0];
    }
    else
    {
      b[i] = a[i + 1] - a[i];      
    }
  }

  vsort(b);

  // rep(i,n)
  // {
  //   cout << b[i] << endl;;
  // }
  cout << k - b[n - 1];
  

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(x ==1){
      System.out.println(1);
      return;
    }
    int jou;
    int max = -1;
    for(int i = 2;i<=100;i++){
      jou = i;
      int aa = 0;
      while(jou <= x){
        jou *= i;
        aa++;
      }
      if(aa>1){
        jou /= i;
        max = Math.max(max,jou);
      }

    }
    System.out.println(max);
  }
}


Measured memory_bytes: 35696
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    ll n;
    cin >> n;
    vector <ll> a(n);
    vector <ll> b(n);
    rep(i,0,n){
        cin >> a[i];
		b[i] = a[i];
    }
	sort(b.begin(), b.end());
	rep(i,0,n){
		if (a[i] == b[n-1]) {
			cout << b[n-2] <<endl;
		} else {
			cout << b[n-1] << endl;
		}
	}
}

Measured memory_bytes: 4736
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    #define FOR(i,a,b)      for(int i=(a);i<(b);i++)
#define REP(i,n)        FOR(i,0,n)
#define SORT(v)         sort((v).begin(),(v).end())
#define UN(v)           SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)             memset(a,b,sizeof a)
#define pb              push_back
    // Modified version of : https://codeforces.com/contest/666/submission/17576849

    ll p25[2111111];
ll p26[2111111];
ll    f[2111111];
ll invf[2111111];
 
ll qp(ll c,ll st){
    ll r=1;
    while(st){
        if(st&1)r*=c,r%=mod;
        c*=c,c%=mod;
        st>>=1;
    }
    return r;
}
 
map<int,int> mp;
vector<vi> ans;
 
char s[2111111];
 
void solve(int n){
    
    if(mp.count(n)) return;
    int sz = mp.size();
    mp[n] = sz;
    ans.pb(vi(2000001,0));
 
    for(int i=n;i<=2000000;i++){
        ans.back()[i] = (ans.back()[i-1]*26ll + p25[i-n]*f[i-1]%mod*invf[n-1]%mod*invf[i-n])%mod;
        // cout<<i<<" "<<ans.back()[i]<<endl;
    }
}
 

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n,k,i,j;
            cin>>k;
            string s;
            cin>>s;
            n=s.length();
            p25[0]=1;
            p26[0]=1;
            f[0]=1;
            FOR(i,1,2111111){
                p25[i]=p25[i-1]*25%mod;
                p26[i]=p26[i-1]*26%mod;
                f[i]=f[i-1]*i%mod;
            }
            REP(i,2111111)invf[i]=qp(f[i],mod-2);
            solve(n);

            cout<<ans[mp[n]][n+k]<<endl;
        }
        return 0;
    }


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

using namespace std;

int main()
{
  string s; cin >> s;
  string ans = "";
  for (int i=0; i<s.size(); i++)
  {
    if (s[i]=='B')
    {
      if (!ans.empty()) ans.erase(ans.size()-1, 1);
    }
    else ans += s[i];
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
"use strict"

function main(input) {
  input = input.split(/\n/)

  let ans = "NO"
  if (
    input[0][0] == input[1][2] &&
    input[0][1] == input[1][1] &&
    input[0][2] == input[1][0]
  ) {
    ans = "YES"
  }

  console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7372
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define PI 3.141592653589793238462643383279


void change(int *x, int *y){
	int z;
	z = *x;
	*x = *y;
	*y = z;
}
int compare_int(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}

int main(void){
	unsigned long n, k;
	scanf("%lu %lu", &n, &k );
	unsigned long a[n];
	for(int i=0; i<n;i++)	scanf("%lu", &a[i]);
	
	unsigned long hairetu[40];
	for(int i=0;i<40;i++)	hairetu[i]=pow(2,i);
	
	unsigned long a2[n][40];	//aの2審
	unsigned long data[40];	//各桁の1の数
	for(int i=0;i<40;i++)	data[i]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<40;j++){
			a2[i][j] = (a[i] & hairetu[j]) / pow(2,j);
			data[j]+=a2[i][j];
		}
	}
	
	unsigned long ansnum=0;
	for(int i=39;i>=0;i--){
		if(data[i]*2<n){
			if(ansnum+hairetu[i]<=k)	ansnum+=hairetu[i];
		}
	}
	
	unsigned long ans=0;
	for(int i=0;i<n;i++){
		ans += ansnum ^ a[i];
	}
	
	printf("%lu", ans);
	return 0;
}

Measured memory_bytes: 32256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s.size()<4){
		cout<<"No"<<endl;
	}
	else{
		if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    ll N,K;
    cin >> N >> K;
    ll x[N];
    for(int i=0;i<N;i++){
        cin >> x[i];
    }
    ll ans=INF;
    for(ll i=0;i+K-1<N;i++){
        if(x[i]*x[i+K-1]<0){
            ans = min(ans,abs(x[i])+abs(x[i])+abs(x[i+K-1]));
            ans = min(ans,abs(x[i])+abs(x[i+K-1])+abs(x[i+K-1]));
        }else{
            ans = min(ans,max(abs(x[i]),abs(x[i+K-1])));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
using ull = unsigned long long;

const int MAX_N = 21;
const int MAX_MASK = 1 << (MAX_N + 1);
const ull MOD = 1e9 + 7;
ull dp[MAX_N + 1][MAX_MASK];
ull inp[MAX_N + 1];

int main() {
	ios_base::sync_with_stdio(false);
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;

	int N; cin >> N;
	for (size_t i = 1; i <= N; i++) {
		ull mask = 0;
		for (size_t j = 0; j < N; j++) {
			ull val; cin >> val;
			mask |= val << j;
		}
		inp[i] = mask;
	}

	ull MASK = 1 << N;
	for (size_t i = 1; i <= N; i++) {
		for (size_t mask = 0; mask < MASK; mask++) {
			if (__builtin_popcount(mask) == i - 1) {
				for (size_t bit = 0; bit <= N; bit++) {
					if ((1 << bit) & inp[i] && !((1 << bit) & mask)) {
						dp[i][(1 << bit) | mask] = (dp[i][(1 << bit) | mask] + dp[i - 1][mask]) % MOD;
					}
				}
			}
		}
	}
	cout << dp[N][(1 << N) - 1] << endl;
	return 0;
}

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

bool solve(string s,string t){
	int ss=s.size(),ts=t.size();
	for(int i=0;i<ts;i++){
		if(t[i]==s[0]){
			for(int j=1;i+j*(ss-1)<ts;j++){
				bool c=true;
				for(int k=1;k<ss;k++){
					if(t[i+j*k]!=s[k]){c=false; break;}
				}
				if(c)return true;
			}
		}
	}
	return false;
}

int main(){
	int n,ans=0;
	string s,t;
	scanf("%d",&n);
	cin>>s;
	for(int i=0;i<n;i++){
		cin>>t;
		if(solve(s,t))ans++;
	}
	printf("%d\n",ans);
}

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

#define ALL(obj) (obj).begin(),(obj).end()
template<class T> using priority_queue_reverse = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = 1'000'000'000LL + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
vector<string> split(const string &str, const char delemiter) {vector<string> res;stringstream ss(str);string buffer; while( getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}
int msb(int x) {return x?31-__builtin_clz(x):-1;}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> L(N);
    for(int i = 0; i < N; ++i) {
        cin >> L[i];
    }
    ll ans = 0;
    for(int i = 0; i < N; ++i) {
        for(int j = i+1; j < N; ++j) {
            for(int k = j+1; k < N; ++k) {
                if(L[i]+L[j]<=L[k]) continue;
                if(L[k]+L[i]<=L[j]) continue;
                if(L[j]+L[k]<=L[i]) continue;
                if(L[i]==L[j] || L[j]==L[k] || L[k]==L[i]) continue;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    string s; cin >> s;
    deque<char> q; //vectorと同じ動的配列クラスで、末尾だけでなく先頭への要素追加・削除ができる
    for (char c: s) q.push_back(c);
    bool flip=false;
    int Q; cin >> Q;
    rep(i,Q){
        int ty; cin >> ty;
        if(ty==1){
            flip=!flip;
        }else{
            int f; char c;
            cin >> f >> c;
            if (flip) f=3-f;
            if (f==1){
                q.push_front(c);
            }else{
                q.push_back(c);
            }
        }
    }
    if(flip) reverse(q.begin(),q.end());
    string ans;
    for (char c:q) ans+=c;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1412
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    int k = 0;
    while(n!=0) {
        k++;
        n>>=1;
    }
    cout << (1<<(k-1)) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n;
	cin>>n;

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

	ll ans[n+1];
	ans[1] = a[1];
	ans[2] = max(a[1],a[2]);

	if(n >= 3)
		ans[3] = max(a[2],a[3]);
	ll odd_sum[n+1];
	odd_sum[1] = a[1];

	for(int i =3;i <= n;i+=2)
		odd_sum[i] = odd_sum[i-2] + a[i];
	for(int i =4;i <= n;i++){
		if(i % 2 == 0)
			{ans[i] = ans[i-2] + a[i];
				ans[i] = max(ans[i],odd_sum[i-1]); //consider a;; odd indcices value
			}
		else
			ans[i] = max(ans[i-1],ans[i-2] + a[i]);
	}

	// for(int i =1;i<=n;i++)
	// 	cout<<ans[i]<<" ";
	// cout<<"\n";

	cout<<ans[n]<<"\n";

	return 0;
}

Measured memory_bytes: 8312