akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long nagai;

int main()
{
	ios::sync_with_stdio(false);
	nagai a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	a = min(a, 2 * c);
	b = min(b, 2 * c);
	nagai two = min(a + b, 2 * c);
	nagai mn = min(x, y);
	nagai ans = two * mn + (x - mn) * a + (y - mn) * b;
	nagai mx = x + y - mn;
	ans = min(ans, mx * two);
	cout << ans << '\n';
}


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

const int N = 55;
char s[N][N];
const int d[] = { -1, 0, 1, 0};
int n, m;
int dist[N][N];
bool seen[N][N];

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) scanf("%s", s[i]);

    queue< int> q;
    q.emplace(0);
    seen[0][0] = true;

    while (!q.empty()) {
        int x = q.front() / m;
        int y = q.front() % m;
        q.pop();
        for (int i = 0; i < 4; ++i) {
            int a = x + d[i];
            int b = y + d[i ^ 1];
            if (a < 0 or b < 0 or a >= n or b >= m or seen[a][b]) continue;
            if (s[a][b] == '#') continue;
            seen[a][b] = true;
            dist[a][b] = dist[x][y] + 1;
            q.emplace(a * m + b);
        }
    }

    if (!seen[n - 1][m - 1]) return !printf("-1\n");

    int res = 0;
    for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) if (s[i][j] == '.') res++;
    printf("%d\n", res - dist[n - 1][m - 1] - 1);
}

Measured memory_bytes: 256
n = int(input())
h = [int(x) for x in input().split()]
h.insert(0, -1)
dp = [-1] * (n+1)
dp[1] = 0
dp[2] = abs(h[1] - h[2])

for i in range(3, n+1):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), 
                dp[i-2] + abs(h[i] - h[i-2]))

print(dp[n])

Measured memory_bytes: 52464
using System;

class ITP1_8_B
{
  static void Main()
  {
    while(true)
    {
      char[] s = Console.ReadLine().ToCharArray();
      if (s[0].ToString() == "0" && s.Length == 1) break;
      int sum = 0;
      for (int i = 0; i < s.Length; i ++)
      {
        sum += int.Parse(s[i].ToString());
      }
      Console.WriteLine(sum);
    }
  }
}



Measured memory_bytes: 15924
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for(int i = a; i < b; i++)
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<LL> a(m);
    rep(i, 0, m) cin >> a[i];
    if(n >= m) {
        cout << 0 << endl;
        return 0;
    }
    sort(a.begin(), a.end());
    vector<LL> b(m-1);
    rep(i, 0, m-1)  b[i] = a[i+1] - a[i];
    sort(b.rbegin(), b.rend());
    LL tot = 0;
    for(int i = 0; i+1 < n; i++){
        tot += b[i];
    }   
    LL ans = a.back()-a[0] - tot;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.ArrayDeque

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val s = br.readLine()!!.reversed()
    val dp = Array(s.length + 1) { LongArray(13) } // dp[桁数][あまり]
    dp[0][0] = 1
    var digitNum = 1
    val mod = 1000000007
    for ((i, c) in s.withIndex()) {
        if (c != '?') {
            val current = ((c - '0') * digitNum) % 13
            for (remain in 0 until 13) {
                dp[i + 1][(remain + current) % 13] = (dp[i + 1][(remain + current) % 13] + dp[i][remain]) % mod
            }
        } else {
            for (currentC in 0..9) {
                val current = (currentC * digitNum) % 13
                for (remain in 0 until 13) {
                    dp[i + 1][(remain + current) % 13] = (dp[i + 1][(remain + current) % 13] + dp[i][remain]) % mod
                }
            }
        }


        digitNum = (digitNum * 10) % 13
    }
    out.println(dp[s.length][5])
}

/** edge info */
data class Edge(val from: Int, val to: Int, val cost: Long)

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 50536
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse = True)

def binary(mini,maxi,a,b): #a>b
  if maxi == mini + 1:
    if L[maxi] > a - b:
      return maxi
    elif L[mini] > a - b:
      return mini
    else:
      return False
  elif maxi == mini:
    if L[maxi] > a - b:
      return maxi
    else:
      return False
  else:
    mid = (mini+maxi)//2
    if L[mid] > a - b:
      return binary(mid,maxi,a,b)
    else:
      return binary(mini,mid,a,b)
ans = 0
for a in range(0, N-2):
  for b in range(a+1, N-1):
    tmp = binary(b+1, N-1, L[a], L[b])
    if tmp:
      ans += tmp - b
print(ans)



Measured memory_bytes: 75252
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	string S;
	cin >> S;

	vector<int> cnt(26, 0);
	for(auto it=S.begin(); it!=S.end(); it++)
		cnt[*it - 'a']++;

	string ret("yes");
	for(int i=0; i<26; i++)
		if(cnt[i] > 1)
			ret = "no";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
