akhauriyash/Code-Regression huggingface dataset:
n = int(input())
l = [int(x) for x in input().split()]

l.sort()

ans=0

import itertools
for seq in itertools.combinations(range(n),3):
    if l[seq[2]]!=l[seq[1]] and l[seq[1]]!=l[seq[0]] and l[seq[0]]!=l[seq[2]]:
        if l[seq[2]]<l[seq[0]]+l[seq[1]]:
            ans+=1  

print(ans)


Measured memory_bytes: 68084
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
//constexpr long long MOD = 1000000007LL;
constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
	return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
	return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
	return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
	return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
	a += rhs.a;
	if (a >= Modulus) {
	  a -= Modulus;
	}
	return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
	if (a < rhs.a) {
	  a += Modulus;
	}
	a -= rhs.a;
	return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
	a = a * rhs.a % Modulus;
	return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
	u64 exp = Modulus - 2;
	while (exp) {
	  if (exp % 2) {
		*this *= rhs;
	  }
	  rhs *= rhs;
	  exp /= 2;
	}
	return *this;
  }
};

using mint = modint<MOD>;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int N,S; cin >> N >> S;
	vector<int> A(N);
	rep(i,N) cin >> A[i];

	vector<vector<mint>> dp(N+1, vector<mint>(S+1));
	rep(i,N) dp[i][0] = 1;
	mint ans = 0;
	rep(i,N) {
		rep(j,S+1) {
			dp[i+1][j] += dp[i][j];
			if (A[i] <= j) dp[i+1][j] += dp[i][j-A[i]];
			if (j==S) {
				ans += dp[i+1][j]*(N-i);
				dp[i+1][j] = 0;
			} 
		}
	}

	cout << ans.a << ln;
}


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

using namespace std;
typedef long long ll;
int main()
{
    int n;cin >> n;
    vector<ll> a(n);ll ans = 1;
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
        if(a[i] == 0)
        {
            cout << 0 ;return 0;
        }
    }
    for(int i = 0;i < n;i++)
    {

        if(1e18 / ans < a[i])
        {
            cout << "-1";return 0;
        }
        ans *= a[i];
    }
    if(ans > 1000000000000000000)ans = -1;
    cout << ans;


    return 0;
}


Measured memory_bytes: 4020
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
      	int b = scn.nextInt();
      	int ans = -1;
      	for(int i=1; i<=1000; i++){
          if((int)(i*0.08)==a && (int)(i*0.1)==b){
            ans = i;
            break;
          }
        }
		System.out.println(ans);
	}
}


Measured memory_bytes: 35640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

const M = 1000001

