akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<iostream>
#include<algorithm>
#define llong long long
using namespace std;

inline int read()
{
	int x=0; bool f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=0;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(c^'0');
	if(f) return x;
	return -x;
}

const int N = 5000;
const llong INF = 10000000000000000ll;
int p[N+3],pp[N+3];
llong dp[N+3][N+5],sdp[N+3][N+5];
int n; llong arga,argb;

void update(llong &x,llong y) {x = x<y?x:y;}

int main()
{
	scanf("%d%lld%lld",&n,&arga,&argb);
	for(int i=1; i<=n; i++) {scanf("%d",&p[i]); pp[p[i]] = i;}
	for(int i=0; i<=n; i++) for(int j=0; j<=n; j++) dp[i][j] = sdp[i][j] = INF;
	for(int i=0; i<=n; i++) sdp[0][i] = dp[0][i] = 0ll;
	for(int i=1; i<=n; i++)
	{
		for(int j=0; j<=n; j++)
		{
			if(j==pp[i]) {update(dp[i][j],sdp[i-1][j-1]);}
			llong tmp = sdp[i-1][j]+(j<pp[i]?argb:arga);
			update(dp[i][j],tmp);
//			printf("dp[%d][%d]=%lld\n",i,j,dp[i][j]);
		}
		sdp[i][0] = dp[i][0];
		for(int j=1; j<=n; j++) sdp[i][j] = min(sdp[i][j-1],dp[i][j]);
	}
	llong ans = sdp[n][n];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 391552
a, b, c, x, y = map(int, input().split())
ans = min(x*a+y*b, max(x,y)*c*2)
if x>y: ans = min(ans, y*c*2+(x-y)*a)
else: ans = min(ans, x*c*2+(y-x)*b)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#define int long long int
#define MOD 1000000007
#define MAX INT_MAX
using namespace std;

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

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

int myXOR(int x, int y) {
     return (x | y) & (~x | ~y);
}

void solve() {
    int n, d;
    cin >> n >> d;
    int cur = d+1;
    int count = 1;
    while(1) {
        if(cur+ 2*d+1 < n) {
            count++;
            cur += 2*d+1;
        }
        else
        break;
    }
   // cout << cur << endl;
    if(cur + d >= n)
        cout << count << '\n';
    else
        cout << count+1 << '\n';
    return ;
}              

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
  Scanner scan = new Scanner(System.in);
 int x = scan.nextInt();
int a = scan.nextInt();
int b = scan.nextInt();
int A = a-x>0?(a-x):(x-a);
int B = b-x>0?(b-x):(x-b);
if(A<=B)System.out.println("A");
else System.out.println("B");
}
}

Measured memory_bytes: 22228
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>

using namespace std;

