akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];

		int sum = 0;

		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt();
			sum += a[i] - 1;
		}

		System.out.println(sum);
	}
}

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

int main()
{
    int lpf[1000001];
    lpf[1]=1;
    for(int i=2;i<1000001;i++)
    lpf[i]=i;
    for(int i=2;i<1000001;i++)
    {
        if(lpf[i]!=i)
        continue;
        for(int j=i+i;j<1000001;j+=i){
            lpf[j]=min(lpf[j],i);
        }
    }

    int n;
    cin>>n;
    unordered_map<int,int> mp;
    bool all=1;
    for(int i=0;i<n;i++)
    {
        int ele;
        cin>>ele;
        while(ele!=1)
        {
            if(mp.count(lpf[ele])>0)
            all=0;
            mp[lpf[ele]]++;
            int t=lpf[ele];
            while(ele!=1 && ele%t==0)
            ele=ele/t;
        }
    }

    if(all)
    {cout<<"pairwise coprime"<<endl;
    return 0;
    }
    all=1;
    for(pair<int,int> k:mp)
    {
        if(k.first!=1 && k.second==n)
        {
            all=0;
            break;
        }
    }
    if(all)
    cout<<"setwise coprime"<<endl;
    else
    cout<<"not coprime"<<endl;
    return 0;
}

Measured memory_bytes: 10516
/* 
Mohit Dhattarwal
*/
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define gcd(a,b) __gcd(a,b)
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define filewr() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
 
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,ll> psl;
typedef pair<ll,string> pls;
 
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}
 
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
 
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
const ld PI = 3.1415926535897932384626433832795;
 
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;

void solve()
{
	char a;
	cin>>a;
	if(isupper(a))
	{
		cout<<"A"<<'\n';
	}
	else
	{
		cout<<"a"<<'\n';
	}
}

int main(){
	fastio();
	ll t;
	t=1;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3644
n, t0 = list(map(int, input().split()))
T = list(map(int, input().split()))
ans = t0 * n
for i in range(1, n):
    if T[i] - T[i - 1] < t0:
        ans -= t0 - (T[i] - T[i - 1])
print(ans)

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

int main(){
  int dp[51];
  int num;
  cin>>num;
  dp[0]=1;
  dp[1]=1;
  for(int i=2;i<=num;i++) dp[i]=dp[i-1]+dp[i-2];
  cout<<dp[num]<<endl;
 return 0;
}

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


public class Test
{	
    public static void Main()
	{
	    string s1 = Console.ReadLine();
	    string s2 = Console.ReadLine();
	    bool ok = true;
	    
	    for(int i = 0; i < s1.Length ; i++)
	    {
	        if(s1[i] != s2[s2.Length-1 -i]) ok = false;
	    }
	    
	    if(ok)
	    {
	        Console.WriteLine("YES");
	    }
	    else Console.WriteLine("NO");
	    
	} 
}

Measured memory_bytes: 13140
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    M = 10**9 + 7

    def gp(n):
        prohibit = []
        for c in product('AGCT', repeat=n):
            c = ''.join(c)
            if 'AGC' in c:
                prohibit.append(c)

            for i in range(n-1):
                j = i+1
                l = list(c)
                l[i], l[j] = l[j], l[i]
                if 'AGC' in ''.join(l):
                    prohibit.append(c)
        return set(prohibit)

    p3 = gp(3)
    p4 = gp(4)



    memo = {}
    for c in product('AGCT', repeat=3):
        c = ''.join(c)
        if c not in p3:
            memo[c] = 1

    for _ in range(N-3):
        nm = Counter()
        for c in 'AGCT':
            for k, v in memo.items():
                kk = k + c
                if kk not in p4:
                    nm[kk[1:]] += v
                    nm[kk[1:]] %= M

        memo = nm


    return sum(memo.values()) % M


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 83948
n, l= map(int, input().split())

apple = [l+i for i in range(n)]
ans = -1
vol = apple[n-1]
for i in range(n):
  tmp = sum(apple)
  if abs(vol) > abs(apple[i]):
    vol = apple[i]
    ans = i
print(tmp - apple[ans])

Measured memory_bytes: 3064
use std::io::Read;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();
    let x: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut dp: Vec<usize> = vec![0; n];
    for i in 1..n {
        dp[i] = min(
            dp[i - 1] + (x[i] - x[i - 1]) * a,
            dp[i - 1] + b
        );
    }
    return dp[n - 1].to_string();
}


Measured memory_bytes: 6396
#include <iostream>

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

    int r1 = 1;
    int r2 = 1;
    int result = 1;

    if (n == 1) {
        std::cout << 1 << std::endl;
    } else {
        for (int i = 1; i < n; i++) {
            int tmp = r1;
            r1 = r2;
            r2 = result;
            result += r1;
        }
        std::cout << result << std::endl;
    }
}