func main() {
	n := scanInt()
	a := scanInts(n)

	sort.Ints(a)
	var e [M]bool
	for i := 0; i < n; i++ {
		if i > 0 && a[i] == a[i-1] {
			continue
		}
		for j := 2 * a[i]; j < M; j += a[i] {
			e[j] = true
		}
	}

	var cnt int
	for i := 0; i < n; i++ {
		if i > 0 && a[i] == a[i-1] || i < n-1 && a[i] == a[i+1] {
			continue
		}
		if !e[a[i]] {
			cnt++
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
int n, m, k, x3, y3, x2, y2;
int dx[4] = { 1, -1, 0, 0 };
int dy[4] = { 0, 0, 1, -1 };
int main() {
	cin >> n >> m >> k >> x3 >> y3 >> x2 >> y2;
	x3--;
	y3--;
	x2--;
	y2--;
	string s[n];
	for (int i = 0; i < n; i++)
		cin >> s[i];
	vector<vector<int> > g(n, vector<int>(m, 1e9));
	queue<pair<int, int> > q;
	q.push( { x3, y3 });
	g[x3][y3] = 0;
	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
		int val = g[x][y] + 1;
		for (int dir = 0; dir < 4; dir++) {
			int xx = x;
			int yy = y;
			for (int i = 1; i <= k; i++) {
				xx += dx[dir];
				yy += dy[dir];
				if (xx < 0 || yy < 0 || xx >= n || yy >= m || s[xx][yy] == '@'
						|| g[xx][yy] < val)
					break;
				if (g[xx][yy] > val) {
					g[xx][yy] = val;
					q.push( { xx, yy });
				}
			}
		}
	}
	if (g[x2][y2] == 1e9) {
		cout << -1;
	} else {
		cout << g[x2][y2];
	}
}


Measured memory_bytes: 12040
def slove():
    import sys
    input = sys.stdin.readline
    al = []
    bl = []
    n, h = list(map(int, input().rstrip('\n').split()))
    for i in range(n):
        a, b = list(map(int, input().rstrip('\n').split()))
        al.append(a)
        bl.append(b)
    al.sort()
    bl.sort()
    cnt = 0
    while True:
        if h > 0:
            if len(bl) != 0:
                bv = bl.pop()
                if bv > al[-1]:
                    h -= min(h, bv)
                    cnt += 1
                else:
                    break
            else:
                break
        else:
            break
    cnt += ((h + al[-1] - 1) // al[-1])
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 52956
L = input()
modulo = 10**9+7

dp = [[0] * (len(L)+1) for i in range(2)]
dp[1][0] = 1
  
for i in range(len(L)):
  if L[i] == "1":
    dp[0][i+1] = dp[1][i]
    dp[1][i+1] = dp[1][i] * 2
  else:
    dp[1][i+1] = dp[1][i]
  
  dp[0][i+1] += (3 * dp[0][i])
  dp[0][i+1] %= modulo
  dp[1][i+1] %= modulo

#1 -> 1
#10 -> 5
#11 -> 9
#print(dp)
print((dp[0][-1]+dp[1][-1]) % modulo)


Measured memory_bytes: 11124
/*
*/
#define _CRT_SECURE_NO_WARNINGS

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>  
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <ctime>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define eps 1e-10
#define M_PI 3.141592653589793
#define bs 1000000007;
#define bsize 512

const int N = 233031;

using namespace std;

int n, ar[N];
long long dp[N][4];

int main(){
	//freopen("beavers.in","r",stdin);
	//freopen("beavers.out","w",stdout);
	//freopen("F:/in.txt","r",stdin);
	//freopen("F:/output.txt","w",stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

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

	for (int i = 0; i <= n; i++)
	{
		dp[i][0] = dp[i][1] = -1e18;
	}

	dp[0][0] = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j <= 1; j++)
		{
			for (int q = 0; q <= 1; q++)
			{
				for (int make_here = 0; make_here <= 1; make_here++)
				{
					if (dp[i][j] < 0)
						continue;
					if (q>0 && ar[i + 1] == 0)
						continue;
					int touse = make_here + q;
					if (ar[i + 1] < touse || ar[i + 1] % 2 != touse % 2)
						continue;
					if (j == 0 && make_here == 1)
						continue;
					int new_pairs = ar[i + 1] - touse;
					new_pairs /= 2;
					new_pairs += make_here;
					dp[i + 1][q] = max(dp[i + 1][q], dp[i][j] + new_pairs);
				}
			}
		}
	}

	cout << max(dp[n][0], dp[n][1]) << endl;

	cin.get(); cin.get();
	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto &i:a)cin >> i;
	ll ans = INT_MAX;
	for(int i = -100;i<=100;i++)
	{
		ll now = 0;
		for(int j = 0;j<n;j++)
		{
			now += (i-a[j])*(i-a[j]);
		}
		ans = min(now,ans);
	}
	cout<<ans<<endl;
}

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

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int pattern = 0;
    for (int a=0; a<=A; ++a) {
        int resA = X - 500 * a;
        for (int b=0; b<=B; ++b) {
            int resB = resA - 100 * b;
            if ((resB % 50) == 0) {
                int c = resB / 50;
                if ((c >= 0) && (c <= C)) ++pattern;
            }
        }
    }
    cout << pattern << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 55) - 1;
int MOD = 1e9+7;
ll dp[101][100001];
main(){
    rep(i,0,101)rep(j,1,100001)dp[i][j] = INF;
    int N,W;
    cin >> N >> W;
    rep(i,0,N){
        int w,v;
        cin >> w >> v;
        rep(j,0,100001){
            dp[i+1][j] = dp[i][j];
            if(j - v < 0)continue;
            dp[i+1][j] = min(dp[i][j], dp[i][j - v] + w);
        }
    }
    ll maxi = 0;
    rep(i,0,100001)if(dp[N][i] <= W)maxi = max(maxi, (ll)i);
    cout << maxi << endl;
}

Measured memory_bytes: 79104
//============================================================================
// Name        : Stack.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

int main() {

	string input;
	vector<int> v;
	string line;
	getline(cin, line);
	istringstream iss(line);

	while(iss >> input){
		//cout << input << "\n";
		if(input == "+"){
			int elem2 = v.back();
			v.pop_back();

			int elem1 = v.back();
			v.pop_back();

			int result = elem1 + elem2;
			v.push_back(result);
		}else if(input == "*"){
			int elem2 = v.back();
			v.pop_back();

			int elem1 = v.back();
			v.pop_back();

			int result = elem1 * elem2;
			v.push_back(result);
		}else if(input == "-"){
			int elem2 = v.back();
			v.pop_back();

			int elem1 = v.back();
			v.pop_back();

			int result = elem1 - elem2;
			v.push_back(result);
		}else{
			v.push_back(stoi(input));
		}

	}

	for(int i=0; i<v.size(); i++){
		cout << v.at(i) << "\n";
	}

	return 0;
}



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

