akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
int main(){
    int n;
    cin>>n;
    vi a(n),b(n);
    rep(i,n){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b.begin(),b.end());
    rep(i,n){
        if(a[i]==b[n-1])cout<<b[n-2];
        else cout<<b[n-1];
        cout<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3200
# -*- coding: utf-8 -*-
# D

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
from itertools import combinations
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = int(input())
if n == 1:
    print('a')
    sys.exit()


def dfs(s):
    if len(s) == n:
        print(''.join([chr(s + ord('a')) for s in s]))
    else:
        for i in range(len(set(list(s))) + 1):
            dfs(s + [i])
dfs([])


Measured memory_bytes: 58328
def linear_search(arr, key):
    idx = 0
    while arr[idx] != key:
        idx += 1

    if idx == len(arr) - 1:
        return False

    return True


n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

s.append(None)
cnt = 0
for i in range(q):
    s[n] = t[i]
    if linear_search(s, t[i]):
        cnt += 1

print(cnt)



Measured memory_bytes: 6548
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

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

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

// ll gcd(int a,int b){return b?gcd(b,a%b):a;}

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}


int main(){
	FAST;

	ll A, B;

	cin >> A >> B;

	ll C = gcd(A,B);

	ll ans = 1;

	for(ll i=2; i*i<=C; i++) {
		if(C%i==0) {
			ans++;
			while(C%i==0) C/=i;
		}
	}
	if(C!=1) ans++;

	cout << ans << LF;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N; cin >> N;
  vector<ll> p(N);
  for(int i=0; i<N; i++) cin >> p[i];
  
  vector<ll> v(N);
  iota(v.begin(), v.end(), 0LL);
  sort(v.begin(), v.end(), [&](int i, int j){return p[i]>p[j];});
  
  multiset<ll> st;
  st.insert(-1); st.insert(-1);
  st.insert(N); st.insert(N);
  ll wi, xi, yi, zi, ans;
  ans = 0;
  for(auto i: v){
    auto itr = st.lower_bound(i);
    yi = *itr;
    itr++;
    zi = *itr;
    itr--; itr--;
    xi = *itr;
    itr--;
    wi = *itr;
    ans += p[i] * (xi-wi) * (yi-i);
    ans += p[i] * (i-xi) * (zi-yi);
    st.insert(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
 
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const ll CFMOD = 998244353;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
 
#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define sz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define PB push_back
#define PF push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,n,m) for(int i=(n);i<(m);i++)
#define vec vector
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve(){
    int n;
    
    cin >> n;
    vec<int> v(n), dp(n);

    rep(i,n)    cin >> v[i];
    dp[0] = 0;
    dp[1] = abs(v[1] - v[0]);
    
    REP(i,2,n)
        dp[i] = min(dp[i-2] + abs(v[i-2] - v[i]), dp[i-1] + abs(v[i-1] - v[i]));
    cout << dp[n-1] << '\n';
    
    
}
 
int main(){
    int t = 1;
    
    while(t--){
        solve();
    }
}


Measured memory_bytes: 1024
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[])
    {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt();
        long mod=1000000007;
        while(t-->0)
        {
          int n=sc.nextInt(),ans=0;
          if(n>=400 && n<=599) ans=8;
          else if(n>=600 && n<=799) ans=7;
          else if(n>=800 && n<=999) ans=6;
          else if(n>=1000 && n<=1199) ans=5;
          else if(n>=1200 && n<=1399) ans=4;
          else if(n>=1400 && n<=1599) ans=3;
          else if(n>=1600 && n<=1799) ans=2;
          else if(n>=1800 && n<=1999) ans=1;

           pw.println(ans);
        }
           pw.close();
    }
    static int gcd(int a,int b)
    {
        if(b==0) return a;
        return gcd(b,a%b);
    }
}
  

Measured memory_bytes: 32904
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner S = new Scanner(System.in);
		while(true){
			int m = S.nextInt();
			int f = S.nextInt();
			int r = S.nextInt();
			
			if(m == -1 && f == -1 && r == -1)
				break;
			

			if((m + f < 30) || (m == -1 || f == -1))
				System.out.println("F");	
			else if(m + f >= 80)
				System.out.println("A");
			else if(m + f >= 65)
				System.out.println("B");
			else if(m + f >= 50 || r >= 50)
				System.out.println("C");
			else if(m + f >= 30)
				System.out.println("D");
		}
	}		
}

