akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc157/tasks/abc157_e
// AtCoder Beginner Contest 157
// E - Simple String Queries

/*
Problem.
n文字の文字列が与えられて、それに対してQ個のクエリが与えられる。
クエリは、type1,2があり、
type1:i文字目をcに変更する。
type2:l文字目からr文字目までで、出現した文字の種類を答える。

Point.
各文字種に対して、出現位置をsetで管理する。
2分探索でset内のl以上の最小位置を調べて、r以下であればカウントして行く。
O(26*Q*logN)
*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<ctime>
#include<set>

using namespace std;
using ll = long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  ll n, q;
  cin >> n;
  vector<set<int>> point(26); //配列にしたらTLEしちゃた（これはポカ）
  string s; cin >> s;
  for(int i = 0; i < n; i++){
    point[s[i]-'a'].insert(i);
  }
  cin >> q;
  for(int k = 0; k < q; k++){
    int t;
    cin >> t;
    if(t == 1){
      int i; char c;
      cin >> i >> c;
      i--;
      point[s[i]-'a'].erase(i);
      s[i] = c;
      point[s[i]-'a'].insert(i);
    }
    else{
      int l, r;
      cin >> l >> r;
      l--, r--;
      int tmp = 0;
      for(int j = 0; j < 26; j++){
        auto it = point[j].lower_bound(l);
        if(it != point[j].end() && (*it) <= r) tmp++;
      }
      cout << tmp << endl;
    }
  }

  // end-----------------------------------------------
  cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 24220
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
	int N,K; cin >> N >> K;
	vector<int> h(N);
	int ans = 0;
	rep(i,N){
		cin >> h[i];
		if(h[i] >= K) ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;

int main() {
	int n;
	cin >> n;
	
	string third;
	third = "C";
	
	if (n > 999) {
		n -=  999;
		third = "D";
	}
	
	cout << "AB" + third  << endl;
}

Measured memory_bytes: 256
s = input()
acgt = ['A', 'C', 'G', 'T']
s_list = list(s)

part_len = 0
max_len = 0

for s in s_list:
	if s in acgt:
		part_len += 1
		if part_len > max_len:
			max_len = part_len
	else:
		part_len = 0

print(max_len)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <numeric>
#include <functional>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> A;
    A.reserve(n);
    copy_n(istream_iterator<int>(cin), n, back_inserter(A));

    int neg = count_if(A.begin(), A.end(), [](int x) { return x < 0; });
    for_each(A.begin(), A.end(), [](int &x) { x = abs(x); });
    long long ans = accumulate(A.begin(), A.end(), 0LL);
    if (neg & 1) {
        int z = *min_element(A.begin(), A.end());
        ans -= 2LL * z;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n % 2 == 0) return powmod((a * a) % mod, n / 2, mod);
	return (a * powmod(a, n - 1, mod)) % mod;
}

void chmax(int &a, int b) { a = max(a, b); }

int mod = 1000000007;
int n;
int a[10000];
int sisu[1000001];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	
	rep(i, n) {
		int t = a[i];
		for (int j = 2; j * j <= t; j++) {
			int cnt = 0;
			while (t % j == 0) {
				t /= j;
				cnt++;
			}
			chmax(sisu[j], cnt);
		}
		if (t > 1) chmax(sisu[t], 1);
	}
	
	//rep(i, 10) cout << "i = " << i << ", sisu = " << sisu[i] << endl;
	
	int mul = 1;
	rep(i, 1000001) {
		mul *= powmod(i, sisu[i], mod);
		mul %= mod;
	}
		
	int ans = 0;
	rep(i, n) {
		int b = mul;
		int t = a[i];
		
		for (int j = 2; j * j <= t; j++) {
			int cnt = 0;
			while (t % j == 0) {
				t /= j;
				cnt++;
			}
			b *= powmod(j, cnt * (mod - 2), mod);
			b %= mod;
		}
		if (t > 1) {
			b *= powmod(t, mod - 2, mod);
			b %= mod;
		}
		
		//cout << "b = " << b << endl;
		ans += b;
		ans %= mod;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6656
fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];

    if a == b {
        println!("Draw");
    } else if a == 1 || (b != 1 && a > b) {
        println!("Alice");
    } else {
        println!("Bob");
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

void fnInput(int& rnTrgSu, int& rnTrgKin)
{
  cin >> rnTrgSu >> rnTrgKin;
}

int fnRcsSch(int nPos, int nTrgSu, int nTrgKin, vector<int>& rvnNumMoney)
{
  vector<int> cnvnMoney{10000, 5000, 1000};

  if (nTrgKin < 0)  return -1;
  if (nPos == rvnNumMoney.size() - 1)
  {
    rvnNumMoney[nPos] = nTrgSu;
    if (nTrgKin - cnvnMoney[nPos] * nTrgSu == 0)
      return 1;
    else
      return 0;
  }

  for (int i = 0; i <= nTrgSu; i++)
  {
    rvnNumMoney[nPos] = i;
    int nRtn = fnRcsSch(nPos + 1, nTrgSu - i, nTrgKin - cnvnMoney[nPos] * i, rvnNumMoney);
    if      (nRtn == -1)  return 0;
    else if (nRtn)        return 1;
  }

  return 0;
}

int fnExhSch(int nTrgSu, int nTrgKin)
{
  vector<int> vnNumMoney(3);

  if (fnRcsSch(0, nTrgSu, nTrgKin, vnNumMoney))
    cout << vnNumMoney[0] << " " << vnNumMoney[1] << " " << vnNumMoney[2] << endl;
  else
    cout << -1 << " " << -1 << " " << -1 << endl;
}

int main()
{
  int nTrgSu, nTrgKin;
  
  fnInput(nTrgSu, nTrgKin);
  fnExhSch(nTrgSu, nTrgKin);

  return 0;
}
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,ans=0;
  bool k[1005];
  for(int i=0;i<1005;i++)
    k[i]=false;
  cin>>a>>b;
  for(int i=0;i<b;i++){
    int u;
    cin>>u;
    for(int j=0;j<u;j++){
      int f;
      cin>>f;
      k[f-1]=true;
    }
  }
  for(int i=0;i<a;i++)
    if(k[i]==false)
      ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rFOR(i, a, b) for(int i=b-1; i>=a; i--)
#define MAX 10000
typedef long long ll;
using namespace std;

int powN[10000];
void makePowNum(int n){
  rep(i, n){
    powN[i] = pow(i, 2);
  }
}

int main(void){
  string a, b;  cin >> a >> b;
  int n = stoi(a+b);
  makePowNum(MAX);
  rep(i, MAX){
    if(powN[i] == n){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int main() {
  int N, T;
  scanf("%d %d", &N, &T);

  int c_min = 1001;
  for (int i = 0; i < N; ++i) {
    int c, t;
    scanf("%d %d", &c, &t);

    if (t <= T)
      c_min = std::min(c_min, c);
  }

  if (c_min > 1000) {
    puts("TLE");
  } else {
    printf("%d\n", c_min);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  int K, A, B;
  cin >> K >> A >>B;

  for (int i = A; i <= B; i++) {
    if( i % K == 0){
      cout << "OK" << endl;
      return 0;
    }
  }

  cout << "NG" << endl;

  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int a[12000];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	cout<<a[n]-a[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()


def judge(s):
    if len(s) % 2 == 1:
        print("No")
        return
    for i in range(0, len(s)//2):
        if(s[i] != s[len(s)//2 + i]):
            print("No")
            return
    print("Yes")
    return


judge(s)

Measured memory_bytes: 38384
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

s = input()
li = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
li_cnt = [0]*26
for i in range(len(s)):
    for j in range(len(li)):
        if li[j] == s[i]:
            li_cnt[j] += 1
ans = ""
for i in range(len(li_cnt)):
    if li_cnt[i] == 0:
        ans += li[i]
        break
if len(ans) == 0:
    print("None")
else:
    print(ans)

Measured memory_bytes: 20640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_127
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            int len = 100000 + 5;
            int[] cnt = new int[len];
            for(int i =0; i < m; i++)
            {
                int[] lr = ReadInts();
                cnt[lr[0]]++;
                cnt[lr[1] + 1]--;
            }

            for(int i =1; i < len; i++)
            {
                cnt[i] += cnt[i - 1];
            }
            int res = 0;
            for(int i = 0; i < len; i++)
            {
                if (cnt[i] == m) res++;
            }

            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 15436
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nx = readln.split.to!(int[]);
    auto N = nx[0];
    auto X = nx[1];
    int min_m = int.max;
    foreach (_; 0..N) {
        auto m = readln.chomp.to!int;
        X -= m;
        min_m = min(min_m, m);
    }
    writeln(N + X/min_m);
}

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

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

int main() {
  int H, W;
  std::cin >> H >> W;

  std::vector<std::string> S(H);

  for (int i = 0; i < H; i++) {
    std::cin >> S[i];
  }

  std::vector<std::vector<int>> costs(H, std::vector<int>(W, 1 << 30));
  std::queue<std::pair<int, int>> que;

  costs[0][0] = 0;

  for (que.push(std::make_pair(0, 0)); !que.empty(); que.pop()) {
    int x = que.front().first, y = que.front().second;

    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];

      if (nx >= 0 && nx < W && ny >= 0 && ny < H && S[ny][nx] == '.') {
        if (costs[ny][nx] > costs[y][x] + 1) {
          costs[ny][nx] = costs[y][x] + 1;
          que.push(std::make_pair(nx, ny));
        }
      }
    }
  }

  if (costs[H-1][W-1] == (1 << 30)) {
    std::cout << -1 << std::endl;
  } else {
    int dots = 0;

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        dots += (S[i][j] == '.' ? 1 : 0);
      }
    }

    std::cout << dots - costs[H-1][W-1] - 1 << std::endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            //#define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                ios_base::sync_with_stdio(false);
                cin.tie(NULL);
                lli t,n,i,j,a,b,q,m;
                cin>>n>>a>>b;
                if(abs(a-b)%2==0){
                    cout<<(abs(a-b)/2)<<endl;
                    return 0;
                }
                lli ans1=INT_MAX;
                lli mi=min(a,b);
                lli ma=max(a,b);
                ans1=mi;
                ma-=mi;
                ans1+=ma/2;
                ma=max(a,b);
                lli ans2=n-ma+1;
                lli nmi=n-mi;
                nmi-=n-ma+1;
                ans2+=nmi/2;
                lli ans=min(ans1,ans2);
                cout<<ans<<endl;

                return 0;
            }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll x; cin >> x;
  ll n; cin >> n;
  vector<ll> p(n);
  for (int i=0; i<n; i++){
    cin >> p[i];
  }
  if (n == 0) {
    cout << x << endl;
    return 0;
  }
  sort(p.begin(),p.end());
  ll mi = inf;
  ll ans = 1;
  for (int i=0; i<=101; i++) {
    bool flg = false;
    for (int j=0; j<n; j++) {
      if (p[j] == i) flg = true;
    }
    if (flg) continue;
    if (mi > abs(x-i)) {
      mi = abs(x-i);
      ans = i;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
N = int(input())
MOD_BY = 10**9 + 7

#全通り 10**(N)
#0を1個も含まない　9**(N)
#9を1個も含まない　9**(N)
#0も9を1個も含まない　8**(N)

#https://wakabame.hatenablog.com/entry/2017/09/21/012844
#a**n mod pの高速計算
def power_func(a,n,p):
    bi = str(format(n,"b"))#2進表現に
    res = 1
    for i in range(len(bi)):
        res = (res*res) %p
        if bi[i] == "1":
            res = (res*a) %p
    return res
  
a = power_func(10,N,MOD_BY)
b = power_func(9,N,MOD_BY)
c = power_func(8,N,MOD_BY)
ans = a - 2*b + c
print(ans%MOD_BY)

Measured memory_bytes: 9200
#include <iostream>
using namespace std;
int n, c[109]; bool dp[109][109], dp2[109];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> c[i], dp[i][i] = true;
	for (int i = 2; i <= n; i++) {
		for (int l = 0; l <= n - i; l++) {
			int r = l + i;
			for (int j = l + 1; j < r; j++) {
				if (dp[l][j] && dp[j][r]) dp[l][r] = true;
			}
			if (c[l] != c[r - 1]) continue;
			fill(dp2, dp2 + n + 1, false); dp2[l] = true;
			for (int j = l + 1; j <= r; j++) {
				if (c[j - 1] == c[l] && dp2[j - 1]) dp2[j] = true;
				for (int k = l; k < j; k++) {
					if (dp[k][j] && dp2[k]) dp2[j] = true;
				}
			}
			if (dp2[r]) dp[l][r] = true;
		}
	}
	cout << (dp[0][n] ? "yes" : "no") << endl;
	return 0;
}

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

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

    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    rep(i, n) cin >> a[i];
    mf_graph<int> graph(n*m+2);
    int s = n*m, t = n*m+1;
    rep(i, n) rep(j, m) {
        if (a[i][j]=='#') continue;
        if ((i+j)%2) graph.add_edge(i*m+j, t, 1);
        else graph.add_edge(s, i*m+j, 1);
    }
    rep(i, n) rep(j, m) {
        if ((i+j)%2 || a[i][j]=='#') continue;
        if (i>0 && a[i-1][j]=='.') graph.add_edge(i*m+j, (i-1)*m+j, 1);
        if (i<n-1 && a[i+1][j]=='.') graph.add_edge(i*m+j, (i+1)*m+j, 1);
        if (j>0 && a[i][j-1]=='.') graph.add_edge(i*m+j, i*m+j-1, 1);
        if (j<m-1 && a[i][j+1]=='.') graph.add_edge(i*m+j, i*m+j+1, 1);
    }
    cout << graph.flow(s, t) << endl;
    auto edges = graph.edges();
    for (auto e: edges) {
        if (e.from==s || e.to==t || e.flow==0) continue;
        int e0, e1;
        if (e.from<e.to) e0 = e.from, e1 = e.to;
        else e0 = e.to, e1 = e.from;
        int x0 = e0%m, x1 = e1%m, y0 = e0/m, y1 = e1/m;
        if (abs(x1-x0)==1) {
            a[y0][x0] = '>';
            a[y1][x1] = '<';
        } else {
            a[y0][x0] = 'v';
            a[y1][x1] = '^';
        }
    }
    rep(i, n) cout << a[i] << endl;
    return 0;
}

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

int main(){
    int a[5];
    for(int i=0;i<5;++i)cin >> a[i];
    sort(a, a+5, greater<int>());
    for(int i=0;i<5;++i){
        cout << a[i];
        if(i == 4)cout << endl;
        else cout << ' ';
    }

    return 0;
}


Measured memory_bytes: 3164
#include<iostream>

int main(){
int A[] = {1,3,5,7,8,10,12};
int B[] = {4,6,9,11};
int x, y;
std::cin >>x >>y;
if(x == 2) x = 'C';
if(y == 2) y = 'C';
for(int l: A){
if(l==x) x = 'A';
if(l==y) y = 'A';
}
for(int l: B){
if(l==x) x = 'B';
if(l==y) y = 'B';
}
if(x == y) std::cout << "Yes";
else std::cout << "No";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n, k, h[N], dp[N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> k;
 	for(int i=1; i<=n; i++) 
 	{
 		cin >> h[i];
 		dp[i] = INF;
 	}
 	dp[1] = 0;
 	auto f = [&](int x, int y) { return abs(h[x] - h[y]); };
 	for(int i=2; i<=n; i++)
 		for(int j=1; j<=k && i-j>=1; j++)
 			dp[i] = min(dp[i], dp[i-j]+f(i, i-j));
 	cout << dp[n];
	return 0;
}


Measured memory_bytes: 1024
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long H, W;
    scan(H, W);
    auto cnt = new long[](26);
    foreach (_; 0 .. H)
    {
        auto A = sread();
        foreach (a; A)
        {
            cnt[a - 'a']++;
        }
    }
    auto pool = () {
        if (H & 1 && W & 1)
            return [0, 1, (W - 1) / 2 + (H - 1) / 2, 0, ((W - 1) / 2) * ((H - 1) / 2)];
        if (H & 1)
            return [0, 0, W / 2, 0, (W / 2) * ((H - 1) / 2)];
        if (W & 1)
            return [0, 0, H / 2, 0, (H / 2) * ((W - 1) / 2)];
        return [0, 0, 0, 0, (W / 2) * (H / 2)];
    }();
    foreach_reverse (x; 0 .. pool.length)
    {
        foreach (i; 0 .. cnt.length)
        {
            // dprint(cast(char)(i + 'a'), cnt[i], pool);
            if (0 < pool[x] && x <= cnt[i])
            {
                while (0 < pool[x] && x <= cnt[i])
                {
                    cnt[i] -= x;
                    pool[x]--;
                }
            }
        }
        // dprint(cast(char)(i + 'a'), cnt[i], pool);
        if (pool[x] != 0)
        {
            writeln("No");
            return;
        }
    }
    writeln(cnt.all!"a==0" ? "Yes" : "No");
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
	fast;
	ld n;
	cin >> n;
	ld l = n/3.00;
	ld w = (n - l)/2.00;
	ld h = n - l - w;
	ld ans = l*w*h;
	cout << fixed << setprecision(10) << ans;
	
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

int main(void){
	long long a[101];
	f(i, 101)a[i] = 0;
	bool b[101];
	f(i, 101)b[i] = false;
	long long s;
	int n, m;
	int x, y;
	bool z = true;
	long long ans = 0;
	long long mx = 0;
	int cnt;

	scanf("%d ", &n);
	f(i, n){
		scanf("%lld", &a[i + 1]);
	}
	for (int kk =0; kk < 4194304; kk++){
		x = kk;
		for (int i = 1; i <= n; i++)b[i] = true;
		z = true;
		for (int i = 1; i <=22; i++){
			if (x % 2 == 0){
				if (b[i] == false){
					z = false;
					break;
				}
				for (int j = 1; j*i <= n; j++){
					b[i*j] = false;
				}
			}
			x = x / 2;
		}
		x = 0;
		while (z){
			cnt = 0;
			if (x == 0){
				for (int i = n; i >= 23; i--){
					s = 0;
					for (int j = 1; j*i <= n; j++){
						if (b[i*j] == true)s += a[i*j];
					}
					if (s < 0){
						for (int j = 1; j*i <= n; j++){
							b[i*j] = false;
						}
						cnt++;
					}
				}
			}
			else{
				for (int i = n/2; i >= 23; i--){
					s = 0;
					for (int j = 1; j*i <= n; j++){
						if (b[i*j] == true)s += a[i*j];
					}
					if (s < 0){
						for (int j = 1; j*i <= n; j++){
							b[i*j] = false;
						}
						cnt++;
					}
				}
			}
			if (cnt == 0)z = false;
			x = 1;
		}
		ans = 0;
		for (int i = 1; i <= n; i++){
			if (b[i] == true)ans += a[i];
		}
		mx = max(mx, ans);
	}
	printf("%lld\n", mx);

	return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

long long *value, *weight, dp[100005][102]={};

long long kpsk(int w, int ind){
    if(ind<0 || w<=0){
        return 0;
    }
    if(dp[w][ind]!=0)return dp[w][ind];
    return dp[w][ind] = (w-weight[ind]>=0)?max(value[ind]+kpsk(w-weight[ind],ind-1), kpsk(w,ind-1)):kpsk(w,ind-1);
}
int main()
{
	fast;
    long long n,w, ans;
    cin>>n>>w;
    value = new long long[n];
    weight = new long long[n];
    for(int i=0; i<n; i++){
        cin>>weight[i]>>value[i];
    }
    ans = kpsk(w,n-1);

    cout<<ans;
    return 0;
}



Measured memory_bytes: 79744
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


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

	if(n < 1000){
		cout << "ABC" << endl;
	} else {
		cout << "ABD" << endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const int MAXN = 1e7+2;

int dp[MAXN];
int divisors[MAXN];

int N;
int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    for (int i = 1; i < MAXN; ++i){
        for (int j = i; j < MAXN; j += i){
            ++divisors[j];
        }
    }

    cin >> N;
    ll r = 0;
    for(int i = 1; i <= N; i++){
        r += ll(i)*(ll(divisors[i]));
    }
    cout << r << endl;


    return 0;
}
/*
5
1 0 1
20 1 0
300 0 1
4000 0 0
50000 1 0
1 2
2 3
2 4
1 5
*/