inline int gi()
{
    int f = 1, x = 0;
    char c = getchar();
    while (c < '0' || c > '9')
    {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9')
    {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return f * x;
}

int a, b, ans, l[103], d[5003];

int main()
{
	a = gi(), b = gi();
	for (int i = 1; i <= a; i++) l[i] = gi();
	d[1] = 0;
	if (d[1] <= b) ++ans;
	for (int i = 2; i <= a + 1; i++)
	{
		d[i] = d[i - 1] + l[i - 1];
		if (d[i] <= b) ++ans;
	}
	printf("%d\n", ans);
	return 0;
 } 

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {

  string s;
  cin >> s;
  sort(s.begin(), s.end());

  auto res = s[0] == s[1] and s[2] == s[3] and s[1] != s[2];
  cout << (res ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 764
package main

import (
	"fmt"
)

func main() {
	var k int
	fmt.Scan(&k)
	arr := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}

	fmt.Println(arr[k-1])
}


Measured memory_bytes: 512
#include<iostream>
#include<queue>
#include<string.h>
#define inf 1000000001
#define f first
#define s second
#define mk make_pair
using namespace std;

int X[4]={0,1,0,-1};
int Y[4]={-1,0,1,0};
int H,W;
int map[1002][1002]={};
int memo[1002][1002]={};

bool in(int y,int x)
{
  if(y<0 || x<0 || y>=H || x>=W)return false;
  return true;
}

int md(char c)
{
  if(c=='U')return 0;
  if(c=='R')return 1;
  if(c=='D')return 2;
  if(c=='L')return 3;
}

int main()
{
  int N,si,sj,gi,gj,x,y,T;
  string s;

  cin>>W>>H>>N;
  H=H*2+1;
  W=W*2+1;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      map[i][j]=0;
      memo[i][j]=inf;
    }
  }
  cin>>sj>>si>>gj>>gi;
  si*=2;
  sj*=2;
  gi*=2;
  gj*=2;

  for(int k=0;k<N;k++){
    cin>>x>>y;
    x=x*2+1;
    y=y*2+1;
    cin>>T>>s;
    for(int i=0;i<T;i++){
      for(int j=0;j<s.length();j++){
	int muki=md(s[j]);
	int a=x+X[muki]*2,b=y+Y[muki]*2;
	if(in(b,a)){
	  map[y+Y[muki]][x+X[muki]]++;
	  x=a;
	  y=b;
	}
      }
    }
  }

  int ans=inf;
  priority_queue<pair<int,pair<int,int> > > Q;
  Q.push(mk(0,mk(si,sj)));
  memo[si][sj]=0;
  while(!Q.empty()){
    pair<int,pair<int,int> > u=Q.top();
    Q.pop();
    //cout<<u.y<<" "<<u.x<<" "<<u.cost<<" "<<memo[u.y][u.x]<<endl;
    if(u.s.f==gi && u.s.s==gj){
      ans=min(ans,-u.f);
      break;
    }
    for(int k=0;k<4;k++){
      int a=u.s.s+X[k]*2,b=u.s.f+Y[k]*2;
      if(in(b,a)){
	if(-u.f+map[u.s.f+Y[k]][u.s.s+X[k]]<memo[b][a]){
	  memo[b][a]=-u.f+map[u.s.f+Y[k]][u.s.s+X[k]];
	  Q.push(mk(-memo[b][a],mk(b,a)));
	}
      }
    }
  }
  cout<<ans<<endl;
   
  return 0;
}

Measured memory_bytes: 13000
#include<stdio.h>

#define N_MAX 100000

int main(void){

    int N,i,ans=0,AbleToDown = 0;
    long int H[N_MAX];

    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%ld",&H[i]);
    }

    for(i = 0;i< N - 1;i++){
        if(H[i] >= H[i + 1]){
            AbleToDown++;
        }else{
            if(ans < AbleToDown){
                ans = AbleToDown;
            }
          	AbleToDown = 0;
        }
      	if(ans < AbleToDown){
        	ans = AbleToDown;
    	}
    }

    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
int main()
{
	int m,f,b;
	scanf("%d%d%d",&m,&f,&b);
	if(m>=b){
		printf("0\n");
	}else if(m+f<b){
		printf("NA\n");
	}else{
		printf("%d\n",b-m);
	}
    return 0;
}

Measured memory_bytes: 1828
import math  # noqa: F401
from typing import Dict, List, Optional, Tuple, Union  # noqa: F401


def main(N: int, K: int, p: List[int]):
    p.sort()
    print(sum(p[:K]))


if __name__ == "__main__":
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    main(N, K, p)


Measured memory_bytes: 10308
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	vs := make([][2]int, m)
	vm := [50][50]bool{}
	var a, b int
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		a--
		b--
		vs[i] = [2]int{a, b}
		vm[a][b] = true
		vm[b][a] = true
	}

	ans := 0
	for _, v := range vs {
		a, b := v[0], v[1]
		vm[a][b] = false
		vm[b][a] = false
		if !bfs(n, vm) {
			ans++
		}
		vm[a][b] = true
		vm[b][a] = true
	}

	fmt.Println(ans)
}

func bfs(n int, v [50][50]bool) bool {
	used := make(map[int]bool)
	used[0] = true
	q := make([]int, 0)
	q = append(q, 0)
	for len(q) > 0 {
		e := q[0]
		q = q[1:]
		used[e] = true
		for i := 0; i < n; i++ {
			if v[e][i] && !used[i] {
				q = append(q, i)
			}
		}
	}

	return n == len(used)
}


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

bool match_two_num(int a, int b, int m)
{
  bool flag = false;

  for (int i = 0; i <= m / a; i++)
  {
    if ((m - a * i) % b == 0)
    {
      flag = true;
      break;
    }
  }
  return (flag);
}

