akhauriyash/Code-Regression huggingface dataset:
class Combination:
    """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う"""
    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [0] * (n + 1)
        self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD)
        for i in reversed(range(n)):
            self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % MOD
        self.MOD = MOD

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r]) % self.MOD

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD

    def combination2(self, k, r):
        """kCrを求める O(r) kが大きいが、r <= nを満たしているときに使用"""
        if k < r:
            return 0
        res = 1
        for l in range(r):
            res *= (k - l)
            res %= self.MOD
        return (res * self.inv_fact[r]) % self.MOD


n, a, b, c, d = map(int, input().split())
MOD = 10 ** 9 + 7
comb = Combination(10 ** 5, MOD)

dp = [[0] * (n + 1) for i in range(b - a + 2)]
dp[0][0] = 1

for i in range(b - a + 1):
    per_g = i + a
    pow_ = pow(comb.inverse_factorial(per_g), c - 1, MOD)
    for j in range(0, n + 1):
        dp[i + 1][j] = dp[i][j]
        p = pow_
        for cnt_g in range(c, d + 1):
            if j - cnt_g * per_g < 0:
                break
            p *= comb.inverse_factorial(per_g)
            p %= MOD
            dp[i + 1][j] += dp[i][j - cnt_g * per_g] * comb.combination(j, cnt_g * per_g)\
                            * comb.factorial(cnt_g * per_g) * p\
                            * comb.inverse_factorial(cnt_g)
            dp[i + 1][j] %= MOD
print(dp[-1][-1])

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

using namespace std;

typedef vector<vector<int> > matrix;

int n;
long long k;
matrix A, dp;
const int MOD = 1e9 + 7;

int add(long long a, long long b){
    return (a + b) % MOD;
}

int mul(long long a, long long b){
    return (a * b) % MOD;
}

matrix mul(matrix a, matrix b){
    matrix c(n, vector<int>(n, 0));

    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            for(int k = 0; k < n; k++)
                c[i][j] = add(c[i][j], mul(a[i][k], b[k][j]));

    return c;
}

