akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long int i,j,h,w;
    cin>>h>>w;
    char path[h+1][w+1];
    long long int dp[h+1][w+1]={};
    for(i=1;i<=h;i++)
        for(j=1;j<=w;j++)
            cin>>path[i][j];

    for(i=1;i<=h;i++)
    {
        if(path[i][1]=='#')
            break;
        else
            dp[i][1]=1;
    }
    for(j=1;j<=w;j++)
    {
        if(path[1][j]=='#')
            break;
        else
            dp[1][j]=1;
    }

    for(i=2;i<=h;i++)
    {
        for(j=2;j<=w;j++)
        {

            dp[i][j]=0;
            if(path[i-1][j]=='.')
                dp[i][j]=dp[i-1][j];
            if(path[i][j-1]=='.')
                dp[i][j]+=dp[i][j-1];
            dp[i][j]%=1000000007;

        }
    }
    cout<<dp[h][w];
}


Measured memory_bytes: 9088
import sys
input = sys.stdin.readline
from collections import defaultdict, deque
n = int(input())
X = 10000
INF = 1 << 50
edges = defaultdict(list)
edges_r = defaultdict(list)
def topological_sort(G):

    cnt_in = defaultdict(int)
    for k in G.keys():
        for v in G[k]:
            cnt_in[v] += 1
    # print(cnt_in)
    res = []
    # 入次数==0
    q = deque([i for i in list(G.keys()) if cnt_in[i]==0])
    while len(q) > 0:
        v = q.popleft()
        res.append(v)
        for next_v in G[v]:
            # 入次数を下げていく
            cnt_in[next_v] -= 1
            # 入次数が0に残ったところを次に追加
            if cnt_in[next_v] == 0:
                q.append(next_v)
    # トポソ不可能！
    if len(G) != len(res):
        print(-1)
        exit()
    return res

for i in range(n):
    r = list(map(int, input().split()))
    # 初期
    mn = min(i, r[0]-1)
    mx = max(i, r[0]-1)
    prev = mn * n + mx
    for e in r[1:]:
        e -= 1
        mn = min(i,e)
        mx = max(i,e)
        now = mn*n+mx
        edges[prev].append(now)
        edges_r[now].append(prev)
        prev = now
vs = topological_sort(edges)

# トポソの順番で経路長を入れていく
used = [0] * n**2
# for V in vs:
#     if used[V]: continue
#     used[V] = 1
#     q = deque([V])
#     while len(q) > 0:
#         v = q.popleft()
#         for u in edges[v]: 
#             if used[u] <= used[v]:
#                 q.append(u)
#                 used[u] = max(used[u], used[v] + 1)

for V in vs:
    if used[V]:continue
    used[V] = 1
    mx = 1
    for b in edges_r[V]:
        mx = max(mx, used[b]+1)
    used[V] = mx
# print(used)
print(max(used))

Measured memory_bytes: 299144
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  long long k;
  cin >> k;
  vector<vector<int>> to(61, vector<int>(n));
  for (int i = 0; i < n; i++) {
    cin >> to[0][i];
    to[0][i]--;
  }
  for (int j = 1; j < 61; j++) {
    for (int i = 0; i < n; i++) {
      to[j][i] = to[j - 1][to[j - 1][i]];
    }
  }
  int ans = 0;
  for (int j = 60; j >= 0; j--) {
    if ((1LL << j) <= k) {
      k -= (1LL << j);
      ans = to[j][ans];
    }
  }
  cout << ans + 1 << endl;
  return 0;
}

Measured memory_bytes: 51768
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=2e5+10;
const int Mod=1e9+7;

int N,C[maxm];
long long DP[maxm],Add[maxm];

int main(){
	register int i;
	scanf("%d",&N);
	for(i=1;i<=N;i++) scanf("%d",C+i);
	Add[C[1]]=1;
	for(i=1;i<=N;i++){
		DP[i]=Add[C[i]];
		if(C[i]==C[i+1]) continue;
		Add[C[i+1]]+=DP[i];
		if(Add[C[i+1]]>Mod) Add[C[i+1]]-=Mod;
	}
	printf("%lld",DP[N]);
	return 0;
}

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

