akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  REP(i, N) cin >> d[i];
  ll ans = 0;
  REP(i, N - 1) for (int j = i + 1; j < N; j++) { ans += d[i] * d[j]; }
  cout << ans << endl;
}

Measured memory_bytes: 256
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cerr << fixed << setprecision(15);
  }
} io_setup;

constexpr char el = '\n';

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U>& p) {
  os << p.first << " " << p.second;
  return os;
}
template<typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template<typename T>
ostream &operator<<(ostream &os, const vector< T > &v) {
  rep(i, v.size())
    os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T>
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}
#line 2 "a.cpp"

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

  bool f = 0;
  for (auto&& i : s) {
    if (i == '7') {
      f = 1;
    }
  }

  if (f) cout << "Yes" << el;
  else cout << "No" << el;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    cin >> N;
    vi X(N);
    rep(i, N) cin >> X[i];

    int res = 1e9;
    FOR(i, 1, 100) {
        int t = 0;
        rep(j, N) {
            t += pow(abs(i-X[j]), 2);
        }
        res = min(res, t);
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
para_line = list(map(int,input().split(' ')))
city = []
for i in range(para_line[1]):
    line = list(map(int,input().split(' ')))
    city.append(line+[i])
city.sort(key = lambda a: a[1])
city_cnt = [0 for k in range(para_line[0])]
for n in range(para_line[1]):
    city_cnt[city[n][0]-1] += 1
    city[n].append(str(city[n][0]).zfill(6)+str(city_cnt[city[n][0]-1]).zfill(6))
city.sort(key = lambda b: b[2])
for j in city:
    print(j[3])


Measured memory_bytes: 35420
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    dp = [0] * (n+1)

    dp[1] = 1

    for i in range(2, n+1):
        dp[i] = dp[i-1] + 1
        k = 6
        while i - k>=0:
            dp[i] = min(dp[i], dp[i-k] + 1)
            k *= 6
        k = 9
        while i -k >=0:
            dp[i] = min(dp[i], dp[i-k] + 1)
            k *= 9
    
    print(dp[n])

solve()


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

int main(){
  int n,k,q; cin>>n>>k>>q;
  vector<int> ok(n);
  for(int i=0; i<q; ++i){
    int a; cin>>a;
    ++ok[a-1];
  }

  for(int i=0; i<n; ++i){
    if(k-q+ok[i]>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}


Measured memory_bytes: 1024
x;char s[20];d(int l,int r,int k){x=abs(s[l]-s[r]);return l<0||!s[r]?k:x&&x<3?d(l-1,r+1,k+2):fmax(d(l-1,r,k),d(l,r+1,k));}main(){scanf("%s",s);x=strchr(s,'i')-s;printf("%d\n",d(x-1,x+3,3));exit(0);}

Measured memory_bytes: 544
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

//Manacher O(S)
//戻り値: r[i]: s[i]を中心とする最長の回文の半径 (全長+1)/2
//奇数長のみ 偶数長はダミー文字列を入れる
vector<int> manacher(const string &s) {
	int n = s.size();
	vector<int> r(n);
	int i = 0, j = 0;
	while (i < n) {
		while (i - j >= 0 && i + j < n && s[i - j] == s[i + j]) ++j;
		r[i] = j;
		int k = 1;
		while (i - k >= 0 && i + k < n && k + r[i - k] < j) r[i + k] = r[i - k], ++k;
		i += k; j -= k;
	}
	return r;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	string T; cin >> T;

	map<int, int> mp;
	vector<int> r = manacher(T);
	vector<int> R = r;

	rep(i, 0, N) {
		if (i + r[i] == N) {
			R.emplace_back(i + 1);
		}
	}
	sort(all(R));
	R.erase(unique(R.begin(), R.end()), R.end());

	for (auto x : R) {
		if (x == 1)continue;
		dump(x, r[x - 1]);
		bool ok = true;
		for (int i = x - 1; i < N; i += x - 1) {
			dump(i, r[i]);
			if (i + r[i] == N)continue;
			if (x > r[i]) {
				dump(min(x, N - r[i]), r[i]);
				ok = false;
				break;
			}
		}
		dump(ok);
		if (!ok)continue;
		rep(i, 0, N) {
			if (T[i] != T[x - 1 - abs((i % (2 * x - 2)) - x + 1)]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			cout << x << endl;
			return 0;
		}

	}
	return 0;
}


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

using ll=long long;
using ld=long double;

void solve(){
	float d,t,s;
	cin>>d>>t>>s;
	if(d/s <= t){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3732
n=int(input())
a=[]
for s in range(0,n+1):
    a.append(1)
for l in range(0,7):
    if l == 0:
        a[1]=2
    else:
        if 6**l<=n:
            a[6**l]=2
        else:
            pass
        if 9**l<=n:
            a[9**l]=2
        else:
            pass
for i in range(0,n+1):
    if a[i]>=2:
        for j in range(0,7):
            if i+6**j<=n:
                if a[i+6**j]>=2:
                    a[i+6**j]=min(a[i+6**j],a[i]+1)
                else:
                    a[i+6**j]=a[i]+1
            else:
                break
        for k in range(0,6):
            if i + 9**k<=n:
                if a[i+9**k]>=2:
                    a[i+9**k]=min(a[i+9**k],a[i]+1)
                else:
                    a[i+9**k]=a[i]+1
            else:
                break
    else:
        pass
print(a[n]-1)


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

const int SKIP = 27;
struct Trie {
  struct node {
    int id;
    node* next[28];
    bool skip;
    int size;

    // node* HL[20];
    node(int id) : id(id){
      memset( next,0,sizeof(next) );
      skip = false;
      size = 1;
    }
  };

  
  node *root;
  Trie(){
    root = new node(0);
  }


  bool exist( node *v, char to ){
    return v->next[to-'a'+1];
  }
  void make( node*v, char to, int id ){
    node *nv = new node( id );
    v->next[ to-'a'+1 ] = nv;
  }
  node* next( node*v, char to ){
    return v->next[ to-'a'+1 ];
  }
  
  void add( const string& s, node *v, int id ){
    if( id == (int)s.size() ) return;
    if( !exist( v, s[id] ) ) 
      make( v, s[id], id+1 );
    add( s, next( v, s[id] ), id+1 );
  }
  
  void add( const string& s ){
    add( s, root, 0 );
  }

  node* dfs( node *v, int &cnt ){
    int tmpc = cnt;
    int sz = 0;
    node* tmpv=NULL;
    for(char c = 'a'-1; c<='z'; c++) {
      if( exist( v, c ) ) {
        sz++;
        //node* retv = dfs( next( v, c ), cnt );
        tmpv = dfs( next( v, c ), cnt );
        //if( !tmpv && tmpv->size < retv->size ) tmpv = retv;
      }
    }
    if( sz == 0 ) cnt++;
    v->size = cnt - tmpc;

    if( sz == 1 ){
      v->skip = true;
      v->next[SKIP] = tmpv;
      return tmpv;
    } else
      return v;
  }
  
  node* dfs(){
    int cnt = 0;
    return dfs( root, cnt );
  }

  int solve( const string& s, const string& alp, node *v ){
    int id = v->id;
    if( v->size == 1 ) return 0;
    if( v->skip ) {
      return solve( s, alp, v->next[SKIP] );
    }
    int ret = 0;
    for( char c : alp ){
      if( s[id] == c ) {
        return solve( s, alp, next(v,c) ) + ret;        
      } else {
        if( exist( v, c ) )
          ret += next( v, c )->size;
      }
    }
    assert( false );
  }
  
  int solve( const string& s, const string& alp ){
    return solve( s, alp, root ) + 1;
  }

  
  
};

int N,Q;
string S[100004];
int main(){
  Trie T;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> S[i]; S[i]+=(char)('a'-1);
    T.add( S[i] );
  }
  T.dfs();
  cin >> Q;
  for(int i=0;i<Q;i++){
    string ns = ""; ns +=(char)('a'-1);
    int k; string s; cin >> k>> s; --k;
    ns += s;
    cout << T.solve( S[k], ns ) << endl;
  }  
}


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

int main(){
    int E,Y;
    cin>>E>>Y;
    switch(E){
        case 0: if(1868<=Y&&Y<=1911) cout<<"M"<<Y-1867<<endl;
                else if(1912<=Y&&Y<=1925) cout<<"T"<<Y-1911<<endl;
                else if(1926<=Y&&Y<=1988) cout<<"S"<<Y-1925<<endl;
                else cout<<"H"<<Y-1988<<endl;
                break;
        case 1: cout<<Y+1867<<endl;
                break;
        case 2: cout<<Y+1911<<endl;
                break;
        case 3: cout<<Y+1925<<endl;
                break;
        case 4: cout<<Y+1988<<endl;
                break;
    }
    return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    ll N;
    cin>>N;
    bool ans = true;
    rep(i,0,N){
        ll x;
        cin>>x;
        if(x%2 != 0)ans = false;
    }

    if(ans)cout<<"second";
    else cout<<"first";
    return 0;
}

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

const int MAX_H = 50;
const int MAX_W = 50;
int field[MAX_H][MAX_W];
int cnt;
int H, W;
// int dy[4] = {1, 0, -1, 0};
// int dx[4] = {1, 1, 0, -1};
bool seen[MAX_H][MAX_W];

void bfs(int y, int x)
{
    for (int dy = -1; dy <= 1; dy++)
    {
        for (int dx = -1; dx <= 1; dx++)
        {
            if (dy == 0 && dx == 0)
                continue;

            int ny = y + dy;
            int nx = x + dx;
            if (ny < 0 || ny >= H || nx < 0 || nx >= W)
                continue;
            if (field[ny][nx] == 0)
                continue;
            if (seen[ny][nx])
                continue;

            seen[ny][nx] = true;
            bfs(ny, nx);
        }
    }
}

int main()
{

    while (true)
    {
        cin >> W >> H;
        if (W == 0 && H == 0)
            break;

        for (int y = 0; y < H; y++)
        {
            for (int x = 0; x < W; x++)
            {
                cin >> field[y][x];
            }
        }

        cnt = 0;
        for (int y = 0; y < H; y++)
        {
            for (int x = 0; x < W; x++)
            {
                seen[y][x] = false;
            }
        }

        for (int y = 0; y < H; y++)
        {
            for (int x = 0; x < W; x++)
            {
                if (seen[y][x] || field[y][x] == 0)
                    continue;
                cnt++;
                seen[y][x] = true;
                bfs(y, x);
            }
        }

        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll          long long
#define fio         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define vi          vector<ll>
#define pp          push_pop
#define pll         pair<ll,ll>
#define in          insert
#define ini(a,n)    memset(a,n,sizeof(a))
#define ff          first
#define ss          second
#define inf         10000000000000000
#define all(p)      p.begin(), p.end()
#define que_max     priority_queue <int>
#define que_min     priority_queue <int, vi, greater<int>>
#define print(a)    for(auto i:a){cout<<i<<" ";}
#define print1(a)   for(auto i:a){cout<<i.ff<<" "<<i.ss<<endl;}

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> Set;
unordered_map<ll,vi> g;
unordered_map<ll,ll> vis;

const ll mod = 1e9+7;

ll power(ll x,ll y,ll p){ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
const ll N = 1e5+10;
bool imp = false;

void solve() {

    ll n,k;cin>>n>>k;

    if(k&1) {
        cout<<"No\n";
        return;
    }

    ll f = n*4;
    ll t = n*2;
    if(k > f or k < t){
        cout<<"No\n";
    }
    else{
        cout<<"Yes\n";
    }



}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif

    fio
    int t=1;
    if(imp) cin>>t;
    while(t--)
    {
        // cout<<"Case #"<<tc<<": ";
        g.clear();
        vis.clear();
        solve();
        // tc++;
    }

}


Measured memory_bytes: 3656
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm> 

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<double> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double ans = 0;
    ans += v[0];
    for (int i = 0; i < n; i++)
    {
        ans += v[i];
        ans /= 2;
    }
    cout <<fixed<<setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N, T;
  cin >> N >> T;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  vector<int> M(N), m(N);
  m[0] = A[0];
  for(int i = 1; i < N; ++i) m[i] = min(A[i], m[i-1]);
  M[N-1] = A[N-1];
  for(int i = N-2; i >= 0; --i) M[i] = max(A[i], M[i+1]);
  int D = 0;
  for(int i = 0; i < N; ++i) D = max(D, M[i] - m[i]);
  int x = 0, y = 0;
  for(int i = 0; i < N; ++i){
    if(A[i] - m[i] == D) ++x;
    if(M[i] - A[i] == D) ++y;
  }
  cout << min(x, y) << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include <math.h>

using namespace std;

int main()
{
    int i;
    long long int p=1,N;

    cin>>N;
    
    for(i=1;i<=sqrt(N);i++)
    {
        if(N%i==0){
    	    p=i;
        }
    }
    
    cout<<((p-2)+(N/p));
    
    return 0;
}

Measured memory_bytes: 256
using System;

namespace MyProgram{
    class AtCoder{
        public static void Main(string[] args){
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            int K = input[0];
            int X = input[1];
            Console.WriteLine(K*500 >=X ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,j=0;
  string a,b,r;
  cin>>n;
  cin>>a>>b;
  for(i=0;i<n;i++)
  {
    r[j++]=a[i];
    r[j++]=b[i];
  }
  for(i=0;i<2*n;i++)
  {
      cout<<r[i];
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    if(n<1200){
        cout<<"ABC"<<endl;
    }
    else{
        cout<<"ARC"<<endl;
    }
    return 0;
}


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

struct a
{
    string s;
    int n;
};
bool operator<(const a& left, const a& right) {
    if(left.n != right.n)
        return left.n > right.n;
    return left.s.compare(right.s) < 0;
}
int main(){
    int n,max;
    vector<a> vec;
    string s;
    map<string, int> mp;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>s;
        mp[s]++;
    }
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        vec.push_back((a){
            s : itr->first,
            n : itr->second
        });
    }
    sort(vec.begin(), vec.end());
    max = vec[0].n;
    for(int i=0; i<vec.size(); i++){
        if(vec[i].n == max)
            cout << vec[i].s << endl;
        else
            break;
    }
    return 0;
}

Measured memory_bytes: 29556
from bisect import *
s=input()
t=input()
a=[[]for i in range(26)]
for i in range(len(s)):
    a[ord(s[i])-97].append(i+1)
p=-1
b=[len(i)for i in a]
r=0
for i in t:
    if b[ord(i)-97]==0:
        print(-1)
        break
    c=bisect_right(a[ord(i)-97],p)
    if c==b[ord(i)-97]:
        r+=1
        p=a[ord(i)-97][0]
    else:
        p=a[ord(i)-97][c]
else:
    print(r*len(s)+p)

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n, c;
	cin >> n >> c;
	vector<vector<int>> d(c, vector<int>(c));
	for(int i = 0; i < c; i++) {
		for(int j = 0; j < c; j++) {
			cin >> d[i][j];
		}
	}
	map<int, int> mp[3];
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			int a;
			cin >> a;
			a--;
			mp[(i + j) % 3][a]++;
		}
	}
	long long ans = LLONG_MAX;
	for(int i = 0; i < c; i++) {
		for(int j = 0; j < c; j++) {
			for(int k = 0; k < c; k++) {
				if(i == k || i == j || j == k) {
					continue;
				}
				long long tmp = 0;
				for(int l = 0; l < 3; l++) {
					for(auto it : mp[l]) {
						if(l == 0) {
							tmp += 1LL * d[it.first][i] * it.second;
						}
						if(l == 1) {
							tmp += 1LL * d[it.first][j] * it.second;
						}
						if(l == 2) {
							tmp += 1LL * d[it.first][k] * it.second;
						}
					}
				}
				ans = min(ans, tmp);
			}
		}
	}
	cout << ans << endl;
					
	return 0;	
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  string s;
  cin >> s;
  ll n = s.size();
  vll lsum(n+1),rsum(n+1);

  REP(i, n){
    if(s[i]=='>')
      lsum[i+1] = 0;
    else
      lsum[i+1] = lsum[i]+1;
  }

  for(ll i=n-1; i>=0; i--){
    if(s[i]=='>')
      rsum[i] = rsum[i+1]+1;
    else
      rsum[i] = 0;
  }

  ll ans = 0;
  REP(i, n+1)
    ans += max(lsum[i],rsum[i]);

  cout << ans <<endl;
}


Measured memory_bytes: 8732
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
D = {}
for a in A:
    if a not in D: D[a] = 0
    D[a] += 1

E =  sorted([(k,v) for k,v in D.items() if v>=2] + [(0,4)])

l1, n1 = E[-1]
if n1>=4:
    print(l1*l1)
else:
    l2, n2 = E[-2]
    print(l1*l2)

Measured memory_bytes: 17860
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 1000000
#define N 100
int n,M[N][N];
int color[N],d[N],p[N];
  
int prim(){
  
  int u, mincost, i, v,sum = 0;
  
  for(i = 0; i < n; i++ ){
    color[i] = WHITE;
    d[i] = INFTY;
    p[i] = -1;
  }
  
  d[0] = 0;
  
  while(1){
    mincost = INFTY;
    u = -1;
    for(i = 0; i < n; i++){
      if(mincost > d[i] && color[i] != BLACK){
    u = i;
    mincost = d[i];
      }
    }
    if(u == -1)break;
    color[u] = BLACK;
    for( v = 0; v < n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
    if(M[u][v] < d[v]){
      d[v] = M[u][v]; 
      p[v] = u;
      color[v] = GRAY;
    }
      }
    }
  }
  for(i = 0; i < n; i++){
    if(p[i] != -1){
      sum += M[i][p[i]];
    }
  }
  return sum;
}
int main(){
  int i, j, sum=0;
  scanf("%d",&n);
  for(i = 0; i < n; i++ ){
    for(j = 0; j < n; j++){
      scanf("%d",&M[i][j]);
      if(M[i][j] == -1)M[i][j]=INFTY;
    }
  } 
  sum = prim(n);
  printf("%d\n",sum);
  
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main (void){
    int S, h, m, s;
    scanf("%d",&S);
    if(S<60){
        printf("0:0:%d\n",S);
    }else if(60<S && S<3600){
        m=S/60;
        s=S%60;
        printf("0:%d:%d\n",m,s);
    }else{
        h=S/3600;
        m=S%3600/60;
        s=S%3600%60;
        printf("%d:%d:%d\n",h,m,s);
    }
    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;


ll a[300][300];//地図
ll d[300][300];//最短経路
bool used[300][300];//すでに取り除いた辺

int main()
{
	int n;
	ll ans=0;
	ll minus=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>a[i][j];
			d[i][j]=a[i][j];
			ans+=a[i][j];
		}
	}
	ans/=2;

	//ワーシャルフロイド
	for(int k=0;k<n;k++)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}

	//地図が正しいかどうかのチェック
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(d[i][j]!=a[i][j])
			{
				cout<<-1<<endl;
				return 0;
			}
		}
	}

	//省ける辺を探す
	//ワーシャルフロイド（変形）
	fill(used[0],used[300],false);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i==j)
				continue;
			for(int k=0;k<n;k++)
			{
				if(i!=k && j!= k && d[i][j]==d[i][k]+d[k][j] && used[i][j]==false)
				{
					minus+=d[i][j];
					used[i][j]=true;
				}
			}
		}
	}
	minus/=2;
	ans=ans-minus;
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
//
//  main.cpp
//  D-crossing
//
//  Created by Costin  Tudor on 27/10/2018.
//  Copyright © 2018 Costin  Tudor. All rights reserved.
//