Measured memory_bytes: 3136
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N = II()
    A = LMIIS()
    nums = [0]*(N+1)
    
    for a in A:
        nums[a] += 1

    max_choice = 0
    for c in nums:
        max_choice += c*(c-1)//2
    
    for k in range(N):
        x = nums[A[k]]
        print(max_choice - x*(x-1)//2 + max((x-1)*(x-2)//2,0))

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 104472
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Threading;

class Program
{
    static void Main(string[] args)
    {
        var arr = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        int k = arr[0];
        int x = arr[1];
        if (500 * k >= x) Console.WriteLine("Yes");
        else Console.WriteLine("No");


    }



}

Measured memory_bytes: 28132
def solve():
	x,n = map(int,input().split())

	if n==0:
		print(x)
		return

	arr = list(map(int,input().split()))


	dic = {}
	for i in arr:
		dic[i]=1

	res = -300

	for i in range(n+1):
		if x-i not in dic:
			res = x-i
			break
		elif x+i not in dic:
			res = x+i
			break
	if res==-300:
		print(x-n)
	else:
		print(res)


if __name__ == "__main__":
	solve()


Measured memory_bytes: 61940
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,k[100005],sum=0,ans=0;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>k[i];
    if(k[i]==0){
      ans+=sum/2;
      sum=0;
    }
    else{sum+=k[i];}
  }
  ans+=sum/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())

students = []
for _ in range(n):
    s, t = map(int, input().split())
    students.append((s, t))

xy = []
for _ in range(m):
    x, y = map(int, input().split())
    xy.append((x, y))

# O(nm)
for s, t in students:
    MIN = float('infinity')
    checkpoint = 0
    for i in range(len(xy)):
        x, y = xy[i]
        distance = abs(s - x) + abs(t - y)
        if distance < MIN:
            MIN = distance
            checkpoint = i
    print(checkpoint + 1)

Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
    ll x=0,w=0;char ch=getchar();
    while(!isdigit(ch))w|=ch=='-',ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return w?-x:x;
}
ll cntt,to[10000],headd[10000],nextt[10000],vis[10000];
ll n,a[10000],gs,x,y;
inline void add(ll u,ll v)
{
	to[++cntt]=v;nextt[cntt]=headd[u];headd[u]=cntt;
}
inline bool dfs(ll u,ll fa)
{
	if(vis[u]==2)return false;
	if(vis[u]==1)return true;
	for(reg ll i=headd[u];i;i=nextt[i])
		if(to[i]!=fa&&a[to[i]]<a[u])
			if(dfs(to[i],u))
				return false;
	return true;
}
int main()
{
	n=read();
	for(reg ll i=1;i<=n;++i)
		a[i]=read();
	for(reg ll i=1;i<n;++i)
	{
		x=read();y=read();
		add(x,y);add(y,x);
	}
	for(reg ll i=1;i<=n;++i)
	{
		if(!dfs(i,0))
			vis[i]=2;
		else vis[i]=1;
	}
	for(reg ll i=1;i<=n;++i)
		if(vis[i]==2)
			printf("%lld ",i);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N,Y,x,y,z;
	cin>>N>>Y;
	/*if(Y%1000==0)
	{
		cout<<"-1 -1 -1";
		return 0;
	}*/
	for(x=0;x<=Y/10000;x++)
	for(y=0;y<=Y/5000;y++)
	{
		z=N-x-y;
		if(z>=0 && x*10000+y*5000+z*1000==Y)
		{
			cout<<x<<" "<<y<<" "<<z;
			return 0;
		}
	}
	cout<<"-1 -1 -1";
	return 0;
}

Measured memory_bytes: 256
#素因数分解
def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]
        
    N=abs(N)
    k=2
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1
    
    if N!=1:
        R.append([N,1])
    if not R:
        R.append([N,1])

    return R
#==================================
N,P=map(int,input().split())
A=Prime_Factorization(P)

X=1
for p,k in A:
    X*=p**(k//N)
print(X)


Measured memory_bytes: 62872
using System;
using System.Linq;

namespace B___Great_Ocean_View
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            var hills = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            int max = 0;
            int count = 0;

            foreach(int i in hills)
            {
                if(i >= max)
                {
                    count++;
                    max = i;
                }
            }

            Console.WriteLine(count);
        }
    }
}


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