int main()
{
  int A, B, C, D, E, F, max_sg;
  int ans_sg = 0, ans_wg = 0;

  cin >> A >> B >> C >> D >> E >> F;
  for (int i = 100 * A; i < F; i += 100)
  {
    if (!match_two_num(100 * A, 100 * B, i))
      continue;
    max_sg = min(F - i, i * E / 100);
    for (int j = 1; j <= max_sg; j++)
    {
      if (!match_two_num(C, D, j))
        continue;
      if (ans_sg * (j + i) < j * (ans_sg + ans_wg) || (ans_sg == 0 && j != 0) )
      {
        ans_sg = j;
        ans_wg = i;
      }
    }
  }
  if (ans_wg == 0)
    ans_wg = 100 * A;
  cout << ans_wg + ans_sg << " " << ans_sg << endl;
}

Measured memory_bytes: 256
from bisect import bisect_left
from operator import itemgetter
import sys

input = sys.stdin.readline

N, Q = map(int, input().split(" "))
check_points = [tuple(map(int, input().split(" "))) for _ in range(N)]
querys = [int(input()) for _ in range(Q)]
time = [-1] * Q
jump = [-1] * Q
check_points = sorted(check_points, key=itemgetter(2))
b_left = bisect_left

for line in check_points:
    s, f, x = line
    start = s-x
    end = f-x
    left = b_left(querys, start)
    right = b_left(querys, end)
    while left < right:
        if time[left] == -1:
            time[left] = x
            jump[left] = right
            left += 1
        else:
            left = jump[left]

for t in time:
    print(t)


Measured memory_bytes: 54020
S=input()
if S[0]=="R" :
  if S[1]=="R" and S[2]=="S" :
    print(2)
  elif S[1]=="R" and S[2]=="R" :
    print(3)
  else :
    print(1)
else :
  if S[1]=="R" and S[2]=="S" :
    print(1)
  elif S[1]=="R" and S[2]=="R" :
    print(2)
  elif S[1]=="S" and S[2]=="R" :
    print(1)
  else :
    print(0)

Measured memory_bytes: 9152
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
   FAST/**/
   ll n;
   cin>>n;
   
   pair<ll,ll> arr[n];
   for(ll i=0;i<n;i++) 
   {
       cin>>arr[i].first;
       arr[i].second = i+1;
   }
   
   sort(arr,arr+n);
   for(ll i=0;i<n;i++)
        cout<<arr[i].second<<" ";
   
   return 0;
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int a, b, c;
  int sum = 0;
  int Atriangle = 0, Rtriangle = 0, Otriangle = 0;
  while(true){
      cin >> a >> b >> c;
      if(a+b > c && b+c > a && c+a > b ){
        sum++;
        vector<int> abc = {a,b,c};
        sort(abc.begin(),abc.end());
        abc.at(0) = abc.at(0)*abc.at(0);
        abc.at(1) = abc.at(1)*abc.at(1);
        abc.at(2) = abc.at(2)*abc.at(2);
        if(abc.at(0)+abc.at(1) > abc.at(2)) Atriangle++;
        else if(abc.at(0)+abc.at(1) == abc.at(2)) Rtriangle++;
        else Otriangle++;
      }
      else{
        cout << sum << " " << Rtriangle << " " << Atriangle 
        << " " << Otriangle << endl;
        break;
      }
  }
}


Measured memory_bytes: 3124
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> t3;

int main(void) {
    ll n,k;
    cin >> n >> k;
    map<int,int> m;
    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        m[a]++;
    }
    vector<int> ps;
    for(auto e:m)
    {
        ps.push_back(e.second);
    }
    sort(ps.begin(), ps.end(), std::greater<int>());
    ll sum = 0;
    for(int i = 0;i < min<ll>(k, (ll)ps.size());i++)
    {
        sum += ps[i];
    }
    cout << n - sum << endl;
    return 0;
}


Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define  prec(n)        fixed<<setprecision(n)
#define  optimize       ios::sync_with_stdio(0); cin.tie(0);
#define  PI             acos(-1.0)
#define  RESET(a, b)    memset(a, b, sizeof(a))
#define  pb             push_back
#define  pii            pair<int,int>

int main()
{
    int l,r,d;
    cin>>l>>r>>d;
    int x=(l-1)/d;
    int y=(r-1)/d;
    if(r%d==0) y++;
    cout<<y-x<<endl;
}