int main(){
    scanf("%d%lld", &n, &k);

    A.resize(n, vector<int>(n, 0));
    dp.resize(n, vector<int>(n, 0));

    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            scanf("%d", &A[i][j]);

    for(int i = 0; i < n; i++) dp[i][i] = 1;

    for(int i = 0; i < 62; i++){
        if(k & (1LL << i)) dp = mul(dp, A);
        A = mul(A, A);
    }

    int ans = 0;
    for(auto k1 : dp){
        for(auto v : k1){
            ans = add(ans, v);
        }
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 384
from collections import deque
H,W=map(int, input().split())
inl=[input() for _ in range(H)]

checked = set([])
lis = [(1,0),(0,1),(-1,0),(0,-1)]

def bfs(i,j):
    fifo = deque([])
    fifo.append((i,j))
    checked.add((i,j))
    cntBlack = 0
    cntWhite = 0
    while fifo:
        i,j = fifo.popleft()
        if inl[i][j] == '.':
            cntWhite += 1
        else:
            cntBlack += 1

        for di,dj in lis:
            if i+di >= 0 and i+di < H and j+dj >= 0 and j+dj < W and \
                not (i+di, j+dj) in checked \
                and inl[i][j] != inl[i+di][j+dj]:

                checked.add((i+di, j+dj))
                fifo.append((i+di, j+dj))
    return cntBlack*cntWhite

res = 0
for i in range(H):
    for j in range(W):
        if not (i,j) in checked:
            res += bfs(i,j)
print(res)


Measured memory_bytes: 21504
#include <stdio.h>

int main(){
	
	int n, i, cnt = 0;
	char s[50];
	
	scanf( " %d %s", &n, &s );
	
	for(i = 0; i < n-2; i++){
		if( s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C' )
			cnt++;
	}
	
	printf( "%d\n", cnt );
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
 
#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222
 
using namespace std;
//using namespace __gnu_pbds;
 
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}
 
//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
 
ll b[N];
string a[N];
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++)
        cin >> a[i] >> b[i];
    string s;
    cin >> s;
    ll ans = 0, flag = 0;
    for(int i = 1; i <= n; i ++)
    {
        if(flag == 1)
            ans += b[i];
        if(s == a[i])
            flag = 1;
    }
    cout << ans; 
 
 
 
	
 
 
 
 
 
	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  cout << k * (int)pow(k - 1, n - 1) << endl;

  return 0;
}


Measured memory_bytes: 3936
from collections import deque

def main():
    N = int(input())
    D = [list(map(int,input().split())) for _ in range(N)]

    deq = deque(D)

    count = 0

    while deq:
        pts = deq.popleft()
        if pts[0] == pts[1]:
            count += 1
        else:
            count = 0
        if count >= 3:
            print("Yes")
            return

    print("No")

main()


Measured memory_bytes: 67280
### constant

PI2 = Math::PI * 2

### main

loop do
  n = gets.to_i
  break if n == 0

  pts = n.times.map{gets.split.map(&:to_f)}
  visited = n.times.map{false}
  #p pts

  cx, cy, vx, vy = [0.0, 0.0, 0.0, 1.0]

  cnt = 0
  lsum = 0.0

  while cnt < n
    cth = Math.atan2(vy, vx)

    max_th = -10.0
    max_i = nil
    max_d2 = nil

    for i in (0...n)
      next if visited[i]

      px, py = pts[i]
      vx = px - cx
      vy = py - cy
      d2 = vx * vx + vy * vy
      th = Math.atan2(py - cy, px - cx)
      th -= PI2 if th > cth

      if max_th < th || max_th == th && max_d2 > d2
        max_th = th
        max_i = i
        max_d2 = d2
      end
    end

    visited[max_i] = true
    lsum += Math.sqrt(max_d2)
    cnt += 1

    vx = pts[max_i][0] - cx
    vy = pts[max_i][1] - cy
    cx, cy = pts[max_i]
  end

  puts "%.1f" % lsum
end

Measured memory_bytes: 6248
import java.io.*;
import java.util.*;

public class Main {
	static int[] memo[];
	static int n,T;
	static pair[]in;
	static int dp(int i,int t) {
		if(i>=n || t>=T)return 0;
		if(memo[i][t]!=-1)return memo[i][t];
		return memo[i][t]=Math.max(dp(i+1,t),dp(i+1,t+in[i].time)+in[i].hap);
	}
	static class pair implements Comparable<pair>{
		int time;int hap;
		pair(int x,int y){
			time=x;hap=y;
		}
		@Override
		public int compareTo(pair o) {
			return time-o.time;
		}
		 
		public boolean equals(pair o) {
			if(this.compareTo(o)==0)return true;
			return false;
		}
	}
	public static void main(String[] args) throws Exception {
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		n=sc.nextInt();
		T=sc.nextInt();
		in=new pair[n];
		for(int i=0;i<n;i++) {
			in[i]=new pair(sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(in);
		memo=new int[n][T];
		for(int[]i:memo)Arrays.fill(i, -1);
		pw.println(dp(0,0));
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] takearr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] takearrl(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public Integer[] takearrobj(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] takearrlobj(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


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

long long f(string N, int i, int j){
  int M = N.size();
  if(j<0) return 0;
  if(j==0) return 1;
  if(M-i-1<j) return 0;
  
  long long ret = 1;
  for(int k=0;k<j;k++) ret *= (M-i-1)-k;
  for(int k=1;k<=j;k++) ret /= k;
  for(int k=0;k<j;k++) ret *= 9;
  return ret;
}

int main(){
  string N;
  int K;
  cin >> N >> K;
  
  int j = K;
  long long ans = f(N,0,j);
  j--;
  ans += f(N,0,j) * ((N[0]-'0')-1);
  for(int i=1;i<N.size();i++){
    if(N[i]=='0') continue;
    else{
      ans += f(N,i,j);
      j--;
      ans += f(N,i,j) * ((N[i]-'0')-1);
    }
  }
  int cnt=0;
  for(int i=0;i<N.size();i++){
    if(N[i]!='0') cnt++;
  }
  if(cnt==K) ans++;
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn
import scala.collection.mutable.Buffer
import scala.annotation.tailrec

object Main extends App {
  val n = StdIn.readInt
  val a = Iterator.continually(StdIn.readInt)
    .take(n)
    .toArray
    .toBuffer
  0 +=: a

  val visit = Array.ofDim[Boolean](n+1)
  @tailrec
  def rec(a:Buffer[Int],cnt:Int, from:Int, end:Int):Int = {
      val to = a(from)
      if(to == end) cnt
      else if(visit(from)) return -1
      else {
        visit(from) = true
        rec(a, cnt+1, to, end)
      }
  }

  val ans = rec(a, 1, 1, 2)

  println(ans)
}

Measured memory_bytes: 38016
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void){
    int n;
    cin >> n;
    int ans=0;
    for(int i=0; i<10; i++){
        if(n<=i*111){
            ans=i*111;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
#include <bitset>
using namespace std;
typedef long long ll;
const ll inf = 4e18;
const ll mod = 1e9+7;
#define print(X) cout << (X) << endl
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (ll (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define repd(i, m, n) for (ll (i) = (m); (i) > (n); --(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

int main(void)
{
    ll N,D,X;
    cin >> N >> D >> X;
    vector<ll> A(N);
    rep (i,N) {
        cin >> A[i];
    }
    ll ans=X;
    for (auto i: A) {
        ans += ((D-1) / i) + 1;
    }
    print(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<double, double> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

const ll mod = 1000000007;
const ll INF = 100000000000010000;

ll bit[1000010];
//ll kai[1000010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

/*ll sum(ll i)
{
	i += 1;
	ll t = 0;
	while (i > 0)
	{
		(t += bit[i]) %= mod;
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	i += 1;
	while (i <= 1000005)
	{
		(bit[i] += x) %= mod;
		i += i & -i;
	}
}*/

void test() {
	cout << "888888888888888888888888" << endl;
}

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

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

/*ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
	//毎回オーダーlog(n)かかる
}

void kaijo() {
	kai[0] = 1;
	for (ll i = 1; i <= 1000005; i++) {
		kai[i] = kai[i - 1] * i % mod;
	}
}*/

ll N;
ll x, y;
vector<ll> E[100010];
ll dp[100010][2]; // 0が黒、1が白
bool flg[100010][2];

ll saiki(ll ver, ll col, ll from) {
	if (flg[ver][col]) return dp[ver][col];
	flg[ver][col] = true;
	ll num = 1;
	for (ll v : E[ver]) {
		if (v == from) continue;
		ll nu = 0;
		(nu += saiki(v, 1, ver)) %= mod;
		if (col == 1) (nu += saiki(v, 0, ver)) %= mod;
		(num *= nu) %= mod;
	}
	return dp[ver][col] = num;
}

void solve() {
	cin >> N;
	rep(i, N - 1) {
		cin >> x >> y;
		E[x].push_back(y);
		E[y].push_back(x);
	}
	cout << (saiki(1, 0, 0) + saiki(1, 1, 0)) % mod << endl;
}

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

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



int main() {
  ll N,A,a = 0,j = 0,k = pow(2,36);
  cin >> N;
  rep(i,N)
  {
    cin >> A;
    a = 0;
    j = 0;
    while (a == 0)
    {
      a = A % 2;
      A = A / 2;
      j++;
    }
    k = min (k,j - 1);
  }
  cout << k << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

struct Edge{
	Edge(int arg_to,ll arg_cost){
		to = arg_to;
		cost = arg_cost;
	}
	int to;
	ll cost;
};

struct State{
	State(int arg_node_id,ll arg_sum_cost){
		node_id = arg_node_id;
		sum_cost = arg_sum_cost;
	}
	bool operator<(const struct State &arg) const{
		return sum_cost > arg.sum_cost; //総コストの昇順(PQ)
	}

	int node_id;
	ll sum_cost;
};

int V,E,K;
ll P[SIZE],c[SIZE],J[SIZE],ans[SIZE];
ll min_cost[2*SIZE];
vector<Edge> G[2*SIZE];


int main(){

	scanf("%d %d %d",&V,&E,&K);

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

		scanf("%lld",&P[i]);
	}

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

		scanf("%lld",&c[i]);
		c[i]--;
	}

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

		scanf("%lld",&J[i]);
	}

	int from,to;
	ll cost;

	for(int loop = 0; loop < E; loop++){

		scanf("%d %d %lld",&from,&to,&cost);
		from--;
		to--;

		G[from].push_back(Edge(to,cost));
		G[to].push_back(Edge(from,cost));

		G[V+from].push_back(Edge(V+to,cost));
		G[V+to].push_back(Edge(V+from,cost));
	}

	for(int from = 0; from < V; from++){

		int to = V+from;
		G[from].push_back(Edge(to,-P[from]+BIG_NUM));
	}


	min_cost[0] = 0;
	for(int i = 1; i < 2*V; i++){

		min_cost[i] = HUGE_NUM;
	}

	priority_queue<State> Q;
	Q.push(State(0,0));

	while(!Q.empty()){

		if(Q.top().sum_cost > min_cost[Q.top().node_id]){

			Q.pop();

		}else{

			for(int i = 0; i < G[Q.top().node_id].size(); i++){

				int next_node = G[Q.top().node_id][i].to;
				ll next_cost = Q.top().sum_cost+G[Q.top().node_id][i].cost;

				if(min_cost[next_node] > next_cost){

					min_cost[next_node] = next_cost;
					Q.push(State(next_node,next_cost));
				}

			}

			Q.pop();
		}
	}

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

		ans[i] = HUGE_NUM;
	}

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

		ans[c[i]] = min(ans[c[i]],min_cost[i]+min_cost[V+i]-BIG_NUM-J[i]);
	}

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

		printf("%lld\n",-ans[i]);
	}

	return 0;
}



Measured memory_bytes: 37816
import sys
import collections

input = sys.stdin.readline

N, K, Q = map(int,input().split())
A=list([int(input()) for _ in range(Q)])

cnt=[0]*N

countA = collections.Counter(A)

for i in range(1,N+1):
    if K-Q+countA[i]>=1:print('Yes')
    else:print('No')

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

int main(void)
{
    int X, N;
    cin >> X >> N;
    
    vector<bool> p(N + 100, false);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        p[a] = true;
    }

    for (int i = 0; ; i++) {
        if (X - i < 0) {
            cout << X - i << endl;
            break;
        }
        else if (p[X - i] == false) {
            cout << X - i << endl;
            break;
        }
        else if (p[X + i] == false) {
            cout << X + i << endl;
            break;
        }
    }
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	static int n;
	static int h, w;
	static int xline[][];

	public static void check(int mark) {
		int right = 0, left = w - 1, top = 0, bottom = h - 1;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (xline[i][j] == mark) {
					right = Math.max(right, j);
					left = Math.min(left, j);
					top = Math.max(top, i);
					bottom = Math.min(bottom, i);
				}
			}
		}
		for (int i = bottom; i <= top; i++) {
			for (int j = left; j <= right; j++) {
				if (xline[i][j] != mark && xline[i][j] != '@') {
					return ;
				}
			}
		}
		for (int i = bottom; i <= top; i++) {
			for (int j = left; j <= right; j++) {
				if (xline[i][j] == mark) {
					xline[i][j] = '@';
				}
			}
		}
	}

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

		n = sc.nextInt();
		while (n-- != 0) {
			h = sc.nextInt();
			w = sc.nextInt();
			xline = new int[h][w];
			for (int i = 0; i < h; i++) {
				String s = sc.next();
				for (int j = 0; j < w; j++) {
					xline[i][j] = s.charAt(j);
				}
			}

			for (int q = 0; q < 7; q++) {
				for (int r = 'A'; r <= 'Z'; r++) {
					check(r);
				}
			}

			boolean f = true;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (xline[i][j] != '.' && xline[i][j] != '@') {
						f = false;
					}
				}
			}

			if (f) {
				System.out.println("SAFE");
			} else {
				System.out.println("SUSPICIOUS");
			}
		}
	}
}

Measured memory_bytes: 38476
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int a, b;
    cin>>a>>b;
    cout<<(a+b-1)/b;
    return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define  sz(x)  (int)x.size()
#define  ff first
#define  ss second
#define  pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int n,cnt=0;
    cin>>n;
    cnt = (n/11)*2;
    if (n%11){
      if (n%11>6) cnt += 2;
      else cnt++;
    }
    cout << cnt << endl; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 256
(X,Y) = gets.split.map(&:to_i)


#a+b=X
#2a+4b=Y
#2b=Y-2*X
b2 = Y-2*X
#puts b2
a = X - b2 / 2
if b2 % 2 == 0 and b2 >= 0 and a >= 0
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 14296
n,m=map(int,input().split())
a=[0]*m;b=[0]*m
for i in range(m):a[i],b[i]=map(int,input().split())

def check(l):
    r=[False]*(n+1)
    r[0]=True
    r[1]=True
    c=1
    while c>0:
        c=0
        for i in l:
            if r[a[i]]^r[b[i]]:r[a[i]]=True;r[b[i]]=True;c+=1
    if all(r):return True
    else: return False
c=0
for i in range(m):
    if not check(list(range(i))+list(range(i+1,m))):c+=1
print(c)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
#define N 100009
#define LL long long
#define INF 0x3f3f3f3f
#define mymin(x,y) (x>=y?y:x)
#define mymax(x,y) (x>=y?x:y)
int main() {
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	int k;
	cin >> k;
	for(int i = 1; i <= k; i++) cout << "ACL";
	cout << endl;
	return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define SIZE 500010
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
long long fac[SIZE],finv[SIZE],inv[SIZE];
long long MOD=mod;

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

// 二項係数計算
long long C(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long nPr(int n, int r) {
   if (n < 0 || r < 0 || n < r) return 0;
   return fac[n] * finv[n - r] % MOD;
 }
long long mpn(long long M,long long N){
    long long tmp=M;
    long long ret=1;
    rep(i,N){
    ret*=tmp;
    ret%=mod;
    tmp--;
    }
    return ret;
}
int main(){
    make();

    long long n,m;
    cin>>n>>m;

    long long ans=0;

    for(long long k=0;k<=n;k++){
        long long p=-1;
        if(k%2==0)p=1;
        long long total=C(n,k)*p*nPr(m,k);
        total%=mod;
        total*=(nPr(m-k,n-k)*nPr(m-k,n-k))%mod;
        ans+=total;
        if(ans<0)ans+=mod;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;

}
/*


*/


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

string map[21];
int sx,sy,ans,x,y;

void search(int xx,int yy){
	ans++;
	map[yy][xx]='#';
	if(xx<x-1&&map[yy][xx+1]=='.')search(xx+1,yy);
	if(xx>0&&map[yy][xx-1]=='.')search(xx-1,yy);
	if(yy<y-1&&map[yy+1][xx]=='.')search(xx,yy+1);
	if(yy>0&&map[yy-1][xx]=='.')search(xx,yy-1);
}

int main(){
	while(cin>>x>>y,x||y){
		ans=0;
		for(int i=0;i<y;i++)cin>>map[i];
		for(int i=0;i<y;i++){
			for(int j=0;j<x;j++){
				if(map[i][j]=='@')sy=i,sx=j;
			}
		}
		search(sx,sy);
		cout<<ans<<endl;
	}
}

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

int main() {
    int a, b, ans=0;

    cin >> a >> b;
    for (int i=0; i<2; i++) {
        if (a > b) {
            ans += a;
            a--;
        } else {
            ans += b;
            b--;
        }
    }
    cout << ans << endl;

    return 0;
}

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

ll h, w;

ll solve(ll x, ll y){
    ll ans = h * w;
    for(int i = 1; i < x; i++){
        ll s1 = i * y;
        ll s2 = (x - i) / 2 * y;
        ll s3 = x * y - s1 - s2;
        ll smax = max(s1, max(s2, s3));
        ll smin = min(s1, min(s2, s3));
        ans = min(ans, smax - smin);

        s2 = (x - i) * (y / 2);
        s3 = x * y - s1 - s2;
        smax = max(s1, max(s2, s3));
        smin = min(s1, min(s2, s3));
        ans = min(ans, smax - smin);
    }
    return ans;
}

int main(){
    cin >> h >> w;
    cout << min(solve(h, w), solve(w, h)) << endl;
    return 0;
}

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

int main() {
	string s; cin >> s;
	int n = s.size() + 1;
	int64_t a[n] = {};
	int64_t cnt = 0;
	for(int i = 0; i < n; ++i) {
		a[i] = cnt;
		if(i == n - 1) break;
		if(s[i] == '<') ++cnt;
		else cnt = 0;
	}
	cnt = 0;
	int64_t ans = 0;
	for(int i = n - 1; i >= 0; --i) {
		ans += max<int64_t>(a[i], cnt);
		if(i == 0) break;
		if(s[i - 1] == '>') ++cnt;
		else cnt = 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4740
#include<stdio.h>
#include<string.h>
#define MAX 1000000

int hamming[MAX+1];
void init(){
	int i,n=0;
	hamming[1] = -1;
	for(i=1;i<=MAX;i++){
		if(hamming[i]==-1){
			hamming[i] = ++n;
			if(i*2<=MAX){
				hamming[i*2] = -1;
				if(i*3<=MAX){
					hamming[i*3] = -1;
					if(i*5<=MAX)hamming[i*5] = -1;
				}
			}
		}
		else {
			hamming[i] = n;
		}
	}
}
int main(){
	int m,n;
	init();
	while(scanf("%d",&m)==1&&m){
		scanf("%d",&n);
		printf("%d\n",hamming[n]-hamming[m-1]);
	}
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    int a,b,k;cin>>a>>b>>k;
    int s=b-k+1;
    if(s>=a+k){
        rep(i,k){
            cout<<a+i<<endl;
        }
        rep(i,k){
            cout<<s+i<<endl;
        }
    }else{
        rep(i,b-a+1){
            cout<<a+i<<endl;
        }
    }
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

//main code
int main(int argc, char const* argv[])
{
	LL inf = 1000000000;
	LL s;
	cin >> s;
	LL x1 = min((LL)sqrt(s)+1,inf);
	LL y2 = x1;
	LL sub = x1*y2 - s;
	LL x2 = 1;
	LL y1 = sub;
	cout << 0 << " " << 0 << " " << x1 << " " << y1 << " " << x2 << " " << y2 << 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(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

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

    int k, odd, even;
    cin >> k;

    if(k%2 == 0){
        odd = even = k/2;
    }
    else{
        odd = k/2 + 1;
        even = odd - 1;
    }

    cout << odd*even ;
}

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

using namespace std;

int memo[8][10];
int calc(int pos, int cur, const vector<int> &as, const vector<int> &is_double) {
    if(pos == (int)is_double.size()) return cur==0;

    int &res = memo[pos][cur];
    if(res < 0) {
        res = 0;
        for(vector<int>::const_iterator it = as.begin(); it != as.end(); ++it) {
            int digit = *it;
            if(is_double[pos]) {
                digit *= 2;
                if(digit >= 10) digit = (digit/10)+(digit%10);
            }
            res += calc(pos+1, (cur+digit)%10, as, is_double);
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N;
    while(cin >> N) {
        string str;
        cin >> str;
        int M;
        cin >> M;
        vector<int> as(M);
        for(int i = 0; i < M; ++i) cin >> as[i];

        vector<int> is_double;
        int checksum = 0;
        for(int i = 0; i < N; ++i) {
            const int pos = (int)str.size()-1-i;
            if(str[pos] == '*') {
                is_double.push_back(i%2);
            } else {
                int digit = str[pos]-'0';
                if(i%2 == 1) {
                    digit *= 2;
                    if(digit >= 10) digit = (digit/10)+(digit%10);
                }
                checksum += digit;
                checksum %= 10;
            }
        }
        fill_n((int*)memo, sizeof(memo)/sizeof(int), -1);
        cout << calc(0, checksum, as, is_double) << endl;
    }
    return 0;
}

Measured memory_bytes: 1392
fun main(args: Array<String>) {
    var x = (1..6).map{
        readLine()!!.toInt()
    }
    var k = x[5]
    var flag = false
    
    for(i in 0..x.size-2){
        for(j in i+1..x.size-1){
            var d = x[j]-x[i]
            if(k<d) flag = true
        }
    }
    if(flag) println(":(")
    else println("Yay!")
}

Measured memory_bytes: 33560
from collections import deque
K = int(input())

q = deque([i for i in range(1, 10)])

for i in range(K):
    x = q.popleft()
    amari = x%10
    if amari == 0:
        l, m = 10*x, 10*x+1
        q.append(l)
        q.append(m)
    elif amari == 1:
        l, m, r = x*10, x*10+1, x*10+2
        q.append(l)
        q.append(m)
        q.append(r)
    elif amari == 9:
        l, m = 10*x+8, 10*x+9
        q.append(l)
        q.append(m)
    else:
        l, m, r = 10*x+(amari-1), 10*x+(amari), 10*x+(amari+1)
        q.append(l)
        q.append(m)
        q.append(r)

print(x)


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;

int n,m;
int a[3000], b[3000];
bool graph[3000][3000], temp_graph[3000][3000];
vector <bool> visited(100,false);

int dfs(int src){
  visited[src] = true;
  rep(i,1,n+1){
    if(temp_graph[src][i]&&!visited[i])dfs(i);//深さ優先探索で到達判定
  }
  bool is_visited_all=true;
  rep(i,1,n+1)if(!visited[i])is_visited_all=false;
  if(is_visited_all)return 0;
  else return 1;
}
void init(){
  rep(i,0,m){
    temp_graph[a[i]][b[i]]=true;
    temp_graph[b[i]][a[i]]=true;
  }
  rep(i,0,visited.size())visited[i]=false;
}

int main(){
  cin >> n >> m;
  rep(i,0,m){
    cin >> a[i] >> b[i];
    graph[a[i]][b[i]]=true;
    graph[b[i]][a[i]]=true;
  }
  init();
  int ans =0;
  rep(i,0,m){
    temp_graph[a[i]][b[i]] = false;
    temp_graph[b[i]][a[i]] = false;
    ans += dfs(1);
    init();
  }
  cout << ans << endl;

}


Measured memory_bytes: 2432
N = int(input())
S = input()

# print(N)
# print(S)

x = 0
x_list = [0]
for s in S:
	# print(s)
	if s == 'I':
		x += 1
	elif s == 'D':
		x -= 1
	x_list.append(x)
	
# print(x_list)
print(max(x_list))

Measured memory_bytes: 2940
#include<stdio.h>
int main(void){
    int a,b,c,d;
    int flg=0;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    while(1){
        c-=b;
        a-=d;
        if(c<=0){
            flg=1;
            break;
        }
        if(a<=0){
            flg=2;
            break;
        }
    }
    if(flg==1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1660
// C + T = X
// 2 * C + 4 * T = Y
// T = X - C
// 2 * C + 4 * (X - C) = Y
// - 2 * C = Y - 4 * X
// C = 2 * X - Y / 2
// T = -X + Y / 2

#include <bits/stdc++.h>

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int X, Y;
    cin >> X >> Y;
    int C, T;
    C = 2 * X - Y / 2;
    T = -X + Y / 2;
    cout << (0 <= C && 0 <= T && C + T == X && 2 * C + 4 * T == Y ? "Yes"
                                                                  : "No")
         << endl;
    return 0;
}


Measured memory_bytes: 3568
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79812
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

n = int(sys.stdin.readline())

for i in range(1, n+1):
    if i % 3 == 0:
        print(' ', i, sep='', end='')
    else:
        x = i
        while x > 0:
            if x % 10 == 3:
                print(' ', i, sep='', end='')
                break
            x //= 10
print()



Measured memory_bytes: 6164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second

typedef long long ll;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

void solve1()
{
    ll n; cin >> n;

    int cnt = 0;
    for(int i = 1; i*i <= n; i++) {
        for(int j = i; j <= n; j++) {
            int c = n - i*j;
            if(c >= 1 && c <= n) {
                if(i == j) {
                  cnt ++;
                } else {
                    cnt += 2;
                }
            }
        }
    }

    cout << cnt << endl;
}

int main()
{
    solve1();
}


Measured memory_bytes: 3668
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;


int main(void){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);
    for(int i = 0; i < 2; i++)
    {
        int cnt = 0;
        for (int j = 0; j < n; j++)
        {
            if(s[j] == 'R') cnt++;
            else
            {
                ans[j] += cnt/2;
                ans[j-1] += (cnt+1)/2;
                cnt = 0;
            }
            
        }
        reverse(s.begin(), s.end());
        reverse(ans.begin(), ans.end());
        for (int j = 0; j < n; j++)
        {
            if(s[j] == 'R') s[j] = 'L';
            else s[j] = 'R';
        }
    }
    for (int i = 0; i < n; i++)
    {
        printf("%d%c", ans[i], i==n-1?'\n':' ');
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a;
  cin >> a;
  if(a=='A'){
    cout << 'T' <<endl;
  }else if(a=='T'){
    cout << 'A' <<endl;
  }else if(a=='G'){
    cout << 'C' <<endl;
  }else if(a=='C'){
    cout << 'G' <<endl;
  }
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u64,
        m: u64,
    }
    let res = match (n,m) {
        (1,1) => 1,
        (1,m) => m-2,
        (n,1) => n-2,
        _ => (n-2) * (m-2)
    };
    println!("{}", res);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << "\n"
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

int main(){
  set<ll> st;
  map<ll,ll> p;
  ll ans = 0;
  cin >> n;
  lep(i,1,n)cin >> d[i];
  lep(i,2,n)d[i] += d[i-1];
  sort(d,d+n+1);
  lep(i,0,n){
    if(st.count(d[i])){
      p[d[i]]++;
      ans += p[d[i]];
    }
    st.insert(d[i]);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=1e5+5;

vector<int> v[N];

int ans[N];

void solve(){
	int n,m;
	cin>>n>>m;
	rep(i,0,m){
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	
	queue<pii> q;
	q.push({1,1});
	while(sz(q)){
		auto k=q.front();
		q.pop();
		if(ans[k.sc])continue;
		ans[k.sc]=k.fr;
		for(int x:v[k.sc]){
			q.push({k.sc,x});
		}
	}
	
	cout<<"Yes\n";
	rep(i,2,n+1){
		cout<<ans[i]<<"\n";
	}
	
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 17080
H,W=map(int,input().split(' '))
F=[input() for i in range(H)]
ans='Yes'
for y in range(H):
    for x in range(W):
        if ans=='No':
            break
        else:
            a = F[y][x]=='#'
            b = x==0 or (x>0 and F[y][x-1]=='.')
            c = x==W-1 or (x<W-1 and F[y][x+1]=='.')
            d = y==0 or (y>0 and F[y-1][x]=='.')
            e = y==H-1 or (y<H-1 and F[y+1][x]=='.')
            if a and b and c and d and e:
                ans='No'
print(ans)

Measured memory_bytes: 3064
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var h = int.Parse(spl[1]);

        var aa = new int[n];
        var bb = new int[n];
        for(int i=0; i<n; i++) {
            spl = input.ReadLine().Split(' ');
            aa[i] = int.Parse(spl[0]);
            bb[i] = int.Parse(spl[1]);
        }

        Array.Sort(bb, (x, y) => y - x);
        Array.Sort(aa, (x, y) => y - x);

        var c = 0;
        var bidx = 0;

        while (h > 0) {
            if(bidx < n && bb[bidx] > aa[0]) {
                h -= bb[bidx];
                bidx++;
                c++;
            } else {
                var x = Math.Max(1, h / aa[0]);
                c += x;
                h -= aa[0] * x;
            }
        }
        return c;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 15828
N, K = map(int, input().split())
d = [0 for i in range(K)]
A = []
for i in range(K):
    d[i] = int(input())
    A.append(list(map(int, input().split())))
trick = [1 for i in range(N)]
for i in range(K):
    for a in A[i]:
        trick[a-1] = 0
print(sum(trick))


Measured memory_bytes: 9188