akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i64 = int64_t;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= a; i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second

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


  int N;
  cin >> N;

  vector<int> result(N + 1);
  F0R(i, N - 1) {
    int a;
    cin >> a;
    result[a]++;
  }

  FOR(i, 1, N+1) {
    cout << result[i] << '\n';
  }
}


Measured memory_bytes: 3988
#include<stdio.h>
int main(void)
{
	int a, b;
	scanf("%d", &a);
	scanf("%d", &b);
	if (a <= 12) {
		if (a < 6) {
			printf("0\n");
		}
		else {
			printf("%d\n", b / 2);
		}
	}
	else {
		printf("%d\n", b);
	}
	return 0;
}

Measured memory_bytes: 128
//Be Name Khoda
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma optimize O3
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
const ll M=1e5+5,LG=32,SM=600+5,inf=1e18+5;
ll mod=1e9+7;

ll n,m;
ll mark[M];
vll g[M],g2[M];
ll a[4];
bool ok;
ll edj,res;

void dfs(ll x,ll mol)
{
    //ER(x);ER(mol);
    mark[x]=mol;
    a[mol]++;
    mol++;
    if (mol==4) mol=1;
    edj+=SZ(g[x]);
    for (ll y:g[x])
    {
        if (mark[y])
        {
            if (mark[y]!=mol) ok=0;
            continue;
        }
        //ER(y);ER(mol);
        dfs(y,mol);
    }
    mol++;
    if (mol==4) mol=1;
    for (ll y:g2[x])
    {
        if (mark[y])
        {
            if (mark[y]!=mol) ok=0;
            continue;
        }
        //ER(y);ER(mol);
        dfs(y,mol);
    }    
}

int main()
{
    cin >> n >> m;
    For(i,0,m)
    {
        ll u,v;
        cin >> u >> v;
        u--;v--;
        g[u].PB(v);
        g2[v].PB(u);
    }
    For(i,0,n)
    {
        if (mark[i]) continue;
        edj=0;
        a[1]=a[2]=a[3]=0;
        ok=1;
        dfs(i,1);
        if (ok)
        {
            if (a[1]==0 || a[2]==0 
                || a[3]==0)
                res+=edj;
            else    res+=(a[1]+a[3])*a[2]+
                a[1]*a[3];
        }        
        else
            res+=(a[1]+a[2]+a[3])*(a[1]+a[2]+a[3]);
    }  
    RET(res); 
}    


Measured memory_bytes: 16640
from collections import deque

def main():
    n = int(input())
    adjacent = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b, c = map(int, input().split())
        adjacent[a - 1].append((b - 1, c))
        adjacent[b - 1].append((a - 1, c))
    q, k = map(int, input().split())
    next_search = deque([k - 1])
    searched = set()
    dist = [10**20] * n
    dist[k - 1] = 0
    while next_search:
        p = next_search.popleft()
        if p in searched:
            continue
        searched.add(p)
        for pp, d in adjacent[p]:
            dist[pp] = min(dist[p] + d, dist[pp])
            next_search.append(pp)
    for _ in range(q):
        x, y = map(int, input().split())
        print(dist[x - 1] + dist[y - 1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 48700
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e5+100,M=20;
ll nxt[N][M],pre[N][M];
ll dp[(1<<M)],pd[(1<<M)];
ll a[N];
int32_t main(){
    sync;
    ll n,v;
    cin >> n >> v ;
    for (int i=1;i<=n;i++){
        cin >> a[i];
    }
    ll z=v*2;
    ll p1=0;
    ll t=0;
    while(z/2>=0){
        z/=2;
        nxt[n][p1]=n;
        for (int i=n-1;i;i--){
            if (a[i+1]-a[i]<=z) nxt[i][p1]=nxt[i+1][p1];
            else nxt[i][p1]=i;
        }
        pre[1][p1]=1;
        for (int i=2;i<=n;i++){
            if (a[i]-a[i-1]<=z) pre[i][p1]=pre[i-1][p1];
            else pre[i][p1]=i;
        }
        p1++;
        if (z==0) break;
    }
    for (int i=1;i<=n;i++){
        if (nxt[i][0]==i) t++;
    }
    if (t>M){
        for (int i=1;i<=n;i++){
            cout << "Impossible" << endl;
        }
        return 0;
    }
    pd[0]=n+1;
    for (int mask=1;mask<(1<<p1);mask++){
        for (int i=0;i<p1;i++){
            if (((1<<i)&mask)){
                ll z=dp[(mask ^ (1<<i))];
                dp[mask]=max(dp[mask],z);
                if (z!=n){
                    z++;
                    z=nxt[z][i];
                    dp[mask]=max(dp[mask],z);
                }
            }
        }
        pd[mask]=n+1;
    }

    for (int mask=1;mask<(1<<p1);mask++){
        for (int i=0;i<p1;i++){
            if (((1<<i)&mask)){
                ll z=pd[(mask ^ (1<<i))];
                pd[mask]=min(pd[mask],z);
                if (z!=1){
                    z--;
                    z=pre[z][i];
                    pd[mask]=min(pd[mask],z);
                }
            }
        }
    }
    for (int i=1;i<=n;i++){
        ll r=nxt[i][0];
      //  cout << i << " " << r << " " << p1 << " " << pd[6] << endl;
        ll p2=0;
        for (int mask=0;mask<(1<<p1);mask++){
        //    cout << " " << mask << endl;
            ll sam=(1<<p1)-1-mask;
            if (sam%2==1) sam--;
            ll z=mask;
            if (mask%2==1) z--;
          //  if (mask==4) cout << sam << endl;
            if (dp[z]>=i-1 && pd[sam]<=r+1) p2=1;
        }
        if (p2){
            for (int j=i;j<=r;j++) cout << "Possible" << endl;
        }
        else for (int j=i;j<=r;j++) cout << "Impossible" << endl;
        i=r;
    }

}
//0110010111000


Measured memory_bytes: 75880
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
int R[MAX], n;

 cin >> n;
 for( int i=0; i<n; i++) cin >>R[i];

int maxv = -2000000000;
int minv = R[0];

for ( int i =1; i <n; i++){
maxv = max(maxv , R[i] - minv);
minv = min(minv, R[i]);
}

cout << maxv << endl;

return 0;
}

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int n; cin >>  n;
   long long ans =1;
   for(long long i = 1; i <= n; i++)
   {
      ans *=i;
      ans%=MOD;
   }

   cout << ans <<nl;
   return 0;

}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int slen = s.length(), tlen = t.length();

    int need = tlen;
    rep (i, slen) {
        int cnt = 0;
        rep (j, tlen) {
            if (i + j >= slen) break;
            if (s[i + j] != t[j]) cnt++;

            if (j == tlen - 1) chmin(need, cnt);
        }
    }
    print(need);

    return 0;
}


