akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    SPEED
    ll n;
    cin >> n;
    vector<ll> h(n);
    for (auto &e : h) {
        cin >> e;
    }
    ll run = 1;
    ll ans = 0;
    FOR(i, 0, n) {
        if (i + 1 < n && h[i] >= h[i + 1]) {
            run++;
        } else {
            ans = max(ans, run - 1);
            run = 1;
        }
    }
    cout << ans;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting, graph is not a tree/connected
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 1024
object Main extends App {

  val n = scala.io.StdIn.readInt()
  val pArr = scala.io.StdIn.readLine().split(" ").map(_.toInt)


  def solve() = {
    var cnt = 0
    for(i <- 1 until n-1) {
      val list = Seq(pArr(i-1), pArr(i), pArr(i+1)).sorted
      if(list(1) == pArr(i)) cnt += 1
    }
    cnt
  }

  println(solve)

}


Measured memory_bytes: 25400
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    a = s.count("a")
    b = s.count("b")
    c = s.count("c")
    x = [a, b, c]
    x.sort()
    if x[2] - x[0] > 1 or x[2] - x[1] > 1:
        print("NO")
    else:
        print("YES")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 40176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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 (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> ans(n, 0);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = n-1; i >= 0; i--) {
        int cnt = 0;
        for(int j = 2*i+1; j < n; j += i+1) {
            cnt += ans[j];
        }
        if((cnt&1)^(a[i]&1)) {
            ans[i] = 1;
        }else{
            ans[i] = 0;
        }
    }
    int r = count(ans.begin(), ans.end(), 1);
    cout << r << endl;
    for(int i = 0; i < n; i++) {
        if(ans[i] == 1) cout << i + 1 << endl;
    } 
}

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