int main(){
    ll n,k;
    std::cin >> n>>k;
    if(k==0){
        std::cout << n*n << std::endl;
        return 0;
    }
    
    // aをbで割ったあまりがk以上
    // a=b*s+r
    // あまりがk以上ということは少なくともbはkよりも大きい
    // b>k
    // a%b >= k;
    // bがとりうる値
    ll result = 0;
    for (int i = k+1; i <= n; i++) {
        // x*b-1 <= Nとなる最大のx
        ll mab = (n+1)/i;
        result += mab*(i-k);
        ll may = n-k-mab*i;
        // std::cout << i<<" "<<mab<<" "<<may << std::endl;
        
        if(may>=0){
            result+=may+1;
        }
        // std::cout <<mab<<" "<< i<<" "<<k<<" "<<may<<" "<<result << std::endl;
        // result += max((ll)0,may+1);
    }
    std::cout << result << std::endl;
    //     k,,,,,,,,,,,,b-1
    // a = b+k,b+k+1,,,,,2*b-1,
        // 2*b+k,,,,,,,,,3*b-1,
                        // x*b-1,
                        // < (x+1)*b-1.
            // x*b+k+y<=Nとなる最大のy
            // y<=n-k-x*b
            
    // 各bについて
        // i*b+k,,,(i+1)*b-1
        // 0,,,,b-1
        //  k,,b-1
        // b-k個
    // nという上限が来る
    
            
}


Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n, a, b = tin()
	#s = input()
	ra = n // (a+b)
	blue_num = ra * a
	amari = n % (a+b)
	blue_num += min(amari, a)
	
	print(blue_num)
	
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

ll win[N], lose[N];

int main() {
	fast_cin();
	int n, k;
	cin >> n >> k;
	map<char, int> pts;
	cin >> pts['r'] >> pts['s'] >> pts['p'];
	string t; cin >> t;
	map<char, char> beats;
	beats['r'] = 'p';
	beats['s'] = 'r';
	beats['p'] = 's';
	for (int i = 0; i < n; ++i) {
		char c = beats[t[i]];
		if (i < k) {
			win[i] = pts[c];
			lose[i] = 0;
		} else {
			lose[i] = win[i - k];
			win[i] = pts[c] + (t[i] == t[i - k] ? lose[i - k] : win[i - k]);
			win[i] = max(win[i], lose[i]);
		}
	}
	ll ans = 0;
	for (int i = n - 1; i >= n - k; --i) {
		ans += max(win[i], lose[i]);
	}
	cout << ans << endl;
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL N;
  cin >> N;

  vector<vector<pii>> graph(N);

  REP(i,N-1){
    LL u, v, w;
    cin>>u>>v>>w;
    u--;
    v--;
    graph[u].push_back({v, w});
    graph[v].push_back({u, w});
  }

  vector<bool> ans(N);

  vector<bool> otozureta(N, false);

  queue<LL> q;

  q.push(0);
  otozureta[0] = true;
  ans[0] = false;

  while(!q.empty()){
    LL a = q.front();
    q.pop();

    REP(i,graph[a].size()){
      LL b = graph[a][i].first;

      if(!otozureta[b]){
        otozureta[b] = true;
        ans[b] = (graph[a][i].second % 2 != 0) ^ ans[a];
        q.push(b);
      }
    }
  }

  REP(i,N){
    if(ans[i]){
      cout << 1 << endl;
    }else{
      cout << 0 << endl;
    }
  }
}





Measured memory_bytes: 7936
fun main(args: Array<String>) {
    val firstLine = readLine()?.split(" ").orEmpty()
    val widthWhole = firstLine[0].toInt()
    val heightWhole = firstLine[1].toInt()
    val quantPoints = firstLine[2].toInt()
    var blankArea = 0
    var leftDraw = 0
    var rightDraw = widthWhole
    var topDraw = heightWhole
    var bottomDraw = 0

    for(i in 0 until quantPoints){
        val grid = readLine()?.split(" ").orEmpty()
        val gridX = grid[0].toInt()
        val gridY = grid[1].toInt()

        when (grid[2].toInt()) {
            1 -> {
                if(gridX > leftDraw){
                    leftDraw = gridX
                }
            }
            2 -> {
                if(gridX < rightDraw) {
                    rightDraw = gridX
                }
            }
            3-> {
                if(gridY > bottomDraw){
                    bottomDraw = gridY
                }
            }
            4 -> {
                if(gridY < topDraw) {
                    topDraw = gridY
                }
            }
        }

    }

    val blankWidth = rightDraw - leftDraw
    val blankHeight = topDraw - bottomDraw


    if(blankWidth > 0 && blankHeight > 0){
        blankArea = blankWidth * blankHeight
    }

    println(blankArea)
}

Measured memory_bytes: 37904
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

X,Y = (int(i) for i in input().split())
if((X+Y) % 3 == 0):
    A = (2*Y-X)//3
    B = (2*X-Y)//3
    print(cmb(A+B,A,mod))
else:
    print(0)

