akhauriyash/Code-Regression huggingface dataset:
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


def eulerian_trail(tree, max_v, root=0):
    """
    木のオイラー路; オイラーツアー
    :param list of (list of (int, int)) tree:
    :param int max_v:
    :param int root:
    :return: (trails, depths, weights)
    :rtype: (list of int, list of int, list of int)
    """
    seen = [False] * (max_v + 1)
    # 頂点の履歴
    trails = []
    # 深さの履歴
    depths = []
    # 距離の履歴
    weights = []
    # Overflow 回避のためループで
    stack = [(root, 0, 0, True)]
    while stack:
        v, d, w, forward = stack.pop()
        seen[v] = True
        trails.append(v)
        depths.append(d)
        weights.append(w)
        if not forward:
            continue

        for u, w in tree[v]:
            if not seen[u]:
                stack.append((v, d, -w, False))
                stack.append((u, d + 1, w, True))
    return trails, depths, weights


N = int(sys.stdin.buffer.readline())
AB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N - 1)]
graph = [[] for _ in range(N)]

# AB = generate_tree(N)
# plot_graph(AB)
# for a, b in AB:
#     graph[a].append((b, 1))
#     graph[b].append((a, 1))

for a, b in AB:
    a -= 1
    b -= 1
    graph[a].append((b, 1))
    graph[b].append((a, 1))

counts = [N // 3, (N + 2) // 3, (N + 1) // 3]

# 二部グラフ
vs, _, _ = eulerian_trail(graph, N - 1)
bp = [0] * N
for i, v in enumerate(vs):
    bp[v] = i & 1


ansmod = [-1] * N
if bp.count(0) <= counts[0]:
    # 3を割り当てる
    for v, b in enumerate(bp):
        if b == 0 and counts[0] > 0:
            ansmod[v] = 0
            counts[0] -= 1
elif bp.count(1) <= counts[0]:
    # 3を割り当てる
    for v, b in enumerate(bp):
        if b == 1 and counts[0] > 0:
            ansmod[v] = 0
            counts[0] -= 1
else:
    # 違う方に違うのを割り当てる
    for v, b in enumerate(bp):
        if b == 0 and counts[1] > 0:
            ansmod[v] = 1
            counts[1] -= 1
        if b == 1 and counts[2] > 0:
            ansmod[v] = 2
            counts[2] -= 1
# 残りに余ってるのを割り当てる
for v in range(N):
    if ansmod[v] < 0:
        for i in range(3):
            if counts[i] > 0:
                ansmod[v] = i
                counts[i] -= 1
                break

ans = []
M = [3, 1, 2]
for a in ansmod:
    ans.append(M[a])
    M[a] += 3
print(*ans)


Measured memory_bytes: 160076
#include <iostream>
#include <algorithm>
using namespace std;
static const int N=100;
int main(){
  int n,p[N+1],m[N+1][N+1];
  cin>>n;
  for(int i=1;i<=n;i++){
	cin>>p[i-1]>>p[i];
  }
  for(int i=1;i<=n;i++) m[i][i]=0;
  for(int l=2;l<=n;l++){
	for(int i=1;i<=n-l+1;i++){
	  int j=i+l-1;
	  m[i][j]=(1<<21);
	  for(int k=i;k<=j-1;k++){
		m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
	  }
	}
  }
  cout<<m[1][n]<<endl;
  return 0;
}




Measured memory_bytes: 3140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.TreeMap;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		TreeMap<String, Integer> map = new TreeMap<>();
		HashSet<String> set = new HashSet<>();
		int max = 0;
		for (int i = 0; i < n; i++) {
			String str = br.readLine();
			if (map.containsKey(str)) {
				map.put(str, map.get(str) + 1);
				max = Math.max(max, map.get(str));
			} else {
				map.put(str, 1);
				max = Math.max(max, map.get(str));
			}
		}

		for (String s : map.keySet()) {
			if (map.get(s) == max) {
				System.out.println(s);
			}
		}
	}
}


Measured memory_bytes: 65404
import sys

