akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Your code here!
s = input()

S = []
for i in s:
    S.append(int(i))
    
if len(S) % 2 == 0: #要素数が偶数の時
    ans = 0
    num1 = 0
    num2 = 0
    
    
    for i, Si in enumerate(S): #左0 右1
        if i % 2 == 0:
            if S[i] != 0:
                num1 += 1
        if i % 2 != 0:
            if S[i] != 1:
                num1 += 1
    
    for i, Si in enumerate(S): #左1 右0
        if i % 2 == 0:
            if S[i] != 1:
                num2 += 1
        if i % 2 != 0:
            if S[i] != 0:
                num2 += 1
    
    ans = min([num1, num2])
    print(ans)

if len(S) % 2 != 0: #要素数が奇数の時
    ans = 0
    num1 = 0
    num2 = 0
    
    
    for i, Si in enumerate(S): #両方1
        if i % 2 == 0:
            if S[i] != 1:
                num1 += 1
        if i % 2 != 0:
            if S[i] != 0:
                num1 += 1
    
    for i, Si in enumerate(S): #両方0
        if i % 2 == 0:
            if S[i] != 0:
                num2 += 1
        if i % 2 != 0:
            if S[i] != 1:
                num2 += 1
    
    ans = min([num1, num2])
    print(ans)

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL a(n);
	cin >> a;
	for (int i = 0; i < n; i++) {
		if (a[i]%2 == 1) {
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
	return 0;
}


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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int N, K;
  string S;
  cin >> N >> K >> S;

  string M, m;
  char moji;

  for(moji='A'; moji<='Z';moji++){
    M+=moji;
  }


  for(moji='a'; moji<='z';moji++){
    m+=moji;
  }

  REP(i, 26) if(S.at(K-1)==M.at(i)) S.at(K-1)=m.at(i);


  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] v = new int[n];
		Arrays.fill(v, -1);
		
		for (int i = 0; i < m; i++) {
			int s = sc.nextInt() - 1;
			int c = sc.nextInt();
			
			if (n > 1 && s + c == 0 || v[s] >= 0 && v[s] != c) {
				System.out.println(-1);
				sc.close();
				return;
			}
			
			v[s] = c;
		}
		
		for (int i = 0; i < n; i++) {
			if (v[i] == -1) {
				v[i] = i == 0 && n > 1 ? 1: 0;
			}
		}
		
		String ans = Arrays.toString(v).replaceAll("\\D", "");
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  double N;
  cin >> N;
  printf("%.0f", pow(floor(sqrt(N)), 2));
}


Measured memory_bytes: 888
import java.util.Arrays;
import java.util.Scanner;

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

        while (n > 0) {
            n /= 2;
            k += 1;
        }

        System.out.println(1 << (k - 1));
    }
}

Measured memory_bytes: 21844
#include<cstdio>
#include<queue>
using namespace std;
typedef long long ll;
int main(){
    int x,y,z,k;
    ll a[1000],b[1000],c[1000],ans=0,d;
    priority_queue<ll> q1,q2;
    scanf("%d %d %d %d",&x,&y,&z,&k);
    for(int i=0;i<x;i++){
        scanf("%lld",&a[i]);
    }
    for(int i=0;i<y;i++){
        scanf("%lld",&b[i]);
    }
    for(int i=0;i<z;i++){
        scanf("%lld",&c[i]);
    }
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            q1.push(a[i]+b[j]);
        }
    }
    for(int i=0;i<k&&!q1.empty();i++){
        d=q1.top();
        q1.pop();
        for(int j=0;j<z;j++){
            q2.push(c[j]+d);
        }
    }
    for(int i=0;i<k;i++){
        printf("%lld\n",q2.top());
        q2.pop();
    }
}

Measured memory_bytes: 43364
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
 
using namespace std;
 
using pii = pair<int, int>;
 
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}
 
bool match(char c1, char c2) {
    return c1 == c2 || c1 == '?' || c2 == '?';
}
 
// return L.
// L[i] (0 <= i < a.size()) is the length of the longest common prefix of a[i:] and b.
vector<int> get_L(string a, string b) {
    vector<int> L(a.size());
    REP(i, a.size()) {
        int j = 0;
        while (i + j < a.size() && j < b.size() && match(a[i + j], b[j])) {
            ++j;
        }
        L[i] = j;
    }
    return L;
}
 
