akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            var paper = new int[10, 10];
            while ((s = Console.ReadLine()) != null)
            {
                var arr = s.Split(',').Select(int.Parse).ToArray();
                int x = arr[0];
                int y = arr[1];
                
                switch(arr[2])
                {
                    case 3:
                        if (isRange(x-2, y)) paper[x-2, y]++;
                        if (isRange(x+2, y)) paper[x+2, y]++;
                        if (isRange(x, y-2)) paper[x, y-2]++;
                        if (isRange(x, y+2)) paper[x, y+2]++;
                        goto case 2;
                    case 2:
                        if (isRange(x-1, y-1)) paper[x-1, y-1]++;
                        if (isRange(x+1, y-1)) paper[x+1, y-1]++;
                        if (isRange(x+1, y+1)) paper[x+1, y+1]++;
                        if (isRange(x-1, y+1)) paper[x-1, y+1]++;
                        goto case 1;
                    case 1:
                        paper[x, y]++;
                        if (isRange(x-1, y)) paper[x-1, y]++;
                        if (isRange(x+1, y)) paper[x+1, y]++;
                        if (isRange(x, y-1)) paper[x, y-1]++;
                        if (isRange(x, y+1)) paper[x, y+1]++;
                        break;
                }
            }
            var white = 0;
            var noop = 0;
            foreach (var v in paper)
            {
                if (v == 0) white++;
                if (v > noop) noop = v;
            }
            Console.WriteLine(white);
            Console.WriteLine(noop);
        }

        static bool isRange(int x, int y)
        {
            return 0 <= x && x < 10 && 0 <= y && y < 10;
        }
    }
}

Measured memory_bytes: 5956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */


int main(void){ 
    int d;
    cin >> d;
    if(d == 22) cout << "Christmas Eve Eve Eve";
    if(d == 23) cout << "Christmas Eve Eve";
    if(d == 24) cout << "Christmas Eve";
    if(d == 25) cout << "Christmas";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
 
  if (N[1] == N[2] ) {
    if(N[1] == N[0] || N[1] == N[3] ){
      cout << "Yes" << endl;
    }
    else{
    cout << "No" << endl;
  }
    
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
mod = 10**9 + 7
N = int(input())
A = list(map(int,input().split()))
r = 0
b = 0
y = 0
ans = 1
for i in range(N):
    f = 0
    if r == A[i]:
        r += 1
        f += 1
    if b == A[i]:
        if f == 0:
            b += 1
        f += 1
    if y == A[i]:
        if f == 0:
            y += 1
        f += 1
    ans = (ans*f) % mod
print(ans)

Measured memory_bytes: 14056
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

const ll MAX = 1000000000000000000;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long double A, B;
  cin >> A >> B;
  long double res = A * B;
  ll ans = (ll)res;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3736
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second


typedef pair<string, lint> PS;
bool lss(PS &a, PS &b){
    if(a.first!=b.first) return a.first<b.first;
    else{
        return a.second>b.second;
    }
}
signed main(){
    lint N; cin>>N;
    vector<PS> A(N);
    map<PS, lint> m;
    REP(i, N) {
        string s;
        lint p;
        cin >> s >> p;
        A[i]=make_pair(s,p);
        m[A[i]] = i+1;
    }
    sort(ALL(A), lss);
    REP(i, N){
        cout << m[A[i]] << endl;
    }
    return 0;
}

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

int main() {
	
	string a,b;
	cin>>a;
	cin>>b;
	int n=a.size(),m=b.size();
	int dp[n+1][m+1];
	
	for(int i=0;i<=n;i++)
	{
	    for(int j=0;j<=m;j++)
	    {
	        if(i==0||j==0)
	            dp[i][j]=0;
	        else if(a[i-1]==b[j-1]&&a[i-1]!=' ')
    	        dp[i][j]= dp[i-1][j-1]+1;
    	    else
    	        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	    }
	}
	string ans="";
	int x=n,y=m;
  	while(x!=0 && y!=0){
  		if(dp[x-1][y]==dp[x][y]){
  			--x;
  		}
  		else if(dp[x][y-1]==dp[x][y]){
  			--y;
  		}
  		else{
  			ans=b[y-1]+ans;
          	x--;
          	y--;
  		}
  	}
// 	reverse(s.begin(),s.end());
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 38848
#include<stdio.h>
main(){
  int a[4],i,j,k;
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  for(i=0;i<3;i++){
    for(j=i+1;j<3;j++){
      if(a[i] > a[j]){
	k = a[i];
	a[i] = a[j];
	a[j] = k;
      }
    }
  }   
  printf("%d %d %d\n",a[0],a[1],a[2]);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
  FAST/**/
   
   ll x,n;
   cin>>x>>n;
   
   set<ll> st;
   rep(n)
   {
       ll temp;
       cin>>temp;
       st.insert(temp);
   }
   
   pair<ll,ll> ans = mp(1000,-1000);
   
   for(ll i=-1;i<=105;i++)
        if(st.find(i) == st.end())
            ans = min(ans,mp(abs(i-x),i));
   
   cout<<ans.ss;            
   
   
   return 0;        
}  
  
          
   

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
const double pi=atan(1.0)*4;
typedef long long ll;
const ll mod=1e9+7; 
ll ksm(ll a,ll n){
	ll ans=1;
	while(n){
		if(n&1) ans=ans*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return ans;
} 
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	ll ans=0;
	for(int i=k;i<=n+1;i++){
		ans=(ans+(ll)i*(2*n-i+1)/2-(ll)i*(i-1)/2+1)%mod;
	} 
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 3828
k,t = map(int, input().split())
a = list(map(int, input().split()))
a = list(reversed(sorted(a)))

for i in range(t-1):
    for j in range(i+1,t):
        if a[i] == 0:
            break
        x = min(a[i], a[j])
        a[i] -= x
        a[j] -= x
print(max(sum(a)-1, 0))

Measured memory_bytes: 9132
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(n=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(n+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, n+1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## const ##
MOD=10**9+7
## libs ##
import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    n = II()
    aa = MII()
    aa.sort()
    c = Counter(aa)
    v = c.values()
    v = [1 if vi%2==1 else 2 for vi in v]
    v_len = len(v)
    v_2_num = v.count(2)
    if v_2_num%2 == 1:
        v_len -= 1
    print(v_len)



if __name__ == '__main__':
    main()

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


def max2(x, y):
    """ pythonの組み込み関数 max は2変数に対しては遅い！！ """
    if x > y:
        return x
    else:
        return y


def knapsack_weight(single=True):
    """
    重さが小さい時のナップサックDP
    :param single: True = 重複なし
    """
    N, W = map(int, input().split())  # N: 品物の種類 W: 重量制限

    """ dp[weight <= W] = 重さ上限を固定した時の最大価値 """
    dp_min = 0  # 総和価値の最小値
    dp = [dp_min] * (W + 1)

    for _ in range(N):
        w, price = map(int, input().split())
        S = reversed(range(w, W + 1))
        for weight in S:
            dp[weight] = max2(dp[weight], dp[weight - w] + price)
    return dp[W]

#######################################################################################################


print(knapsack_weight(single=True))


Measured memory_bytes: 74104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int c = scn.nextInt();
		if(a<b&&b<c){
			System.out.println("Yes");
		}else
			System.out.println("No");
		scn.close();
	}

}

Measured memory_bytes: 25876
#include <cstdio>
#include <algorithm>
#include <map>
#include <utility>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using usize = std::size_t;

using pair = std::pair<i64, i64>;

constexpr i64 MOD = 1000000007;

auto main() -> i32 {
	for (i32 i = 0; i < 5; ++i) {
		i32 x;
		scanf("%d", &x);
		if (x == 0) {
			printf("%d\n", i + 1);
		}
	}
	return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i){
    cin >> A.at(i);
  }
  vector<int> cnt(1000003);
  for (int x : A ){
    if(cnt.at(x)!=0){
      cnt.at(x) = 2;
      continue;
    }
    for (int i = x; i < 1000003; i += x) cnt.at(i) ++;
  }
  int ans = 0;
  for (int x : A){
    if(cnt.at(x)==1) ans ++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8016
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    bool ans = false;
    FOR(i,1,10) FOR(j,1,10) {
            if (i * j == n) {
                ans = true;
                break;
            }
        if (ans) break;
    }

    ATYN(ans);

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<algorithm>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<cmath>

using namespace std;

int main(){
	int Q, i;
	long A, B, x, y, z;
	scanf("%d", &Q);
	for (i = 0; i < Q; i++){
		scanf("%ld %ld", &A, &B);
		x = min(A, B);
		y = max(A, B);
		z = sqrtl(x*y);
		if (x == y){
			printf("%ld\n", 2 * z - 2);
		}
		else if (x+1==y){
			printf("%ld\n", 2 * z - 2);
		}
		else{
			if (z*z == x*y){
				z--;
			}
			if (z*(z + 1) >= x*y){
				printf("%ld\n", 2 * z - 2);
			}
			else{
				printf("%ld\n", 2 * z - 1);
			}
		}
	}

	return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

#define PARENT(x) (x/2)


ll Query(vector<vector<ll>>& table, vector<pair<ll,ll>>& tree, ll n , ll L){
   if( n < table.size() ){
        return table[n][L];
   }

   if( L - tree[n].second < 0 ) {
       return Query(table, tree, PARENT(n),L);
   }

   return  max( Query(table, tree, PARENT(n), L-tree[n].second) + tree[n].first,
                Query(table, tree, PARENT(n), L)
              );
}

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    cin >> N;
    vector<pair<ll,ll>> tree(N+1);

    tree[0] = make_pair(-1,-1);

    REP(i, N){
        ll V, W;
        cin >> V >> W;
        tree[i+1].first = V;
        tree[i+1].second = W;
        //DEBUG("tree[%lld]= (%lld, %lld)", i+1, V, W);
    }

    vector<vector<ll>> table(1024+1, vector<ll>(100001, -1));

    ll limit = min(N+1, (ll)1024+1);
    for(ll n = 1; n < limit; n++ ){
        for(ll w = 0; w <= 100000; w++ ){
            if( w == 0 ){
                table[n][w] = 0;
                continue;
            }

            if( n == 1 ){
                if( w >= tree[n].second ){
                    table[n][w] = tree[n].first;
                }else{
                    table[n][w] = 0;
                }
            }else{
               if( w - tree[n].second < 0 ) {
                  table[n][w] = table[PARENT(n)][w];
               }else{
                  table[n][w] = max(
                         table[PARENT(n)][w-tree[n].second] + tree[n].first,
                         table[PARENT(n)][w]
                      );
                }
            }
        }
    }

    /*
    for(ll n = 1; n < limit; n++ ){
        printf("[%lld]",n);
        for( ll w = 0; w <= 10; w++ ){
            printf(" %03lld,", table[n][w] );
        }
        printf("\n");
    }
    */

    ll Q;
    cin >> Q;
    REP(i, Q){
        ll v, L;
        cin >> v >> L;
        cout << Query(table, tree, v, L) << endl;
    }
}


Measured memory_bytes: 811872
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define VECV(a,n,m) vector<vector<int>> a(n, vector<int>(m));
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int gcd(int a, int b) {
  int v0 = a, v1 = b, v2 = a % b;
  while (v2 != 0) {
    v0 = v1;
    v1 = v2;
    v2 = v0 % v1;
  };
  return v1;
}

int gcd3(int a, int b,int c){
  return gcd(gcd(a,b),c);
}

int mid(int a, int b, int c){
  if(max(max(a,b),c)==a && min(min(a,b),c)==b)
    return c;
  if(max(max(a,b),c)==a && min(min(a,b),c)==c)
    return b;
  if(max(max(a,b),c)==b && min(min(a,b),c)==a)
    return c;
  if(max(max(a,b),c)==b && min(min(a,b),c)==c)
    return a;
  if(max(max(a,b),c)==c && min(min(a,b),c)==a)
    return b;
  if(max(max(a,b),c)==c && min(min(a,b),c)==b)
    return a;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll X;
  cin>>X;
  int i=0;
  ll ans=100;
  while (ans < X) {
    ans*=1.01;
    i+=1;
  }
  cout<<i<<endl;

}


Measured memory_bytes: 3652
n = int(input())
xl = []
for _ in range(n):
    x, l = map(int,input().split())
    xl.append((x-l, x+l, x, l))
xl.sort()

count = n
flag = 0
for i in range(n-1):
    if flag == 1: # this machine was removed.
        flag = 0
    else:
        left, right, x, l = xl[i]
    if xl[i+1][0] < right: # overlap
        if xl[i+1][1] <= right: # i includes i+1
            count -= 1 # remove i
        else:
            flag = 1
            count -= 1 # remove i+1

print(count)

Measured memory_bytes: 24936
def InS(): return input()


def InL(): return list(map(int, input().split()))


def InI(): return int(input())


N, M = (int(x) for x in input().split(" "))

i = 0
WAcnt = [0] * N
stack = [False] * N
WAcnt
# stack = []

data_list = [list(map(str, input().split(" "))) for i in range(M)]

if M == 0:
    print(0, 0)
else:
    while M > i:
        if stack[int(data_list[i][0]) - 1] == False:
            if data_list[i][1] == "AC":
                stack[int(data_list[i][0]) - 1] = True
            else:
                WAcnt[int(data_list[i][0]) - 1] += 1
        i += 1
    res = 0
    for i in range(N):
        if stack[i]:
            res += WAcnt[i]

    print(sum(stack), res)


Measured memory_bytes: 33716
#include <stdio.h>


int main(void)
{
    int a, b;
    char c;
    int ctr[5];
    
    
    ctr[1] = ctr[2] = ctr[3] = ctr[4] = 0;
    
    
    scanf("%d%c%d", &a, &c, &b);
    ctr[a]++;
    ctr[b]++;
    scanf("%d%c%d", &a, &c, &b);
    ctr[a]++;
    ctr[b]++;
    scanf("%d%c%d", &a, &c, &b);
    ctr[a]++;
    ctr[b]++;
    
    
    if(ctr[1] < 3 && ctr[2] < 3 && ctr[3] < 3 && ctr[4] < 3)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    
    //system("pause");
    
    return 0;
}


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

int main(){
  int a,b,k,l;
  cin >> a >> b >> k;
  l=0;
  for(int i=100;i>0;i--){
    if(a%i==0 && b%i==0){
      l++;
      if(l==k){
        cout << i;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
"use strict";
function main(input) {
  const inputs = input.split("\n").filter(x => x !== "");
  let N = Number(inputs[0]);

  function resolve(n) {
    let result = Array(n + 1).fill(0);
    for (let i = 2; i <= n; i++) {
      let cur = i;
      for (let j = 2; j <= i; j++) {
        while (cur % j === 0) {
          result[j] += 1;
          cur = cur / j;
        }
      }
    }
    return result;
  }

  function findLargerThan(num, array) {
    return array.filter(element => element >= num).length;
  }

  function combination(numA, numB) {
    let result = 1;
    for (let i = numA; i > numA - numB; i = i - 1) {
      result = result * i;
    }

    for (let i = numB; i > 0; i = i - 1) {
      result = result / i;
    }
    return result;
  }

  let result = resolve(N);

  let l74 = findLargerThan(74, result);
  let l24 = findLargerThan(24, result);
  let l14 = findLargerThan(14, result);
  let l4 = findLargerThan(4, result);
  let l2 = findLargerThan(2, result);

  let r5x5x3 = (l4 * (l4 - 1) * (l2 - 2)) / 2;
  let r15x5 = l14 * (l4 - 1);
  let r25x3 = l24 * (l2 - 1);
  let r75 = l74;

  console.log(
    l74 + l24 * (l2 - 1) + l14 * (l4 - 1) + (l4 * (l4 - 1) * (l2 - 2)) / 2
  );
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include<cstdio>
int main(){
	char a=getchar();
	char b=getchar();
	char c=getchar();
	char d=getchar();
	int d1=(a-48)*10+b-48;
	int d2=(c-48)*10+d-48;
	if(d1>12||d1==0){
		if(d2>12||d2==0)puts("NA");
		else puts("YYMM");
	}
	else{
		if(d2>12||d2==0)puts("MMYY");
		else puts("AMBIGUOUS");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int MOD = 1000000007;
const ll INF = 1LL << 60;

int dp[3005][3005];

int main(){
  string s,t; cin >> s >> t;
  memset(dp,0,sizeof(dp));
  int n = s.size(), m = t.size();

  rep(i,n)rep(j,m){
    if(s[i] == t[j]) chmax(dp[i+1][j+1],dp[i][j] + 1);
    chmax(dp[i+1][j+1],dp[i+1][j]);
    chmax(dp[i+1][j+1],dp[i][j+1]);
  }
  
  string ans = "";
  int i = n, j = m;
  
  while(i>0 && j>0){
    if(dp[i][j] == dp[i-1][j]) i--;
    else if(dp[i][j] == dp[i][j-1]) j--;
    else{
      i--;j--;
      ans = s[i] + ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35584
#include<iostream>
#include<algorithm>
using namespace std;
struct point{
    int x_coo;
    int y_coo;
    int height;
};
int main(){
    int n,i;
    cin>>n;
    point p[n];
    for(i=0;i<n;i++){
        cin>>p[i].x_coo>>p[i].y_coo>>p[i].height;
    }
    int cx,cy,ch,flag,h;
    for(cx=0;cx<101;cx++){
        for(cy=0;cy<101;cy++){
            flag=0;
            for(i=0;p[i].height==0;i++);
            ch=p[i].height+abs(cx-p[i].x_coo)+abs(cy-p[i].y_coo);
            for(i=0;i<n;i++){
                h=ch-abs(cx-p[i].x_coo)-abs(cy-p[i].y_coo);
                if(h<0)h=0;
                if(h!=p[i].height){flag=1;break;}
            }
            if(!flag)goto a1;
        }
    }
    a1:cout<<cx<<' '<<cy<<' '<<ch;
    return 0;
}

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

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

  Y /= 1000;
  for (int x = 0; x <= N; x++) {
    for (int y = 0; y <= N - x; y++) {
      int z = Y - (10 * x + 5 * y);
      if (z == N - (x + y)) {
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
//標準関数をすべてインクルードする。
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

const int_least64_t INF = 10000000;

int main(){
    //cin coutを高速化
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

    int s, w;
    cin >> s >> w;

    if(w >= s){
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    } 

    return 0;
}



Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll A, B, K; std::cin >> A >> B >> K;
  ll M = std::min(A,K);
  A -= M;
  K -= M;
  std::cout << A << " " << std::max(0LL, B-K) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,a[101],i,b[100],j,l,flg,c[100];
	scanf("%d",&n);
	while(n!=0){
	    for(i=0;i<n+1;i++){
		    scanf("%d",&a[i]);
		}
		for(i=0;i<n+1;i++){
		    l=0;
			flg=0;
		    for(j=0;j<n;j++){
			    if(i!=j){
				    b[j]=a[l];
				}
				else{
				    l++;
				    b[j]=a[l];
				}
				l++;
			}
			for(j=0;j<n;j++){
			    c[j]=b[j+1]-b[j];
			}
			for(j=0;j<n-1;j++){
			    if(c[j]!=c[j+1]&&j!=n-2){
				    flg=1;
				}
				else if(c[j-1]!=c[j]&&j==n-1){
				    flg=1;
				}
			}
			if(flg==0){
			    printf("%d\n",a[i]);
				break;
			}
		}
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 2760
#include<stdio.h>
#define N 105
#define INF 100000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N]={};

void dijkstra(void){
    int min,i,v;
    int d[N],color[N];
    for(i=0;i<n;i++){
        d[i]=INF;
        color[i]=WHITE;
    }
    d[0]=0;
    color[0]=GRAY;
    while(1){
        min=INF;
        int u=-1;
        for(i=0;i<n;i++){
            if(min>d[i] && color[i]!=BLACK){
                u=i;
                min=d[i];
            }
        }
        if(u==-1)break;
        color[u]=BLACK;
        for(v=0;v<n;v++){
            if(color[v]!=BLACK && M[u][v]!=INF){
                if(d[v] > d[u]+M[u][v]){
                    d[v]=d[u]+M[u][v];
                    color[v]=GRAY;
                }
            }
        }
    }
    for(i=0;i<n;i++){
        printf("%d ",i);
        if(d[i]==INF)printf("%d\n",-1);
        else printf("%d\n",d[i]);
    }
}

int main(){
    int i,j,u,k,c,v;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            M[i][j]=INF;
        }
    }
    for(i=0;i<n;i++){
        scanf("%d%d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d%d",&v,&c);
            M[u][v]=c;
        }
    }
    dijkstra();
    return 0;
}



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

using namespace std;

int d[110];

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> indexPairList;
    for (int i = 0; i < N; ++i) {
        cin >> d[i];
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if(i == j) continue;
            bool alreadyAdd = false;
            for (auto pair : indexPairList) {
                if ((pair.first == i && pair.second == j)
                      || (pair.first == j && pair.second == i)) {
                    alreadyAdd = true;
                    break;
                }
            }
            if (!alreadyAdd) {
                indexPairList.emplace_back(i, j);
            }
        }
    }
    int sum = 0;
    for (auto & i : indexPairList) {
        sum += d[i.first] * d[i.second];
    }
    cout << sum << endl;
}

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

int main() {
	int n[3];
	int tmp;

	cin >> n[0] >> n[1] >> n[2];

	if (n[0] > n[1]) {
		tmp = n[0];
		n[0] = n[1];
		n[1] = tmp;
	}

	if (n[0] > n[2]) {
		tmp = n[0];
		n[0] = n[2];
		n[2] = tmp;
	}

	if (n[1] > n[2]) {
		tmp = n[1];
		n[1] = n[2];
		n[2] = tmp;
	}

	cout << n[0] << " ";
	cout << n[1] << " ";
	cout << n[2] << endl;

	return 0;

}


Measured memory_bytes: 3084
(defn otoshidama [N,Y](if-let [x (first (for [A (range (inc N)) B (range (- (inc N) A)) :let [C (- N A B)] :when (= Y (+(* 10000 A) (* 5000 B) (* 1000 C)))] (format "%d %d %d" A B C)))] x "-1 -1 -1"))
(println (otoshidama (read) (read)))

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



ll a[100010];
ll b[100010];
ll c[100010];
int N;

ll acalc(ll key) {
  int ok = -1,ng = N;
  while(abs(ng-ok)>1) {
    int mid = (ng + ok)/2; 
    if(a[mid] < key) ok = mid;
    else ng = mid;
  }
  return ok + 1;
}

ll ccalc(ll key) {
  int ok = N,ng = -1;
  while(abs(ng-ok)>1) {
    int mid = (ng+ok)/2;
    if(c[mid] > key) ok = mid;
    else ng = mid;
  }
  return N - ok;
}


int main() {
  cin >> N;
  rep(i,N) cin >> a[i];sort(a,a+N);
  rep(i,N) cin >> b[i];sort(b,b+N);
  rep(i,N) cin >> c[i];sort(c,c+N);
  ll ans = 0;
  rep(i,N) {
    ans += (acalc(b[i]) * ccalc(b[i]));
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    string n;
    cin >> n;
    int a = 0, b = 1;
    for(int i = 0; i < n.length(); i++) {
        int c = a;
        a = min(a + n[i] - '0', b - n[i] + '1' + 9);
        b = min(c + n[i] + 1 - '0', b + '9' - n[i]);
    }
    cout << a << endl;
    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    string s;
    cin >> s;
    if( s[0] == s[2] ) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
const int MOD = 1e9+7;

bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; }
    return true;
}

int main() {
	int A,B;
  	cin >> A>>B;
  	if(A == 1) A = 14;
  	if(B == 1) B =14;
  	if(A==B) cout << "Draw" << endl;
  	else if(A>B)cout << "Alice" << endl;
  	else if(A < B)cout << "Bob" << endl;
  
  
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  
  int S[10000], T[500], n, m, i, j, num = 0;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&m);
  
  for(i = 0; i < m; i++){
    scanf("%d",&T[i]);
  }
  for(i = 0; i < m; i++){
    for(j = 0; j < n; j++){  
      if(T[i] == S[j]) {
        num++;
        break;
      }
    }
  }
  printf("%d\n", num);
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const ll mod = 1e9 + 7;				//adjust mod value according to your need
int main()
{
	SPEED
	int n;
	cin >> n;
	int t1 = (n*100)/108;
	int t2 = t1 + 1;
	bool sol = false;
	float d1 = t1*1.08;
	float d2 = t2*1.08;
	if (floor(d1)==n)
	{
		cout << t1;
		return 0;
	}
	if (floor(d2)==n)
	{
		cout << t2;
		return 0;
	}
	cout << ":(";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    
    vector<int> im;
    map<int, lli> m;
    int n, a;
    cin >> n;
    rep(i, n){
        cin >> a;
        m[a]++;
        im.push_back(a);
    }

    lli sum = 0;
    for(auto p : m){
        sum += (p.second) * (p.second-1) / 2;
    }

    for(auto p : im){
        lli sub = m[p] - 1;
        cout << sum - sub << endl;
    }
    return 0;
}

Measured memory_bytes: 10356
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE BangPatterns #-}

module Main where

import Debug.Trace
import Control.Monad
--import Data.List
--import qualified Data.Set.Strict as Set
--import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as Map

main :: IO ()
main = do
  getLine
  as <- map read . words <$> getLine
  getLine
  qs <- map (map read . words) . lines <$> getContents 
  --a `traceShow`
  forM_ (solve as qs) $ \s -> do
    print s

solve :: [Int] -> [[Int]] -> [Int]
--solve as qs = ["aa", "bb", "cc"]
solve as qs = build tbl st qs
  where
    tbl = foldr (\a m -> Map.insertWith (+) a 1 m) Map.empty as
    st = sum as


--build :: Map.Map Int Int -> Int -> [[Int]] -> [Int]
build :: Map.IntMap Int -> Int -> [[Int]] -> [Int]
--build m ([b, c]:qs) =  m' `traceShow` (Map.foldrWithKey (\k a ks -> ks + k * a) 0 m') : build m' qs
build m !prev ([!b, !c]:qs) = cur : build m' cur qs
  where
    (cur ,m') = case Map.lookup b m of
      Just k -> (prev + k * (c - b), Map.insertWith (+) c k (Map.delete b m))
      Nothing -> (prev, m)
build m _ [] = []


Measured memory_bytes: 37616
import sys
s = input()
a = int(s[0])
b=[]
for i in range(3):
    b.append(int(s[i+1]))

for i in range(8):
    tmp = a
    for j in range(3):
        if (i>>j) & 1 == 0:
            tmp += b[j]
            
        else:
            tmp -= b[j]
    if tmp == 7:
        ans = [str(a)]
        for k in range(3):
            if (i>>k) & 1 == 0:
                ans.append("+")
            else:
                ans.append("-")
            ans.append(str(b[k]))
        print(''.join(ans),end="")
        print("=7")
        sys.exit()



Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
const int MOD=1e9+7;
const int INF=1<<29;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
const int N=1e5+11;
int dp[N];
bool visited[N];
void solve(){
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++)visited[i]=false;
  for(int i=1;i<=m;i++){
	   int x;
	   cin>>x;
	   visited[x]=true;
	 }
   dp[0]=1;
   for(int i=1;i<=n;i++){
	  dp[i]=(dp[i-1]+dp[i-2])%MOD;
	  dp[i]%=MOD;
	  if(visited[i])dp[i]=0;  
	 }
	 cout<<dp[n]<<endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}


Measured memory_bytes: 1152
import Control.Applicative

type Dict = [Content]
type Content = (String, Int)

main = do
  word <- words <$> getLine
  let longest = searchMax $ addWordLens word []
      modeWord = searchMax $ addWords word []
  putStr $ fst modeWord
  putStr " "
  putStrLn $ fst longest

addWord :: String -> Dict  -> Dict
addWord word dict = case lookup word dict of
                         Nothing -> (word, 1) : dict
                         Just n -> (word, n+1) : dict

addWords :: [String] -> Dict -> Dict
addWords words dict = foldl (flip addWord) dict words
addWordLen :: String -> Dict -> Dict
addWordLen word dict = case lookup word dict of
                            Nothing -> (word, length word) : dict
                            Just n  -> dict

addWordLens :: [String] -> Dict -> Dict
addWordLens words dict = foldl (flip addWordLen) dict words

searchMax :: Dict -> Content
searchMax = foldl maxNum ("a",minBound)

maxNum :: Content -> Content -> Content
maxNum (a,na) (b,nb)
  | na >= nb = (a,na)
  | na <  nb = (b,nb)

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

const ll INF = 1LL << 60;

int main(){
	ll n;
	cin >> n;
	vector<pair<ll, ll>> p(n);
	rep(i,n){
		ll x,y;
		cin >> x >> y;
		p[i].first = x - y;
		p[i].second = x + y;
	}
	ll ans = 0;
	ll max_1 = -INF;
	ll min_1 = INF;
	rep(i,n){
		max_1 = max(p[i].first, max_1);
		min_1 = min(p[i].first, min_1);
	}
	ans = max(max_1 - min_1, ll(0));
	ll max_2 = -INF;
	ll min_2 = INF;
	rep(i,n){
		max_2 = max(p[i].second, max_2);
		min_2 = min(p[i].second, min_2);
	}
	ans = max(ans, max_2 - min_2);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 6332
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int n;
    cin >> n;
    int res = 0;
    rep(i,n){
        int l,r;
        cin >> l >> r;
        res += r-l+1;
    }
    cout << res << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
from collections import deque
 
h, w = map(int, input().split())
a = ''.join(input() + '#' for _ in range(h))
n = len(a) - 1
b = ['#'] * w
r = 0
for i in range(n):
  if a[i] == '.':
    b[:-w] = a
    b[i] = 0
    q = deque([i])
    while(q):
      i = q.popleft()
      r = max(r, b[i])
      for j in (i - 1, i + 1, i - w - 1, i + w + 1):
        if b[j] == '.':
          b[j] = b[i] + 1
          q.append(j)
print(r)


Measured memory_bytes: 3316
#include <iostream>
#include <cassert>
#include <cstring>
#include <vector>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while(t--){
        int n,k;
        cin >> n >> k;
        vector<int> a(n);
        for(int i=0 ; i<n ; i++){
            cin >> a[i];
        }
        vector<short> dp(k+1,0);
        for(int i=0 ; i<=k ; i++){
            bool found = false;
            for(int j=0 ; j<n && i-a[j]>=0 && !found ; j++){
                if(dp[i-a[j]]==0)
                    found = true;
            }
            if(found) dp[i] = 1;
        }

        if(dp[k]) cout <<  "First\n";
        else cout << "Second\n";
    }
    return 0;
}



Measured memory_bytes: 3648
// ███▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓╬╬╬╬╬╬▓█
// ███▓███████▓▓╬╬╬╬╬╬╬╬╬╬╬╬▓███▓▓▓▓█▓╬╬╬▓█
// ███████▓█████▓▓╬╬╬╬╬╬╬╬▓███▓╬╬╬╬╬╬╬▓╬╬▓█
// ████▓▓▓▓╬╬▓█████╬╬╬╬╬╬███▓╬╬╬╬╬╬╬╬╬╬╬╬╬█
// ███▓▓▓▓╬╬╬╬╬╬▓██╬╬╬╬╬╬▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬╬╬╬▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓███████▓▓███▓╬╬╬╬╬╬▓███████▓╬╬╬╬▓█
// ████████████████▓█▓╬╬╬╬╬▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬█
// ███▓▓▓▓▓▓▓╬╬▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬▓▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓▓█▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓██▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// █████▓▓▓▓▓████▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓█▓▓▓▓██▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓▓███▓▓▓▓▓▓▓██▓╬╬╬╬╬╬╬╬╬╬╬╬█▓╬▓╬╬▓██
// █████▓███▓▓▓▓▓▓▓▓████▓▓╬╬╬╬╬╬╬█▓╬╬╬╬╬▓██
// █████▓▓█▓███▓▓▓████╬▓█▓▓╬╬╬▓▓█▓╬╬╬╬╬╬███
// ██████▓██▓███████▓╬╬╬▓▓╬▓▓██▓╬╬╬╬╬╬╬▓███
// ███████▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬████
// ███████▓▓██▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓████
// ████████▓▓▓█████▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█████
// █████████▓▓▓█▓▓▓▓▓███▓╬╬╬╬╬╬╬╬╬╬╬▓██████
// ██████████▓▓▓█▓▓▓╬▓██╬╬╬╬╬╬╬╬╬╬╬▓███████
// ███████████▓▓█▓▓▓▓███▓╬╬╬╬╬╬╬╬╬▓████████
// ██████████████▓▓▓███▓▓╬╬╬╬╬╬╬╬██████████
// ███████████████▓▓▓██▓▓╬╬╬╬╬╬▓███████████
//#include "grader.h"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define read(FILENAME) assert(freopen((FILENAME + ".in").c_str(), "r", stdin))
#define write(FILENAME) assert(freopen((FILENAME + ".out").c_str(), "w", stdout))
#define files(FILENAME) read(FILENAME), write(FILENAME)
using namespace std;
template <typename A, typename B> void chkmin(A &x, B y) {if (x > y) x = y;}
template <typename A, typename B> void chkmax(A &x, B y) {if (x < y) x = y;}
     
typedef pair <int, int> point;
     
const string FILENAME = "input";
const int MAXN = 1e5, p = 1e9 + 7;

string s;

bool check(string s) {
	for (auto c: s) {
		if (c != s[0])
			return false;
	}
	return true;
}

int f(char c) {
	string k = s;
	while (!check(k)) {
		for (int i = 0; i + 1 < k.size(); ++i) {
			if (k[i] == c || k[i + 1] == c)
				k[i] = c;
		}
		k.pop_back();
	}
	return s.size() - k.size();
}

int main() {
	//read(FILENAME);
	cin >> s;
	int ans = s.size();
	for (char c = 'a'; c <= 'z'; ++c) {
		chkmin(ans, f(c));
	}
	cout << ans << endl;
}








Measured memory_bytes: 256
#最小費用流問題
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,m,f = map(int,readline().split())
"""
n頂点m辺の重み付き有向グラフに流量fを流したい。
コストの最小値を出力せよ。
但しsourse = 0,sink = n-1とし、
そもそも流量f流せるだけcapacityがない場合は-1を出力せよ。
"""
# 最小費用流(minimum cost flow)
class MinCostFlow:
    def __init__(self, n):
        self.n = n
        self.G = [[] for i in range(n)]

    def addEdge(self, f, t, cap, cost): #costは1capに対して1costで定義される
        # [to, cap, cost, rev]↓revは勝手に逆辺張ってくれるので考えなくて良い。
        self.G[f].append([t, cap, cost, len(self.G[t])])
        self.G[t].append([f, 0, -cost, len(self.G[f])-1])

    def minCostFlow(self, s, t, f): #sからtまで、流量fを流し切る
        n = self.n
        G = self.G
        prevv = [0]*n; preve = [0]*n
        INF = 10**18

        res = 0 #コスト合計
        while f:
            dist = [INF]*n
            dist[s] = 0
            update = 1
            while update:
                update = 0
                for v in range(n):
                    if dist[v] == INF:
                        continue
                    gv = G[v]
                    for i in range(len(gv)):
                        to, cap, cost, rev = gv[i]
                        if cap > 0 and dist[v] + cost < dist[to]:
                            dist[to] = dist[v] + cost
                            prevv[to] = v; preve[to] = i
                            update = 1
            if dist[t] == INF: #そもそもcapacity的に流量fを流せない場合
                return -1

            d = f; v = t
            while v != s:
                d = min(d, G[prevv[v]][preve[v]][1])
                v = prevv[v]
            f -= d
            res += d * dist[t] #distには、一本の道全体としての単位コストが入っている。
            #dだけ流せるので、d*その道全体のコストを,コスト合計のresに入れる。
            v = t
            while v != s:
                e = G[prevv[v]][preve[v]]
                e[1] -= d
                G[v][e[3]][1] += d
                v = prevv[v]
        return res

MCF = MinCostFlow(n)
for i in range(m):
    u,v,cap,cost = map(int,readline().split())
    MCF.addEdge(u,v,cap,cost)

print(MCF.minCostFlow(0,n-1,f))


Measured memory_bytes: 5808
# include<bits/stdc++.h>
using namespace std;
int main(){
	string s1,s2;
  cin >> s1;
  cin >> s2;
  int count = 0;
  for(int i = 0; i < min(s1.length(),s2.length()); i++){
  if (s1[i]==s2[i])
    count += 1;
  }
  cout << count<<'\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>

using namespace std;

long long n, k, t, s;
long long a[100100];

int main () {
    cin >> n; s = pow(10, 16);
    for ( int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for ( int i = 1; i <= 100; i++) {
        t = 0;
        for ( int j = 1; j <= n; j++) {
            t = t + (a[j] - i) * (a[j] - i);
        }
        s = min(s, t);
    }
    cout << s;
}


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

int main() {
  long n,ans=0;
  cin >> n;
  vector<long> p(n);
  vector<long> gyakup(n);
  set<long> aaa;
  for(long i=0;i<n;i++) cin >> p[i];
  
  for(long i=0;i<n;i++) gyakup[n-p[i]]=i;
  for(long i=0;i<n;i++) {
    aaa.insert(gyakup[i]);
    long a=-1,b=-1,c=gyakup[i],d=-1,e=n;
    auto itr=aaa.lower_bound(gyakup[i]);
    if(itr!=aaa.begin()) {
      itr--;
      b=*itr;
    }
    if(itr!=aaa.begin()) {
      itr--;
      a=*itr;
    }
    itr=aaa.upper_bound(gyakup[i]);
    if(itr!=aaa.end()) {
      d=*itr;
      itr++;
    }
    if(itr!=aaa.end()) {
      e=*itr;
    }

    if(b!=-1) {
      if(d!=-1) ans+=(n-i)*(b-a)*(d-c);
      else ans+=(n-i)*(b-a)*(n-c);
    }
    if(d!=-1) {
      if(b!=-1) ans+=(n-i)*(e-d)*(c-b);
      else ans+=(n-i)*(e-d)*(c+1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e2+5;
char s[N];
int n,k;
ll f[N][105];
ll dfs(int pos,int x,bool pre,bool limit) {
	//printf("%d %d %d %d\n",pos,x,pre,limit);
	if(pos==n+1) return pre&&x==k;
	if(~f[pos][x]&&!limit) return f[pos][x];
	int up=limit?(s[pos]-'0'):9;
	ll ans=0;
	for(int i=0;i<=up;i++) {
		if(i) ans+=dfs(pos+1,x+1,true,i==up&&limit);
		else ans+=dfs(pos+1,x,pre,i==up&&limit);
	}
	if(!limit) f[pos][x]=ans;
	return ans;
}
int main() {
	memset(f,-1,sizeof f);
	scanf("%s%d",s+1,&k);
	n=strlen(s+1);
	ll ans=0;
	ans+=dfs(2,0,false,false);
	int up=s[1]-'0';
	for(int i=1;i<=up;i++) {
		ans+=dfs(2,1,true,i==up);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384