akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	ll x = 0;
	for(int i=2;i<n;i++)
		x ^= a[i];
	ll s = a[0]+a[1];
	if(s < x || s%2 != x%2){
		cout<<"-1\n";
		return 0;
	}

	ll k = (s-x)/2;
	int MX = 45;
	ll powers[MX];
	powers[0] = 1;
	for(int i=1;i<MX;i++)
		powers[i] = powers[i-1]*2;

	vector<int> v(MX);
	int ok = 0;
	ll cur = 0;
	for(int i=0;i<MX;i++){
		if(x&powers[i]){
			if(k&powers[i]){
				ok = 1;
				break;
			}
			else{
				v[i] = 1;
			}
		}
		else{
			if(k&powers[i]){
				cur += powers[i];
				v[i] = 2;
			}
			else{
				v[i] = 0;
			}
		}
	}

	if(ok || cur > a[0]){
		cout<<"-1\n";
		return 0;
	}

	ok = 0;
	for(int i=MX-1;i>=0;i--){
		if(v[i] == 1){
			if(cur + powers[i] <= a[0])
				cur += powers[i];
		}
	}

	if(ok || cur == 0){
		cout<<"-1\n";
		return 0;
	}
	else
		cout<< a[0]-cur <<endl;
}

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

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

  if (n%2==1||s.substr(0,n/2)!=s.substr(n/2,n/2)) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}



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

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    int r=0,b=0;
    for (int i=0;i<s.size();i++){
        if(s[i]=='R') r++;
        else b++;
    }
    if(r>b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;

using namespace std;



int main() {

	int A, B, K;
	cin >> A >> B;

	if (A > 9 || B > 9)
		cout << -1 << endl;
	else
		cout << A * B << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
int main(){
  ll n,k;
  ll a,b;
  cin >> n >> k;
  if(k%2==0){
    a = n/k;
    b = n/(k/2)-a;
  }else{
    a = n/k;
    b = 0;
  }
  cout << modpow(a,3,0)+modpow(b,3,0) << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen

#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
bool tt[1300];
vector<P> student[10005];
struct LOG{
	int t, n, m, s;
};
	
int main()
{
//	cut here before submit 
//	freopen ("testcase.ALLR", "r", stdin );
	int N, M;
	while (scanf ("%d %d", &N, &M ), N, M ){
		rep (i, M ) student[i].clear();
		int r;
		scanf ("%d", &r );

		LOG log[r];
		rep (i, r ){
			int t, n, m, s;
			scanf ("%d %d %d %d", &t, &n, &m, &s );
			n--;m--;
			log[i].t = t, log[i].n = n, log[i].m = m, log[i].s = s;
		} // end rep

		rep (i, r ){
			if (log[i].s == 0 ) continue;
			int cn = log[i].n, cm = log[i].m;
			int st = log[i].t;
			for (int j = i+1; j < r; j++ ){
				if (log[j].n == cn && log[j].m == cm && log[j].s == 0 ){
					int et = log[j].t;
					student[cm].push_back (P (st, et ) );
					break;
				} // end if
			} // end for
		} // end rep

		int q;
		scanf ("%d", &q );
		vector<int> ans (q, 0 );

		rep (i, q ){
			int ts, te, m;
			scanf ("%d %d %d", &ts, &te, &m );
			m--;
			memset (tt, false, sizeof (tt ) );
			if (!student[m].empty() ){
				rep (j, student[m].size() ){
					for (int t = student[m][j].first; t < student[m][j].second; t++ ){
						tt[t] = true;
					} // end for
				} // end rep
			} // end if

			int res = 0;
			for (int t = ts; t < te; t++ ){
				if (tt[t] ) res++;
			} // end if
			ans[i] = res;
		} // end rep
		rep (i, q ){
			printf ("%d\n", ans[i] );
		} // end rep
			
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1492
#include <bits//stdc++.h>
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;
typedef long long ll;
 
int main(){
    ll n;
    cin >> n;
    ll run;
    run = pow(n,0.5);
    ll x = 0;
    for(ll i = run;i > 0;i--){
        if(n % i == 0){
            x = i;
            break;
        }
    }
    ll y;
    y = n / x;
    cout << x + y - 2 << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	//業務ロジック記載箇所
	nextReader = newScanner()

	a := nextInt()
	s := nextString()
	if a >= 3200 {
		fmt.Println(s)
	} else {
		fmt.Println("red")
	}
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std; 

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;

    if(a+b == c || b+c == a || a+c == b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}
/** atcoder **/


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll n;
		cin >> n;
		ll ans = 0;
		ll arr[n + 1];
		for (ll i = 1; i <= n; i++)
		{
			ll a;
			cin >> a;
			if (i % 2 != 0 && a % 2 != 0)
				ans++;

		}
		cout << ans << endl;
	}
	return 0;
}


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

int n,Count=0,minn=1e9,f[105];
char s[105];

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s[i];
        if(s[i]=='(')
            f[i]=f[i-1]+1;
        else
            f[i]=f[i-1]-1;
        minn=min(minn,f[i]);
    }
    int Count=0;
    while(minn+Count<0)
    {
        Count++;
        cout<<'(';
    }
    for(int i=1;i<=n;i++)
        cout<<s[i];
    for(int i=1;i<=f[n]+Count;i++)
        cout<<')';
}


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


int main(void)
{
	int w,n;

	cin >> w >> n;

	int d[31];
	for(int i = 0; i < 31; i++)
		d[i] = i;
	int a,b;

	while(n > 0){
		scanf("%d,%d", &a, &b);
		swap(d[a],d[b]);
		n--;
	}
	for(int i = 1; i <= w; i++)
		cout << d[i] << endl;


	return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>

int main() {
	int n = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		
		if (i % 3 == 0) {
			printf(" %d", i);
			continue;
		}
		
		int x = i;
		while (x) {
			if (x % 10 == 3) {
				printf(" %d", i);
				break;
			}

			x /= 10;
		}
	}

	printf("\n");
	return 0;
}

Measured memory_bytes: 1852
'use strict'
function main(inp) {
  inp = inp.trim().split(' ').map(n => Number(n));
  if (inp[1]===1) {
    console.log(0)
  } else if (inp[1]>inp[0]) {
    inp[1] -= inp[0]
    console.log(Math.ceil(inp[1] / (inp[0] - 1) + 1))
  } else {
    console.log(1)
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include<stdio.h>
int str_length(char[]);

int main(){
char p[100],s[100],p1[200];

gets(p);//scanf("%c \n %c",&s[],&p[]);
gets(s);//??????identifier??????????????????

int len=str_length(p),i,j,f=0;
for(i=0;i<len;i++){
p1[i]=p[i];
p1[i+len]=p[i];
}
p1[len+len]='\0';

for(i=0;i<len;i++){
	int cnt=0;
	for(j=0;j<str_length(s);j++){
	if(p1[i+j]!=s[j])break;
	cnt++;
	}
	if(cnt==str_length(s)){
	f=1;
	break;
	}
}

if(f==0)printf("No\n");
if(f==1)printf("Yes\n");

return 0;
}

int str_length(char str[]){
int i;
for(i=0;str[i]!='\0';i++);
return i;
}

Measured memory_bytes: 524
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <math.h>
using namespace std;
int main(){
  long long int l,r,i,j,minimo=7373;
  cin>>l>>r;
  if(r-l>=2019){
    cout << "0"<<endl;
  }else if ((r%2019)<(l%2019)||l%2019==0){
  	cout << "0"<<endl;
  }else{
    for(i=l%2019;i<=r%2019;i++){
      for(j=i+1;j<=r%2019;j++){
        minimo=min((i*j)%2019,minimo);
      }
    }
   cout << minimo<<endl;
    
    
    
  }
  
}

Measured memory_bytes: 256
open Core
open Stdio

let read_line () = In_channel.(input_line_exn stdin)

let money_inf = 50 * 50
let dist_inf = Int64.(10L ** 15L)
type edge_t = { cod : int; unchin : int; jikan : Int64.t }

let [n;m;s] = read_line () |> String.split ~on:' ' |> List.map ~f:Int.of_string
let s = min money_inf s

let edges = Array.create ~len:n []

let () =
    for i = 1 to m do
        let [u; v; un; ji] = read_line () |> String.split ~on:' ' in
        let u = Int.of_string u - 1 in
        let v = Int.of_string v - 1 in
        let un = Int.of_string un in
        let ji = Int64.of_string ji in
        edges.(u) <- { cod = v; unchin = un; jikan = ji } :: edges.(u);
        edges.(v) <- { cod = u; unchin = un; jikan = ji } :: edges.(v)
    done

let maisu_jikan_s = Array.init n ~f:(fun _ ->
    let x,y = read_line () |> String.lsplit2_exn ~on:' ' in
    let x = min money_inf (Int.of_string x) in
    let y = Int64.of_string y in
    (x,y))

let used = Array.make_matrix ~dimx:n ~dimy:(money_inf+1) false
let res = Array.make_matrix ~dimx:n ~dimy:(money_inf+1) dist_inf

let rec dijk mins = match Set.min_elt mins with
    | None -> ()
    | Some ((dist, v, money) as tup) ->
        let mins = Set.remove mins tup in
        if used.(v).(money) then dijk mins else begin
        used.(v).(money) <- true;
        res.(v).(money) <- Int64.min res.(v).(money) dist;
        (* printf "%Ld (%d, %d)\n" res.(v).(money) v money; *)
        (* 銀貨に交換 *)
        let mins = let money = money + fst maisu_jikan_s.(v) in
            let dist = Int64.(dist + snd maisu_jikan_s.(v)) in
            if money <= money_inf && not used.(v).(money) (* && Int64.(dist < res.(v).(money)) *)
            then Set.add mins (dist, v, money) 
            else mins in
        (* 別の都市に移動 *)
        let mins = List.fold edges.(v) ~init:mins ~f:(fun mins ch ->
            let money = money - ch.unchin in
            let dist = Int64.(dist + ch.jikan) in
            let v = ch.cod in
            if money >= 0 && not used.(v).(money) (* && Int64.(dist < res.(v).(money)) *)
            then Set.add mins (dist, v, money)
            else mins) in
        dijk mins
        end

module DijkData : (Comparator.S with type t = int64 * int * int) = struct
    type t = int64 * int * int
    include Comparator.Make (struct
        type t = int64 * int * int
        let compare = Tuple3.compare ~cmp1:Int64.compare ~cmp2:compare ~cmp3:compare
        let sexp_of_t = Tuple3.sexp_of_t Int64.sexp_of_t Int.sexp_of_t Int.sexp_of_t
    end)
end

let () = dijk (Set.singleton (module DijkData) (0L, 0, s));
(* let () = dijk (Map.singleton (module Int64) 0L (0, s)); *)
    for v = 1 to n - 1 do
        printf "%Ld\n" @@ Option.value_exn (Array.min_elt res.(v) ~compare:Int64.compare)
    done


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    string s;
    cin >> s;
    rep(i, 4) cout << s.at(i);
    cout << " ";
    rep(i, 8) cout << s.at(i + 4);
    cout << endl;
    // end

    return 0;
}


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

using namespace std;

int main(void){

	string data("qwertyuioplkjhgfdsazxcvbnm");
	char inp;
	int num[27]={0};

	while(scanf("%c",&inp)!=EOF){
		if(data.find(inp)!=-1) num[inp-'a']++;
		else num[inp-'A']++;
	}

	
	for(int i=0;i<26;i++){
		cout<<(char)('a'+i)<<" : "<<num[i]<<endl;
	}

	return 0;
}

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

int main(){
  string s,t; cin >> s >> t;
  int a,b; cin >> a >> b;
  string u; cin >> u;
  if(s==u)cout << a-1 << ' ' << b << endl;
  else if(t==u)cout << a << ' ' << b-1 << endl;
  else cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<set>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   map<ll, int> log;
   int a;
   for (int i = 0; i < N; i++) {
      cin >> a;
      log[a]++;
   }
   vector<ll> tmp;
   ll MAX = 0;
   bool is4 = false;
   for (auto it = log.begin(); it != log.end(); it++) {
      if (it->second < 2) continue;
      tmp.push_back(it->first);
      if (MAX < it->first) {
         MAX = it->first;
         is4 = it->second >= 4 ? true : false;
      }
      
   }
   sort(tmp.rbegin(), tmp.rend());
   if (tmp.size() < 2) cout << 0 << endl;
   else if (is4) {
      ll ans = MAX * MAX;
      cout << ans << endl;
   }
   else {
      ll ans = tmp[0] * tmp[1];
      cout << ans << endl;
   }
   return 0;
}


Measured memory_bytes: 6528
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String[] str2 = new String[3];
        str2 = str.split("");
        Arrays.sort(str2);
        if( !(str2[1].equals(str2[2])) && str2[0].equals(str2[1]) && str2[2].equals(str2[3])) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35564
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
typedef long double LD;
typedef pair <int,int> pii;
typedef pair <int,LL> piL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=300005,mod=998244353;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
int Fac[N],Inv[N];
void prework(){
	int n=N-1;
	for (int i=Fac[0]=1;i<=n;i++)
		Fac[i]=(LL)Fac[i-1]*i%mod;
	Inv[n]=Pow(Fac[n],mod-2);
	Fod(i,n,1)
		Inv[i-1]=(LL)Inv[i]*i%mod;
}
int C(int n,int m){
	if (m<0||m>n)
		return 0;
	return (LL)Fac[n]*Inv[m]%mod*Inv[n-m]%mod;
}
int n,a,b;
LL k;
int main(){
	prework();
	n=read(),a=read(),b=read(),k=read();
	int ans=0;
	For(i,0,n){
		if ((k-(LL)a*i)%b)
			continue;
		LL j=(k-(LL)a*i)/b;
		if (j<0||j>n)
			continue;
		Add(ans,(LL)C(n,i)*C(n,j)%mod);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main()
{
    int n,ara[10],i,sum=0,d;

    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        scanf("%d",&ara[i]);
    }

    int max = ara[0];

    for(i=1;i<n;i++)
    {
        if(ara[i]>max)
            max = ara[i];
    }

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

    d = sum-max;

    if(d>max) printf("Yes\n");

    else if(d<=max) printf("No\n");

    return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
void chmax(T1 &a, const T2 &b) {
  if(a < b) a = b;
}

template <typename T1, typename T2>
void chmin(T1 &a, const T2 &b) {
  if(a > b) a = b;
}

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i != (int)(s.size())-1) cout << " ";
  }
  cout << "\n";
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

  int n; cin >> n;
  string s, t; cin >> s >> t;
  REP(i, n) {
    cout << s[i] << t[i];
  }
  cout << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    cout << "Christmas" << ' ';
    if (D == 24) cout << "Eve" << endl;
    if (D == 23) cout << "Eve Eve" << endl;
    if (D == 22) cout << "Eve Eve Eve" << endl;

    return 0;
}




Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

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


        long[] A = new long[X];
        long[] B = new long[Y];
        long[] C = new long[Z];
        for (int i = 0; i < X; i++) {
            A[i] = sc.nextLong();
        }
        for (int i = 0; i < Y; i++) {
            B[i] = sc.nextLong();
        }
        for (int i = 0; i < Z; i++) {
            C[i] = sc.nextLong();
        }

        Arrays.sort(A);
        Arrays.sort(B);
        Arrays.sort(C);

        // ABの組み合わせの上位Kを取り出し
        // それとCの組み合わせを考える
        // O(XY) -> O(KZ)
        long[] AB = new long[X * Y];
        int index = 0;
        for (int x = 0; x < X; x++) {
            for (int y = 0; y < Y; y++) {
                AB[index++] = A[x] + B[y];
            }
        }

        Arrays.sort(AB);
        long[] ABC = new long[Math.min(3000, X * Y) * Z];
        index = 0;

        loop:
        for (int ab = AB.length - 1; ab >= AB.length - Math.min(3000, X * Y); ab--) {
            for (int z = 0; z < Z; z++) {
                ABC[index++] = AB[ab] + C[z];
            }
        }

        Arrays.sort(ABC);
        for (int k = ABC.length - 1; k > ABC.length - K - 1; k--) {
            out.println(ABC[k]);
        }
    }
}