Measured memory_bytes: 3616
x, y  = map(int, input().split())
 
def prime_factorize(n):
    a = [1]
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
prime_x = prime_factorize(x)
prime_y = prime_factorize(y)
 
num_x = len(prime_x)
num_y = len(prime_y)
 
num = min(num_x, num_y)
co = list(set(prime_x) & set(prime_y))

ans = 0
for i in range(len(co)):
  if co == [1]:
    ans = 1
    break
  else:
    if len(prime_factorize(co[i])) == 1 or len(prime_factorize(co[i])) == 2:
      ans += 1
print(ans)
 

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int main() {
    int x;
    cin >> x;
    cout << (1LL << (x+2)) - 2 << endl;

    return 0;
}

Measured memory_bytes: 256
import itertools

n,m,q = map(int,input().split())
ab = []
for _ in range(q):
    t = list(map(int,input().split()))
    ab.append(t)

kazu = []

for i in range(1,m+1):
    kazu.append(i)

ans = 0

for v in itertools.combinations_with_replacement(kazu, n):
    memo = 0
    for i , j ,k ,l in ab:
        if v[j-1]-v[i-1] == k:
            memo += l
    ans = max(memo,ans)
print(ans)

Measured memory_bytes: 67672
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
L = list(set(a))
res = 0
d = Counter()
d.update(a)
for i in L:
    X = d[i]
    if X < i:
        res += X
    
    else:
        res += X - i

print(res)
    
  

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

int main(){
    int N; cin >> N;
    vector<ll> A(N),B(N);
    ll mi, ma;
    rep(i,N){
        cin >> A[i] >> B[i];
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if(N % 2 == 0){
        mi = A[N/2-1] + A[N/2];
        ma = B[N/2-1] + B[N/2];
    }else{
        mi = A[N/2];
        ma = B[N/2];
    }
    cout << ma - mi + 1 << endl;
}

Measured memory_bytes: 6336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int K;
  cin >> N >> K;
  int64_t count;
  count = 0;
  vector<int64_t> hp(N);
  
  for (int i=0; i<N; i++){
    cin >> hp.at(i);
  }
  
  if (K<N && 1<=K){
    sort (hp.begin(), hp.end());
    for (int i=0; i<N-K; i++){
      count += hp.at(i);
    }
  }
  
  if (K == 0){
  	for (int i=0; i<N; i++){
  		count += hp.at(i);
  	}
  }
  
  cout << count << endl;
  
}

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