Measured memory_bytes: 123772
#include <bits/stdc++.h>
#define maxn 1000000
using namespace std;
vector<int> G[maxn]; 
queue<int> q;
long long dis[maxn],w[maxn];
int in[maxn],nex[maxn],first[maxn],to[maxn],tot,vis[maxn],ins[maxn];
int n,m,p;
void add(int u,int v,int we)
{
	nex[++tot]=first[u];	
	first[u]=tot;
	to[tot]=v;
	w[tot]=we;
}
int spfa()
{
	while(q.size())q.pop();
	fill(dis,dis+n+1,1e12);
	dis[1]=0;
	q.push(1);
	while(q.size())
	{
		int u=q.front();
		q.pop();
		in[u]=0;
		for(int e=first[u];e;e=nex[e])
		{
			int v=to[e];
			if(w[e]+dis[u]<dis[v])
			{
				if(!ins[v])continue;
				dis[v]=dis[u]+w[e];
				if(in[v])continue;
				vis[v]++;
				if(vis[u]>=n)return 0; 
				q.push(v);
				in[v]=1;
			}
		}
	}
	return 1;
}
void bfs()
{
	q.push(n);
	ins[n]=1;
	while(q.size())
	{
		int u=q.front();
		q.pop();
		for(int i=0;i<G[u].size();i++)
		{
			int v=G[u][i];
			if(ins[v])continue;
			q.push(v);
			ins[v]=1;
		}
	}
}
inline bool dfs(int p){
	if(in[p])return 0;
	if(p==n)return 1;
	in[p]=1;
	for(int e=first[p];e;e=nex[e])if(dfs(to[e]))return 1;
	return 0;
}
int main()
{
//	freopen("in.txt","r",stdin);
	cin>>n>>m>>p;
	for(int i=1;i<=m;i++)
	{
		int u,v,val;
		scanf("%d%d%d",&u,&v,&val);
		G[v].push_back(u);
		add(u,v,-(val-p));
	}
 	bfs();	
// 	memset(ins,1,sizeof(ins));
// 	for(int i=1;i<=n;++i){
//		if(!dfs(i))ins[i]=0;
//		memset(in,0,sizeof(in));
//	}
	if(!spfa())cout<<-1<<endl;
	else cout<<(dis[n]>=0?0:-dis[n]);
	return 0;
}  

Measured memory_bytes: 38272
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define LINE_BUF_SIZE 256

int main(){

    int M,N,A,B,C;
    int i,j,k;
    char line[LINE_BUF_SIZE];

    fgets(line,sizeof(line),stdin);

    if(strncmp(line,"abc",3) == 0 || strncmp(line,"bac",3) == 0 || strncmp(line,"acb",3) == 0 || strncmp(line,"cab",3) == 0 || strncmp(line,"cba",3) == 0 || strncmp(line,"bca",3) == 0){
        printf("Yes");
    return 0;
        }

    printf("No");

    return 0;

}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n, t = lmi()
c = [0] * n
for i in range(n):
    c[i] = lmi()

d = [x[0] for x in c if x[1] <= t]
if d == []:
    print('TLE')
else:
    print(min([x[0] for x in c if x[1] <= t]))