int main() {
	int64_t n, k; cin >> n >> k;
	int p[n];
	for(int i = 0; i < n; ++i) {
		cin >> p[i];
		--p[i];
	}
	int64_t ans = -1e18;
	int64_t c[n];
	for(int i = 0; i < n; ++i) {
		cin >> c[i];
	}
	for(int i = 0; i < n; ++i) {
		vector<int64_t> val = {0};
		int now = i;
		int64_t sum = 0;
		for(int j = 1; j <= n; ++j) {
			int nxt = p[now];
			sum += c[nxt];
			val.push_back(sum);
			now = nxt;
			if(now == i) break;
		}
		int sz = val.size() - 1;
		for(int j = 1; j <= sz and j <= k; ++j) {
			ans = max(ans, val[j] + max<int64_t>(0, sum * ((k - j) / sz)));
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<int, ll> lp;
const int inf = 1e9;
const ll linf = 1LL << 50;
int n, m, x;
ll h[100001];
vector<lp> vec[100001];
ll cost[100001];
bool used[100001];

int main(int argc, char const* argv[])
{
	cin >> n >> m >> x;
	for(int i = 0; i < n; i++)cin >> h[i];
	for(int i = 0; i < m; i++){
			int x, y;
			ll z;
			cin >> x >> y >> z;
			x--; y--;
			vec[x].pb(mk(y, z));
			vec[y].pb(mk(x, z));
	}
	fill(cost, cost + n, linf / 2);
	fill(used, used + n, false);
	priority_queue<Pl, vector<Pl>, greater<Pl> > q;
	cost[0] = 0;
	q.push(mk(0, 0));
	while(!q.empty()){
			Pl p = q.top(); q.pop();
			ll cos = p.first;
			int at = p.second;
			int hei = 0;
			used[at] = true;
			if(x >= cos)hei = x - cos;
			for(auto itr = vec[at].begin(); itr != vec[at].end(); ++itr){
					int to = (*itr).first;
					if(used[to])continue;
					ll tocost = (*itr).second;
					ll dis = cos + tocost;
					if(hei < tocost){
							if(tocost > h[at])continue;
							dis += tocost - hei;
					}
					if(hei - tocost > h[to]){
							dis += hei - (tocost + h[to]);
					}
					if(dis < cost[to]){
							cost[to] = dis;
							q.push(mk(dis, to));
					}
			}
	}
	ll hei = 0;
	if(cost[n-1] > linf / 3){
			cout << -1 << endl;
			return 0;
	}
	if(x >= cost[n-1])hei = x - cost[n-1];
	cout << cost[n-1] + abs(h[n-1] - hei) << endl;
	return 0;
}



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

int main() {
  int N, M; cin >> N >> M;
  int c[M], s[M];
  for (int i = 0; i < M; i++) {
    cin >> c[i] >> s[i];
  }
  
  int res = -1;
  if (N == 1) {
    for (int n = 9; n >= 0; n--) {
      bool ok = true;
      for (int i = 0; i < M; i++) {
        if (s[i] != n) {ok = false;}
      }
      if (ok) {res = n;}
    }
  }
  else if (N == 2) {
    for (int n = 99; n >= 10; n--) {
      bool ok = true;
      int n1 = n/10; int n2 = n%10;
      for (int i = 0; i < M; i++) {
        if (c[i] == 1) {if (s[i]!=n1) {ok = false;}}
        if (c[i] == 2) {if (s[i]!=n2) {ok = false;}}
      }                
      if (ok) {res = n;}
    }
  }
  
  else if (N == 3) {
    for (int n = 999; n >= 100; n--) {
      bool ok = true;
      int n1 = n/100; int m1 = n%100;
      int n2 = m1/10; int n3 = m1%10;
      for (int i = 0; i < M; i++) {
        if (c[i] == 1) {if (s[i]!=n1) {ok = false;}}
        if (c[i] == 2) {if (s[i]!=n2) {ok = false;}}
        if (c[i] == 3) {if (s[i]!=n3) {ok = false;}}
      }
      if (ok) {res = n;}
    }
  }
  
  cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, m;
    cin >> n >> m;
    cout << (n == m? "Yes":"No")<< endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define in (void)scanf
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
//#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(int i=(int)(l);i<(int)(r);i+=(int)(k))
//#define Repp(i,l,r,k)for(LL i=(LL)(l);i<(LL)(r);i+=(LL)(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//998244353,1000000007,1000000009,4999999999999997
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a,LL n,int m){LL x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
typedef struct fac { LL n, exp; }F;
LL fact(LL n,F*a){LL x=n,i,j,c=0;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c++].exp=j-1;}}if(x-1){a[c].n=x;a[c++].exp=1;}return c;}
LL nibtan(LL* a,LL n,LL x){LL p=0,q=n/2,r=n-1;while(r-p>1){if(x>=a[q])p=q;if(x<=a[q])r=q;q=(p+r)/2;}return a[p]==x?p:r;}
//snippet

#define N 200009

int n, k, a[N];

LL check(int x) {
	LL ret = 0;
	rep(i, n)ret += (LL)ceill((Lf)a[i] / (Lf)x) - 1;
	return ret;
}

void run(void) {
	//saw editorial
	in("%d%d", &n, &k);
	rep(i, n)in("%d", &a[i]);

	int p = 0, q = MOD / 2, r = MOD, ans = n;
	while (r - p > 1) {
		if (check(q) <= (LL)k) r = q;
		else p = q;
		q = (p + r) / 2;
	}
	if (check(r) <= k)ans = r;
	if (check(q) <= k)ans = q;
	if (check(p) <= k)ans = p;
	printf("%d\n", ans ? ans : 1);
}

int main(void) {
	int test = 1;
//	in("%d", &test);
	while (test--) {
		run();
	}
	return 0;
}

Measured memory_bytes: 2884
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int N;
    cin >> N;
    vector<int> H(N);
    REP(i, N) cin >> H[i];

    int ans = 0;
    int tmp = 0;
    REP(i, N-1) {
        if (H[i] >= H[i+1]) {
            tmp += 1;
        } else {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }
    ans = max(ans, tmp);
    print(ans);
}

int main()
{
    solve();

    return 0;
}


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

int main() {
    int A, B;
    cin >> A >> B;
    int x, y, z;
    x = A + B;
    y = A - B;
    z = A * B;
    cout << max(x, max(y, z)) << endl;

  return 0;
}


Measured memory_bytes: 256
s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力

Measured memory_bytes: 9312
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;

int main(){
    int N;
    cin >> N;
    int p[N];
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    int sum = accumulate(p, &p[N], 0);
    int ans = sum - *max_element(p, &p[N])/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 2002;

ll dp[MAX_N][MAX_N];
ll sm[100005];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,l;
    cin >> n >> m >> l;
    vi K(n),s(m);
    rep(i,n){
        cin >> K[i];
        --K[i];
    }
    rep(i,m){
        cin >> s[i];
    }
    sort(all(K));
    rep(i,n+1){
        rep(j,n+1){
            dp[i][j] = (1LL << 60);
        }
    }
    sm[0] = 0;
    rep(i,m){
        sm[i+1] = sm[i]+s[i];
    }
    dp[0][0] = 0;
    rep(i,n-2){
        rep(j,i+1){
            cmn(dp[i+1][j],dp[i][j]+(sm[K[i+1]+1]-sm[K[i]])/l);
            cmn(dp[i+1][i],dp[i][j]+(sm[K[i+1]+1]-sm[K[j]])/l);
        }
    }
    // rep(i,n-1){
    //     rep(j,i){
    //         cout << i << " " << j << " " << dp[i][j] << "\n";
    //     }
    // }
    ll ans = (1LL << 60);
    rep(i,n-1){
        cmn(ans,dp[n-2][i]+(sm[K[n-1]+1]-sm[K[n-2]])/l+(sm[K[n-1]+1]-sm[K[i]])/l);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 35344
import java.util.Scanner;
public class Main
{
 	public static void main(String[] args)
    {
     	 Scanner sc = new Scanner(System.in);
      	int a = Integer.parseInt(sc.nextLine());
      	int b[] = new int[4]; 
      	for(int i = 0; i < a; i++)
        {	
          	String word = sc.nextLine();
         	if(word.equals("AC")) 
            {
              b[0]++;
            }else if(word.equals("TLE")){
              b[2]++;
            }else if(word.equals("WA")){
              b[1]++;
            }else{
              b[3]++;
            }
              
        }
      	System.out.println("AC x " + b[0]);
      	System.out.println("WA x " + b[1]);
      	System.out.println("TLE x " + b[2]);
      	System.out.println("RE x " + b[3]);
    }
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(ll, a, b);
  if (a == b) {
    out(0);
  } else if ((a + b) % 2 == 0) {
    out((a + b) / 2);
  } else {
    out("IMPOSSIBLE");
  }
}


Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main() {
	string str;
	cin >> str;

	while (1) {
		str.pop_back();
		if (str.size() % 2 != 0)continue;
		
		string str1, str2;
		for (int i = 0; i < str.size() / 2; i++) str1.push_back(str[i]);
		for (int i = str.size() / 2; i < str.size(); i++)str2.push_back(str[i]);

		if (str1 == str2)break;
	}
	cout << str.size() << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
	$n = fgets(STDIN);
	$s = 1;
	while(true){
		if($n < $s){
			$s = $s /2;
			break;
		}
		elseif($n == $s){
			break;
		}
		$s = $s * 2;
	}
	
	echo $s;
?>

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;

ull N,V;
ull p[4][1001];

ull solve() {
  vector<ull> a(N*N,0),b(N*N,0);
  for (int i=0; i<2; ++i) {
    for (int j=0; j<N; ++j) {
      for (int k=0; k<N; ++k) {
        ull tmp = p[i*2][j]+p[i*2+1][k];
        if (i==1) {
          a[j*N+k] = tmp;
        } else {
          b[j*N+k] = tmp;
        }
      }
    }
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  ull ans = 0;
  for (int i=0; i<a.size(); ++i) {
    pair<vector<ull>::iterator, vector<ull>::iterator> c = equal_range(b.begin(), b.end(), V-a[i]);
    ans += c.second - c.first;
  }
  return ans;
}

int main() {
  cin>>N>>V;
  for (int i=0; i<4; ++i) {
    for (int j=0; j<N; ++j) {
      cin>>p[i][j];
    }
  }
  cout<<solve()<<endl;
  return 0;
}


Measured memory_bytes: 18404
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define each(i, n) for(auto&& i: n)

int main() {
  int N, a = 0;
  st S;
  cin >> N >> S;
  rep(i, N - 2) {
    if(S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C') {
         a++;
    }
  }
  cout << a << endl;
}  

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

#define MAX_N 100000
#define MAX_DIGIT 40
typedef long long int ll;

int n;
ll k, a[MAX_N], count[MAX_DIGIT + 1];

ll calc(int i) {
  ll ret = 0LL;
  for(int j = MAX_DIGIT; j > i; --j) {
    if(((k + 1) >> j) & 1) {
      ret += (1LL << j) * ((ll) n - count[j]);
    } else {
      ret += (1LL << j) * count[j];
    }
  }

  ret += (1LL << i) * count[i];

  for(int j = i - 1; j >= 0; --j) {
    ret += (1LL << j) * std::max(count[j], (ll) n - count[j]);
  }

  return ret;
}

int main() {
  std::cin >> n >> k;
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }

  for(int i = 0; i <= MAX_DIGIT; ++i) {
    count[i] = 0;
    for (int j = 0; j < n; ++j) {
      count[i] += (a[j] >> i) & 1;
    }
  }

  ll ans = 0;
  for(int i = 0; i <= MAX_DIGIT; ++i) {
    if(((k + 1) >> i) & 1) {
      ans = std::max(ans, calc(i));
    }
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

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

using namespace std;


int main(void)
{
	ll n, k, ans=0, sum=0, midans=0;
	cin >> n >> k;
	int A[40][n], x[40], K[40];
	pair<ll, ll> p[40];
	rep(i, n){
		ll a;
		cin >> a;
		rep(j, 40){
			A[j][i] = a % 2;
			a /= 2;
		}
	}
	rep(i, 40){
		ll cnt0=0;
		rep(j, n){
			if (A[i][j] == 0) cnt0++;
		}
		if (2*cnt0 <= n){
			x[i] = 0;
			midans += (n-cnt0) << i;
		}else{
			x[i] = 1;
			p[i].first = (cnt0) << i;
			p[i].second = (n-cnt0) << i;
		}
	}
	sum = midans;
	rep(i, 40){
		K[i] = k % 2;
		k /= 2;
		if (x[i] == 1){
			if (K[i] == 1){
				sum += p[i].first;
			}else{
				sum += p[i].second;
			}
		}
	}
	ans = sum;
	rep(i, 40){
		if (K[i] == 0) continue;
		sum = midans;
		rep(j, 40){
			if (x[j] == 1){
				if ((K[j] == 1 && i != j) || (j < i)){
					sum += p[j].first;
				}else{
					sum += p[j].second;
				}
			}
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    ll x,k,d;
    cin>>x>>k>>d;
    x = abs(x);
    ll ans;
    if(x/d >=k){
        ans = x-d*k;
    }else{
        ll e = x/d;
        k -= e;
        x -= e*d;
        if(k%2==1) x = abs(x-d);
        ans = x;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(void){
	int n,q;
	int s[10000],t[500];
	int i,j,c=0;

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

	scanf("%d",&q);
	for(i=0;i<q;++i){
		scanf("%d",&t[i]);
	}
	
	for(i=0;i<q;++i){
		for(j=0;j<n;++j){
			if(s[j]==t[i]){
				c++;
				break;
			}
		}
	}
	printf("%d\n",c);
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);



int main()
{
	
	fastio;
	
	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;
			break;
		}
	}


		
	
	return 0;
}







Measured memory_bytes: 3552
n = int(input())
l = list(map(int, input().split()))
if len(set(l)) == 1:
  if l[0] <= n//2 or l[0] == n-1:
    print('Yes')
  else:
    print('No')
elif len(set(l)) > 2 or max(l)-min(l) > 1:
  print('No')
else:
  ma = max(l)
  mi = ma - 1
  mac = l.count(ma)
  mic = n - mac
  if mic <= mi <= mic-1+mac//2:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 14244
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


int fac(int num) {
  if(num==1) return 1;
  else return num*fac(num-1);
}


ll a[110000];
ll dp[110000][2];

int main() {
  int N,X; cin >> N >> X;
  int pos = 0;
  int ans = 1;
  rep(i,N) {
    int L;
    cin >> L;
    pos += L;
    if(pos <= X) ans++;
  }

  cout << ans << endl;

  
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k  = sc.nextInt();
		int ans = 0;
		for(int i = 0; i < n; i++ ) {
			int h = sc.nextInt();
			if(h >= k) ans++;
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 47184
#include <stdio.h>

int main(void)
{
	int a, b,ans;
	char op;

	scanf("%d %c %d", &a, &op, &b);

	while (!(op == '?'))
	{
		if (op == '+')
			ans = a + b;
		else if (op == '-')
			ans = a - b;
		else if (op == '*')
			ans = a*b;
		else if (op == '/')
			ans = a / b;
		else
			break;

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

		scanf("%d %c %d", &a, &op, &b);
	}

	return 0;
}

Measured memory_bytes: 600
program main
  implicit none
  character(len=100000) :: s
  integer :: i, j, n, k = 0, l = 0
  integer, allocatable :: h1(:), h2(:)

  read *, s
  n = len_trim(s)
  allocate (h1(n), h2(n))
  h1 = 0
  h2 = 0

  do i = 1, n-1
    if (s(i:i+1) == 'RR') then
      k = k + 1
    else if(s(i:i+1) == 'RL') then
      h1(i) = h1(i) + int((k+2)/2)
      h1(i+1) = h1(i+1) + int((k+1)/2)
      k = 0
    end if
    j = n - i + 1
    if (s(j-1:j) == 'LL') then
      l = l + 1
    else if (s(j-1:j) == 'RL') then
      h2(j) = h2(j) + int((l+2)/2)
      h2(j-1) = h2(j-1) + int((l+1)/2)
      l = 0
    end if
  end do

  do i = 1, n
    write(*, fmt='(i0, x)', advance='no') h1(i) + h2(i)
  end do
end program


Measured memory_bytes: 1572
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

LL n;
LL a[100010];
LL sum=0;

bool ans(){
     if(n==1)return true;
     else if(sum%(LL)(n*(n+1)/2)!=0)return false;
     else{
         sum=sum/(LL)(n*(n+1)/2);
	 for(int i=0;i<n-1;i++){
	     //cout<<sum<<endl;
             LL temp=a[i+1]-a[i]-sum;
	     if(!(temp<=0 && temp%n==0))return false;
         }
	 LL temp=a[0]-a[n-1]-sum;
	 if(!(temp<=0 && temp%n==0))return false;
	 
         return true;
     }
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
	sum+=a[i];
    }	
    
	
	
   // cout<<sum<<endl;
    puts(ans()?"YES":"NO");
    return 0;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    ll s = 0;
    int i;
    for (i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            s += i;
        }
    }
    printf("%lld\n", s);


    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



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

int main(void){


    string str,ans1,ans2;
    map<string,int> dict;
    int maxi = 0;
    while(cin >> str){
        if(maxi < str.size()){
            maxi = str.size();
            ans1 = str;
        }
        dict[str]++;
        int count = 0;
        map<string,int>::iterator itr;
        for(itr = dict.begin();itr != dict.end();itr++){
            if(count < (*itr).second){
                ans2 = (*itr).first;
                count = (*itr).second;
            }
        }
    }
    cout << ans2 << " " << ans1 << endl;
    return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = b/x - max(a-1, 0ll)/x;
    cout << ans+(a==0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long llong;
typedef unsigned long long ullong;

using namespace std;


int main() {
	llong n, m;
	cin >> n >> m;
	set<llong> v;

	llong ans = 0;
	if( n != 0 )
	{
		v.insert( n );
		while( 1 )
		{
			llong  x = n % m;

			if( x == n )
			{
				x = m - n;
			}

			if( x == 0 || x == 1 )
			{
				ans = x;
				break;
			}

			auto r = v.insert( x );
			if( r.second == false )
			{
				ans = *v.begin();
				break;
			}
			n = x;
		}

	}

	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi = 3.141592654;
ll arr[100];

int main()
{
#ifndef oj
    //freopen("input", "r", stdin);
    //freopen("output.txt","w",stdout);
#endif
    // system("cls");
    //getchar();
    // cout<<adj[1][0];

    int t,sum=0;
    // cin>>t;
    t=1;
    while(t--)
    {
        ll x,y;
        cin>>x>>y;
        if(x*500 <y)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;

    }

}




Measured memory_bytes: 256
import sys

n = int(input())
balls = []

for line in sys.stdin:
    x, y = map(int, line.split())
    balls.append((x, y))

balls.sort()
ans = 0
for i in range(n - 1):
    x1, y1 = balls[i]
    for j in range(i + 1, n):
        x2, y2 = balls[j]
        p, q = x2 - x1, y2 - y1
        tmp = 0
        for x, y in balls:
            if (x - p, y - q) in balls:
                tmp += 1
        ans = max(ans, tmp)
print(n - ans)


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

int main(){
        long long n;
        long long max=0;
        int dig;
        cin >> n;
        int num=0;
        int num_nine=0;
        int lastone;
        while(n){
                lastone=n;
                dig = n%10;
                n=n/10;
                num++;
                if(dig==9){
                        num_nine++;
                }
        }
        int value = (num-1)*9 + lastone-1;
        if(num == num_nine){
                cout << value+1 << endl;
        }else if(num-1 == num_nine && lastone!=9){
                cout << value+1 << endl;
        }else{
                cout << value << endl;
        }
        return 0;
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  cin>>a>>b;
  
  cout<<a*b<<" "<<2*(a+b)<<endl;
      
  return 0;
}


Measured memory_bytes: 2996
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int a;
	vector<int> v;
	for(int i=0;i<10;i++){
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	cout<<v[9]<<endl;
	cout<<v[8]<<endl;
	cout<<v[7]<<endl;
	return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

int main(){
	std::string S; std::cin >> S;
	int a, z;
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == 'A') {
			a = i;
			break;
		}
	}
	for (int i = S.size() - 1; i >= 0; --i) {
		if (S[i] == 'Z') {
			z = i;
			break;
		}
	}
	std::cout << z - a + 1 << std::endl;

	return 0;
}

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

int main(){
  int n, m, s = 0, t[100], p[100], x[100];
  cin >> n; rep(i, n) {cin >> t[i]; s += t[i];}
  cin >> m; rep(i, m) cin >> p[i] >> x[i];
  rep(i, m) cout << s - t[p[i] - 1] + x[i] << endl;
}	

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



void solve(long long N, std::vector<std::string> S){
    unordered_map<string,ll> um;
    um["AC"] = 0;
    um["WA"] = 0; 
    um["TLE"] = 0;
    um["RE"] = 0;
    for(auto &&elm : S) {
        um[elm]++;
    }
    cout << "AC x " << um["AC"] << endl;
    cout << "WA x " << um["WA"] << endl;
    cout << "TLE x " << um["TLE"] << endl;
    cout << "RE x " << um["RE"] << endl;

}

signed 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: 6448
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



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

map<ll,int> m;
rep(i,N){
    ll D;
    cin>>D;
    m[D]++;
}
int M;
cin>>M;

rep(i,M){
 ll T;
    cin>>T;
    if(m[T]>0){
        m[T]--;
    }
    else{
        cout<<"NO"<<endl;
        return 0;
    }
}
cout<<"YES"<<endl;
return 0;
}

Measured memory_bytes: 16120
//BISMILLAH
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
   int a,b,c,d,minus1,minus2,res=0;
   int n;
   int flag=n;
   set<string>s;
   cin>>n;
   while(n--)
   {
       string str;
       cin>>str;
       s.insert(str);

   }
   res=s.size();
   cout<<res<<endl;
}


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

int main() {
    long long a;
    long long b;
    long long k;
    cin >> a >> b >> k;
    if(k - a > 0) {
        k = k - a;
        a = 0;
    }else {
        a = a - k;
        k = 0;
    }
    if(k - b > 0) {
        b = 0;
    }else {
        b = b - k;
    }
    cout << a << " " << b;

    return 0;
}


Measured memory_bytes: 256
/**Lucky Boy**/
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 500005
#define maxm 1000006
#define pii pair <int,int>
#define Task ""
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
using namespace std;
const int mod = maxc;
int dp[60][2][2][2];
bool ok[60][2][2][2];
long long ll,rr;
void Add(int &x,int y)
{
    x += y;
    if (x >= mod) x -= mod;
}
int DP(int d,long long l,long long r,bool bot,bool top,bool lead)
{
    if (d < 0) return 1;
    int &res = dp[d][bot][top][lead];
    if (ok[d][bot][top][lead]) return res;
    ok[d][bot][top][lead] = 1;
    FOR(b,0,1) FOR(t,0,1)
    {
        if (b > t) continue;
        if (!lead && b != t) continue;
        int limt = ((r >> d) & 1ll),
            limb = ((l >> d) & 1ll);
        if (top && t > limt) continue;
        if (bot && b < limb) continue;
        Add(res,DP(d-1,l,r,bot && b == limb,top && t == limt,lead || t));
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
    //freopen(Task".inp", "r",stdin);
    //freopens(Task".out", "w",stdout);
    cin >> ll >> rr;
    cout << DP(59,ll,rr,1,1,0);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  string S,T; cin >> S >> T;
  int ans=0;
  rep(i,SZ(S)){
    if(S[i]!=T[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
long long K,sum,mod=7LL;
int main(){
    cin>>K;
    for(int i=0;i<10000000;mod*=10LL,i++){
        mod%=K;
        sum+=mod;
        sum%=K;
        if(sum==0LL){cout<<i+1<<endl;return 0;}
        if(mod==0LL){cout<<-1<<endl;return 0;}
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3632
# coding: utf-8
# Your code here!
class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))#親ノード
        self.size = [1]*n #グループの要素数

    def root(self, x): #root(x): xの根ノードを返す．
        while self.parent[x] != x:
            self.parent[x] = self.parent[self.parent[x]]
            x = self.parent[x]
        return x 

    def merge(self, x, y): #merge(x,y): xのいるグループと$y$のいるグループをまとめる
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.size[x] < self.size[y]: 
            self.size[y] += self.size[x] #yの要素数を更新
            self.parent[x] = y #xをyにつなぐ
        else:
            self.size[x] += self.size[y] #xの要素数を更新
            self.parent[y] = x #yをxにつなぐ
        return True

    def issame(self, x, y): #same(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)
        
    def size(self,x): #size(x): xのいるグループの要素数を返す
        return self.size[self.root(x)]


n,m = [int(i) for i in input().split()]
 
T=UnionFind(n)
c=0
for _ in [0]*m:
    x,y,z=[int(i) for i in input().split()]
    if not T.issame(x-1,y-1):
        T.merge(x-1,y-1)
        c+=1
 
print(n-c)

Measured memory_bytes: 8564
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while( true ) {
        int n;
        cin >> n;
        if( n == 0 ) break;

        int cnt[10] = {};
        for( int i = 0; i < n; ++i ) {
            int a;
            cin >> a;
            ++cnt[a];

        }
        for( int i = 0; i < 10; ++i ) {
            for( int j = 0; j < cnt[i]; ++j ) cout << '*';
            if( cnt[i] == 0 ) cout << '-';
            cout << endl;

        }
    }
    return 0;
}





Measured memory_bytes: 3228
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

VVI matmul(VVI A, VVI B, int mod){
	int n = A.size();
	VVI C(n, VI(n));
	REP(i,n) REP(j,n) REP(k,n){
		C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
	}
	return C;
}

VVI matpow(VVI A, int t, int mod){
	int n = A.size();
	VVI B(n, VI(n));
	REP(i,n) B[i][i] = 1;
	while (t){
		if (t & 1)
			B = matmul(A, B, mod);
		A = matmul(A, A, mod);
		t /= 2;
	}
	return B;
}

int main(){
	int n, m, a, b, c, t;
	while (cin >> n >> m >> a >> b >> c >> t && n){
		VVI A(n,VI(n));
		REP(i,n){
			A[i][i] = b;
			if (i > 0) A[i][i-1] = a;
			if (i < n-1) A[i][i+1] = c;
		}
		A = matpow(A, t, m);
		VI ans(n), s(n);
		REP(i,n) cin >> s[i];
		REP(i,n) REP(j,n){
			ans[i] = (ans[i] + A[i][j] * s[j]) % m;
		}
		REP(i,n){
			cout << ans[i];
			if (i < n-1) cout << " ";
		}
		cout << endl;
	}

    return 0;
}

Measured memory_bytes: 3200
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let K: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let ans = (K / 2) * ((K + 1) / 2);

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


Measured memory_bytes: 4352