int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> p(m);
    string s[m];
    bool acflag[n];
    int waval[n];

    rep(i,0,m-1){
        cin>>p[i]>>s[i];
    }
    rep(i,0,n-1){
        acflag[i] = false;
        waval[i] = 0;
    }
    ll ac = 0,wa = 0;
    rep(i,0,m-1){
        if(s[i]=="AC") acflag[p[i]-1] = true;
        if(s[i]=="WA"){
            if(!acflag[p[i]-1]){
                waval[p[i]-1]++;
            }
        }
    }
    rep(i,0,n-1){
        if(acflag[i]){
            ac++;
            wa += waval[i];
        }
    }
    cout<<ac<<" "<<wa<<endl;
    return 0;
}

Measured memory_bytes: 7040
# -*- coding: utf-8 -*-

def main():
    N, T = list(map(int, input().split()))
    paths = []
    for i in range(N):
        c, t = list(map(int, input().split()))
        paths.append((c, t))
    paths = sorted(paths, key=lambda x: x[0])

    for p in paths:
        if p[1] <= T:
            print(p[0])
            exit()
    print("TLE")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   pii;
typedef vector<int>     vi;
typedef long double     ld;
#define MOD         1000000007
#define pb          push_back
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        '\n'
#define PI          3.14159265359d
#define sz(x)       (int)x.size()
ll fact[100005];
int pos[100005];
long long int power(long long int a, long long int b)
{
    long long int x=1,y=a;
    while(b > 0)
    {
        if(b%2 == 1)
        {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD;
        b /= 2;
    }
    return x;
}
ll C(int n,int r)
{
    if(r>n)
        return 0;
    return (fact[n]*power((fact[r]*fact[n-r])%MOD,MOD-2))%MOD;
}
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,x,i,z;
    for(i=fact[0]=1;i<=100004;i++)
        fact[i]=(i*fact[i-1])%MOD;
    cin>>n;
    for(i=1;i<=n+1;i++)
    {
        cin>>x;
        if(pos[x])
            z=pos[x]+n-i;
        else
            pos[x]=i;
    }
    for(i=1;i<=n+1;i++)
        cout<<(C(n+1,i)-C(z,i-1)+MOD)%MOD<<endl;
    return 0;
}


Measured memory_bytes: 2432
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let it = stdin.lock().bytes().map(|c| c.unwrap() as char);
    let (fs, ft) = (|c: &char| c.is_whitespace(), |c: &char| !c.is_whitespace());
    let token = it.skip_while(fs).take_while(ft).collect::<String>();
    token.parse().ok().unwrap()
}
#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    f(std::io::BufWriter::new(out.lock()));
}
#[allow(unused_macros)]
macro_rules! debug {
    ($($var:expr),*) => { #[cfg(debug_assertions)] {
        $({ match &$var { v => eprint!("{}={:?} ", stringify!($var), v) } })*
        eprintln!();
    }};
}

fn main() {
    let n: i32 = input();

    let p6: Vec<i32> = (1..)
        .map(|i| i32::pow(6, i))
        .take_while(|&i| i <= n)
        .collect();
    let p9: Vec<i32> = (1..)
        .map(|i| i32::pow(9, i))
        .take_while(|&i| i <= n)
        .collect();

    let mut dp = vec![i32::max_value(); n as usize + 1];
    dp[0] = 0;
    for i in 1..n as usize + 1 {
        dp[i] = std::cmp::min(dp[i], dp[i - 1] + 1);
        for &j in &p6 {
            let j = j as usize;
            if i < j {
                break;
            }
            dp[i] = std::cmp::min(dp[i], dp[i - j] + 1);
        }
        for &j in &p9 {
            let j = j as usize;
            if i < j {
                break;
            }
            dp[i] = std::cmp::min(dp[i], dp[i - j] + 1);
        }
    }
    println!("{}", dp[n as usize]);
}


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

int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
    cin >> N;
    rep2(i,N+1) cin >> x[i] >> y[i];
    double sum = 0.0;
    vector<int> v(N);
    rep(i,N) v[i] = i + 1;
    do {
        rep(i,N-1) sum += dist(v[i], v[i+1]);
    } while(next_permutation(v.begin(), v.end()));
    int Factorial = 1;
    for(int i = 2; i<= N; i++) Factorial *= i;
    cout << fixed << setprecision(10) << sum / Factorial << endl;
    return;
}

int main() {
    solve();
    return 0;
}


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