Measured memory_bytes: 3316
class WeightedUnionFind:
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [-1]*(n+1)
        self.weight = [0]*(n+1)
    
    """ xの根を求める"""
    def Find_Root(self, x):
        if (self.root[x] < 0):
            return x
        else:
            y = self.Find_Root(self.root[x])
            self.weight[x] += self.weight[self.root[x]]
            self.root[x] = y
            return y
    
    """ 木の合併 """
    def Union(self, x, y, w):
        rx = self.Find_Root(x)
        ry = self.Find_Root(y)
        
        if self.rnk[rx] < self.rnk[ry]:
            self.root[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        
        else:
            self.root[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rnk[rx] == self.rnk[ry]:
                self.rnk[rx] += 1
    
    """ xとyが同じ木に所属するかの判定 """
    def IsSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    
    """ x,yのノード重みの取得 """
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]
    
    """ xが属する木のサイズ(集合の個数)を取得 """
    def Size(self, x):
        return -self.root[self.Find_Root(x)]
n,m = map(int,input().split())
wuf = WeightedUnionFind(n)
flg = True
for _ in range(m):
    l,r,d = map(int,input().split())
    if not wuf.IsSameGroup(l,r):
        wuf.Union(l,r,d)
    else:
        if wuf.diff(l,r)!=d:
            flg = False
            break
print('Yes' if flg else 'No')

Measured memory_bytes: 103768
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 200005, MOD = 1000000007;
typedef long long i64;

i64 fac[MAX_N], ifac[MAX_N], inv[MAX_N];

i64 binom(int n, int m) {
  if (n < m) return 0;
  return fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
}

int main() {
  int H, W, tot, A, B;
  scanf("%d%d%d%d", &H, &W, &A, &B);

  tot = H + W, fac[0] = ifac[0] = inv[1] = 1;
  for (int i = 1; i <= tot; ++i) fac[i] = fac[i - 1] * i % MOD;
  for (int i = 2; i <= tot; ++i) inv[i] = -(MOD / i) * inv[MOD % i] % MOD;
  for (int i = 1; i <= tot; ++i) ifac[i] = ifac[i - 1] * inv[i] % MOD;

  i64 res = 0;
  int x = H - A - 1;
  
  for (int i = B; i < W; ++i) 
    res = (res + binom(x + i, x) * binom(H - 2 - x + W - 1 - i, W - 1 - i) % MOD) % MOD;

  printf("%lld\n", (res + MOD) % MOD);
  return 0;
}


Measured memory_bytes: 4864
import java.util.*;

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

        Integer max_len = s.length();
        int[] n_mod = new int[max_len+1];
        int[] map2019 = new int[2019];
        int pow = 1;
        for(int i=max_len-1;i>=0;i--){
            Integer num = Integer.valueOf(s.substring(i, i+1));
            Integer tmp = (num*pow + n_mod[i+1])%2019;
            n_mod[i] = tmp;
            map2019[tmp]+=1;
            pow *= 10;
            pow %= 2019;
            // System.out.println(tmp);
        }

        long count = (long)map2019[0];
        for(int i=0;i<2019;i++){
            Integer num = map2019[i];
            if(num<2)continue;
            count += num*(num-1)/2;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 45960
s = gets.chomp
first_length = s.length

i = 0
while i < s.length
  if s.length > 0
    case s[i]
    when "0"
      if s[i+1] == "1"
        s.slice!(i, 2)
        if i >= 2
          i -= 2
        elsif i == 1
          i -= 1
        end
      else
        i += 1
      end
    when "1"
      if s[i+1] == "0"
        s.slice!(i, 2)
        if i >= 2
          i -= 2
        elsif i == 1
          i -= 1
        end
      else
        i += 1
      end
    else
      i += 1
    end
  else
    break
  end
end

puts s ? first_length - s.length : first_length

Measured memory_bytes: 78604
#include<iostream>
using namespace std;
int main(void){
	while(true){
		int x,y;
		int moved = 0;
		bool bLoop = false;
		int h,w;
		char **map;

		cin >> h >> w;
		if( h==0&&w==0 ) break;
		cin.ignore(3,'\n');

		map = new char*[h];
		for(int i = 0; i < h; i++){
			map[i] = new char[w+2];
			cin.getline(map[i], w+2);
		}

		x = 0; y = 0;
		while( true ){
			if( map[y][x] == '.' || bLoop ) break;
			if( moved > h * w + 1 ) bLoop = true;
			switch( map[y][x] ){
				case '>':
					x++;
					break;
				case 'v':
					y++;
					break;
				case '^':
					y--;
					break;
				case '<':
					x--;
					break;
			}
			moved++;
		}
		if( bLoop ) cout << "LOOP\n";
		else cout << x << ' ' << y << '\n';

		for(int i = 0; i < h; i++){
			delete []map[i];
		}
		delete []map;
	}
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

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

    cout.precision(10);

    cout << ((N+1)/2)/ (float)N << endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional>
using namespace std;
#define ll long long
#define ull unsigned ll
const ll mod=1000000007;
int n, m;
ll gao(int x) {
	ll res=1ll;
	for (int i=2; i<=x; i++) {
		res=(res*(ll)i)%mod;
	}
	return res;
}
int main() {
	cin>>n>>m;
	if (abs(n-m)>1) {
		cout<<0<<endl;
		return 0;
	}
	cout<<(gao(n)*gao(m)*(abs(n-m)==1?1ll:2ll))%mod<<endl;
	return 0;
}

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

#define readInt(num) scanf("%d", &num)
#define read(num1, num2) scanf("%d %d", &num1, &num2)
typedef long long int lli;

int n;
int a, avg, arr[51];
lli dp[51][2501][51];

lli solve(int pos, int sum, int cnt)
{
    if(pos == n) return 0;

    if(dp[pos][sum][cnt] != -1) return dp[pos][sum][cnt];

    dp[pos][sum][cnt] = 0;

    lli val1=0, val2=0;

    //cout << sum+arr[pos] << " " << cnt +1 << endl;

    if(sum+arr[pos] == ((cnt+1)*a))
    {
        val1 = 1+ solve(pos+1, sum+arr[pos], cnt+1);
    }
    else val1 = solve(pos+1, sum+arr[pos], cnt+1);

    val2 = solve(pos+1,sum,cnt);

    return dp[pos][sum][cnt] += (val1+val2);

}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    while(read(n,a) != EOF)
    {
        for(int i=0; i<n; i++) readInt(arr[i]);
        memset(dp, -1, sizeof dp);
        //a = a * n;
        printf("%lld\n", solve(0, 0, 0));
    }

    return 0;
}


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

using namespace std;

int main()
{
    unsigned long long N, A, B;
    cin >> N >> A >> B;
    unsigned long long tmp = N / (A + B);
    unsigned long long tmp2 = (N - tmp * (A + B));
    if (tmp2 <= A)
    {
        cout << tmp * A + tmp2 << endl;
    }
    else
    {
        cout << tmp * A + A << endl;
    }
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

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

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

void foreach_permutation(int n, std::function<void(int *)> f) {
	int indexes[n];
	for (int i = 0; i < n; i++)
		indexes[i] = i;
	do {
		f(indexes);
	} while (std::next_permutation(indexes, indexes + n));
}

string P;
string Q;

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N;
	cin >> N;
	P.resize(N);
	Q.resize(N);

	for (size_t i = 0; i < N; i++) {
		cin >> P[i];
	}
	for (size_t i = 0; i < N; i++) {
		cin >> Q[i];
	}

	string s;
	s.resize(N);

	int loop_count = 0;
	int a = -1;
	int b = -1;
	foreach_permutation(N, [&](int *indexes) {
		for (size_t i = 0; i < N; i++) {
			s[i] = '1' + indexes[i];
		}

		//cout << s << endl;

		if (P == s) {
			a = loop_count;
		}
		if (Q == s) {
			b = loop_count;
		}

		loop_count++;
	});

	cout << abs(a - b) << endl;

	return 0;
}


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


int main(){
  int n,a,b;
  string s;
  cin >> n >> a >> b;
  cin >> s;
  int apos=0,bpos=0,now=0;;
  rep(i,s.size()){
    if (s[i]=='a') {
      apos++;
      if ( now < a + b ){
        cout << "Yes" << endl;
        now++;
      }
      else cout << "No" << endl;
    }
    else if (s[i] == 'b') {
      bpos++;
      if (now < a + b && bpos <= b){
        cout << "Yes" << endl;
        now++;
      }
      else cout << "No" << endl;
    }
    else cout << "No" << endl;
  }
  
  

  return 0;
}



Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


/*
 update : k に xを加算
 query : [s,t) の総和を出力
 */
const ll INIT = 0;
struct SegTree {
    int N;
    ll init_v;
    vector<ll> node;
    
    SegTree(int _N):init_v(INIT) {
        N = 1;
        while (N < _N) N *= 2;
        node.resize(2 * N - 1, init_v);
    }
    
    ll merge(ll l,ll r){
        return l+r;
    }
    void update(int k, ll val) {
        k += N - 1;
        node[k] = merge(node[k],val);
        while (k) {
            k = (k - 1) / 2;
            node[k] = merge(node[k],val);
        }
    }
    ll query(int a, int b) { return query(a, b, 0, 0, N); }
    ll query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return init_v;
        if (a <= l && r <= b) return node[k];
        else {
            ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return merge(vl,vr);
        }
    }
};

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n; cin >> n;
    SegTree ST(n);
    int q; cin >> q;
    while(q--){
        int com; cin >> com;
        if(com == 0){
            int s,t; cin >> s >> t;
            ST.update(s-1,t);
        }else{
            int s,t; cin >> s >> t;
            cout << ST.query(s-1,t) << endl;
        }
    }
}



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