def main():
    x = int(sys.stdin.readline().rstrip())

    payable = [False] * (x + 1)
    payable[0] = True

    if x < 100:
        print(0)
        sys.exit()
    if 100 <= x <= 105:
        print(1)
        sys.exit()

    for i in range(100,106):
        payable[i] = True
    for i in range(106, x+1):
        payable[i] =  any(payable[i-105:i-99])

    print(payable[x] & 1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3828
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <set>
#define ll long long
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 2e5;

int n;
int fa[N + 1], f[N + 1];
struct Node {
	int	num, val0, val1;
	ll	val;
	inline bool operator <(Node a) const
	{
		if (1ll * val0 * a.val1 == 1ll * val1 * a.val0)
			return num < a.num;
		return 1ll * val0 * a.val1 > 1ll * val1 * a.val0;
	}
} node[N + 1];
set<Node> s;

inline int getfa(int x)
{
	if (f[x] == x)
		return x;
	f[x] = getfa(f[x]);
	return f[x];
}
inline void solve()
{
	for (int i = 1; i <= n; i++)
		f[i] = i;
	while (!s.empty()) {
		Node now = *s.begin();
		if (now.num == 1) {
			s.erase(now);
			continue;
		}
		Node faa = node[getfa(fa[now.num])];
		s.erase(now);
		s.erase(faa);
		f[now.num] = faa.num;
		faa.val += now.val;
		faa.val += 1ll * now.val0 * faa.val1;
		faa.val0 += now.val0;
		faa.val1 += now.val1;
		node[now.num] = now;
		node[faa.num] = faa;
		s.insert(faa);
	}
	return;
}
int main()
{
	n = read();
	for (int i = 2; i <= n; i++)
		fa[i] = read();
	for (int i = 1; i <= n; i++) {
		node[i].num = i;
		node[i].val = 0;
		int x = read();
		if (x) {
			node[i].val0 = 0;
			node[i].val1 = 1;
		} else {
			node[i].val0 = 1;
			node[i].val1 = 0;
		}
		s.insert(node[i]);
	}

	solve();

	printf("%lld\n", node[1].val);
	return 0;
}


Measured memory_bytes: 22532
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] t = s.Split(' ');
            int a = int.Parse(t[0]);
            int b = int.Parse(t[1]);

            Console.WriteLine((a + b) % 24);
            
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

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


ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1)res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

const int B = 1e9 + 7;

signed main() {
	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;
	vector<int> hash(n + 1, 0),bpow(n + 1, 0);
	hash[1] = s[0];
	bpow[0] = 1;
	for (int i = 2; i <= s.size(); i++) {
		bpow[i - 1] = bpow[i - 2] * B;
		hash[i] = (hash[i - 1] * B + s[i - 1]);
	}

	int l = 0, r = 1;
	set<int> se;
	rep(i, m) {
		string t;
		cin >> t;
		if (t == "R++") {
			r++;
		}
		if (t == "L++") {
			l++;
		}
		if (t == "R--") {
			r--;
		}
		if (t == "L--") {
			l--;
		}
		int val = (hash[r] - hash[l] * bpow[r - l]);
		se.insert(val);
	}
	cout << se.size() << endl;

	return 0;
}

