akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
  #define N 10000
  int search(int A[],int n,int key){
    int i=0;
    A[n]=key;
    while(A[i]!=key) i++;
    return i!=n;
  }
  int main(){
    int i,num,A[N+1],q,key,sum=0;
    scanf("%d",&num);
    for(i=0;i<num;i++){
      scanf("%d",&A[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
      scanf("%d",&key);
      if(search(A,num,key))sum++;
    }
    printf("%d\n",sum);
    return 0;
  }



Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
	int n,t=1,inp;
	sd(n);
	for(int i = 1; i <= n; i++){
		sd(inp);
		if(inp==t) t++;
	}
	if(t==1) pd(-1);
	else pd(n+1-t);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second

#define END puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();

int main() {
    clue();
    return 0;
}
int clue() {

    int n;
    cin>>n;
    cout<<(1000-(n%1000))%1000<<endl;
    return 0;
}

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

int main() {
    string S;
    cin >> S;

    int count = 0;
    for (int i = 0; i <= static_cast<int>(S.size() - 1) / 2; i++) {
        if (S[i] != S[S.size() - (i + 1)]) {
            count++;
        }
    }

    cout << count << endl;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int ac[100000], wa[100000];

int main(){
	int n, m;
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int p;
		string s;
		cin >> p >> s;
		p--;
		if(ac[p]>0) continue;
		if(s=="AC") ac[p]=1;
		else wa[p]++;
	}

	int a=0, w=0;
	for(int i=0; i<n; i++) a+=ac[i];
	for(int i=0; i<n; i++){
		if(ac[i]!=0) w+=wa[i];
	}
	cout << a << " " << w << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define x real()
#define y imag()
using namespace std;
typedef complex <double> point;
vector <point> po;
double dot(point a,point b){return a.x*b.x+a.y*b.y;}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}

double get_area(){
  double res=0;
  int size=po.size();
  for(int i=0;i<size;i++){
    point a=po[i],b=po[(i+1)%size];
    res+=cross(a,b)/2;
  }
  return abs(res);
}


int main(){
  int n;
  cin>>n;
  for(int i=0,a,b;i<n;i++)cin>>a>>b,po.push_back(point(a,b));
  printf("%.1f\n",get_area());
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  //aの最大値を求める
  int max1=0;
  for(int i=0;i<n;i++){
      cin >> a[i];
      if(max1<a[i]){
          max1 = a[i];
      }
  }

  //aの最大値の個数を求める
  int count =0;
  for(int i=0;i<n;i++){
      if(a[i]==max1) count++;
  }

  //最大値の要素数が1つの場合
  //最大値を1つ取り出したとき次の最大値を出力すればよい
  if(count==1){
    int max2 = 0;//次の最大値
    for(int i=0;i<n;i++){
        if(max2<a[i]&&a[i]!=max1) max2 = a[i];
    }

    for(int i=0;i<n;i++){
        if(a[i]==max1) cout << max2 << endl;
        else cout << max1 << endl;
    }
  }

  //最大値の要素数が2つ以上の場合
  else{
    for(int i=0;i<n;i++){
        cout << max1 << endl;
    }
  }
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin >> s;
  int ans = 100000000;
  for(int i=0;i<(int)s.size()-2;i++){
    int pre = stoi(s.substr(i,3));
    //cout << pre << endl;
    pre = abs(pre-753);
    ans = min(ans,pre);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,W,sumV,ans;
int w[101],v[101];
int memo[101][100001];
int main()
{
	scanf("%d %d",&N,&W);
	sumV=0;
	for(int i=0;i<N;i++)
	{
		scanf("%d %d",&w[i],&v[i]);
		sumV+=v[i];
	}
	
	for(int i=0;i<N;i++)
	{
		memo[i][0]=0;
		for(int j=1;j<=sumV;j++)
			memo[i][j]=1000000000;
	}
	
	memo[0][v[0]]=w[0];
	ans=0;
	for(int i=1;i<N;i++)
	{
		for(int j=1;j<=sumV;j++)
		{
			if(j<v[i])
			{
				memo[i][j]=memo[i-1][j];
				continue;
			}
			memo[i][j]=min(memo[i-1][j],w[i]+memo[i-1][j-v[i]]);
		}
	}
	
	for(int j=1;j<=sumV;j++)
		if(memo[N-1][j]<=W)
			ans=j;
	printf("%d\n",ans);
}

Measured memory_bytes: 39296
program ans2
      implicit none
      integer(16),allocatable,dimension(:) :: A
      integer(16) :: N
      integer(16) :: i
      integer(16) :: total
      integer(16) :: to1,to2
      integer :: one
      integer(16) :: ans
 
      total = 0
      to1 = 0
      to2 = 0
      one = 0

      read(*,*) N
      allocate(A(N))
      read(*,*) (A(i),i=1,N)
      
      do i=1,N
        total = total + A(i)
      end do

      do i=1,N
        to1 = to1 + A(i)
        if(to1 > total/2) exit
        to2 = to1
      end do
      if(mod(total,2) == 1) one = 1
      
      if((to1-total/2) > (total/2-to2)) then
        ans = 2*(total/2 - to2) + one
      else
        ans = 2*(to1 - total/2) - one
      end if
      
      write(*,*) ans
      end program ans2

Measured memory_bytes: 3968
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String[] nyu=sc.nextLine().split(" ");
   //  String nyu=sc.nextLine();

int X=Integer.parseInt(nyu[0]);
int A=Integer.parseInt(nyu[1]);

if(X<A){
System.out.println("0");
}else{
System.out.println("10");

}

	}
}

Measured memory_bytes: 21716
S, T = input(), input()
s, t = sorted(S), sorted(T, reverse=True)

for i in range(min(len(s), len(t))):
    if s[i] < t[i]:
        print("Yes")
        break
    if s[i] > t[i]:
        print("No")
        break
else:
    if len(s) < len(t):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3060
M,K = map(int,input().split())
if K>=2**M:
    print(-1)
elif M==1:
    if K==0:
        print('0 0 1 1')
    else:
        print(-1)
else:
    ans1 = [i for i in range(2**M) if i != K]
    ans2 = ans1[::-1]
    ans = [K]+ans1+[K]+ans2
    ans = ' '.join(str(i) for i in ans)
    print(ans)

Measured memory_bytes: 29584
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	string S;
	scan(S);
	if(S.back()=='s') S+="es";
	else S+="s";
	prin(S);
	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 intt int64_t
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007

int main() {
    int n;
    scanf("%d", &n);
    printf("%d\n", n*n*n);
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] str = s.split("");
    int length = str.length;
    
    boolean easiness = true;
    for(int i=0;i<length;i+=2) {
      if(str[i].equals("L")) {
        easiness = false;
        break;
      }
    }
    for(int i=1;i<length;i+=2) {
      if(str[i].equals("R")) {
        easiness = false;
        break;
      }
    }
    
    if(easiness) {
      System.out.println("Yes");
    }
    else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23764
import sys
def solve():
    sys.setrecursionlimit(100000)
    
    N = int(input())
    b = list(map(int, input().split()))

    ans = []

    i = N-1
    while i >= 0:
        if b[i] == i + 1:
            ans.append(b[i])
            del b[i]
            i = len(b) - 1
        else:
            i -= 1

            if i == -1:
                print(-1)
                exit(0)
    
    print(*ans[::-1], sep="\n")

if __name__ == '__main__':
    solve()

Measured memory_bytes: 38512
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

  int n;
  cin >> n;
  lol a[n + 5];
  rep(i, n){
    cin >> a[i];
  }
  lol ans = 0;
  bool in, de;
  in = de = false;
  rep(i, n - 1){
    if(in){
      if(a[i] > a[i + 1]){
	in = false;
      }
    } else if(de){
      if(a[i] < a[i + 1]){
	de = false;
      }
    } else {
      if(a[i] < a[i + 1]){
	in = true;
	ans ++;
      } else if(a[i] > a[i + 1]){
	de = true;
	ans ++;
      }
    }
  }
  if(!in && !de){
    ans ++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
n,m=map(int,input().split())
graph = [[] for _ in range(n)]
for i in range(m):
    a, b=map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

def dfs(v, seen):
    if all(seen):
        return 1
    ans=0
    for i in graph[v]:
        if seen[i]:
            continue
        seen[i]=True
        # print(seen)
        ans+=dfs(i, seen)
        seen[i]=False
    return ans

seen=[False]*n
seen[0]=True
print(dfs(0, seen))


Measured memory_bytes: 9156
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

int main() {

	const i64 A = read_item();
	const i64 V = read_item();
	const i64 B = read_item();
	const i64 W = read_item();
	const i64 T = read_item();

	if(V <= W) {
		printf("NO\n");
		return 0;
	}

	i64 diff = abs(A - B);
	bool ok = (V - W) * T >= diff;
	printf("%s\n", ok ? "YES" : "NO");

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 3596
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

auto main() -> int {
  int N;
  std::cin >> N;

  std::vector<int> ps(N);
  for (auto& pi : ps) {
    std::cin >> pi;
  }
  std::sort(ps.begin(), ps.end(), std::greater<int>{});

  int ans = std::accumulate(ps.cbegin() + 1, ps.cend(), ps.front() / 2);
  std::cout << ans << std::endl;
}


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

#define loop(n, i) for(int i=0;i<n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using vec = vector<T>;

int main() {
    int n; cin >> n;
    vec<ll> A(n);
    loop (n, i) cin >> A[i];
    loop (n, i) A[i] -= i;
    sort(A.begin(), A.end());
    ll b = A[n / 2];
    ll ans = 0;
    loop (n, i) ans += abs(A[i] - b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
  int x, y, z;

  scanf("%d%d", &x, &y);
  if(x > y)
    {
      x = x % y;
      for(z = x; z > 0; z--)
	{
	  if((x % z) == 0 && (y % z) == 0) break;
	}
    }
  else if(x < y)
    {
      y = y % x;
      for(z = y; z > 0; z--)
	{
	  if((x % z) == 0 && (y % z) == 0) break;
	}    
    }
  else z = x; 
  printf("%d\n", z);

  return 0;
}

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main(){
    ll n,a,b;
    cin>>n;
    cin>>a>>b;

    ll ans;
    if(abs(a-b)%2==0){
        ans = abs(a-b)/2;
    }else{
        ll at,ab,bt,bb;
        at = abs(n-a);
        bt = abs(n-b);
        ab = abs(a-1);
        bb = abs(b-1);
        ll stnt,stnb;
        ll elst,elsb;
        if(at>bt){
            stnt = at;
            elst = bt;
        }else{
            stnt = bt;
            elst = at;
        }
        if(ab>bb){
            stnb = ab;
            elsb = bb;
        }else{
            stnb = bb;
            elsb = ab;
        }
        if(stnb>stnt){
            ans = elst + (abs(elst-stnt)-1)/2 +1;
        }else{
            ans = elsb + (abs(elsb-stnb)-1)/2 +1;
        }
    }
    cout<<ans<<endl;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	lli n;
	cin>>n;

	map<string,lli> ans;
	for(lli i=0;i<n;i++){
		string s;
		cin>>s;

		//ここで受け取った文字列sを辞書順最小にソートする
		sort(s.begin(),s.end());
		//ここで受け取った文字列sを辞書順最小にソートする

		ans[s]++;
	}
	lli sum = 0;

	for(auto e:ans){
		lli tmp = e.second*(e.second-1)/2;
		sum += tmp;
	}
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <random>
#include <iomanip>
#include <functional>
#include <list>
using namespace std;

long long bin_pow(long long n, long long p)
{
	long long res = 1;
	if (p == 0)
		return res;

	if (p & 1)
	{
		res *= n;
		p--;
	}

	long long half_res = bin_pow(n, p / 2);
	res = res * half_res * half_res;

	return res;
}

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

	long long k;
	cin >> k;

	const long long days = 5000000000000000ll;

	char found_char = s[0];
	long long past_chars = 0;
	for (char c : s)
	{
		long long m = c - '0';
		if (m > 1)
			past_chars += k;
		else
			past_chars++;
		if (past_chars >= k)
		{
			found_char = c;
			break;
		}
	}

	cout << found_char;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  if(!(N[1] == N[2])) cout << "No" << endl;
  else if(N[0] == N[1] || N[3] == N[2]){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 10000000;
int eratoes[maxn+1];
long long number_of_factors(long long a){
	if(a==1) return 1;
	long long ret = 1;
	long long temp = a;
	vector<int>primes;
	while(a!=1){
		primes.push_back(eratoes[a]);
		a/=eratoes[a];
	}
	sort(primes.begin(),primes.end());
	int counter = 0;
	int curr = primes[0];
	for(int i=0; i<primes.size(); i++){
		if(primes[i]==curr) counter++;
		else{
			ret*=(counter+1);
			counter = 1;
			curr = primes[i];
		}
	}
	ret*=(counter+1);
	return ret; 
}
int main(){

	for(long long i=2; i<=maxn; i++) eratoes[i] = i;
	for(long long i=2; i*i<=maxn; i++){
		if(eratoes[i]==i){
			for(long long j=i*i; j<=maxn; j+=i) eratoes[j] = i;
		}
	}
	int n;
	cin>>n;
	long long ret = 0;
	for(long long i=1; i<=n; i++){
		ret+=i*number_of_factors(i);
	}
	cout<<ret;
}

Measured memory_bytes: 42640
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL A, B;

int main()
{
	in >> A >> B;
	out << std::max({ A + B, A - B, A * B });
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll>a[1000];
	vector<ll>st;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n-1;j++){
			ll x;
			cin>>x;
			x--;
			a[i].push_back(x);
		}
		reverse(a[i].begin(),a[i].end());
		st.push_back(i);
	}
	ll cnt=0;
	while(st.size()!=0){
		cnt++;
		bool ok[1000];
		for(ll i=0;i<n;i++){
			ok[i]=false;
		}
//		cout <<cnt<<endl;
		while(st.size()!=0){
			ll now=st.back();
			st.pop_back();
			ll next=a[now].back();
			if(ok[now]||ok[next]){
				continue;
			}
			if(a[next].back()==now){
				ok[now]=true;
				ok[next]=true;
				a[now].pop_back();
				a[next].pop_back();
			}
		}
		for(ll i=0;i<n;i++){
		//	cout << i <<ok[i]<<endl;
			if(ok[i]==true&&a[i].size()!=0){
				st.push_back(i);
			}
		}
	}
	for(ll i=0;i<n;i++){
		if(a[i].size()){
			cout <<-1;
			return 0;
		}
	}
	cout << cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n,m;
    cin >> n >> m;
    vector<pair<int, int> > lst;
    rep(i,m){
        ll ta,tb;
        cin >> ta >> tb;
        lst.push_back(make_pair(tb,ta));
    }
    sort(lst.begin(),lst.end());
    int cnt=0;
    int last=0;
    rep(i,m){
        if(lst[i].second>last){
            last=lst[i].first-1;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 1400
import sys
def input(): return sys.stdin.readline().strip()

class BIT:

    """
    https://tjkendev.github.io/procon-library/python/range_query/bit.html
    Binary index treeの実装
    配列[a1, a2,...,an]に対して以下のクエリをO(logn)で行う:
        1. aiにxを加える
        2. 区間和 ai + a(i+1) + ... + aj の和を求める
    isom法を使えば、
        1. aiの値を取得する
        2. 区間[i, j]の全ての数にxを加算する
    もO(logN)で行うことができる
    """

    def __init__(self, n):
        """
        添字は1スタート
        """
        self.n = n
        self.data = [0] * (n + 1)
        self.el = [0] * (n + 1)

    def add(self, i, x):
        """
        i>0に対してaiにxを加算(x < 0でもOK)
        """
        if i <= 0 or self.n < i:
            print("i should be within 1 to n")
        else:
            self.el[i] += x
            while i <= self.n:
                self.data[i] += x
                i += i & -i

    def sum(self, i):
        """
        添字1からiまでの累積和を求める
        """
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    def get(self, i, j=None):
        """
        添字iからjまでの累積和を求める
        j=Noneの場合はaiの値を返す
        """
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i - 1)


def main():
    N = int(input())
    A = list(map(int, input().split()))

    """
    決め打ち二分探索な匂いがする。
    ans <= Xとするとこれはmedian[l, r] <= XなるものがN * (N + 1) // 4個より多く存在することに同値。
    median[l, r] <= Xなるペア[l, r]の個数は以下の用にして求まる：

    １、所与の数列の各元に対して、それがX以下なら-1、Xより大なら+1に置き換える。
    ２、その数列の累積和をとり、先頭に0を追加。
    ３、この数列の転倒数(i < j s.t.A[i] > A[j])を数えると、その個数がmedian[l, r] <= Xなるものの個数になっている。

    転倒数を求めるには分割統治法かBITを使う方法があるが、前者はソート前の配列をコピーする必要があるので
    計算量的に好ましくない？よって後者で実装する。

    この時数列中の数は正であることと、BITの葉ノードは数列中の数のうち最大のものにすることが要求されるが
    今回の場合累積和をとった数列Bの要素は-N以上N以下なのでN + 1の下駄を履かせれば良い。（N <= 10^5なので初期化は十分間に合う）
    """

    left = 0
    right = 10**9
    while right - left > 1:
        #print("left={}, right={}".format(left, right))
        mid = (left + right) // 2
        B = [0] * (N + 1)
        for i in range(1, N + 1):
            if A[i - 1] <= mid: B[i] = B[i - 1] - 1
            if A[i - 1] > mid: B[i] = B[i - 1] + 1

        # Bの転倒数を求める
        tree = BIT(2 * N + 1) # +Nの下駄を履かせる
        cnt = 0
        for i in range(N + 1):
            tree.add(B[i] + N + 1, 1)
            cnt += tree.get(B[i] + N + 2, 2 * N + 1)
        #print("X={}, B={}, cnt={}".format(mid, B, cnt))

        if cnt > N * (N + 1) // 4: right = mid
        else: left = mid
    print(right)

if __name__ == "__main__":
    main()


Measured memory_bytes: 118764
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-09-01 11:55:56
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

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

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

int n , A[MAXN];

int solve(){
	ll sum = 0;
	for(int i = 0 ; i < n ; i++)	sum += A[i];
	if(sum % 2 != n % 2)	return 1;
	int g = 0 , cnt = 0;
	for(int i = 0 ; i < n ; i++){
		if(A[i] & 1){
			cnt++;
		}
		if(A[i] == 1)	cnt++;
	}
	if(cnt > 1)	return 2;
	for(int i = 0 ; i < n ; i++){
		if(A[i] & 1)	A[i]--;
		g = __gcd(A[i] , g);
	}
	for(int i = 0 ; i < n ; i++)	A[i] /= g;
	return 3 ^ solve();
}

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

	cin >> n;
	if(n == 1)	return cout << "Second" << endl , 0;
	for(int i = 0 ; i < n ; i++)	cin >> A[i];
	int x = solve();
	if(x == 1)	cout << "First" << endl;
	else	cout << "Second" << endl;

    return 0;
}
/*

*/

Measured memory_bytes: 4088
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            BigInteger w = sc.nextBigInteger();
            BigInteger h = sc.nextBigInteger();
            BigInteger c = sc.nextBigInteger();
            BigInteger gcd = w.gcd(h);
            System.out.println(w.divide(gcd).multiply(h.divide(gcd)).multiply(c));
        }
    }
}



Measured memory_bytes: 26412
package main

import "fmt"

type Combination struct {
	n int
	f *Factorial
}

func NewCombination(n int, m int64) *Combination {
	f := NewFactorial(n, m)
	return &Combination{n, f}
}

func (c *Combination) Combination(n, k int) int64 {
	return c.f.F[n] * c.f.Inv[k] % c.f.Mod * c.f.Inv[n-k] % c.f.Mod
}

func (c *Combination) Permutation(n, k int) int64 {
	return c.Combination(n+k-1, n-1)
}

func (c *Combination) Factorial(n int) int64 {
	return c.f.F[n]
}

type Factorial struct {
	n      int
	Mod    int64
	F, Inv []int64
}

func NewFactorial(n int, m int64) *Factorial {
	f := Factorial{n, m, nil, nil}
	f.F = make([]int64, n+1)
	f.Inv = make([]int64, n+1)
	f.F[0] = 1
	for i := 1; i <= n; i++ {
		f.F[i] = f.F[i-1] * int64(i) % f.Mod
	}
	f.Inv[n] = pow(f.F[n], f.Mod-2, f.Mod)
	for i := n; i > 0; i-- {
		f.Inv[i-1] = f.Inv[i] * int64(i) % f.Mod
	}
	return &f
}

func pow(x, n, m int64) int64 {
	if n == 0 {
		return 1
	}
	if n&1 == 0 {
		r := pow(x, n/2, m)
		return r * r % m
	}
	return x * pow(x, n-1, m) % m
}

func div(x, n, m int64) int64 {
	return x * pow(n, m-2, m) % m
}

func main() {
	var k int
	var s string
	m := int64(1e9) + 7
	fmt.Scan(&k, &s)
	c := NewCombination(k+len(s), m)
	var ans int64
	for i := 0; i <= k; i++ {
		v := pow(26, int64(i), m) * c.Combination(len(s)+k-i-1, len(s)-1) % m
		v *= pow(25, int64(k-i), m)
		v %= m
		ans += v
		ans %= m
	}
	fmt.Println(ans)
}


Measured memory_bytes: 36676
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long n=N;
        long max=(long)Math.pow(10, 15)+1;
        String res="";
        
        
        while(N>0){
            N--;
            res = res + (char)('a' + N%26);
            N = N/26;
        }
        StringBuffer ans = new StringBuffer(res);
        String hoge2 = ans.reverse().toString();
        System.out.println(ans);
    }

}

Measured memory_bytes: 39160
N = int(input())
S = sorted([int(input()) for _ in range(N)])
 
m = 0
for s in S:
  if s % 10 != 0 and m == 0:
    m = s
    break
ans = sum(S)
if ans % 10 != 0:
  print(ans)
elif m != 0:
  print(ans-m)
else:
  print(0)

Measured memory_bytes: 62468
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

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

    if (K == 0) {
        ll ans = N * N;
        cout << ans << endl;
        return 0;
    }

    ll ans = 0;
    rep(b, K + 1, N + 1) {
        ll n = (N + 1) / b;
        ll d = 0;

        d += 1LL * (b - K) * n;

        ll L = K + b * n;
        ll R = N;
        if (L <= R) d += R - L + 1;

        ans += d;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main(void){
    int n; cin >> n;
    string s; cin >> s;

    int ans = 0;
    for(int i = 0; i < n; i++){
        map<char, int> mpx, mpy;
        for(int j = 0; j <= i; j++){
            // X
            mpx[s[j]]++;
        }
        for(int j = i + 1; j < n; j++){
            // Y
            mpy[s[j]]++;
        }

        int tmp_ans = 0;
        for(int k = 0; k < 26; k++){
            if(mpx[char('a'+k)] >= 1 && mpy[char('a'+k)] >= 1){
                tmp_ans++;
            }
        }
        ans = max(ans, tmp_ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <limits>

typedef long long ll;
typedef std::vector< int > VI;

const double EPS = 1e-10;
const double PI  = acos(-1);
const ll     INF = 1 << 30;

ll gdb_exec(ll a, ll b) {
  if (b == 0) return a;
  return gdb_exec(b, a % b);
}

ll gdb(ll a, ll b) {
  if (a < b) std::swap(a, b);
  if (a == 0 || b == 0) return -999999999;
  return gdb_exec(a, b);
}

ll lcm(ll a, ll b) {
  ll gdb_val = gdb(a, b);
  if (a % gdb_val == 0) {
    return (a / gdb_val) * b;
  }
  return (b / gdb_val) * a;
}

std::string to_string(long long val)
{
  char buf[1024];
  sprintf(buf, "%lld", val);
  return buf;
}

int main(int argc, char* argv[])
{
  ll n;
  std::cin >> n;

  ll sqrt_num = std::floor(std::sqrt(n));
  //std::cout << sqrt_num << std::endl;

  ll ans = INF;
  for (ll i = sqrt_num; i >= 1; i--) {
    if (n % i == 0) {
      ll keta_a = std::log10((double)i) + 1;
      ll keta_b = std::log10((double)(n/i)) + 1;
      ans = std::min(ans, std::max(keta_a, keta_b));
    }
  }
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 512
#include <stdint.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

map<ll, ll> m;
vector<vector<ll>> qq;
ll NN;
ll c = 0;
vector<ll> VV;
vector<ll> WW;

void dfs(ll n) {
  if (n > NN) {
    return;
  }
  m.insert({n, c});
  c++;
  dfs(n * 2);
  dfs(n * 2 + 1);
}

ll dp[20][100010];
ll cur = 0;
ll ans[(size_t)1e5];
ll cur2 = 0;

void dfs2(const ll n, const ll depth) {
  if (n > NN) {
    return;
  }
  const ll kTh = 9;
  if (depth <= kTh) {
    REP(w, 100001) {
      if (w >= WW[n - 1]) {
        dp[depth][w] = max(dp[depth - 1][w - WW[n - 1]] + VV[n - 1], dp[depth - 1][w]);
      } else {
        dp[depth][w] = dp[depth - 1][w];
      }
    }
  }
  while (cur < qq.size() && qq[cur][1] == n) {
    ll z = qq[cur][2];
    if (depth <= kTh) {
      ans[qq[cur][3]] = dp[depth][z];
    } else {
      vector<pair<ll, ll>> v;
      v.reserve(pow(2, depth - kTh));
      v.emplace_back(0, 0);
      ll nn = n;
      ll ddepth = depth;
      while (ddepth > kTh) {
        ll vs = v.size();
        REP(j, vs) {
          v.emplace_back(v[j].first + VV[nn - 1], v[j].second + WW[nn - 1]);
        }
        ddepth--;
        nn /= 2;
      }
      ll m = 0;
      REP(i, v.size()) {
        if (z >= v[i].second) {
          m = max(m, v[i].first + dp[ddepth][z - v[i].second]);
        }
      }
      ans[qq[cur][3]] = m;
    }
    cur++;
  }
  dfs2(n * 2, depth + 1);
  dfs2(n * 2 + 1, depth + 1);
}

void solve(long long N, std::vector<long long> V, std::vector<long long> W, long long Q, std::vector<long long> v,
           std::vector<long long> L) {
  VV.swap(V);
  WW.swap(W);
  NN = N;
  dfs(1);
  qq.resize(Q);
  REP(i, Q) {
    qq[i] = {m[v[i]], v[i], L[i], i};
  }
  sort(ALL(qq));
  dfs2(1, 1);
  REP(i, Q) {
    cout << ans[i] << endl;
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> V(N);
  std::vector<long long> W(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &V[i]);
    scanf("%lld", &W[i]);
  }
  long long Q;
  scanf("%lld", &Q);
  std::vector<long long> v(Q);
  std::vector<long long> L(Q);
  for (int i = 0; i < Q; i++) {
    scanf("%lld", &v[i]);
    scanf("%lld", &L[i]);
  }
  solve(N, std::move(V), std::move(W), Q, std::move(v), std::move(L));
  return 0;
}


Measured memory_bytes: 40704
n,m=gets.split.map &:to_i
a=[]
a<< [true,1]
(n-1).times do
  a<< [false,1]
end
m.times do
  b,c=gets.split.map{|i|i.to_i-1}
  if a[b][0]==true
    a[c][0]=true
  end
  a[c][1]+=1
  a[b][1]-=1
  if a[b][1]==0
    a[b][0]=false
  end
end
c=0
a.each do |e|
  c+=1 if e[0]
end
p c

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

using namespace std;

int main(){
    int n, N, R;
    cin >> n;

    vector<int> as(n);
    for(size_t i = 0; i < n; ++i)
        cin >>as.at(i);
    sort(as.begin(), as.end());

    N = as[n-1];

    R = INT_MAX;
    for(int i = 0; i < n; ++i)
    {
        if(abs(as[i]-(double)N/2) < abs(R - (double)N/2))
            R = as[i];
    }

    cout << N << " " << R << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define vi vector<ll>
#define vvi vector<vi>
#define llINF 1e18
#define ll long long
using namespace std;
bool vis[2510];
struct Edge{
  ll to,cost;
};
const ll MAX_V=2510;
vector<vector<Edge>> E(MAX_V);
vi dist(MAX_V,llINF);
bool bellman_ford(ll s){
  queue<ll>que;
  que.push(s);
  dist[s]=0;
  for(int i = 0;i < MAX_V;i++){
    ll n = que.size();
    set<ll>se;
    for(int j = 0;j < n;j++){
      ll now=que.front();
      que.pop();
      for(int k = 0;k < E[now].size();k++){
	Edge e = E[now][k];
	if(dist[e.to] > dist[now] + e.cost){
	  dist[e.to] = dist[now] + e.cost;
	  if(i == MAX_V-1)
	    if(vis[e.to])
	      return true;
	  se.insert(e.to);
	}
      }
    }
    for(auto a:se)que.push(a);
  }
  return false;
}
vvi E2(MAX_V);
int main(){
  ll n,m,p;
  cin>>n>>m>>p;
  for(int i=0;i<m;i++){
    ll a,b,c;cin>>a>>b>>c;
    E[--a].push_back({--b,-(c-p)});
    E2[b].push_back(a);
  }
  queue<ll>que;
  que.push(n-1);
  vis[n-1]=true;
  while(que.size()){
    ll hoge=que.front();que.pop();
    for(auto a:E2[hoge])
      if(vis[a]==false){
	que.push(a);
	vis[a]=true;
      }
  }
  if(bellman_ford(0)==false){
    cout<<max(0LL,-dist[n-1])<<endl;
  }else cout<<-1<<endl;
}


Measured memory_bytes: 768
N = int(input())
X = [int(i) for i in input().split()]
a = X[:]
a.sort()
l = a[N//2-1]
r = a[N//2]
if l == r:
    for i in range(N):
        print(l)
else:
    for i in range(N):
        if X[i] <= l:
            print(r)
        elif X[i] >= r:
            print(l)

Measured memory_bytes: 25344
from sys import stdin
A, B = [int(x) for x in stdin.readline().rstrip().split()]
def binary_(A):
    A += 1
    n = 0
    ans = 0
    while 2 ** n <= A:
        a = 2 ** n
        a_ = a * 2
        b = A // a_
        b = b * a
        c = A % a_
        if c > a:
            d = (b + c - a) % 2
            ans += a * d
        elif c == 0:
            d = b % 2
            ans += a * d
        else:
            d = b % 2
            ans += a * d
        n += 1
    return ans
print(binary_(A-1) ^ binary_(B))

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  string S, T; cin>>S>>T;
  REP(i,N) {
    cout << S[i] << T[i];
  }
  cout << endl;
  return 0;
}


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

using namespace std;

int main(){
	int N,K;

	cin >> N >> K;
	
	int h[N];
	int dp[N];
	
	for(int i=0; i<N ;i++){
		cin >> h[i];
	}
	
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2; i<N; i++){
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		for(int j=2; j<=K && j<=i; j++){
			dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
	
	cout << dp[N-1] << endl;
	
	return 0;
}

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

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

  int d0 = 0, d1 = 0;
  int i = 0;
  for(char c: s) {
    if(i % 2 == 0) {
      if(c == '0') d1 += 1;
      if(c == '1') d0 += 1;
    } else {
      if(c == '1') d1 += 1;
      if(c == '0') d0 += 1;
    }
    i++;
  }

  cout << min(d0, d1) << endl;

  return 0;
}


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

int n, m, an[3001][3001][2], md = 1e9 + 7;

inline void ad(int &x, int y) { if ((x += y) >= md)x -= md; }

int main(){
	scanf("%d%d", &n, &m);
	f(i, 0, n + 1)an[0][i][0] = 1;
	f(i, 0, m)f(j, 0, n + 1){
		int &o = an[i][j][1], &z = an[i][j][0];
		if (j == 1)ad(an[i + 1][j][1], z), ad(an[i + 1][j][1], o), ad(an[i + 1][j - 1][1], z), ad(an[i + 1][j - 1][1], o);
		else if (j)ad(an[i + 1][j][0], z), ad(an[i + 1][j][1], o), ad(an[i + 1][j - 1][0], z), ad(an[i + 1][j - 1][1], o);
		if (!j)ad(an[i + 1][j][1], o), ad(an[i + 1][j][1], z), ad(an[i + 1][j + 1][1], o), ad(an[i + 1][j + 1][1], z);
		else if (j != n)ad(an[i + 1][j][1], o), ad(an[i + 1][j][0], z), ad(an[i + 1][j + 1][1], o), ad(an[i + 1][j + 1][0], z);
	}
	int a = 0;
	f(i, 0, n + 1)if ((a += an[m][i][1]) >= md)a -= md;
	printf("%d\n", a);
}

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

int main(){
    ll h,n;
    cin>>h>>n;
    ll sum=0;
    rep(i,n){
        ll a;
        cin>>a;
        sum+=a;
    }
    if(h<=sum){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


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

int mp[19][19];
vector<long long> pre;
int n;
void dfs(vector<long long>& curr,vector<int>& not_taken,int index,int currMask,int oldmask){
    if(index == not_taken.size()){
      curr[oldmask|currMask] = max(pre[currMask]+curr[oldmask],curr[oldmask|currMask]);
      return ;
    }
    dfs(curr,not_taken,index+1, currMask ,oldmask);
    dfs(curr,not_taken,index+1, currMask|(1<<not_taken[index]),oldmask );
}
int main(){
    cin>>n;
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            cin>>mp[i][j];
        }
    }
    // pre process
    pre = vector<long long>(1<<n,0);
    for(int mask=0;mask<(1<<n);++mask){
        for(int i=0;i<n;++i){
            for(int j=i+1;j<n;++j){
                if( (mask & (1<<i)) > 0 && (mask & (1<<j)) >0 ){
                    pre[mask] += (1ll * mp[i][j]);
                }
            }
        }
    }

    vector<long long> dp(1<<n,0);
        for(int mask=0;mask<(1<<n);++mask){
            vector<int> not_taken;
            for(int j=0;j<n;++j){
                if((mask & (1<<j))==0){
                    not_taken.push_back(j);
                }
            }
            dfs(dp,not_taken,0,0,mask);
        }
    cout<<dp[(1<<n)-1]<<endl;
    
    return 0;
}


Measured memory_bytes: 1280
#define _USE_MATH_DEFINES

#include <iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

int main()
{
	ll n;
	//ll a[200000];
	vector<ll> a;

	cin >> n;
	ll sum = 0;
	for (ll i = 0; i < n; i++) {
		ll temp;
		cin >> temp;
		a.push_back(temp);
		sum += temp;
	}

	ll answer = ll(10e16);

	ll parts=0;
	for (int i = 0; i < n - 1; i++) {
		parts += a[i];
		if (answer >llabs(sum - 2 * parts)) {
			answer = llabs(sum - 2 * parts);
		}
	}

	cout << answer;



	return 0;
}

Measured memory_bytes: 2420
#include <cstdio>

using u32 = unsigned int;

int n;
bool S[2999];
u32 dp[3001];

constexpr u32 mod = 1000000007;

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n-1; i++){
    char c;
    do { scanf("%c", &c); } while(c != '>' && c != '<');
    S[i] = c == '>';
  }

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

  for(int i = 0; i < n-1; i++){
    if(S[i]){
      for(int j = 0; j < n - i; j++){
        dp[j] = dp[j+1];
      }
      for(int j = n-i-3; j >= 0; j--){
        dp[j] += dp[j+1];
        if(dp[j] >= mod) dp[j] -= mod;
      }
    }
    else {
      for(int j = 0; j < n - i - 1; j++){
        dp[j] += dp[j-1];
        if(dp[j] >= mod) dp[j] -= mod;
      }
    }
//    for(int j = 0; j < n - i; j++) printf("%d ", dp[j]);
//    puts("");
  }

  printf("%d\n", dp[0]);

  return 0;
}


Measured memory_bytes: 128
import heapq

n,m = map(int,input().split())
li = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(li)
for _ in range(m):
    tmp_min = heapq.heappop(li)
    heapq.heappush(li, (-1)*(-tmp_min//2))  # 計算誤差の関係で-1を2回かけてます
print(-sum(li))

Measured memory_bytes: 14252
k, a, b = map(int, input().split()) 
biscet = 1

rate = (b-a)/2

if ( rate > 1):
    k-=(a-1)
    biscet+=(a-1)
    biscet += int(k/2) * (b-a)
    biscet += k%2
    
else:
    biscet += k    

print(biscet)

Measured memory_bytes: 9192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args)
    {
        FastReader sc = new FastReader();
        int n = sc.nextInt();

        int arr[] = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        if(n == 1) {
            System.out.println(arr[0]);
            return;
        }
        int left[] = new int[n];
        int right[] = new int[n];
        left[0] = arr[0];
        right[n-1] = arr[n-1];

        for (int i = 1; i < n; i++) {
            left[i] = left[i-1] ^ arr[i];
        }

        for (int i = n-2; i >= 0; i--) {
            right[i] = right[i+1] ^ arr[i];
        }

        System.out.print(right[1] + " ");
        for(int i=1;i<n-1;i++){
            System.out.print((left[i-1] ^ right[i+1]) + " ");
        }
        System.out.print(left[n-2]);
    }
}

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

int mod = 998244353;

long long modpow(long long x, long long y){
    if (y == 0) return 1;
    if (y % 2) return x * modpow(x, y - 1) % mod;
    return modpow(x, y / 2) * modpow(x, y / 2) % mod;
}

int main(){
    int n;
    cin >> n;
    vector<int> cnt(n, 0);
    int x;
    cin >> x;
    if (x != 0){
        cout << 0 << endl;
        return 0;
    }
    cnt[x]++;
    for (int i = 1; i < n; i++) cin >> x, cnt[x]++;
    int num = 0;
    for (int i = 0; i < n; i++){
        if (cnt[i] == 0) break;
        num += cnt[i];
    }
    if (cnt[0] != 1 || num != n) {
        cout << 0 << endl;
        return 0;
    }
    long long ans = 1;
    for (int i = 1; i < n; i++){
        if (cnt[i] == 0) break;
        ans *= modpow(cnt[i - 1], cnt[i]);
        ans %= mod;
    }
    cout << ans << endl;
}

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

using namespace std;

//#define TEST

void swap(int* x, int* y) {
	*x = (*x) ^ (*y);
	*y = (*x) ^ (*y);
	*x = (*x) ^ (*y);
}

signed main() {
	int n; cin >> n;
	bool* X = new bool[n + 1];
	bool* Y = new bool[n + 1];
	for (int i = 0; i <= n; ++i) {
		X[i] = false;
		Y[i] = false;
	}
	vector<pair<int, int>> stones(n);
	for (int i = 0; i < n; ++i) {
		int x, y; cin >> x >> y;
		if (X[x] || Y[y]) {
			cout << -1 << endl;
			return 0;
		}
		X[x] = Y[y] = true;
		stones[i] = make_pair(x, y);
	}

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

#ifdef TEST
	cout << "----------" << endl;
	for (auto si : stones) {
		cout << si.first << " " << si.second << endl;
	}
	cout << "----------" << endl;
#endif

	int* idx = new int[n + 1];
	for (int i = 0; i < n; ++i)
		idx[stones[i].second] = i;

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (stones[i].first == stones[i].second) continue;
		int tmp = stones[i].second;
		swap(&(stones[idx[i + 1]].second), &(stones[i].second));
		swap(&(idx[tmp]), &(idx[i + 1]));
		ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4148
import java.util.*;

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

        String S = sc.next();

        for (int i=0; i<3; i++) {
            if (S.charAt(i) == S.charAt(i+1)) {
                System.out.println("Bad");
                return;
            }
        }
        System.out.println("Good");
    }
}



Measured memory_bytes: 22228