akhauriyash/Code-Regression huggingface dataset:
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int ans = n;
    for(int i = 0;i<n-1;i++){
        if(s[i] == s[i+1]) ans--;
    }
    cout << ans << endl;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

int main ()
{
    int x ;

    cin >> x ;

    int d = 3 ;

    cout << pow(x,d) ;




    return 0 ;
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a[10010],sum=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        a[i]*=n;
        sum+=a[i];
    }
    ll ave=sum/n;
    pll s[200];
    rep(i,n){
        s[i]=pll(abs(a[i]-ave),i);
    }
    sort(s,s+n);
    cout<<s[0].sc<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int a, b, c, x, y;
  cin >> a >> b >> c>> x >> y;
  if(a + b <= 2*c){
    cout << a*x + b*y << endl;
  }else{
    if(x < y){
      int p1 = c*2*x + (y - x)*b;
      int p2 = c*2*y;
      cout << min(p1, p2) << endl;
    }else{
      int p1 = c*2*y + (x - y)*a;
      int p2 = c*2*x;
      cout << min(p1, p2) << endl;
    }
  }
}


Measured memory_bytes: 256
# 3.4.3

import re
from collections import deque
from functools import reduce
from itertools import permutations
from math import pi
from operator import itemgetter
from operator import mul
from operator import xor
from os import linesep
from queue import PriorityQueue
from sys import stdin


def rline() -> str:
    return stdin.readline().strip()


def rlines(hint: int = 1):
    ret = ['' for i in range(hint)]
    for i in range(hint):
        ret[i] = rline()
    return ret


def htokens(hint: int = 1):
    lns = rlines(hint)
    ret = list(map(lambda ln: ln.split(), lns))
    # if return value has one and only one element(list),
    if hint == 1:
        # then add an empty list.
        ret.append([])
    return ret


def vtokens(hint: int = 1):
    m, _ = htokens()
    wint = len(m)
    ret = [[None] * hint for i in range(wint)]
    for y in range(hint):
        if y != 0:
            m, _ = htokens()
        # convert horizontal to vertical
        x = 0
        for v in m:
            ret[x][y] = v
            x += 1
    # if return value has one and only one element(list),
    if wint == 1:
        # then add an empty list.
        ret.append([])
    return ret


def rint(radix: int = 10) -> int:
    return int(rline(), radix)


def hints(hint: int = 1, radix: int = 10):
    ret = htokens(hint)
    for i in range(len(ret)):
        ret[i] = list(map(lambda v: int(v, radix), ret[i]))
    return ret


def vints(hint: int = 1, radix: int = 10):
    ret = vtokens(hint)
    for i in range(len(ret)):
        ret[i] = list(map(lambda v: int(v, radix), ret[i]))
    return ret


def mat(hint: int, wint: int):
    return [[None]*wint for i in range(hint)]


def filllist(lst, value: int) -> None:
    # destructive.
    for i in range(len(lst)):
        lst[i] = value


def isprime(n: int) -> bool:
    if n <= 1:
        return False
    if n in (2, 3, 5):
        return True
    if n % 2 == 0:
        return False
    if n % 3 == 0:
        return False
    lst = int(n**0.5)
    f = 5
    while f <= lst:
        if n % f == 0:
            return False
        if n % (f + 2) == 0:
            return False
        f += 6
    return True


def strmat(matrix, lnsep: str = linesep, fieldsep: str = ' ') -> str:
    return lnsep.join(map(lambda row: fieldsep.join(map(str, row)), matrix))


def strbool(boolval: int) -> str:
    return ['No', 'Yes'][boolval]


