akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		WriteLine(Array.FindIndex(GetInts(5), x => x == 0) + 1);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 28416
import sys
input = sys.stdin.readline

n,m,l = map(int,input().split())
dp = [[-1]*n for _ in range(n)]
for i in range(n):
    dp[i][i] = 0

for _ in range(m):
    a,b,c = map(int,input().split())
    dp[a-1][b-1] = c
    dp[b-1][a-1] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            if dp[i][k] != -1 and dp[k][j] != -1:
                if dp[i][j] == -1:
                    dp[i][j] = dp[i][k] + dp[k][j]
                else:
                    dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j])

dp2 = [[-1]*n for _ in range(n)]

for i in range(n):
    for j in range(n):
        if 0 <= dp[i][j] <= l:
            dp2[i][j] = 1

for i in range(n):
    dp[i][i] = 0

for k in range(n):
    for i in range(n):
        for j in range(n):
            if dp2[i][k] != -1 and dp2[k][j] != -1:
                if dp2[i][j] == -1:
                    dp2[i][j] = dp2[i][k] + dp2[k][j]
                else:
                    dp2[i][j] = min(dp2[i][j],dp2[i][k]+dp2[k][j])

for _ in range(int(input())):
    s,t = map(int,input().split())
    if dp2[s-1][t-1] == -1:
        print(-1)
    else:
        print(dp2[s-1][t-1]-1)


Measured memory_bytes: 58204
N, D = map(int, input().split())
X = []
count = 0
for n in range(N):
  temp = list(map(int, input().split()))
  X.append(temp)
for i in range(N):
  for j in range(i + 1, N):
    sums = 0
    for d in range(D):
      sums += (X[i][d] - X[j][d]) ** 2
    for n in range(sums):
      if n * n == sums or sums == 1:
        count += 1
print(count)

Measured memory_bytes: 3064
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
    
ans = 0

n = int(input())

x = factorization(n)

for i in x:
    cnt = 0
    k = 1
    while i[1]>=k:
        cnt += 1
        k += (cnt+1)
    ans += cnt
    
if n == 1:
    ans = 0
    
print(ans)

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

fn main() {
    let mut n: u32 = read();
    let mut v: Vec<u32> = read_vec();
    let mut c: Vec<u32> = read_vec();
    let mut ans:u32 = 0;
    for i in 0..n {
        let i = i as usize;
        if v[i]>c[i] {
            ans += v[i]-c[i];
        }
    }
    println!("{}", ans);
}
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

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

const int N = 1000000;
int data[1000000];
int n;

void Eratosthenes(){
  for(int i=0; i<N; i++){
    data[i] = 1;
  }
  for(int i=2; i<sqrt(N); i++){
    if(data[i]){
      for(int j=0; i*(j+2)<N; j++){
	data[i *(j + 2)] = 0;
      }
    }
  }
}

int main()
{
  int cnt = 0;
  Eratosthenes();
  while( cin >> n ) {
    cnt = 0;
    for(int i=2; i<=n; i++) {
      if( data[i] ) cnt++;
    }

    cout << cnt << endl;
  }
}