int main() {
 
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    vector<string> a(3);
    REP(i, 3) cin >> a[i];
 
    map<pii, vector<int>> L;
    REP(i, 3) REP(j, 3) {
        if (i == j) continue;
        L[pii(i, j)] = get_L(a[i], a[j]);
    }
 
    int result = a[0].size() + a[1].size() + a[2].size();
 
    REP(k0, 3) { // a[k0] is the prefix of s.
        REP(k1, 3) {
            if (k1 == k0) continue;
            REP(k2, 3) {
                if (k2 == k0 || k2 == k1) continue;
                REP(i, a[k0].size() + 1) FOR(j, i, max(a[k0].size(), i + a[k1].size()) + 1) {
                    // a[k1] starts at index i of s.
                    // a[k2] starts at index j of s.
 
                    int first, last;
 
                    // check whether a[k0] and a[k1] have overlap (and match).
                    first = i;
                    last = min(a[k0].size(), i + a[k1].size());
                    if (first < last) { // have overlap.
                        if (last - first > L[pii(k0, k1)][i]) { // do not match.
                            continue;
                        }
                    }
 
                    // check whether a[k0] and a[k2] have overlap (and match).
                    first = j;
                    last = min(a[k0].size(), j + a[k2].size());
                    if (first < last) { // have overlap.
                        if (last - first > L[pii(k0, k2)][j]) { // do not match.
                            continue;
                        }
                    }
 
                    // check whether a[k1] and a[k2] have overlap (and match).
                    first = max(i, j);
                    last = min(i + a[k1].size(), j + a[k2].size());
                    if (first < last) { // have overlap.
                        if (last - first > L[pii(k1, k2)][j - i]) { // do not match.
                            continue;
                        }
                    }
 
                    int length_s = max(a[k0].size(), max(i + a[k1].size(), j + a[k2].size()));
                    amin(result, length_s);
                }
            }
        }
    }
 
    cout << result << endl;
 
    return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
)

func combination(n, k int) int {
	if n < k {
		return 0
	}
	x := 1
	y := 1
	for i := 0; i < k; i++ {
		x *= (n - i)
		y *= i + 1
	}
	return x / y
}

func main() {
	var s string
	var k int

	fmt.Scan(&s, &k)

	a := []int{}
	for i := 0; i < len(s); i++ {
		a = append(a, int(s[i]-'0'))
	}

	var ret int
	if k == 1 {
		ret = (len(a) - 1) * 9
		ret += a[0]
	} else if k == 2 {
		ret = combination(len(a)-1, k) * 9 * 9
		ret += (a[0] - 1) * (len(a) - 1) * 9

		for i := 1; i < len(a); i++ {
			if a[i] > 0 {
				ret += a[i]
				ret += (len(a) - i - 1) * 9
				break
			}
		}
	} else if k == 3 {
		ret = combination(len(a)-1, k) * 9 * 9 * 9
		ret += (a[0] - 1) * combination(len(a)-1, k-1) * 9 * 9
		for i := 1; i < len(a); i++ {
			if a[i] > 0 {
				// i桁目が0
				ret += combination(len(a)-i-1, k-1) * 9 * 9
				// i桁目が最大値以下
				ret += (a[i] - 1) * combination(len(a)-i-1, k-2) * 9
				// i桁目が最大値
				for j := i + 1; j < len(a); j++ {
					if a[j] > 0 {
						ret += a[j]
						ret += (len(a) - j - 1) * 9
						break
					}
				}
				break
			}
		}
	}

	fmt.Println(ret)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i=0; i<N; i++){
   cin >> v.at(i);
  }
  int ans = 0;
  ans = v.at(0)-v.at(1);
  if(ans < 0){
    ans *= -1;
  }
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
    if(v.at(i) >= v.at(j)){
      if(v.at(i)-v.at(j) > ans){
        ans = v.at(i)-v.at(j);
      }
    }
    if(v.at(i) < v.at(j)){
      
   if(v.at(j)-v.at(i) > ans){
        ans = v.at(j)-v.at(i);
      }
    }
    }
  }
  cout << ans << endl;
    
	
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll ,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define REP(i,x,y) for(ll i = x;i <= y;++i)
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z))
        ;
    return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