Measured memory_bytes: 42672
#include<bits/stdc++.h>
using namespace std;
#define ll      long long int
#define pii     pair<ll,ll>
#define vi      vector<ll>
#define mp      make_pair
#define pb      push_back
#define F       first
#define S       second
#define pf(n)   printf("%lld\n",n)
#define sf(n)   scanf("%lld",&n)
#define fast    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)  x.begin(),x.end()
#define ms(n,i) memset(n,i,sizeof n)
#define sz(x)   (ll)x.size()
#define pi      3.141592653589793238
#define hell    1000000007
#define hell2   1000000009
#define endl    '\n'
#define inf     1e18
#define N       100005

int main()
{
    ll n,w,i,j,k;
    cin>>n>>w;
    vector<pii> v(n);
    for(i=0;i<n;i++){
        cin>>v[i].F>>v[i].S;
    }
    vi dp(w+1,0);
    for(i=0;i<n;i++){
        for(j=w;j>=v[i].F;j--)
            dp[j]=max(dp[j],dp[j-v[i].F]+v[i].S);
    }
    cout<<dp[w]<<endl;
}

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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

signed main(){
    // cout << fixed << setprecision(10) << flush;
    vector<int> n, x;
    int i = 0;
    int a, b;
    do{
        cin >> a >> b;
        n.push_back(a);
        x.push_back(b);
    }while(a != 0 || b != 0);

    for(int c=0; c<n.size()-1; c++){
        int cnt = 0;
        if(n[c] == 0 && x[c] == 0) break;
        for(int i=3; i<=min(x[c], n[c]); i++){
            for(int j=2; j<=min(i-1, min(x[c], n[c])); j++){
                int k = x[c] - i - j;
                if(k < j && k >= 1) cnt++;
            }
        }
        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 200007;

vector <int> adj[N];

int st[N], en[N], sum[N], t;

int dfs(int u, int p) {
        st[u] = ++t;
        for(auto v: adj[u]) {
                if(v != p) {
                        dfs(v, u);
                }
        }
        en[u] = t;
}

int32_t main() {
        int n, m; cin >> n >> m;
        for(int i = 1; i < n; i++) {
                int u, v; cin >> u >> v;
                adj[u].push_back(v);
                adj[v].push_back(u);
        }

        dfs(1, -1);

        for(int i = 1; i <= m; i++) {
                int q, k; cin >> q >> k;
                sum[st[q]] += k;
                sum[en[q] + 1] -= k;
        }

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


        for(int i = 1; i <= n; i++) {
                cout << sum[st[i]] << " ";
        }
}


Measured memory_bytes: 27392
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define MOD 1000000007

int main(void){
    int n;
    cin >> n;
    vector<pair<ll,ll>> rob(n);
    rep(i,n){
        ll x,l;
        cin >> x >> l;
        rob[i] = make_pair(x+l, x-l);
    }
    int ans = 1;
    sort(all(rob));
    ll fin = rob[0].first;
    for(int i=1; i<n; i++){
        if(rob[i].second >= fin){
            fin = rob[i].first;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  
  int s = 0, k = 0;
  s += a[0];
  rep(i, N-1) k += a[i+1];
  
  int ans = abs(s-k);
  rep(i, N-2) {
    s += a[i+1];
    k -= a[i+1];
    ans = min(ans, abs(s-k));
  }
  cout << ans << endl;
}

Measured memory_bytes: 4844
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
ll dp[2][4];
int now = 0;
int t[3];
ll p2[32];
bool use[100010];
int arr[256];
void Sequence() {

	int n;
	string s;
	cin >> n;
	cin >> s;
	int res = 0;
	int x = 0;
	for (size_t i = 0; i < n; i++)
	{
		if (s[i] == 'I') {
			x++;
		}
		else x--;
		res = max(res, x);
	}
	cout << res << endl;
}
int main() {
	Sequence();
	return 0;
}



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

int main(){
	//freopen("/home/byte001/Code/Input/1.txt","r",stdin);
	unsigned long long int n,a,b; cin>>n>>a>>b;
	if(n<=(a+b)) cout<<min(n,a)<<endl;
	else{
		unsigned long long int x = (n/(a+b))*a;
		x+=min(a,(n%(a+b)));
		cout<<x<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
from subprocess import*
a,b=map(int,input().split())
x=set(map(int,Popen(['factor',str(a)],stdout=PIPE).communicate()[0].decode().split()[1:]))
y=set(map(int,Popen(['factor',str(b)],stdout=PIPE).communicate()[0].decode().split()[1:]))
print(len(x&y)+1)

Measured memory_bytes: 4848
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> namespace mp = boost::multiprecision; //mp::cpp_intで宣言
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////


int main(){
    string s;cin>>s;
    ll n=s.size();
    ll a[n+1];memset(a,0,sizeof(a));
    rep(i,0,n-1){
        if(s[i]=='B')a[i+1]=a[i]+1;
        else a[i+1]=a[i];
    }
    //rep(i,0,n)cout<<a[i]<<" ";cout<<endl;
    ll ans=0;
    rep(i,0,n-1){
        if(s[i]=='W'){
            ans+=a[i];
        }
    }
    cout<<ans<<endl;

    
    return 0;
} 

Measured memory_bytes: 2180
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#include<vector>
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
using namespace std;

int main(){
	ll a,b;
	cin>>a>>b;
	ll ans=(a*b)/__gcd(a,b);
	cout<<ans;
return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
 
int x, y, ans;
int m[20][20];
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};

void dfs(int now, int X, int Y) {
  
  if (now >= ans) return;

  for (int i = 0; i < 4; i++) {
    int nx = X + dx[i];
    int ny = Y + dy[i];
    if (nx < 0 || x <= nx || ny < 0 || y <= ny || m[ny][nx] == 1) continue;
    
    while (1) {
      if (m[ny][nx] == 3) {
	ans = now;
	return;
      }
      nx += dx[i];
      ny += dy[i];
      if (nx < 0 || x <= nx || ny < 0 || y <= ny) {
	break;
      }
      if (m[ny][nx] == 1) {
	m[ny][nx] = 0;
	dfs(now + 1, nx - dx[i], ny - dy[i]);
	m[ny][nx] = 1;
	break;
      }
    }
  }
}
 
int main(void) {

  while (cin >> x >> y, x + y) {

    int sx, sy;
    for (int i = 0; i < y; i++) {
      for (int j = 0; j < x; j++) {
	cin >> m[i][j];
	if (m[i][j] == 2) {
	  sx = j;
	  sy = i;
	}
      }
    }
    ans = 11;
    dfs(1, sx, sy);
    if (ans > 10) ans = -1;
    cout << ans << endl;
  }
   return 0;
}

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

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

    if (a > b) {
        cout << "a > b" << endl;
    } else if (a < b) {
        cout << "a < b" << endl;
    } else {
        cout << "a == b" << endl;
    }

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int target = H.at(i);
    bool ok = true;
    for (int j = 0; j < i; j++) {
      if (target < H.at(j)) {
        ok = false;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

class dice{
public:
    int top, bottom, right, left, front, back;
    void North();
    void East();
    void South();
    void West();
};
void dice:: North(){
    int tmp = top;
    top = front;
    front = bottom;
    bottom = back;
    back = tmp;
}
void dice:: East(){
    int tmp = top;
    top = left;
    left = bottom;
    bottom = right;
    right = tmp;
}
void dice:: South(){
    int tmp = top;
    top = back;
    back = bottom;
    bottom = front;
    front = tmp;
}
void dice:: West(){
    int tmp = top;
    top = right;
    right = bottom;
    bottom = left;
    left = tmp;
}

signed main(){
    dice d;
    cin >> d.top >> d.front >> d.right >> d.left >> d.back >> d.bottom;
    string s;
    cin >> s;
    rep(i, 0, s.size()){
        // switch (s[i]){
            // case 'N': d.North();
            //case 'E': d.East();
            //case 'S': d.South();
            //case 'W': d.West();
        if(s[i] == 'N') d.North();
        else if(s[i] == 'E') d.East();
        else if(s[i] == 'S') d.South();
        else if(s[i] == 'W') d.West();
           // cout << d.top << endl;
    }
    cout << d.top << endl;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
map<int,int>fr;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,on=1,cnt=0;cin>>n;
  for(int i=1;i<=n;i++)
  {
    int x;cin>>x;on=x;
    if(!fr[x])cnt++;
    fr[x]++;
  }
  if(cnt==1&&!on)cout<<"Yes"<<endl,exit(0);
  if(cnt==2)
  {
    int f=0;
    for(auto x:fr)
    {
      if(!f)
      {
        if(x.first==0&&x.second==n/3)
          cout<<"Yes"<<endl,exit(0);
      }
      f=1;
    }
  }
  if(cnt!=3||n%3)cout<<"No"<<endl,exit(0);
  int xxr=0;
  for(auto x:fr)
  {
    if(x.second!=n/3)cout<<"No"<<endl,exit(0);
    xxr^=x.first;
  }
  if(xxr)cout<<"No"<<endl,exit(0);
  cout<<"Yes"<<endl;

  return 0;
}

Measured memory_bytes: 3840
package main

import "fmt"

func main() {
	var n, k, x, y int
	fmt.Scanf("%d", &n)
	fmt.Scanf("%d", &k)
	fmt.Scanf("%d", &x)
	fmt.Scanf("%d", &y)

	var sum int
	for i := 1; i <= n; i++ {
		if i > k {
			sum+=y
		} else {
			sum+=x
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
n = int(input())

d = [[0] * 10 for i in range(10)]

ans = 0
for i in range(1,n + 1):
    s = str(i)
    if s[0] == "0" or s[-1] == "0":
        continue
    else:
        d[int(s[0])][int(s[-1])] += 1

ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += d[i][j] * d[j][i]

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 10, maxQ = 50;
int n, m, q;
int a[maxQ], b[maxQ], c[maxQ], d[maxQ];
int A[maxN];

int solve(int i = 0, int prv = 1)
{
  if (i == n)
  {
    int ans = 0;
    for (int j = 0; j < q; j++)
      if (A[b[j]] - A[a[j]] == c[j])
        ans += d[j];
    return ans;
  }
  int ans = 0;
  for (int aa = prv; aa <= m; aa++)
  {
    A[i] = aa;
    ans = max(ans, solve(i + 1, aa));
  }
  return ans;
}

int main()
{
  while (scanf("%d %d %d", &n, &m, &q) != EOF)
  {
    for (int i = 0; i < q; i++)
    {
      scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
      a[i]--, b[i]--;
    }
    int ans = solve();
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
typedef long long LL;
const LL mod = 1e9 + 7;
const int N = 3e5 + 5;

int n, sum, m;

int main() {
    cin>>n;
    m = n;
    while(m) {
    	sum += m%10;
    	m /= 10;
    }
    if(sum == 1) cout<<10<<endl;
    else cout<<sum<<endl;
}

Measured memory_bytes: 3564
#include <cstdio>
#include <cstring>
#include <stack>
#include <algorithm>
using namespace std;
bool cats[102];

int main(){
    int L, id, res = -1;
    stack<int> c;
    memset(cats, 0, sizeof (cats));
    scanf("%d", &L);
    for (int i = 1; i <= L; i++) {
        scanf("%d", &id);
        if (res < 0) {
            if (id < 0) {
                if (cats[abs(id)] && c.top() == abs(id)) { cats[abs(id)] = false; c.pop(); }
                else res = i;
            }
            else if (id > 0) {
                if (!cats[id]) { cats[id] = true; c.push(id); }
                else res = i;
            }
        }
    }
    (res == -1) ? printf("OK\n") : printf("%d\n", res);
    return 0;
}



Measured memory_bytes: 2764
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var X = cin.ReadInt;
			var N = cin.ReadInt;
			var P = cin.ReadIntArray(N);
			var cand = Enumerable.Repeat(true, 102).ToArray();
			foreach(var item in P) {
				cand[item]=false;
			}
			var absMin = int.MaxValue;
			int res = -1;
			for(int i = 0; i<102; i++) {
				if(!cand[i]) continue;
				var abs = Abs(i-X);
				if(abs<absMin) {
					absMin=abs;
					res=i;
				}
			}
			Console.WriteLine(res);
		}

	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
}

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

int main(){
  int n,ans=0,t;string s,s1,s2;cin>>n>>s;
  REP(i,n-1){
    set<char> se;
    s1=s.substr(0,i+1);
    s2=s.substr(i+1,s.size()-i-1);
    for(int j=0;j<s1.size();j++) if(s2.find(s1.at(j))!=-1) se.insert(s1.at(j));
    t=se.size();
    ans=max(ans,t);
  }
  cout<<ans;
}


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

#define EPS 1e-7

typedef complex<double> P;
#define X real()
#define Y imag()

double cross(P a,P b){ return (a.X*b.Y)-(a.Y*b.X); }

int isIntersected(P a1,P a2,P b1,P b2)
{
        return cross(a2-a1,b1-a1) * cross(a2-a1,b2-a1) < EPS &&
                   cross(b2-b1,a1-b1) * cross(b2-b1,a2-b1) < EPS;
}

int main()
{
        double a,b,c,d,e,f,g,h;

        while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&a,&b,&c,&d,&e,&f,&g,&h))
        {
                P aa(a,b), bb(c,d), cc(e,f), dd(g,h);
                cout<<( isIntersected(aa,cc,bb,dd)>0.0 || isIntersected(bb,dd,aa,cc)>0.0 ? "YES" : "NO" )<<endl;
        }

        return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n;
  cin>>n;
  vector<int> v;
  REP(i,pow(2,n)){
    int a;
    cin>>a;
    v.PB(a);
  }
  REP(i,n){
    vector<int> k;
    REP(j,pow(2,n-i)){
      int tmp;
      if(v[j]==v[j+1]){
        tmp=v[j];
      }else{
       tmp=abs(v[j]-v[j+1]);
      }
      k.PB(tmp);
      j++;
    }
    REP(j,k.size()){
      v[j]=k[j];
    }
  }
  cout<<v[0]<<endl;
  return 0;
}


Measured memory_bytes: 4336
from scipy.sparse import*
_,*s=open(0)
r=s+["#"*20]
*g,=eval("[0]*500,"*500)
i=-1
for t in s:
 i+=1;j=0
 for u in t:k=i*20+j;g[k][k+1]=u>'#'<t[j+1];g[k][k+20]=u>'#'<r[i+1][j];j+=1
a=csgraph.johnson(csr_matrix(g),0)
print(int(max(a[a<999])))

Measured memory_bytes: 21996
def main():
    H, W = map(int, input().split())
    a = [i == '.' for i in input()]
    v = [0] * W
    v[0] = 1
    for j in range(1, W):
        if not a[j]:
            break
        v[j] = 1

    for i in range(1, H):
        a = [i == '.' for i in input()]
        u = v
        v = [0] * W
        v[0] = u[0] if a[0] else 0
        for j in range(1, W):
            v[j] = u[j] + v[j - 1] if a[j] else 0
    print(v[-1] % (10 ** 9 + 7))


main()


Measured memory_bytes: 3444
N = int(input())
S = input()
res = 0

for i in range(1,N):
  count = 0
  S_f = set(S[:i])
  S_l = set(S[i:])
  for s in S_f:
    if s in S_l:
      count += 1
  if res < count: res = count
    
print(res)
  

Measured memory_bytes: 2940
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<bits/stdc++.h>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
bool comparator(P a, P b) {
	return a.first / a.second < b.first / b.second;
}
int p[1001];
int x[1001];

int main() {
	string s;
	cin >> s;
	if (s[2] != s[3]) {
		cout << "No" << endl;
		return 0;
	}
	if (s[4] != s[5]) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;


	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
int main(){
  long double a;
  cin >> a;
  long double b=a/3;
  cout << fixed << setprecision(15) << b*b*b << endl;
}

Measured memory_bytes: 256
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

l = [int(input()) for i in range(5)]

ans = INF
for row in permutations(l, 5):
    t = 0
    for ind, i in enumerate(row):
        t += i
        if ind == 4:
            break
        for j in range(10):
            if (t + j) % 10 == 0:
                t += j
    if t<ans:
        ans = t

print(ans)



Measured memory_bytes: 3668
package main

import "fmt"

func main() {
	var n, k int
	var s string
	fmt.Scan(&n, &k, &s)

	ans := 0
	for l, r := -1, 0; r < len(s); r++ {
		for r < len(s) && s[r] == '1' {
			r++
		}
		for k > 0 {
			k--
			for r < len(s) && s[r] == '0' {
				if r == len(s) {
					break
				}
				r++
			}
			for r < len(s) && s[r] == '1' {
				if r == len(s) {
					break
				}
				r++
			}
		}
		r--
		if v := r - l; v > ans {
			ans = v
		}
		k++
		l++
		for l < len(s) && s[l] == '1' {
			l++
		}
		for l < len(s) && s[l] == '0' {
			l++
		}
		l--
	}

	fmt.Println(ans)
}


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

int main(){
    int a,b,sum = 0;
    char op;
    cin >> a >> op >> b;
    if(op == '+')
        sum = a + b;
    else
        sum = a - b;
    printf("%d\n",sum);

    return 0;
}

Measured memory_bytes: 256