Measured memory_bytes: 5064
#include<bits/stdc++.h>
using namespace std;
const int maxn=(1e5+10);
int n,a[maxn];
void die()
{
	puts("No");
	exit(0);
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(i==0)
			--a[i];
		else
		{
			if(a[i]<a[i-1])
				die();
			if(a[i]==a[i-1])
				continue;
			--a[i];
		}
	}
	puts("Yes");
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	int d[n];
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}

	sort(d, d+n);
	int num = n/2;
	int ans = d[num] - d[num-1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
vote = []
for i in range(N):
    s = input()
    vote.append(s)
vote = sorted(vote)
vote.append("zzzzzzzzzzz")

if N == 1:
    ans = [vote[0]]
else:
    ans = []
    num = 1
    M = 0
    for i in range(1,N+1):
        if vote[i] == vote[i-1]:
            num += 1
        else:
            name = vote[i-1]
            if num == M:
                ans.append(name)
                num = 1
            elif num > M:
                ans = [name]
                M = num
                num = 1
            else:
                num = 1
for i in ans:
    print(i)


Measured memory_bytes: 20160
from collections import deque
h, w = map(int, input().split())
maze = ["#"*(w+2)]
white_cnt = 0
for _ in range(h):
    row = input()
    white_cnt += row.count('.')
    maze.append("#"+row+"#")
else:
    maze.append("#"*(w+2))

w += 2
h += 2
INF = 10**9
dist = [[INF]*w for _ in range(h)]
dist[1][1] = 0
next_block = deque([(1, 1)])
dirc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
cnt = 0
while next_block:
    i, j = next_block.popleft()
    for x, y in dirc:
        if maze[i+x][j+y] == '#':
            continue
        if dist[i+x][j+y] != INF:
            continue
        next_block.append((i+x, j+y))
        dist[i+x][j+y] = min(dist[i+x+v][j+y+w] for v, w in dirc)+1

if dist[-2][-2] == INF:
    print(-1)
else:
    print(white_cnt-dist[-2][-2]-1)


Measured memory_bytes: 3316
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
#pragma endregion
#pragma endregion


int main() {
	lint n, m; cin >> n >> m;
	if (n > m) swap(n, m);
	if (n == 1 && m == 1) cout << 1 << endl;
	if (n == 1 && m != 1) cout << m - 2 << endl;
	if (n != 1 && m != 1) cout << (n - 2) * (m - 2) << endl;

	return 0;
}

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

int gcd(int x,int y){
    if (y==0) return x;
    return gcd(y,x%y);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K; cin >> K;
    ll ans=0;
    for (int i=1;i<=K;++i)
        for (int j=1;j<=K;++j)
            for (int k=1;k<=K;++k)
                ans+=gcd(i,gcd(j,k));
    cout << ans << '\n';
}

Measured memory_bytes: 3612
import heapq
N,M=map(int,input().split())
G=[[] for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
dist=[10**15 for i in range(N)]
prev=[-1 for i in range(N)]
dist[0]=0
q=[]
heapq.heappush(q,(0,0))
while(len(q)>0):
    c,v=heapq.heappop(q)
    if dist[v]<c:
        continue
    for d in G[v]:
        if dist[d]>dist[v]+1:
            dist[d]=dist[v]+1
            heapq.heappush(q,(dist[d],d))
            prev[d]=v
print("Yes")
for i in range(1,N):
    print(prev[i]+1)


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

int main()
{
    string a,b;
    cin>>a;
    cin>>b;
    string c=a+b;
   stringstream g(c);
   int x=0;
   g>>x;
   int k=sqrt(x);
   if(k*k==x) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100;
const int mid = 160 * 80;

int h, w;
int arr[MAXN][MAXN];
bool f[MAXN][MAXN][2 * 160 * 80 + 100];

int main(){
	scanf("%d %d", &h, &w);
	for(int i = 1; i <= h; i++)
		for(int j = 1; j <= w; j++)
			scanf("%d", &arr[i][j]);
	int tmps;
	for(int i = 1; i <= h; i++)
		for(int j = 1; j <= w; j++)
			scanf("%d", &tmps), arr[i][j] = abs(tmps - arr[i][j]);
	memset(f, false, sizeof(f));
	f[1][1][mid + arr[1][1]] = 1;
	f[1][1][mid - arr[1][1]] = 1;
	for(int i = 1; i <= h; i++)
		for(int j = 1; j <= w; j++){
			for(int k = 0; k <= 2 * mid; k++){
				if(f[i][j][k]){
					f[i + 1][j][k + arr[i + 1][j]] |= f[i][j][k];
					f[i + 1][j][k - arr[i + 1][j]] |= f[i][j][k];
					f[i][j + 1][k + arr[i][j + 1]] |= f[i][j][k];
					f[i][j + 1][k - arr[i][j + 1]] |= f[i][j][k];
				}
			}
		}
	for(int i = 0; i <= mid; i++) if(f[h][w][mid + i] || f[h][w][mid - i]){
		printf("%d\n", i);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 251264
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        double kaku = 0;
        for (int i=1; i<=N; i++) {
            int tokuten = i;
            double sunukeWin = (double)1/N;
            while (tokuten < K) {
                tokuten = tokuten * 2;
                sunukeWin = sunukeWin * 0.5;
            }
            kaku += sunukeWin;
        }

        System.out.println(kaku);
    }
}

Measured memory_bytes: 21716
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var rail= new Stack<int>();
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var n = int.Parse(line);
            if (n == 0)
            {
                var train = rail.Pop();
                Console.WriteLine(train);
            }
            else rail.Push(n);
        }
    }
}