using namespace std;
int main(){
  string s;
  cin >> s;
  char s2[s.size()-7];
  for(int i=0;i<s.size()-8;i++)
    s2[i]=s[i];
  s2[s.size()-8]='\0';
  cout << s2 << "\n";
  return 0;
}


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


int kai(vector<int> l, int n, int k){
    int res = 0;
    for(int i=0; i<n; i++){
        if(i < k){
            if(l.at(i)){
                res++;
            }
        }
        else{
            if(l.at(i)){
                if(l.at(i-k)){
                    l.at(i) = 0;
                }
                else{
                    res++;
                }
            }
        }
    }
    return res;

}

int main(){
    int n,k,r,s,p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;

    vector<int> lr(n),ls(n),lp(n);
    for(int i=0; i<n; i++){
        if(t.at(i) == 'r'){
            lr.at(i) = 1;
        }
        else if(t.at(i) == 's'){
            ls.at(i) = 1;
        }
        else{
            lp.at(i) = 1;
        }
    }

    cout << p*kai(lr,n,k) + r*kai(ls,n,k) + s*kai(lp,n,k) << endl;
    return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<bits/stdc++.h>
#define ll long long  
#define d double
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    int c1=0;
    int c2=0;
    int c3=0;
    int c4=0;
    while(n--){
      string s;
	  cin>>s;
	  if(s=="AC"){
	   	c1++;  	
	   }
      
	   else if(s=="WA"){
	   	  c2++;
	   }
	   
	   else if(s=="TLE"){
	  	c3++;
	  }
	  	
	  else if(s=="RE"){
	    c4++;	
	  }	  	
	}
	
	cout<<"AC x "<<c1<<endl;
	cout<<"WA x "<<c2<<endl;
	cout<<"TLE x "<<c3<<endl;
	cout<<"RE x "<<c4<<endl;
    
    return 0;
}
    