Measured memory_bytes: 21912
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main() {
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 0, sz(s)/2){
        ans += s[i] != s[sz(s) - i - 1];
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Qmax = 100;
int Q;
ll A[Qmax], B[Qmax];

int main(){
	cin >> Q;
	//for(int i=0; i<Q; i++) cin >> A[i] >> B[i];

	for(int i=0; i<Q; i++){
		cin >> A[i] >> B[i];
		ll lb=0, ub=1e9;
		while(ub-lb>1){
			ll med = (ub+lb)/2;
			if(med*med <= A[i]*B[i]-1) lb = med;
			else ub = med;
		}
		ll x = lb;
		if(x == 0){
			cout << 0 << endl;
			continue;
		}
		ll y = (A[i]*B[i]-1)/x;
		ll ans = (x==y)?(2*x-1):2*x;
		if(A[i]<=x || B[i]<=x) ans -= 1;
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int> PI;
#define MAX 1000009
int main(){
    int e;
    while(cin>>e,e){
        vector<PI> v3;
        for(int i =0;i<=100;i++){
            PI temp;
            temp.first=pow(i,3);temp.second=i;
            v3.push_back(temp);
        }
        vector<PI> v2;
        for(int i=0; i<=10000;i++){
            PI temp;
            temp.first=pow(i,2); temp.second=i;
            v2.push_back(temp);
        }
        PI min; min.first=INF; min.second=INF;
        for(int i=(int)v3.size()-1; i>=0;i--){
            for(int j=(int)v2.size()-1; j>=0;j--){
                if(v3[i].first+v2[j].first<=e){
                    if(min.second+min.first>e-(v3[i].first+v2[j].first)+v3[i].second+v2[j].second){
                        min.second=v3[i].second+v2[j].second;
                        min.first=e-(v3[i].first+v2[j].first);
                    }
                }
            }
        }
        cout<<min.second+min.first<<endl;
    }
    return 0;
}

Measured memory_bytes: 3248
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int K = Integer.parseInt(sc.get());
		int[] V = new int[N];
		Arrays.setAll(V, $ -> Integer.parseInt(sc.get()));

		int ops = Math.min(N, K);

		int max = 0;
		for (int f = 0; f <= ops; f++) {
			for (int l = 0; l <= ops - f; l++) {
				int[] sorted = new int[f + l];
				System.arraycopy(V, 0, sorted, 0, f);
				System.arraycopy(V, N - l, sorted, f, l);
				Arrays.sort(sorted);
				int sum = 0;
				for (int r = 0; r < (f + l); r++) {
					int next = sorted[r];
					if (r < K - (f + l) && next < 0) continue;
					sum += next;
				}
				max = Math.max(max, sum);
			}
		}
		System.out.println(max);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
	}
}

Measured memory_bytes: 27344
s = input()
if 1<=int(s[:2])<=12 and (int(s[2:])>12 or int(s[2:])==0):
    print('MMYY')
elif 1<=int(s[2:])<=12 and (int(s[:2])>12 or int(s[:2])==0):
    print('YYMM')
elif 1<=int(s[2:])<=12 and 1<=int(s[:2])<=12:
    print('AMBIGUOUS')
else:
    print('NA')

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, char, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

typedef ll Weight;
struct Edge {
	int from, to;
	Weight weight;
	Edge(int src, int dst) :
		from(src), to(dst), weight(0) { }

	Edge(int src, int dst, Weight weight) :
		from(src), to(dst), weight(weight) { }
};
bool operator < (const Edge& e, const Edge& f) {
	return e.weight != f.weight ? e.weight > f.weight :
	e.from != f.from ? e.from < f.from : e.to < f.to;
}

struct UndirectionalCompare {
	bool operator() (const Edge& e, const Edge& f) const {
		if (min(e.from, e.to) != min(f.from, f.to))
			return min(e.from, e.to) < min(f.from, f.to);
		return max(e.from, e.to) < max(f.from, f.to);
	}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
typedef set<Edge, UndirectionalCompare> Edgeset;

struct bridge_solver {

	void visit(const Graph& g, int v, int u,
		Edges& brdg, vector< vector<int> >& tecomp,
		stack<int>& roots, stack<int>& S, vector<bool>& inS,
		vector<int>& num, int& time) {
		num[v] = ++time;
		S.push(v); inS[v] = true;
		roots.push(v);
		for(const auto& e : g[v]) {
			int w = e.to;
			if (num[w] == 0)
				visit(g, w, v, brdg, tecomp, roots, S, inS, num, time);
			else if (u != w && inS[w])
				while (num[roots.top()] > num[w]) roots.pop();
		}
		if (v == roots.top()) {
			brdg.push_back(Edge(u, v));
			tecomp.push_back(vector<int>());
			while (1) {
				int w = S.top(); S.pop(); inS[w] = false;
				tecomp.back().push_back(w);
				if (v == w) break;
			}
			roots.pop();
		}
	}
	void bridge(const Graph& g, Edges& brdg, vector< vector<int> >& tecomp) {
		const int n = g.size();
		vector<int> num(n);
		vector<bool> inS(n);
		stack<int> roots, S;
		int time = 0;
		rep(u, n) if (num[u] == 0) {
			visit(g, u, n, brdg, tecomp, roots, S, inS, num, time);
			brdg.pop_back();
		}
	}
};

int main(void)
{
	int v, e;
	cin >> v >> e;

	Graph g(v);
	rep(i, e) {
		int s, t;
		cin >> s >> t;
		g[s].push_back({s,t,0});
		g[t].push_back({t,s,0});
	}
	bridge_solver solver;
	Edges edge;
	vector<vector<int>> temp;
	solver.bridge(g, edge, temp);
	set<Edge> se;
	for (auto element : edge) {
		if (element.from < element.to) {
			se.emplace(element);
		}
		else {
			se.emplace(element.to, element.from);
		}
	}

	for (auto i : se) {
		cout << i.from << " " << i.to << endl;
	}
	return 0;
}



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

using namespace std;

template <class T> inline T updmax(T& a, T b) { return a = max(a, b); }
template <class T> inline T updmin(T& a, T b) { return a = min(a, b); }

int ng() {
	cout << -1 << endl;
	return 0;
}

int nex[200005][26];
int tmp[26];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	string s, t;
	cin >> s >> t;
	int m = s.length();
	s = s + s + s;
	int x = -1;
	long long ans = 0;
	int n = t.length();
	for (int i = 0; i < n; i++) {
		size_t p = s.find(t[i], x + 1);
		if (p == string::npos) return ng();
		ans += p - x;
		x = p % m;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 848
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	ll N;
	cin>>N;
	vector<ll> arr(N);

	REP(i,N)cin>>arr[i];

	sort(arr.rbegin(),arr.rend());
	ll ans = 0;

	for(int i = 1; i < N; i++){
		ans += arr[i/2];
	}
	
	cout<<ans<<endl;
	return 0;

}



Measured memory_bytes: 4816
package main

import "fmt"

func main() {
	var s, ans string
	fmt.Scan(&s)
	for _, v := range s {
		if v == '0' || v == '1' {
			ans += string(v)
		} else if len(ans) > 0 {
			ans = ans[:len(ans)-1]
		}
	}
	fmt.Println(ans)
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int32_t main()
{
	IOS;
	string s,t;
	cin >> s >> t;
	int c=0;
	repp(i,0,s.size())
	{
		if(s[i]==t[i])
		{
			c++;
		}
	}
	cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  ll m = 1000;
  ll k = 0;
  ll y = 0;
  rep(i,N)
  {
    if(i==y)
    {
      m += A[i] * k;
      k = 0;
    }
    for(int j=i;j<N;j++)
    {
      if(A[j]>A[i])
      {
        y = j;
        k += m/A[i];
        if(m>A[i])
        {
          m -= k * A[i];
        }
        break;
      }
      else if(A[j]<A[i])
      {
        break;
      }
    }
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 3620
a,b=map(int,input().split())
k=list(map(int,input().split()))

sa=0
ans=1

n=k[a-1]

for i in range(a-2,-1,-1):
    if k[i]>n:
        n=k[i]
    tmp=n-k[i]
    if tmp>sa:
        sa=tmp
        ans=1
    elif tmp==sa:
        ans+=1

    

print(ans)


Measured memory_bytes: 14252
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
#include <algorithm>
#include <functional>
//#include<stdlib.h>
using namespace std;
int main() {
	int n;
	cin >> n; int m = 2 * n, a = 0;
	vector<int>l(m);
	for (int k = 0; k < m; k++)	{cin >> l[k];}
	std::sort(l.begin(), l.end(), std::greater<int>());
	for (int k = 1; k < m; k += 2) { a += l[k]; }
	cout << a;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    static ArrayList<Integer>[] map;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        if(x==1){
            System.out.println(n-2);
            System.exit(0);
        }
        map = new ArrayList[n+1];
        for(int i=0;i<=n;i++) map[i]=new ArrayList<>();
        for(int i=0;i<n-1;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            map[a].add(b);
            map[b].add(a);
        }
        long ans = 0;
        for(int i=1;i<=n;i++){
            int first=1,second=0;
            for(int w:map[i]){
                int[] cur = dfs(w,i,x/2-1);
                first+=cur[0];
                second = Math.max(second,cur[1]);
            }
            if(x%2==1) first+=second;
            ans =Math.max(ans,first);
        }
        System.out.println(n-ans);
    }
    static int[] dfs(int root, int from, int level){
        if(level==0) return new int[]{1,map[root].size()-1};
        int first=1,second=0;
        for(int w:map[root]){
            if(w==from) continue;
            int[] cur = dfs(w,root,level-1);
            first += cur[0];
            second += cur[1];
        }
        return new int[]{first,second};
    }
}


Measured memory_bytes: 73120
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		try {
			int width = Integer.parseInt(scanner.nextLine());
			int height = 2;

			int[][] candyLines = new int[height][width];
			for (int x = 0; x < height; x++) {
				String[] tmp = scanner.nextLine().split(" ");
				int[] line = Stream.of(tmp).mapToInt(Integer::parseInt).toArray();
				for (int y = 0; y < width; y++) {
					candyLines[x][y] = line[y];
				}
			}

			int maxCandy = 0;
			for (int i = 0; i < width; i++) {
				int candy = 0;
				for (int l1 = 0; l1 <= i; l1++) {
					candy += candyLines[0][l1];
				}
				for (int l2 = i; l2 < width; l2++) {
					candy += candyLines[1][l2];
				}
				if (candy > maxCandy) {
					maxCandy = candy;
				}
			}
			System.out.print(maxCandy);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			scanner.close();
		}
	}
}


Measured memory_bytes: 27220
#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 rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

int main(void) {
    int n;
    cin >> n;

    string s[n],x;
    int t[n];
    rep (i, n) {
        cin >> s[i] >> t[i];
    }
    cin >> x;

    bool ok = false;

    ll ans = 0;
    rep (i, n) {
        if (ok) {
            ans += t[i];
        }
        if (s[i] == x) ok = true;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
    int N, arr[105], x;
    int sum = 0;
    scanf("%d",&N);

    for(int i=0;i<N;i++){
        scanf("%d",&arr[i]);
        sum+=arr[i];
    }
    int M, p;
    scanf("%d",&M);
    for(int i=0;i<M;i++){
        scanf("%d%d",&p,&x);
        printf("%d\n",sum-arr[p-1]+x);
    }
    return 0;
}


Measured memory_bytes: 128
x,y,a,b,c=map(int,input().split())
l=list(map(int,input().split()))
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))

sum=0
l.sort()
l1.sort()
l2.sort()
ct=1



l=l[a-x:]
l1=l1[b-y:]
#print(l,l1)
l=l[:]+l1[:]
#print(l)


if c>=x+y:
  l2=l2[c-(x+y):]


l=l[:]+l2[:]
l.sort()
#print("EDFF",l)

while ct<=x+y:
  sum+=l[-ct]
  ct+=1
  
print(sum)

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,xx,yy;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>x>>y>>xx>>yy;
      cmp=x-xx;
      cmpp=y-yy;
      cout<<xx+cmpp<<" "<<yy-cmp<<" "<<x+cmpp<<" "<<y-cmp<<"\n";
     

       
return 0;
}


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