Measured memory_bytes: 62756
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,n,m,i,j,k,x,y,u=0;
    cin>>n>>k;
    set<ll>s;
    set<ll>::iterator it,it1;
    for(i=0;i<k;i++)
    {
        cin>>y;
        for(j=0;j<y;j++)
        {
            cin>>x;
            s.insert(x);
        }
    }
    cout<<n-s.size();
}


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

int main() {
  int H , W;
  cin >> H >> W;
  for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;
  
  for(int j = 0; j < H; j++){
    string s;
    cin >> s;
    cout << "#" << s << "#" << endl;
  }
  
  for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
    cout << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

vector<vector<int>> v;

int sol(vector<int> &s){
  int x = 0;
  rep(i,4){
    x=v[x][s[i]];
  }
  return x;
}

bool isValid(vector<int> &s){
  int x = 0;
  rep(i,5){
    x = v[x][s[i]];
  }
  if(x) return false;
  else return true;
}

int main(){
  int n = 10;
  v=vector<vector<int>>(n,vector<int>(n));
  rep(i,n) rep(j,n) cin >> v[i][j];
  int ans=0;
  rep(i,10000){
    int x = i;
    vector<int> s(5);
    per(j,4){
      s[j]=x%10;
      x/=10;
    }
    s[4]=sol(s);
    bool ok = true;
    vector<int> tmp;
    rep(j,5){
      rep(k,10){
        if(k==s[j]) continue;
        tmp=s;
        tmp[j]=k;
        if(isValid(tmp)) ok=false;
      }
    }
    rep(j,4){
      if(s[j]==s[j+1]) continue;
      tmp=s;
      swap(tmp[j],tmp[j+1]);
      if(isValid(tmp)) ok=false;
    }
    if(!ok) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3144
s = input()

for i in range(len(s)-1):
    if s[i] == s[i+1]:
        print(i+1, i+2)
        exit()

for i in range(len(s)-2):
    if s[i] == s[i+2]:
        print(i+1, i+3)
        exit()

print(-1, -1)


Measured memory_bytes: 3188
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    H, W = map(int, input().split())
    field = []

    white = 0
    for _ in range(H):
        line = input()
        field.append(line)
        white += line.count(".")

    cost = [[INF] * W for _ in range(H)]
    cost[0][0] = 1
    q = deque()
    q.append((0, 0))
    while len(q) != 0:
        y, x = q.popleft()

        for i in range(4):
            ny, nx = y + dy4[i], x + dx4[i]

            if inside(ny, nx, H, W) and cost[ny][nx] == INF and field[ny][nx] == ".":
                cost[ny][nx] = cost[y][x] + 1
                q.append((ny, nx))

    if cost[-1][-1] == INF:
        print(-1)
    else:
        print(white - cost[-1][-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
import math
input_a= input().split(" ")
X=int(input_a[0])
N=int(input_a[1])
dis=X+3
dis2=100
if N!=0:
  array= input().split(" ")
else:
  array=[0,0]

num=X
num2=-100
for i in range(N+1):

  
  if str(num) not in array:
    dis=abs(X-num)
    num2=X-dis
    num1=num
    if str(num2) not in array:
    	numa=min([num,num2])
    else:
      numa=num1
    break
  num=num+1
    

num=X
i=0
for i in range(dis):
  
  if str(num) not in array:
    
    dis2=abs(X-num)
    num3=X+dis2

    if str(num3) not in array:
    	numb=min([num,num3])
    else:
      numb=num
      break
  num=num-1

if dis<dis2:
  print(numa)
elif dis==dis2:
  print(numb)
else:
  print(numb)

Measured memory_bytes: 9172
#include<iostream>
#include<string>

using namespace std;

int main()
{
  long long int n,result = 0;
  cin >> n;
  
  for(int i = 1; i < (n+1); i++)
  {
    if(i % 15 == 0)
    {
      continue;
    }
    else if(i % 3 == 0)
    {
      continue;
    }
    else if(i % 5 == 0)
    {
      continue;
    }
    else
    {
      result += i;
    }
  }
  
  cout << result;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int w,h;
vvll a(50,vll(50));

void dfs(int x,int y){
     a.at(x).at(y)=0;
     rep2(dx,-1,2){
       rep2(dy,-1,2){
         int  nx=x+dx;
         int  ny=y+dy;
           if(0<=nx&&nx<h&&0<=ny&&ny<w){
                if(a.at(nx).at(ny)==1){
                    dfs(nx,ny) ;         
                           }
                       }
                   }
               }                                  
}


int main() {
   while(1){
   cin>>w>>h;
   if(w==0&&h==0)break;
   else{
   rep(i,h){
       rep(j,w)cin>>a.at(i).at(j);
   }
  
   int ans=0;
   rep(i,h){
       rep(j,w){
           if(a.at(i).at(j)==1){
               
               
               dfs(i,j);
               ans++;
               
           }
       }
   }
   
  
   cout<<ans<<endl;
   }
   }
    
}



Measured memory_bytes: 3264
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long m = sc.nextInt();
		long count;
		if (n == 1 && m == 1) {
			count = 1;
		} else if (n == 1 || m == 1) {
			count = n * m - 2;
		} else {
			count = (n - 2) * (m - 2);
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21588
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
        int H = sc.nextInt();
        int W = sc.nextInt();
        if ( H == 0 && W == 0 ) break;
        for ( int i = 0; i < H; i++ ){
            for ( int j = 0; j < W; j++ ){
                System.out.print("#");		       
            }
        System.out.println();		       
        }
        System.out.println();
    }
}
}



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

int main() {
	int k, n, sum = 0;
	cin >> k >> n;
	vector<int> v(n), d(n, 0);
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	for (int i = 1; i < n; i++)
	{
		d[i] = v[i] - v[i - 1];
		sum += d[i];
	}
	d[0] = k + v[0] - v[n - 1];
	sum += d[0];
	cout << sum - *max_element(d.begin(), d.end()) << endl;
}


Measured memory_bytes: 1792
sa = input()
sb = input()
sc = input()
t = "a"
r = ""
while True:
    if t == "a":
        if len(sa) == 0:
            r = "A"
            break
        t = sa[0]
        sa = sa[1:]
    elif t == "b":
        if len(sb) == 0:
            r = "B"
            break
        t = sb[0]
        sb = sb[1:]
    elif t == "c":
        if len(sc) == 0:
            r = "C"
            break
        t = sc[0]
        sc = sc[1:]
print(r)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    vector<int> a(5,0);
    for(int i=0;i<5;i++) cin>>a[i];
    for(int i=0;i<5;i++){
        if(a[i]==0)
            cout<<i+1<<"\n";
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    int t;
    // cin >> t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

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

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

const int mod = 1e9 + 7;

void solve(ll N, vector<ll> x) {
  int c = 0;
  ll res = 1;
  for (ll i: x) {
    if (i <= c * 2) { res = (res * (c + 1)) % mod; }
    else ++c;
  }
  while (c > 0) {
    res = (res * c) % mod;
    --c;
  }
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> x(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &x[i]);
	}
	solve(N, x);
	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
int n, m, field[11][11], si, sj, num;

int dfs(int x, int y){
  int ans = 0;
  if(num == 0){
    if(x == si || y == sj)return 1;
    else return 0;
  }
  field[x][y] = 0;
  for(int i = x + 1;i < m;i++){
    if(field[i][y] == 1){
      num--;
      ans += dfs(i, y);
      num++;
      break;
    }
  } 
  for(int i = x - 1;i >= 0;i--){
    if(field[i][y] == 1){
      num--;
      ans += dfs(i, y);
      num++;
      break;
    }
  } 
  for(int i = y + 1;i < n;i++){
    if(field[x][i] == 1){
      num--;
      ans += dfs(x, i);
      num++;
      break;
    }
  } 
  for(int i = y - 1;i >= 0;i--){
    if(field[x][i] == 1){
      num--;
      ans += dfs(x, i);
      num++;
      break;
    }
  }  
  field[x][y] = 1;
  return ans;
}

int main(){
  while(1){
    scanf("%d%d", &n, &m);
    if(n == 0 && m == 0)return 0;
    memset(field, 0, sizeof(field));
    num = 0;
    for(int i = 0;i < m;i++){
      for(int j = 0;j < n;j++){
	scanf("%d", &field[i][j]);
	if(field[i][j] == 2){
	  si = i;
	  sj = j;
	}
	else num += field[i][j];
      }
    }
    printf("%d\n", dfs(si, sj));
  }
}

Measured memory_bytes: 1032
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    i = int(n**(1/2))
    while n % i != 0:
        i -= 1
    print(len(str(n//i)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  Int a,b,c;
  cin>>a>>b>>c;
  if(a>b) swap(a,b);
  cout<<(a<=c&&c<=b?"Yes":"No")<<endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 1e6;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);

    int n, m;
    cin >> n >> m; 

    vll dp(m + 1);
    for (int i = 0; i < n; i++) {
        vll dp_ = dp;
        ll w, v;
        cin >> w >> v;
        dp_[w] = max(dp[w], v);
        for (int i = 1; w + i <= m; i++) {
            if (dp[i])
                dp_[i + w] = max(dp_[i + w], dp[i] + v);
        }
        swap(dp, dp_);
    }
    cout << *max_element(dp.begin(), dp.end()) << '\n';
}

Measured memory_bytes: 1816
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 102000;
int n,a[N],res,k,f[N];Vi e[N];
void dfs(int u){
	rep(i,0,SZ(e[u])-1)dfs(e[u][i]),umax(f[u],f[e[u][i]]);
	f[u]++;if(f[u]==k&&u>1&&a[u]!=1)res++,f[u]=0;
}
int main() {
	read(n);read(k);rep(i,1,n)read(a[i]);
	if(a[1]!=1)res++,a[1]=1;
	rep(i,2,n)e[a[i]].pb(i);
	dfs(1);cout<<res;
	return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

int64_t arc071d()
{
  int64_t n;
  cin >> n;
  const int64_t mod = 1000000007;

  vector<int64_t> out(n + 1);
  out[0] = 1;
  out[1] = n;
  int64_t acc = n - 1;

  for(size_t i = 2; i < out.size(); ++ i)
  {
    // '1', ???
    out[i] = out[i - 1];
    // '{2, ..., n}', '{2, ..., n}',
    out[i] += (n - 1) * (n - 1) % mod;
    out[i] %= mod;
    // '{2, ..., n}', 1, 1, ..., 1, ???
    out[i] += acc;
    out[i] %= mod;

    acc += (out[i - 2] + mod - 1) % mod;
    acc %= mod;
  }

  return (out.back() % mod + mod) % mod;
}

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << arc071d();

  return EXIT_SUCCESS;
}



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

#define fi first
#define se second
#define int long long
#define all(a) a.begin(),a.end()
string s1,s2;
int pd[3010][3010];

void mmax(int &a,int b){
	a = max(a,b);
}

int32_t main(){
    cin >> s1 >> s2;
    int sz1=(int)s1.size(),sz2=(int)s2.size();
	for(int i=0;i<=sz1;i++)
		for(int j=0;j<=sz2;j++){ 
			if(i) mmax(pd[i][j],pd[i-1][j]);
			if(j) mmax(pd[i][j],pd[i][j-1]);
			if(i<sz1 and j<sz2)
				if(s1[i]==s2[j])
					mmax(pd[i+1][j+1],pd[i][j]+1);
		}
	/*for(int i=0;i<=sz1;i++){
		for(int j=0;j<=sz2;j++)
			cout << pd[i][j] << " ";
		cout << '\n';		
	}*/
	string out ="";
	int i=sz1,j=sz2,p=pd[sz1][sz2];
	while(p--){
		while(pd[i][j]==pd[i-1][j])
			i--;
		while(pd[i][j]==pd[i][j-1])
			j--;
		i--,j--;
		out+=s1[i];
	}
	reverse(all(out));
	cout << out << '\n';
}

Measured memory_bytes: 70784
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define MOD 1000000007
#define MX 200005

using namespace std;

template <typename T> void read(T& x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

int n0, n;
int src[MX];
int seq[MX];
int pre[MX];
int app[MX];
int sum[MX];
int f[MX];

int main()
{
	read(n0);
	for(int i=1; i<=n0; i++) read(src[i]);
	for(int i=1; i<=n0; i++)
		if(seq[n] != src[i])
			seq[++n] = src[i];
	f[0] = 1;
	for(int i=1; i<=n; i++)
	{
		pre[i] = app[seq[i]];
		app[seq[i]] = i;
	}
	for(int i=1; i<=n; i++)
	{
		sum[seq[i]] = (sum[seq[i]] + f[i-1]) % MOD;
		f[i] = sum[seq[i]] % MOD;
	}
	printf("%d\n", f[n]);
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<ll, int> P;

int n, w, s, e;

int main(){
	ll a, b, c; cin >> a >> b >> c;
	if(a*b*c%2) cout << min(a*b, min(b*c, c*a)) << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
def insertionSort(lst, n):
    for i in range(1, n):
        v = lst[i]
        j = i - 1
        while j >= 0 and lst[j] > v:
            lst[j+1] = lst[j]
            j = j - 1
        lst[j+1] = v
        print(" ".join([str(n) for n in lst]))


if __name__ == "__main__":
    n = int(input())
    lst = [int(n) for n in input().split()]
    print(" ".join([str(n) for n in lst]))
    insertionSort(lst, n)

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

int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    for(int i=0;i<min(s.size(),t.size());i++){
        
        if(s[i] < t[i]){
            cout << "Yes" << endl;
            return 0;
        }
        else if(s[i] == t[i])continue;
        else{
             cout << "No" <<endl;
             return 0;
             }
    }
    if(s.size() < t.size())cout << "Yes" << endl;
    else cout <<"No" <<endl;
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(string, S);
    ll N = S.size();
    vi A(N + 1);
    ll k = 1;
    REP(i, N)
    {
        A[i + 1] = (A[i] + k * (S[N - i - 1] - '0')) % 2019;
        k = (10 * k) % 2019;
    }
    vi dp(2019);
    FOR(a, A)
    {
        ++dp[a];
    }
    // DUMP(dp);
    ll ans = 0;
    REP(i, 2019)
    {
        // if (dp[i] > 0)
        // {
        //     DUMP(i);
        //     DUMP(dp[i]);
        // }
        ans += (dp[i] * (dp[i] - 1)) / 2;
    }
    OUT(ans);
}


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

int main()
{
  int N, max = 1;
  string str;
  vector<string> vec;

  cin >> N;
  map<string, int> mp;
  for (int i = 0; i < N; i++)
  {
    cin >> str;
    auto itr = mp.find(str);
    if (itr != mp.end())
    {
      mp[str]++;
      if (max < mp[str])
      {
        max = mp[str];
      }
    }
    else
    {
      mp[str] = 1;
    }
  }
  for (auto itr = mp.begin(); itr != mp.end(); ++itr)
  {
    if (itr->second == max) {
      vec.push_back(itr->first);
    }
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 26868
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll h,w,k,cnt=1;
  bool ex,fir;
  cin >> h >> w >> k;
  string s[h];
  ll d[h][w];
  bool is_le[h];
  fill(d[0],d[h],0);
  fill(is_le,is_le+h,false);
  for(int i=0;i<h;i++){
    cin >> s[i];
  }
  for(int i=0;i<h;i++){
    ex = false;
    for(int j=0;j<w;j++){
      if(s[i][j]=='#'){
        ex = true;
        break;
      }
    }
    if(ex){
      is_le[i]=true;
      fir=true;
      for(int j=0;j<w;j++){
        if(s[i][j]=='#'){
          if(!fir){
            cnt++;
          }else{
            fir=false;
          }
        }
        d[i][j]=cnt;
      }
      cnt++;
    }
  }
  for(int i=0;i<h;i++){
    if(is_le[i]==false){
      ll ind=-1;
      for(int j=i+1;j<h;j++){
        if(is_le[j]){
          ind=j;
          break;
        }
      }
      if(ind==-1){
        for(int j=i-1;j>=0;j--){
          if(is_le[j]){
            ind=j;
            break;
          }
        }
      }
      for(int j=0;j<w;j++){
        d[i][j] = d[ind][j];
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout << d[i][j]<<" ";
    }
    cout << endl;
  }
}


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

count = 0
def dfs(now, conb):
    global count
    if '3' in conb and '5' in conb and '7' in conb and n >= int(conb):
        count += 1
    if now < 10:
        for i in ['3', '5', '7']:
            dfs(now + 1, conb + i)

dfs(0, '0')
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a;
  cin >> a;
  vector<int> b(a);
  vector<int> c(a);
  for(int i = 0;i < a;i++){
    cin >> b.at(i);}
  for(int i = 0;i < a;i++){
    cin >> c.at(i);}
  int g = 0;
  for(int i = 0;i < a;i++){
    g += max(0,b.at(i)-c.at(i));
  }
  cout << g << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int n,cap;
   cin>>n>>cap;
   //cout<<n<<cap<<endl;
   long long int w[n],v[n];
   long long int i,j;
   for(i=0;i<n;i++)
   {cin>>w[i];cin>>v[i];}
  
   long long int dp[n+1][cap+1];
   
   
   for(i=0;i<=n;i++)
   {
       for(j=0;j<=cap;j++)
       {
           if(i==0||j==0)
           dp[i][j]=0;
           else if(j<w[i-1])
           dp[i][j]=dp[i-1][j];
         
           else 
            dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
           // cout<<dp[i][j]<<" ";
       }
      // cout<<endl;
   }cout<<dp[n][cap];
}

Measured memory_bytes: 79104
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{   ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long t,n,m,x,c,k;
    int a[5];
    for(int i=0;i<5;i++)
    {
        cin >> a[i] ;
    }
    for(int i=0;i<5;i++)
    {
        if(a[i]==0)
        {
            cout << i+1 <<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
import sys

def main():
    """ MAIN """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())

    D = {}
    for i in cmds:
        if i[0] == "i":
            D[i[7:]] = 1
        elif i[0] == "f":
            if i[5:] in D:
                print("yes")
            else:
                print("no")

if __name__ == '__main__':
    main()

Measured memory_bytes: 137872