n,w=map(int,input().split())
l=[[0,0]]
for _ in range(n):
    l.append(list(map(int,input().split())))
dp=[[10**10]*(n*(10**3)+1) for _ in range(n+1)]
for k in range(n+1):
    dp[k][0]=0
for i in range(1,n+1):
    for j in range(0,n*(10**3)+1):
        if j>=l[i][1]:
            dp[i][j]=min(dp[i-1][j-l[i][1]]+l[i][0],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
print(max([i for i,x in enumerate(dp[n]) if x<=w]))

Measured memory_bytes: 119148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

#define NIL -1

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    int X, Y, Z;
    rep(i, M) {
        cin >> X >> Y >> Z;
        X--; Y--;
        G[X].push_back(Y); G[Y].push_back(X);
    }
    vector<int> check(N, NIL);
    int tmp = 1;
    rep(i, N) {
        if (check[i] == NIL && !G[i].empty()) {
            check[i] = tmp;
            queue<int> q;
            q.push(i);
            while (!q.empty()) {
                int now = q.front(); q.pop();
                rep(j, G[now].size()) {
                    if (check[G[now][j]] == NIL) {
                        check[G[now][j]] = tmp;
                        q.push(G[now][j]);
                    }
                }
            }
            tmp++;
        }
    }
    int ans = vmax(check);
    //rep(i, N) cout << check[i] << " ";
    //cout << endl;
    //cout << ans << endl;
    rep(i, N) {
        if (check[i] == NIL) ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 9860
#include <iostream>

#define mod 998244353
#define MAX 8000
#define ll long long
using namespace std;

ll pw(ll x,ll a){
	ll ans = 1;
	while(a){
		while(a%2==0){
			a /= 2;//a /= 2;
			x = (x*x)%mod;
		}
		ans = (ans*x)%mod;
		--a;
	}
	return ans;
}

ll inv[MAX],fact[MAX],fi[MAX];

void inverse(){
	int i;
	inv[1] = 1;
	for(i=2;i<MAX;i++){
		inv[i] = mod - (mod/i)*inv[mod%i]%mod;
	}
}

void factinv(){
	int i;
	fact[0] = fi[0] = 1;
	for(i=1;i<MAX;i++){
		fact[i] = fact[i-1]*i%mod;
		fi[i] = (fi[i-1]*inv[i])%mod;
	}
}

ll comb(ll n,ll k){
	if(n<0 || k<0 || n<k){
		return 0;
	}else{
		return fact[n]%mod*fi[k]%mod*fi[n-k]%mod;
	}
}

int main(){
	long long k,n,i,j,ans[5010];
	cin >> k >> n;
	inverse();
	factinv();
	for(i=2;i<=k+1;i++){
		ans[i] = 0;
		if(i%2==1){
			ll m = (i-1)/2;
			for(j=0;j<=m;j++){
				//cout << pw(2,j)*comb(m,j)%mod*comb(n+k-i,n-j)%mod << endl;
				ans[i] += pw(2,j)*comb(m,j)%mod*comb(n+k-i,n-j)%mod;
				ans[i] %= mod;
			}
			cout << ans[i] << endl;
		}else{
			ll m = i/2 - 1;
			for(j=0;j<=m;j++){
				ans[i] += pw(2,j)*comb(m,j)%mod*(comb(n+k-i,n-j)+comb(n+k-i-1,n-j-1))%mod;
				ans[i] %= mod;
			}
			cout << ans[i] << endl;
		}
	}
	for(i=k+2;i<=2*k;i++){
		cout << ans[2*k+2-i] << endl;
	}
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll nCr(int n, int r){
  ll num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N;i++) cin >> A[i];
    int max_n = 0;
    int max_n2 = 0;
    vector<int> B = A;
    sort(all(B));
    max_n = B.back();
    max_n2 = B[B.size() - 2];
    if(max_n == max_n2) for(int i = 0; i < N; i++) cout << max_n << endl;
    else{
        for(int i = 0; i < N; i++){
            if(A[i] == max_n) cout << max_n2 << endl;
            else cout << max_n << endl;
        }
    }
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int q; cin >> q;
    set<int> S;
    rep(i,q){
        int query; cin >> query;
        if(query == 0){
            int x; cin >> x;
            S.insert(x);
            cout << S.size() << endl;
        }else if(query == 1){
            int x; cin >> x;
            cout << S.count(x) << endl;
        }else if(query == 2){
            int x; cin >> x;
            S.erase(x);
        }
        
    }
}


Measured memory_bytes: 12372
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
int main()
{
  string s,t; cin >> s >> t;
  int n = s.size(), m = t.size();
  int idx = -1;
  vector<string> res;
  for (int i = n - 1; i >= 0; --i) {
    int k = i - m + 1;
    if(k < 0) break;
    bool f = true;
    rep(j,m) {
      if(s[k + j] != t[j] && s[k + j] != '?') {
	f = false;
	break;
      }
    }
    if(f) {
      idx = k;
      string ss = s;
      for (int j = k; j < k + m; ++j) {
	ss[j] = t[j - k];
      }
      rep(i,n) {
	if(ss[i] == '?') ss[i] = 'a';
      }
      res.push_back(ss);
    }
  }
  if(idx == -1) cout << "UNRESTORABLE" << "\n";
  else {
    sort(res.begin(), res.end());
    cout << res[0] << "\n";
  }

  return 0;
}


Measured memory_bytes: 3636
th,ta,ah,aa=map(int,input().split(" "))
#print(th,ta,ah,aa)
#print((ah-1)//ta,(th-1)//aa)
if (ah-1)//ta > (th-1)//aa:
  print("No")
elif (ah-1)//ta <= (th-1)//aa:
  print("Yes")

Measured memory_bytes: 61692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
int n,q;
vector<int> v[200100];
ll o[200100],ans[200100];
void go(int cr,int pa,ll sum)
{
    sum+=o[cr];
    ans[cr]=sum;
    for(int i=0;i<v[cr].size();i++)
    {
        if(v[cr][i]==pa)
            continue;
        go(v[cr][i],cr,sum);
    }

}
int main() {

    cin>>n>>q;
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    while(q--)
    {
        int p,x;
        cin>>p>>x;
        o[p]+=x;

    }
    go(1,0,0);
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<' ';
    return 0;
}
// ABAB
//


Measured memory_bytes: 28800
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] b = new int[n - 1];
		Arrays.setAll(b, i -> sc.nextInt());
		
		int[] a = new int[n];
		a[0] = b[0];
		a[n - 1] = b[n - 2];
		for (int i = 1; i < n - 1; i++) {
			a[i] = Math.min(b[i - 1], b[i]);
		}
		
		int sum = Arrays.stream(a).sum();
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 26964
#include <cstdio>

using namespace std;

char cmd[7] = {"UFRDBL"};

int dy[6][6][8] = {
	{{0,0,0,1,0,0,0,0},{0,0,-1,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},	{0,0,0,0,0,0,0,0}},
	{{ 0, 0, 0, 0, 0, 0, 0, 0},{ 0, 0, 1, 2, 0, 0, 0, 0},{ 0,-1, 0, 1, 2, 0, 0, 0},{ 0,-2,-1, 0, 1, 0, 0, 0},{ 0, 0,-2,-1, 0, 0, 0, 0},{ 0, 0, 0, 0, 0, 0, 0, 0}},
	{{0,0,0,3,0,0,0,0},{0,0,0,1,0,0,0,0},{0,0,0,-2,0,1,3,0},{0,0,0,-2,-1,0,1,0},{0,0,0,-2,0,0,0,0},{0,0,0,-2,0,0,0,0}},
	{{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,1,0,0,0,0},{0,0,-1,0,0,0,0,0}},
	{{0,0,3,2,0,0,0,0},{0,0,0,0,0,0,0,0},{3,0,0,0,0,-2,0,1},{2,0,0,0,0,-3,-1,0},{0,0,0,0,0,0,0,0},{0,0,-2,-3,0,0,0,0}},
	{
	{ 0, 0, 2, 0, 0, 0, 0, 0},
	{ 0, 0, 2, 0, 0, 0, 0, 0},
	{ 0, 1, 2, 0, 0, 0, 0,-1},
	{-1, 0, 2, 0, 0, 0, 0,-3},
	{ 0, 0,-1, 0, 0, 0, 0, 0},
	{ 0, 0,-3, 0, 0, 0, 0, 0}}
};

int dx[6/*コマンド数*/][6/*縦*/][8/*横*/] = {
	{{0,0,1,0,0,0,0,0},{0,0,0,-1,0,0,0,0},{6,6,-2,-2,-2,-2,-2,-2},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0}},
	{{ 0, 0, 0, 0, 0, 0, 0, 0},{ 0, 0, 2, 1, 0, 0, 0, 0},{ 0, 2, 1, 0,-1, 0, 0, 0},{ 0, 1, 0,-1,-2, 0, 0, 0},{ 0, 0,-1,-2, 0, 0, 0, 0},{ 0, 0, 0, 0, 0, 0, 0, 0}},
	{{0,0,0,3,0,0,0,0},{0,0,0,3,0,0,0,0},{0,0,0,0,1,0,-3,0},{0,0,0,0,0,-1,-3,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0}},
	{{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{2,2,2,2,2,2,-6,-6},{0,0,1,0,0,0,0,0},{0,0,0,-1,0,0,0,0}},
	{{0,0,-2,-3,0,0,0,0},{0,0,0,0,0,0,0,0},{2,0,0,0,0,-3,1,0},{3,0,0,0,0,-2,0,-1},{0,0,0,0,0,0,0,0},{0,0,3,2,0,0,0,0}},
	{{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{1,0,0,0,0,0,0,-5},{0,-1,0,0,0,0,0,-5},{0,0,5,0,0,0,0,0},{0,0,5,0,0,0,0,0}}
};

void turn(char table[6][9],int icmd){
	char tmp[6][9], i, j;
	for(i = 0;i < 6;i++){
		for(j = 0;j < 8;j++){
			tmp[i + dy[icmd][i][j]][j + dx[icmd][i][j]] = table[i][j];
		}
		tmp[i][j] = '\0';
	}
	for(i = 0;i < 6;i++){
		for(j = 0;j < 8;j++){
			table[i][j] = tmp[i][j];
		}
		table[i][j] = '\0';
	}
}

int main(void){
	int i;
	char c, table[6][9] = {{"..rr...."},{"..rr...."},{"ggyybbww"},{"ggyybbww"},{"..oo...."},{"..oo...."}};
	while((c = getchar()) != '\n'){
		for(i = 0;i < 6;i++){
			if(cmd[i] == c){
				turn(table,i);
			}
		}
	}
	for(i = 0;i < 6;i++){
		printf("%s\n",table[i]);
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }

int main() {
  int T; cin >> T;
  rep(i,T) {
    ll A, B, C, D; cin >> A >> B >> C >> D;
    if (A<B) { cout << "No" << endl; continue; }
    if (B>D) { cout << "No" << endl; continue; }
    if (C>=B) { cout << "Yes" << endl; continue; }
    if (D%B==0) {
      string result = (A%B<=C) ? "Yes" : "No";
      cout << result << endl; 
      continue;
    }
    ll gbd = gcd(B,D);
    string result = ((B-gbd)+A%gbd<=C) ? "Yes" : "No";
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		int n = 0;
		for(; a <= b; a++){
			if(c % a == 0)
				n++;
		}

		System.out.println(n);
	}
}



Measured memory_bytes: 26412
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int64_t n;
  cin >> n;
  int64_t ans=n+1;
  int64_t k=1;
  while(k*k<=n){
    if(n%k==0){
      ans=min(ans,k+n/k);
    }
    k++;
  }
  cout << ans-2 << endl;
}

Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : December 22 2019 17:31:15 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

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


    time_taken();
    return 0;
}

Measured memory_bytes: 256
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
char dic[2001234][13];
int h1(int x){
	return x % 2001234;
}
int h2(int x){
	return 1 + (x % 2001233);
}
int ht(int key, int i){
	return (h1(key)+(i*h2(key))) % 2001234;
}
int charnum(char a){
	if(a=='A') return 1;
	else if(a== 'C') return 2;
	else if(a=='G') return 3;
	else if(a== 'T') return 4;
	else return 0;
}
ll genkey(char *str){
	int i;ll j=1;
	ll key = 0;
	for(i=0;i<(int)strlen(str);i++){
		key += 	j*charnum(str[i]);
		j *= 5;
	}
#ifdef DBG
	cout << key << endl;
#endif
	return key;
}
void insert(char *str){
	int i=0;
	ll key=genkey(str);
	while(231231){
		int j = ht(key, i);
#ifdef DBG
		cout <<j<<endl;
#endif
		if(strlen(dic[j])==0){
			strcpy(dic[j], str);
			return;
		}else i++;
	}
}
bool search(char *str){
	int i=0;
	ll key=genkey(str);
	while(23485743){
		int j = ht(key, i);
#ifdef DBG
		cout <<j<<endl;
#endif
		if(strcmp(dic[j], str) == 0)
			return true;
		else if(strlen(dic[j])==0) return false;
		else i++;
	}
}
int main(){
	int i, n;
	char str[13];
	string command;
	scanf("%d", &n);
	for(i=0;i<n;i++){
		cin >> command;
		scanf("%s", str);
		if(command == "insert"){
			insert(str);
		}else if(command == "find"){
			if(search(str))printf("yes\n");
			else printf("no\n");
		}
	}
}



Measured memory_bytes: 28544
#include<stdio.h>
#include<stdlib.h>


struct node
{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;


void preorder(Node);
void inorder(Node);
void insert(int);

Node treeSearch(Node x, int k){
  if(x==NULL) return x;
  else if(x->key==k) return x;
  
  else if(x->key<k) return treeSearch(x->right,k);
  else return treeSearch(x->left,k);

}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL)
    {
      y=x;
      if(z->key<x->key) x=x->left;
      else x=x->right;
    }
  z->parent=y;
  if(y==NIL) root=z;
  else if( z->key < y->key ) y->left = z;
  else y->right = z;



}