def solve() -> None:
    # read here
    n = rint()
    ss = rlines(n)

    # solve here
    dict = {}
    for s in ss:
        cnt = [0] * 26
        for c in s:
            cnt[ord(c) - ord('a')] += 1
        tup = tuple(i for i in cnt)
        if not tup in dict.keys():
            dict[tup] = 0
        dict[tup] += 1

    # 2-combination of x.
    ans = sum(map(lambda x: 0 if x == 1 else x*(x-1)//2, dict.values()))

    # print here
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 44280
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

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

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	int w, a, b; cin >> w >> a >> b;
	if ((b<=a+w&&b>=a) || (a <=b+w&&a>=b)) cout << 0;
	else {
		if (b > a + w) cout << b - a - w;
		if (a > b + w) cout << a - b - w;
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
l, r, d = map(int,input().split())
counter = 0
for i in range(l+1, r+1):
    if i % d == 0:
        counter += 1
if d == 1:
    print(counter + 1)
elif l == r:
    if l % d == 0:
        print(1)
    else:
        print(0)
else:
    print(counter)

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

int main () {

    int N;
    cin >> N;

    string S;
    cin >> S;

    vector<bool> left_alph(26, false), right_alph(26, false);
    
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            left_alph[S[j] - 'a'] = true;
        }

        for (int j = i + 1; j < N; j++) {
            right_alph[S[j] - 'a'] = true;
        }

        int cnt = 0;
        for (int j = 0; j < 26; j++) {
            if (left_alph[j] && right_alph[j]) {
                cnt++;
            }
            left_alph[j] = false;
            right_alph[j] = false;
        }

        ans = max(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>



int main(void){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(A==5&&B==7&&C==5)printf("YES\n");
    else if(A==5&&B==5&&C==7)printf("YES\n");
    else if(A==7&&B==5&&C==5)printf("YES\n");
    else printf("NO\n");
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
 
int main(){
    // vector<vector<int>> A(3, vector<int>(3));
    vector<vector<int>> A(3);
    vector<int> B;

    int N, M; cin >> N >> M;
    int ans[N];
    rep(i, N) ans[i]=-1;

    rep(i, M){
        int s; int c; cin >> s >> c; s--;

        // cout << " s" << s << " c:" << c << endl;

        if(N!= 1 && s==0 && c==0){
            cout << -1 << endl;
            return 0;
        }
        if(ans[s]==-1){ // 既にないならOK
            ans[s]=c;
            // cout << "   s: " << s << " c:" << c << endl;
        }else if(ans[s]!=c){
            // 既に違うものがあるならNG
            // cout << "   s: " << s << " c:" << c << endl;
            cout << -1 << endl;
            return 0;
        }
    }

    if(N==1){
        if(ans[0]==-1){
            cout << 0 << endl;
            return 0;
        }
    }
    // 穴埋め
    rep(i, N){
        // 最初の桁は1が最小値
        if(ans[i]==-1){
            if(i==0){
                ans[i] = 1;
            }else{
                ans[i] = 0;
            }
        }
    }
    rep(i, N) cout << ans[i];
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>

using namespace std;

int n,m,k,i,j;

int main()
{
    cin>>n>>m>>k;
	for(int i=0;i<=n;i++)
	    for(int j=0;j<=m;j++)
		    if((n-i)*j+(m-j)*i==k){puts("Yes");return 0;}
	puts("No");
}

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

using namespace std;

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.14159265;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' '; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
//double d;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> s;
	n = s.length();
  string as(s.cbegin(),s.cbegin()+(n-1)/2);
  string bs(s.cbegin()+(n+3)/2-1,s.cend());
  	//dbg(as);dbg(bs);
  string ss(s), aas(as), bbs(bs);
  reverse(ALL(ss));
  reverse(ALL(aas));
  reverse(ALL(bbs));
	if (s==ss&&as==aas&&bs==bbs) {
    	cout << "Yes"; return 0;
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
    return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_i64_desc(const void* a, const void* b) {
    return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

static size_t powSz(const size_t base, const size_t exp) {
    if (exp == 0) {
        return 1;
    }

    if (exp == 1) {
        return base;
    }

    if (exp % 2 == 0) {
        return powSz(base * base, exp / 2);
    }
    else {
        return base * powSz(base, exp - 1);
    }
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    size_t N, M;
    int32_t a[50], b[50], c[50], d[50];

    scanf("%zu %zu\n", &N, &M);
    for (size_t i = 0; i < N; i++) {
        scanf("%"PRId32" %"PRId32"\n", &(a[i]), &(b[i]));
    }
    for (size_t i = 0; i < M; i++) {
        scanf("%"PRId32" %"PRId32, &(c[i]), &(d[i]));
        if (i < M - 1) {
            scanf("\n");
        }
    }

    for (size_t i = 0; i < N; i++) {
        size_t nearestCP = 0;
        size_t distanceToNearestCP = (size_t)ABS(a[i] - c[0]) + (size_t)ABS(b[i] - d[0]);
        for (size_t cp = 1; cp < M; cp++) {
            const size_t distanceToCP = (size_t)ABS(a[i] - c[cp]) + (size_t)ABS(b[i] - d[cp]);
            if (distanceToCP < distanceToNearestCP) {
                nearestCP = cp;
                distanceToNearestCP = distanceToCP;
            }
        }

        printf("%zu\n", nearestCP + 1);
    }

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<math.h>
#define P 3.141592653589793
using namespace std;

double Y(int z){
	if(z==0||z==180)return 0.0;
	if(z<180)return sin(P/180*z);
	return -sin(P/180*(360-z));
}
double X(int z){
	if(z==90||z==270)return 0.0;
	if(z<180)return cos(P/180*z);
	return cos(P/180*(360-z));
}
int main(){
	double x=0,y=0;
	int z=90,a,b;char u;
	while(cin>>a>>u>>b&&a+b){
		y+=a*Y(z),x+=a*X(z);
		z-=b;z%=360;if(z<0)z+=360;
	}
	int xx=x,yy=y;
	cout<<xx<<endl;
	cout<<yy<<endl;
	return 0;
}

Measured memory_bytes: 3328
n = int(input())

a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))

memory=-1
add=0
ans=0

for i in range(n):
    ans+=b[a[i]-1]
    if a[i]==memory+1:
        ans+=add
    
    memory=a[i]
    if a[i]!=n:
        add=c[a[i]-1]
    else:
        add=0

print(ans)

Measured memory_bytes: 9132
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

bool bingo(const std::vector<std::vector<int>>& mat)
{
    for (const auto& line : mat)
    {
        int sum = 0;
        for (const auto& elm : line)
        {
            sum += elm;
        }
        if (sum == 0)
            return true;
    }

    for (int i = 0; i < 3; ++i)
    {
        int sum = 0;
        for (int j = 0; j < 3; ++j)
        {
            sum += mat[j][i];
        }
        if (sum == 0)
            return true;
    }

    int sum = 0;
    for (int i = 0; i < 3; ++i)
    {
        sum += mat[i][i];
    }
    if (sum == 0)
        return true;

    sum = mat[0][2] + mat[1][1] + mat[2][0];
    if (sum == 0)
        return true;

    return false;
}

void garagara(std::vector<std::vector<int>>& mat, int n)
{
    for (auto& line : mat)
    {
        for (auto& elm : line)
        {
            if (elm == n)
            {
                elm = 0;
                return;
            }
        }
    }
}


void b(std::istream& in)
{
    std::vector<std::vector<int>> mat(3, std::vector<int>(3, 0));
    in >> mat[0][0] >> mat[0][1] >> mat[0][2];
    in >> mat[1][0] >> mat[1][1] >> mat[1][2];
    in >> mat[2][0] >> mat[2][1] >> mat[2][2];

    int N;
    in >> N;

    for (int i = 0; i < N; ++i)
    {
        int b;
        in >> b;
        garagara(mat, b);
        if (bingo(mat))
        {
            std::cout << "Yes";
            return;
        }
    }
    std::cout << "No";
}

int main(int, char* [])
{
    b(std::cin);
    return 0;
}


Measured memory_bytes: 256
n,a,b=gets.split.map &:to_i
if a>b
  p 0
else
  if n==1
    if a==b
      p 1
    else
      p 0
    end
  elsif n==2
    p 1
  else
    g=n-2
    p (b-a).abs*g+1
  end
end

Measured memory_bytes: 1788
q = int(input())
for _ in range(q):
    x0, y0, x1, y1, x2, y2, x3, y3 = map(int, input().split())
    s = (x3 - x2)*(y0 - y2) - (x0 - x2)*(y3 - y2)
    t = (x1 - x0)*(y3 - y2) - (x3 - x2)*(y1 - y0)
    u = s/t
    print(x0 + u*(x1 - x0), y0 + u*(y1 - y0))



Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define nn 300008
#define int long long 
#define mod 998244353
int ai[nn],bi[nn];int n;
signed main() {
	#define a ai
	#define b bi
	scanf("%lld",&n);for(int i=1;i<=n;i++) scanf("%lld",&ai[i]);for(int i=1;i<=n;i++) scanf("%lld",&bi[i]);
	#define pii pair<int,int>
	#define mp make_pair
	set<pii> s;for(int i=1;i<=n;i++) s.insert(mp(bi[i],i));
	int ans=0;
	while(s.size()){
		int x=(*s.rbegin()).second;s.erase(--s.end());
		if(b[x]==a[x]) continue;
		if(b[x]<a[x]) break;
		b[0]=b[n],b[n+1]=b[1];
		int su=b[x-1]+b[x+1],dif=b[x]-a[x];
		if(dif<su) break;
		ans+=dif/su,dif%=su;
		b[x]=a[x]+dif;
		s.insert(mp(b[x],x));
	}
	
	for(int i=1;i<=n;i++) if(ai[i]!=bi[i]) return puts("-1")*0;
	cout<<ans;
	return 0;
}



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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

auto factoring = [](i64 x){
    int sq = sqrt(x) + 1;
    vector<int> ret;
    if(x == 1){
        ret.emplace_back(1);
        return ret;
    }
    for(i64 i = 2; i < sq; ++i)
        while(x % i == 0){
            ret.emplace_back(i);
            x /= i;
        }
    if(x != 1)
        ret.emplace_back(x);
    return ret;
};


template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;




signed main(){
    int n;
    cin >> n;
    vector<int> v(200, 0);
    for(int i = 0; i < n; ++i){
        auto res = factoring(i + 1);
        for(auto y : res)
            ++v[y];
    }
    vector<vector<int>> dp(201, vector<int>(76, 0));
    dp[2][1] = 1;
    for(int i = 2; i < 200; ++i){
        for(int j = 1; j < 76; ++j){
            if(dp[i][j] == 0)
                continue;
            for(int k = 0; k <= v[i]; ++k){
                if(j * (k + 1) <= 75){
                    dp[i + 1][j * (k + 1)] += dp[i][j];
                }
            }
        }
    }
    cout << dp.back()[75] << endl;
}


Measured memory_bytes: 3652
N, M = map(int, input().split())

param = []
for i in range(M):
    ks = [int(s)-1 for s in input().split()]

    x = 0
    for i in range(1, len(ks)):
        x += pow(2, ks[i])
    param.append(x)


P = [int(s) for s in input().split()]


ans = 0
for x in range(pow(2, N)):
    check = True
    for i in range(M):
        if bin(param[i] & x).count("1") % 2 != P[i]:
            check = False
            break

    if check:
        ans += 1

print(ans)


Measured memory_bytes: 3064
n,m=map(int,input().split())
mod=10**9+7

def a(x):
    ans=1
    for i in range(1,x+1):
        ans*=i
        ans%=mod
    return ans

if n==m:
    print(2*(a(n)**2)%mod)
elif n==m+1:
    print(a(n)*a(n-1)%mod)
elif m==n+1:
    print(a(m)*a(m-1)%mod)
else:
    print(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=2e6+5,p=998244353;
int inv[N],f[N],finv[N];
int comb(int n,int m)
{
	if(n<m)return 0;
	return f[n]*1ll*finv[m]%p*finv[n-m]%p;
}
int qpow(int a,int b){int ret=1;while(b){if(b&1)ret=1ll*ret*a%p;a=1ll*a*a%p;b>>=1;}return ret;}
int iv(int a){return qpow(a,p-2);}
int main()
{
//	freopen("yesorno.in","r",stdin);
//	freopen("yesorno.out","w",stdout);
//	cout<<499122178*2ll%p;
	int n=2e6,m,ans;
	f[0]=finv[0]=inv[1]=f[1]=finv[1]=1;
	for(int i=2;i<=n;i++)
	{
		inv[i]=(p-p/i)*1ll*inv[p%i]%p;
		f[i]=1ll*f[i-1]*i%p;
		finv[i]=1ll*finv[i-1]*inv[i]%p;
	}
	cin>>n>>m;
	if(n<m)swap(n,m);
	ans=(m+1)*1ll*comb(n+m,m+1)%p;
//	cout<<"dsfg\n";
	for(int i=1;i<=m;i+=2)ans=(ans+comb(n+m+1,m-i))%p;
//	cout<<"dsfg\n";
	ans=ans*1ll*iv(comb(n+m,n))%p;
	cout<<ans<<endl;
}

Measured memory_bytes: 23680
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  string S; cin>>S;
  string T; cin>>T;
  ll sl=S.size();
  ll tl=T.size();
  ll key=sl-tl+1;
  ll count=sl;
  if(sl<tl) cout<<"UNRESTORABLE"<<endl;
  else{
  rep(i,key){
    bool ok=true;
    rep(j,tl){
      if(T[j]!=S[sl-tl+j-i]&&S[sl-tl+j-i]!='?') ok=false;
      else continue;
    }
    if(ok) {
      count=sl-tl-i;
      break;
    }
  }
  if(count==sl) cout<<"UNRESTORABLE"<<endl;
  else{
    rep(i,sl) if(S[i]=='?') S[i]='a';
    rep(i,tl) S[count+i]=T[i];
    cout<<S<<endl;
  }
  }
}



Measured memory_bytes: 256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

/*考えを書くスペース
xxxxxxxxxx  0000000000 最初のsearchで
xoooooooxx  0111111100
xxoooooxxx  0011111000
xxxoooxxxx  0001110000
xxxxoxxxxx  0000100000
xxxxxxxxxx  0000000000
xxxxoxxxxx  0000200000
xxxoooxxxx  0002220000
xxoooooxxx  0022222000
xxxxxxxxxx  0000000000
*/
//main.cpp----------------------------
#define max_n 100

void solve();

string s;
ll pos[4];

int main() {
  cin >> s;

  solve();

  return 0;
}

void solve() {

  ll length = (int)(s.length());

  rep(i, length) {
    if(s[i]=='N') pos[0]+=1;
    if(s[i]=='S') pos[1]+=1;
    if(s[i]=='W') pos[2]+=1;
    if(s[i]=='E') pos[3]+=1;
  }
  ll cnt = 0;
  rep(i, 4) {
    if(pos[i]==0) cnt += 1;
  }

  if(cnt==3) {
    cout << "No" << endl;
    return;
  }

  if((pos[0]==0&&pos[1]==0)||(pos[2]==0&&pos[3]==0)) {
    cout << "Yes" << endl;
    return;
  }

  if(pos[0]==0||pos[1]==0||pos[2]==0||pos[3]==0) {
    cout << "No" << endl;
    return;
  }

  cout << "Yes" << endl;
  return;
}


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

int int_sort( const void * a , const void * b ) {
  if( *( int * )a < *( int * )b ) {
    return -1;
  }
  else
    if( *( int * )a == *( int * )b ) {
      return 0;
    }
  return 1;
}


int main(void){

  int N;
  scanf("%d", &N);

  int *A,*B;
  A = (int*)malloc((N/2)*sizeof(int));
  B = (int*)malloc((N/2)*sizeof(int));
  for(int i=0; i<N; i++){
    scanf("%d %d ", &A[i], &B[i]);
  }

  qsort(A,N/2,sizeof(int),int_sort);
  qsort(B,N/2,sizeof(int),int_sort);
  int num=1,maxA1=0,maxA2=0,keyA1=0,keyA2=0,maxB1=0,maxB2=0,keyB1=0,keyB2=0;

  for(int i=0; i<N/2-1; i++){
    if(A[i]==A[i+1]){
      num++;
    }else{
      if(num>maxA1){
        maxA2 = maxA1;
        maxA1 = num;
        keyA2 = keyA1;
        keyA1 = A[i];
      }else if(num>maxA2){
        maxA2 = num;
        keyA2 = A[i];
      }
      num = 1;
    }
  }
  if(num>maxA1){
    maxA2 = maxA1;
    maxA1 = num;
    keyA2 = keyA1;
    keyA1 = A[N/2-1];
  }else if(num>maxA2){
    maxA2 = num;
    keyA2 = A[N/2-1];
  }
  num=1;

  for(int i=0; i<N/2-1; i++){
    if(B[i]==B[i+1]){
      num++;
    }else{
      if(num>maxB1){
        maxB2 = maxB1;
        maxB1 = num;
        keyB2 = keyB1;
        keyB1 = B[i];
      }else if(num>maxB2){
        maxB2 = num;
        keyB2 = B[i];
      }
      num = 1;
    }
  }
  if(num>maxB1){
    maxB2 = maxB1;
    maxB1 = num;
    keyB2 = keyB1;
    keyB1 = B[N/2-1];
  }else if(num>maxB2){
    maxB2 = num;
    keyB2 = B[N/2-1];
  }

  int ans=0;

  if(keyA1!=keyB1){
    ans = N-maxA1-maxB1;
  }else if(maxA2>maxB2){
    ans = N-maxA2-maxB1;
  }else{
    ans = N-maxA1-maxB2;
  }

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

  return 0;
}



Measured memory_bytes: 824
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
//constexpr int inf = 3e18;


int N,D;
int V[1<<18],W[1<<18];
int memo[1<<18],dep[1<<18];
vector<P>dp[1<<18];
void dfs(int x,int depth){
	dep[x]=depth;
	if(depth<D/2){
		for(auto i:dp[x]){
			if(x*2+1<N){
				dp[x*2+1].pb({i.first+W[x*2+1],i.second+V[x*2+1]});
				dp[x*2+1].pb(i);
			}
			if(x*2+2<N){
				dp[x*2+2].pb(i);
				dp[x*2+2].pb({i.first+W[x*2+2],i.second+V[x*2+2]});
			}
		}
	}
	else if(depth==D/2){
		if(x*2+1<N){
			memo[x*2+1]=x;
			dp[x*2+1].pb({0,0});
			dp[x*2+1].pb({W[x*2+1],V[x*2+1]});
		}
		if(x*2+2<N){
			memo[x*2+2]=x;
			dp[x*2+2].pb({0,0});
			dp[x*2+2].pb({W[x*2+2],V[x*2+2]});
		}
	}else {
		if(x*2+1<N){
			memo[x*2+1]=memo[x];
		}
		if(x*2+2<N){
			memo[x*2+2]=memo[x];
		}
		for(auto i:dp[x]){
			if(x*2+1<N){
				dp[x*2+1].pb({i.first+W[x*2+1],i.second+V[x*2+1]});
				dp[x*2+1].pb(i);
			}
			if(x*2+2<N){
				dp[x*2+2].pb(i);
				dp[x*2+2].pb({i.first+W[x*2+2],i.second+V[x*2+2]});
			}
		}
	}
	if(x*2+1<N)dfs(x*2+1,depth+1);
	if(x*2+2<N)dfs(x*2+2,depth+1);
}
signed main(){
	cin>>N;
	rep(i,19){
		if((1<<i)>=N){
			D=i;break;
		}
	}
	rep(i,N)cin>>V[i]>>W[i];
	dp[0].pb({0,0});dp[0].pb({W[0],V[0]});
	dfs(0,0);
	rep(i,N){
		if(dep[i]>D/2)continue;
		sort(all(dp[i]));
		rep(j,len(dp[i])-1){
			chmax(dp[i][j+1].second,dp[i][j].second);
		}
	}
	int Q;
	cin>>Q;
	while(Q--){
		int v,L;cin>>v>>L;v--;
		if(dep[v]<=D/2){
			int j=upper_bound(all(dp[v]),P(L,mod))-dp[v].begin();
			j--;
			cout<<dp[v][j].second<<endl;
		}else {
			int mx=0;
			for(auto i:dp[v]){
				if(L<i.first)continue;
				int j=upper_bound(all(dp[memo[v]]),P(L-i.first,mod))-dp[memo[v]].begin();
				j--;
				chmax(mx,i.second+dp[memo[v]][j].second);
			}
			cout<<mx<<endl;
		}
	}
}


Measured memory_bytes: 372928
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()

isp = [True] * 1001
isp[0] = isp[1] = False
for p in range(2, 1001):
    if isp[p]:
        for j in range(p*2, 1001, p):
            isp[j] = False

maxe = [0] * 1000001
for v in a:
    for p in range(2, 1001):
        e = 0
        while v % p == 0:
            v //= p
            e += 1
        maxe[p] = max(maxe[p], e)
    if v > 1:
        maxe[v] = max(maxe[v], 1)

def inv(a, mod):
    b = mod
    p, q = 1, 0
    while b > 0:
        c = a//b
        d = a; a = b; b = d % b
        d = p; p = q; q = d-c*q
    return p+mod if p < 0 else p


ans = 1
mod = 1000000007
for i in range(2, 1000001):
    for j in range(maxe[i]):
        ans = ans * i % mod

xx = 0
for v in a:
    xx += inv(v, mod)

print(ans*xx%mod)


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

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

    char memo[26] = {};
    char memo1[26] = {};
    string ans = "Yes";
    for(int i = 0; i < s.length(); i++){
        if(memo[t[i]-'a'] == 0){
            memo[t[i]-'a'] = s[i];
        }else if(memo[t[i]-'a'] != s[i]){
            ans = "No";
        }
        if(memo1[s[i]-'a'] == 0){
            memo1[s[i]-'a'] = t[i];
        }else if(memo1[s[i]-'a'] != t[i]){
            ans = "No";
        }
    }
    
    cout << ans << endl;
    return 0;
}

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


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; }

//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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())


//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

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

	//dp[i番目までみたとき]の最小コスト

	vector<int> dp(n + 2, INF);
	dp[0] = 0;

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

			if (i - j < 0)break;

			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}

	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a>b){
    printf("a > b\n");
  }else if (a<b){
    printf("a < b\n");
  }else if (a==b){
    printf("a == b\n");}
    return 0;
  }

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, x, m;
    cin >> n >> x >> m;
    vector<int>val(m, 0);
    val[x] = 1;
    long long y = -1, z = -1, len = -1;
    long long sum[100006];
    sum[0] = 0;
    sum[1] = x;
    for(long long i = 2; i <= n; i++){
        x = (x * x) % m;
        if(val[x] != 0){
            y = val[x];
            z = i - 1;
            len = i - y;
            break;
        }
        val[x] = i;
        sum[i] = sum[i - 1] + x;
    }
    if(z == -1){
        cout << sum[n];
    }
    else{
        long long ans = sum[z];
        ans += ((n - z)/len) * (sum[z] - sum[y - 1]);
        long long r = (n - z) % len;
        ans += sum[y + r - 1] - sum[y - 1];
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 3984
n=gets.to_i
s=gets.split.map(&:to_i)
q=gets.to_i
t=gets.split.map(&:to_i).sort
c=0
q.times{|i|
	l=0
	r=n
	while l<r
		m=(l+r)/2
		if t[i]==s[m]
			c+=1
			break
		elsif t[i]<s[m]
			r=m
		else
			l=m+1
		end
	end
}
p c


Measured memory_bytes: 16136
#include<stdio.h>
int main(){
	int k[33]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	scanf("%d",&n);
	printf("%d",k[n-1]);
	
}

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

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int x[110], y[110];
  for (int i = 0; i < N; i++) cin >> x[i];
  for (int i = 0; i < M; i++) cin >> y[i];

  sort(x, x + N);
  sort(y, y + M);
  
  bool ans = false;

  for (int Z = X + 1; Z <= Y; Z++) {
    if (Z > x[N - 1] && Z <= y[0]) {
      ans = true;
      break;
    }
  }

  cout << (ans ? "No War" : "War") << endl;
}

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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto &(i) : (vec))


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

string restore(Wint &DP, string &s, string &t, int i, int j){
  if(i == 0 || j == 0) return "";
  if(DP[i][j] == DP[i - 1][j]) return restore(DP, s, t, i - 1, j);
  if(DP[i][j] == DP[i][j - 1]) return restore(DP, s, t, i, j - 1);
  return restore(DP, s, t, i-1, j-1) + s.at(i-1);
}

int main(void){
  string s, t; cin >> s >> t;
  int ss = s.size(), ts = t.size();
  /* DP[i][j] := s_0s_1...s_(i-1)とt_0t_1...t_(j-1)の最長部分列の長さ <~ 文字列は長さで復元可能
  *              (ただし, 0 <= i <= s.size, 1<= j <= t.size)
  * DP(0)(0) = 初期文字による
  */
  Wint DP(ss + 1, Vint(ts + 1, 0));
  REP(i, ss) REP(j, ts){
    if(s.at(i) == t.at(j)) chmax(DP[i + 1][j + 1], DP[i][j] + 1);
    else{
    chmax(DP[i + 1][j + 1], DP[i + 1][j]);
    chmax(DP[i + 1][j + 1], DP[i][j + 1]);
    }
  }
  /*
  REP(i, ss + 1) REP(j, ts + 1){
    printf("DP(%d, %d) = %d\n", i, j, DP[i][j]);
  }*/
  cout << restore(DP, s, t, s.size(), t.size()) << "\n";
  return 0;
}

Measured memory_bytes: 35840
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    if(sz(s) % 2 == 0){
        s.pop_back();
        s.pop_back();
        while(true){
            if(s.substr(0, sz(s) / 2) == s.substr(sz(s) / 2)){
                print(sz(s));
                return 0;
            }
            s.pop_back();
            s.pop_back();
        }
    } else {
        s.pop_back();
        while(true){
            if(s.substr(0, sz(s) / 2) == s.substr(sz(s) / 2)){
                print(sz(s));
                return 0;
            }
            s.pop_back();
            s.pop_back();
        }
    }


    

}


Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>