void localTest() {
    #ifndef ONLINE_JUDGE
        freopen("inp", "r", stdin);
        freopen("out", "w", stdout);
    #endif      
}
const ll N = 2e5 + 5;
ll A[N], B[N];
int main() {

    localTest();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, ans = 0, l, r;
    cin >> n;
    for(ll i = 1;i <= n;++i) cin >> A[i] >> B[i]; 
    sort(A + 1, A + 1 + n);
    sort(B + 1, B + 1 + n);
    if(n & 1) l = A[(n + 1) / 2], r = B[(n + 1) / 2];
    else l = A[n / 2] + A[n / 2 + 1], r = B[n / 2] + B[n / 2 + 1];
    ans = r - l + 1;
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 6792
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int n = sc.nextInt();
			calc(n);
		}
	}
	public void calc(int n){
		int[][] gyouretsu = new int[n][n];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				gyouretsu[i][j] = 0;
			}
		}
		for(int i = 0; i < n; i++){
			int u = sc.nextInt();
			int k = sc.nextInt();
			for(int j = 0; j < k; j++){
				int v = sc.nextInt();
				gyouretsu[u-1][v-1] = 1;
			}
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				System.out.print(gyouretsu[i][j]);
				if(j != n-1){
					System.out.print(" ");
				}
			}
				System.out.println();
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

const double PI = acos(-1.0);

// long long積のオーバーフロー検出
bool detect_mul_overflow(ll a, ll b)
{
    return a >= LONG_MAX / b;
}

int lcm(int a, int b)
{
    //最小公倍数
    return a / __gcd(a, b) * b;
}

struct edge
{
    int from, to, cost;
};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));


string S;