void inorder(Node x){
  if(x!=NIL)
    {
      inorder(x->left);
      printf(" %d",x->key);
      inorder(x->right);
    }
}
void preorder(Node x){
  if(x!=NIL)
    {
      printf(" %d",x->key);
      preorder(x->left);
      preorder(x->right);
    }
    
}

int main()
{
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ )
    {
      scanf("%s", com);
      if ( com[0] == 'f' )
	{
	  scanf("%d", &x);
	  Node t = treeSearch(root, x);
	  if ( t != NIL ) printf("yes\n");
	  else printf("no\n");
	} else if ( com[0] == 'i' )
	{
	  scanf("%d", &x);
	  insert(x);
	} else if ( com[0] == 'p' )
	{
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	} 
    }

  return 0;
}

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

using namespace std;

typedef long long ll;

struct Lex {
  Lex(){}
  void load(string s){ S = s; }
  int solve(){
    char *p = (char*)S.c_str();
    return eval(&p);
  };
  int eval(char** p){
    if (isdigit(**p)){
      int r = 0;
      while (isdigit(**p)){
        r = r * 10 + **p - '0';
        (*p)++;
      }
      return (r + 1) / 2;
    }
    vector<int> costs;
    while (**p == '['){
      consume(p, '[');
      costs.push_back(eval(p));
      consume(p, ']');
    }
    sort(costs.begin(), costs.end());
    int n = (costs.size() + 1) / 2;
    int r = 0;
    for (int i = 0; i < n; i++) r += costs[i];
    return r;
  }
  void consume(char** p, char expected){
    assert(**p == expected);
    (*p)++;
  }
  string S;
};

