akhauriyash/Code-Regression huggingface dataset:
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val Array(n, x) = readLine.trim.split(' ').map(_.toLong)
  println(
    patty(n.toInt, x)
  )
  def patty(level: Int, so: Long): Long = {
    level match {
      case 0 ⇒ if (so >= 1) 1L else 0L
      case _ if so <= 0 ⇒ 0L
      case _ ⇒
        numOfLevel(level - 1) match {
          case l if l + 2 <= so ⇒ pattyOfLevel(level - 1) + 1 + patty(level - 1, so - l - 2)
          case _ ⇒ patty(level - 1, so - 1)
        }

    }
  }
  def pattyOfLevel(level: Int): Long = {
    level match {
      case 0 ⇒ 1L
      case _ ⇒ pattyOfLevel(level - 1) * 2 + 1
    }
  }
  def numOfLevel(level: Int): Long = {
    level match {
      case 0 ⇒ 1L
      case _ ⇒ numOfLevel(level - 1) * 2 + 3
    }
  }


  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 27332
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1e9
// Parent pointer's concept with 2d suffix dp
//dp[i][j] - till i-1th char and j-1th char - max lcs found
//p[i][j] - parent of dp[i][j] - so basically from which cell of dp I came to i,j
//going from i,j to i+1,j nd stuff not oworking out for me--> back to basics
string solnF(string& a,string& b){
	int n1 = a.length(),n2 = b.length();
	// cout<<endl<<a<<endl<<b<<endl;
	vector<vector<int> > dp(n1+1,vector<int>(n2+1,0));
	vector<vector< pair<int,int> > > p(n1+1,vector< pair<int,int> >(n2+1));
	// dp[0][0]
	for(int i=1;i<=n1;i++){
		for(int j=1;j<=n2;j++){
			if(a[i-1]==b[j-1]){
				dp[i][j] = dp[i-1][j-1]+1;
				p[i][j] = make_pair(i-1,j-1);
			}	
			else if(dp[i][j-1]>dp[i-1][j]){
				dp[i][j] = dp[i][j-1];
				p[i][j] = make_pair(i,j-1);
			}
			else{
				dp[i][j] = dp[i-1][j];
				p[i][j] = make_pair(i-1,j);
			}
			// cout<<i<<" "<<j<<" "<<dp[i][j]<<" - "<<p[i][j].first<<" "<<p[i][j].second<<endl;
		}
	}
	//dp[n1][n2] is length of lcs
	string str;
	pair<int,int> cur = make_pair(n1,n2);
	pair<int,int> prev = p[n1][n2];
	// int count = 50;
	while(cur.first&&cur.second){
		// cout<<"KK";
		// cout<<cur.first<<" "<<cur.second<<endl;
		// cout<<prev.first<<" "<<prev.second<<endl;
		if(cur == make_pair(prev.first+1,prev.second+1)){
			str.push_back(a[prev.first]);
		}
		cur = prev;
		prev = p[prev.first][prev.second];
		// count--;
	}
	reverse(str.begin(),str.end());
	return str;
}


int main(){
	string a,b;
	getline(cin,a,'\n');
	// cout<<"kk";
	getline(cin,b,'\n');
	// string s; 
	// while (getline(cin, s)) 
	// { 
	// 	if (s.empty()) 
	// 		break; 
	// 	cout << s << endl; 
	// } 
	// return 0; 
	// cin>>b;
	// for(int i=0;i<n;i++) cin>>w[i]>>v[i];
	cout<<solnF(a,b)<<endl;
}


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