int main()
{
    cin>>S;
    int ans=0;
    for(const auto& e :S){
        ans+=(int(e-'0')%9);
        ans%=9;
    }

    if(ans%9==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3720
#include <stdio.h>
int main(){
  int n,i,a[100001],t=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  for(i=0;i<n+1;i++){
    t=a[t]-1;
    if(t==1){
      printf("%d",i+1);
      return 0;
    }
  }
  puts("-1");
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define ll long long
#define fm_t  ll t;cin>>t;while(t--)
#define fr(i,a,b) for( ll i=a;i<b;i++)
#define fr1(i,n,a) for( ll i=n-1;i>=a;i--)
#define sz(x) (ll)(x).size()
#define all(v)  (v).begin(), (v).end()
#define Sort(x) sort(x.begin(),x.end())
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
const ll mod = 998244353;
#define Mod 1000000007

#define inf 1e18
#define ld long double
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define pi pair<ll, ll>
#define ppi pair<pair<ll, ll>, ll>
#define ump unordered_map<ll,ll>
#define pri priority_queue< pair<ll,ll> , vector< pair<ll,ll> >, greater< pair<ll,ll> > >
void ingraph(vl graph[], ll m){ll x, y;fr(i,0,m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)

//setprecision(10)
//greater<int>()
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll modinv(ll a){
    return modpower(a,mod-2);
}   
     
int main()
{
      
    fast;
  ll n;
  cin>>n;
 map<ll,ll>mp;
 fr(i,0,n)
 {
    ll a;
    cin>>a;
    mp[a]++;
 }
 vlp v;
 for(auto it:mp)
 {
    v.pb({it.ff,it.ss});
   // cout<<it.ff<<" "<<it.ss<<endl;
 }
 n=sz(v);
 ll ans=0;
 for(ll i=0;i<n;i++)
 {
    for(ll j=i+1;j<n;j++)
    {
        for(ll k=j+1;k<n;k++)
        {
            if(v[i].ff+v[j].ff>v[k].ff)
            {
                ans+=((v[i].ss)*(v[j].ss)*(v[k].ss));
               // cout<<v[i].ss<<" "<<v[j].ss<<" "<<v[k].ss<<endl;

            }
            
        }
    }
 }
 cout<<ans<<endl;
    
//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
return 0;
}

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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int pow = (int)Math.pow(2, m);
		int ans = (1900 * m + 100 * (n - m) ) * pow;
		
		out.println(ans);

		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}

Measured memory_bytes: 21204
#include<iostream>

using namespace std;

int main()
{
	int a[5],k;

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

	cin >> k;

	for(int i=0;i<5;i++)
	{
		for(int j=i+1;j<5;j++)
		{
			int distance = abs(a[i] - a[j]);

			//cout << a[i] <<":"<<a[j] <<"-"<<abs(a[i] - a[j]) << endl;

			if(distance > k)
			{
				cout << ":(" << endl;
				return 0;
			}
		}
	}

	cout << "Yay!" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		char[] S = sc.next().toCharArray();
		int N = S.length + 1;
		int[] elems = new int[N];
		Arrays.fill(elems, - 1);
		if (S[0] == '<') elems[0] = 0;
		if (S[N-2] == '>') elems[N - 1] = 0;
		for (int i = 0; i + 1 < N - 1; i++) {
			if (S[i] == '>' && S[i + 1] == '<') {
				elems[i + 1] = 0;
			}
		}
		for (int i = 0; i < N - 1; i++) {
			if (S[i] == '<' && elems[i] >= 0) {
				elems[i + 1] = Math.max(elems[i + 1], elems[i] + 1);
			}
		}
		for (int i = N - 2; i >= 0; i--) {
			if (S[i] == '>' && elems[i + 1] >= 0) {
				elems[i] = Math.max(elems[i], elems[i + 1] + 1);
			}
		}
		long ans = 0;
		for (int elem : elems) {
			ans += elem;
		}
		out.println(ans);
		
		out.flush();
	}
	
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 29456
#include<stdio.h>

int main(){
	
	/*準備部分*/
	int n,h,i,j,b,f,r,v,ninzu[4][3][10]={};
	
	/*入力部分*/
	scanf("%d",&n);
	for(h=0;h<n;h++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		ninzu[b-1][f-1][r-1]+=v;
	}
	
	/*出力部分*/
	for(h=0;h<4;h++){
		for(i=0;i<3;i++){
			for(j=0;j<10;j++){
				printf(" %d",ninzu[h][i][j]);
			}
			printf("\n");
		}
		if(h<3)printf("####################\n");
	}
	
	return 0;
}



Measured memory_bytes: 2108
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    ll X[100010];
    rep(i, N) cin >> X[i];
    ll ans = 0;
    rep(i, N - 1) {
        ans += min((X[i + 1] - X[i])* A , B);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   ll n;
   cin >> n;
   vector<int> a(n + 1);
   vector<ll> s(n + 1);
   vector<ll> cmb(n + 1);

   ll acc = 0;

   FOR(i, 1, n + 1)
   {
      cin >> a[i];
      s[a[i]]++;
   }
   FOR(i, 1, n + 1)
   {
      acc+= s[i] * (s[i] - 1LL) / 2LL;
   }
   // ll acc = accumulate(cmb.begin()+1, cmb.end(), 0);
   FOR(i, 1, n + 1)
   {
      // cout << (acc - s[a[i]] + 1LL) << endl;
      printf("%lld\n", acc - s[a[i]] + 1LL);
   }
   return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>

#define LOWER_MAX 9999999

struct NUMBER {
	int upper;
	int lower;
	int minus; // 1 = minus, 0 = plus
};

void add( struct NUMBER *sum, int new_val ){
	if( new_val > 0 ){
		if( ! sum->minus ) {
			// Plus + Plus
			sum->lower = sum->lower + new_val;
			if( sum->lower > LOWER_MAX ) {
				sum->upper = sum->upper + 1;
				sum->lower = sum->lower - LOWER_MAX - 1;
			}
		} else {
			// Minus + Plus
			sum->lower = sum->lower - new_val;
			if( sum->lower  <= 0 ){
				if( sum->upper > 0 ){
					sum->upper = sum->upper - 1;
					sum->lower = sum->lower + LOWER_MAX + 1;
				} else {
					sum->lower = sum->lower * (-1);
					sum->minus = 0;
				}
			}
		}
	} else if( new_val < 0 ) {
		if( sum->minus ){
			// Minus + Minus
			sum->lower = sum->lower + (-new_val);
			if( sum->lower > LOWER_MAX ) {
				sum->upper = sum->upper + 1;
				sum->lower = sum->lower - LOWER_MAX - 1;
			}
		} else {
			// Plus + Minus
			sum->lower = sum->lower - (-new_val);
			if( sum->lower  < 0 ){
				if( sum->upper > 0 ){
					sum->upper = sum->upper - 1;
					sum->lower = sum->lower + LOWER_MAX + 1;
				} else {
					sum->lower = sum->lower * (-1);
					sum->minus = 1;
				}
			}
		}
	}
}

int main(int argc, char **argv){
	int i;
	int len,val;
	int min,max;
	struct NUMBER sum;
	
	// Input Length
	scanf("%d",&len);
	
	// Input First Number
	scanf("%d",&val);
	min = val;
	max = val;
	sum.lower = 0;
	sum.upper = 0;
	sum.minus = 0;
	add(&sum,val);
	
	// Input Rest Number
	for(i=1;i<len;i++){
		scanf("%d",&val);
		if( val < min ){
			min = val;
		}
		if( val > max ){
			max = val;
		}
		add( &sum, val);
	}

	// Output
	printf("%d %d ", min,max);
	if( sum.minus ){
		printf("-");
	}
	if( sum.upper > 0 ){
		printf("%d%07d\n",sum.upper,sum.lower);
	} else {
		printf("%d\n",sum.lower);
	}
	
	return 0;
}

Measured memory_bytes: 604
tiles = gets.strip.split('').map(&:to_i)
count = 0
prev_tile = nil
tiles.each_with_index do |tile, index|
  if index == 0
    prev_tile = tile
  else
    if tile == prev_tile
      prev_tile = tile == 1 ? 0 : 1
      count += 1
    else
      prev_tile = tile
    end
  end
end

puts count

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

  
    return 0;
}

Measured memory_bytes: 1404
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> g[100000];
int dist[2][100000],id;
void dfs(int idx,int par=-1){
	if(~par)	dist[id][idx]=dist[id][par]+1;
	for(int j=0;j<g[idx].size();j++){
		if(g[idx][j]!=par)	dfs(g[idx][j],idx);
	}
}
int main(){
	cin>>N;
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		--a;--b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	id=0;
	dfs(0);
	id=1;
	dfs(N-1);
	int ret=0;
	for(int i=0;i<N;i++){
		if(dist[0][i]<=dist[1][i])	++ret;
	}
	if(ret>=(N+2)/2)	cout<<"Fennec"<<endl;
	else{
		cout<<"Snuke"<<endl;
	}
	return 0;
}

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




int main()
{
    long long int a,b,c,d,e,f,i,j,k,n,m,t,s,q,l,r;


    string s1;
    cin>>s1;
    a=0;
    b=0;
    c=0;
    n=s1.size();
    for(i=n-1;i>=0;i--)
    {
        if(s1[i]=='0')
        {
            a++;
        }
        else
        {
            b++;
        }
    }
    c=min(a,b);
    cout<<c*2<<"\n";
    return 0;
}


Measured memory_bytes: 512
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}
int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n,k;
	cin>>n>>k;
	vi dp(k+1);
	vi a(n);
	forci(0,n)	cin>>a[i];
	for(int stones=0;stones<=k;stones++)
	{
		for(auto x:a)
		{
			if(stones>=x && !dp[stones-x])
				dp[stones]=true;
		}
	}
	if(dp[k]==1)
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;


}
signed main()
{
	fastio;
//	test
		solve();
}




Measured memory_bytes: 1024
N, *L = map(int, open(0).read().split())
MOD = 10**9+7
D = [b-a for a,b in zip(L,L[1:])]
f = [1]
for i in range(1,N+1):
  f.append(f[-1]*i%MOD)
C = [1]
for i in range(1,N-1):
  C.append((C[-1]+pow(i+1,MOD-2,MOD))%MOD)
ans = sum(d*c for d,c in zip(D,C))%MOD
print(ans*f[N-1]%MOD)

Measured memory_bytes: 18840
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t = 0;
  cin >> n;
  vector<int> S(n);
  for (int i = 0; i < n; i++) {
      cin >> S.at(i);
  }
  for (int i = 0; i < n - 2; i++) {
      if ((S.at(i) < S.at(i + 1) && S.at(i + 1) < S.at(i + 2))|| (S.at(i) > S.at(i + 1) && S.at(i + 1) > S.at(i + 2))) {
          t += 1;
      }
  }
  cout << t << endl;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
Ap = [a+1 for a in A]
Am = [a-1 for a in A]
label = set(A+Ap+Am)
dict = {l:0 for l in label}
for a in A+Ap+Am:
    dict[a]+=1
print(max(dict.values()))

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

#define X first
#define Y second
#define ll long long
#define MP make_pair
#define PB push_back

using namespace std;

const int MAXN=1e5;

ll n,mat[5][MAXN+5],dp[5][MAXN+5];

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

	cin>>n;
	for(int i=0; i<n; i++){
		cin>>mat[0][i]>>mat[1][i]>>mat[2][i];
	}
	dp[0][0]=mat[0][0];
	dp[1][0]=mat[1][0];
	dp[2][0]=mat[2][0];
	for(int i=1; i<n; i++){
		dp[0][i]=mat[0][i]+max(dp[1][i-1],dp[2][i-1]);
		dp[1][i]=mat[1][i]+max(dp[0][i-1],dp[2][i-1]);
		dp[2][i]=mat[2][i]+max(dp[0][i-1],dp[1][i-1]);
	}
	cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
	
	return 0;
}