int main()
{
  int n;
  cin >> n;
  for (int i = 0; i < n; i++){
    string s;
    cin >> s;
    Lex lex;
    lex.load(s);
    cout << lex.solve() << endl;
  }

  return 0;
}

Measured memory_bytes: 1284
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;
}

void get_permutation(vs& perm, string s){
    vector<char> vc;
    for (char c : s) vc.push_back(c);

    sort(vc.begin(), vc.end());
    do {
        string t = "";
        for (char c : vc) t += c;            
        perm.push_back(t);      
    } while (next_permutation(vc.begin(), vc.end()));
}
#endif


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

    int N; cin >> N;
    vvi A(2, vi(N));
    REP(i, 2)
        REP(j, N) cin >> A[i][j];

    string S = "d" + string(N - 1, 'r');
    vs ptn;
    get_permutation(ptn, S);
    
    int ans = -INF;
    for(string p : ptn){
        int x = 0, y = 0;
        int sum = A[0][0];
        for(char c : p) {
            if (c == 'd') x++;
            else y++;
            sum += A[x][y];
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Abra_Ka_Dabra 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;
using namespace std;

int main() {

	Abra_Ka_Dabra

	int n;
	cin>>n;
	vector<ll> x(n);
	for(int i=0; i<n; i++){
        cin>>x[i];
	}
	sort(x.begin(), x.end());
	ll ans=0;
	for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                if(x[i]+x[j]>x[k] && x[i]+x[k]>x[j] && x[k]+x[j]>x[i] && x[i]<x[j] && x[j]<x[k])
                    ans++;
            }
        }
	}
	cout<<ans<<"\n";

	return 0;
}



