akhauriyash/Code-Regression huggingface dataset:
from collections import deque

H , W = map(int,input().split())
maze = []
white_cnt = -1
for _ in range(H):
    row = list(input())
    white_cnt += row.count(".")
    maze.append(row)

def bfs(sy,sx,gy,gx , ma):
    dx = [0,1,0,-1]
    dy = [1,0,-1,0]
    score = [[-1 for _ in range(W)] for _ in range(H)]
    score[sy][sx] = 0
    q = deque()
    q.append([sy,sx])
    while q:
        now_y , now_x = q.popleft()
        for i in range(4):
            next_y , next_x = now_y + dy[i] , now_x + dx[i]
            if 0 <= next_y and next_y < H and 0 <= next_x and next_x < W and score[next_y][next_x] == -1 and ma[next_y][next_x] == ".":
                q.append([next_y,next_x])
                score[next_y][next_x] = score[now_y][now_x] + 1
    return score[gy][gx]


min_distance = bfs(0 , 0,H - 1,W - 1 , maze)
if min_distance == -1:
    print(min_distance)
else:
    print(white_cnt - min_distance)

Measured memory_bytes: 40560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n, k;
  cin >> n >> k;
  if (k == 0) {
    cout << n * n << endl;
    return 0;
  }
  ll ans = 0;
  for (ll b = k+1; b <= n; ++b) {
    ll num = n / b;
    ans += (b-k) * num;
    ans += max((n % b) - k+1, 0LL);
    debug(b, (b-k) * num, (n % b) - k+1, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def nCr(com_n, com_r):
    if com_n < com_r: return 0
    return fac[com_n] * ifac[com_r] % md * ifac[com_n - com_r] % md

# combinationの準備
# md>n_maxの条件
md = 998244353
n_max = 4005
fac = [1]
for i in range(1, n_max + 1): fac.append(fac[-1] * i % md)
ifac = [1] * (n_max + 1)
ifac[n_max] = pow(fac[n_max], md - 2, md)
for i in range(n_max - 1, 1, -1): ifac[i] = ifac[i + 1] * (i + 1) % md

def solve():
    dp = [[0] * (n + 1) for _ in range(n + 1)]
    dp[0][0] = 1
    r = b = 0
    for i, c in enumerate(s):
        if c == "0": r += 2
        elif c == "2": b += 2
        else: r, b = r + 1, b + 1
        for j in range(n):
            pre = dp[i][j]
            if pre == 0: continue
            if j + 1 <= r: dp[i + 1][j + 1] += pre
            if i + 1 - j <= b: dp[i + 1][j] += pre
    # p2D(dp)
    ans = 0
    for j in range(n + 1):
        ans += dp[n][j] * nCr(n, r - j)
        ans %= md
    print(ans)

s=SI()
n=len(s)
solve()


Measured memory_bytes: 370676
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  LL n, k, q;
  cin >> n >> k >> q;
  vector<LL> a(q);
  vector<LL> cnt(n, 0);
  rep(i, q) {
    cin >> a[i];
    a[i] --;
    cnt[a[i]] ++;
  }

  rep(i, n) {
    if (k - q + cnt[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int64_t> luca(N + 1);
  luca.at(0) = 2;
  luca.at(1) = 1;
  rep(i, N - 1) {
    luca.at(i + 2) = luca.at(i) + luca.at(i + 1);
  }
  cout << luca.at(N) << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int N;

void _main() {
    cin >> N;
    if (N == 1) {
        cout << 1 << endl;
        return;
    }
    int a = 2, b = 1;
    for (int i = 2; i <= N; ++i) {
        int c = a + b;
        a = b;
        b = c;
    }
    cout << b << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i'))
            freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o'))
            freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int main()
{
        int n, x, sum, cnt=0;
        int comb;
        int combs[50];

        while(1) {
                cin >> n >> x;

                if(n==0 && x==0) break;

                for(int i = 1; i <= n-2; i++) {
                  for(int j = i+1; j <= n-1; j++) {
                    for(int k = j+1; k <= n; k++) {
                        sum = i + j + k;
                          if(sum == x) {
                            comb++;
                          }
                        }
                    }
                }
                combs[cnt++] = comb;
                comb = 0;
        }

        for(int i = 0; i < cnt; i++) {
                cout << combs[i] << endl;
        }

        return 0;
}


Measured memory_bytes: 3108
n,m=map(int,input().split())
c=[0]*(n+1)
for i in range(m):
    l,r=map(int,input().split())
    c[l-1]+=1
    c[r]-=1
for i in range(n):
    c[i+1]+=c[i]
ans=sum([1 for i in c if i==m])
print(ans)
    


Measured memory_bytes: 7860
n = int(input())
#from tqdm import tqdm
ans=[0 for _ in range(10001)]
for x in range(1, 105):
    for y in range(1, 105):
        for z in range(1, 105):
            v = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if v < 10001:
                ans[v]+=1
                #print(i, x,y,z)
for i in range(n):
    print(ans[i+1])

Measured memory_bytes: 9084
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N, M;
vector<int>v, h;
vector<pair<int, int>>eve;//first=time second=cost

int dp[3333];//iアイテム目までの最大の強さ

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < N; ++i) {
		int vv, hh;
		cin >> vv >> hh;
		v.push_back(vv);
		h.push_back(hh);
	}
	for (int i = 0; i < M; ++i) {
		int t, s;
		cin >> t >> s;
		eve.push_back({ t,s });
	}
	int vmos = 0;
	int ok = 0;
	for (int i = 1; i <= N; ++i) {
		vmos += v[i - 1];
		auto itr = upper_bound(eve.begin(), eve.end(), pair<int, int>(vmos, 0));
		int limit = 0;
		int ltime = 0;
		if (itr != eve.begin()) {
			itr--;
			ltime = itr->first;
			limit = itr->second;
		}
		else {}
		int nowp = h[i - 1];
		for (int j = i - 1; j >= 0; --j) {
			if (j != i - 1) {
				nowp += abs(h[j] - h[j + 1]);
				nowp += h[j];
			}
			if (limit > dp[j]) {
				break;
			}
			dp[i] = max(dp[i], dp[j] + nowp);
		}
		if (dp[i] == 0) {
			ok = ltime;
			break;
		}
	}
	if (ok != 0) {
		cout << -1 << endl;
		return 0;
	}
	int can = N + 1;
	for (int i = N; i >= 0; --i) {
		if (dp[i] >= eve.back().second) {
			can = i;
		}
		else {
			break;
		}
	}
	if (can == N + 1) {
		cout << -1 << endl;
		return 0;
	}
	int ans = eve.back().first;
	for (int i = 0; i < can; ++i) {
		ans -= v[i];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	int n, m, X;
	cin >> n >> m >> X;
	vl c(n);
	ll a[n][m];
	for (int i = 0;i < n;i++) {
		cin >> c[i];
		for (int j = 0;j < m;j++)	
			cin >> a[i][j];
	}
	ll ans = LLONG_MAX;
	for (int x = 0;x < (1<<n);x++) {
		vl k(n, 0);
		ll cost = 0;
		for (int i = 0;i < n;i++)
			if (x & (1<<i)) {
				cost += c[i];
				for (int j = 0;j < m;j++)
					k[j] += a[i][j];
			}
		int j = 0;
		for (;j < m && k[j] >= X;j++);
		if (j == m)
			ans = min(ans, cost);
	}
	if (ans == LLONG_MAX)
		cout << -1 << '\n';
	else
		cout << ans << '\n';
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N = 2e5 + 5, INF = 0x3f3f3f3f;
inline int read() {
	int x = 0, f = 0; char ch = 0;
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}
int ans[N];
vector <int> G[N], col[2], mod[3];
void dfs(int x, int c, int fa) {
	col[c].push_back(x);
	for (auto y : G[x]) if (y != fa) dfs(y, c ^ 1, x);
}
void sol(int i, int j) {
	while (!col[i].empty() && !mod[j].empty()) {
		ans[col[i].back()] = mod[j].back();
		col[i].pop_back(), mod[j].pop_back();
	}
}
int main() {
	int n = read();
	for (int i = 1; i < n; i++) {
		int x = read(), y = read();
		G[x].pb(y), G[y].pb(x);
	}
	for (int i = 1; i <= n; i++) mod[i % 3].pb(i);
	dfs(1, 0, 0);
	sol(col[0].size() < col[1].size(), 1), sol(col[0].size() < col[1].size(), 2);
	sol(0, 0), sol(1, 0);
	for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
	return 0;
}//cy

Measured memory_bytes: 22296
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	long long int n;
	cin >> n;
	vector<long long int> a(3*n);
	for (long long int i = 0; i < 3*n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	long long int aa = 0;
	for (long long int i = 0; i < n; i++) {
		aa += a[3 * n - 2 - (i * 2)];
		//cout << a[3 * n - 2 - (i * 2)] << endl;
	}
	cout << aa << endl;
	return 0;
}

Measured memory_bytes: 2560
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int tot[200001];
graph G;

void preorder(int start) {
	stack<pair<int, int>> S; S.push({start, 0});
	unordered_set<int> VST;
	while(!S.empty()) {
		pair<int, int> VP = S.top(); S.pop(); int V = VP.first;
		VST.insert(V);
		// Process here
		for(int NB: G[V]) {
			if(VST.count(NB) > 0) continue;
			tot[NB] += tot[V];
			S.push({NB, V});
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, q; cin >> n >> q;
	forl(i, 0, n-1) { int a, b; cin >> a >> b; G[a].insert(b); G[b].insert(a); }
	forl(i, 0, q) { int a, b; cin >> a >> b; tot[a] += b; }
	preorder(1);
	forl(i, 1, n+1) {
		cout << tot[i] << " ";
	}
	cout << endl;
}


Measured memory_bytes: 49012
class UnionFind
  def initialize(n)
    @par = Array.new(n){|x| x}
    @size = Array.new(n, 0)
  end

  def find(x)
    return x if x == @par[x]
    return @par[x] = find(@par[x])
  end

  def unite(x, y)
    x = find(x)
    y = find(y)
    return if x == y
    swap(x, y) if @size[x] < @size[y]
    @par[y] = x
    @size[x] += @size[y]
  end

  def same(x, y)
    return find(x) == find(y)
  end

  def size(x)
    return @size[find(x)]
  end
end

n, q = gets.split.map(&:to_i)
uf = UnionFind.new(n)
q.times {
  com, x, y = gets.split.map(&:to_i)
  if com.zero?
    uf.unite(x, y)
  else
    p uf.same(x, y) ? 1 : 0
  end
}

Measured memory_bytes: 9200
def fib(n):
    memo = [0 for _ in range(n+1)]
    memo[0] = 1
    memo[1] = 1
    
    for i in range(n-1):
        memo[i+2] = memo[i+1] + memo[i]
            
    return memo[n]

n = int(input())
print(fib(n))


Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

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

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  string S;
  cin >> N >> S;

  ll ans = 0;
  REP3(gap,1,N){
      ll l = 0;    
      while (l<N-gap+1){
          ll r = l;
          while (S[r]==S[r+gap] && r-l<gap){
              r++;
          }
          ans = max(ans, r-l);
          l = r+1;
      }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define inf (int)(1e9)

int main(){
	int H, N, A, B, Amax = 10000, i, j;
	scanf("%d%d", &H, &N);
	vector<int> dp(H + Amax + 1, inf);
	dp[0] = 0;
	for(i = 0; i < N; i++){
		scanf("%d%d", &A, &B);
		for(j = A; j <= H + Amax; j++){
			dp[j] = min(dp[j], dp[j - A] + B);
		}
	}
	int ans = inf;
	for(j = H; j <= H + Amax; j++){
		ans = min(ans, dp[j]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
# https://atcoder.jp/contests/abc122/tasks/abc122_b



S = gets.chomp
ans=0
i=0
S.chars do |s|
    if s=='A'||s=='C'||s=='G'||s=='T'
        i+=1
    else
        ans=[ans,i].max
        i=0
    end
end
ans=[ans,i].max
puts ans


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

int main() {
  int n; cin >> n;
  if(n % 10 == 7){
    cout << "Yes";
  }else if((n % 100) / 10 == 7){
    cout << "Yes";
  }else if(n / 100 == 7){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 3636
import java.util.*;

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

		while(true){
			int n = sc.nextInt();
			if(n == 0) break;

			int[][] map = new int[10][10];
			for(int i=0;i<10;i++){
				Arrays.fill(map[i],-1);
			}

			for(int i=0;i<n;i++){
				int a = sc.nextInt();
				int b = sc.nextInt();
				int cost = sc.nextInt();

				map[a][a] = map[b][b] = 0; 
				map[a][b] = map[b][a] = map[a][b]==-1 ? cost : Math.min(map[a][b],cost);
			}

			int ansNode = Integer.MAX_VALUE, ansCost = Integer.MAX_VALUE;
			for(int from=0;from<10;from++){
				int sum = -1;
				for(int to=0;to<10;to++){
					int cost = minCost(from,to,map);
					sum += cost>=0 ? cost : 0;
				}
				if(sum >= 0 && (ansCost > sum+1 || ansCost == sum+1 && ansNode > from)){
					ansCost = sum+1;
					ansNode = from;
				}
			}

			System.out.println(ansNode + " " + ansCost);
		}
	}

	static int minCost(int s,int g,int[][] map){
		PriorityQueue<State> open = new PriorityQueue<State>();
		HashSet<State> closed = new HashSet<State>();
		State ans = null;
		open.add(new State(s,0));

		while(!open.isEmpty()){
			State st = open.poll();
			if(closed.contains(st)) continue;
			closed.add(st);
			if(st.n == g){
				ans = st;
				break;
			}
			open.addAll(st.nexts(map));
		}

		if(ans == null) return -1;
		else return ans.cost;
	}
}

class State implements Comparable<State>{
	int n,cost;

	State(int n,int cost){
		this.n = n;
		this.cost = cost;
	}

	List<State> nexts(int[][] map){
		List<State> sts = new ArrayList<State>();
		for(int i=0;i<map.length;i++){
			if(map[n][i] >= 0){
				sts.add(new State(i,cost+map[n][i]));
			}
		}
		return sts;
	}

	public boolean equals(Object o){
		State st = (State)o;
		return st.n == this.n;
	}

	public int hashCode(){
		return n;
	}

	public int compareTo(State st){
		return this.cost - st.cost;
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define inf 1e18

 
using namespace std;
 
int max(int a, int b)
{
    if(a>b) return a;
    else return b;
}
 
int min(int a,int b)
{
    if(a<b) return a;
    else return b;
}
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    string s,t;
    cin>>s>>t;
    int n,i,ans=0;
    n=s.length();
    for(i=0;i<n;i++) if(s[i]!=t[i]) ans++;
        cout<<ans;
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int shit[]={0,1,2,4,7,12,20,29,38,52,73};
ll w[11][11];
int p[11];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi();
	w[1][2]=w[2][1]=1;ll M=1;
	for(int x=3;x<=n;++x){//insert node x
		for(int i=1;i<x;++i)w[x][i]=w[i][x]=shit[i]*(M+1);
		for(int i=1;i<=x;++i)p[i]=i;
		do{
			if(p[1]>p[x])continue;
			ll sum=0;
			for(int i=1;i<x;++i)sum+=w[p[i]][p[i+1]];
			cxk(M,sum);
		}while(std::next_permutation(p+1,p+x+1));
	}
	assert(M<=1e11);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j)printf("%lld ",w[i][j]);
		puts("");
	}
	return 0;
}



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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define m_p make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    unordered_map<string,ll> mp; 
    rep(i,n){
        string s;
        cin >> s;
        sort(all(s));
        mp[s]++;
    }
    ll ans = 0;
    for(auto& p : mp){
        ll n = p.second;
        ans += n*(n-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10660
// Think twice, Code once
// 1SAC
#include<bits/stdc++.h>
using namespace std;
 
/*============================ DEBUGGING =============================*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
/*============================= DEFINES ==============================*/
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
/*============================== TYPEDEFS ============================*/
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;
/*============================ START FROM HERE =======================*/
 
int main(){
	FIO
	
	int n;cin >> n;
	int a[n],b[n];
	forn(i, n)cin >> a[i];forn(i, n)cin >> b[i];
	int perm[n];forn(i, n)perm[i] = i + 1;
	int f,s;
	int c = 1; 
	do{
		bool ok = 1;
		forn(i, n)if(perm[i] != a[i]){ok = 0;break;}
		if(ok)f = c;
		ok = 1;
		forn(i, n)if(perm[i] != b[i]){ok = 0;break;}
		if(ok)s = c;
		c++;
	}while(next_permutation(perm,perm + n));
	cout << abs(f - s);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    int n;
    int l,r;
    int sum = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> l >> r;
        sum += (r-l+1);
    }
    cout << sum << endl;
    return 0;
}


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

int S[100000];

int BinarySearch(int value, int s_size)
{
    int first_idx = 0;
    int last_idx  = s_size - 1;
    int mid_idx   = s_size / 2;
    while(1) {
        if (value == S[mid_idx]) {
            return mid_idx;
        }
        if (first_idx >= last_idx) {
            break;
        }
        if (value < S[mid_idx]) {
            last_idx = mid_idx - 1;
            s_size = mid_idx - first_idx;
            mid_idx = first_idx + s_size / 2;
        } else if (value > S[mid_idx]) {
            first_idx = mid_idx + 1;
            s_size = last_idx - mid_idx;
            mid_idx = first_idx + s_size / 2;
        }
    }
    return -1;
}

int main(int argc, char *argv[])
{
    int n, q;
    int find_num = 0;
    
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }

    scanf("%d", &q);
    if (q > 50000) {
        exit(-1);
    }
    for (int i = 0; i < q; i++) {
        int value;
        scanf("%d", &value);
        if (BinarySearch(value, n) >= 0) {
            find_num++;
        }
    }
    std::cout << find_num << std::endl;
}


Measured memory_bytes: 3528
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N = 105;
const int MOD = 1000000007;

int n,m,h[N],w[N];
LL dp[N][N];

int pow_(int x,int y) {///快速幂求 x的y次方
    int ans = 1;
    if(y > 0) {
        while(y) {
            if(y % 2)ans = (LL)ans * x % MOD;
            x = (LL)x * x % MOD;
            y /= 2;
        }
    }
    return ans;
}

int main() {
    scanf("%d",&n);
    for(int i = 1;i <= n;i ++) {
        scanf("%d",&h[i]);
        w[++ m] = h[i];
    }
    sort(w + 1,w + m + 1);///高度排序
    m = unique(w + 1,w + m + 1) - w - 1;///离散化 m是离散化后的长度
    for(int i = 1;i <= n;i ++) {
        h[i] = lower_bound(w + 1,w + m + 1,h[i]) - w;
    }
    dp[0][0]=1;
    for(int i = 1;i <= n;i ++) {
        for(int j = h[i] + 1;j <= h[i - 1];j ++)
            (dp[i][0] += dp[i - 1][j] * 2 % MOD) %= MOD;
        (dp[i][0] += dp[i - 1][0] * 2 % MOD) %= MOD;///交叉或者不交叉
        for(int j = 1;j <= h[i];j ++) {
            dp[i][j]=(LL)dp[i - 1][j] * pow_(2,w[h[i]] - w[h[i-1]]) % MOD;
            if(h[i - 1] >= j)continue;///如果是高度不超过前一列的位置 量已经确定了
            if(j > 1)(dp[i][j] += dp[i - 1][0] * (pow_(2,w[j] - w[j - 1]) - 1) % MOD * 2 % MOD * pow_(2,w[h[i]] - w[j]) % MOD) %= MOD;
            else (dp[i][1] += dp[i - 1][0] * (pow_(2,w[1]) - 2) % MOD * pow_(2,w[h[i]] - w[1]) % MOD) %= MOD;///上一列中无重复的乘上化不超过上一列高度中有重复的
        }
    }
    LL ans = 0;
    for(int i = 0;i <= m;i++)
        (ans += dp[n][i]) %= MOD;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> int least_bit(T n) {
  static_assert(sizeof(T) == 4 || sizeof(T) == 8, "unsupported size");
  if (sizeof(T) == 4) return __builtin_ffs(n) - 1;
  if (sizeof(T) == 8) return __builtin_ffsll(n) - 1;
}

// n must be greater than 0.
template<typename T> int least_bit_fast(T n) {
  static_assert(sizeof(T) == 4 || sizeof(T) == 8, "unsupported size");
  if (sizeof(T) == 4) return __builtin_ctz(n);
  if (sizeof(T) == 8) return __builtin_ctzll(n);
}

template<typename T> int most_bit(T n) {
  static_assert(sizeof(T) == 4 || sizeof(T) == 8, "unsupported size");
  if (sizeof(T) == 4) return n ? 31 - __builtin_clz(n) : -1;
  if (sizeof(T) == 8) return n ? 63 - __builtin_clzll(n) : -1;
}

template<typename T> int count_bit(T n) {
  static_assert(sizeof(T) == 4 || sizeof(T) == 8, "unsupported size");
  if (sizeof(T) == 4) return __builtin_popcount(n);
  if (sizeof(T) == 8) return __builtin_popcountll(n);
}

template<typename T = double> constexpr T pi() {return acos(T(-1));}

template<typename T> T gcd(T t) {return t;}

template<typename T, typename... S> T gcd(T a, S... s) {
  auto b = gcd(s...);
  if (a == 0 || b == 0) return max(a, b);
  int fa = least_bit_fast(a);
  int fb = least_bit_fast(b);
  a >>= fa;
  b >>= fb;
  while (a != b) {
    auto& c = a > b ? a : b;
    c = abs(a - b);
    c >>= least_bit_fast(c);
  }
  return a << min(fa, fb);
}

template<typename T> T lcm(T t) {return t;}

template<typename T, typename... S> T lcm(T t, S... s) {
  T l = lcm(s...);
  return t / gcd(t, l) * l;
}

template<typename T> T floor(T a, T b) {
  auto d = div(a, b);
  return d.quot - (d.rem && (a < 0) != (b < 0) ? 1 : 0);
}

template<typename T> T ceil(T a, T b) {
  auto d = div(a, b);
  return d.quot + (d.rem && (a > 0) == (b > 0) ? 1 : 0);
}

template<typename T> T round(T a, T b) {return floor(a + b / 2, b);}

template<typename T> T mod(T a, T b) {
  T c = a % b;
  return c < 0 ? c + abs(b) : c;
}

template<typename T> T factorial(T n) {return n <= 1 ? 1 : factorial(n - 1) * n;}

template<typename T> T square(T n) {return n * n;}

template<typename T> T cube(T n) {return n * n * n;}

template<typename T> T norm(T x1, T y1, T x2, T y2) {return square(x1 - x2) + square(y1 - y2);}

template<typename T> bool isSquare(T n) {return square(T(sqrt(n))) == n;}

template<typename T> T clamp(T v, T l, T u) {return v < l ? l : v > u ? u : v;}

int main() {
  int n;
  cin >> n;
  cout << lcm(2, n) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


signed main() {
    string s;
    cin >> s;
    ll c0 = 0;
    ll c1 = 0;
    
   
    rep(i, (ll)s.size()) {
        char c = s[i] - '0';
        if(c != (i%2)) {
            c0++;
        }
        if(c != (1 - i%2)) {
            c1++;
        }
    }
    mes(min(c0, c1));
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 3744
main=do
 n<-readLn
 print$f 0 False False False n
f k a b c n
 |k>n=0
 |otherwise=(if a&&b&&c then 1 else 0)+(f(k*10+3)True b c n)+(f(k*10+5)a True c n)+(f(k*10+7)a b True n)

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
const int MOD=1E9+7;
map<int,int>res;
void prime_factor(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            res[i]++;
            n/=i;
        }
    }
    if(n!=1)
    {
        res[n]+=1;
    }
}
int main(void)
{
    int n;
    cin>>n;
    for(int i=2;i<=n;i++)
    {
        prime_factor(i);
    }
    long long ans=1;
    for(auto ele:res)
    {
        ans=(ans*(ele.second+1))%MOD;
    }
    cout <<ans <<endl;
    return 0;
}


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

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

	int a, b;
	cin >> a >> b;
	int digit = 0;
	int c = b;
	bool judge = false;
	int ab;
	while(c > 0) {
		c = c / 10;
		digit++;
	}
	ab = (a * pow(10, digit)) + b;
	for(int i = 0; i < 1000; i++) {
		if(i * i == ab) {
			judge = true;
		}
	}
	if(judge) {
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(15).
        01 B PIC 9(15).
        01 C PIC 9(15).
      	01 D PIC 9(15).
      	01 E PIC 9(15).
      	01 t PIC 9(15).
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
        01 N PIC 9(15).
      
        PROCEDURE DIVISION.
      	MAIN.
			ACCEPT A.
      		COMPUTE B = A / 10.
      		COMPUTE B = A - B * 10.
      		COMPUTE A = (A - B) / 10.
      		COMPUTE C = A / 10.
      		COMPUTE C = A - C * 10.
      		COMPUTE A = (A - C) / 10.
      		COMPUTE D = A / 10.
      		COMPUTE D = A - D * 10.
      		COMPUTE A = (A - D) / 10.
      		MOVE A to E.
      		IF B = C OR C = D OR E = D THEN
      			DISPLAY "Bad"
      		ELSE
      			DISPLAY "Good"
      		END-IF.
		STOP RUN.

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

using namespace std;
typedef long long ll;

int main(){
    ll n, m, c;
    cin >> n >> m >> c;
    vector<ll> bs(m, 0);
    for(int i = 0; i < m; ++i){
        cin >> bs.at(i);
    }
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        ll sum = c;
        for(int j = 0; j < m; ++j){
            ll a;
            cin >> a;
            sum += bs.at(j) * a;
        }
        ans += (ll)(sum > 0);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int a(char);
char a(int);

int main()
{
  int n, buf2;
  char buf1;
  int d[52]={0};
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> buf1 >> buf2;
    d[a(buf1)*13+buf2-1]=1;
  }
  for(int i=0; i<52; i++){
    if(!d[i]){
      cout << a(i/13) << ' ' << i%13+1 << endl;
    }
  }
  return 0;
}

int a(char c){
  switch(c){
    case 'S':
      return 0;
    case 'H':
      return 1;
    case 'C':
      return 2;
    case 'D':
      return 3;
  }
  return 0;
}

char a(int i){
  switch(i){
    case 0:
      return'S';
    case 1:
      return'H';
    case 2:
      return'C';
    case 3:
      return'D';
  }
  return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 ,-1};
signed main(){
    int H,W;
    cin >> H >> W;
    vector<vector<int>>c(10,vector<int>(10));
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }
    vector<int>cnt(10);
    iota(cnt.begin(),cnt.end(),0);
    vector<int>cnt2(10,INF);
    do{
        int sum = 0;
        for(int i = 0; i < 10; i++) {
            if(i) {
                sum+=c[cnt[i-1]][cnt[i]];
            }
            if(cnt[i] == 1) {
                break;
            }
        }
        cnt2[cnt[0]] = min(cnt2[cnt[0]],sum);
    } while (next_permutation(cnt.begin(),cnt.end()));
    int ans = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            int A;
            cin >> A;
            if(A == -1) {
                continue;
            }
            ans+=cnt2[A];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(void){
  int r, g, b, a;
  cin >> r >> g >> b;
  a = 100 * r + 10 * g + b;
  if(a%4==0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

#define int long long int
#define mp make_pair
using namespace std;

int n;
vector <int> v(3002);
int dp[3002][3002][2];

int fun(int start , int end , int turn)
{
    if(start >end){
        return 0;
    }
    if(dp[start][end][turn] != -1){
        return dp[start][end][turn];
    }
    if(turn == 0){
        dp[start][end][turn] = max(v[start] + fun(start+1 , end , 1) , v[end] + fun(start , end-1 , 1));
    }
    else{
        dp[start][end][turn] = min(-v[start] + fun(start+1 , end , 0) , -v[end] + fun(start , end-1 , 0));
    }
    return dp[start][end][turn];
}

int32_t main() {
    scanf("%lld", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%lld", &v[i]);
    }
    for (int i = 0; i < 3002; ++i) {
        for (int j = 0; j < 3002; ++j) {
            for (int k = 0; k < 2; ++k) {
                dp[i][j][k] = -1;
            }
        }
    }
    int ans = fun(0 , n-1 , 0);
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
set<int> st[maxn];
int ind[maxn];
int f[maxn],sz[maxn],ans[maxn];
vector<int> e[maxn];
int find(int x){
    return f[x]==x?x:f[x]=find(f[x]);
}
void un(int x,int y){
    x=find(x);y=find(y);
    if(x==y)return;
    f[x]=y;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     int n,m,k;
     cin>>n>>m>>k;
     rep(i,1,n)f[i]=i;
     rep(i,1,m){
         int x,y;cin>>x>>y;
         st[x].insert(y);
         ind[x]++,ind[y]++;
     }
     rep(i,1,k){
         int x,y;cin>>x>>y;
         //if(st[x].count(y))
         e[x].push_back(y);
         e[y].push_back(x);
     }  
    rep(i,1,n)for(auto t:st[i])un(i,t);
    rep(i,1,n)sz[find(i)]++;
    rep(i,1,n){
        ans[i]=sz[f[i]]-ind[i];
        for(auto t:e[i])if(f[t]==f[i])ans[i]--;
        cout<<ans[i]-1<<' ';
    }
}
/* 
先用friendship （建图，染色）直接并查集。
有blockship就不建边、XXX 要分别统计
freindship 直接减去
4 4 1
2 1
1 3
3 2
3 4
4 1
 */

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

int main()
{
	int n, k, r;
	cin >> n >> r;
	if (n >= 10) {
		k = r;
	}
	else
	{
		k = r + 100 * (10 - n);
	}
	cout << k << endl;
	return 0;
}

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

using namespace std;

const int N = 998244353;

#define ll long long

int main(){

    ios::sync_with_stdio(false);

    cin.tie();

    int n, k;

    cin>>n>>k;

    set<int> s;

    ll dp[n+1];

    vector<pair<int, int> > vp;

    for(int i = 0; i < k; i++){

        int l, r;

        cin>>l>>r;

        vp.push_back(make_pair(l, r));

    }

    sort(vp.begin(), vp.end());

    dp[1] = 1;

    dp[0] = 0;

    ll predp[n+1];

    predp[0] = 0;

    predp[1] = 1;

    for(int i = 2; i <= n; i++){

        // cout<<"i = "<<i<<endl;

        ll ans = 0;

        for(int j = 0; j < k; j++){

            int start = vp[j].first;

            int end = vp[j].second;

            int s = i - end, e = i - start;

            // cout<<"s = "<<s<<" e = "<<e<<" ";

            if(e <= 0)

            break;

            if(s <= 0){

                ans+=predp[e];

                // cout<<"predp[e] = "<<predp[e]<<" ans = "<<ans<<" ";

                ans %= N;

                break;

            }

            ans += (predp[e] - predp[s] + N+ dp[s]);

            // cout<<"predp[e] = "<<predp[e]<<" predp[s] = "<<predp[s]<<" ans = "<<ans<<" ";

            ans %=N;

        }

        // cout<<"\ni = "<<i<<" ans = "<<ans<<endl;

        dp[i] = ans;

        predp[i] = predp[i-1]+dp[i];

        predp[i] %= N;

    }

    cout<<dp[n];

    return 0;

}



Measured memory_bytes: 6728
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000

int main(){
	
	string S;
	cin>>S;
	int k = 1;
	bool f = false;
	for(int i=1;i<S.size();i++){
		if(S[i]==S[i-1]&&f==false){
			i++;
			f=true;
			if(i>=S.size())break;
			k++;
		}
		else{
			k++;
			f=false;
		}
	}
		
		
	cout<<k<<endl;
	
	
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
int main(){
	int N,a1=0,a2=0,a3=0;
	double dp[302][302][302]={};
	cin>>N;
	FOR(i,0,N){
		int k;
		cin >> k;
		if(k==1)a1++;
		if(k==2)a2++;
		if(k==3)a3++;
	}
	FOR(i,0,N+1){
		FOR(j,0,N+1){
			FOR(k,0,N+1){
				if(i+k+j==0)continue;
				if(k>0)dp[k][j][i] += dp[k-1][j][i]*k/N;
				if(j>0)dp[k][j][i] += dp[k+1][j-1][i]*j/N;
				if(i>0)dp[k][j][i] += dp[k][j+1][i-1]*i/N;
				dp[k][j][i] += 1.0;
				dp[k][j][i] *= (double)N/double(i+j+k);
			}
		}
	}
	printf("%.12lf\n",dp[a1][a2][a3]);
}

Measured memory_bytes: 215424
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using ii = pair<int, int>;
 
void solve();
 
clock_t start_time;
double get_current_time() {
    return (double)(clock() - start_time) / CLOCKS_PER_SEC;
}
 
int main() {
//	freopen("water.in", "r", stdin);
//	freopen("water.out", "w", stdout);
 
    ios_base::sync_with_stdio(false);
	solve();
}
 
/* ========== actual code starts here ========== */
 
#define fi first
#define re return
#define se second
#define in insert
#define pb push_back
#define eb emplace_back
#define y1 y123123123123
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for(int i = x; i < n; i++)
#define rrep(i, x, n) for(int i = n - 1; i >= x; i--)
 
#ifdef artem
    #define debug(x) x
    #define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
    #define debug(x)
#endif

void solve() {
	int n;
	cin >> n;
	vector<ll> a(n + 1);
	vector<int> where(n + 1);
	for(int i = 1; i <= n; i++) {
		cin >> a[ i ];
		where[ a[ i ] ] = i;
	}

	set<ll> pos;
	pos.in(0), pos.in(n + 1);
	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		int x = where[ i ];
		auto l = *(--pos.lower_bound(x)), r = *pos.lower_bound(x);
		ans += i * (x - l) * (r - x);
		// cout << l << ' ' << r << endl;
		pos.in(x);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 15080
#include <bits/stdc++.h>
#define SIZE(x) ((x).size())
#define PB push_back
#define FI first
#define SE second
#define _ << " " <<

using namespace std;

typedef pair<int, int> iint;

int n;

bool read() {
    if (!(cin >> n)) {
        return false;
    }
    return true;
}

void solve() {
    int a = n / 2;
    int b = n / 2 + (n % 2);
    cout << a*b << endl;
}

int main(void) {
    while (read())
        solve();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;
const int MOD=1000000007;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }



int main(int argc, char**argv){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(0, min(b, d) - max(a, c) ) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

signed main(void)
{
	int n; cin >> n;
	int t[n + 1], x[n + 1], y[n + 1];
	bool ok;

	t[0] = 0;
	x[0] = 0;
	y[0] = 0;
	FOR(i, 1, n + 1) cin >> t[i] >> x[i] >> y[i];
	ok = true;
	rep(i, n)
	{	
		int z = abs(x[i] - x[i + 1]) + abs(y[i] - y[i + 1]);
		if (t[i + 1] - t[i] >= z) 
		{
			if ((t[i + 1] - t[i] - z) % 2 != 0)
				ok = false;
		}
		else
			ok = false;
	}
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

using namespace std;

void replace_all(string &str, string src, string dst) {
    int index = 0;
    while (true) {
        index = (int)str.find(src, index);
        if (index == string::npos) break;
        str.replace(index, src.length(), dst);
    }
}

int main(void) {
    string str, apple = "apple", peach = "peach", dummy = "_____";
    getline(cin, str);
    replace_all(str, apple, dummy);
    replace_all(str, peach, apple);
    replace_all(str, dummy, peach);
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;
using ll = long long;

int main(){
    int K; cin >> K;
    vector<ll> A(K);
    for(int i=0;i<K;i++) cin >> A[i];

    ll x_min = 2;
    ll x_max = 2;
    for(int i=K-1;i>=0;i--){
        if(x_min%A[i]) x_min += A[i] - x_min%A[i];
        if(x_max%A[i]) x_max += -x_max%A[i];
        if(x_min > x_max){
            cout << -1 << endl;
            return 0;
        }else{
            x_max += A[i] - 1;
        }
    }

    cout << x_min << " " << x_max << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    int a,b,c,d;
    cin>>a>>b;
    c=max(a,b);
    d=min(a,b);
    cout<<c+max(c-1,d)<<endl;
    
   return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
from copy import copy

sys.setrecursionlimit(10**7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())

INF = 10**7


def main():
    H, W = in_nn()
    Ch, Cw = in_nn()
    Dh, Dw = in_nn()
    Ch -= 1
    Cw -= 1
    Dh -= 1
    Dw -= 1
    grid = in_map2(H)

    dp = [[INF for _ in range(W)] for _ in range(H)]
    dp[Ch][Cw] = 0

    q = deque()
    q.append((Cw, Ch))

    while q:
        now = q.popleft()
        x, y = now
        for px in range(-2, 3):
            for py in range(-2, 3):
                if (px == 0 and py == 0):
                    continue
                nx, ny = x + px, y + py
                if 0 <= nx < W and 0 <= ny < H and grid[ny][nx]:
                    if (px == -1 and py == 0) or (px == 1 and py == 0) \
                            or (px == 0 and py == -1) or (px == 0 and py == 1):
                        if dp[ny][nx] > dp[y][x]:
                            dp[ny][nx] = dp[y][x]
                            q.appendleft((nx, ny))
                    else:
                        if dp[ny][nx] > dp[y][x] + 1:
                            dp[ny][nx] = dp[y][x] + 1
                            q.append((nx, ny))

    # for i in range(H):
    #     print(' '.join(map(str, dp[i])))

    if dp[Dh][Dw] >= INF:
        ans = -1
    else:
        ans = dp[Dh][Dw]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 103568