using namespace std;

int main( )
{
	string str, cmd, p;
	int q;
	int a, b;

	cin>>str;
	cin>>q;
	
	while( q-- ) {	
		cin>>cmd;
		if( "print" == cmd ) {
			cin>>a>>b;
			cout<<str.substr( a, b-a+1 )<<endl;
		} else if( "reverse" == cmd ) {
			cin>>a>>b;
			char t;
			for( int i=0; i<=(b-a)/2; i++ ) {
				t = str[ a+i ];
				str[ a+i ] = str[ b-i ];
				str[ b-i ] = t;
			}
		} else if( "replace" == cmd ) {
			cin>>a>>b>>p;
			str.replace( a, b-a+1, p );
		}
	}
	
	return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>

int main(void){
  int n, a[100], i, j, minj, x, sum;

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

  sum = 0;

  for (i = 0; i < n; i++) {
    minj = i;
    for (j = i; j < n; j++) {
      if (a[j] < a[minj]) {
        minj = j;
      }
    }
    if (i != minj) {
      sum++;
      x = a[i];
      a[i] = a[minj];
      a[minj] = x;
    }
  }

  for (i = 0; i < n; i++) {
    if (i < n - 1) {
      printf("%d ", a[i]);
    }
    else if (i == n - 1) {
      printf("%d\n", a[i]);
      printf("%d\n", sum);
    }
  }
}


Measured memory_bytes: 2124
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a;
	getline(cin,a);
	for(int i=0;i<=a.size()-5;i++){
		if(a[i]=='a'&&a[i+1]=='p'&&a[i+2]=='p'&&a[i+3]=='l'&&a[i+4]=='e'){
			a[i]='p';
			a[i+1]='e';
			a[i+2]='a';
			a[i+3]='c';
			a[i+4]='h';
		}
		else if(a[i]=='p'&&a[i+1]=='e'&&a[i+2]=='a'&&a[i+3]=='c'&&a[i+4]=='h'){
			a[i]='a';
			a[i+1]='p';
			a[i+2]='p';
			a[i+3]='l';
			a[i+4]='e';
		}
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 1172
import numpy as np
N = int(input())
num = list(map(int, input().split()))

sumz = np.zeros(N+1, dtype=int)
count = np.zeros(N+1, dtype=int)
for i in range(1, N+1):
    sumz[i] = sumz[i-1] + num[i-1]

sortedsumz = np.sort(sumz)

def CC(a, b):
    ans = 1
    mulz = 1
    for i in range(b-a+1, b+1):
        ans *= i
    for i in range(1,a+1):
        mulz *= i
    return int(ans/mulz)

ways = 0
for i in range(1, N+1):
    if sortedsumz[i] == sortedsumz[i-1]:
        count[i] = count[i-1]+1
    elif count[i-1] >= 1:
        ways += CC(2, count[i-1]+1)

    #if sortedsumz[i-1] == 0:
    #    nzero += 1

if count[N] >= 1:
    ways += CC(2, count[N] + 1)
print(ways)


Measured memory_bytes: 49984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	char c;cin >> c;
	if(c=='A' || c=='T'){
		if(c=='A') cout << 'T' << endl;
		else cout << 'A' << endl;
	}
	else{
		if(c=='C') cout << 'G' << endl;
		else cout << 'C' << endl;
	}
}

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

class Program
{
    public class Dice
    {
        public int[] Face {get; set;}
        public void Nua(char dir)
        {
            int[] f = Face.Clone() as int[];
            switch (dir)
            {
                case 'N':
                {
                    Face[0] = f[1];
                    Face[1] = f[5];
                    Face[5] = f[4];
                    Face[4] = f[0];
                }
                break;
                case 'E':
                {
                    Face[2] = f[0];
                    Face[0] = f[3];
                    Face[3] = f[5];
                    Face[5] = f[2];
                }
                break;
                case 'W':
                {
                    Face[3] = f[0];
                    Face[0] = f[2];
                    Face[2] = f[5];
                    Face[5] = f[3];
                }
                break;
                case 'S':
                {
                    Face[1] = f[0];
                    Face[5] = f[1];
                    Face[4] = f[5];
                    Face[0] = f[4];
                }
                break;
            }
        }
    }
    static void Main(string[] args)
    {
        var aid = new Dice { Face = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray()};
        foreach (var f in Console.ReadLine())
        {
            aid.Nua(f);
        }
        Console.WriteLine(aid.Face[0]);
    }
}
















































































































































































































































































































































































































































































































































































































































































































































































Measured memory_bytes: 9548
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100005
#define INF 0x3f3f3f3f
#define MS(x, i) memset(x, i, sizeof x)
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define MOD 998244353
#define NOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

inline int read()
{
    int res = 0, sgn = 1;
    char c = getchar();

    while(c < '0' || c > '9')
    {
        if(c == '-')
            sgn = -1;
        c = getchar();
    }

    while(c >= '0' && c <= '9')
    {
        res = res * 10 + c - '0';
        c = getchar();
    }

    return res * sgn;
}

int main()
{
    string s;
    cin >> s;
    for(int i = 0; i < s.length(); i++)
        cout << "x";
    cout << endl;
}


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

using namespace std;

const int MAXN = 1e5 + 7;
const int INF = 1e9 + 7;

int d[MAXN];

signed main() {
	//freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	for (int i = 0; i < MAXN; ++i) d[i] = -INF;

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

	for (int i = 0; i < m; ++i) {
	 	int l, r;
	 	cin >> l >> r;
	 	d[r] = max(d[r], l);
	}
	
	int last = -1, ans = 0;
	for (int i = 0; i < MAXN; ++i) {
		if (last <= d[i]) {
		 	++ans;
		 	last = i;
		}
	}

	cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 768
#include"bits/stdc++.h"
using namespace std;

void Main() {
  double L;
  cin >> L;

  cout << (L / 3) * (L / 3) * (L / 3) << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



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

typedef long long ll;
typedef long double ld;

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

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

int main(){

    ll A, B;
    char op;

    cin >> A >> op >> B;

    cout << (op == '+' ? A + B : A - B) << endl;

    return 0;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'



void solve(){
  string s;
  cin >> s;
  map<char, int> m;
  forn(i, len(s)){
    m[s[i]]++;
  }
  for(auto pp: m){
    if (pp.ss%2){
      cout << "No";
      return;
    }
  }
  cout << "Yes";
}

int main() {
  ios::sync_with_stdio(false); 
  // cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 




*/

Measured memory_bytes: 3520
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

ll N, M;
ll dp[1001][(1<<12)];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i,M+1) rep(j,(1<<N)) dp[i][j] = linf;
    dp[0][0] = 0;
    rep(i,M) {
        int a, b; cin >> a >> b;
        int mask = 0;
        rep(j,b) {
            int c; cin >> c;
            c--;
            mask |= (1<<c);
        }
        rep(j,(1<<N)) dp[i+1][j] = dp[i][j];
        rep(j,(1<<N)) {
            dp[i+1][j|mask] = min(dp[i+1][j|mask], dp[i][j]+a);
        }
    }
    if (dp[M][(1<<N)-1] == linf) cout << -1 << endl;
    else cout << dp[M][(1<<N)-1] << endl;
}

Measured memory_bytes: 32256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define SET(x, a) memset(x, a, sizeof x);
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pld pair<ld, ld>
const ll MOD = 1000000007;
const ll INF = 1000000000;
template <class T> T read(T &x) {
  char c;
  int flag = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-')
      flag *= -1;
  x = c - '0';
  while ((c = getchar()) >= '0' && c <= '9')
    x = x * 10 + c - '0';
  x *= flag;
  return x;
}
map<int, int> cnt[2];
int a[100005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    cnt[i % 2][x]++;
  }
  int ans = 0;
  int fimx = -1;
  for (auto i : cnt[0]) {
    if (i.se > cnt[0][fimx])
      fimx = i.fi;
  }
  int mx = 0;
  for (auto i : cnt[1])
    if (i.fi != fimx)
      mx = max(mx, i.se);
  int glbmx = (n >> 1) - cnt[0][fimx] + (n >> 1) - mx;
  fimx = -1;
  mx = 0;
  for (auto i : cnt[1]) {
    if (i.se > cnt[1][fimx])
      fimx = i.fi;
  }
  mx = 0;
  for (auto i : cnt[0])
    if (i.fi != fimx)
      mx = max(mx, i.se);
  glbmx = min(glbmx, (n >> 1) - cnt[1][fimx] + (n >> 1) - mx);
  cout << glbmx << endl;
}

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

#define pb push_back
#define mp make_pair
#define ld long double
#define ll long long int
#define f(i,g,n) for(int i=g;i<=n;i++)
#define rf(i,g,n) for(int i=n;i>=g;i--)

const int N=300;
ll A[N][N],B[N][N];

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

	ll n,m,l,a,b,c,q;
	cin>>n>>m>>l;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			A[i][j] = INT_MAX;
	}
	while(m--)
	{
		cin>>a>>b>>c;
		a--,b--;
		A[a][b] = c;
		A[b][a] = c;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			B[i][j] = A[i][j];
	}
	for(int k=0;k<n;k++)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n && j!=i;j++)
				B[j][i] = B[i][j] = min(B[i][j],B[i][k]+B[k][j]);
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			(B[i][j] <= l) ? B[i][j] = 1 : B[i][j] = INT_MAX;
	}
	for(int k=0;k<n;k++)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n && j!=i;j++)
				B[j][i] = B[i][j] = min(B[i][j],B[i][k]+B[k][j]);
		}
	}
	cin>>q;
	while(q--)
	{
		cin>>a>>b;
		if(B[a-1][b-1] > n)
			cout<<"-1\n";
		else
			cout<<B[a-1][b-1]-1<<"\n";
	}

	return 0;
}