Measured memory_bytes: 3680
#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 () {
  int l = 0;
  string s;
  int n;
  cin >> n >> s;

  int i = 0, j = 0;
  rep(i,n) {
    if(s[i] == '(') {
      j++;
    } else {
      j--;
    }
    l = max(l, -j);
  }

  rep(i, l) printf("(");
  cout << s;
  rep(i, l+j) printf(")");
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
from sys import stdin
from itertools import groupby

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
li.sort()

lin = []

for key, value in groupby(li):
    lin.append([key,len(list(value))])

point = 0

for i in lin:
    if i[1] >= 3:
        while True:
            if i[1] < 3:
                break
            i[1] -= 2

iti = 0
ni = 0

for i in lin:
    if i[1] == 1:
        iti += 1
    else:
        ni += 1

if ni%2 == 0:
    print(iti+ni)
else:
    print(iti+ni-1)

Measured memory_bytes: 18592
# -*- coding: utf-8 -*-

N = int(input())
a = []
for i in range(N):
    a.append(int(input()))

ans = pos = 0
flag = [0] * N
while True:
    ans += 1
    if a[pos] == 2:
        break
    #print(pos,a[pos]-1)
    pos = a[pos] - 1

    if flag[pos] > 0:
        ans = -1
        break
    else:
        flag[pos] = 1

print(ans)