Measured memory_bytes: 3664
#include<bits/stdc++.h>
long long n,m,a[233],sum;
int main(){
	scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]),sum+=a[i];
    std::sort(a+1,a+n+1,std::greater<long long>());
	puts(a[m]*4*m>=sum?"Yes":"No");
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 200010
int c[N],d[N],n;
int main(){
	scanf("%d",&n);
	for(int i=1,a;i<=n;++i) scanf("%d",&a),c[i]=d[i]=a-i;
	sort(c+1,c+n+1);
	int mid=n%2? c[n/2+1]:(c[n/2]+c[n/2+1])/2;
	long long ans=0;
	for(int i=1;i<=n;++i) ans+=abs(d[i]-mid);
	printf("%lld",ans);
	return 0;
}

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

int main(){
  int a, b, c;
  char op;
  while (true) {
    cin >> a >> op >> b;
    if (op == '+'){
    c = a + b;
  } else if (op == '-'){
    c = a - b;
  } else if (op == '*'){
    c = a * b;
  } else if (op == '/') {
    c = a / b;
  } else if (op == '?'){
    break;
  }
  cout << c << endl;
  }
  return 0;
}


Measured memory_bytes: 3100
/*input
5
4 4 9 7 5
*/
 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define ar array
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define tests int r; cin >> r; while(r--)
#define MP make_pair
#define PI acos(-1)
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define godspeed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
 
#define M(x) ((x)%(1000000007))
 
vector<int> adj_list[100010];
bool visited[10010];