int main(){

	int mt_list[10];

	for (int i = 0; i<10; i++){
		cin >> mt_list[i];
	}

	int high[3] = { 0, 0, 0 };
	for (int h = 0; h<3; h++){
		int tmp = 0;
		for (int i = 0; i<10; i++){
			if (high[h] <= mt_list[i]){
				high[h] = mt_list[i];
				tmp = i;
			}
		}
		high[h] = mt_list[tmp];
		mt_list[tmp] = 0;
	}

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

	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();
        int k = sc.nextInt();
        int count = 0;

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

        if (count >= k) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<cstring>

using namespace std;

int n,w;
int v[100][2];
int dp[10001];

int dfs(int k){
  for(int i = 0; i < w; i++){
    if(dp[i] != -1){
      if(i + v[k][1] <= w)dp[i + v[k][1]] = max(dp[i + v[k][1]], dp[i] + v[k][0]);
    }
  }
  if(k < n-1) return dfs(k+1);
  else return 0;
}

int main(){
  cin >> n >> w;
  for(int i = 0; i < n ;i++){
    cin >> v[i][0] >> v[i][1];
  }
  memset(dp, -1, sizeof(dp));
  dp[0] = 0;
  dfs(0);
  int m = 0;
  for(int i = 0; i <= w; i++){
    m = max(m, dp[i]);
  }
  cout << m << endl;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  int a,b,t;
  cin >> a >> b >> t;
  int p = t/a * b;
  cout << p << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<set>
#include<algorithm>
#define Max 200005
using namespace std;
typedef long long LL;
int main() {
    int n;
    int a[Max];
    LL sum[Max] = {0};
    scanf("%d",&n);
    for(int i = 1;i <= n;i ++) {
        scanf("%d",&a[i]);
        sum[i] = sum[i - 1] + a[i];
    }
    LL ans = sum[n];
    int l = 1,r = 3;
    for(int i = 2;i <= n - 2;i ++) {
        LL last = sum[n];
        set<LL> s;
        while(l < i) {
            LL d = abs(sum[i] - sum[l] * 2);
            if(d > last) break;
            else last = d;
            l ++;
        }
        l --;
        s.insert(sum[l]);
        s.insert(sum[i] - sum[l]);
        last = sum[n];
        while(r < n) {
            LL d = abs(sum[n] + sum[i] - sum[r] * 2);
            if(d > last) break;
            else last = d;
            r ++;
        }
        r --;
        s.insert(sum[r] - sum[i]);
        s.insert(sum[n] - sum[r]);
        ans = min(ans,*s.rbegin() - *s.begin());
    }
    printf("%lld",ans);
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n;
  cin >> n;

  vector<int> a(n+1);
  rep(i, n) {
    cin >> a[i];
  }

  int ans = 0;
  for (int i = 1; i < n; ++i) {
    if (a[i] == a[i-1]) {
      ++ans;
      a[i] = 100000;
    }
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	tasks := make(Tasks, n)

	for i := 0; i < n; i++ {
		tasks[i].a = getNextInt(scanner)
		tasks[i].b = getNextInt(scanner)
	}
	sort.Sort(tasks)
	ans := "No"
	if canFinish(tasks) {
		ans = "Yes"
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}

type Task struct {
	a int
	b int
}

type Tasks []Task

func (a Tasks) Len() int           { return len(a) }
func (a Tasks) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Tasks) Less(i, j int) bool { return a[i].b < a[j].b }

func canFinish(tasks Tasks) bool {
	n := len(tasks)
	done := 0
	for i := 0; i < n; i++ {
		done += tasks[i].a
		if done > tasks[i].b {
			return false
		}
	}
	return true
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define mset(a,x) memset(a,x,sizeof(a))
#define OUT(x) cout<<(x)<<"\n"
#define SZ(x) (int)(x).size()
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)



int main() {
    vector<ll> a(3);
    rep(i, 3) cin >> a[i];
    sort(ALL(a));

    ll p = a[0] * a[1] * (a[2] / 2);
    ll q = a[0] * a[1] * (a[2] - a[2] / 2);
    cout << q - p << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
int main()
{
    fastio();
    
    ll n,k;
    cin>>n>>k;
    ll sum=0,ans=0;
    ll arr[k+1]={0};
    for(ll i=1;i<=k;i++)
    {
        ll div = k/i;
        arr[i]= mpowe(div,n,MOD1);
    }
    for(ll i=k;i>0;i--)
    {
        ll j = i*2;
        while(j<=k)
        {
            arr[i] = (arr[i] - arr[j] + MOD1)%MOD1;
            j=j+i;
        }
    }
    for(ll i=1;i<=k;i++)
    {
        ans = (ans + (i*arr[i])%MOD1)%MOD1;
    }
    ans = (ans+sum)%MOD1;
    cout<<ans<<endl;
}


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

int main(){
	double min, max, x;
	cin >>x;
	min = x;
	max = x;
	while(cin >>x){
		if(x > max) max = x;
		if(x < min) min = x;
	}
	cout <<max - min <<endl;
	return 0;
}

Measured memory_bytes: 0
/*
    Author : manu_sy
*/
#include "bits/stdc++.h"
using namespace std;
 
/** Template Begins **/
#define int ll 
typedef long long        ll;
typedef pair<int,int>    PII;
 
#define IOS         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl        '\n'
#define pb          push_back
#define F           first
#define S           second
#define mp          make_pair
#define all(a)      (a).begin(), (a).end()
#define FOR(i,a,b)  for(int i=a;i<=b;i++)
#define LP(i,n)     for(int i=0;i< n;i++)
 
/* Debug */
 
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.F << "," << P.S << ")";
} 
 
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr << sdbg << '=' << h << endl; }
 
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr << *sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
 
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
 
/* Debug Ends */
 
const int N = 5e6+7;
 
/** Template Ends **/

 
signed main() {
 
    IOS;
    int n, d;	cin >> n >> d;
    int ans = 0;
    LP(i,n) {
    	int x, y;	cin >> x >> y;
    	if (x * x + y * y <= d * d) ans++;
    }
    cout << ans << endl;


 
    return 0;
}























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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    cout << 180*(n-2) << endl;
    return 0;
}


Measured memory_bytes: 256
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans1 = 0
for i in range(n-1):
    a[i+1] = a[i]+a[i+1]
for i in range(m-1):
    b[i+1] = b[i]+b[i+1]
import bisect
key = bisect.bisect(a,k)
for i in range(key):
    ans = 0
    ans += key-i
    time = a[key-i-1]
    ans += bisect.bisect(b,k-time)
    ans1 = max(ans1,ans)
ans = 0
ans += bisect.bisect(b,k)
ans1 = max(ans,ans1)

            
print(ans1)

Measured memory_bytes: 42332
//Don't give up too easy bhai
#pragma GCC optimize("O3")
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
 
#define forall(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define vll vector<ll>
#define vld vector<ld>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007
#define br cout<<"\n"
#define whatis(x) cerr << ">"<<#x << " ==> " << x << endl;
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define T ll __t;cin>>__t;while(__t--)


int main()
{
	fast;

	char x;cin>>x;
	// cout<<int(x-'a');
	if( x-'a' < 26 and x-'a'>=0) cout<<'a';
	else cout<<'A';


	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, A;
    cin >> N >> A;
    cout << N * N - A << endl;
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll x,k,d,r,s;
    cin >> x >> k >> d;
    if(x<=0) x=-x;
    s=min(k,(x/d));
    k-=s;
    x-=d*s;
    if(k%2==0) cout << x << endl;
    else cout << (d-x) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	long long int a,b;
	cin>>a>>b;
	if((a+b)%2==1){
		cout<<"IMPOSSIBLE\n";
	}else{
		cout<<(a+b)/2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" <<endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    map<int ,int> a;
    int t;
    REP(i,Q) {
        cin >> t;
        a[t-1]++;
    };

    REP(i,N) {
        if (K - Q + a[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P, ll> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;

int main() {
    ll s, t, d, x[100005]{}, xmin=LLINF;
    cin >> s >> t >> d;
    for(int i=0;i<d;i++){
        cin >> x[i+1];
        x[i+1] += x[i];
        if(xmin > x[i+1]){
            xmin = x[i+1];
        }
    }
    if(x[d] > 0 && s+xmin > t){
        cout << -1 << endl;
    }
    else{
        ll k = max(0LL, s+xmin-t)/abs(x[d]);
        ll ans = d*k;
        s += x[d]*k;
        for(int i=0;s>t;i=(i+1)%d,ans++){
            s += x[i+1]-x[i];
        }
        cout << ans << endl;
    }
    return 0;
}



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

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

#define ll long long
#define ull unsigned long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define all(v) (v).begin(), (v).end()

//ofstream out("debug.txt");

const int m = 1e9 + 7, mxS = 1e6, mxN = 100;
ll dp[mxS];
int v[mxN];

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

    int n;
    cin >> n;
    dp[0] = 1;
    for (int j = 1; j <= n; ++j)
        for (int i = 3; i <= n; ++i)
            if (j >= i)
                dp[j] = (dp[j - i] + dp[j]) % m;
    cout << dp[n];
}

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

const double PI=3.14159265358979323846;

int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double A_kaku, B_kaku, answer;
  B_kaku = M/60*2*PI;
  A_kaku = (H*60+M)/12/60*2*PI;
  answer = sqrtl((B*cos(B_kaku)-A*cos(A_kaku))*(B*cos(B_kaku)-A*cos(A_kaku))+(B*sin(B_kaku)-A*sin(A_kaku))*(B*sin(B_kaku)-A*sin(A_kaku)));
  cout << setprecision(12) << answer << endl;
  
}


Measured memory_bytes: 4100
//
// Created by 吉川純平 on 2019-12-01.
//

#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
//using ull = unsigned long long;
#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
struct Node{
    ll parent = -1;
    ll depth = 0;
    string kinds = "internal node";
    vector<ll> vec;
};
vector<bool> isroot(100000,true),visited(100000,false);
struct Node nodes[100000];
void dfs(ll num,ll depth){
  if(visited[num]){
    return;
  }
  nodes[num].depth = depth;
  visited[num] = true;
  for(auto itr : nodes[num].vec){
    dfs(itr,depth+1);
  }
}
int main(){
  ll n;
  cin >> n;
  ll root = -1;
  rep(i,n){
    cin >> tmp1 >> tmp2;
    if(tmp2 == 0){
      nodes[tmp1].kinds = "leaf";
    }
    rep(j,tmp2){
      cin >> tmp3;
      nodes[tmp3].parent = tmp1;
      nodes[tmp1].vec.emplace_back(tmp3);
      isroot[tmp3] = false;
    }
  }
  rep(i,n){
    if(isroot[i]){
      root = i;
      break;
    }
  }
  nodes[root].kinds = "root";
  dfs(root,0);
  rep(i,n){
    printf("node %d: parent = %d, depth = %d, %s, [",i,nodes[i].parent,nodes[i].depth,nodes[i].kinds.c_str());
    bool first_node = true;
    for(auto itr : nodes[i].vec){
      if(first_node){
        printf("%d",itr);
        first_node = false;
      }else{
        printf(", %d",itr);
      }
    }
    printf("]\n");
  }
}


Measured memory_bytes: 13908
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  lint x, k, d, y; cin >> x >> k >> d;
  if(x < 0) x *= -1;
  lint a = x % d, b = d - a, c = x / d;
  if(k < c) y = x - d * k;
  else{
    if((k - c) & 1) y = b;
    else y = a;
  }
  cout << y << endl;
  return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    int N; cin >> N;
    map<int, int> A;
    rep(i, N) {
        int a; cin >> a;
        A[a]++;
    }

    ll ans = 0;
    for (auto i : A) {
        if (i.first < i.second) ans += i.second - i.first;
        else if (i.first > i.second) ans += i.second;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4736
#include <stdio.h>

int e;
long long f;

int check (long long a,int b)
{
	int c;
	if(a<=f){
		if(b==7){
			e++;
		}
	}
	if(a<=f){
		check(a*10+3,b|1);
		check(a*10+5,b|2);
		check(a*10+7,b|4);
	}
	return e;
}
	
int main(void)
{
	int d;
	scanf("%lld",&f);
	d=check(0,0);
	printf("%d\n",d);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF (2e9)
#define EPS (1e-6)
#define int ll
#define NATHANLEE_IS_EVIL true
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif
void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(!NATHANLEE_IS_EVIL);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

bitset<1000010> b;

int32_t main() {
	INIT();
	//code...
	int k; cin>>k;
	int all=0,now=7;
	int ans=0;
	bool ac=NATHANLEE_IS_EVIL;
	b.reset();
	while(NATHANLEE_IS_EVIL){
		ans++;
		all=(all+now)%k;
		now=(now*10)%k;
		if(b[all]){
			ac=!NATHANLEE_IS_EVIL;
			break;
		}
		if(all==0) break;
		b[all]=NATHANLEE_IS_EVIL;
	}
	if(ac) cout<<ans<<"\n";
	else cout<<"-1\n";
	return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int ans=0;
    ans+=(N/500)*1000;
    N%=500;
    ans+=(N/5)*5;
    cout << ans << endl;
}


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

int main() {
  int N;
  int sum = 1;
  cin >> N;
      int K;
    cin >> K;
  
  for (int i = 0; i < N; i++) {
    
    if (sum * 2 >= sum + K)
    sum += K;
    
    if (sum * 2 < sum + K)
    sum *= 2;
  }
    cout << sum << endl;
}

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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const double eps = 1e-9;
const int oo = 0x3f3f3f3f;
const int mod = 1000000007;

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

    int n; cin >> n;

    string s; cin >> s;

    vector<int> dp(n + 1);
    int ans = 0;

    for (int i = 1; i <= n; ++i){
        vector<int> ndp(n + 1);

        for (int j = i + 1; j <= n; ++j){
            if (s[i - 1] == s[j - 1]){
                ndp[j] = 1 + dp[j - 1];
                ans = max(ans, min(j - i, ndp[j]));
            }
        }

        dp.swap(ndp);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int N, E, T, x[100009];
long long dp[100009], INF = 1LL << 50;
multiset < long long > S1, S2;

void push (int lin, long long val)
{
    if (lin == 1) S1.insert (val);
    else S2.insert (val);
}

void pop (int lin, long long val)
{
    if (lin == 1) S1.erase (S1.find (val));
    else S2.erase (S2.find (val));
}

long long getVal (int lin, int k)
{
    if (lin == 1) return (long long) dp[k - 1] - x[k] - x[k] - x[k - 1];
    return (long long) dp[k - 1] - x[k - 1] + T;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d %d", &N, &E, &T);
for (int i=1; i<=N; i++)
    scanf ("%d", &x[i]);
int k = 1;
for (int i=1; i<=N; i++)
{
    while (2 * (x[i] - x[k]) >= T)
    {
        push (1, getVal (1, k));
        pop (2, getVal (2, k));
        k ++;
    }
    push (2, getVal (2, i));
    ///pe [1, k - 1] am dp[k - 1] - x[k] - x[k] - x[k - 1]     +3x[i]
    ///pe [k, i] am dp[k - 1] - x[k - 1] + T    +x[i]
    long long val1 = INF, val2 = INF;
    if (!S1.empty ()) val1 = (*S1.begin ()) + 3LL * x[i];
    if (!S2.empty ()) val2 = (*S2.begin ()) + x[i];
    dp[i] = min (val1, val2);
}
printf ("%lld\n", dp[N] + E - x[N]);
return 0;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) > (b); --(i))
#define pb push_back
#define pr pair<int,int>
#define mp make_pair
#define ll long long int
const int mod=1e9+7;
int main(){
  int n;
  cin>>n;
  map<int,int>mp1;
  for(int i=2;i<=n;i++){
      int b;
      cin>>b;
      mp1[b]++;
  }
  for(int i=1;i<=n;i++)cout<<mp1[i]<<endl;
}


Measured memory_bytes: 12972
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

constexpr int INF = 1e8;
constexpr int MOD = 1e9+7;

bool red[100000];
int num[100000];

int main(void) {
    int i, n, m;
    scanf("%d%d",&n,&m);
    REP (i,n) num[i] = 1;
    red[0] = true;
    REP (i,m) {
        int x, y;
        scanf("%d%d",&x,&y);
        x--; y--;
        num[x]--; num[y]++;
        if (red[x]) {
            red[y] = true;
            if (num[x] == 0) red[x] = false;
        }
    }
    int ans = 0;
    REP (i,n) if (red[i]) ans++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>




typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;




int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int cnt=0;
    rep(i,n-1){
        if (s[i]==s[i+1]){
            cnt++;
        }
    }
    int ans=min(cnt+2*k,n-1);
    
    cout<<ans;
    return 0;
}


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

int main() {
  
  string S;
  cin >> S;
  
  if(S == "SUN") cout << 7 << endl;
  if(S == "MON") cout << 6 << endl;
  if(S == "TUE") cout << 5 << endl;
  if(S == "WED") cout << 4 << endl;
  if(S == "THU") cout << 3 << endl;
  if(S == "FRI") cout << 2 << endl;
  if(S == "SAT") cout << 1 << endl;
  
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int main(){
  string A, B;
  cin >> A >> B;
  
  ll ans=0;
  rep(i,3) if(A[i]==B[i]) ans++;
  cout << ans << endl;

}

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

int main(void){
	
	int a,b,c,d;
	
	cin>>a>>b>>c>>d;

	if(a*b>c*d){
		cout<<a*b<<endl;
	}
	else{
		cout<<c*d<<endl;
	}

	
	return 0;
}


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

#define ll long long
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define ii pair < int, int >
#define vi vector < int > 
#define all(a) (a).begin(), (a).end()

using namespace std;

const int maxn = 2e5 + 10;
const double eps = 1e-9;

void solve() {
	int n, k;
	cin >> n >> k;
	cout << ceil( log( n ) / log( k ) + eps ) << "\n";
}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll INF = LLONG_MAX;

ll solve(){
    int n;
    cin >>n;
    vector<vector<ll>> a(n,vector<ll>(n));
    rep(i,n)rep(j,n) cin >>a[i][j];

    vector<vector<ll>> d(a);
    rep(k,n)rep(i,n)rep(j,n) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);

    rep(i,n)rep(j,n)if(d[i][j] != a[i][j]) return -1;

    ll ans = 0;
    rep(i,n)rep(j,i){
        bool ok = false;
        rep(k,n)if(k!=i && k!=j) ok |= (d[i][j] == d[i][k]+d[k][j]);
        if(!ok) ans += d[i][j];
    }

    return ans;
}

int main(){
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 1664