const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x=0): x(x % mod) {}

    mint& operator += (const mint a) {
        if ((x += a.x) >= mod) {
            x -= mod;
        }
        return *this;
    }

    mint& operator -= (const mint a) {
        if ((x += mod - a.x) >= mod) {
            x -= mod;
        }
        return *this;
    }

    mint& operator *= (const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint& operator + (const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint& operator - (const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint& operator * (const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) {
            return 1;
        }

        mint a = pow(t >> 1);
        a *= a;

        if (t & 1) {
            a *= *this;
        }

        return a;
    }

    mint inv() const {
        return pow(mod - 2);
    }

    mint& operator /= (const mint a) {
        return (*this) *= a.inv();
    }

    mint operator / (const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main()
{
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N), sortA(N);
    rep (i, N) {
        cin >> A[i];
        sortA[i] = A[i];
    }
    sort(sortA.begin(), sortA.end());

    ll count = 0;
    ll countK = 0;

    rep (i,  N) {
        for (int j = i + 1; j < N; j++) {
            if (A[i] > A[j]) {
                count++;
            }
        }

        rep (j, N) {
            if (A[i] > sortA[j]) {
                countK++;
            }
        }
    }

    mint countKNeed = ((K - 1) * K) / 2;
    mint answer = ((count * K % mod)  + (countK * countKNeed.x % mod));
    cout << answer.x << endl;
}



Measured memory_bytes: 256
package main
 
import(
  "fmt"
)

func solver(a int, b int, sum int){
  a = a - sum
  if a < 0{
    b = b + a
    a = 0
  }
  if b < 0{
    b = 0
  }
  fmt.Println(a , b)
}
 
func main(){
  a := 0
  b := 0
  sum := 0
  fmt.Scan(&a)
  fmt.Scan(&b)
  fmt.Scan(&sum)
  solver(a,b,sum)
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
    int a;
    cin>>a;
    if(a==111)
        cout<<"3";
    if(a==000)
        cout<<"0";
    if(a==110)
        cout<<"2";
    if(a==11)
        cout<<"2";
    if(a==101)
        cout<<"2";
    if(a==100)
        cout<<"1";
    if(a==10)
        cout<<"1";
    if(a==001)
        cout<<"1";
	return 0;
}


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

using namespace std;

// #define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)



void solve()
{
    string S, T;
    cin>>S>>T;
    int m = sz(S) + 1;
    int n = sz(T) + 1;
    vector< vector<int> > dp(m, vector<int> (n));
    int i,j;
    for(i=0;i<m;i++)
        dp[i][0] = 0;
    for(i = 0; i<n ; i++)
        dp[0][i] = 0;
    for(i=1;i<m;i++)
        for(j=1;j<n;j++)
            dp[i][j] = max(dp[i-1][j], max(dp[i][j-1], dp[i-1][j-1] + (S[i-1] == T[j-1])));
    string reverseLCS;
    reverseLCS.clear();
    i = m-1; j = n-1;
    while(i>0 && j>0)
    {
        if(dp[i][j] == dp[i-1][j-1] + 1 && S[i-1] == T[j-1])
        {
            reverseLCS.push_back(S[i-1]);
            i--; j--;
        }
        else if(dp[i][j] == dp[i][j-1])
            j--;
        else i--;
    }
    for(i = reverseLCS.size() - 1; i>=0; i--)
        cout<<reverseLCS[i];
    cout<<endl;
}


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc;
	tc = 1;
    // cin>>tc;
    while(tc--)
        solve();

    return 0;
}


Measured memory_bytes: 37248
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#define mod 1000000007
#define pb push_back
using namespace std;
int pos[200009];
int main(){
	int n,malen;
	cin>>n;
	if(n==1){cout<<0<<endl;return 0;}
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		pos[x]=i;
	}
	int len=1;
	for(int i=1;i<=n-1;i++){
		if(pos[i]<pos[i+1])len++;
		else{len=1;}
		if(len>malen)malen=len;
	}
	cout<<n-malen<<endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

ll f(ll n)
{
    ll r=n%4;
    if(r==0) return n;
    else if(r==1) return 1;
    else if(r==2) return n+1;
    return 0;
}

int main(void)
{
    ll a,b; cin>>a>>b;
    cout<<(f(b)^f(a-1))<<endl;
    return 0;
}

Measured memory_bytes: 3640
N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans = 0
for i in range(N):
    if i == N-1:
        if x == A[i]:
            ans += 1
        break
    if x >= A[i]:
        x -= A[i]
        ans += 1
    else:
        break
print(ans)


Measured memory_bytes: 9124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Process {
    String name;
    int time;

    Process(String s, int n) {
        name = s;
        time = n;
    }
}

// I want to use Generics but General type array T[] cannot define.
// add(i, elm) of List<T> shift elements to right.
// So I do not use Generics here.
class Queue {
    int size;
    Process[] buf;
    int head = 0;
    int tail = 0;

    Queue(int n) {
        size = n + 1;
        buf = new Process[size];
    }

    boolean isEmpty() {
        return head == tail;
    }

    boolean isFull() {
        return head == (tail + 1) % size;
    }

    void enqueue(Process x) {
        if (isFull()) {
            throw new IndexOutOfBoundsException("Queue is full");
        }

        buf[tail] = x;
        if ((tail + 1) == size) {
            tail = 0;
        } else {
            tail++;
        }
    }

    Process dequeue() {
        if (isEmpty()) {
            throw new IndexOutOfBoundsException("Queue is empty");
        }

        Process x = buf[head];
        if ((head + 1) == size) {
            head = 0;
        } else {
            head++;
        }

        return x;
    }
}

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            String[] line = in.readLine().split(" ");
            int n = Integer.parseInt(line[0]);
            int q = Integer.parseInt(line[1]);

            Queue queue = new Queue(n);
            for (int i = 0; i < n; i++) {
                line = in.readLine().split(" ");
                String name = line[0];
                int time = Integer.parseInt(line[1]);
                queue.enqueue(new Process(name, time));
            }

            int currTime = 0;
            while (true) {
                if (queue.isEmpty()) break;

                Process p = queue.dequeue();
                if (p.time <= q) {
                    currTime += p.time;
                    System.out.println(p.name + " " + currTime);
                } else {
                    currTime += q;
                    p.time -= q;
                    queue.enqueue(p);
                }
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
// static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to;
    char cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

#include <iostream>
using namespace std;

const int MAX = 10000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];


int main(void){

  int N;
  cin >> N;
  int ans =0;
  for(int i = 1; i <= N; i+=2){
    int count = 0;
    for(int j = 1; j <=i; j++){
      if(i%j==0){
        count++;
      }
    }
    if(count==8)ans++;
  }

  cout << ans << endl;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

int main(){
  int a,b,ans;
  cin >> a >> b;
  ans = 0;
  if(a <= 5){
    cout << 0 << endl;
  }else if(a <= 12){
    cout << b/2 << endl;
  }else{
    cout << b << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    string op;
    while(1){
        cin >> a >> op >> b;
        if(op=="+"){
            cout << a+b << endl;
        } else if (op=="-"){
            cout << a-b << endl;
        } else if (op=="*"){
            cout << a*b << endl;
        } else if (op=="/") {
            cout << a/b << endl;
        } else {
            break;
        }
    }
}


Measured memory_bytes: 3148
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

int main() {
    FAST;
    ll k,n;
    cin>>n>>k;
    ll l=0;
    ll r=n;
    ll ladd=1;
    ll radd=n-1;
    ll ans=0;
    ll cnt=1;
    while(l<(n*(n+1))/2){
        if(cnt>=k)
        ans=(ans+r-l+1)%mod;
        l+=ladd;
        r+=radd;
        ladd++;
        radd--;
        cnt++;
    }
    ans++;
    cout<<ans;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

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

  
int main(){
 int n;
  cin >> n;
  vector<string> w(n);
  rep(i,n) cin >> w.at(i);
  bool a= true;
  bool b= true;
  rep(i,n){
    rep(j,i){
      if(w.at(i)==w.at(j)){
        a=false;
      }
    }
  }
  rep(i,n-1){
    int x;
    x=w.at(i).size();
    if(w.at(i).at(x-1)!=w.at(i+1).at(0)){
      b=false;
    }
  }
  if(a && b) cout <<"Yes" <<endl;
  else cout << "No" <<endl;
        

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

int mainsolve(){

	ll n,m;
	cin >> n >> m;

	vector<vector<ll>> to(n);

	rep(i,n-1){
		ll x,y;
		cin >> x >> y;
		--x; --y;
		to[x].push_back(y);
		to[y].push_back(x);
	}

	vector<vector<ll>> dp(n); // 要素数 2(n-1)
	rep(i,n) dp[i] = vector<ll>(to[i].size()); // vの子から始まる部分木（vの子自身を含む）

	// まず普通にdfsして子方向へのdpを埋める
	function<ll(ll,ll)> dfs = [&](ll v, ll p){
		ll res = 1;
		rep(i,to[v].size()){
			ll u = to[v][i];
			if(u != p){
				dp[v][i] = dfs(u,v); // uがrootである部分木
				(res *= (1 + dp[v][i]) % m) %= m;
			}
		}
		return res;
	};
	dfs(0,-1);

	/*
	vector<vector<ll>> cumL(n), cumR(n); // 左右からの累積積
	rep(i,n){
		cumL[i] = cumR[i] = vector<ll>(to[i].size()+1, 1);
		rep(j,to[i].size()){
			cumL[i][j+1] = (cumL[i][j] * ((1 + dp[i][j]) % m)) % m;
			cumR[i][j+1] = (cumR[i][n-j] * ((1 + dp[i][n-1-j]) % m)) % m;
		}
	}
	*/

	// 各dpSum[v]について、親方向へのノード1個分だけ足せていないので、それを足す
	/*
	function<void(ll,ll,ll)> dfs2 = [&](ll v, ll p, ll dpP){
		dpSum[v] *= (1 + dpP) % m;

		rep(i,to[v].size()){
			ll u = to[v][i];
			ll nextDpP = dpSum[v] / (1 + dp[v][i]); // 親vの部分木から子uの部分木の分だけ引く
			if(u != p) dfs2(u, v, nextDpP);
		}

	};
	*/
	vector<ll> ans(n);
	function<void(ll,ll,ll)> dfs2 = [&](ll v, ll p, ll dpP){

		ll deg = to[v].size();
  		rep(i,deg) if (to[v][i] == p) dp[v][i] = dpP;

		vector<ll> dpLeft(deg+1,1), dpRight(deg+1,1);
		rep(i,deg) dpLeft[i+1] = (dpLeft[i] * (1 + dp[v][i]) % m) % m;
		for (int i = deg-1; i >= 0; --i) dpRight[i] = (dpRight[i+1] * (1 + dp[v][i]) % m) % m;
		
		ans[v] = dpLeft[deg];

		rep(i,deg){
			ll u = to[v][i];
			if(u == p) continue;
			ll d = (dpLeft[i] * dpRight[i+1]) % m;
			dfs2(u,v,d);
		}
	};	
	dfs2(0,-1,1);

	rep(i,n) cout << ans[i] << endl;
	return 0;
}

int main(){

	return mainsolve();
}

Measured memory_bytes: 26752
#include <stdlib.h> 
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>

using namespace std; 

int main()
{
  int k;
  string s; 
  
  cin>>k;
  cin>>s;
  
  int tam = s.length();

  if(k < tam)
  {
  	s.resize(k);
  	s.append(3,'.');
  	cout<<s;
  }
  else cout<<s;
   
}


Measured memory_bytes: 3624
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    int n; cin >> n;
    vi v(n);
    for (auto &it : v) cin >> it;

    sort(v.begin(), v.end(), greater<int>());
    
    ll res = v[0];
    int ct = 2;
    int i=1;
    bool done = false;
    while (ct < n) {
        ct++;
        res += (ll)v[i];
        if (done) {
            i++;
        }
        done = !done;
    }

    cout << res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<int,P>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c/a*b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char s[11];
	int i,j,len=0,x=0,y=999;
	scanf("%s",s);
	len=strlen(s);
	for(i=0;i<len-2;i++){
		x=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
		x=753-x;
		if(0>x) x*=-1;
		if(y>x) y=x;
	}
	printf("%d\n",y);
	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;

int main() {
	int a, b;
	cin >> a >> b;
	int res = 0;
	if (a >= 13) {
		res = b;
	}
	else if (a >= 6) {
		res = b / 2;
	}
	else {
		res = 0;
	}
	pv(res)
	return(0);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int num;
    string S;
    string A[3] ={"Sunny","Cloudy","Rainy"};
    cin >> S;
    if (S==A[2]){
        cout << A[0];
    }
    else{
      for (int i=0; i<2; i++){
         if (S==A[i]){
            cout << A[i+1];
            break;
         }

        }
    }

    return 0;
}


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

int N; bool dp[100010];
string s,aux;

int main(){
    cin >> s;
    N=s.length();

    dp[N]=1;
    int i,j;
    for (i=N-1; i>=0; i--){
        aux="";
        for (j=0; j<7 && i+j<N; j++){
            aux+=s[i+j];
            if (aux=="dream" || aux=="dreamer" || aux=="erase" || aux=="eraser")
                dp[i]|=dp[i+j+1];
        }
    }

    if (dp[0]) cout << "YES\n";
    else cout << "NO\n";

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main() {
    int r, c, i, j, num[101][101], sum;
    scanf("%d%d", &r, &c);
    for (i = 0; i < r; i++) {
        num[i][c] = 0;
        for (j = 0; j < c; j++) {
            scanf("%d", &num[i][j]);
            num[i][c] += num[i][j];
        }
    }
    for (j = 0; j <= c; j++) {
        num[r][j] = 0;
        for (i = 0; i < r; i++) {
            num[r][j] += num[i][j];
        }
    }
    for (i = 0; i <= r; i++) {
        for (j = 0; j < c; j++) {
            printf("%d ", num[i][j]);
        }
        printf("%d\n", num[i][j]);
    }
    return 0;
}

Measured memory_bytes: 636
N = int(input())
lst = []
for i in range(1,12):
    if N <= 26 :
        lst.append(N % 26)
        break
    lst.append(N % 26)
    if N % 26 == 0:
        N = N // 26 - 1
    else:
        N = N // 26

chr = 'abcdefghijklmnopqrstuvwxyz'
res = ""
for j in lst:
    res = chr[j-1] + res
print(res)

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


int main()
{
	int N;
	cin >> N;
	vector<int> b(N);

	for (int i = 0; i < N; ++i) {
		cin >> b[i];
		--b[i];
	}

	vector<int> ans;

	bool flag = true;

	while (flag && b.size() > 0) {
		for (int i = b.size() - 1; i >= 0; --i) {
			if (b[i] == i) {
				ans.push_back(i);
				b.erase(b.begin() + i);
				break;
			}
			if (i == 0) {
				flag = false;
			}
		}
	}

	if (flag) {
		for (int i = ans.size() - 1; i >= 0; --i) {
			cout << ans[i] + 1 << endl;
		}
	}
	else {
		cout << "-1" << endl;
	}
}

Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

fn main() {
    input!(n: usize, x: usize, mut vs: [usize; n]);

    let mut ans = 0;
    if vs[0] > x {
        ans += vs[0] - x;
        vs[0] = x;
    }
    for i in 0..n - 1 {
        if vs[i] + vs[i + 1] > x {
            let diff = vs[i] + vs[i + 1] - x;
            vs[i + 1] -= diff;
            ans += diff;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
    // Your code here!
    var s = readLine()!!
    var t = readLine()!!
    var msg = "No"
    
    if(s == t.substring(0,s.length) && t.length == s.length + 1){
        msg = "Yes"
    }
    println(msg)
}


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

using namespace std;

int main()
{
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int cnt =0,cntb=1;
    rep(i,0,s.size())
    {
        switch(s[i]){
        case 'c':
            cout << "No" << endl;
            break;
        case 'a':
            if (cnt < a + b){
                cout << "Yes"  << endl;
                cnt +=1;
            }
            else cout << "No" << endl;;
            break;
        case 'b':
            if (cnt < a + b && cntb <= b){
                cout << "Yes"  <<endl;
                cnt += 1;

            }else cout << "No" << endl;
            cntb += 1;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3728
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;

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

    ll div = 1000000007;
    // vector<ll> ret = { 4, 3, 4, 4,
    //                     4, 4, 3, 4,
    //                     4, 3, 4, 4,
    //                     4, 4, 4, 4 };
    vector<ll> ret(64);
    vector<string> retstr(64);
    vector<string> strmap = {"A", "C", "G", "T"};
    vector<string> error = {"AGC" , "ACG", "GAC"};
    vector<string> error2 = {"AGC"};
    for(size_t i = 0; i < 64; i++)
    {
        retstr[i] = strmap[i/16] + strmap[i%16/4] + strmap[i%4];
        //if (retstr[i] != "AGC" && retstr[i] != "ACG" &&retstr[i] != "GAC")
        if (find(error.begin(), error.end(), retstr[i]) == error.end())
            ret[i] = 1;
        else
            ret[i] = 0;
    }
    vector<ll> ret_temp(64);
    ll matrix[64][64];
    for(size_t i = 0; i < 64; i++)
    {
        for(size_t j = 0; j < 64; j++)
        {
            if(retstr[i].substr(0,2) == retstr[j].substr(1,2)){
                string substr1 = retstr[j].substr(0,2) + retstr[i].substr(2,1);
                string substr2 = retstr[j].substr(0,1) + retstr[i].substr(1,2);
                if((find(error.begin(), error.end(), retstr[i]) != error.end()) ||
                (find(error2.begin(), error2.end(), substr1) != error2.end()) ||
                (find(error2.begin(), error2.end(), substr2) != error2.end()))
                    matrix[i][j] = 0;
                else
                    matrix[i][j] = 1;
            }
            else
                matrix[i][j] = 0;
        }
    }
    for(size_t i = 3; i < N; i++)
    {
        ret_temp = vector<ll>(64, 0);
        for(size_t j = 0; j < 64; j++)
        {
            for(size_t k = 0; k < 64; k++)
            {
                ret_temp[j] += (matrix[j][k] * ret[k]);
            }
        }
        for(size_t l = 0; l < 64; l++)
        {
            ret[l] = ret_temp[l] % div;
        }
    }

    ll ret_total=0;
    for(auto reti : ret){
        ret_total += reti % div;
    }
    ret_total %= div;
    cout << ret_total << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000;
template <typename T>
struct range_add_range_min{
	int N;
	vector<T> ST;
	vector<T> lazy;
	range_add_range_min(int n){
		N = 1;
		while (N < n){
			N *= 2;
		}
		ST = vector<T>(N * 2 - 1, 0);
		lazy = vector<T>(N * 2 - 1, 0);
	}
	range_add_range_min(vector<int> &A){
		int n = A.size();
		N = 1;
		while (N < n){
			N *= 2;
		}
		ST = vector<T>(N * 2 - 1, 0);
		lazy = vector<T>(N * 2 - 1, 0);
		for (int i = 0; i < n; i++){
			ST[N - 1 + i] = A[i];
		}
		for (int i = N - 2; i >= 0; i--){
			ST[i] = min(ST[i * 2 + 1], ST[i * 2 + 2]);
		}
	}
	void eval(int i){
		if (i < N - 1){
			lazy[i * 2 + 1] += lazy[i];
			lazy[i * 2 + 2] += lazy[i];
		}
		ST[i] += lazy[i];
		lazy[i] = 0;
	}
	void range_add(int L, int R, T x, int i, int l, int r){
		eval(i);
		if (R <= l || r <= L){
			return;
		} else if (L <= l && r <= R){
			lazy[i] += x;
			eval(i);
		} else {
			int m = (l + r) / 2;
			range_add(L, R, x, i * 2 + 1, l, m);
			range_add(L, R, x, i * 2 + 2, m, r);
			ST[i] = min(ST[i * 2 + 1], ST[i * 2 + 2]);
		}
	}
	void range_add(int L, int R, T x){
		range_add(L, R, x, 0, 0, N);
	}
	T range_min(int L, int R, int i, int l, int r){
		eval(i);
		if (R <= l || r <= L){
			return INF;
		} else if (L <= l && r <= R){
			return ST[i];
		} else {
			int m = (l + r) / 2;
			return min(range_min(L, R, i * 2 + 1, l, m), range_min(L, R, i * 2 + 2, m, r));
		}
	}
	T range_min(int L, int R){
		return range_min(L, R, 0, 0, N);
	}
};
int main(){
	int n, q;
  cin >> n >> q;
  range_add_range_min<long long> a(n);
  for (int i = 0; i < q; i++){
    int T;
    cin >> T;
    if (T == 0){
      int s, t, x;
      cin >> s >> t >> x;
      a.range_add(s, t + 1, x);
    }
    if (T == 1){
      int s, t;
      cin >> s >> t;
      cout << a.range_min(s, t + 1) << endl;
    }
  }
}


Measured memory_bytes: 7068
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int A[100010];
    rep(i, N) cin >> A[i];
    
    int sum[100010] = {};
    map<int, int> mp;
    rep(i, N) {
        sum[i + 1] = (sum[i] + A[i]) % M;
        mp[sum[i + 1]]++;
    }
    int ans = mp[0];
    int S = 0;  
    rep(i, N) {
        ans += mp[sum[i + 1]] - 1;
        mp[sum[i + 1]]--;
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 5760
#include <iostream>

using namespace std;

long long a[200010] = {};

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

	int mod = 1000000007;
	for (int i = 1; i <= n; i++) {
		a[i] = i;
		a[i] += a[i - 1];
		a[i] %= mod;
	}

	long long ans = 0;
	long long t;
	for (int i = k; i <= n; i++) {
		t = mod + a[n] - a[n - i] + 1;
		t += mod - a[i - 1];
		t %= mod;

		ans += t;
		ans %= mod;
	}
	ans++;
	ans %= mod;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
vector<ll> f(1e7+5);
void go(ll n) {
	for(ll i = 1; i <= n; i++) {
		for(ll j = i; j <= n; j+=i ) {
			f[j]++;
		}
	}
}
int main(){
	ll n;
	cin >> n;
	go(n);
	ll  res = 0;
	for(ll i = 1; i <= n; i++) {
		res += i * f[i];
	}
	cout << res << endl;
	return 0;
}





Measured memory_bytes: 81188
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void)
{

	char str[1200];		//英文
	char ch = 97;		//'a'の2進数
	int chCnt[26];			//該当する文字の数
	int i;
	
	for(ch = 97; ch < 97 + 26; ch++)
	{
	    
		chCnt[ch - 97] = 0;
	}

	//英文を入力する

	while(fgets(str, 1200, stdin))
	{
		ch = 97;
		do
		{
			i = 0;
			while(str[i] != 0)
			{
				if(isalpha(str[i]))
				{
					if(tolower(str[i]) == ch)
					{
						chCnt[ch - 97]++;
					}
				}
				i++;
			}
			ch++;
		} while (ch < 97 + 26);	//アルファベットの最後まで
	}
	
	for(ch = 97; ch < 97 + 26; ch++)
	{
	    
			printf("%c : %d\n", ch, chCnt[ch - 97]);
	}
	

	return 0;
}


Measured memory_bytes: 2064
#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>;

const int mod = 1000000007;

int main() {
    int N;
    cin >> N;
    ll total = 1, ex0or9 = 1, ex0and9 = 1;
    rep(i, N) total = (total * 10) % mod;
    rep(i, N) ex0or9 = (ex0or9 * 9) % mod;
    ex0or9 = ex0or9 * 2 % mod;
    rep(i, N) ex0and9 = (ex0and9 * 8) % mod;

    ll ans = total - ex0or9 + ex0and9;
    if (ans < 0) ans += mod;
    if (N == 1) ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 3672