int main(){
  char s[258] = {}, tmp[258] = {};
  int m, h, i, l;
  while(scanf("%s", s) && s[0] != '-'){
    scanf("%d", &m);
    while(m--){
      scanf("%d", &h);
      strcpy(tmp, s + h);
      s[h] = '\0';
      strcat(tmp, s);
      strcpy(s, tmp);
    }
    puts(s);
  }
  return 0;
}



Measured memory_bytes: 2028
#include<bits/stdc++.h>
using namespace std;
long long n,x;
int cnt=0,ans=0,y;
int main()
{
	scanf("%lld",&n);
	for(long long i=2;i*i<=n;++i) {
		x=i;
		cnt=0;
		while(n%x==0) {
			n/=x;
			++cnt;
		}
		if(cnt!=0) {
			y=1;
			while(cnt>=y) {
				cnt-=y;
				++ans;
				++y;
			}
		}
	}
	if(n>1) ++ans;
//	for(long long i=2;i*i<=n;++i) 
//		if(vis[i]==0) {
//			x=i;
//			while(n%x==0) {
//				printf("%lld\n",x);
//				vis[x]=1;
//				n/=x;
//				x*=i;
//				++cnt;
//			}
//		}
//	if(n>1) ++cnt;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    int L,R,d;
    cin >> L >> R >> d;
    int count = 0;
    for (int i = L;i <= R;i++){
        if ((i % d) == 0){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

int main(){
  int N,SUM=0;
  cin >> N;
  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin >> d.at(i);
  }
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      SUM+=d.at(i)*d.at(j);
    }
  }
  cout << SUM << endl;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007
#define M_MAX 1111

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

int xx[M_MAX*M_MAX];
int yy[M_MAX*M_MAX];
pair<int,int> dp[M_MAX][M_MAX];
bool isp[M_MAX*M_MAX];
int mp[M_MAX][M_MAX];
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};