Measured memory_bytes: 19220
import re
import copy

def accept_input():
    a,b,x = map(int,input().split())
    return a,b,x

a,b,x = accept_input()
print(b // x - (a - 1) // x)
"""
if a%x == 0 and a != b:
    print(b//x - a//x +1)
elif a%x == 0 and a == b:
    print(0)
else:
    print(b//x - a//x)
""" 


Measured memory_bytes: 9964
#C
import collections
n = int(input())
s = []
for _ in range(n):
    s.append(input())
 
for i in range(n):
    s[i] = "".join(sorted(s[i]))
s.sort()

c = collections.Counter(s)

result = [x for x in c.values() if x > 1]

ans = 0
for i in range(len(result)):
    ans += result[i]*(result[i] - 1) //2
    
print(ans)
    

Measured memory_bytes: 19756
parseint(x) = parse(Int, x)
readint() = readline() |> parseint
readints() = map(parseint, readline() |> split)

function main()
    n = readint()
    a = readints()
    b = readints()
    ans = 0
    for i = 1:n
        ans += min(a[i], b[i])
        b[i] -= min(a[i], b[i])
        ans += min(a[i+1], b[i])
        a[i+1] -= min(a[i+1], b[i])
    end
    println(ans)
end

main()

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

int main(void)
{
	int n, k;
	string s;
	cin >> n >> k >> s;
	s[k-1] = tolower(s[k-1]);
	cout << s << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i;
	int c=0,a[3]={0,0,0};
	for(i=0;i<10;i++){
		scanf("%d",&c);
		if(c>a[0]){
			a[2]=a[1];
			a[1]=a[0];
			a[0]=c;
		}else if(c>a[1]){
			a[2]=a[1];
			a[1]=c;
		}else if(c>a[2]){
			a[2]=c;
		}
	}

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

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

int main() {
    int A,B; cin >> A >> B;
    int outlet = 1;
    int ans = 0;
    while(outlet < B) {
        outlet--;
        outlet += A;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
using namespace std;

int n, k;
int main() {
	cin >> n >> k;
	vector<int> p(n);
	rep(i, 0, n) cin >> p[i];

	sort(ALL(p));
	int ans = 0;
	rep(i, 0, k) ans += p[i];
	cout << ans << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<pair<int,int>>a(n);
  rep(i,n){
    cin >> a[i].first;
    a[i].second=i;
  }
  sort(a.begin(),a.end());
  
  rep(i,n){
    cout << a[i].second+1;
    if(i<n-1) cout << ' ';
  }
  cout << endl;
    
}


Measured memory_bytes: 1664
package main

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

func main() {
	l := ScanInt()
    x := float64(l)/3
    y := float64(l)/3
    z := float64(l)/3
    r := fmt.Sprintf("%f", (x*y*z))
    P(r)
}

/*********************** I/O ***********************/

var in *bufio.Scanner
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func MnMx(args ...int) (int, int) {
	minVal, maxVal := int(math.MaxInt32), int(math.MinInt32)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int) int { mn, _ := MnMx(args...); return mn }
func Mx(args ...int) int { _, mx := MnMx(args...); return mx }
func LCM(a, b int) int   { return a / GCD(a, b) * b }
func GCD(a, b int) int {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a.rbegin(), a.rend());
    debug(a);
    int Alice = 0;
    int Bob = 0;
    for (int i=0; i<n; i++) {
        if (i % 2 == 0) {
            Alice += a[i];
        } else {
            Bob += a[i];
        }
    }
    int ans = Alice - Bob;
    cout << ans << endl;
    
}

Measured memory_bytes: 3172
N=int(input())
A=[int(i) for i in input().split()]
dp=[[10**23]*N for i in range(N)]
S=[0]*(N+1)
for i in range(1,N+1):
    S[i]=S[i-1]+A[i-1]
for i in range(N):
    dp[i][i]=0
for k in range(1,N):
    for i in range(N-k):
        for l in range(i,i+k):
            dp[i][i+k]=min(dp[i][i+k],dp[i][l]+dp[l+1][i+k]+S[i+k+1]-S[i])
print(dp[0][N-1])

Measured memory_bytes: 44252
#include <iostream>
#include <memory>
#include <vector>

int main(int argc, char const* argv[])
{
    long int min = 1E10;
    long int max = 0;
    long int max_diff = -1E10;
    long int n = 0;
    std::vector<int> vec;
    std::cin >> n;
    vec.resize(n);
    for (int i = 0; i < n; i++) {
        std::cin >> vec[i];
    }

    for (auto i: vec) {
        if ((i - min) > max_diff) {
            max_diff = i - min;
        }
        if (i < min) {
            min = i;
        }
    }
    std::cout << max_diff << std::endl;
    return 0;
}

Measured memory_bytes: 3516
x = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    #divisors.sort()
    return divisors

kouho = make_divisors(x)

#A>0,B<0
for y in kouho:
    for a in range(1000):
        b = a-y
        if a**5 - b**5 == x:
            print(a,b)
            break

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

typedef long long ll;

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


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

#define pii pair<double,double>
#define F first
#define S second
#define mp make_pair
#define pb push_back

using namespace std;

int n;

int a[50];

double sum, sz;

pii p[50];

vector <double> x;

int main () {
    cin >> n;
    for (int i = 1;i <= n;i ++) {
        cin >> p[i].F >> p[i].S;
        a[i] = i;
    }
    do {
        double res = 0;
        for (int i = 2;i <= n;i ++) {
            res += sqrt ((p[a[i]].S - p[a[i - 1]].S) * (p[a[i]].S - p[a[i - 1]].S) + (p[a[i]].F - p[a[i - 1]].F) * (p[a[i]].F - p[a[i - 1]].F));
        }x.pb (res);
    }while (next_permutation (a + 1, a + n + 1));
    for (auto it : x) {
        sum += it;
    }
    sz = x.size ();
    cout << fixed << setprecision (12)<< sum / sz;
}


Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>

using namespace std;

int main(void) {
	int n; cin >> n;
	int sum = 0;
	string a, b, c; cin >> a >> b >> c;

	for (int i = 0; i < n; i++) {
		map<char, int> mp;
		int tmp = 0;
		mp[a[i]];
		mp[b[i]];
		mp[c[i]];
		for (pair<char, int> x : mp) {
			tmp++;
		}
		if (tmp == 3) { sum += 2; }
		else if (tmp == 2) { sum += 1; }

	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    long long int n,x;
    cin>>n>>x;
    long long int m=n;
    long long int rem,ram;
    n-=x;
    while (n%x!=0)
    {
        rem=n/x*x;
        m+=rem*2;
        ram=n;
        n=x;
        x=ram-rem;
    }
    rem=n/x*x;
    m+=rem*2-x;
    printf ("%lld\n",m);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n;
  cin >> n;
  int sum = 0;
  rep(i,0,leng(n)){
    int a, b;
    a = pow(10,i+1);
    b = pow(10,i);
    sum += (n % a) / b;
  }
  if(n%sum==0) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}


Measured memory_bytes: 640
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    public void solve() {
    	int N = ni();
    	String[] S = new String[N];
    	int[] T = new int[N];
    	for (int i = 0; i < N; i++) {
			S[i] = ns();
			T[i] = ni();
		}
    	String X = ns();
    	int ans = 0;
    	boolean f = false;
    	for (int i = 0; i < N; i++) {
			if(f)				ans += T[i];
			if(X.equals(S[i]))	f = true;
		}
    	out.println(ans);
	}
    static class PP{
    	public int key, val;
    	public PP(int key, int val) {
    		this.key = key;
    		this.val = val;
    	}
		public int getKey() {
			return key;
		}
		public void setKey(int key) {
			this.key = key;
		}
		public int getVal() {
			return val;
		}
		public void setVal(int val) {
			this.val = val;
		}
    }

    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

vector<int> to[2505];
vector<int> rto[2505];
bool reachablefrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachablefrom1[v]) return;
  reachablefrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  int n = in();
  cout << 1-(float)(n/2)/n << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define $$ long long int
#define pb push_back
#define db pop_back
#define q2(n) (n%2)==0
#define loop(i,m,p) for ($$ i = m; i < p; ++i)
#define loopn(i,m,p) for ($$ i = p-1; i >=m; --i)

using namespace std;

int main()
{
    $$ n,h,w,cn=0;
    cin>>n>>h>>w;
    $$ ar[n][2];
    loop(i,0,n)
    {
      cin>>ar[i][0]>>ar[i][1];
    }
    loop(i,0,n)
    {
      if ((ar[i][0]>=h)&&(ar[i][1]>=w))
      {
        cn++;
      }
    }
    cout<<cn<<endl;


    return 0;

}



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

struct Node{
    int left,right,parent;
    Node(){
        left=right=parent=-1;
    }
};

void preorder(Node T[],int node){
    if(node==-1)return;
    printf(" %d",node);
    preorder(T,T[node].left);
    preorder(T,T[node].right);
    return;
}

void inorder(Node T[],int node){
    if(node==-1)return;
    inorder(T,T[node].left);
    printf(" %d",node);
    inorder(T,T[node].right);
    return;
}
void postorder(Node T[],int node){
    if(node==-1)return;
    postorder(T,T[node].left);
    postorder(T,T[node].right);
    printf(" %d",node);
    return;
}

int main(){
    int n,id,l,r;
    cin>>n;
    Node BTree[n];
    rep(i,n){
        scanf("%d %d %d",&id,&l,&r);
        BTree[id].left=l;BTree[id].right=r;
        BTree[l].parent=BTree[r].parent=id;
    }
    int root;
    rep(i,n) if(BTree[i].parent==-1)root=i;
    printf("Preorder\n");
    preorder(BTree,root);printf("\n");
    printf("Inorder\n");
    inorder(BTree,root);printf("\n");
    printf("Postorder\n");
    postorder(BTree,root);printf("\n");
}


Measured memory_bytes: 3232
import numpy as np
W,H,N = list(map(int,input().split()))

points = [list(map(int, input().split())) for _ in range(N)]
res = np.ones((W,H), dtype=np.int64)

for x, y, a in points:
    if a == 1:
        res[:x] = 0
    if a == 2:
        res[x:] = 0
    if a == 3:
        tmp = res[:, :y]
        res[:, :y] = 0
    if a == 4:
        tmp = res[:, y:]
        res[:, y:] = 0

print(res.sum())

Measured memory_bytes: 14536
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    vector<int> A,ans;
    REP(i,n){
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }

    REP(i,n){
        bool flag = false;
        REPR(j,n-1-i){
            if(A[j] == j + 1){
                ans.push_back(j + 1);
                A.erase(A.begin() + j );
                flag = true;
                break;
            }
        }
        if(not flag){
            cout << -1 << endl;
            return 0;
        }
    }
    REPR(i,n-1) cout << ans[i] << endl;
}

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

int main(void){
    int a,b;
    cin >> a >> b;
    
    if(a == b){
        cout << "a == b" << endl;
    }else if(a > b){
        cout << "a > b" << endl;
    }else{
        cout << "a < b" << endl;
    }
}



Measured memory_bytes: 3096
import collections
import itertools
N = int(input())
march = ['M','A','R','C','H'] 
lst = []
count = 0
for _ in range(N):
    s = input()
    if s[0] in march:
        lst.append(s[0])
        
c = collections.Counter(lst)  
lst2 = [ c[i] for i in march]
lst3 = list(itertools.combinations(lst2,3))
for l in lst3:
    count += l[0] * l[1] * l[2]
    
print(count)

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

int main(){
    string S,a,b;
    int count=0;
    int max=0;
    int n;
    cin>>S;
    n=S.size();
    for(int i=0;i<n;i++){
        if(S[i]=='A')count++;
        else if(S[i]=='T')count++;
        else if(S[i]=='C')count++;
        else if(S[i]=='G')count++;
        else count = 0;
        if(count >= max)max=count;
    }
    cout<<max<<endl;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  
  if (y % 2 == 1)
    cout << "No" << endl;
  else {
    int a;
    a = (4 * x - y) / 2;
    if (a < 0 || x < a)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3592
import std.stdio, std.string, std.conv, std.array, std.algorithm, std.range, std.math;

void main()
{
    auto n = readln.chomp.to!int;
    auto as = readln.chomp.split(" ").map!(to!int).array;

    auto av = as.reduce!"a+b" / n.to!double;
    auto av1 = ceil(av);
    auto ret1 = as.dup.map!(i => ((i - av1) ^^ 2).to!long).reduce!"a+b";

    av1 = floor(av);
    auto ret2 = as.dup.map!(i => ((i - av1) ^^ 2).to!long).reduce!"a+b";

    writeln(ret1 < ret2 ? ret1 : ret2);
}

Measured memory_bytes: 256
//itp1_topic4_c

#include <bits/stdc++.h>

using namespace std;


int main(){

	while(1){

	int a,b;

	string op;

	cin>>a>>op>>b;

	if(op == "?") break;


	int ans;

	if( op == "+" ) ans = a + b;

	if( op == "-" ) ans = a - b;

	if( op == "*" ) ans = a * b;

	if( op == "/" ) ans = a / b;

	
	cout<<ans<<endl;

	}

	return 0;

}


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

int main() {
  int A, B, price;
  cin >> A >> B;
  price = 0;
  
  if (A >= 13) {
    price = B;
  } else if (A >= 6 && A <= 12) {
    price = B / 2;
  } else {
    price = 0;
  }
  
  cout << price << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)
ll modpow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a % m;
		a = a * a%m; n >>= 1;
	}
	return res;
}
ll Combination(ll n, ll a){
  ll ans = 1;
  if(a>n/2) a = n - a;
  RPT(i,0,a) ans = ans * (n-i) / (i+1);
  return ans;
}
int main(){
  string S;int N, P;
  cin >> N >> P >> S;
  FOR(i,0,N) S[i] -= '0';
  if(P==2){
    ll ans = 0;
    IFOR(i,0,N){
      if(S[i]%2==0) ans += (i+1);
    }
    cout << ans << endl;
    return 0;
  }
  else if(P==5){
    ll ans = 0;
    IFOR(i,0,N){
      if(S[i]%5==0) ans += (i+1);
    }
    cout << ans << endl;
    return 0;
  }
  vector<ll> U(N+5,0);
  U[N] = 0;
  IFOR(i,0,N){
    U[i]= (U[i+1]+S[i]*modpow(10,N-1-i,P))%P;
  }
  map<int,int> Map;
  FOR(i,0,N+1){
    Map[U[i]]++; //cout << U[i] << " ";
  }//cout << endl;
  ll ans = 0;
  FOR(i,0,P){
    if(Map[i]>=2) ans += Combination(Map[i],2);
    //cout << Map[i] << " ";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2436
#include <bits/stdc++.h>
#define sf sacnf
#define pf printf
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define ii pair <int,int>
#define iii pair <int,ii>
#define pll pair <ll,ll>
#define plll pair <ll,pll>
#define Ziru 0
using namespace std;

int main(){
    int a,b;

    while(cin>>a>>b, a&&b){
        for(int i=1; i<=a; i++){
            for(int j=1; j<=b; j++){
                if(i%2!=0){
                    if(j%2!=0) cout<<"#";
                    else cout<<".";
                }
                else{
                    if(j%2!=0) cout<<".";
                    else cout<<"#";
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return Ziru;
}



Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N, K, c;
    c = 0;
    string str;
    cin >> N >> K >> str;
    for (int i = 0; i < N - 1; ++i){
        if (str[i+1] == str[i]) c += 1;
    }
    cout << min(c + 2 * K , N - 1) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>
#include <map>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int main() {
  std::string s;
  std::cin >> s;
  std::string s2;
  for(int i = 0; i < s.size(); i++) {
    if(0 == s2.size() || s2.back() == 'T')
      s2 += s[i];
    else if(s[i] == 'T') {
      s2.pop_back();
    } else
      s2.push_back(s[i]);
  }
  std::cout << s2.size();
  return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int x = 0;
  vector<int> a(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i];
  }
  vector<int> b(n, 0);
  for (int i = 0; i < n; i++) {
   b[a[i]]++;
  }
  for (int i = 1; i < n; i++) {
    cout << b[i] << endl;
  }
  cout << x << endl;
}


Measured memory_bytes: 4808
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,a,b;cin>>n>>a>>b;
    int ans=0;
    for(int i=1;i<=n;i++){
        int ni=i;
        int t=0;
        while(ni){
            t+=ni%10;
            ni/=10;
            
        }
        //cout<<t<<endl;
        if(t>=a&&t<=b)
            ans+=i;
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
int main(void) {
  int n;
  int s[1000];
  int sum = 0;
  double avg, ans;

  while (1) {
    ans = 0.0;
    sum = 0;
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (int i = 0; i < n; i++) {
      scanf("%d", &s[i]);
      sum += s[i];
    }
    avg = (double)sum / (double)n;
    for (int i = 0; i < n; i++) {
      ans += ((double)s[i] - avg) * ((double)s[i] - avg);
    }
    ans /= (double)n;
    printf("%lf\n", sqrt(ans));
  }
  return 0;
}


Measured memory_bytes: 2048
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)*}
    };
}

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

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input! {
        n: usize,
        k: usize,
        v: [i64; n],
    }
    
    let s1: i64 = v.iter().sum();
    let mut v_c: Vec<i64> = v.clone();
    v_c.sort_by(|a, b| b.cmp(a));
 
    let s2: i64 = v_c.iter().take(k).sum();
    let s: i64 = s1 - s2;

    if s > 0 {
        println!("{}", s)
    } else {
        println!("0")
    }
}


Measured memory_bytes: 8444
#include<stdio.h>
#include <sysexits.h>
#include<stdlib.h>
#include<math.h>

int main(void){
  int a,n,sum,i,L,p[20];
  if(scanf("%d",&n)>1){
    exit(0);
  }
  for(i=0;i<n;i++){
   if(scanf("%d",&p[i])>1){
    exit(0);
  }
  }
  sum=0;
  for(i=1;i<n-1;i++){
    if(p[i-1]<p[i]){
      if(p[i+1]>p[i]){
	sum+=1;
      }
    }
    if(p[i+1]<p[i]){
      if(p[i-1]>p[i]){
	sum+=1;
      }
    }
  }
  printf("%d",sum);
  return 0;
}


Measured memory_bytes: 128
def coin_change(coins, payment):
    T = [0] + [50001] * payment
    for c in coins:
        for i, t in enumerate(zip(T[c:], T), start=c):
            a, b = t
            T[i] = min(a, b + 1)
    return T[payment]

n, m = map(int, input().split())

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

ans = coin_change(c, n)

print(ans)

Measured memory_bytes: 11408
/*input
6 15
6 5
5 6
6 4
6 6
3 5
7 2
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

const int N = 101;

int n,W;
int w[N],v[N];
int dp[N][100001];


void solve(){
	 cin >> n >> W;
	 RE(i,n)cin >> w[i] >> v[i];
	// RE(i,n)cin >> v[i];
	 dp[0][0] = 0;
	 for(int i = 1;i <= n;i++){
         for(int j = 0;j <= W;j++){
            dp[i][j] = dp[i-1][j];
            if(j >= w[i])dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);

         }
	 }
	 int ans = 0;
	 for(int j = 1;j <= n;j++){
	 for(int i = 1;i <= W;i++){
	 	ans = max(ans,dp[j][i]);
	 }
	 }
	 cout << ans;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;//cin >> t;
  WL(t)solve();
  return 0;
}

Measured memory_bytes: 78336
#include <iostream>
#include<cmath>
#include <vector>
using namespace std;

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

int countPrime( vector<int>& a );

int main() {
	int n; cin >> n;
	vector<int> a(n);

	REP( i, n ) cin >> a[i];
	cout << countPrime( a ) << endl;

}

int countPrime( vector<int>& a ) {
	int count = 0;
	REP( i, a.size() ) {
		if( a[i] == 2 ) { count++; continue; }
		if( a[i] % 2 == 0 ) continue;

		int j;
		double sqrtNum = sqrt( a[i] );
		for( j = 3; j <= sqrtNum; j += 2 ) {
			if( a[i] % j == 0 ) break;
		}
		if( j > sqrtNum ) count++;
	}

	return count;
}


Measured memory_bytes: 3040
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e3+2;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	// freopen("out10.txt","w",stdout);
	#endif
	int n,k;
	cin>>k>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int ans=k;
	// cout<<ans;
	for(int i=1;i<n;i++)
	{
		// cout<<a[i]<<" ";
		ans=min(ans,k-(a[i]-a[i-1]));
		// cout<<ans<<" ";
	}
	ans=min(ans,k-(k-(a[n-1])+(a[0])));
	cout<<ans;
}
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

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

int next_combination(int sub){
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}

void solve(long long N, std::vector<std::string> S){
    vector<ll> cnt(5, 0);
    for(ll i = 0; i < N; ++i){
        if(S[i][0] == 'M') cnt[0]++;
        else if(S[i][0] == 'A') cnt[1]++;
        else if(S[i][0] == 'R') cnt[2]++;
        else if(S[i][0] == 'C') cnt[3]++;
        else if(S[i][0] == 'H') cnt[4]++;
    }
    //for(auto i: cnt) cout << i << endl;
    ll ans = 0;
    int bit = (1<<3)-1;
    for(;bit < (1<<5); bit = next_combination(bit)){
        ll tmp = 1;
        for(int i = 0; i < 5; ++i){
            if(bit & (1<<i)){
                tmp *= cnt[i];
            }
        }
        ans += tmp;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 6144
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rrep(i,n) for(ll i=(n)-1;i>=0;--i)
#define rep1(i,n) for(ll i=1;i<=(n);++i)
#define rrep1(i,n) for(ll i=(n);i>=1;--i)
#define fr first
#define sc second
#define pb push_back
#define INF 0xfffffff
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
struct edge{ll to,cap,rev; }; // ????????????????????????

vector<edge> G[100];
vector<edge> rG[100];
ll d[100];
ll a[100];
ll cnt=0;
void add_edge(ll from,ll to,ll cap){
	G[from].pb((edge){to, cap, rG[to].size() });
	rG[to].pb((edge){from, 0, G[from].size()-1} );
}

ll max_flow(ll V,ll E,ll s,ll t){
	ll res=0;
	memset( d, 0, sizeof(d) );
	memset( a, 0, sizeof(a) );
	d[s] = V;
	a[s]=-1;
	a[t]=0;
	rep(i,G[s].size()){
		edge &e = G[s][i];
		a[e.to] += e.cap;
		rG[e.to][e.rev].cap = e.cap;
		e.cap = 0;
	}
	for(;;){
		ll v = -1;  //1
		rep(i,V){
			if( a[i]>0 && i!=t ){
				v = i;
				break;
			}
		}
		if(v < 0) return a[t];
		ll J=0; //2
		ll id;
		rep(i,G[v].size()){
			if( G[v][i].cap>0 && d[v] - d[G[v][i].to] == 1 ){
				id = i;
				J=1;
				break;
			}
		}
		if(!J) rep(i,rG[v].size()){
			if( rG[v][i].cap>0 && d[v] - d[rG[v][i].to] == 1 ){
				id = i;
				J=2;
				break;
			}
		}
	
		if(J){  //3
			edge &e = (J==1?G[v][id]:rG[v][id]);
			if(J==1){
				ll f = min(a[v], e.cap );
				a[v] -= f;
				e.cap -= f;
				rG[e.to][e.rev].cap += f;
				if(a[e.to]>=0) a[e.to] += f;
			}
			else{
				edge &efor = G[e.to][e.rev];
				ll f = min(a[v], e.cap);
				a[v] -= f;
				e.cap -= f;
				efor.cap += f;
				if(a[e.to]>=0) a[e.to] += f;
			}
		}

		else{  //4
			ll dmin=0xfffffff;
			rep(i,G[v].size()){
				if(G[v][i].cap>0) dmin = min(dmin,d[G[v][i].to]);
			}
			rep(i,rG[v].size()){
				if(rG[v][i].cap>0) dmin = min(dmin,d[rG[v][i].to]);
			}
			d[v] = dmin + 1;
		}
	}
}

ll V,E,A[1000],B[1000],C[1000];

void input(){
	scanf("%lld%lld",&V,&E);
	rep(i,E){
		scanf("%lld%lld%lld",&A[i],&B[i],&C[i]);
	}
}

int main()
{
	input();
	rep(i,V){
		G[i].clear(); rG[i].clear();
	}
	rep(i,E) add_edge(A[i], B[i], C[i]);
	cout<<max_flow(V,E,0,V-1)<<endl;
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;


int main(){
    string s,t;
    cin >> s >> t;
    rep(i,0,s.size()){
        string r,l;
        r = s.substr(0,i+1);
        l = s.substr(i+1,s.size()-i-1);
        if(t == l + r){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    cout << "No" <<endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut s: Vec<char> = read::<String>().chars().collect();
    let t: Vec<char> = read::<String>().chars().collect();
    let mut ansIdx: i64 = -1;

    for i in 0..(s.len() - t.len() + 1) {
        let mut flag = false;
        for j in 0..t.len() {
            if s[i + j] != '?' && s[i + j] != t[j] {
                flag = true;
                break;
            }
        }
        if !flag {
            ansIdx = i as i64;
        }
    }
    if ansIdx == -1 {
        println!("UNRESTORABLE");
        return;
    }

    for i in ansIdx..(ansIdx + t.len() as i64) {
        s[i as usize] = t[(i - ansIdx) as usize];
    }

    for i in 0..s.len() {
        if s[i] == '?' {
            s[i] = 'a';
        }
    }
    let mut ans = String::new();
    for i in 0..s.len() {
        let si = s[i];
        ans += &si.to_string()
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352