Measured memory_bytes: 9928
import java.util.*;
import java.math.BigInteger;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long m = sc.nextInt();
        if (n < 2 || m < 2) {
            if (n == 1 && m == 1) {
                System.out.println(1);
            } else {
                long l = Math.max(n, m);
                System.out.println(l - 2);
            }
        } else {
            BigInteger bign = new BigInteger("0");
            BigInteger bigm = new BigInteger("0");
            BigInteger ans = new BigInteger("0");
            bign = BigInteger.valueOf(n - 2);
            bigm = BigInteger.valueOf(m - 2);
            ans = bign.multiply(bigm);
            System.out.println(ans);
        }
    }
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    int H, W;
    cin >> H >> W;
    int A, B;
    cin >> A >> B;
    // 上から B 行目までと、左から A 列目までで切って、
    // ２色で塗り分けを行えば常に構成可能

    REP1 (h, H)
    {
        REP1 (w, W)
        {
            std::cout << int(w <= A xor B < h);
        }
        std::cout << endl;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>

using namespace std;

int answer[2*1001];

int dist[2*1001][2*1001];

int main(){

    int n,x,y;
    cin >> n >> x >> y;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            dist[i][j] = abs(j-i);
        }
    }

    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j++){
            dist[i][j] = min(dist[i][j],dist[i][x]+1+dist[y][j]);
            dist[i][j] = min(dist[i][j],dist[i][y]+1+dist[x][j]);
            answer[dist[i][j]]++;
        }
    }
    for(int i=1;i<n;i++){
        cout << answer[i] << endl;
    }

}

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

int main() {
  // 入力
  int N, K;
  cin >> N >> K;
  vector<double> p(N);
  for(int i=0; i<N; i++)
    cin >> (p.at(i));
  
  //累積和
  vector<double> s(N+1, 0);
  for (int i=0; i<N; i++)
    s.at(i+1) = s.at(i) + (p.at(i)+1)/2;
  
  double ans = 0, tmp;
  for(int i=0; i<= N-K; i++){
    tmp = s.at(K+i) - s.at(i);
    if (tmp > ans)
      ans = tmp;
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <set>
#include <tuple>

using pii = std::pair<int, int>;

template<class T>
using vec = std::vector<T>;

void update(int &l, int r)
{
    if (l < r) l = r;
}

int main()
{
    int N, M, L, d, a, b, t;
    std::cin >> N >> M >> L;
    
    std::set<pii> p[5 * N + 1];
    for (int i = 0; i < M; i++) {
        std::cin >> d >> a >> b >> t;
        a = a + d * N;
        p[a].insert(pii(a + b, t));
    }
    N = 5 * N;
    
    int res = 0;
    vec<vec<int>> dp(L + 1, vec<int>(N + 2)); 
    for (int i = 0; i <= L; i++) {
        for (int j = 0; j <= N; j++) {
            update(dp[i][j + 1], dp[i][j]);
            for (auto &x: p[j]) {
                std::tie(b, t) = x;
                
                if (i + 1 <= L) {
                    update(dp[i + 1][b], dp[i][j] + t);                
                    update(res, dp[i + 1][b]);
                }                
            }
        }
    }
    
    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a[3][3];
    for (int i = 0; i < 3; i++){
        for (int j =0 ; j < 3; j++){
            scanf("%d",&a[i][j]);
        }
    }
    int n;
    scanf("%d",&n);
    int done[3][3];
    memset(done,0,sizeof(done));
    for (int i = 0; i < n; i++){
        int b;
        scanf("%d",&b);
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 3; k++){
                if (a[j][k] == b) done[j][k] = 1;
            }
        }
    }
    for (int i = 0; i < 3; i++){
        if (done[0][i] && done[1][i] && done[2][i]){
            printf("Yes");
           return 0;
        }
        if (done[i][0] && done[i][1] && done[i][2]){
            printf("Yes");
            return 0;
        }

    }
    if (done[0][0] && done[1][1] && done[2][2]){
         printf("Yes");
        return 0;
    }
    if (done[0][2] && done[1][1] && done[2][0]){
         printf("Yes");
        return 0;
    }
    printf("No");
}