int main() {
 	
 	int n;
 	cin>>n;
 	int arr[n];
 	rep(i,n){
 		int a;
 		cin>>a;
 		arr[i] = a;
 	}
 	int count = 0;
 	for(int i = 0; i<n;i++){
 		for(int j = i+1; j<n;j++){
 			for(int q = j+1; q<n; q++){

 				int a = arr[i];
 				int b = arr[j];
 				int c = arr[q];
 				if(a!=b&&b!=c&&a!=c){
 					if((a+b)>c&&(b+c)>a&&(a+c)>b){
 					count++;
 				}
 				}
 				
 			}
 		}
 	}
 	cout<<count<<endl;

}

 


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

int compare(const void *a, const void *b){
    return *(int *)a - *(int *)b;
}

int main(void){
    int i,n,k;
    scanf("%d",&n);
    int d[n];
    for(i=0;i<n;i++){
        scanf("%d",&d[i]);
    }
    qsort(d,n,4,compare);
    if(d[n/2-1] == d[n/2]){
        k=0;
    }else{
        k=d[n/2]-d[n/2-1];
    }
    printf("%d\n",k);
    return 0;
}


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

int main() {
	string S,T;
  	cin >> S >> T;
  
  	string ans = "No";
  
  	for(int j = 0; j < S.size(); j++) {
      bool ok = true;
     
      if(S != T) 
        ok = false;
      
      char Sfirst = S.at(0);
      for(int k = 0; k < S.size() - 1; k++){
      S.at(k) = S.at(k + 1);
    }  
      S.at(S.size() - 1) = Sfirst;
      
      if(ok)  
        ans = "Yes";
  }
  
  	cout << ans << endl;
}

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