int main(){
  int n, u, v;
  cin >> n >> u >> v;
  vector<vector<int>> T(n);
  for (int i=0; i<n-1; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    T[a].push_back(b);
    T[b].push_back(a);
  }

  stack<pair<int, int>> next_t;
  vector<int> been_t(n, -1);
  next_t.push(make_pair(u-1, 0));
  while (!next_t.empty()){
    int x, c;
    tie(x, c) = next_t.top(); next_t.pop();
    been_t[x] = c;
    for (auto g: T[x]){
      if (been_t[g] == -1){
        next_t.push(make_pair(g, c+1));
      }
    }
  }

  stack<pair<int, int>> next_a;
  vector<int> been_a(n, -1);
  next_a.push(make_pair(v-1, 0));
  while (!next_a.empty()){
    int x, c;
    tie(x, c) = next_a.top(); next_a.pop();
    been_a[x] = c;
    for (auto g: T[x]){
      if (been_a[g] == -1){
        next_a.push(make_pair(g, c+1));
      }
    }
  }
  int ans = 0;
  for (int i=0; i< n; i++){
    // cout << been_t[i] << " " << been_a[i] << endl;
    if (been_t[i] < been_a[i]){
      ans = max(ans, been_a[i] - 1);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
//int NUMOFDIV(int n) 素因数分解して+1してかける奴
int NUMOFDIV2(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	return (n + 9) / 10 * 10;
}
int DIGITSUM(int n) {
	int sum = 0,dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	int n,a,b,ans=0;
	cin >> n>> a >> b;
	REP(i, n) {
		if (BETWEEN(DIGITSUM(i), a, b))
			ans += i;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string w; cin>>w;
  int n[100]={0};
  for(char c:w) n[c-'a']=n[c-'a']^1;
  for(int i:n) if(i){cout<<"No";return 0;}
  cout<<"Yes";
}

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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n), tot(n), moto(n);
	rep(i, n) cin >> a[i];
	tot[0] = a[0];
	rep(i, n-1) tot[i+1] += tot[i] + a[i+1];
	
	ll ans = 1LL<<60, now = 0;
	ll wa = 0;
	int p;
	moto = tot;
	if(tot[0] != 0) {
		p = tot[0] / abs(tot[0]);
		rep(i, n) {
			tot[i] += wa;
			if(p == 1) {
				if(tot[i] <= 0) {
					wa += abs(tot[i]) + 1;
					now += abs(tot[i]) + 1;
				}
			} else {
				if(tot[i] >= 0) {
					wa -= abs(tot[i]) + 1;
					now += abs(tot[i]) + 1;
				}
			}
			// cout << tot[i] << " " << wa << endl;
			p *= -1;
		}
		ans = min(ans, now);
		tot = moto;
		p = tot[0] / abs(tot[0]) * -1;
		now = abs(tot[0])+ 1;
		wa = p * (abs(tot[0])+ 1);
		rep(i, n) {
			tot[i] += wa;
			if(p == 1) {
				if(tot[i] <= 0) {
					wa += abs(tot[i]) + 1;
					now += abs(tot[i]) + 1;
				}
			} else {
				if(tot[i] >= 0) {
					wa -= abs(tot[i]) + 1;
					now += abs(tot[i]) + 1;
				}
			}
			// cout << tot[i] << " " << wa << endl;
			p *= -1;
		}
		ans = min(ans, now);
	} else {
		tot = moto;
		now = 1;
		wa = 1;
		p = 1;
		rep(i, n) {
			tot[i] += wa;
			if(p == 1) {
				if(tot[i] <= 0) {
					wa += abs(tot[i]) + 1;
					now += abs(tot[i]) + 1;
				}
			} else {
				if(tot[i] >= 0) {
					wa -= abs(tot[i]) + 1;
					now += abs(tot[i]) + 1;
				}
			}
			// cout << tot[i] << " " << wa << endl;
			p *= -1;
		}
		ans = min(ans, now);
		tot = moto;
		now = 1;
		wa = -1;
		p = -1;
		rep(i, n) {
			tot[i] += wa;
			if(p == 1) {
				if(tot[i] <= 0) {
					wa += abs(tot[i]) + 1;
					now += abs(tot[i]) + 1;
				}
			} else {
				if(tot[i] >= 0) {
					wa -= abs(tot[i]) + 1;
					now += abs(tot[i]) + 1;
				}
			}
			// cout << tot[i] << " " << wa << endl;
			p *= -1;
		}
		ans = min(ans, now);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if max(b-a,c-a, d-a,e-a, c-b,d-b,e-b,d-c,e-c,e-d)>k:
    print(":(")
else:
    print("Yay!")

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

bool p[1010101];

int main()
{
  memset(p, true, sizeof(p));

  p[0] = p[1] = false;

  for (int i = 0; i < 1001; i++){
    if (!p[i]) continue;
    for (int j = 2 * i; j < 1000000; j += i){
      p[j] = false;
    }
  }

  int n;
  while (cin >> n, n){
    int cnt = 0;
    for (int i = 3; i <= n; i += 2){
      if (p[i] && p[n - i]) cnt++;
    }
    cout << (cnt + 1) / 2 << endl;
  }
}

Measured memory_bytes: 4084
import java.util.Scanner;

public class Main {

	static long Calc(long n) {
		int keta = Long.toString(n).length();
		int[] text = new int[keta + 1];
		for(int i = 0; i < keta; i++) {
			text[i] = (int) (n % 10);
			n /= 10;
		}
		text = Add(keta, text, 0);
		long ans = 0;
		for(int i = keta; i > -1; i--) {
			ans += text[i];
			ans *= 10;
		}
		ans /= 10;
		return ans;
	}

	static int[] Add(int keta, int[] text, int pos) {
		if(pos == keta) {
			text[pos] = 1;
			return text;
		}
		if(text[pos] < 9) {
			if(keta - 1 != pos && text[pos] <= text[pos + 1]) {
				text[pos]++;
			} else if(keta - 1 == pos) {
				text[pos]++;
			} else {
				text = Add(keta, text, pos + 1);
				if(text[pos + 1] > 0)
					text[pos] = text[pos + 1] - 1;
				else
					text[pos] = 0;
			}
		} else {
			text = Add(keta, text, pos + 1);
			if(text[pos + 1] > 0)
				text[pos] = text[pos + 1] - 1;
			else
				text[pos] = 0;
		}

		return text;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		long ans = 0;
		for(int i = 0; i < k; i++) {
			ans = Calc(ans);
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 33764
n, y = map(int, input().split())

existed = False
for man_ichi in range(n+1):
	for sen_go in range(n+1-man_ichi):
		if y == (man_ichi*10000 + sen_go*5000 + (n-man_ichi-sen_go)*1000):
			print(man_ichi, sen_go, n-man_ichi-sen_go)
			break
	else:
		continue
	break
else:
	print(-1, -1, -1)



Measured memory_bytes: 3060
n, m, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

max_c = 0
c = 0
i = 0
j = 0

while i < n and k - a[i] >=0:
    k -= a[i]
    i += 1
    c += 1

while j < m and k - b[j] >=0:
    k -= b[j]
    j += 1
    c += 1


max_c = c
# print(max_c, k, i, j)

i -= 1

while i >= 0:
    k += a[i]
    c -= 1
    while j < m and k - b[j] >= 0:
        k -= b[j]
        c += 1
        j += 1
    max_c = max(c, max_c)
    i -= 1
print(max_c)

Measured memory_bytes: 111672
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	ll n, k;
	cin >> n >> k;
	REP(i, k)
	{
		int x, y; cin >> x >> y;
		x--; y--;
		if (x >= n / 2)	x = n - x - 1;
		if (y >= n / 2)	y = n - y - 1;

		if (x < y)
		{
			cout << x % 3 + 1 << endl;;
		}
		else
		{
			cout << y % 3 + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <stack>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
int inc(int num)
{
    int tmp=num%10,flag=1;
    num/=10;
    while(num)
    {
        if ((num%10+1)!=tmp)
        {
            flag=0;
            break;
        }
        else
        {
            tmp=num%10;
            num/=10;
        }
    }
    return flag;
}
int main()
{
   // freopen("in.txt","r",stdin);
    int n,tmp,a[1200];
    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int maxn=-1;
    for (int i=n-1;i>=0;i--)
    {
        for (int j=i-1;j>=0;j--)
        {
            tmp=a[i]*a[j];
            if (tmp>maxn)
            {
                if (inc(a[i]*a[j])==1)
                maxn=tmp;
            }
            else break;
        }
    }
    cout<<maxn<<endl;
    return 0;
}

Measured memory_bytes: 3160
from bisect import bisect

A,B,Q = map(int,input().split())

INF = 10**11
S = [-INF] + sorted([int(input()) for i in range(A)]) + [INF]
T = [-INF] + sorted([int(input()) for i in range(B)]) + [INF]
X = [int(input()) for i in range(Q)]

for x in X :
    right_s = bisect(S,x)
    right_t = bisect(T,x)
    left_s = right_s - 1
    left_t = right_t - 1
    
    calc1 = x - min(S[left_s], T[left_t])
    calc2 = -x + max(S[right_s], T[right_t])
    calc3 = (x-S[left_s]) + (T[right_t] - S[left_s])
    calc4 = (x-T[left_t]) + (S[right_s] - T[left_t])
    calc5 = (-x+S[right_s]) + (S[right_s] - T[left_t])
    calc6 = (-x+T[right_t]) + (T[right_t] - S[left_s])
    
    print(min(calc1,calc2,calc3,calc4,calc5,calc6))
 

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

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int& x : l)
    {
        cin >> x;
    }

    sort(l.begin(), l.end(), greater<int>());
    int ans = 0;
    for (int i = 1; i < n; ++i)
    {
        ans += l.at(i);
    }

    cout << (l.at(0) < ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
/*       Rohan Balot
    NSIT, New Delhi, India  */
#include <bits/stdc++.h>
using namespace std;

#define FIND(c, e) (c).find(e) != (c).end()
#define NFIND(c, e) (c).find(e) == (c).end()
#define ALL(t) (t).begin(), (t).end()
#define ALLR(t) (t).rbegin(), (t).rend()
#define MP make_pair

const int N = int( 1e5 ) + 2;
const int Q = int( 1e5 ) + 2;
const int M = int( 1e6 ) + 2;
const int MOD = int( 1e9 ) + 7;
const double PI = acos(-1.0);
const double eps = 1.0e-6;



struct node {
	vector< pair< int, int > > v; // divisor[a[i]]
	int size;
	int sum;
} tree[N << 2];


// prime stuff
const int PRIME_TILL = M;
vector<bool> isprime(PRIME_TILL , true);
vector<int> prime;
vector<int> pf(PRIME_TILL);
vector< pair<int, int > > divisor[M];
// array stuff
int a[N];
vector<int> f(PRIME_TILL, 0);
int n;
vector<int> freq(M, 0);


int expo(int num, int p)
{
	int e = 0;
	while (num % p == 0) {
		e++;
		num /= p;
	}
	return e;
}
void sieve(int n = PRIME_TILL)
{
	isprime[0] = isprime[1] = false;
    for (int p = 2; p < n; p++) {
        if (isprime[p]) {
            for (int i = p; i < n; i += p) {
                isprime[i] = false;
				if(p <= i) {
					int e = expo(i, p);
					if(e > 0)
						divisor[i].push_back(MP(p, e));
				}
			}
        }
    }
}
int binary(vector< pair<int, int > > v, int num)
{
	int low = 0;
	int high = v.size() - 1;
	while (low <= high) {
		int mid = low + (high - low) / 2;
		if(v[mid].first == num) {
			return v[mid].second;
		} else if(v[mid].first > num) {
			high = mid - 1;
		} else {
			low = mid + 1;
		}
	}
	return -1;
}
// TODO : possible optimization , use vector<int> prime
void factors()
{
	for(int i = 2; i < PRIME_TILL; i++) {
		if(isprime[i]) {
			for(int j = i; j < PRIME_TILL; j += i) {
				int e = expo(j, i);
				divisor[j].push_back(MP(i, e));
				f[i] += e * freq[j];
			}
		}
	}
	for(int i = 1; i < PRIME_TILL; i++) {
		f[i] += f[i - 1];
	}
}

long long func(int l, int r, int x, int y)
{
    long long ans = 0LL;
	for(int i = x; i <= y; i++) {
			ans += (f[r] - f[l - 1]);
			//for(int j = l; j <= r; j++) {
			//	int n = a[j], e = 0;
			//	while(n % prime[i] == 0) {
			//		e++;
			//		n /= prime[i];
			//	}
			//	ans += e;
			//}
    }
    return ans;
}
void __answer()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(ALL(v));
    int ans = 0;
    for(int i = 0; i + 1 < n; i++)
        ans += v[i + 1] - v[i];
    cout << ans;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifdef LOCAL
        freopen("sample_input.txt", "r", stdin);
    	// freopen("data.txt", "w", stdout);
    	// freopen("log.txt", "w", stderr);
    #endif
    __answer();
    return 0;
}


Measured memory_bytes: 48000
class Node:

    def __init__(self, key: int) -> None:
        self.key = key
        self.parent = None
        self.left = None
        self.right = None


def input_line() -> (str, int):
    line = input().split()
    if line[0] == 'insert':
        return line[0], int(line[1])
    elif line[0] == 'find':
        return line[0], int(line[1])
    else:
        return line[0], None


def preorder(tree: Node) -> None:
    """先行順巡回。"""
    print(f' {tree.key}', end='')
    if tree.left is not None:
        preorder(tree.left)
    if tree.right is not None:
        preorder(tree.right)


def inorder(tree: Node) -> None:
    """中間順巡回。"""
    if tree.left is not None:
        inorder(tree.left)
    print(f' {tree.key}', end='')
    if tree.right is not None:
        inorder(tree.right)


def insert(new_node: Node) -> None:
    """二分探索木に挿入する。"""

    # rootはglobalに共有する。
    global root

    # new_nodeを付け加える節(parent)の初期値をNoneに設定する。
    parent = None

    # tmpにrootを設定する。
    tmp = root

    # new_nodeを付け加える節(parent)を探索する。
    while tmp is not None:
        parent = tmp
        if new_node.key < tmp.key:
            tmp = tmp.left
        else:
            tmp = tmp.right

    # new_nodeの親を設定する。
    new_node.parent = parent

    # new_nodeの子供を設定する。
    if parent is None:
        # treeが空だった場合は、rootにnew_nodeを設定する。
        root = new_node
    elif new_node.key < parent.key:
        parent.left = new_node
    else:
        parent.right = new_node


def find(key)-> bool:

    global root

    # tmpにrootを設定する。
    tmp = root

    # new_nodeを付け加える節(parent)を探索する。
    while tmp is not None:
        if key == tmp.key:
            return True
        elif key < tmp.key:
            tmp = tmp.left
        else:
            tmp = tmp.right

    return False


root = None  # treeの根を表す。初期値はNone。
N = int(input())
for _i in range(N):
    order, val = input_line()
    if order == 'insert':
        node = Node(val)
        insert(node)
    elif order == 'print':
        inorder(root)
        print()
        preorder(root)
        print()
    elif order == 'find':
        if find(val):
            print('yes')
        else:
            print('no')





Measured memory_bytes: 85272
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let s=read::<String>().chars().collect::<Vec<char>>();
    println!("{}{}{}",s[0],s.len()-2,s[s.len()-1])
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main() {
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if(x+r <= w && x-r >= 0 && y+r <= h && y-r >= 0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3120
def sol(inp=input):
    n=int(inp())
    pts=[tuple(map(int,inp().split())) for _ in range(n)]
    min_cost=n
    pt1=pts[0]
    for pt2 in pts[1:]:
        p,q=(pt1[0]-pt2[0],pt1[1]-pt2[1])
        cost=0
        for i,pt in enumerate(pts):
            if (pt[0]+p,pt[1]+q) not in pts:
                cost+=1
        min_cost=min(cost,min_cost)
    return '{}'.format(min_cost)
print(sol())

Measured memory_bytes: 40556
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>

struct max_min
{
    int64_t max = 0;
    int64_t min = 0;
};

const int64_t cc = pow( 10, 9 ) + 7;
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< int64_t, int64_t > origin, std::pair< int64_t, int64_t > another )
{
    return origin.first < another.first;
}

int main()
{
    std::string word;
    std::string w = "Yes";
    int64_t a,b,c,d,e,f;
    std::cin>> a;
    std::cin>> b;

    std::vector< int64_t > list( b );

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

    std::sort( list.begin(), list.end() );

    int64_t dist = 0;

    for( int i = 0; i < b - 1; i++ )
    {
        dist = std::max( dist, list[i+1] - list[i] );
    }

    dist = std::max( dist, list.front() + a - list.back() );
    c = a - dist;

    std::cout<< c;
}


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

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m; cin >> n >> m;
    vector<bool>vis(n,false);
    bool ans = false;
    for(int i=0;i<m; i++){
        int a, b; cin >> a >> b;
        if(a == 1){
            if(vis[b]) ans = true;
            vis[b] = true;
        }
        else if(b == n){
            if(vis[a]) ans = true;
            vis[a] = true;
        }
    }
    if(ans) cout << "POSSIBLE"<< endl;
    else cout << "IMPOSSIBLE"<< endl;


    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  pair<pair<string, int>,int> r[101];
  rep(i, n) { 
    int t;
    string s;
    cin >> s >> t;
    r[i] = make_pair(make_pair(s, -t), i + 1);
  }
  sort(r, r + n);
  rep(i,n) cout << r[i].se << endl;
  return 0;
}

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

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

	if(A[K-1]!=2){
		cout << -1 << endl;
		return 0;
	}
	
	long long min=2;
	long long max=3;
	
	for(int i=K-2; i>=0; i--){
		if((max%A[i])==0){
			max=max+A[i]-1;
		}else if(max<A[i]){
			cout<<-1<<endl; return 0;
		}else if(max >A[i]){
			max=max-(max%A[i])+A[i]-1;
		}
		
		if((min%A[i])==0){
			min=min;
		}else if(min<A[i]){
			min=A[i];	
		}else if(min>A[i]){
			min=min-(min%A[i])+A[i];
		}
		
		if(min>max){cout << -1 << endl; return 0;}
		
	}
	
	cout << min << " " << max <<endl;
	return 0;
}

Measured memory_bytes: 640
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n;
	cin >>n;
	vector<long long> ans(3, 0);
	for(long long i = 0; i < n; i++) {
		vector<long long> curr(3);
		vector<long long> dp(3, 0);
		for(long long i = 0; i < 3; i++)
			cin >>curr[i];
		for(long long i = 0; i < 3; i++) {
			for(long long j = 0; j < 3; j++) {
				if(i != j) {
					dp[j] = max(dp[j], ans[i] + curr[j]);
				}
			}
		}
		ans = dp;
	}
	cout <<max({ans[0], ans[1], ans[2]});
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (stoi(s.substr(5, 2)) <= 4) {
        cout << "Heisei" << endl;
    } else
        cout << "TBD" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int maxn=200005;
struct AS{
    int x,v;
}a[maxn];
inline bool cmp1(AS x,AS y){
    return x.x<y.x;
}
inline bool cmp2(AS x,AS y){
    return x.v>y.v;
}
struct AP{
    int L,R;
    bool operator<(const AP B)const{
        return R<B.R||(R==B.R&&L<B.L);
    }
}b[maxn];
int n,c[maxn],cc[maxn];
inline int read(){
    int res=0,f_f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f_f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') res=(res<<3)+(res<<1)-'0'+ch,ch=getchar();
    return res*f_f;
}
inline void checkmin(int &x,int y){
    if(x==-1||x>y) x=y;
}
inline void add_c1(int x,int v){
    for (int i=x;i<=n;i+=i&-i) checkmin(c[i],v);
}
inline int get_c1(int x){
    int res=-1;
    for (int i=x;i;i-=i&-i){
        if(c[i]==-1) continue;
        checkmin(res,c[i]);
    }
    return res;
}
inline void add_c2(int x,int v){
    for (int i=x;i<=n+1;i+=i&-i) cc[i]=(cc[i]+v)%mod;
}
inline int get_c2(int x){
    int res=0;
    for (int i=x;i;i-=i&-i){
        res=(res+cc[i])%mod;
    }
    return res;
}
int main(){
    n=read();
    for (int i=1;i<=n;i++){
        a[i].x=read(),a[i].v=read();
    }
    sort(a+1,a+n+1,cmp1);
    for (int i=1;i<=n;i++){
        a[i].x=i;
    }
    sort(a+1,a+n+1,cmp2);
    memset(c,-1,sizeof(c));
    for (int i=1;i<=n;i++){
        add_c1(a[i].x,i);
        b[i].L=get_c1(a[i].x);
    }
    memset(c,-1,sizeof(c));
    for (int i=n;i;i--){
        add_c1(n-a[i].x+1,n-i+1);
        b[i].R=n-get_c1(n-a[i].x+1)+1;
    }
    sort(b+1,b+n+1);
    add_c2(1,1);
    for (int i=1;i<=n;i++){
        int x=(get_c2(b[i].R+1)-get_c2(b[i].L-1)+mod)%mod;
        add_c2(b[i].R+1,x);
    }
    printf("%d\n",(get_c2(n+1)-get_c2(n)+mod)%mod);
    return 0;
}

Measured memory_bytes: 8420
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}

int main(void) {
  int a,b,c;cin>>a>>b>>c;
  pr(max(c-(a-b),0));
  return 0;
}


Measured memory_bytes: 256
// Problem : 
// 			D - Moving Piece
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_d
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	ll n,k;
	cin >> n >> k;
	vector<ll> per(n);
	for(int i=0;i<n;++i)
	{
		cin >> per[i];
		per[i]--;
	}
	vector<ll> v(n);
	for(int i=0;i<n;++i)
	cin >> v[i];
	ll lgn=40;
	vector<vector<ll>> bin(n,vector<ll>(lgn)),ans(n,vector<ll>(lgn));
	for(int i=0;i<lgn;++i)
	{
		for(int j=0;j<n;++j)
		{
			if(i==0)
			{
				bin[j][i]=per[j];
				ans[j][i]=v[per[j]];
			}
			else
			{
				bin[j][i]=bin[bin[j][i-1]][i-1];
				ans[j][i]=ans[j][i-1]+ans[bin[j][i-1]][i-1];
			}
		}
	}
	vector<ll> p;
	ll temp=1;
	while(temp<=(ll)1e9)
	{
		p.push_back(temp);
		temp*=2;
	}
	ll fans=-(ll)1e10;
	for(ll i=0;i<n;++i)
	{
		ll tempans=0;
		ll a=i;
		for(ll take=1;take<=k && take<=2*n;++take)
		{
			a=per[a];
			tempans+=v[a];
			fans=max(fans,tempans);
		}
		tempans=0;
		if(k-2*n<=0)
		continue;
		ll tk=k-2*n;
		a=i;
		for(int j=(int)p.size()-1;j>=0;--j)
		{
			if(tk>=p[j])
			{
 				tempans+=ans[a][j];
				tk-=p[j];
				a=bin[a][j];
			}
		}
		fans=max(fans,tempans);
		for(ll take=0;take<2*n;++take)
		{
			a=per[a];
			tempans+=v[a];
			fans=max(fans,tempans);
			//cout << tempans << " " << k+take+1 << " " << i << endl;
		}
		//cout << i << endl;
	}	
	cout << fans << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


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

int main(void)
{
    int N, K;
    cin >> N >> K;

    int dp[N+1][K+1] = {};

    vector<int> a(N+1,0);

    for (int i = 1; i <= N; ++i)
    {
        int tmp;
        cin >> tmp;
        a.at(i) = tmp;
    }

    for (int i = 0; i <= N; ++i)
    {
        dp[i][0] = 1;
    }

    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= K; ++j)
        {
            dp[i][j] = (dp[i][j] + dp[i-1][j] + dp[i][j-1]) % 1000000007;
            if(j-a.at(i)-1 >= 0) 
            {
                int tt = dp[i-1][j-a.at(i)-1];
                dp[i][j] = (dp[i][j] + 1000000007 - tt) % 1000000007;
            }
            // for(int l = 0; l <= a.at(i); ++l)
            // {
            //     if(j-l >= 0) dp[i][j] = (dp[i][j] + dp[i-1][j-l]) % 1000000007;
            // }
        }
    }

    cout << dp[N][K] << endl;

    return 0;
}



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

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

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    vector<int> c(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) --p[i];
    for(int i = 0; i < n; i++) cin >> c[i];

    ll ans=-1e18;
    for(int si = 0; si < n; si++) {
        int x=si;
        vector<int> s;
        ll tot=0;
        while(true) {
            x=p[x];
            s.emplace_back(c[x]);
            tot+=c[x];
            if(x==si) break;
        }
        int l=s.size();
        ll t=0;
        for(int i = 0; i < l; i++) {
            t+=s[i];
            if(i+1 > k) break;
            ll now=t;
            if(tot>0){
                ll e=(k-i-1)/l;
                now+=tot*e;
            }
            ans=max(ans,now);
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3712
import itertools

N = int(input())
L = list(map(int, input().split()))
cnt = 0

for i in itertools.combinations(L, 3):
    if i[0] != i[1] and i[0] != i[2] and i[2] != i[1]:
        if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[2] + i[0] > i[1]:
            cnt += 1


print(cnt)

Measured memory_bytes: 9104
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    cout << (N * (N + 1)) / 2 << endl;
}

Measured memory_bytes: 3544
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    int n; cin >> n;
    if(n%1000==0){
        cout << 0 << ln;
    }else {
        cout << 1000 - n%1000 << ln;        
    }
    return 0;    
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#include<complex>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef complex<double> P;
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
P pin(){
	double x,y;
	cin>>x>>y;
	P p(x,y);
	return p;
}
void PIN(P* a,int n){
	rep(i,n)a[i]=pin();
}
double dot(P a,P b){
	return real(conj(a)*b);
}
double cross(P a,P b){
	return imag(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
} 
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
P intersect_ls(L a,L b){
	double t1=abs(cross(a[1]-a[0],b[0]-a[0]));
	double t2=abs(cross(a[1]-a[0],b[1]-a[0]));
	return b[0]+(b[1]-b[0])*t1/(t1+t2);
}
int main(){
	int n;
	cin>>n;
	while(n--){
		P p[4];
		PIN(p,4);
		L a=L(p[0],p[1]);
		L b=L(p[2],p[3]);	
		P ans=intersect_ls(a,b);
		printf("%.9f %.9f\n",ans.real(),ans.imag());
	}
}

Measured memory_bytes: 1256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function bsearch(a,x)
	l,r = 0, length(a)+1
	while r-l>1
		m = (r+l)>>1
		if a[m]<x
			l = m
		else
			r = m
		end
	end
	r
end
are(a::Array{Int,1},x::Int)=Int[i%x for i in a]

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	b = readline() |> split |> parseMap
	r = 29
	ans = 0
	for i in 1:r
		t = 2^(i-1)
		c = are(b,2t)
		c = sort(c)
		s = 0
		for j in 1:n
			x = a[j]%(2*t)
			s += bsearch(c,2t-x)-bsearch(c,t-x)+bsearch(c,4t-x)-bsearch(c,3t-x)

		end
		ans += (s%2)*t
	end
	println(ans)
end

main()

Measured memory_bytes: 170360
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> v(m);
  rep(i, m){
    cin >> v[i];
  }
  int a = 0, b = 0;
  for(int i = 0; i < m; i++){
    if(v[i] < x){
      a++;
    }else b++;
  }
  cout << min(a, b) << endl;
  system("pause");
}


Measured memory_bytes: 504
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

ll n, ans, a[200005], c[200005];
int main() {
	ll i;
	cin >> n;
	for(i=0; i<n; i++) scanf("%lld", &a[i]), c[a[i]]++;
	for(i=1; i<=n; i++) ans += c[i] * (c[i]-1) / 2;
	for(i=0; i<n; i++) printf("%lld\n", ans - c[a[i]] + 1);
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand((unsigned)time(NULL));
  ll N, M, K;
  cin >> N >> M >> K;
  vll A(N), B(M);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  for(int i = 0; i < M; i++){
    cin >> B.at(i);
  }
  vll AA(N+1, 0), BB(M+1, 0);
  for(int i = 0; i < N; i++){
    AA.at(i+1) += AA.at(i) + A.at(i);
  }
  for(int i = 0; i < M; i++){
    BB.at(i+1) += BB.at(i) + B.at(i);
  }
  ll ok = 0, ng = N+M+1;
  while(ng - ok > 1){
    ll mid = (ok + ng)/2;
    ll mini = INF;
    for(int i = 0; i <= mid; i++){
      if(i > N|| mid-i > M) continue;
      chmin(mini, AA.at(i) + BB.at(mid-i));
    }
    if(mini <= K) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}

Measured memory_bytes: 9524
n, k = map(int, input().split())

ans = 0
a = []
for _ in range(n):
    a.append(0)
    
for i in range(k):
    d = int(input())
    treat = list(map(int, input().split()))
    for snuke in treat:
        a[snuke-1] += 1
    
for j in range(n):
    if a[j] == 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i;
    cin>>n;
    long long int h[n];
    for(i=0;i<n;i++)
        cin>>h[i];
    long long int dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(i=2;i<n;i++)
    {
        dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
    };
    cout<<dp[n-1];
    return 0;
}


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

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  
  char x = a.at(0) - 32;
  char y = b.at(0) - 32;
  char z = c.at(0) - 32;
  
  cout << x << y << z << endl;
  return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

void solve()
{
    string S;
    cin >> S;
    int ans = 0;
    REP0(i, S.length() - 1)
    {
        if (S[i] != S[i + 1])
            ans++;
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

int n, k;

unsigned long long sumi, sumn, cazuri;

int main()
{
    cin >> n >> k;
    for(int i = 0 ; i <= k - 1 ; i ++)
        sumi += i;
    for(int i = n ; i >= n - k + 1 ; i --)
        sumn += i;
    cazuri = (sumn - sumi + 1) % MOD;
    if(sumn != sumi)
    {
        int indi = k, indn = n - k;
        for(int i = k + 1 ; i <= n ; i ++)
        {
            sumn += indn;
            indn --;
            sumi += indi;
            indi ++;
            cazuri = (cazuri + (sumn - sumi + 1)) % MOD;
        }
        cazuri = (cazuri + 1) % MOD;
    }
    cout << cazuri;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}
int qpow(int a,int n)
{
    int r=1%P;
    for (a%=P; n; a=a*a%P,n>>=1)if(n&1)r=r*a%P;
    return r;
}
const int maxn=2e5+50;
int a[maxn];
  int n,k;
int check(int x)
{  int kk=0;
   for(int i=1;i<=n;i++)
   {
    kk+=(a[i]-1)/x;
   }
   if(kk>k)
    return 0;
   else
    return 1;
}
int main()
{
  cin>>n>>k;
  for(int i=1;i<=n;i++)
  {
      cin>>a[i];
  }
  int l=1,r=1e9;
  int ans=0;
  while(l<=r)
  {
      int mid=(l+r)/2;
      if(check(mid))
      {
          r=mid-1;
          ans=mid;
      }
      else
      {
          l=mid+1;
      }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4340
#include <iostream>
using namespace std;
long long a,b,sol;
int main()
{
    //ios::sync_with_stdio(false);
    cin>>a>>b;
    b/=a;
    a=1;
    while(a<=b)
    {
        ++sol;
        a*=2;
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint(), Q = getint();
	
	int AC[100000];
	AC[0] = 0;
	rep(i, N - 1) {
		AC[i + 1] = AC[i];
		if (*ci++ == 'A' && *ci == 'C') AC[i + 1]++;
	}
	ci += 2;
	rep(i, Q) {
		int l = getint(), r = getint();
		putint(AC[r - 1] - AC[l - 1]);
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 1920
#include <iostream>

using namespace std;

int main() {
    int n;
    int rez(0);
    cin >> n;
    int p = 0;
    int a;
    for (int i = 1; i<= n ;i++){
        cin >> a;
        if(p == a){
            rez++;
            p = 0;
        }else{p = a;}
    }
    cout << rez;
}

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


 const int MAX = 1001;
const int MOD = 1000000007;



signed main(){
 
   int n;
   cin>>n;
   int k=0,o=1;
   while(n>=(o<<k))k++;
   int dp[k][3];
    dp[0][0]=1;
    dp[0][1]=1;
    dp[0][2]=0;
    for(int i=1;i<k;i++){
        if(1&(n>>(k-i-1))){
            dp[i][0]=dp[i-1][0];
            dp[i][1]=(dp[i-1][0]+dp[i-1][1])%MOD;
            dp[i][2]=(dp[i-1][2]*3+dp[i-1][1]*2)%MOD;
        }else{
            dp[i][0]=(dp[i-1][0]+dp[i-1][1])%MOD;
            dp[i][1]=dp[i-1][1];
            dp[i][2]=(dp[i-1][2]*3+dp[i-1][1])%MOD;
        }
    }

    cout<<(dp[k-1][0]+dp[k-1][1]+dp[k-1][2])%MOD;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000;
const int MOD = (int)1e9 + 7;
template <class T>
inline T in()
{
    T x;
    cin >> x;
    return x;
}

signed main()
{
    double n = in<int>();
    double k = in<int>();
    double logk = log2(k);
    double r = 0;
    for (double i = 1; i <= n; i++)
    {
        double x = logk - log2(i);
        double y = ceil(x);
        if (k == i) {
            r += n - i + 1;
            break;
        }
        r += 1 / pow(2, y);
    }
    r /= n;
    cout << setprecision(12) << r << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b;
  if(a==0){
    if(b >= 1868 && b <= 1911){
      b -= 1867;
      cout<<"M"<<b<<'\n';
    }
    else if(b >= 1912 && b <= 1925){
      b -= 1911;
      cout<<"T"<<b<<'\n';
    }
    else if(b >= 1926 && b <= 1988){
      b -= 1925;
      cout<<"S"<<b<<'\n';
    }
    else if(b >= 1989){
      b -= 1988;
      cout<<"H"<<b<<'\n';
    }
  }
  if(a != 0){
    if(a == 1){
      b += 1867;
    }
    else if(a == 2){
      b += 1911;
    }
    else if(a == 3){
      b += 1925;
    }
    else if(a == 4){
      b+= 1988;
    }
    cout<<b<<'\n';
  }
  return 0;
}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main(){
    string s; cin >> s;
    int n; cin >> n;
    string ans;
    rep(i,s.size()){
        if((i) % n == 0 || i == 0)ans.push_back(s[i]);
    }
    cout << ans << endl;
}




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

Measured memory_bytes: 1024
#include <iostream>
#define ll long long
using namespace std;
int main(void){
    // Your code here!
    ll k,n;
    cin>>k;
    n=(k+1)/2;
    n+=n%2;
    if(k==1){
        cout<<1<<endl<<1;
    }
    else{
    cout<<n<<endl;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<n;j++){
            if(i%2==0){
                cout<<(i+j)%n+1<<" ";
            }
            else{
                if(n+(i+j)%n>=k){
                    cout<<(i+j)%n+1<<" ";
                }
                else{
                cout<<(n+(i+j)%n)+1<<" ";
                }
            }
        }
        cout<<endl;
    }
    }
}


Measured memory_bytes: 1152