Measured memory_bytes: 8276
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; i < (i64)(n); ++i)
#define WHOLE(x) std::begin(x), std::end(x)
#define LEN(a) int((a).size())

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

template <typename T>
using V = std::vector<T>;
template <typename T>
vector<T> make_vec(size_t n, T a) {
  return vector<T>(n, a);
}
template <typename... Ts>
auto make_vec(size_t n, Ts... ts) {
  return vector<decltype(make_vec(ts...))>(n, make_vec(ts...));
}
template <typename T>
istream &operator>>(istream &is, vector<T> &a) {
  for (auto &x : a) is >> x;
  return is;
}
template <typename Container>
ostream &pprint(const Container &a, string_view sep = " ",
                string_view ends = "\n", ostream *os = nullptr) {
  if (os == nullptr) os = &cout;
  auto b = std::begin(a), e = std::end(a);
  for (auto it = std::begin(a); it != e; ++it) {
    if (it != b) *os << sep;
    *os << *it;
  }
  return *os << ends;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
  return pprint(a, ", ", "", &(os << "[")) << "]";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &a) {
  return pprint(a, ", ", "", &(os << "{")) << "}";
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &a) {
  return pprint(a, ", ", "", &(os << "{")) << "}";
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &a) {
  return os << "(" << a.first << ", " << a.second << ")";
}

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  V<tuple<i64, i64, i64>> cakes(N);
  REP(i, N) {
    i64 x, y, z;
    cin >> x >> y >> z;
    cakes[i] = {x, y, z};
  }
  i64 ans = 0;
  REP(s, 8) {
    int sx = s >> 2 & 1;
    int sy = s >> 1 & 1;
    int sz = s & 1;
    V<i64> v(N);
    REP(i, N) {
      auto [x, y, z] = cakes[i];
      v[i] += sx ? -x : x;
      v[i] += sy ? -y : y;
      v[i] += sz ? -z : z;
    }
    nth_element(v.begin(), v.begin() + M, v.end(), greater<i64>());
    i64 sum = 0;
    REP(i, M) { sum += v[i]; }
    chmax(ans, sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3692
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;

	string s;
	int sum = 0;
	for (int i = 0; i < h; i++) {
		cin >> s;
		for (int j = 0; j < w; j++) {
			if (s[j] == '#') {
				sum++;
			}
		}
	}
	cout << (sum == h + w - 1 ? "Possible" : "Impossible") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
const int maxN = 100010;
const int MAXM = 310;
const int MAXK = 17;
const int MOD = 1000000007;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;
 
int a[maxN];
int b[maxN];
int c;
int n,m; 
struct node
{
	int x,y;
	bool operator<(const node& p)const
	{
		return x<p.x;
	}	
};
node s[maxN];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&s[i].x,&s[i].y);
	}
	sort(s+1,s+1+n);
	ll ans = 0;
	for(int i=1;i<=n;i++)
	{
		if(s[i].y >= m)
		{
			ans += (ll)s[i].x * m;
			break;
		}
		else
		{
			ans += (ll)s[i].x * s[i].y;
			m -= s[i].y;
		}
	}
	cout<<ans<<endl;
    return 0;
}

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