void f(){
	int x = M_MAX-1;
	int y = M_MAX-1;
	int now = M_MAX*M_MAX;
	int cou = 0;
	
	while(now > 0){
		mp[y][x] = now;
		xx[now] = x;
		yy[now] = y;
		now--;
		int tmpx = x + dx[cou];
		int tmpy = y + dy[cou];
		
		if(tmpx >= 0 && tmpx < M_MAX && tmpy >= 0 && tmpy < M_MAX && 
		mp[tmpy][tmpx] == 0){
			x = tmpx;
			y = tmpy;
		}
		else{
			cou = (cou + 1) % 4;
			x += dx[cou];
			y += dy[cou];
		}
	}
	
	REP(i,M_MAX*M_MAX)isp[i] = true;
	isp[0] = isp[1] = false;
	for(int i = 2;i < M_MAX*M_MAX;i++){
		if(isp[i]){
			for(int j = 2*i;j < M_MAX*M_MAX;j += i)isp[j] = false;
		}
	}
}

int main(){
	
	f();
	
	int n,m;
	
	while(cin >> m >> n,n|m){
		
		REP(i,M_MAX)REP(j,M_MAX)dp[i][j] = MP(-1,-1);
		
		dp[yy[n]][xx[n]] = MP(0,0);
		
		REP(i,M_MAX){
			REP(j,M_MAX){
				if(dp[i][j] != MP(-1,-1) && mp[i][j] <= m){
					if(isp[mp[i][j]]){
						dp[i][j] = MP(dp[i][j].FI+1,mp[i][j]);
					}
					REP(k,3){
						int x = j + dx[k];
						int y = i + 1;
						DBG(cout << "xy : " << x << ' ' << y << endl;)
						if(x >= 0 && x < M_MAX && y >= 0 && y < M_MAX){
							dp[y][x] = max(dp[i][j],dp[y][x]);
						}
					}
				}
			}
		}
		
		pair<int,int> ans = MP(0,0);
		
		REP(i,M_MAX){
			REP(j,M_MAX){
				if(mp[i][j] <= m)ans = max(ans,dp[i][j]);
			}
		}
		
		cout << ans.FI << ' ' << ans.SE << endl;
	}

	return 0;
}


Measured memory_bytes: 28320