#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int i, N;
    scanf("%d", &N);
    for (i = 1; ; ++i) {
        if (i * (i + 1) == N + N) {
            break;
        }
        else if (i * (i + 1) > N + N) {
            printf("No\n");
            return 0;
        }
    }
    int M = i;
    printf("Yes\n");
    vector < vector < int > > sol(M+1);
    int j = 1;
    for (int i = 1; i <= M; ++i) {
        for (int k = 0; k < i ; ++k) {
            sol[i].push_back(j);
            sol[k].push_back(j);
            j++;
        }
    }
    printf("%d\n", M+1);
    for (int i = 0; i < M+1; ++i) {
        printf("%d ", (int)sol[i].size());
        for (auto t : sol[i]){
            printf("%d ", t);
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var kx = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            Console.WriteLine(kx[0] * 500 >= kx[1] ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 28188
inputs =  list(map(int, input().split()))

N = inputs[0]
M = inputs[1]

start = 1
end = N

for i in range(M):
    inputs = list(map(int, input().split()))
    if start < inputs[0]:
        start = inputs[0]
    if inputs[1] < end:
        end = inputs[1]

if start <= end:
    print(end - start + 1)
else:
    print(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b,c,d;
	string s;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	cin>>s;
	if(c<d){
		int dem=0;
		for(int i=a-1;i<min(d-1,n-1);i++){
			if(s[i]==s[i+1]&&s[i]=='#'){
				dem++;
				break;
			}
		}
		if(dem>0) printf("No");
		else printf("Yes");
	}
	else{
		int dem=0;
		for(int i=a-1;i<min(c-1,n-1);i++){
			if(s[i]==s[i+1]&&s[i]=='#'){
				dem++;
				break;
			}
		}
		if(dem>0) printf("No");
		else{
			dem=0;
			for(int i=b-2;i<min(d-1,n-2);i++){
				if(s[i]==s[i+1]&&s[i+1]==s[i+2]&&s[i]=='.'){
					dem++;
					break;
				}
			}
			if(dem==0) printf("No");
			else printf("Yes");
		}
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

struct Node {
  ll value;
  V<int> childs;
};

V<Node> graph;
V<bool> visited;

// DFS
// スタックを使った実装より、再起関数の方が早い?
void accum(int current_i, ll value) {
  visited[current_i] = true;
  graph[current_i].value += value;

  for(auto next_i : graph[current_i].childs) {
    if(visited[next_i]) {
      continue;
    }

    accum(next_i, graph[current_i].value);
  }
}

int main() {
  int n, q;

  cin >> n >> q;
  graph.resize(n);
  visited.resize(n);

  rep(i, n - 1) {
    int from, to;
    cin >> from >> to;
    from--; to--;
    graph[from].value = 0;
    graph[from].childs.push_back(to);
    graph[to].childs.push_back(from);
    visited[from] = false;
  }

  rep(i, q) {
    int to;
    ll x;
    cin >> to >> x;
    to--;
    graph[to].value += x;
  }
  accum(0, 0);

  rep(i, n) {
    cout << graph[i].value << " ";
  }
  cout << endl;
}


Measured memory_bytes: 25120
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int P, Q, R, i, j, temp;
	int array[3];
	scanf("%d", &P);
	scanf("%d", &Q);
	scanf("%d", &R);
	array[0] = P;
	array[1] = Q;
	array[2] = R;
	for (i = 0; i < 2; i++) 
	{
		for (j = 0; j < 2; j++) 
		{
			if (array[j + 1] < array[j]) 
			{
				temp = array[j]; array[j] = array[j + 1]; array[j + 1] = temp;
			}
		}
	}
	printf("%d", array[0] + array[1]);
	return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

using Weight = int;
using Flow = int;
struct Edge {
    int s, d; Weight w; Flow c;
    Edge() {};
    Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
    g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
    addArc(g, a, b, w);
    addArc(g, b, a, w);
}

int dfs(Graph &g, int p, int bef)
{
    vi tmp;
    for (auto i : g[p]) {
        if (i.d != bef) {
            tmp.pb(dfs(g, i.d, p));
        }
    }
    sort(all(tmp));
    int ret = 0;
    rep(i, tmp.size()) {
        ret = max(ret+1, tmp[i]+1);
    }
    //cout << p + 1 << " : " << ret << endl;
    return ret;
}

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

    Int(n);

    Graph g(n);
    for (int i = 0; i < n-1; i++) {
        Int(tmp);
        addEdge(g, i+1, tmp-1);
    }

    std::cout << dfs(g, 0, -1) << std::endl;

    return 0;
}


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

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

//#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 998244353;
using P = pair<ll, ll>;

signed main() {
	int a, b; cin >> a >> b;
	if (a >= 13)cout << b << endl;
	else if (6 <= a)cout << b / 2 << endl;
	else cout << 0 << endl;
	return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  int ans = 0;
  rep(i,n){
    cin >> p[i];
    ans += p[i];
  }
  sort(p.rbegin(),p.rend());
  cout << ans - p[0]/2 << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque

n = int(input())
list = [list(map(int,input().split())) for i in range(n)]

p = []
for i in list:
  p.append([i[0] - i[1],i[0] + i[1]])
  
p = sorted(p,key = lambda x: x[1])

p = deque(p)
ex = []
ex.append(p.popleft())




for i in range(len(p)):
  if(ex[-1][1] <= p[0][0]):
    ex.append(p.popleft())
  else:
    p.popleft()

print(len(ex))

Measured memory_bytes: 43688
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 1000000000
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue
 
#define FOR(i, a, b) for (int i=(a); i<=(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)
 
#define MN 200005
int a, b, c;

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

    cin >> a >> b >> c;
    int poi = min(c, a+b+1);
    cout << b+poi << "\n";

    return 0;
}


Measured memory_bytes: 256
N, K = list(map(int, input().split()))
V = list(map(int, input().split()))

Ans = 0
M = min(N + 1, K + 1)
for i in range(M):
  S = V[:i]
  for j in range(M - i):
    if j == 0:
      P = S
    else:
      P = S + V[-j:]
    t = 0
    T = []
    for k in P:
      t += k
      if k < 0:
        T.append(k)
    T.sort()
    for k in range(min(len(T), K - (i + j))):
      t -= T[k]
    Ans = max(Ans, t)

print(Ans)

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 高橋_Hits
		int first_hits = sc.nextInt();
		// 高橋_Atk
		int first_atk = sc.nextInt();
		// 青木_Hits
		int second_hits = sc.nextInt();
		// 青木_Atk
		int second_atk = sc.nextInt();

      	while( first_hits>=0 && second_hits>=0 ) {
          second_hits -= first_atk;
          //System.out.println("second " + second_hits);
          if (second_hits <= 0) {
            break;
          }
		  first_hits -= second_atk;
          //System.out.println("first " + first_hits);
          if (first_hits <= 0) {
            break;
          }
        }
      
      	if (second_hits <= 0) {
            System.out.println("Yes");
        } else /* (first_hits <= 0)*/ {
            System.out.println("No");
        }


	}
}

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

int main() {

  string s;
  cin >> s;

  long long int q;
  cin >> q;

  for ( long long int i = 0; i < q; i++ ) {

    string in;
    cin >> in;

    if ( in == "print" ) {

      long long int a, b;
      cin >> a >> b;
      cout << s.substr( a, b - a + 1 ) << endl;

    }else if ( in == "reverse" ) {

      long long int a, b;
      cin >> a >> b;
      string k = s;
      for ( long long int j = a; j <= b; j++ ) {
	s[j] = k[a+b-j];
      }

    }else if ( in == "replace" ) {

      long long int a, b;
      cin >> a >> b;

      for ( long long int j = a; j <= b; j++ ) {
	char c;
	cin >> c;
	s[j] = c;
      }

    }

  }

  return 0;

}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;

int main() {
    int n,i,j;
    cin >> n;
    int a[n],b[n],c[n];
    for(i=0;i<n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[n+1][3];
    dp[0][1]=0;dp[0][0]=0;dp[0][2]=0;
    for(i=1;i<=n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2]) + a[i-1];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+ b[i-1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+ c[i-1];
    }
    cout << max(dp[n][0],max(dp[n][1],dp[n][2]));
}

Measured memory_bytes: 5964
<?php
list($D) = ints();
$k = 26;
$c = ints();
for ($i = 0; $i < $D; ++$i) $s[] = ints();
for ($i = 0; $i < $D; ++$i) {
    list($t[$i]) = ints();
    --$t[$i]; // 0-indexed
}
$score = calcScore($t);
list($M) = ints();
for ($i = 0; $i < $M; ++$i) {
    list($d, $q) = ints();
    $score += update($d - 1, $q - 1);
    $ans[] = $score;
}
echo implode(PHP_EOL, $ans);

function calcScore($t)
{
    global $D, $k, $c, $s;
    $last = array_fill(0, $k, 0);
    $res = 0;
    for ($i = 0; $i < $D; ++$i) {
        $res += $s[$i][$t[$i]];
        $last[$t[$i]] = $i + 1;
        for ($j = 0; $j < $k; ++$j) $res -= $c[$j] * ($i + 1 - $last[$j]);
    }
    return $res;
}
function update($d, $q)
{
    global $D, $s, $c, $t;
    $p = $t[$d];
    $pp = $pq = -1;
    $np = $nq = $D;
    for ($i = 0; $i < $D; ++$i) {
        if ($t[$i] === $p) {
            if ($i < $d) $pp = $i;
            if ($i > $d && $np === $D) $np = $i;
        }
        if ($t[$i] === $q) {
            if ($i < $d) $pq = $i;
            if ($i > $d && $nq === $D) $nq = $i;
        }
    }
    $res = $s[$d][$q] - $s[$d][$p];
    $res -= $c[$p] * ($d - $pp) * ($np - $d);
    $res += $c[$q] * ($d - $pq) * ($nq - $d);

    $t[$d] = $q;
    return $res;
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

ll MOD = 998244353;

int main(void){
    int N, S;
    cin >> N >> S;
    vector<ll> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    
    vector<vector<ll>> dp(N+1, vector<ll>(S+1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= S; j++) {
            dp[i+1][j] = (dp[i+1][j] + 2*dp[i][j])  % MOD;
            if (dp[i][j] != 0 && j+A[i] <= S) {
                dp[i+1][j+A[i]] = (dp[i][j] + dp[i+1][j+A[i]]) % MOD;
            }
        }
    }
    cout << dp[N][S] << endl;
}


Measured memory_bytes: 73648
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()

int main(){
    
    ll n , x;
    cin >> n >> x;

    vector<ll> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }

    cout << n + (x - accumulate(all(v),0ll) ) / *min_element(all(v)) << endl;  
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 4

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int res[ N ];
  int i;

  for ( ; ; )
  {
    int * p = res;

    for ( i = 0; i < 8 * 8; ++i )
    {
      int ch;

      do
      {
        ch = getchar ( );
        if ( ch == EOF ) goto ESCAPE;
      }
      while ( ch != '0' && ch != '1' );

      if ( ch == '1' )
      {
        *( p++ ) = i;
      }
    }
    for ( i = 1; i < N; ++i )
    {
      res[ i ] -= *res;
    }

    if ( res[ 1 ] == 1 && res[ 2 ] == 8 && res[ 3 ] == 9 )
    {
      puts ( "A" );
    }
    else if ( res[ 1 ] == 8 && res[ 2 ] == 16 && res[ 3 ] == 24 )
    {
      puts ( "B" );
    }
    else if ( res[ 1 ] == 1 && res[ 2 ] == 2 && res[ 3 ] == 3 )
    {
      puts ( "C" );
    }
    else if ( res[ 1 ] == 7 && res[ 2 ] == 8 && res[ 3 ] == 15 )
    {
      puts ( "D" );
    }
    else if ( res[ 1 ] == 1 && res[ 2 ] == 9 && res[ 3 ] == 10 )
    {
      puts ( "E" );
    }
    else if ( res[ 1 ] == 8 && res[ 2 ] == 9 && res[ 3 ] == 17 )
    {
      puts ( "F" );
    }
    else if ( res[ 1 ] == 1 && res[ 2 ] == 7 && res[ 3 ] == 8 )
    {
      puts ( "G" );
    }
  }
ESCAPE:

  return ( 0 );
}

Measured memory_bytes: 0
h, w, k=map(int,input().split())
masu =[input() for _ in range(h)]
ans=0
for x in range(2**h):
    for y in range(2**w):
        cnt=0
        for i in range(h):
            for j in range(w):
                if x>>i&1 and y>>j&1 and masu[i][j]=="#":
                    cnt+=1
        if cnt == k:
            ans += 1
print(ans)####

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
int K,N;
vector<ll> h;

int main(void){
  cin >> N >> K;
  h.resize(N);
  int i;
  ll min=INF;
  REP(i,N) cin >> h[i];
  sort(h.begin(),h.end());
  REP(i,N-K+1){
    if( h[K+i-1] - h[i] < min ) min = h[K+i-1] - h[i];
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 1024
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
  class Cookie
  {
    long[] c = new long[2];
    public Cookie(long a, long b)
    {
      c[0] = a;
      c[1] = b;
    }
    public void eat()
    {
      if (c[0] % 2 == 1) c[0]--;
      c[0] /= 2;
      c[1] += c[0];
    }

    public void swap()
    {
      c[0] ^= c[1];
      c[1] ^= c[0];
      c[0] ^= c[1];
    }

    public long getA(){
      return c[0];
    }
    public long getB() {
      return c[1];
    }
  }
  public class Program
  {
    public static void Main(string[] args)
    {
      new Program().Solve(new ConsoleInput(Console.In, ' '));
    }

    public void Solve(ConsoleInput cin)
    {
      var a = cin.ReadLong;
      var b = cin.ReadLong;
      var c = new Cookie(a, b);
      var n = cin.ReadInt;
      for (int i = 0; i < n; i++)
      {
          c.eat();
          c.swap();
      }
      if (n % 2 == 1) c.swap();
      WriteLine("{0} {1}", c.getA(), c.getB());
    }
  }

  public class ConsoleInput
  {
    private readonly System.IO.TextReader _stream;
    private char _separator = ' ';
    private Queue<string> inputStream;
    public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
    {
      this._separator = separator;
      this._stream = stream;
      inputStream = new Queue<string>();
    }
    public string Read
    {
      get
      {
        if (inputStream.Count != 0) return inputStream.Dequeue();
        string[] tmp = _stream.ReadLine().Split(_separator);
        for (int i = 0; i < tmp.Length; ++i)
          inputStream.Enqueue(tmp[i]);
        return inputStream.Dequeue();
      }
    }
    public string ReadLine { get { return _stream.ReadLine(); } }
    public int ReadInt { get { return int.Parse(Read); } }
    public long ReadLong { get { return long.Parse(Read); } }
    public double ReadDouble { get { return double.Parse(Read); } }
    public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
    public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
    public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
  }
}

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

int main()
{
    int M, D;
    cin >> M >> D;
    int cnt = 0;
    for(int i = 1; i <= M; ++i) {
        for(int j = 2; j <= D/10; ++j) {
            for(int k = 2; (10*j+k) <= D && k <= 9; ++k) {
                if(j*k == i) ++cnt;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import os
import sys
from io import BytesIO, IOBase
# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------------------

def RL(): return map(int, sys.stdin.readline().rstrip().split())
def RLL(): return list(map(int, sys.stdin.readline().rstrip().split()))
def N(): return int(input())
def comb(n, m): return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0
def perm(n, m): return factorial(n) // (factorial(n - m)) if n >= m else 0
def mdis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2)
def toord(c): return ord(c)-ord('a')
def lcm(a, b): return a*b//lcm(a, b)
mod = 998244353
INF = float('inf')
from math import factorial, sqrt, ceil, floor, gcd
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush


# ------------------------------


def main():
    n = N()
    s = input()

    b, e = 0, n-1
    res = 0

    while b<e:
        while b < n and s[b] == 'R': b += 1
        while e > -1 and s[e] == 'W': e -= 1
        if b>=e: break
        res+=1
        b+=1
        e-=1
    print(res)


if __name__ == "__main__":
    main()



Measured memory_bytes: 69300
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
num = {i:s.count(i) for i in set(s)}
out = [v-max(0,t.count(k)) for k, v in num.items()]
print(max(max(out),0))

Measured memory_bytes: 3064
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}


int main(int argc, char const* argv[])
{
  int n;
  string a, b, c;
  cin >> n >> a >> b >> c;
  ll res = 0;
  for(int i = n - 1; i >= 0; i--){
    set<char> st;
    st.insert(a[i]);
    st.insert(b[i]);
    st.insert(c[i]);
    if(st.size() == 2)res++;
    else if(st.size() == 3)res += 2;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
struct edge {
  int la,b;
} con[N << 1];
int tot,fir[N];
void add(int from,int to) {
  con[++tot] = (edge) {fir[from],to};
  fir[from] = tot;
}
void deledge(int from,int to) {
  for (int i = fir[from], *j = &fir[from] ; i ; j = &con[i].la, i = con[i].la) {
    if (con[i].b == to) {
      *j = con[i].la;
      break;
    }
  }
}
int n,m,dep[N],val[N],cnt,lop[N],inl[N],vis[N],rt;
int getlop(int pos,int fa) {
  if (vis[pos])
    return rt = pos, 1;
  vis[pos] = 1;
  int tmp;
  for (int i = fir[pos] ; i ; i = con[i].la) {
    if (con[i].b == fa) continue;
    if (tmp = getlop(con[i].b,pos), tmp) {
      if (tmp == 1) {
	lop[++cnt] = pos;
	inl[pos] = 1;
	if (pos == rt) return 2;
	return 1;
      }
      return 2;
    }
  }
  return 0;
}
void dfs(int pos,int fa) {
  dep[pos] = dep[fa] + 1;
  val[pos] = dep[pos]&1 ? 1 : -1;
  for (int i = fir[pos] ; i ; i = con[i].la) {
    if (con[i].b == fa) continue;
    dfs(con[i].b,pos);
    val[pos] += val[con[i].b];
  }
}
void doittree() {
  int ans = 0;
  dfs(1,0);
  for (int i = 1 ; i <= n ; ++ i)
    ans += abs(val[i]);
  if (val[1] == 0) printf("%d\n",ans);
  else puts("-1");
}
vector<int> tmp;
void doitodd() {
  int ans = 0;
  dfs(rt,0);
  if (val[rt]&1) {
    puts("-1");
    return;
  }
  ans += abs(val[rt] >> 1);
  for (int i = 1 ; i < cnt ; ++ i)
    val[lop[i]] -= val[rt] >> 1;
  val[rt] = 0;
  for (int i = 1 ; i <= n ; ++ i)
    ans += abs(val[i]);
  printf("%d\n",ans);
}
void doiteven() {
  int ans = 0;
  dfs(rt,0);
  if (val[rt] != 0) {
    puts("-1");
    return;
  }
  for (int i = 1 ; i <= n ; ++ i)
    if (!inl[i]) ans += abs(val[i]);
  for (int i = 1 ; i < cnt ; ++ i)
    tmp.push_back(val[lop[i]]);
  sort(tmp.begin(),tmp.end());
  int x = tmp[tmp.size() >> 1];
  for (int i = 0 ; i < (int)tmp.size() ; ++ i)
    ans += abs(x - tmp[i]);
  ans += abs(x);
  printf("%d\n",ans);
}
void doit() {
  getlop(1,0);
  deledge(rt,lop[1]);
  deledge(lop[1],rt);
  if (cnt&1) doitodd();
  else doiteven();
}
int main() {
  int x,y;
  scanf("%d%d",&n,&m);
  for (int i = 1 ; i <= m ; ++ i) {
    scanf("%d%d",&x,&y);
    add(x,y);
    add(y,x);
  }
  if (m == n-1)
    doittree();
  else doit();
  return 0;
}


Measured memory_bytes: 9468