Measured memory_bytes: 1920
#include <iostream>

using namespace std;


int ans[1005][1005];

int main() {
  int h,w,a,b;
  cin >> h >> w >> a >> b;

  for(int i = 0; i < h; i++) {
    if(i < b) {
      for(int j = 0; j < w; j++) {
	if(j < a) ans[i][j] = 0;
	else ans[i][j] = 1;
      }
    }
    else {
      for(int j = 0; j < w; j++) {
	if(j < a) ans[i][j] = 1;
	else ans[i][j] = 0;
      }
    }
  }

  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      cout << ans[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 5120
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename T = long long>
class SegmentTree {
public:
    std::vector<T> ary;
    int n;
    const T default_value = std::numeric_limits<T>::max() / 4;
    SegmentTree(int n) {
        this->n = 1;
        while (this->n < n) this->n *= 2;
        ary.resize(this->n * 2 - 1, 1<<30);
    }
    T ope(T l, T r) {
        return std::min(l, r);
    }
    void update(int k, T d) {
        k += n - 1;
        ary[k] = d;
        while (k > 0) {
            k = (k - 1) / 2;
            ary[k] = ope(ary[2 * k + 1], ary[2 * k + 2]);
        }
    }
    T query(int a, int b) {
        return query(a, b, 0, n, 0);
    }
    T query(int a, int b, int l, int r, int i) {
        if (a <= l && b >= r) return ary[i];
        if (a >= r || b <= l) return default_value; // min
        int m = (l + r) / 2;
        T vl = query(a, b, l, m, 2 * i + 1);
        T vr = query(a, b, m, r, 2 * i + 2);
        return ope(vl, vr);
    }
};

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    SegmentTree<> seg(n);
    REP(i,0,n) seg.update(i,a[i]);
    LL ans = 0;
    REP(i,0,n) {
        int l, r;
        {
            int ok = i, ng = -1;
            while (abs(ok - ng) > 1) {
                int mid = (ok + ng) / 2;
                if (seg.query(mid,i+1) == a[i]) ok = mid;
                else ng = mid;
            }
            l = abs(i - ok) + 1;
        }
        {
            int ok = i, ng = n;
            while (abs(ok - ng) > 1) {
                int mid = (ok + ng) / 2;
                if (seg.query(i,mid+1) == a[i]) ok = mid;
                else ng = mid;
            }
            r = abs(i - ok) + 1;
        }
        ans += a[i] * (1LL * l * r);
    }
    cout << ans << endl;
}

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

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

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  bool ans = true;
  while (s.size() != 0 && ans == true) {
    if (s.substr(0, 5) == "maerd")
      s.erase(s.begin(), s.begin() + 5);
    else if (s.substr(0, 5) == "esare")
      s.erase(s.begin(), s.begin() + 5);
    else if (s.substr(0, 6) == "resare")
      s.erase(s.begin(), s.begin() + 6);
    else if (s.substr(0, 7) == "remaerd")
      s.erase(s.begin(), s.begin() + 7);
    else
      ans = false;
  }
  if (ans)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int dp[11][156];
int n,k,s;

void init(){
  for(int i=0;i<11;i++){
    for(int j=0;j<156;j++)dp[i][j]=0;
  }
  dp[0][0]=1;
}

int main(){

  while(1){
    cin>>n>>k>>s;
    if(n==0&&k==0&&s==0)break;
    init();
    for(int i=1;i<=k;i++){
      for(int j=1;j<=s;j++){
	if(j-i>=0)dp[i][j]+=dp[i][j-i];
	if(j-i>=0)dp[i][j]+=dp[i-1][j-i];
	if(j-n-1>=0)dp[i][j]-=dp[i-1][j-n-1];
      }
    }
    cout<<dp[k][s]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

// int MOD = 998244353;
int MOD = 1000000007;

#define N 100010
int par[N];
int rnk[N];
int weight[N];

void init(int n){
    for(int i=0;i<n;i++){
        par[i] = i;
        weight[i] = 1;
        rnk[i] = 0;
    }
}

int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}

void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rnk[x] < rnk[y]){
        weight[find(y)] += weight[find(x)];
        par[x] = y;
    }
    else{
        weight[find(x)] += weight[find(y)];
        par[y] = x;
        if(rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x,int y){
    return find(x) == find(y);
}

//----------------------------------------------------------------
signed main(){

	string s;
	cin >> s;
	if(s == "Sunny")cout << "Cloudy";
	if(s == "Cloudy")cout << "Rainy";
	if(s == "Rainy")cout << "Sunny";
	cout << endl;

	

	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2017-final.contest.atcoder.jp/tasks/ddcc2017_final_b
// rm -r -f test;oj dl https://abc141.contest.atcoder.jp/tasks/abc141_b

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{

    int N;
    string S;
    cin >> N >> S;
    ve<bitset<28>> A(800,0);
    ve<vi> AA(800,vi(26,0));
    int ii = 0;
    rep(i,N){
        A[ii] |= (1<<(S[i]-'a'));
        AA[ii][S[i]-'a']++;
        if((i+1)%700 == 0) ii++;
    }
    
    int Q;
    cin >> Q;
    
    vi ans;
    
    rep(i,Q){
        int a;
        cin >> a;
        if(a == 1){
            int b;
            char c;
            cin >> b >> c;
            b--;
            if(c == S[b]) continue;
            if(AA[b/700][c-'a'] == 0) A[b/700][c-'a'] = 1;
            AA[b/700][c-'a']++;
            AA[b/700][S[b]-'a']--;
            if(AA[b/700][S[b]-'a'] == 0) A[b/700][S[b]-'a'] = 0;
            
            S[b] = c;
            
        }else{
            int s,t;
            cin >> s >> t;
            s--,t--;
            bitset<28> B = 0;
            
            while (s%700 != 0 && s <= t) {
                B |= (1<<(S[s]-'a'));
                s++;
            }
            while (s+700 <= t) {
                B |= A[s/700];
                s+= 700;
            }
            while (s <= t) {
                B |= (1<<(S[s]-'a'));
                s++;
            }
            
            int an = 0;
            rep(i,29){
                if(B[i]) an++;
            }
            //cout << endl;
            //cout << B << endl;
            
            ans.pb(an);
            
        }
    }
    
    rep(i,ans.size()) cout << ans[i] << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 1156
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#define ll long long
using namespace std;
int main(){
	int n,m;
	cin>>n;
	map<string,int> m1,m2;
	string s;
	for(int i=0;i<n;i++){
		cin>>s;
		m1[s]++;
	}
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>s;
		m2[s]++;
	}
	map<string, int>::iterator it;
	int ans=0;
	for(it=m1.begin();it!=m1.end();it++){
		s=it->first;
		if(m1[s]-m2[s]>ans){
			ans=m1[s]-m2[s];
		}
	}
	if(ans<0){
		cout<<0<<endl;
	}else{
		cout<<ans<<endl;
	} 
    return 0;
}

Measured memory_bytes: 256