Measured memory_bytes: 3628
#![allow(unused)]

use std::{cell, cmp, collections, convert, fmt, io, iter, ops, str};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($($args: tt)*) => { eprint!($($args)*) };
}

#[cfg(feature = "debug")]
macro_rules! debugln {
    ($($args: tt)*) => { eprintln!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($($args:tt)*) => {};
}

#[cfg(not(feature = "debug"))]
macro_rules! debugln {
    ($($args:tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn main() {
    let n = parse_line::<usize>();
    let s = read_line();

    let ans = (1..n)
        .map(|i| {
            let (x, y) = s.split_at(i);

            let x_chars = x.chars().collect::<HashSet<_>>();
            let y_chars = y.chars().collect::<HashSet<_>>();

            x_chars.intersection(&y_chars).collect::<HashSet<_>>().len()
        })
        .max()
        .unwrap();

    println!("{}", ans);
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if !buf.is_empty() {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn next_prime(x: i32) -> i32 {
    for i in (x + 1).. {
        if is_prime(i) {
            return i;
        }
    }

    panic!("attempt to add with overflow");
}

fn is_prime(x: i32) -> bool {
    let ceil = f64::from(x).sqrt().ceil() as i32;
    x == 2 || (2..(ceil + 1)).all(|i| x % i != 0)
}

fn bit_high(bits: u64, pos: u64) -> bool {
    bits & (1 << pos) != 0
}


Measured memory_bytes: 4352
// 1_8_D
#include <iostream>
#include <string>
using namespace std;

int main(){
  string s, p;
  cin >> s >> p;

  if((s+s).find(p) != string::npos){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3224
import math as m
money=int(input())
if(m.ceil(money/1000.0)==m.floor(money/1000.0)):
  print("0")
elif(m.ceil(money/1000.0)<m.floor(money/1000.0)):
  print(money%1000)
else:
  print(1000-(money%1000))

Measured memory_bytes: 9172
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;


//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int p = 1; p < N; p++) cout << ", " << v[p]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	


int main() {
	char a, b;
	cin >> a >> b;
	if (a == 'H' && b == 'H') cout << 'H';
	else if (a == 'H' && b == 'D') cout << 'D';
	else if (a == 'D' && b == 'H') cout << 'D';
	else cout << 'H';
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i< (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(void){
    string S;
    cin >> S;
    
    if(S == "ARC"){
        cout << "ABC" << endl;
    }else if(S == "ABC"){
        cout << "ARC" << endl;
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; ++i)
    cin >> H[i];

  bool flag = true;
  int max_n = -1;
  for (int i = 1; i < N; ++i) {
    max_n = max(max_n, H[i]);
    if (max_n - H[i] >= 2)
      flag = false;
  }

  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 640
public class Main {
    public static void main(String[] args) {
        int value = Integer.parseInt(readLine(255));
        System.out.printf("%f",(2*Math.PI*value));
    }

    public static  String readLine(int maxLen){
        int[] holder = new int[maxLen];
        int counter =0, reader =1;

        try{
            while(counter < maxLen){
                reader = System.in.read();
                if(reader <0 || (reader =='\n'))break;
                holder[counter++] = reader;
            }
        }catch(Exception ex){
            return (null);
        }

        if(counter ==0 && reader <0)return (null);
        return new String(holder,0,counter);
    }
}


Measured memory_bytes: 25684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    while(y > 0) {
        ll tmp = x % y;
        x = y;
        y = tmp;
    }
    return x;
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

int main() {
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;

    ll l = lcm(n, m);
    ll g = gcd(n, m);
    for (ll i = 0; i <= g; i++) {
        if (s[i * n / g] != t[i * m / g]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline long long in(){long long x=0;char c=getchar();bool neg=false;while(c!='-'&&('0'>c||c>'9')) c=getchar();if(c=='-') neg=true,c=getchar();while('0'<=c&&c<='9') x=10*x+c-'0',c=getchar();if(neg) x=-x;return x;}
inline void out(long long x){if(x<0) putchar('-'),x=-x;if(x>9) out(x/10);putchar(x%10+'0');}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "l"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define _ putchar(' ')
#define __ putchar('\n')
const int N=3010;
int n,s;
int a[N];
int f[N][N];
int F(int l,int r)
{
    if(l>r) return 0;
    if(f[l][r]!=-1) return f[l][r];
    int ans;
    if((l+r)%2!=n%2) ans=max(F(l+1,r)+a[l],F(l,r-1)+a[r]);
    else ans=min(F(l+1,r)-a[l],F(l,r-1)-a[r]);
    return f[l][r]=ans;
}
main()
{
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    cin>>n;
    forinc(i,1,n) cin>>a[i],s+=a[i];
    reset(f,-1);
    cout<<F(1,n);
}


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

i = 2
cur_n = n
cnt = []
while i * i <= n:
    z = 0
    while cur_n % i == 0:
        z += 1
        cur_n //= i
    if z:
        cnt.append(z)
    i += 1

if cur_n != 1:
    cnt.append(1)

'''
ans_table = [0]
for i in range(40):
    ans_table[i // 2] + 1

[0, 1, 2
'''


def get_ans(power):
    i = 1
    res = 0
    while res + i <= power:
        res += i
        i += 1
    return i - 1


ans = 0
for v in cnt:
    ans += get_ans(v)


print(ans)


Measured memory_bytes: 63344
#include <bits/stdc++.h>
#include<cstdlib>
using namespace std;
int main() 
{
    int N;
    cin>>N;
    int h[N];
    int ans[N]; 
    
    
    for(int j=0;j<N;j++)
     cin>>h[j];

    ans[0]=0;
    ans[1]=abs(h[1]-h[0]);
    for(int i=2;i<N;i++)
      ans[i]=min(ans[i-1]+abs(h[i]-h[i-1]),ans[i-2]+abs(h[i]-h[i-2]));
     
   
      cout<<ans[N-1];

      return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	v := make([]int, n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&c[i])
	}
	var result int
	for i := 0; i < n; i++ {
		if v[i] > c[i] {
			result += v[i] - c[i]
		}
	}
	fmt.Println(result)
}

Measured memory_bytes: 512
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
ll in(){ll x; cin >> x; return x;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n, k;
	cin >> n >> k;
	Vec v(n);
	rep(i, n) cin >> v[i];

	ll ans = 0;
	deque<ll> a(n);
	rep(l, min(n, k)+1){
		rep(r, min(n, k)-l+1){
			a.clear();
			rep(i, l) a.pb(v[i]);
			rep(i, r) a.pb(v[n-1-i]);
			sort(all(a));
			rep(i, min(k-l-r, l+r)) if(a[0] < 0) a.pop_front();
			ll sum = 0;
			for(ll i : a) sum += i;
			chmax(ans, sum);
		}
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int n,i,a[100],minj,j,r,cnt=0,flag;
  
  scanf("%d",&n);
  for(i=0; i<n; i++)scanf("%d",&a[i]);

  for(i=0; i<n-1; i++){
    flag=0;
    minj=i;
    for(j=i; j<=n-1; j++){
      if(a[j]<a[minj]){
	minj=j;
	flag=1;
      }
    }
    if(flag){
    r=a[i];
    a[i]=a[minj];
    a[minj]=r;
    cnt++;
    }
  }

  for(i=0; i<n; i++){
    if(i)printf(" ");
    printf("%d",a[i]);
  }
  printf("\n%d\n",cnt);

  return 0;
}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",(long long)x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)1e6+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll fmod(ll x){if (x<mod) return x;return x%mod;}
ll mul(ll a, ll b, ll c){
	ll ret=0;while(b){if (b%2) ret=(ret+a)%c;a=(a*2)%c;b>>=1;}
    return ret;
}
int modpow(ll a, ll b){
    ll ret=1;while(b){if (b%2) ret=(ret*a)%mod;a=(a*a)%mod;b>>=1;}
    return (int)ret;
}
inline int inv(int x){ return modpow(x, mod-2);}
int isprime[N];
void calc_prime(){
	isprime[1]=1;for(ll i=2;i<N;i++) if (!isprime[i]) for(ll j=i*i;j<N;j+=i) isprime[j]=1;
}
#define ld long double
int main(){
    int n;cin>>n;
    ld d;
    cin>>d;
    int ans = 0;
    fr(i, 1 ,n){
        ld x, y;cin>>x>>y;
        ld val = x*x + y* y;
        if (val <= d*d) ans++;
    }
    pr(ans);n_l;
    return 0;
}



Measured memory_bytes: 3788
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            List<long> Ai, Bi, Ci;
            Ai = Slist();
            Bi = Slist();
            Ci = Slist();
            Ai.Sort();
            Bi.Sort();
            Ci.Sort();
            var dp = Enumerable.Range(0, 2).Select(_ => new long[N]).ToArray();
            for (var i = 0; i < N; ++i)
                dp[0][i] = ~Ai.BinarySearch(Bi[i] - 1, new ub<long>());//Biより小さいAiの個数
            for (var i = 0; i < N; ++i)
                dp[1][i] = ~Bi.BinarySearch(Ci[i] - 1, new ub<long>());//Ciより小さいBiの個数
            var rui = new long[N + 1];
            for (var i = 1; i <= N; ++i)
                rui[i] += rui[i - 1] + dp[0][i - 1];
            var ans = 0L;
            for (var i = 0; i < N; ++i)
                ans += rui[dp[1][i]];
            WriteLine(ans);
            //Out.Flush();
        }
        public class ub<T> : IComparer<T> where T : IComparable<T>
        {
            public int Compare(T x, T y) => 0 < x.CompareTo(y) ? 1 : -1;
        }
    }
}

Measured memory_bytes: 39064
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(1, n - 1):
  if p[i] > p[i + 1] and p[i] < p[i - 1] or p[i] < p[i + 1] and p[i] > p[i - 1]:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
    double a, b;
    scanf("%lf %lf", &a, &b);
    int l, m;
    double n;
    l = a / b;
    m = a - l * b;
    n = a / b;
    printf("%d %d %f\n", l, m, n);
    return 0;
}

Measured memory_bytes: 1076
s = input()
sp = s.split('/')

year = 2019 - int(sp[0])
month =int(sp[1]) -4
day = 30 - int(sp[2])

if year == 0 and month == 0 and day == 0:
  print("Heisei")
else:
  if year >= 0:
    if month > 0:
      print("TBD")
    else:
      print("Heisei")
  else:
    print("Heisei")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
struct point
{
    int x,y;
    int vis;
};
point a[105],b[105];
bool check(int p,int k)
{
    if((b[p].x>a[k].x)&&(b[p].y>a[k].y))
        return 1;
    return 0;
}
int js(int m,int l)
{
    if((a[m].x<a[l].x)&&(a[m].y<a[l].y))
        return 1;
    else
        return 0;
}
bool cmp(point p,point b)
{
    if(p.x!=b.x)
        return p.x<b.x;
    else return p.y<b.y;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%d%d",&a[i].x,&a[i].y);
        a[i].vis=0;
    }
    for(int i=0; i<n; i++)
    {
        scanf("%d%d",&b[i].x,&b[i].y);
        b[i].vis=0;

    }
    sort(a,a+n,cmp);
    sort(b,b+n,cmp);
    int ans=0,minn=201,num,tmp,flag=0;
    for(int i=0; i<n; i++)
    {
        flag=0,num=-1;
        for(int j=0; j<n; j++)
        {
            if(a[j].vis==0&&a[j].x<b[i].x&&a[j].y<b[i].y)
            {
                if(flag==0)
                {
                    flag=1;
                    num=j;
                    //puts("222");
                }
                else if(a[j].y>a[num].y)
                {
                    num=j;
                }
            }
        }
        if(flag)
        {
            b[i].vis=1;
            a[num].vis=1;
            ans++;
        }

    }
    /*for(int i=2*n-1; i>=0; i--)
    {
        if(a[i].vis==0)
        {
            for(int j=i+1; j<2*n; j++)
            {
                if(a[j].vis==1&&js(i,j))
                {
                   tmp=a[j].x+a[j].y-a[i].x-a[i].y;
                   if(tmp<minn)
                   {
                       minn=tmp;
                       num=j;
                   }
                   flag=1;
                }
            }
            if(flag)
            {
                flag=0;
                a[i].vis=2;
                a[num].vis=2;
                minn=201;
                ans++;
            }

        }

    }*/
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

ll n;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n;
  ll r = 0, o = 0, a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    r += min(o, a);
    a -= min(o, a);
    r += a / 2;
    a %= 2;
    o = a;
  }
  cout << r << "\n";
}


Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  string s;cin>>s;
  for(int i = 1; 4 > i; i++){
    if(s[i-1] == s[i]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	cin>>n;
	for(int i=1;i<=9;i++){
		for(int j=i;j<=9;j++){
			int s=i*j;
			if(n==s){
				cout<<"Yes";
				return 0;
			}	
			else continue;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3608
import itertools

A = list(map(int, open(0).read().split()))
items = list(itertools.permutations(A))

ans = float('inf')

for item in items:
    t = 0
    for i in item[:-1]:
        t += (i if i%10==0 else (i//10+1)*10)
    t += item[-1]

    if t < ans:
        ans = t

print(ans)

Measured memory_bytes: 3188
import math

s = int(input())
tmp = s % 10
sn = tmp
tmp1 = math.floor(s /10)
while tmp1 >0:
    tmp = tmp1 % 10
    sn += tmp
    tmp1 = math.floor(tmp1/10)
if s % sn == 0:
    print("Yes")
else:
    print("No")


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

int main()
{
    int a,b,d;
    cin>>a>>b;
    if((a>0 && a<10) && (b>0 && b<10))
    {
        d=a*b;
    }
    else
    {
        d=-1;
    }
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 3524