int main() {
	string a1,a2;
	cin>>a1>>a2;
    string b1=a2;string b2=a1;
	reverse(b2.begin(),b2.end());
	reverse(b1.begin(),b1.end());
	if(a1==b1&&a2==b2)
	cout<<"YES";
	
	else
	cout<<"NO";
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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 bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

/*
    ワーシャルフロイド法
    vvc<ll> dist(n,vc<ll>(n,INF));
    
    下のようにして距離を保存してください
    rep(i,m){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    
    distに i -> j の最短距離が入ります
    dist[i][j] が負の値の場合　負閉路です
*/

void war(vvc<ll>& dist){
    ll n = SIZE(dist);
    rep(k,n) rep(i,n) rep(j,n){
        chmin(dist[i][j], dist[i][k] + dist[k][j]);
    }
}

int main(){
    cout << fixed << setprecision(20);
    ll n = 10;
    vvc<ll> dist(n,vc<ll>(n,INF));
    ll h,w; cin >> h >> w;
    rep(i,10){
        rep(j,10){
            cin >> dist[i][j];
            if(i == 1) dist[i][j] = 0;
        }
    }
    war(dist);
    ll ans = 0;
    rep(i,h){
        rep(j,w){
            int x; cin >> x;
            if(x == -1) continue;
            ans += dist[x][1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
L = [0]*M
R = [0]*M
for i in range(M):
    l,r = map(int,input().split())
    L[i] = l
    R[i] = r

if min(R)-max(L)<0:
    print(0)
else:
    print(min(R)-max(L)+1)

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

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

  ll q,h,s,d;cin>>q>>h>>s>>d;
  ll n;cin>>n;
  s = min(s, min(4*q, h*2));

  if (s*2<d){
    cout<<n*s<<endl;
  }else {
    if(n%2==0){
      cout<<(n / 2) * d<<endl;
    }else {
      cout<<(n / 2) * d + s<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

       int k;
       string s;
        cin>>k>>s;

          if(s.length() <= k)
           cout<<s;

          else{
             string g = s.substr(0,k);
              g = g + "...";
              cout<<g;
          }
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main (){
int a,b,c;
cin>>a>>b>>c;


if (a==b&a!=c){
    cout<<c;
}
else if (a==c&a!=b){
    cout<<b;
}
else if (b==a&b!=c){
    cout<<c;
}
else if (b==c&b!=a){
    cout<<a;
}
else if (c==a&c!=b){
    cout<<b;
}
else if (c==b&c!=a){
    cout<<a;
}
return 0;



}


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

int main() {
	int x; 
	vector<int> v(3);
	cin>>v[0]>>v[1]>>v[2];

	sort(v.begin(), v.end());
	int c = 0;
	for(auto it = v.begin(); it !=v.end(); it++)
	{
		c++;
		if(c==v.size()) cout << *it ;
		else cout << *it << " ";
	}
	cout<<'\n';
	return 0;
}


Measured memory_bytes: 3120
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		int K = sc.nextInt();
		int N = sc.nextInt();
		List<Integer> A = new ArrayList<>();
 
		for (int i=0; i<N; i++) {
			A.add(sc.nextInt());
		}
		
		Collections.sort(A);
		
		int max = 0;
		for (int i=0; i<N - 1; i++) {
			int kyori = A.get(i + 1) - A.get(i);
			max = Math.max(kyori, max);
		}
		int kyori = A.get(0) + (K - A.get(N - 1));
		max = Math.max(kyori, max);
		
		System.out.println(K - max);
	}
}

Measured memory_bytes: 88360
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    long int n = 0, sum = 0, co = 0, ans = 0;
    cin >> n;
    long int x[n];
    for(int i = 0 ; i < n ; i++){
        cin >> x[i];
        sum += x[i];
    }
    co = round(double(sum) / n);
    for(int i = 0 ; i < n ; i++){
        ans += pow(x[i] - co, 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main(){
	int N,K;
	long long L,R;
	scanf("%d%d%lld%lld",&N,&K,&L,&R);
	int n=N/2;
	vector<long long>v(N);
	for(int i=0;i<N;i++)scanf("%lld",&v[i]);
	multiset<pair<int,long long>>se1;
	vector<pair<int,long long>>se2;
	for(int i=0;i<1<<n;i++){
		int m=0;
		long long V=0;
		for(int j=0;j<n;j++)if(i&(1<<j))m++,V+=v[j];
		se1.emplace(m,V);
	}
	for(int i=0;i<1<<(N-n);i++){
		int m=0;
		long long V=0;
		for(int j=0;j<(N-n);j++)if(i&(1<<j))m++,V+=v[j+n];
		se2.emplace_back(m,V);
	}
	sort(se2.begin(),se2.end());
	long long r=0;
	for(auto &e1:se1){
		//?????°=K-e1.first
		//????¨?=L-e1.second??\???R-e1.second??\???
		auto it1=lower_bound(se2.begin(),se2.end(),make_pair(K-e1.first,L-e1.second));
		auto it2=upper_bound(se2.begin(),se2.end(),make_pair(K-e1.first,R-e1.second));
		r+=distance(it1,it2);
	}
	printf("%lld\n",r);
}

Measured memory_bytes: 84568
N, K = map(int, input().split())

total = (N - 1) * (N - 2) // 2
if K > total:
    print(-1)
else:
    edges = []
    for k in range(2, N + 1):
        edges.append([1, k])

    res = total - K
    cnt = 0
    for u in range(2, N + 1):
        if cnt == res:
            break
    
        for v in range(u + 1, N + 1):
            edges.append([u, v])
            cnt += 1

            if cnt == res:
                break

    print(len(edges))
    for v in edges:
        print(*v)

Measured memory_bytes: 68936
// Hovalhagh
// Ya Aziz & Hakim
// AliReza Kaboli

#include <bits/stdc++.h>

using namespace std;

const int N = 3e3 + 100;

int dp[N][N];

int main() {
	string s, t, ans;
	cin >> s >> t;
	for (int i = 1; i <= s.size(); ++i)
		for (int j = 1; j <= t.size(); ++j)
			if (s[i - 1] == t[j - 1])
				dp[i][j] = dp[i - 1][j - 1] + 1;
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
	int i = s.size(), j = t.size();
	while (i != 0 && j != 0) {
		if (s[i - 1] == t[j - 1]) {
			ans += s[i - 1];
			--i, --j;
		}
		else if (dp[i - 1][j] > dp[i][j - 1])
			--i;
		else
			--j;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
}


Measured memory_bytes: 37120
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int Vmax = 100010;

struct edge {
    int to;
    ll weight;
};

vector<edge> tree[Vmax];
ll cost_k[Vmax];

void dfs(int v, int parent, ll dist) {
    cost_k[v] = dist;

    rep(i, tree[v].size()) {
        if(tree[v][i].to == parent) {
            continue;
        }
        dfs(tree[v][i].to, v, dist + tree[v][i].weight);
    }
}

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

    rep(i, n-1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }

    int q, k;
    cin >> q >> k;
    k--;

    dfs(k, -1, 0);

    rep(i, q) {
        int x, y;
        cin >> x >> y;
        x--;  y--;
        cout << cost_k[x] + cost_k[y] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int K;
   cin >> K;
   int n = (K + 3) / 4 * 2;
   if (K == 1) {
      cout << "1" << endl;
      cout << "1" << endl;
      return 0;
   }
   cout << n << endl;
   for (int r = 0; r < n; r++) {
      if (r % 2 == 0) {
         for (int c = 0; c < n; c++) {
            cout << (r + c) % n + 1;
            if (c != n - 1) cout << " ";
         }
      } else {
         for (int c = 0; c < n; c++) {
            int tmp = (r + c) % n + n + 1;
            if (tmp > K) cout << tmp - n;
            else cout << tmp;
            if (c != n - 1) cout << " ";
         }
      }
      cout << endl;
   }
   return 0;
}


Measured memory_bytes: 1152
#include <iostream>

using namespace std;

char s[27] = {};
bool have[26] = {};
bool ans = true;
int n = 0;

int main(){
	cin >> s;
	while (s[n] != 0){
		if (have[s[n] - 'a']){
			ans = false;
		}
		else{
			have[s[n] - 'a'] = true;
		}

		n++;
	}

	if (ans){
		cout << "yes" << endl;
	}
	else{
		cout << "no" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
using namespace std;
int n,a[114514];
int p[114514],q[114514];
signed main(){
	//113459
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	int ans1=0,ans2=0;
	if(n%2){
		p[0]=a[n/2];
		q[0]=p[0];
		REP(i,n){
			if(i%2){
				p[i]=a[i/2];
				q[i]=a[n-1-i/2];
			}else {
				p[i]=a[n-i/2];
				q[i]=a[i/2-1];
			}
		}
	}else {
		p[0]=a[n/2-1];
		q[0]=a[n/2];
		REP(i,n){
			if(i%2){
				p[i]=a[n-1-i/2];
				q[i]=a[i/2];
			}else {
				p[i]=a[i/2-1];
				q[i]=a[n-i/2];
			}
		}
	}
	REP(i,n){
		ans1+=abs(p[i]-p[i-1]);
		ans2+=abs(q[i]-q[i-1]);
	}
	cout<<max(ans1,ans2)<<endl;
}
	
	


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define fi first
#define se second
#define ii pair<int, int>
//#define int long long
using namespace std;

const int INF = 1e18;
int n, ans;
string s;
int tree[26][500005];

void upd(int p, int type, int val)
{
    for (int i = p; i <= n; i += i & -i)
        tree[type][i] += val;
}

int get(int p, int type)
{
    int sum = 0;
    for (int i = p; i; i -= i & -i)
        sum += tree[type][i];
    return sum;
}

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

    cin >> n >> s;
    for (int i = 0; i < n; i++)
        upd(i+1, s[i] - 'a', 1);
    int q;
    cin >> q;
    while(q--)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int pos;
            char x;
            cin >> pos >> x;
            upd(pos, s[pos-1] - 'a', -1);
            upd(pos, x - 'a', 1);
            s[pos-1] = x;
        } else {
            int l, r;
            cin >> l >> r;
            int ans = 0;
            for (int i = 0; i < 26; i++)
                if (get(r, i) - get(l-1, i))
                    ans++;
            cout << ans << "\n";
        }
    }

}


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

// input
string S;


void input() {
    cin >> S;
}


int main() {
    input();
    set<char> s{'A', 'C', 'G', 'T'};
    int n = S.size();
    int ans = 0;
    int i, c= 0;
    while (i < n) {
        if (s.count(S[i])) {
            c++;
            ans = max(ans, c);
        } else {
            c = 0;
        }
        i++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include<stdio.h>
#include<string.h>

int main(void) {
  int k;
  char s[101];
  scanf("%d", &k);
  scanf("%s", s);
  int i;
  if(strlen(s) <= k) {
    printf("%s\n", s);
  }
  else {
    for(i=0; i<k; i++) {
      printf("%c", s[i]);
    }
    printf("...\n");
  }
  
  return 0;
}

Measured memory_bytes: 1624
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
check_list = []
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        check_list.append(1)
    else:
        check_list.append(0)
flag = 0
for i in range(n - 2):
    if sum(check_list[i:(i+3)]) == 3:
        flag = 1
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9192
program speedrun
implicit none
integer N
character(100),allocatable,dimension(:)::s
integer,allocatable,dimension(:)::t
character(100)::x

integer::i
logical::sleep=.false.
integer::ans=0
read*,N
allocate(S(N),t(N))
do i=1,N
    read*,S(i),t(i)
end do
read*,x
do i=1,N
    if(sleep)ans=ans+t(i)
    if(S(i)==X)sleep=.true.
end do
print"(i0)",ans
end program speedrun

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define mo 1000000007
int sum[60];
int main(){
	LL x,ans=0;int n;scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&x);
		for(int j=0;j<60;j++)if(x&(1ll<<j))sum[j]++;
	}
	for(int i=0;i<60;i++)ans+=(1ll<<i)%mo*sum[i]%mo*(n-sum[i])%mo;
	printf("%d",ans%mo);
	return 0;
}

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

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    int ans = X;
    for (int i = 0; i < N; i++){
        ans += (D - 1) / a[i] + 1;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  int i,j;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  int mini = -100;
  int min = 99999999;
  int tmp = 0;
  for(i=-100;i<=100;i++){
    tmp = 0;
    for(j=0;j<n;j++){
      tmp += (a[j]-i)*(a[j]-i);
    }
    if(min>tmp){
      min = tmp;
    }
  }
  cout << min;
}


Measured memory_bytes: 256
pub struct Scanner{
    line : Vec<String> ,
    idx : usize
}

impl  Scanner{
   #[allow(dead_code)]
   fn new() -> Scanner{
       return Scanner{ line: vec![], idx : 0}
   }
   #[allow(dead_code)]
   fn next<T: std::str::FromStr> (&mut self) -> T{
       if self.idx == self.line.len() {
           let mut buffer = String::new();
           std::io::stdin().read_line(&mut buffer).ok();

           let a : Vec<&str>  = buffer.trim().split(' ').collect();
           self.line = a.iter().map(|&s| String::from(s)).collect();
           self.idx = 0;
       }
       let ret : T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
       self.idx += 1;
       ret
   }
   #[allow(dead_code)]
   fn read_vec<T: std::str::FromStr>  (&mut self, n: usize) -> Vec<T>{
       let mut v : Vec<T>= Vec::with_capacity(n);
       for _i in 0..n {
           v.push(self.next());
       }
       v
   }
}


fn main() {
    let mut scan = Scanner::new();
    let s:String  = scan.next();
    let v = s.chars().collect::<Vec<char>>();

    if v[2] == v[3] && v[4] == v[5] {
        println!("Yes");
    }else{
        println!("No");
    }
}

Measured memory_bytes: 4352
#include<iostream>

int main(){
    int n ,d;
    int b = 0;

    std::cin >> n >> d;

    int a = 2 * d + 1;

    while(1){
        n -= a;
        b++;

        if(n <= 0){
            break;
        }
    }

    std::cout << b << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[3][110]; 
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=2;i++){
		for(int j=1;j<=n;j++){
			scanf("%d",&a[i][j]);
		}
	}
	a[2][1]+=a[1][1];
	for(int i=2;i<=n;i++){
		a[1][i]+=a[1][i-1];
	}
	for(int i=2;i<=n;i++){
		a[2][i]+=max(a[1][i],a[2][i-1]);
	}
	printf("%d\n",a[2][n]);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

const int MAX = 200;

int main() {
	int H, W;
	int table[10][10];
	int A[MAX][MAX];
	int ans = 0;

	cin >> H >> W;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> table[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 10; k++) {
				if (j == i || k == i)continue;
				if (table[j][k] > table[j][i] + table[i][k]) {
					table[j][k] = table[j][i] + table[i][k];
				}
			}
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (A[i][j] == -1)continue;
			ans += table[A[i][j]][1];
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi = acos(-1);
#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // メインプログラムここから
    ll n; cin >> n;
    vector<ll> L(2*n);
    REP(i, 2*n) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    ll ans = 0;
    REP(i, n) {
        ans += L[i*2];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;


void solve(long long X, long long Y, long long Z){
    cout << Z << " " << X << " " << Y << endl;
}
 
signed main(){
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long Z;
    scanf("%lld",&Z);
    solve(X, Y, Z);
    return 0;
}


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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) for(auto x:obj)cout<<x<<' ';cout<<endl;
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	string N; cin>>N;
	bool nat = true;
	REP(i,N.size()-1){
		if(N[i] != '9')nat = false;
	}
	if(nat){
		cout<<9*(N.size()-1) + N[0] - '0'<<endl ; return 0;
	}
	int ans = (N.size()-1)*9 + N[0] - '1';
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		//int n = sc.nextInt();
		System.out.println(sc.nextInt() * sc.nextInt() % 2 != 0 ? "Yes" : "No");
	}
}


Measured memory_bytes: 35688
#include<stdio.h>
#include <stdlib.h>
int main()
{
	int i, x = 7, K;
	scanf("%d", &K);
	if (K % 2 == 0 || K % 5 == 0) {
		printf("-1");
		exit(0);
	}
	for (i = 0; i <= K - 1; i++) {
		if (x%K == 0) {
			printf("%d", i+1);
			exit(0);
		}
		x = (x * 10 + 7) % K;
	}
	printf("-1");
}

Measured memory_bytes: 1736
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();
        String S = sc.nextLine();
        int K = sc.nextInt();

        char target = S.charAt(K-1);

        String ret="";
        for(int i=0;i<N;i++){
            if(S.charAt(i)==target){
                ret+=target;
            }else{
                ret+='*';
            }
        }
        System.out.println(ret);
    }
}

Measured memory_bytes: 21844
#include <iostream>

int main()
{
    constexpr int N = 45;
    
    int dp[N] {};
    
    dp[0] = 1;
    dp[1] = 1;
    
    for(int i = 2; i < N; ++i)
        dp[i] = dp[i-1] + dp[i-2];
    
    int n;
    std::cin >> n;
    std::cout << dp[n] << std::endl;
    
    return 0;
}


Measured memory_bytes: 3120
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

H, W = MAP()
N = INT()
a = LIST()

cnt = 0
ans = [[-1]*W for _ in range(H)]
tmp = a.pop(0)
color = 1
flg = 0

for i in range(H):
	for j in range(W):
		if i%2 == 1:
			j = -j-1
		ans[i][j] = color
		tmp -= 1
		if tmp == 0:
			if not a:
				break
			tmp = a.pop(0)
			color += 1



for i in ans:
	print(" ".join([str(x) for x in i]))


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

int main()
{
    string str;
    cin >> str;
    map<char, int> map1;
    
    for (char i = 'a'; i <= 'z'; i++) {
        map1[i] = 0;
    }

    for (int i = 0; i < str.length(); i++) {
        map1[str[i]]++;
    }

    for (char i = 'a'; i <= 'z'; i++) {
        if (map1[i] % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
from math import *
from collections import deque, defaultdict, Counter
from itertools import product, permutations, combinations, accumulate
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappush, heappop
from copy import copy, deepcopy

# def gyakugen(n,p): return pow(n,p-2,p) # == n**(-1) mod p # kurikaeshi jijou hou niyori kousoku

N = int(input())
es = list(map(int, input().split()))

cer = list(Counter(es).items())

if len(cer)==3:
    if cer[0][1] == cer[1][1] and cer[1][1] == cer[2][1]:
        if cer[0][0] ^ cer[1][0] == cer[2][0]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

elif len(cer)==2:
    if cer[0][0] == 0:
        if cer[0][1]*2==cer[1][1]:
            print("Yes")
        else:
            print("No")
    elif cer[1][0] == 0:
        if cer[1][1]*2==cer[0][1]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

elif len(cer)==1:
    if cer[0][0] == 0:
        print("Yes")
    else:
        print("No")

else:
    print("No")

Measured memory_bytes: 15780
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lce(a, b):
    return a * b // gcd(a, b)

N = int(input())
A = [int(i) for i in input().split()]

ans = 1
for b in A:
    ans = lce(ans, b)

print(ans)


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

int main(){
  int N;
  cin>>N;
  int ans = 9999;
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    int count = 0;
    while(A%2==0){
      A/=2;
      count++;
    }
    ans = min(ans,count);
  }
  cout<<ans<<endl;
  return 0;
}


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

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[3];
		int[] b = new int[3];
		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < 3; i++) {
			b[i] = sc.nextInt();
		}

		int[] dp = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			dp[i] = i;
			for (int j = 0; j < 3; j++) {
				if (i >= a[j]) dp[i] = Math.max(dp[i], dp[i - a[j]] + b[j]);
			}
		}

		int m = dp[n];
		long[] dp2 = new long[m + 1];
		for (int i = 1; i <= m; i++) {
			dp2[i] = i;
			for (int j = 0; j < 3; j++) {
				if (i >= b[j]) dp2[i] = Math.max(dp2[i], dp2[i - b[j]] + a[j]);
			}
		}

		System.out.println(dp2[m]);
	}
}


Measured memory_bytes: 219348
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int digits(ll n){
    int ct=0;
    while(n!=0){
        n/=10;
        ct++;
    }
    return ct;
}

int main(){
    ll n,m=0;
    cin>>n;
    ll sq=sqrt(n);
    for(ll i=2;i<=sq;i++)
        if(n%i==0)m=i;
    if(m==0)cout<<digits(n)<<endl;
    else cout<<(m>n/m?digits(m):digits(n/m))<<endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *  Author : Coda
 *  Title : OSU!
 *  Date : 2019-08-20
 */
#include <bits/stdc++.h>
using namespace std ;

typedef long long ll ;
typedef unsigned long long ull ;
typedef double DB ;
const long long mod = 1e9+7 ;
const double pi = acos(-1) ;
#define PB push_back
#define MP make_pair
#define lb lower_bound
#define ub upper_bound
#define fs first
#define sd second
#define pii pair<int,int>
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define debug(x) cout << #x << " = " << x << endl
#define debug2(x,y) cout << #x << " = " << x << ' ' << #y << " = " << y << endl
#define debug3(x,y,z) cout << #x << " = " << x << ' ' << #y << " = " << y << ' ' << #z << " = " << z << endl
//#pragma comment(linker,"/STACK:10240000,10240000")
//#include <random>
//mt19937 rand_(time(0));
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll qpow(ll a,ll b,ll c){ll t=1;while(b){if(b&1)t=t*a%c;a=a*a%c;b>>=1;}return t;}
ll inv(ll x){return qpow(x,mod-2,mod);}
int test = 1 ;

const int maxn = 5 + 3e5 ;
const int maxm = 5 + 1e6 ;
// Write the variables here

int N,W ;
ll v[maxn],w[maxn] ;
ll dp[maxn] ;

//#define TEST
int main(){
#ifdef TEST
    freopen("in.txt","r",stdin) ;
#endif
    while(test--){
        // code begins
        scanf("%d%d",&N,&W) ;

        ll sum = 0 ;
        for(int i=1 ; i<=N ; i++){
            scanf("%lld%lld",&w[i],&v[i]) ;
        }
        for(int i=1 ; i<=100000 ; i++){
            dp[i] = LLINF ;
        }
        dp[0] = 0;
        ll ans = 0 ;
        for(int i=1 ; i<=N ; i++){
            for(int j=100000 ; j>=v[i] ; j--){
                dp[j] = min(dp[j],dp[j-v[i]]+w[i]);
            }
        }
        for(int i=1 ; i<=100000 ; i++){
            if(dp[i]<=W) ans = max(ans,i*1ll) ;
        }
        printf("%lld\n",ans) ;

    }
#ifdef TEST
    cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
    return 0 ;
}


Measured memory_bytes: 5120
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll a,b; cin >> a >> b;
  if((a+b) % 2 == 0) cout << (a+b)/2 << endl;
  else cout << "IMPOSSIBLE" << endl;
}

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

#define MOD 1000000007

int main () {
	
	long long int a=0, b=0, res=0, x=0, i=0;

	scanf("%lld %lld", &a, &b);

	if (abs(a-b) > 1) printf("0\n");

	else {
		
		if (a == b) {
			res = 1;
			for (i=1; i<=a; i++) {

				res = (res*i)%MOD;
				res = (res*i)%MOD;

				//if (res < 0) cout << i << endl;
			}
			res = (res*2)%MOD;
		}

		else {
			a = max(a, b);
			res = 1;
			for (i=a; i>=2; i--) {
				res = (res*i)%MOD;
				res = (res*(i-1))%MOD;
				//cout << res << endl;
			}
		}

		printf("%lld\n", res);

	}

	return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 1000;
const double EPS = 1E-10;
struct Point{
	double x, y;
	Point(double _x=0, double _y=0):x(_x), y(_y){}
};
struct Circle{
	Point p; double r;
}c[MAXN + 5];
typedef Point Vector;
Vector operator + (Vector a, Vector b) {return Vector(a.x+b.x, a.y+b.y);}
Vector operator - (Vector a, Vector b) {return Vector(a.x-b.x, a.y-b.y);}
Vector operator * (Vector a, double k) {return Vector(a.x*k, a.y*k);}
Vector operator / (Vector a, double k) {return Vector(a.x/k, a.y/k);}
double cross(Vector a, Vector b) {return a.x*b.y - a.y*b.x;}
double dot(Vector a, Vector b) {return a.x*b.x + a.y*b.y;}
double length(Vector a) {return sqrt(dot(a, a));}
double dcmp(double x) {if( fabs(x) <= EPS ) return 0; else return x > 0 ? 1 : -1;}
double pow2(double x) {return x*x;}
Vector Unit(Vector a) {double l = length(a); return Vector(a.x/l, a.y/l);}
double dist(Point a, Point b) {return sqrt(pow2(a.x - b.x) + pow2(a.y - b.y));}
bool Check(Circle a, Circle b) {return dcmp(a.r + b.r - dist(a.p, b.p)) >= 0;}
bool Check(Circle a, Point b) {return dcmp(a.r - dist(a.p, b)) >= 0;}
double dist(Circle a, Circle b) {
	Vector vb = Unit(a.p - b.p), va = Unit(b.p - a.p);
	Point A = (a.p + va*a.r), B = (b.p + vb*b.r);
	return dist(A, B);
}
double dist(Circle a, Point b) {
	Vector v = Unit(b - a.p);
	return dist(b, a.p + v*a.r);
}
Point s, t;
double G[MAXN + 5][MAXN + 5], dis[MAXN + 5];
bool vis[MAXN + 5];
int N;
void dijkstra() {
	for(int i=1;i<=N+1;i++)
		dis[i] = G[0][i];
	vis[0] = true;
	for(int i=1;i<=N+1;i++) {
		double mn = 1E18;int p;
		for(int j=0;j<=N+1;j++) {
			if( !vis[j] && dis[j] < mn ) {
				p = j;
				mn = dis[j];
			}
		}
		vis[p] = true;
		for(int j=0;j<=N+1;j++) {
			if( !vis[j] ) dis[j] = min(dis[j], dis[p] + G[p][j]);
		}
	}
}
int main() {
	scanf("%lf%lf%lf%lf", &s.x, &s.y, &t.x, &t.y);
	scanf("%d", &N);
	for(int i=1;i<=N;i++)
		scanf("%lf%lf%lf", &c[i].p.x, &c[i].p.y, &c[i].r);
	for(int i=1;i<=N;i++) {
		if( Check(c[i], s) ) G[0][i] = G[i][0] = 0;
		else G[0][i] = G[i][0] = dist(c[i], s);
		if( Check(c[i], t) ) G[i][N+1] = G[N+1][i] = 0;
		else G[i][N+1] = G[N+1][i] = dist(c[i], t);
	}
	G[0][N+1] = G[N+1][0] = dist(s, t);
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++) {
			if( Check(c[i], c[j]) ) G[i][j] = 0;
			else G[i][j] = dist(c[i], c[j]);
		}
	dijkstra();
	printf("%.10lf\n", dis[N+1]);
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

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

signed main() {
  string a, b;
  cin >> a >> b;
  rep(i, 0, a.length()) {
    if(i == a.length() - 1) {
      cout << a[i];
      if(a.length() == b.length()) cout << b[i];
      break;
    }
    cout << a[i] << b[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
def is_possible(A):
    if A[0] != 0:
        return False
    for i in range(1, len(A)):
        if A[i-1] < A[i] - 1:
            return False
    return True

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    if not is_possible(A):
        print(-1)
        return
    ans = 0
    i = N-1
    while i >= 0:
        if A[i] > 0:
            x = A[i]
            ans += x
            while i >= 0 and x > 0 and A[i] == x:
                i -= 1
                x -= 1
        else:
            i -= 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 57560
#include<stdio.h>
using namespace std;

int main() {
  char ch;
  int counter[26] = {0};

  while (scanf("%c", &ch) != EOF) {
    if ('a' <= ch && ch <= 'z') counter[ch - 'a']++;
    else if ('A' <= ch && ch <= 'Z') counter[ch - 'A']++;
  }

  for (int i = 0; i < 26; i++) {
    printf("%c : %d\n", i + 'a', counter[i]);
  }

  return 0;
}



Measured memory_bytes: 2616
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <numeric>

using namespace std;

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

    int difference = 0;
    for(int i = 1 ; i <= n ; i++ ){
        int p;
        cin >> p;
        if (p != i){
            difference++;
        }
    }

    cout << ((difference <= 2) ? "YES" : "NO") << endl;

    return 0;
}



Measured memory_bytes: 256
//abc100_a.cpp
//Sat Jun 16 20:58:56 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

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

	if (a <= 8 && b <= 8){
		cout << "Yay!" << endl;
	}else {
		cout << ":(" << endl;
	}
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
'''
S = input()
n = len(S)

ans_0 = '01'*(n//2) + '0'*(n%2)
ans_1 = '10'*(n//2) + '1'*(n%2)

c_0 = c_1 = 0

for i in range(n):
    if ans_0[i] != S[i]:
        c_0 += 1
    if ans_1[i] != S[i]:
        c_1 += 1

print(min(c_0, c_1))
'''
S = input()
n = len(S)
a = 0
cnt_0 = cnt_1 = 0
for moji in S:
    cnt_0 += int(moji) ^ a
    a ^= 1

a = 1
for moji in S:
    cnt_1 += int(moji) ^ a
    a ^= 1

print(min(cnt_0, cnt_1))

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  float A[N];
  string B[N];
  float ans = 0;
  REP(i, N) cin >> A[i] >> B[i];
  REP(i, N) {
    if(B[i] == "JPY") {
      ans += A[i];
    } else {
      ans += A[i] * 380000;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, x, y;
    cin >> n >> x >> y;
    --x; --y;
    vector<int> ans(n, 0);
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j){
            int dist = j - i;
            chmin(dist, abs(i-x) + 1 + abs(y-j));
            chmin(dist, abs(i-y) + 1 + abs(x-j));
            ++ans[dist];
        }
    }
    for(int i = 1; i < n; ++i){
        cout << ans[i] << endl;
    }
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define loop(i,a,B) for (int i = a; i B; i++)
#define loopR(i,a,B) for (int i = a; i B; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", my_dmp(#__VA_ARGS__, __VA_ARGS__)
void my_dmp(const char*) { cerr << endl; }
template <class T, class... U>
void my_dmp(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; my_dmp(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define OUTPUT(...) ostream& operator<<(ostream& os, __VA_ARGS__ const& v) { os << "{"; for (auto const& x : v) os << " " << x; return os << " }"; }
template <class T> OUTPUT(vector<T>)
template <class T> OUTPUT(deque<T>)
template <class T> OUTPUT(set<T>)
template <class T> OUTPUT(multiset<T>)
template <class T, class U> OUTPUT(map<T,U>)
#undef OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S>& p) { return is >> p.first >> p.second; }
struct my_Init { my_Init() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } my_init;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
////////////////////////////////

int32_t main() {
    int n; cin >> n;
    vector<int> d(n); cin >> d;
    int sum = 0;
    rep (i,n) rep (j,n) if (i < j) {
        sum += d[i]*d[j];
    }
    cout << sum << "\n";
}


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

using namespace std;
using ll = long long;
#define FOR(i,k,n) for(ll (i)=(k);(i)<(n);(i)++)
#define REP(i,n) FOR((i),0,(n))


int Q;
vector<pair<string, string>> s;

void input() {
	cin >> Q;
	string a, b;
	REP(i, Q) {
		cin >> a >> b;
		s.push_back({ a,b });
	}
}

int action(string s, string t) {
	int x = s.size() - 1;
	while (s[x] != '1')x--;
	int y = t.size() - 1;
	while (t[y] != '1')y--;

	int z = -1;
	REP(i, s.size()){
		if (s[i] != t[i]) {
			z = i;
			break;
		}
	}
	if (z == -1)return 0;
	return abs(x - z) + abs(y - z);
}

int main() {
	input();
	for (auto p : s) {
		cout << action(p.first, p.second) << endl;
	}
	//cin >> Q;
}


Measured memory_bytes: 26360
import Data.List

main = do
  n <- readLn :: IO Int
  (d:x:_) <- getLine >>= return . map read . words :: IO [Int]
  as <- getContents >>= return . map read . lines :: IO [Int]

  print $ sum (map length [takeWhile (<=d) (iterate (+a) 1) | a <- as]) + x


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

int main() {
  int a,b;
  cin>>a>>b;
  if(a==b) {
    cout<<"Draw"<<endl;
  }
  if(a>=2&&b>=2) {
    if(a>b) {
      cout<<"Alice"<<endl;
    }
    if(a<b) {
      cout<<"Bob"<<endl;
    }
  }
  if(a==1&&b!=1) {
    cout<<"Alice"<<endl;
  }
  if(b==1&&a!=1) {
    cout<<"Bob"<<endl;
  }
}

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

const long long INF = 1000000000000000;

int main() {
	int a, b, q; cin >> a >> b >> q;
	long long s[100010], t[100010];
	s[0] = t[0] = -INF;
	for (int i = 1; i <= a; i++) {
		cin >> s[i];
	}
	for (int i = 1; i <= b; i++) {
		cin >> t[i];
	}
	s[a + 1] = INF; t[b + 1] = INF;
	long long ans[100010];
	for (int i = 0; i < q; i++) {
		ans[i] = INF;
	}
	for (int i = 0; i < q; i++) {
		long long x; cin >> x;
		int sh = lower_bound(s, s + a + 2, x) - s;
		int tem = lower_bound(t, t + b + 2, x) - t;
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				ans[i] = min(ans[i], abs(s[sh - j] - x) + abs(t[tem - k] - s[sh - j]));
				ans[i] = min(ans[i], abs(t[tem - k] - x) + abs(s[sh - j] - t[tem - k]));
			}
		}
	}
	for (int i = 0; i < q; i++) {
		cout << ans[i] << endl;
	}
}

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

ans = 0
length = 0

for i in range(n):
	if p[i] == i + 1:
		length += 1
	else:
		ans += (length + 1) // 2
		length = 0

ans += (length + 1) // 2

print(ans)

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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    int N, A;
    vector<int> X;
    void input() {
        cin >> N >> A;
        X.resize(N); cin >> X;
    }

    ll dp[51][51][2501];
    void solve() {
        int MX = 0;
        for (int i = 0; i < N; i++) MX = max(MX, X[i]);
        if (A > N * MX) {
            cout << 0 << endl;
            return;
        }
        dp[0][0][0] = 1;
        for (int i = 1; i <= N; i++) {
            for (int k = 0; k <= i; k++) {
                for (int a = 0; a <= N * MX; a++) {
                    dp[i][k][a] = dp[i - 1][k][a];
                    if (k - 1 >= 0 && a - X[i - 1] >= 0) {
                        dp[i][k][a] += dp[i - 1][k - 1][a - X[i - 1]];
                    }
                }
            }
        }
        ll ans = 0;
        for (int m = 1; m <= N; m++) {
            ans += dp[N][m][m * A];
        }
        cout << ans << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}



Measured memory_bytes: 26368