int main()
{
	ll m,i,j,k,s=0,x=0,y=0,z,a,n,b,c,g,minn=INT_MIN;
cin>>n>>m;
	a=max(n,m);
	b=min(n,m);
	for(i=0;i<a;i++)
	{cout<<b;
	}
	
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll X,N;
ll p[101];
bool f[101]={};
int main(){
    cin>>X>>N;
    for(ll i=0;i<N;i++){
        ll p;cin>>p;
        f[p]=true;
    }
    ll minDif=INF;
    ll ans=INF;
    for(ll i=0;i<=101;i++){
        if(!f[i] && minDif > abs(i-X)){
            minDif=abs(i-X);
            ans=i;
        }
    }
    cout<<ans<<endl;
    

    return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include<vector>
#include<map>
#include<iostream>
#include<string>

typedef long long ll;

using namespace std;

int main()
{
	//A, C, G, T が存在し、A と T、C と G がそれぞれ
	char c;

	cin >> c;

	if (c == 'A')
		cout << 'T';
	else if (c == 'C')
		cout << 'G';
	else if (c == 'G')
		cout << 'C';
	else
		cout << 'A';

	return 0;
}


Measured memory_bytes: 256
N = int(input())
Al = sorted([int(i) for i in input().split()])
maxAl = Al[-1]
markl = [-1] * (maxAl+1)

for i in Al:
    if markl[i] == 1:
        continue
    if markl[i] == 0:
        markl[i] = 1
        continue
    markl[i] = 0
    p = i*2
    while p <= maxAl:
        markl[p] = 1
        p += i
print(markl.count(0))

Measured memory_bytes: 32192
N = int(input())
a = list(map(int,input().split()))

check = 1
ans = 0


for i in a:
  ans+=1
  if i == check:
    ans -=1
    check+=1
    
if a==[j for j in range(1,N+1)]:
  print(0)
  exit()
  
elif ans==N:
  print(-1)
  exit()

print(ans)
  
  



Measured memory_bytes: 33328
n = int(input())
h_list = list(map(int,input().split()))
ans = 0
f = True
while f:
    f = False
    e = True
    for i in range(n):
        if h_list[i] > 0:
            h_list[i] -= 1
            if e:
                ans += 1
            f = True
            e = False
        else:
            e = True
print(ans)

Measured memory_bytes: 3064
import std.stdio;
import std.algorithm;
import std.conv;
import std.array;
import std.string;
import std.math;
import std.functional;
import std.range;

void main(string[] args) {
  readln;
  readln.solve.writeln;
}

auto solve(string input) {
  return input.split.map!(to!int).map!(a => divCount(a, 2)).minElementAlt;
  // return input.split.map!(to!int).map!(a => divCount(a, 2)).minElement;
}

unittest {
  assert(solve("8 12 40") == 2, "1");
  assert(solve("5 6 8 10") == 0, "2");
  assert(solve("382253568 723152896 37802240 379425024 404894720 471526144") == 8, "3");
}

// ----------------------------------------

pure auto minElementAlt(Range)(Range r) 
if (isInputRange!Range && !isInfinite!Range) {
  import std.algorithm: min;
  auto res = r.front;
  foreach(v; r) {
    res = min(v, res);
  }
  return res;
} unittest {
  assert([4, 6, 3, 0, 1].minElementAlt == 0);
}


pure auto divCount(int n, int base) {
  auto count = 0;
  while (n % base == 0) {
    n /= base;
    count++;
  }
  return count;
} unittest {
  assert(divCount(12, 2) == 2);
  assert(divCount(125, 2) == 0);
  assert(divCount(81, 3) == 4);
}

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

const int INF = 1001001001;

int main() {
string s;
cin >> s;
long long ans = 0;
for (int tmp = 0; tmp < (1 << s.size()-1); tmp++) {
  string ka;
  ka.push_back(s.at(0));
  bitset<10> bt(tmp);
  for (int i = 0;i < s.size() - 1;i++) {
    if (bt.test(i)) {
      ans += stoll(ka);
      ka = '0';
      ka.push_back(s.at(i+1));
    } else {
      ka.push_back(s.at(i+1));
    }
  }
  ans += stoll(ka);
  }

cout << ans << endl;



return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 305
using namespace std;
int n;
bool vis[M][M][M];
double dp[M][M][M];

double dfs(int x,int y,int z) {
    if (x<0 || y<0 || z<0) return 0.0;
    if (x==0 && y==0 && z==0) return 0.0;
    if (vis[x][y][z]) return dp[x][y][z];
    vis[x][y][z] = true;
    double &res = dp[x][y][z];
    
    double f = (double)(n-x-y-z) / n;
    res = dfs(x-1, y, z)*((double)x/n) +
        dfs(x+1, y-1, z)*((double)y/n) +
        dfs(x, y+1, z-1)*((double)z/n) +
        1.0;
    res /= (1.0 - f);
    return res;
}
int main()
{
    int c[4] = {0, 0, 0, 0};
    scanf("%d", &n);
    REP(i,1,n) {
        int x;
        scanf("%d", &x);
        c[x]++;
    }

    printf("%.10f\n", dfs(c[1], c[2], c[3]));
    return 0;
}


Measured memory_bytes: 127292
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1.0)

#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pf(a) printf("%lld\n",a)

#define stll(a) stoll(a,nullptr,10)
#define all(a) a.begin(),a.end()
#define PII pair<ll,ll>
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define EL printf("\n")
#define ff first
#define ss second
#define rev(a) reverse(all(a))


#define mem(ar,val) memset(ar,val,sizeof(ar))
#define ssort(ar) sort(ar.begin(),ar.end())
#define csort(ar,comp) sort(ar.begin(),ar.end(),comp)

#define bug1(a) cout<<"test "<<a<<endl;
#define bug2(a,b) cout<<"test "<<a<<" "<<b<<endl;
#define bug3(a,b,c) cout<<"test "<<a<<" "<<b<<" "<<c<<endl;
#define bug4(a,b,c,d) cout<<"test "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define fout freopen("output.txt","w",stdout)
#define fin  freopen("input.txt","r",stdin)

/// unordered_map<int,int>mp;
/// mp.reserve(1024);
/// mp.max_load_factor(0.25);

/// pbds
/// *find_by_order(k) - return k th largest element.. 0 based
/// order_of_key(k) - number of items strictly smaller than k

/*
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
*/

typedef long long ll;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

int main()
{
    ll n;
    cin>>n;
    cout<<n+ n*n+n*n*n<<endl;
}














Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define loop(i, sta, end, inc) for(int i = sta; i <= end; i += inc)
#define itr(it, l)             for(auto it = l.begin(); it != l.end(); it ++)
#define in(a, b, c)            assert( b <= a && a <= c)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define what_is(x) cerr<<#x<<" ="<<x<<" ";
#define error(args...)  { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define LINT_MAX  9223372036854775807
#define LINT_MIN -9223372036854775808
#define EPS 1e-9
#define MOD 1000000007
#define DEBUG 0

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
void err(istream_iterator<string> it) { cerr<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    if(DEBUG == 0)return;
	cerr << *it << " = " << a <<" ";
	err(++it, args...);
}
int A[100000];
int dp[100000];
int main(){
   // freopen("test.txt", "r", stdin);
    int n;cin>>n;
    forn(i,n)cin>>A[i];
    dp[0]=0;
    dp[1]=dp[0]+abs(A[1]-A[0]);
    for(int i=2; i < n ;i++){
      dp[i]=min((dp[i-1]+abs(A[i]-A[i-1])),(dp[i-2]+abs(A[i]-A[i-2])));
    }
    cout<<dp[n-1]<<endl;

    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


struct UnionFind{
    vector<int> par;
    UnionFind(int n) : par(n){
       rep(i, n) par[i] = i;
    }
    int root(int x){
        if(x == par[x]) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(x < y) swap(x, y);
        par[x] = y;
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
};

int main(){
  int N, K;
  cin >> N >> K;
  int p[N];
  rep(i, N){
    int a; cin >> a;
    a--;
    p[i]=a;
  }
  UnionFind uf(N);
  rep(i, K){
    int x, y;
    cin >> x >> y;
    x--; y--;
    uf.unite(x, y);
  }
  int ans=0;
  rep(i, N){
    ans += uf.same(i, p[i]);
  }
  cout << ans << endl;  
}

Measured memory_bytes: 1024
# ABC070_B
A,B,C,D = map(int, input().split())
f = []
s = []
# 先にボタンを押し始めたほうをfに格納する
if A <= C:
    f = [A, B]
    s = [C, D]
else:
    s = [A, B]
    f = [C, D]

ans = 0
if f[1] <= s[0]:
    ans = 0
elif s[1] <= f[1]:
    ans = s[1] - s[0]
elif f[1] <= s[1]:
    ans = f[1] - s[0]

print(ans)
     

Measured memory_bytes: 9228
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll n,m,i,j,k,l,t,a,b,c,d,arr[100009];
map<ll,ll>mp;
vector<ll>v[100009];
int main()
{
    scanf("%lld %lld",&n,&k);
    for(i=1;i<=n;i++)
        scanf("%lld",&arr[i]);
    for(i=1;i<=k;i++)
    {
        scanf("%lld %lld",&a,&b);
        v[a].push_back(b);
    v[b].push_back(a);
    }
    for(i=1;i<=n;i++)
    {
        b=0;
        for(j=0;j<v[i].size();j++)
        {
            a=v[i][j];
            if(arr[a]>=arr[i])
                b++;
        }
        if(b==0)
            c++;
    }
    printf("%lld\n",c);
}


Measured memory_bytes: 10420
#include <iostream>

int main(int argc, char** argv)
{
    int N;
    std::cin >> N;
    int p;
    int c = 0;
    for (int i = 0; i < N; i++) {
        std::cin >> p;
        if ((i+1) != p) {
            c++;
        }
    }

    if (c == 0 || c == 2) {
        std::cout << "YES" << std::endl;
    }
    else {
        std::cout << "NO" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<queue>
#include<cmath>
#include <string>
#include<map> 
#include<deque>  
#include<vector>
#include<bitset>
#include<string>  
#include<cstring> 
#include<stack>  
#include<set>
#include<functional>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<long long,long long> pll;
char ch[9];
int e[11][11],m,n,mp;
ll ans;
void floyd(){
	for(int k=0;k<10;k++)
    for(int i=0;i<10;i++)
        for(int j=0;j<10;j++)
            if(e[i][j]>e[i][k]+e[k][j])
                 e[i][j]=e[i][k]+e[k][j];
}
int main()
{
	scanf("%d%d",&m,&n);
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			scanf("%d",e[i]+j);
		}
	}floyd();
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			scanf("%d",&mp);
			if(~mp)ans+=e[mp][1];
		}
	} cout<<ans<<endl;
	return 0;
}

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

#define INF 1e9
using namespace std;

int main() {

    string S; cin >> S;

    int count = 0;

    for (int i = 0; i < 15; ++i) {
        if (S[i] == 'x') {
            ++count;
        }
    }

    if (count <= 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256