Measured memory_bytes: 13688
import java.util.Scanner;
public class Main { public static void main(String[] args) { 
	// ?¨??????\??????????????????????????????????????? 
	Scanner sc = new Scanner(System.in);
	// ????????????????????????????????´??°?????¨????????????????????????
	int x = sc.nextInt();
	int answer = x*x*x;
	System.out.println(answer);   
	}

}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  string a,b;cin>>a>>b;
  if (a.size()>b.size()) {
    cout << "GREATER" << endl;
    return;
  }
  if (a.size()<b.size()) {
    cout << "LESS" << endl;
    return;
  }
  if (a>b) cout << "GREATER" << endl;
  else if (a<b) cout << "LESS" << endl;
  else cout << "EQUAL" << endl;
}

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        String ans = "Yes";
        if(a == b){
            if(b == c){
                ans = "No"; 
         }   
        }else if(b != c){
            if(a == c){
                ans = "Yes";
            }else{
                ans = "No"; 
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var ABC = Sarray();
            Array.Sort(ABC);
            var diffmin = ABC[2] - ABC[1];
            var diffmax = ABC[2] - ABC[0];

            var ans = diffmin + (diffmax - diffmin) / 2;
            if ((diffmax - diffmin) % 2 != 0)
                ans += 2;
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define DEBUG(x) cout << x << '\n'

ll n, f[100];
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios::sync_with_stdio(false);

    int now = 0;
    for(int i = 1; i <= 12; i++) f[now+=i] = i;
    for(int i = 1; i <= 50; i++)
        if(f[i] == 0) f[i] = f[i-1];
    cin >> n;
    vector<int> v;
    int ans = 0;
    for(ll i = 2; i * i <= n; i++){
        if(n % i == 0){
            int cnt = 0;
            while(n % i == 0)
                cnt++, n /= i;
            ans += f[cnt];
        }
    }
    if(n > 1) ans++;
    cout << ans;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int gcd(int a, int b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

int main()
{
    lint n,k;
    cin >> n>>k;
    vector<lint> a(n);
    lint m=0;
    REP(i, n) {
        cin >> a[i];
        m = max(m, a[i]);
    }
    lint g=a[0];
    REP(i,n){
        g = gcd(g, a[i]);
    }
    //cout << g << "\n";
    string ans;
    lint d = m - k;
    if(d>=0&&d%g==0){
        ans = "POSSIBLE";
    }else{
        ans = "IMPOSSIBLE";
    }
    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main() {

    int num[3];
    for(int i = 0; i < 3; i++) {
        scanf("%d", &num[i]);
    }
    for(int i = 0; i < 3; i++) {
        for(int j = 2; j > i; j--) {
            if (num[j] > num[j-1]) {
                int tmp = num[j];
                num[j] = num[j-1];
                num[j-1] = tmp;
            }
        }
    }

    int sum = num[0] * 10 + num[1] + num[2];
    printf("%d", sum);

    return 0;
}

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

int main()
{
	//?????°??????
	int Array[100][100] = {};//[???][?¨?]
	int Vector[100] = {};
	int n = 0;
	int m = 0;
	//??\?????????
	cin >> m >> n;
	for (int i = 0; i<m; i++)
	{
		for (int j = 0; j<n; j++)
		{
			cin >> Array[i][j];
		}
	}

	for (int i = 0; i<n; i++)
	{
		cin >> Vector[i];
	}
	//?¨??????????
	int TemporarySum = 0;//
	int ReturnVector[100] = {};//??????????????£??\??????
	for (int i = 0; i<m; i++)
	{
		for (int j = 0; j<n; j++)
		{
			TemporarySum += Array[i][j] * Vector[j];
		}
		ReturnVector[i] = TemporarySum;
		TemporarySum = 0;
	}
	//????????????
	for (int i = 0; i<m; i++)
	{
		cout << ReturnVector[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3144
import java.util.*;
public class Main{
  public static void main(String [] args){
    Scanner sc = new Scanner(System.in);
    int ans,count;
    while(sc.hasNext()){
      ans = sc.nextInt();
      count = 0;
      for(int i = 0;i <= 9;i++){
        for(int j = 0;j <= 9;j++){
          for(int k = 0;k <= 9;k++){
            for(int l = 0;l <= 9;l++){
              if(ans == i + j + k + l) count++;
            }
          }
        }
      }
      System.out.println(count);
    }
  }
}

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

using namespace std;
int main()
{
    int n;
    cin >> n;

    vector<int> v(n);

    for (int i = 0, in; i < n && cin >> in; ++i)
        v[i] = in + 1;

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

    int current = v[0];
    int minus[3] {};
    int ans {};

    for (int i = 0; i < v.size(); ++i)
    {
        switch (v[i] - current)
        {
        case 0:
            ++minus[0];
            break;
        case 1:
            minus[2] = minus[1];
            minus[1] = minus[0];
            minus[0] = 1;
            break;
        case 2:
            minus[2] = minus[0];
            minus[1] = 0;
            minus[0] = 0;
            break;
        default:
            for (int& m : minus)
                m = 0;
            break;
        }

        int sum {};
        for (int m : minus)
            sum += m;

        if (ans < sum)
            ans = sum;

        current = v[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
k = int(input())
if k % 2 == 0:
    print(-1)
elif k in [1,7]:
  	print(1)
else:
  amari = [7]
  tmp = 7
  for i in range(k):
      tmp = (tmp * 10) % k
      if tmp != 7:
          amari.append(tmp%k)
      else:
          break
  amari = amari * ((k//len(amari)) +1)

  ans = amari[0]
  for i in range(1, k+1):
      ans += amari[i]
      if ans % k == 0:
          print(i+1)
          break
  else:
    print(-1)

Measured memory_bytes: 63884
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    getLine
    as <- getIntList
    bs <- getIntList
    print $ solve as bs

solve _ [] = 0
solve (a1:a2:as) (b:bs) = s + solve (a2':as) bs
  where (s, a2') | a1 >= b = (b, a2)
                 | a1 + a2 >= b = (b, a1 + a2 - b)
                 | otherwise = (a1 + a2, 0)

Measured memory_bytes: 6780
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

#回数
n = int(arr_data[0][0])

#番目
k = int(arr_data[0][1])

arr=[]

for i in range(1, 1 + n):
    
    arr.append(list(map(int, arr_data[i])))

arr.sort(key=lambda x:(x[0]))

#print(arr)

#sys.exit()

mysum=0

for i in range(0,n):
 
    cnt = arr[i][1]
    j = arr[i][0]
 

    if k<=mysum+cnt:
        
        print(j)
        
        break
        
    else:
        
        
        mysum+=cnt

Measured memory_bytes: 58280
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  string s,t,u; cin>>s;
  int c=s.size(),d=s.size();
  rep(i,0,s.size()){
    int a=s[i]-48;
    if(i%2==a) c--;
    else d--;
  }
  co(min(c,d));
  
  return 0;
}

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

int main(){
  int K;
  cin >> K;
  int ans=1;
  int an=0;
  for(int i =0; i<K;i++){
    an =(an%K)*10+7;
    if(an%K==0){
      cout << ans << endl;
      break;
    }
    ans++;
  }
  if(an%K!=0){
    cout << -1 << endl;
  }
}
    
      

Measured memory_bytes: 3640
package main

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

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

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

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

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

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

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

	n := getNextInt(scanner)
	m := getNextInt(scanner)
	p := getNextInt64(scanner)

	edges := make([]Edge, m)

	var g Graph
	g.lto = make([][]int, n)
	g.rto = make([][]int, n)
	for i := 0; i < n; i++ {
		g.lto[i] = make([]int, 0)
		g.rto[i] = make([]int, 0)
	}

	for i := 0; i < m; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		c := (getNextInt64(scanner) - p) * -1
		edges[i] = Edge{
			a:    a,
			b:    b,
			cost: c,
		}
		g.lto[a] = append(g.lto[a], b)
		g.rto[b] = append(g.rto[b], a)
	}

	g.lreach = make([]bool, n)
	g.rreach = make([]bool, n)

	g.dfs(0, false)
	g.dfs(n-1, true)

	cc := make([]int64, n)
	for i := 0; i < n; i++ {
		cc[i] = math.MaxInt64
	}

	cc[0] = 0

	for i := 0; i < n; i++ {
		for ii := 0; ii < m; ii++ {
			if cc[edges[ii].a] == math.MaxInt64 {
				continue
			}
			if g.lreach[edges[ii].a] == false {
				continue
			}
			if g.rreach[edges[ii].a] == false {
				continue
			}
			if cc[edges[ii].b] > edges[ii].cost+cc[edges[ii].a] {
				cc[edges[ii].b] = edges[ii].cost + cc[edges[ii].a]
				if i == n-1 {
					fmt.Fprintln(writer, "-1")
					writer.Flush()
					return
				}
			}
		}
	}
	ans := -cc[n-1]
	if ans < 0 {
		ans = 0
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}

type Graph struct {
	lto, rto       [][]int
	lreach, rreach []bool
}

func (g *Graph) dfs(s int, r bool) {
	to := g.lto
	reach := g.lreach
	if r == true {
		to = g.rto
		reach = g.rreach
	}
	if reach[s] == true {
		return
	}
	reach[s] = true
	for _, t := range to[s] {
		g.dfs(t, r)
	}
}

type Edge struct {
	a, b int
	cost int64
}


Measured memory_bytes: 1792
'use strict'
const lines = require('fs').readFileSync(0, 'utf8').split('\n')
const N = parseInt(lines[0], 10)
const map = {a:[],b:[],c:[]}
for (let i=1;i <= N;i++) {
  const abc = lines[i].split(' ')
  map.a.push(parseInt(abc[0], 10))
  map.b.push(parseInt(abc[1], 10))
  map.c.push(parseInt(abc[2], 10))
}
const dp = {a:[],b:[],c:[]}
dp.a[0] = map.a[0]
dp.b[0] = map.b[0]
dp.c[0] = map.c[0]
for (let i=1;i < N;i++) {
  dp.a[i] = map.a[i] + Math.max(dp.b[i-1], dp.c[i-1])
  dp.b[i] = map.b[i] + Math.max(dp.a[i-1], dp.c[i-1])
  dp.c[i] = map.c[i] + Math.max(dp.b[i-1], dp.a[i-1])
}
console.log(Math.max(dp.a[N-1], dp.b[N-1], dp.c[N-1]))

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

int main(){
    while(true){
        int n;
        cin >> n;
        if(n==0) break;
        int a[n];
        for(int i=0; i<n; i++){
            cin >> a[i];
        }
        int min1=abs(a[1]-a[0]);
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(j != i && min1 > abs(a[j]-a[i])) min1 = abs(a[j] - a[i]);
            }
        }
        cout << min1 << endl;
    }

    return 0;
}


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int mxn = 2005;
int n, arr[mxn * 3], dp[mxn][mxn], rmx[mxn], cmx[mxn], mx, ormx[mxn], ocmx[mxn], omx;

void upd(int x, int y, int v) {
	if (v > dp[x][y]) {
		dp[x][y] = v;
		rmx[x] = max(rmx[x], v);
		cmx[y] = max(cmx[y], v);
		mx = max(mx, v);
	}
}

int main() {
	scanf("%d", &n);
	rep(i, n * 3) scanf("%d", &arr[i]), -- arr[i];
	memset(dp, -0x3f, sizeof(dp));
	memset(rmx, -0x3f, sizeof(rmx));
	memset(cmx, -0x3f, sizeof(cmx));
	mx = -0x3f3f3f3f;
	upd(arr[0], arr[1], 0);
	int temp = 0;
	rep(i, n - 1) {
		int c = arr[i * 3 + 2], d = arr[i * 3 + 3], e = arr[i * 3 + 4];
		memcpy(ormx, rmx, sizeof(rmx));
		memcpy(ocmx, cmx, sizeof(cmx));
		omx = mx;
		int occ = dp[c][c], odd = dp[d][d], oee = dp[e][e];
		static int nc[mxn], nd[mxn], ne[mxn];
		memset(nc, -0x3f, sizeof(nc));
		memset(nd, -0x3f, sizeof(nd));
		memset(ne, -0x3f, sizeof(ne));
		if (c == d && d == e) { ++ temp; continue; }
		if (c == d) rep(a, n) ne[a] = max(dp[a][c], dp[c][a]) + 1;
		if (d == e) rep(a, n) nc[a] = max(dp[a][d], dp[d][a]) + 1;
		if (c == e) rep(a, n) nd[a] = max(dp[a][e], dp[e][a]) + 1;
		rep(a, n) upd(a, c, nc[a]);
		rep(a, n) upd(a, d, nd[a]);
		rep(a, n) upd(a, e, ne[a]);
		upd(d, e, occ + 1);
		upd(c, e, odd + 1);
		upd(c, d, oee + 1);
		upd(c, d, omx);
		upd(d, e, omx);
		upd(c, e, omx);
		rep(a, n) upd(a, c, max(ormx[a], ocmx[a]));
		rep(a, n) upd(a, d, max(ormx[a], ocmx[a]));
		rep(a, n) upd(a, e, max(ormx[a], ocmx[a]));
	}
	int ans = -0x3f3f3f3f;
	rep(a, n) rep(b, n) {
		int c = arr[n * 3 - 1];
		ans = max(ans, dp[a][b] + (a == b && b == c));
	}
	printf("%d\n", ans + temp);
	return 0;
}


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

int main(){
    ll n;
    cin >> n;
    //vector <ll> c(n),a(n),b(n);
    ll a,b;
    vector <vector <ll>> c(n,vector <ll>(3));
    
    rep(i,n){
        cin >> a >> b;
        c[i][0]=a+b;
        c[i][1]=a;
        c[i][2]=b;
    }

    sort(c.rbegin(),c.rend());
    ll ans=0;
    rep(i,n){
        if(i%2==0){
            ans+=c[i][1];
        }
        else{
            ans-=c[i][2];
        }
    }

    cout << ans << endl;

    

    return 0;
}

Measured memory_bytes: 8804
#include <iostream>

using namespace std;

int main() {
    int n;  cin >> n;
    long long *a = new long long[n], inf = 1e18;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    long long ans = 1;
    for (int i = 0; i < n; i++) {
        if (ans > inf/a[i]) {
            cout << -1 << endl;
            return 0;
        }
        else {
            ans *= a[i];
        }
    }
    cout << ((ans > inf) ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 4308
#include<cstdio>
const int N=100002;
int n,a,s[N],i,s1,s2;
void init(){
	scanf("%d",&n);
	while(n--){
		scanf("%d",&a);
		s[a]++;
	}
}
void work(){
	for(i=1;i<N;i++){
		while(s[i]>=3)
			s[i]-=2;
		if(s[i]==1)s1++;
		if(s[i]==2)s2++;
	}
	printf("%d",s1+(s2>>1<<1));
}
int main(){
	init();
	work();
	return 0;
}

Measured memory_bytes: 512
def resolve():
    S = input()
    strings = ["dream", "dreamer", "erase", "eraser"]
    while True:
        if S == "":
            print("YES")
            return

        if S.startswith("eraser"):
            S = S[len("eraser"):]
            continue
        elif S.startswith("erase"):
            S = S[len("erase"):]
            continue
        elif S.startswith("dreamer"):
            if S.startswith("dreamerase"):
                S = S[len("dream"):]
                continue
            else:
                S = S[len("dreamer"):]
                continue
        elif S.startswith("dream"):
            S = S[len("erase"):]
            continue
        else:
            print("NO")
            return




if '__main__' == __name__:
    resolve()



Measured memory_bytes: 3188
def main():
    from collections import deque
    H, W = (int(i) for i in input().split())
    Ch, Cw = (int(i)-1 for i in input().split())
    Dh, Dw = (int(i)-1 for i in input().split())
    A = [input() for i in range(H)]
    V = [[-1]*W for i in range(H)]  # V[h][w]を頂点iとする
    d = ((1, 0), (0, 1), (-1, 0), (0, -1))

    def bfs_2d(sy, sx, v):
        que = deque()
        V[sy][sx] = v
        que.append((sy, sx))
        while que:
            uh, uw = que.popleft()
            for dy, dx in d:
                next_h = uh + dy
                next_w = uw + dx
                if not(0 <= next_h < H and 0 <= next_w < W):
                    continue
                if V[next_h][next_w] != -1:
                    continue
                if A[next_h][next_w] == '#':
                    continue
                V[next_h][next_w] = v
                que.append((next_h, next_w))

    # グループ分け
    vertex = 0
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#" or V[h][w] != -1:
                continue
            bfs_2d(h, w, vertex)
            vertex += 1

    # グラフを作成、全てのマスで5*5の範囲を走査
    G = [[] for _ in range(vertex)]
    used = [set() for _ in range(vertex)]
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#":
                continue
            for dh in range(-2, 3):
                for dw in range(-2, 3):
                    if h + dh < 0 or H <= h + dh or w + dw < 0 or W <= w + dw:
                        continue
                    if A[h+dh][w+dw] == "#":
                        continue
                    if V[h][w] == V[h+dh][w+dw]:
                        continue
                    if V[h+dh][w+dw] in used[V[h][w]]:
                        continue
                    G[V[h][w]].append((V[h+dh][w+dw]))
                    used[V[h][w]].add((V[h+dh][w+dw]))

    # for h in range(H):
    #     print(V[h])

    # for i in range(vertex):
    #     print(G[i])

    # スタートからゴールまでbfsして最短距離を求める
    s = V[Ch][Cw]
    g = V[Dh][Dw]

    dist = [-1 for _ in range(vertex)]
    que = deque()
    dist[s] = 0
    que.append(s)
    while que:
        u = que.popleft()
        for v in G[u]:
            if dist[v] != -1:
                continue
            dist[v] = dist[u] + 1
            que.append(v)

    print(dist[g])


if __name__ == '__main__':
    main()


Measured memory_bytes: 161964
#include<stdio.h>
int check(int a[], int b[], int i, int q){
    int j;
    for(j=0; j<q; j++)if(a[j+i]!=b[j])return 0;
    return 1;
}
int main(){
    int i, t[1000], p[1000], l=0, q=0;
    while((t[l++]=getchar())!='\n'){}
    while((p[q++]=getchar())!='\n'){}
    for(i=0; i<l-q+1; i++)if(check(t, p, i, q-1))printf("%d\n", i);
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <cstring>
using namespace std;
int w,h, ans;
int map[20][20];
int mvx[4] = {0, 0, 1, -1};
int mvy[4] = {1, -1, 0, 0};

void getStartPoint(int* sx, int* sy){
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (map[i][j] == 2){
	*sx = j;
	*sy = i;
	return;
      }
    }
  }
}

void dfs(int sx, int sy, int count){
  if (count >= ans)
    return;
  for (int i = 0; i < 4; i++) {
    int mx = sx + mvx[i];
    int my = sy + mvy[i];
    if ((mx < 0) || (mx >= w) || (my < 0) || (my >= h))
      continue;
    if (map[my][mx] == 1){
      continue;
    }
    while (true){
      if (map[my][mx] == 3){
	ans = count;
	return;
      }
      mx += mvx[i];
      my += mvy[i];
      if ((mx < 0) || (mx >= w) || (my < 0) || (my >= h)){
	break;
      }
      if (map[my][mx] == 1){
	map[my][mx] = 0;
	dfs(mx-mvx[i], my-mvy[i], count+1);
	map[my][mx] = 1;
	break;
      }
    }
  }
}

int main()
{
  int sx, sy;
  while (true) {
    cin >> w >> h;
    if ((w == 0) && (h == 0))
      break;

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
	cin >> map[i][j];
      }
    }
    ans = 11;
    getStartPoint(&sx, &sy);
    dfs(sx, sy, 1);
    if (ans > 10)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define pq priority_queue
using namespace std; typedef pair<int, int> P; typedef pair<int, P> P2; typedef pair<int, P2> P3;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<1010> fact; constexpr Prime<10> prime;
constexpr long long comb(int a, int b){if(a < b) return 0LL;if(!a or !b) return 1LL; long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b]; return pos * pot % MOD * por % MOD;}
template<int n> struct Bernoulli{long long arr[n+1];constexpr Bernoulli():arr(){arr[0]=1;for(int i=1;i<=n;i++){long long sum=0;for(int j=0;j<i;j++){(sum+=comb(i+1,j)*arr[j]%MOD)%=MOD;}arr[i]=(MOD-mod_pow(i+1,MOD-2,MOD))%MOD*sum%MOD;}}};
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr long double PI = abs(acos(-1));
constexpr int sqrtN = 512, logN = 32;
constexpr long long LINF=1e18;

int main(){
	int n; cin >> n;
	
	if(n == 3){
		cout << "2 5 63" << endl;
		return 0;
	}else if(n == 4){
		cout << "2 5 20 63" << endl;
		return 0;
	}else if(n == 5){
		cout << "2 3 4 5 16" << endl;
		return 0;
	}
	
	vector<int> vec;
	for(int i = 0; i < 30000; i += 12){
		if(n >= 6){
			vec.push_back(i + 2);
			vec.push_back(i + 3);
			vec.push_back(i + 4);
			vec.push_back(i + 8);
			vec.push_back(i + 9);
			vec.push_back(i + 10);
			n -= 6;
		}
	}
	
	for(int i = 6; i <= 30000; i += 6){
		if(!n) continue;
		vec.push_back(i);
		n--;
	}
	
	for(auto v : vec) cout << v << " "; cout << endl;
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    while(1) {
        int d;
        scanf("%d", &d);
        if(d == 0) return 0;
        int result = 0;
        while(1) {
            int d2 = 0;
            if(d == 1) break;
            d2 = d;
            while(d2 % 5 == 0) {
                result += 1;
                d2 /= 5;
                if(d2 < 5) break;
            }
            d--;
        }
        printf("%d\n", result);
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
const int maxval = 1e9 + 1;
int main(){
  int n; cin >> n;
  int arr[n + 1];
  memset(arr,0,sizeof(arr));
  //int minval = -1;
  for(int i = 0; i < n; ++i){
    cin >> arr[i];
  }
  int l[n + 2];
  int r[n + 2];
  l[0] = 0;
  r[n + 1] = 0;
  l[1] = arr[0];
  r[n] = arr[n - 1];
  for(int i = 2; i < n + 1; ++i){
    l[i] = __gcd(l[i-1],arr[i - 1]);
    //cout << l[i] << '\n';
    r[n - i + 1] = __gcd(r[n - i + 2],arr[n - i]);
    //cout << r[n - 1 -i] << '\n';
    //cout << l[i] << ' ' << r[n - i + 1] << '\n';
  }
 // cout << l[n] << '\n';
  int x_2 = maxval;
  int leasthcf = maxval;
  for(int i = 1; i < n + 1; ++i){
    int x = __gcd(l[i],r[i + 1]);
    int y = __gcd(l[i - 1],r[i + 1]);
    //cout << x << ' ' << y << '\n';
    if(x <= leasthcf){
      x_2 = ( x == leasthcf ? max(x_2,y) : y );
     // cout << x_2 << '\n';
      leasthcf = x;
    }
  }
  cout << (x_2 > l[n] ? x_2 : l[n]) << '\n';
}


Measured memory_bytes: 4764
#include<cstdio>

int main(){
    int a,b,i,sum;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        sum=a+b;
        for(i=0;sum>0;i++)sum=sum/10;
        printf("%d\n",i);
    }
    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define yes(i) cout<<(i?"yes":"no")<<endl
using namespace std;
int main(){
	char c;
	cin>>c;
	if(c=='A'){
		cout<<"T"<<endl;
	}else if(c=='T'){
		cout<<"A"<<endl;
	}else if(c=='G'){
		cout<<"C"<<endl;
	}else{
		cout<<"G"<<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 ll;
typedef pair<int,int> P;

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

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
#define int long long int
#define mod 1000000007
int fact[1000001];
void function2()
{
	fact[0]=1;
	int j;
	for(j=1;j<=1000000;j++)
	{
		fact[j]=(j*fact[j-1])%mod;
	}
}
int power(int a,int b)
{
	if(b==0)
	  return 1;
	else
	{
		int r=power(a,b/2);
		if(b%2==0)
		   return (r*r)%mod;
		else
		{
			int x=(r*r)%mod;
			return (a*x)%mod;
		}
	}
}
int ncr(int n,int r)
{
	int val=fact[n];
	val*=power(fact[r],mod-2);
	val%=mod;
	val*=power(fact[n-r],mod-2);
	val%=mod;
	return val;
}
int32_t main()
{
	//function2();
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int val1=a*c;
	int val2=a*d;
	int val3=b*c;
	int val4=b*d;
	int answer=max(val1,val2);
	int answer2=max(val3,val4);
	answer=max(answer,answer2);
	cout<<answer<<endl;
}


Measured memory_bytes: 3648
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [X, A] = string_to_int(inputs[0])
    if X >= A:
        return 10
    else:
        return 0


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 2940
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>

using namespace std;

int my_abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int my_abs_B(long long num,long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int A, B;
    cin >> A >> B;
    int count = max(A, B);
    int moto = min(A, B);
    string ans = to_string(moto);
    string aaa = to_string(moto);
    int anss = 0;
    for (int i = 0; i < count-1; i++) {
        ans = ans + aaa;
    }
    cout << ans << endl;
    
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define maxn 200005
using namespace std;

int n,i,j,k,a[maxn];

struct segmenttree{
	int t[maxn*4],inf;
	void maketree(int x,int l,int r){
		t[x]=inf; if (l==r) return;
		int mid=(l+r)>>1;
		maketree(x<<1,l,mid),maketree(x<<1^1,mid+1,r);
	}
	int find(int x,int l,int r,int L,int R){
		if (l>R||r<L) return inf;
		if (L<=l&&r<=R) return t[x];
		int mid=(l+r)>>1;
		return max(find(x<<1,l,mid,L,R),find(x<<1^1,mid+1,r,L,R));
	}
	void change(int x,int l,int r,int p,int v){
		if (l==r) {t[x]=max(v,inf);return;}
		int mid=(l+r)>>1;
		if (p<=mid) change(x<<1,l,mid,p,v);
		else change(x<<1^1,mid+1,r,p,v);
		t[x]=max(t[x<<1],t[x<<1^1]);
	}
} t[2];

int bz[maxn],Q[maxn];
void prepare(){
	t[0].inf=0,t[1].inf=-1e9;
	t[0].maketree(1,1,n),t[1].maketree(1,1,n);
	int mx=0;
	for(i=1;i<=n;i++) mx=max(mx,a[i]),bz[i]=(a[i]==mx)+1;
	for(i=n;i>=1;i--) Q[i]=Q[i+1]+bz[i]-1;
	for(i=n;i>=1;i--) for(j=0;j<2;j++)
		t[j^(bz[i]&1)].change(1,1,n,a[i],t[j].find(1,1,n,a[i]+1,n)+bz[i]);
}

void clear(int i){
	t[0].change(1,1,n,a[i],t[0].inf);
	t[1].change(1,1,n,a[i],t[1].inf);
}

int s[maxn],lena,lenb,mxa,mxb;
int check(int i,int la,int lb,int ma,int mb){
	if (la-lb+Q[i]>=0&&t[(la-lb+Q[i])&1].find(1,1,n,mb+1,n)>=la-lb+Q[i])
		return 1;
	if (lb-la+Q[i]>=0&&t[(lb-la+Q[i])&1].find(1,1,n,ma+1,n)>=lb-la+Q[i])	
		return 1;
	return 0;
}

void doit(){
	lena=lenb=mxa=mxb=0;
	clear(1);
	if (!check(1,lena,lenb,mxa,mxb))
		printf("-1"),exit(0);
	for(i=1;i<=n;i++){
		if (check(i+1,lena+(a[i]>mxa),lenb,max(mxa,a[i]),mxb))
			s[i]=0,lena+=a[i]>mxa,mxa=max(mxa,a[i]); else 
			s[i]=1,lenb+=a[i]>mxb,mxb=max(mxb,a[i]);
		if (i<n) clear(i+1);
	}
}

int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	prepare();
	doit();
	for(i=1;i<=n;i++) putchar('0'+s[i]);
}

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

using namespace std;
using ll=long long;

int main() {
  ll n;
  cin >> n;
  ll y=n;
  string s;
  cin >> s;
  char x='#';
  for(int i=0;i<n;i++) {
    if(x==s.at(i)) {
      y-=1;}
    else {
      y-=0;}
    x=s.at(i);}
  cout << y << endl;
  return 0;
  }
    


Measured memory_bytes: 512
using System;
class Program {
    static void Main(string[] args) {
        //整数の入力
        int a = int.Parse(Console.ReadLine());
        //スペース区切りの整数の入力
        //string[] input = Console.ReadLine().Split(' ');
        //int b = int.Parse(input[0]);
        //int c = int.Parse(input[1]);
        //文字列の入力
        //string s = Console.ReadLine();
        //出力
        if(a>=30){
            Console.WriteLine("Yes");
        }
        else{
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 27472
// ２つの文字列 s1、s2 の編集距離（レーベンシュタイン距離）を求める

#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <climits>
#include <cassert>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair

// 参考：https://ja.wikipedia.org/wiki/%E3%83%AC%E3%83%BC%E3%83%99%E3%83%B3%E3%82%B7%E3%83%A5%E3%82%BF%E3%82%A4%E3%83%B3%E8%B7%9D%E9%9B%A2
int calc_edit_distance(string s1, string s2) {
    int len1 = SIZE(s1);
    int len2 = SIZE(s2);
    // len1+1 行 len2+1 列のテーブルを用意
    vector<vector<int>> d(len1+1, vector<int>(len2+1));
    REP(i, len1+1) d[i][0] = i;
    REP(i, len2+1) d[0][i] = i;
    FOR(i1, 1, len1+1) {
        FOR(i2, 1, len2+1) {
            int cost = (s1[i1-1] == s2[i2-1]) ? 0 : 1;
            d[i1][i2] = min(min(d[i1-1][i2] + 1,
                                d[i1][i2-1] + 1),
                            d[i1-1][i2-1] + cost);
        }
    }
    return d[len1][len2];
}

int main(){
    string s1, s2;
    cin >> s1 >> s2;

    auto ans = calc_edit_distance(s1, s2);
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 6872
[N,K] = list(map(int,input().split()))

if K>(N-1)*(N-2)/2:
    output =-1
    print(output)
else:
    output = []
    for i in range(2,N+1):
        output.append([1,i])
    count = int((N-1)*(N-2)/2)
    small = 2
    large = 3
    while (count!=K)and(count>0):
        output.append([small,large])
        count += -1
        large += 1
        if large > N:
            small += 1
            large = small+1

    print(len(output))
    for i in range(len(output)):
        print("{0} {1}".format(output[i][0], output[i][1]))

Measured memory_bytes: 3844
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int s, w;
	cin >> s >> w;
	if (w >= s) cout << "unsafe" << endl;
	else cout << "safe" << endl;


	return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        llin(n);
        llin(m);
        vllin(s,n);
        vllin(t,m);
        vvll d(n,vll(m,0));
        ll c=0;
        FOR(i,0,n-1){
                c=0;
                FOR(j,0,m-1){
                        if(s[i]==t[j]){
                                c=(c+(i==0|j==0?1:d[i-1][j-1]))%MOD;
                        }
                        d[i][j]=(c+(i==0?1:d[i-1][j]))%MOD;
                }
        }
        sal(d[n-1][m-1])
}


Measured memory_bytes: 31616
from bisect import bisect

A, B, Q = map(int, input().split())
s = [-10**15]
t = [-10**15]
for _ in range(A):
    s.append(int(input()))
s.append(10**15)
for _ in range(B):
    t.append(int(input()))
t.append(10**15)
x = list(map(int, (input() for _ in range(Q))))
for y in x:
    i = bisect(s, y)
    j = bisect(t, y)
    ans = min(
        max(abs(s[i] - y), abs(t[j] - y)),
        max(abs(s[i - 1] - y), abs(t[j - 1] - y)),
        2 * min(abs(s[i] - y), abs(t[j - 1] - y)) + max(abs(s[i] - y), abs(t[j - 1] - y)),
        2 * min(abs(s[i - 1] - y), abs(t[j] - y)) + max(abs(s[i - 1] - y), abs(t[j] - y))
    )
    print(ans)

Measured memory_bytes: 16156