int main() {
  int N;
  int ac = 0, wa = 0,tle = 0,re = 0;
  cin >> N ;
  string S[N];
  for(int i=0;i<N;i++){
    cin >> S[i];
  	if(S[i] == "AC")ac++;
  	if(S[i] == "WA")wa++;
  	if(S[i] == "TLE")tle++;
  	if(S[i] == "RE")re++;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

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

int main() {
    long n, m;
    cin >> n >> m;
    long answer = 0;
    if(n <= m/2){
        m = m - 2*n;
        answer = answer + n + m/4;
    } else if(n > m/2 && m >= 2){
        answer = answer + m/2;
    }
    cout << answer << endl;
}

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

using namespace std;
#define ll long long
#define r(i, n) for(int i=0;i<n;i++)

int main() {
    map<string, int> MAP;
    int num_query;
    cin >> num_query;
    int command, x;
    for (int loop = 0; loop < num_query; loop++) {
        string tmp;
        cin >> command;
        if (command == 0) {
            cin >> tmp >> x;
            MAP[tmp] = x;
        } else if(command==1){
            cin >> tmp;
            cout << MAP[tmp] << endl;
        } else {
            cin >> tmp;
            MAP.erase(tmp);
        }
    }
    return 0;
}


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

int main() {
    int K;
    string S;
    cin >> K >> S;
    if(S.size()<=K){
        cout << S << endl;
    }
    else{
        for(int i=0;i<K;i++){
            cout << S.at(i);
        }
        cout << "..." << endl;
    }
	
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) {
 		Scanner sc = new Scanner(System.in);

    String s=sc.next();
    if(s.equals("Sunny")){
      System.out.println("Cloudy");
    }else if(s.equals("Cloudy")){
      System.out.println("Rainy");

    }else{
      System.out.println("Sunny");
    }

	}
}


Measured memory_bytes: 21076
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

int A, B;

int main() {
    cin >> A >> B;

    int num = 0;
    for (int i = A; i <= B; i++) {
        string s = to_string(i);
        string r = to_string(i);
        reverse(r.begin(), r.end());
        if (s == r) {
            num++;
        }
    }

    cout << num << endl;
}



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

int main()
{
	int A,B;
	cin >> A >> B;
	if (A > B)
	{
		swap(A,B);		
	}

	if ((A+B) % 2 == 1)
	{
		cout << "IMPOSSIBLE" << endl;
	}
	else
	{
		cout << (A+B) / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string p,s;
    cin>>p>>s;
    p=p+p;
    bool flag=false;
    for(int i=0;i<(int)p.size()-(int)s.size()+1;i++){
        string t=p.substr(i,s.size());
        if(t==s){
            flag=true;
            break;
        }  
    }
    if(flag){
    cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


Measured memory_bytes: 3192
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

int H,W, ans = 0;
string s[2000];
int lc[2000][2000]; // row, column
int par[2000], sz[2000];

int getpar(int x) {
    if (par[par[x]] != par[x]) par[x] = getpar(par[x]);
    return par[x];
}

void unite(int a, int b) {
    a = getpar(a), b = getpar(b);
    if (sz[a] < sz[b]) swap(a,b);
    par[b] = a;
    sz[a] += sz[b];
}

void test(int x) {
    F0R(i,W) par[i] = i, sz[i] = 1;
    
    vector<pii> zz;
    F0R(i,W-1) zz.pb({lc[x][i],i});
    sort(zz.begin(),zz.end());
    reverse(zz.begin(),zz.end());
    
    for (pii a: zz) {
        unite(a.s,a.s+1);
        ans = max(ans,a.f*sz[getpar(a.s)]);
    }
}

int main() {
    cin >> H >> W;
    F0R(i,H) cin >> s[i];
    F0Rd(i,H) {
        F0R(j,W-1) {
            if (i == H-1) {
                lc[i][j] = 1;
                continue;
            }
            int x = (s[i][j] == s[i][j+1]) + (s[i+1][j] == s[i+1][j+1]);
            if (x % 2 == 1) {
                lc[i][j] = 1;
                continue;
            }
            lc[i][j] = lc[i+1][j]+1;
        }
    }
    ans = max(H,W);
    F0R(i,H) test(i);
    cout << ans;
}

// read!
// ll vs. int!

Measured memory_bytes: 19968
#include<iostream>
#include<vector>

int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    int i;
    for(i=0;i<n;i++){
        std::cin >>a[i];
    }
    for(i=n-1;i>=0;i--){
        std::cout << a[i];
        if(i>0){
            std::cout << " ";
        }
    }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#include<list>
using namespace std;
int main (){
    int N;
    cin >> N;
    vector<int> A(N+2);
    vector<int> B(N + 2);

    for (int a = 0; a < N+1;a++){
        cin >> A.at(a + 1);
    }

    for (int b = 1; b < N + 1; b++){
        B.at(A.at(b)) = b;
    }
    for (int c = 1; c < N + 1;c++){
        cout << B.at(c);
        cout << " ";
    }
        return 0;
    }

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

int main() {
	string a, b;
	cin >> a >> b;
	
	if (a.size() > b.size()) cout << "GREATER" << endl;
    	else if (a.size() < b.size()) cout << "LESS" << endl;
    	else if (a > b) cout << "GREATER" << endl;
    	else if (a < b) cout << "LESS" << endl;
    	else cout << "EQUAL" << endl;

	return 0;
}

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


void solve(std::string c){
  if (c[0] == 'a' or c[0] == 'e' or c[0] == 'i' or c[0] == 'o' or c[0] == 'u') {
      cout << "vowel" << endl;
  } else {
      cout << "consonant" << endl;
  }
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string c;
    std::cin >> c;
    solve(c);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

int main() {
    int table[10][10];
    for (int j = 0; j < 10; ++j) {
        for (int k = 0; k < 10; ++k) {
            cin >> table[j][k];
        }
    }

    int ans = 0;
    for (int n = 0; n < 10000; ++n) {
        int d[5];
        for (int j = 0; j < 4; ++j) {
            d[j] = (n / (int)pow(10, 3-j)) % 10;
        }

        { 
            int chk = 0;
            for (int j = 0; j < 4; ++j) {
                chk = table[chk][d[j]];
            }
            d[4] = chk;
        }

        int inc = 0;

        // altering one digit
        for (int j = 0; j < 5; ++j) {
            int ds[5];
            for (int k = 0; k < 5; ++k) {
                ds[k] = d[k];
            }

            for (int k = 0; k < 10; ++k) {
                ds[j] = k;

                bool ignore = true;
                for (int l = 0; l < 5; ++l) {
                    if (d[l] != ds[l]) ignore = false;
                }
                if (ignore) continue;

                int chk = 0;
                for (int l = 0; l < 5; ++l) {
                    chk = table[chk][ds[l]];
                }
                if (chk == 0) {
                    inc = 1;
                }
            }
        }

        // transposing two adjacent digits
        for (int j = 0; j < 4; ++j) {
            int ds[5];
            for (int k = 0; k < 5; ++k) {
                ds[k] = d[k];
            }
            swap(ds[j], ds[j+1]);

            bool ignore = true;
            for (int l = 0; l < 5; ++l) {
                if (d[l] != ds[l]) ignore = false;
            }
            if (ignore) continue;

            int chk = 0;
            for (int l = 0; l < 5; ++l) {
                chk = table[chk][ds[l]];
            }
            if (chk == 0) {
                inc = 1;
            }
        }

        ans += inc;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3276
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << -1; return;}

const int N = 3e5 + 7;

int row[N], col[N];

void solve() {
    int h, w, m;
    cin >> h >> w >> m;
    vector <pi> c(m);
    loop(i, m) {
        int x, y;
        cin >> x >> y;
        c[i] = { x, y };
        ++row[x], ++col[y];
    }
    sort(all(c));
    vector <int> good_row, good_col;
    int mxr = 0, mxc = 0;
    loop(i, N) {
        mxr = max(mxr, row[i]);
        mxc = max(mxc, col[i]);
    }
    loop(i, N) {
        if (row[i] == mxr)
            good_row.pb(i);
        if (col[i] == mxc)
            good_col.pb(i);
    }
    for (int x : good_row)
        for (int y : good_col) {
            pi p = { x, y };
            auto it = lower_bound(all(c), p);
            if (it == c.end() || *it != p) {
                cout << mxr + mxc; return;
            }
        }
    cout << mxr + mxc - 1;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[111], v[111];
ll s[100010];
int main(){
    int n, w;
    while(cin>>n>>w){
        ll ans=0;
        for(int i=0; i<n; ++i){
            scanf("%d%d",a+i, v+i);
        }
        for(int i=0; i<100010; ++i)
            s[i]=1e9+1;
        s[0]=0;
        for(int i=0; i<n; ++i){
            for(int j=100000; j>=v[i]; --j){
                if(s[j-v[i]]!=-1)
                    s[j]=min(s[j], s[j-v[i]]+a[i]);
                if(s[j]<=w)
                    ans=max(ans, (ll)j);
            }
        }
        cout<<ans<<endl;
    }
  return 0;
}




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

int main(){
  int n;
  cin >> n;
  int m = 0, a = 0, r = 0, c = 0, h = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s.front() == 'M') m++;
    if (s.front() == 'A') a++;
    if (s.front() == 'R') r++;
    if (s.front() == 'C') c++;
    if (s.front() == 'H') h++;
  }
  vector<long long> d(5);
  d.at(0) = m, d.at(1) = a, d.at(2) = r, d.at(3) = c, d.at(4) = h;
  long long ans = 0;
  vector<int> fi = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
  vector<int> se = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
  vector<int> th = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
  for (int i = 0; i < 10; i++) {
    ans += d.at(fi.at(i)) * d.at(se.at(i)) * d.at(th.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), K = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine();
        int ans = 0;
        List<Integer> lbs = new ArrayList<>(), rbs = new ArrayList<>();
        for (int i = 0; i < n; ++i) {
            if (s.charAt(i) == '0') {
                lbs.add(i);
                for (; i < n && s.charAt(i) == '0'; ++i);
                rbs.add(i-1);
            }
        }
        if (lbs.size() <= K) {
            ans = n;
        } else {
            ans = Math.max(lbs.get(K), n - rbs.get(rbs.size() - K - 1) - 1);
            for (int i = K + 1; i < lbs.size(); ++i) {
                ans = Math.max(ans, lbs.get(i) - rbs.get(i - K - 1) - 1);
            }
        }
        System.out.println(ans);
    }
}


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

int main(){
  string s;
  cin >> s;
  vector<string> ss = {"dream", "dreamer", "erase", "eraser"};
  reverse(s.begin(), s.end());
  bool ans = true;
  rep(i, ss.size()){
    reverse(ss[i].begin(), ss[i].end());
  }
  

  for(int i = 0; i < s.length();){
    bool ok = false;
    rep(j, ss.size()){
      string tmp = s.substr(i, ss[j].length());
      if(tmp == ss[j]) {
        ok = true;
        i += ss[j].length();
        break;
      }
    }
    if(!ok){
      ans = false;
      break;
    } 
  }
  cout << (ans ? "YES" : "NO") << endl;

}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long double a, b;
	cin >> a >> b;
	a *= b;
	cout << fixed << setprecision(0) << floor(a) << endl;
	return 0;
}


Measured memory_bytes: 3796
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n;
	scanf("%d", &n);
	VV(pii) G(n);
	for(int i = 0; i < n; ++i){
		int c;
		scanf("%d", &c);
		for(int j = 0; j < c; ++j){
			int x, y;
			scanf("%d%d", &x, &y);
			G[i].emplace_back(x - 1, y);
		}
	}

	int ans = 0;
	for(int S = 0; S < (1 << n); ++S){
		int cnt = __builtin_popcount(S);
		if(cnt <= ans){ continue; }
		bool ok = true;
		for(int i = 0; i < n; ++i){
			if(S >> i & 1){
				for(cauto p : G[i]){
					if((S >> p.first & 1) != p.second){
						ok = false;
						break;
					}
				}
			}
		}
		if(ok){
			ans = cnt;
		}
	}
	printf("%d\n", ans);
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){
	throw;
}


Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string S;

LL ans = 0;

void solve(){
	int N = S.size();
	int left,right;
	if(N%2==0){
		ans = N/2;
		left = N/2 - 1;
		right = N/2;
		while(right<N){
			if(S[left]==S[right]){
				left--;
				right++;
				ans = right;
			}else{
				return;
			}
		}
	}else{
		left = N/2;
		right = left;
		if(S[left]!=S[left+1]){
			ans = N/2 + 1;
			return;
		}
		while(right<N){
			//cout << left << " " << right << endl;
			if(S[left]==S[right]){
				left--;
				right++;
				ans = right;
			}else{
				return;
			}
		}
	}
}

int main(){
    cin >> S;

    solve();

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

Measured memory_bytes: 512