Measured memory_bytes: 256
def resolve():
    N, Y = map(int, input().split())

    for b1 in range(N + 1):
        for b5 in range(N - b1 + 1):
            b10 = N - b1 - b5
            sum = 1000*b1 + 5000*b5 + 10000*b10
            if sum == Y:
                print("{} {} {}".format(b10, b5, b1))
                return
    print("-1 -1 -1")


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 38768
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x; cin >> x;
  for(int i=1;i<=x;++i){
    int r = x - i * 100;
    if (r >= 0 && r <= 5 * i) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;

}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n, k; cin >> n >> k;

    vector<double> e(1010, 0);

    for (int i = 1; i < 1010; ++i) {
        for (int j = 1; j <= i; ++j) {
            e[i] += (double)j * (1.0 / (double)i);
        }
    }

    vector<int> p(n);

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

    vector<double> s(n+1, 0.0);

    for (int i = 0; i < n; ++i) {
        s[i+1] = s[i] + e[p[i]];
    }

    double ans = 0.0;

    for (int i = 0; i <= n-k+1; ++i) {
        ans = max(ans, s[i+k] - s[i]);
    }

    cout << setprecision(10) << fixed << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <utility>
using namespace std;

typedef long long ll;

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

  if(k%2==0){
    cout << a-b << endl;
  }else{
    cout << b-a << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import sys

def quartet(h, w):
    global flag
    if 0 <= h <= 11 and 0 <= w <= 11:
        if mapp[h][w] == '1':
            mapp[h][w] = '$'
            flag = True
            bigbang(h, w)
        elif mapp[h][w] == '0' or mapp[h][w] == '$':
            return
    else:
        return

def bigbang(h, w):
    quartet(h, w+1)
    quartet(h-1,w)
    quartet(h, w-1)
    quartet(h+1, w)

mapp = []
for line in sys.stdin:
    if not line == '\n':
        lis = []
        for char in line.rstrip():
            lis.append(char)
        else:
            mapp.append(lis)
    if len(mapp) == 12:
        flag = False
        count = 0
        for h in range(12):
            for w in range(12):
                quartet(h, w)
                if flag == True:
                    count += 1
                flag = False
        else:
            print count
            mapp = []

Measured memory_bytes: 4376
#include<stdio.h>

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



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

int main() {
  for (int h, w; cin >> h >> w;) {
    if (h == 0 && w == 0) break;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) cout << "#";
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int i,x=0;
  string s;
  cin >> s;
  for (i=0;i<s.size();i++) if (s.at(i)=='x') x++;
  if (x<8) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define All(obj) (obj).begin(),(obj).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=0; i>=(n);--i)
#define FOR(i,b,n) for(int i=(b);i<(n);++i)

typedef long long ll;

const int M=2e5+5;
const int INF=2e9;
const int MOD=1e9+7; //prime number


void Solve()
{
    int k;
    cin >> k;
    string str = "ACL";
    for(int i = 0; i < k; ++i)
    {
        cout << str;
    }
}
int main()
{
    fastio;
    Solve();

    return 0;
}



Measured memory_bytes: 3608
A, B, C = map(int, input().split())
K = int(input())

for a in range(K+1):
    for b in range(K+1):
        c = K - (a + b)
        if (c >= 0) and (a + b + c <= K):
            if ((2**a)*A < (2**b)*B) and ((2**b)*B < (2**c)*C):
                print('Yes')
                exit()

print('No')

Measured memory_bytes: 9204
#include <iostream>
#include <math.h>
using namespace std;
int main() {
 
long long A, B;
cin >> A >> B;
for (long long k = 0; k < 1000000000; k++) {
 bool f = true;
  if(A + B == 2 * k) {
cout << k << endl; f = false; break;
  }
if (f == true && k == 999999999)
cout << "IMPOSSIBLE" << endl;
    }  
}


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

using namespace std;

int main() {
    unsigned int n, c, k;
    cin >> n >> c >> k;

    vector<int> t(n);
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
    }
    sort(t.begin(), t.end());

    vector<int> passengers(n);
    for (int i = 0; i < n; ++i) {
        passengers[i] = 1;
    }

    int ans = 0;
    int curr = 0;
    for (int i = 1; i < n; ++i) {
        if (t[i] > t[curr] + k || passengers[ans] == c) {
            ans++;
            curr = i;
        } else {
            passengers[ans]++;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
A, B = map(int, input().split())
P = [int(x) for x in input().split()]

pr = [0]*3
for p in P :
    if p <= A :
        pr[0] += 1
    elif p <= B :
        pr[1] += 1
    else :
        pr[2] += 1

print(min(pr))


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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    bool ans = a + b + c >= 22;

    if (ans) puts("bust");
    else puts("win");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll x;
	cin >> x;

	ll happy = 0;
	if (x >= 500)
		happy += (x / 500) * 1000;
		x = x % 500;
	happy += (x / 5) * 5;
	cout << happy << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int main( ){
  while(1){
    int b[4],l,s,sum,count=0;
    string a;
    cin>>a;
    if(a[0]=='0'&&a[1]=='0'&&a[2]=='0'&&a[3]=='0')break;
    if(a[0]==a[1]&&a[2]==a[3]&&a[0]==a[3]){
      printf("NA\n");
      continue;
    }
    b[0]=a[0]-'0';
    b[1]=a[1]-'0';
    b[2]=a[2]-'0';
    b[3]=a[3]-'0';
    while(1){
      sum=b[0]*1000+b[1]*100+b[2]*10+b[3];
      if(sum==6174)break;
      count++;
      sort(b,b+4);
      s=b[0]*1000+b[1]*100+b[2]*10+b[3];
      l=b[3]*1000+b[2]*100+b[1]*10+b[0];
      sum=l-s;
      b[0]=sum/1000;
      b[1]=(sum%1000)/100;
      b[2]=(sum%100)/10;
      b[3]=sum%10;
    }
    printf("%d\n",count);
  }
  return 0;
}

Measured memory_bytes: 3204
import re,sys
def S(): return sys.stdin.readline().rstrip()
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
A,B = LI()
S = S()
p = '[0-9]{{{0}}}-[0-9]{{{1}}}'.format(A,B)
print('Yes' if re.fullmatch(p,S) else 'No')


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
 
typedef unsigned long long ull;
typedef unsigned int ui;
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=2000+5,A=4e6+5;
int cnt[A];
ull a[A/64+5];int mx;
bool Count(int x)
{
	return a[x/64]&(1LL<<(x&63));
}
void move(int x)
{
	int u=mx/64;mx+=x;
	int du=x/64,di=x&63;
	if(!di)
	{
		for(int i=u;i>=0;--i)a[i+du]|=a[i];
		return ;
	}
	for(int i=u;i>=0;--i)
	{
		a[i+du+1]|=a[i]>>64-di;
		a[i+du]|=a[i]<<di;
	}
}
 
int main()
{
//	freopen("will.in","r",stdin);freopen("will.out","w",stdout);
	int n;
	cin>>n;
	int sum=0;
	rep(i,1,n)
	{
		int x;
		scanf("%d",&x);
		sum+=x;
		++cnt[x];
	}
	mx=0;a[0]=1;
	rep(i,1,sum)
	{
		while(cnt[i]>2){++cnt[i*2];cnt[i]-=2;}
		while(cnt[i]--)move(i);
	}
	rep(i,(sum+1)/2,sum)
	if(Count(i))
	{
			cout<<i;
			break;
	}
}

Measured memory_bytes: 16384
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    p = set()
    for _ in range(n):
        p.add(S())
    print(len(p))
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 48968
#include<iostream>
using namespace std;
int main()
{
  int k,c;
  int i;
  int ans;
  while(1){
    cin >> k;
    if(k==0) break;
    ans=0;
    for(i=0;i<k*(k-1)/2;++i){
      cin >> c;
      ans += c;
    }
    cout << ans/(k-1)  << endl;
  }
  return 0;
}

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

int num(int arr[], int n, int used[], int i);
int fact(int n)
{
    int ans;

    if(n==0) return 1;
    ans=n*fact(n-1);

    return ans;
}

int main(void)
{
    int n,p[8],q[8],useda[8]={0},usedb[8]={0},a,b,ans,i;

    scanf("%d",&n);
    for ( i = 0; i < n; i++)
    {
        scanf("%d",p+i);
    }
    for ( i = 0; i < n; i++)
    {
        scanf("%d",q+i);
    }

    a=num(p,n,useda,0);
    b=num(q,n,usedb,0);

    ans=(a-b>0)? a-b:b-a;
    printf("%d",ans);

    return 0;
}

int num(int arr[], int n, int used[], int i)
{
    if(i==n-1) return 0;
    used[arr[i]]=1;
    int now,nokori=arr[i]-1;
    for (int j = 1; j < arr[i]; j++)
    {
        if(used[j]==1) nokori--;
    }
    now=nokori*fact(n-i-1);
    int partial=num(arr,n,used,i+1);
    return now+partial;
}

Measured memory_bytes: 128
import java.util.Arrays;

public class Main {


  private static void solve() {
    int n = ni();
    long[] a = nal(n);
    Arrays.sort(a);
    int ret = 1;
    long sum = 0;
    for (int i = 0; i < n - 1; i ++) {
      sum += a[i];
      if (a[i + 1] <= sum * 2) {
        ret ++;
      } else {
        ret = 1;
      }
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 43284
#include<stdio.h>
#include<stdbool.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
  int n, m, k[11], s[11][11] ,p[11];
  scanf("%d%d",&n,&m);
  rep(i,m){
    scanf("%d",&k[i]);
    rep(j,k[i]){
      scanf("%d",&s[i][j]);
    }
  }
  rep(i,m){
   scanf("%d",&p[i]);
  }
  
  int times = 0;
  rep(x,1<<n) {//スイッチのオン・オフの全事象
    int on[11] = {0};
    rep(t,n){
      if(x>>t&1){//スイッチLがonの時
        rep(i,m) {
          rep(j,k[i]){
            if((t+1) == s[i][j]) on[i]++;
          }
      	}
      }
    }//それぞれの電球のスイッチのオンの数計算
    
    //rep(i,m) printf("%d ",on[i]);
      
    bool ok = true;
    rep(i,m){
      //printf("%d %d\n",on[i],p[i]);
      if( ((on[i])%2) != p[i]) {
        ok = false;
        break;
      }
    }//全部の電球つくか確かめる
    if(ok == true) times++;
  }
  printf("%d\n",times);
  return 0;
}
  
  

Measured memory_bytes: 1696
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int a, b;

    cin >> a >> b;

    cout << (b + a - 3) / (a - 1) << endl;
}

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

int main() {
	int n;
	while (cin >> n) {
		int a[100];
		for (int i = 0; i < n; i++)cin >> a[i];
		sort(a, a + n);
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += (a[i] * (n - i));
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int X;
  cin >> X;
  
  int ans = 0;
  int i=0;
  while (ans == 0) {
    bool judge = 1;
    
    for (int j=2; j*j<=X+i; j++) {
      if ((X+i)%j == 0) {
        judge = 0;
        break;
      }
    }
    
    if (judge) {
      ans = X + i;
    }
    
    i++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

bool debug = 0;

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    string t = "";
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] != 'x') t += s[i];
    }
    for (int i = 0; i * 2 < (int)t.size(); i++) {
        if (t[i] != t[t.size() - i - 1]) ans = -1;
    }
    if (ans == 0) {
        int l = 0, r = n - 1;
        while (r - l > 0) {
            if (s[l] != s[r]) {
                ans++;
                if (s[l] == 'x') l++;
                if (s[r] == 'x') r--;
            } else {
                l++;
                r--;
            }
        }
    }
    cout << ans << endl;
}

int main() {
    if (debug) {
        while (true) {
            cout << "********" << endl;
            solve();
        }
    } else {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3756
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pii pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=3e5+10;

    int a[N];
	void main()
	{
		int A=qread(),B=qread(),C=qread(),ans=0;
		while(A%2==0 and B%2==0 and C%2==0)
		{
			if(A==B and B==C){write(-1);return;}
			ans++;int x=(A+B)/2,y=(A+C)/2,z=(B+C)/2;A=x,B=y,C=z;
		}write(ans);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<ll>d1(n),d2(n),d3(n),d4(n),d5(n),d6(n),d7(n),d8(n);
  rep(i,0,n){
    ll x,y,z;
    cin >> x >> y >> z;
    d1[i] = x+y+z;
    d2[i] = x+y-z;
    d3[i] = x-y+z;
    d4[i] = -x+y+z;
    d5[i] = x-y-z;
    d6[i] = -x+y-z;
    d7[i] = -x-y+z;
    d8[i] = -x-y-z;
  }
  sort(d1.begin(),d1.end());
  sort(d2.begin(),d2.end());
  sort(d3.begin(),d3.end());
  sort(d4.begin(),d4.end());
  sort(d5.begin(),d5.end());
  sort(d6.begin(),d6.end());
  sort(d7.begin(),d7.end());
  sort(d8.begin(),d8.end());
  ll s1 = 0,s2 = 0,s3 = 0,s4 = 0,s5 = 0,s6 = 0,s7 = 0,s8 = 0;
  rep(i,0,m){
    s1 += d1[n-1-i];
    s2 += d2[n-1-i];
    s3 += d3[n-1-i];
    s4 += d4[n-1-i];
    s5 += d5[n-1-i];
    s6 += d6[n-1-i];
    s7 += d7[n-1-i];
    s8 += d8[n-1-i];
  }
  ll ans = max(s1,s2);
  ans = max(ans,s3);ans = max(ans,s4);ans = max(ans,s5);ans = max(ans,s6);
  ans = max(ans,s7);ans = max(ans,s8);
  cout << ans << endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n, x, y;
	cin >> n >> x >> y, -- x, -- y;
	vector<vector<int>> adj(n);
	for(int u = 1; u < n; ++ u){
		int v = u - 1;
		adj[u].push_back(v), adj[v].push_back(u);
	}
	adj[x].push_back(y), adj[y].push_back(x);
	vector<int> res(n - 1);
	for(int s = 0; s < n; ++ s){
		vector<int> dist(n, -1);
		dist[s] = 0;
		deque<int> q{s};
		while(!q.empty()){
			auto u = q.front();
			q.pop_front();
			for(auto v: adj[u]){
				if(dist[v] == -1){
					dist[v] = dist[u] + 1;
					q.push_back(v);
				}
			}
		}
		for(int u = 0; u < n; ++ u){
			if(dist[u]){
				++ res[dist[u] - 1];
			}
		}
	}
	for(auto &x: res){
		x /= 2;
	}
	copy(res.begin(), res.end(), ostream_iterator<int>(cout, "\n"));
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exists(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}
inline ll modpow(ll x, ll y) {
    ll res = 1;
    while(y) {
        if(y&1) res = mul(res,x);
        y >>= 1;
        x = mul(x,x);
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int ans = (N+1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let s: Vec<char> = input::<String>().chars().collect();
    let t: Vec<char> = input::<String>().chars().collect();

    let mut dp = vec![vec![0; t.len() + 1]; s.len() + 1];
    for i in 0..s.len() {
        for j in 0..t.len() {
            if s[i] == t[j] {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            } else {
                dp[i + 1][j + 1] = std::cmp::max(dp[i][j + 1], dp[i + 1][j]);
            }
        }
    }

    let mut ans = vec![];
    let mut i = s.len();
    let mut j = t.len();
    while i > 0 && j > 0 {
        if s[i - 1] == t[j - 1] {
            ans.push(s[i - 1]);
            i -= 1;
            j -= 1;
        } else if dp[i][j] == dp[i][j - 1] {
            j -= 1;
        } else {
            i -= 1;
        }
    }

    let ans: String = ans.iter().rev().cloned().collect();
    println!("{}", ans);
}


Measured memory_bytes: 41212
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y,z;
  cin>>x>>y>>z;
  x-=z;
  for(int i=0;true;i++){
    if(x<(y+z)*i){
      cout<<i-1;
      break;
    }
  }
}

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

#define i64 long long int
#define ran 2022

int n;
int a[ran];

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) scanf("%d", &a[i]);
	sort(a, a+n);
	
	i64 ans = 0;
	for(int i=0;i<n-2;i++)
		for(int j=i+1, k=i+2;j<n-1;j++) {
			while(k<n && a[k]<a[i]+a[j]) k++;
			if(k==j) k=j+1;
			ans += k-j-1;
		}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int l = S.Length;
            long ans = 0;
            int count = 0;
            for (int i = 0; i < l; i++) 
            {
                if (S[i] == 'B') 
                {
                    count++;
                }
                if (S[i] == 'W') 
                {
                    ans += count;
                }
            }
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 26736
s = input()
t = input()

s_dict = {}
t_dict = {}

for i in range(len(s)):
    if s[i] not in s_dict:
        s_dict[s[i]] = t[i]
        
    elif s_dict[s[i]] != t[i]:
        print('No')
        exit()

    if t[i] not in t_dict:
        t_dict[t[i]] = s[i]
    elif t_dict[t[i]] != s[i]:
        print('No')
        exit()


print('Yes')

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n, L, T; cin >> n >> L >> T;
    vector<ll> X(n), W(n);
    REP(i, n) cin >> X[i] >> W[i];
    vector<ll> Y(n);
    REP(i, n) {
        Y[i] = ((X[i] + (W[i] == 1 ? 1 : -1) * T) % L + L) % L;
    }
    vector<ll> Y0 = Y;
    sort(ALL(Y));
    ll hit = 0;
    REP(i, n) {
        if (W[i] == W[0]) continue;
        ll len = W[0] == 1 ? X[i]-X[0] : X[0]-X[i];
        if (len < 0) len += L;
        // cout << i << " " << len << endl;
        if (len < T*2) {
            hit += (T*2 - len - 1)/L+1;
        }
    }
    // cout << hit << endl;
    ll idx = hit * (W[0] == 1 ? 1 : -1);
    REP(i, Y.size()) {
        if (Y[i] == Y0[0]) {
            idx -= i;
            if (i+1 < Y.size() && Y[i+1] == Y[i] && W[0] == 2) {
                --idx;
            }
            break;
        }
    }
    idx = (idx % n + n) % n;
    vector<ll> ans(n, -1);
    REP(i, Y.size()) {
        ans[(idx+i)%n] = Y[i];
    }
    REP(i, n) cout << ans[i] << endl;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int ans = pow(10, 9);

    int N;
    cin >> N;

    vector<int> a(N);

    for(int i = 0; i < N; i++) cin >> a[i];

    for(int i = -100; i <= 100; i++) {
        int c = 0;
        for(int j = 0; j < N; j++) {
            c += (i - a[j]) * (i - a[j]);
        }
        ans = min(ans, c);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
	int n;
	cin >> n;
	if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
	{
		puts("hon");
	}
	else if(n%10==3)
	{
		puts("bon");
	}
	else puts("pon");
	return 0;
}

Measured memory_bytes: 3128