akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>


int main() {

	int n = 0;
	std::cin >> n;
	std::vector<std::string>str(n);
	std::vector<std::pair<char, int>>str_char_pair{};

	bool enable = false;
	for (int i = 0; i < n; i++)
	{
		std::cin >> str[i];
		for (char c = 'a'; c <= 'z'; c++)
		{
			int count = std::count(str[i].begin(), str[i].end(), c);

			if (count >= 1) {
				str_char_pair.emplace_back(c, count);
			}
		}
	}
	std::sort(str_char_pair.begin(), str_char_pair.end());
	std::vector<std::pair<char, int>>enable_str_pair;
	for (char c = 'a'; c <= 'z'; c++)
	{
		int count = std::count_if(str_char_pair.begin(), str_char_pair.end(), [&c](std::pair<char, int>p) ->bool {return p.first == c;});
		if (count == n)
		{
			auto it = str_char_pair.begin();
			for (auto i = str_char_pair.begin(); i != str_char_pair.end(); i++)
			{
				bool b = [&c](std::pair<char, int>p) ->bool {return p.first == c;}(*i);
				if (b) {
					it = i;
					break;
				}
			}

			for (size_t i = 0; i < n; i++)
			{
				enable_str_pair.push_back(*(it + i));
			}
		}
	}

	for (char c = 'a'; c <= 'z'; c++)
	{
		for (auto& i : enable_str_pair)
		{
			if (i.first == c)
			{
				for (int j = 0; j < i.second; j++)
				{
					std::cout << c;
					enable = true;
				}
				break;
			}
		}
	}
	if (!enable)std::cout << "";
	std::cout << std::endl;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long
#define INF 10e9

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

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

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

int N, K;
string s;

int main () {
  cin >> N >> K;
  cin >> s;

  int diff = 0;
  Rep(i, N-1) {
    if (s[i] != s[i+1]) ++diff;
  }

  int ans = min(N-1, N-1-diff+2*K);
  cout << ans << "\n";
}

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

N=int(input())
S=[input().strip() for i in range(N)]
S.sort(key=len)

VLIST=[[set() for j in range(len(S[i]))] for i in range(N)]

for i in range(N):
    for j in range(len(S[i])):
        VLIST[i][j]=VLIST[i][j-1]|{S[i][j]}

# Trie木

Next_node_id=[[-1]*26] # "a"～"z"それぞれについて、対応する次のノードのid
Parent_id=[-1] # 親ノード
End=[[]] # そのノードを終端とするStringがあるか。ある場合、最後の一文字を入れる。

ANS=0

Nodes_id=1
for i in range(N):
    S2=S[i]
    L=len(S2)

    NOW=0
    for j in range(L-1,-1,-1):
        for s in End[NOW]:
            if s in VLIST[i][j]:
                ANS+=1

        if j==0:
            End[NOW].append(S2[0])
            continue
        
        NEXT=ord(S2[j])-97
        
        if Next_node_id[NOW][NEXT]==-1: # Nodeを追加する場合
            Next_node_id[NOW][NEXT]=Nodes_id

            Next_node_id.append([-1]*26)
            Parent_id.append(NOW)
            End.append([])

            NOW=Nodes_id         
            Nodes_id+=1

        else: # 追加しない場合
            NOW=Next_node_id[NOW][NEXT]

print(ANS)

Measured memory_bytes: 893432
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def MI(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

H,W = LI()

if H%3 == 0 or W%3 == 0:
    print(0)
    exit()

ans = min(H,W)
for i in range(H):
    num1 = W*i
    num2 = math.floor(W/2)*(H-i)
    num3 = math.ceil(W/2)*(H-i)
    now = max(num1,num2,num3)-min(num1,num2,num3)
    if now < ans:
        ans = now

for i in range(W):
    num1 = H*i
    num2 = math.floor(H/2)*(W-i)
    num3 = math.ceil(H/2)*(W-i)
    now = max(num1,num2,num3)-min(num1,num2,num3)
    if now < ans:
        ans = now

print(ans)

Measured memory_bytes: 41964
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <iostream>
#include <string>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <queue>
#define PII pair<int, int>
#define T3I tuple<int, int, int>
#define STA(a, b) min(a, b), max(a, b)
using namespace std;

typedef long long ll;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;

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

    ll h, w;
    cin >> h >> w;
    if(min(h, w) == 1) {
        cout << 1 << endl;
    }else {
        cout << (h*w+1)/2 << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
#define fin return 0
#define input(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = (ll)1e19;

int r[100], l[100];
int a, b;

#define MAX 9223372036854775807
/*********************** */

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


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

const int maxn = 305, mod = 1e9 + 7;

int n, m;
int f[maxn][maxn][maxn];
vector<pair<int, int> > vec[maxn];

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

inline void inc(int &a, int b) {a += b; if (a >= mod) a -= mod;}

inline bool check(int r, int j, int k)
{
	for (int i = 0; i < vec[r].size(); ++i)
		if (1 + (vec[r][i].first <= j) + (vec[r][i].first <= k) != vec[r][i].second) return 0;
	return 1;
}

int main()
{
	n = gi(); m = gi();
	for (int l, r, x, i = 1; i <= m; ++i) {
		l = gi(); r = gi(); x = gi();
		vec[r].push_back(make_pair(l, x));
	}

	if (check(1, 0, 0)) f[1][0][0] = 3;
	for (int i = 1; i < n; ++i)
		for (int j = 0; j < i; ++j)
			for (int k = 0; k < i; ++k) {
				if (!f[i][j][k]) continue;
				if (check(i + 1, j, k))
					inc(f[i + 1][j][k], f[i][j][k]);
				if (check(i + 1, i, k))
					inc(f[i + 1][i][k], f[i][j][k]);
				if (check(i + 1, j, i))
					inc(f[i + 1][j][i], f[i][j][k]);
			}

	int ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			inc(ans, f[n][i][j]);
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 108800
def gcd(x, y):
    return y if x % y == 0 else gcd(y, x%y)

N, X = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
ans = A[0] - X
for a in A:
    ans = gcd(ans, abs(a - X))

print (ans)


Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::string S; std::cin >> S;

  std::vector<std::vector<int>> s1(N+1, std::vector<int>(10));
  std::vector<std::vector<int>> s2(N+1, std::vector<int>(100));
  std::vector<std::vector<int>> s3(N+1, std::vector<int>(1000));

  for(int i=0; i<N; i++) {
    int k = S[i] - '0';
    if ( i == 0 ) s1[i][k] = 1;
    else {
      for(int j=0; j<10; j++) if ( s1[i-1][j] == 1 || j == k ) s1[i][j] = 1;
      for(int j=0; j<10; j++) {
        if ( s1[i-1][j] == 1 ) {
          int t = j*10 + k;
          s2[i][t] = 1;
        }
      }
      for(int j=0; j<100; j++) if ( s2[i-1][j] == 1 ) s2[i][j] = 1;

      for(int j=0; j<100; j++) {
        if ( s2[i-1][j] == 1 ) {
          int t = j*10 + k;
          s3[i][t] = 1;
        }
      }
      for(int j=0; j<1000; j++) if ( s3[i-1][j] == 1 ) s3[i][j] = 1;
    }
  }
  
  int ans = 0;
  for(int j=0; j<1000; j++) if ( s3[N-1][j] == 1 ) {
    ans++;
  }
  std::cout << ans << std::endl;
  return 0;
}


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

int main(){

  int D,T,S;

  cin >> D >> T  >> S ;

  if((double)(D)/(double)(S) <= (double)(T)){

      cout << "Yes" << endl;

  }else{

      cout << "No" << endl;

  }

    
 
 }

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


int main()
{
    int a[5],t[5];
    for(int i = 0;i < 5;i++) scanf("%d",&t[i]);
    for(int i = 0;i < 5;i++) a[i] = i;
    int ans = INT_MAX;
    do{
        int pos = 0;
        for(int i = 0;i < 5;i++)
        {
            if(i != 4) pos += (t[a[i]] + 9) / 10 * 10;
            else pos += t[a[i]];
        }
        ans = min(ans,pos);
    }while(next_permutation(a,a + 5));
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> L(n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> L.at(i);
    }
    sort(L.begin(), L.end());
    for (int i = 0; i < n - 2; i++) {
        for (int j = i + 1; j < n - 1; j++) {
            auto Iter = lower_bound(L.begin(), L.end(), L.at(i) + L.at(j));
            int num = Iter - L.begin();
            ans += num - j - 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

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

ll lcm(ll m, ll n) {
    if ((0 == m) || (0 == n)) return 0;
    return ((m / gcd(m, n)) * n);
}

// 素因数分解
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> mp;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
    return mp;
}

// 素数判定
bool is_prime(ll n) {
    for (int i = 2; i * i <= n; i++) if (n % i == 0) return false;
    return n != 1;
}

unordered_map<ll, ll> mp;

// 約数列挙
void divisor(ll n) {
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            mp[i]++;
            if (i != n / i) mp[n / i]++;
        }
    }
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl();
        vl a(n);
        rep(i, n) cin >> a[i];
        ll dl[n], dr[n];
        dl[0] = a[0], dr[n - 1] = a.back();
        for (int i = 1; i < n; ++i) dl[i] = gcd(dl[i - 1], a[i]);
        for (int i = n - 2; i >= 0; --i) dr[i] = gcd(dr[i + 1], a[i]);
        ll ans = 0;
        rep(i, n) {
            if (i == 0) ans = max(ans, dr[1]);
            else if (i == n - 1) ans = max(ans, dl[n - 2]);
            else {
                ans = max(ans, gcd(dl[i - 1], dr[i + 1]));
            }
        }
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end



int main(){
   ll a,b,c; scanf("%lld%lld%lld",&a,&b,&c);
   if(c-a-b>=0&&4*a*b<(c-a-b)*(c-a-b))puts("Yes");
   else puts("No");
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

int main(){
    string S; cin>>S;
    int G=0, P=0;
    for(int i=0;i<S.size();i++){
        if(S.at(i)=='g') G++;
        else P++;
    }

    cout<<(G-P)/2<<endl;

}

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

int main() {
  
  int a;
  int b;
  
  cin >> a;
  cin >> b;
  
  if (a * b % 2 == 0) {
    cout << "Even" << endl;
  }
  
  if ( a * b % 2 == 1) {
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define N 200000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
        * @author :: Sawlani
        *
        */
ll arr[N + 1], b[N + 1];
ll getSum(ll BITree[], ll index)
{
    ll sum = 0;
    while (index > 0)
    {
        sum = max(sum, BITree[index]);
        index -= index & (-index);
    }
    return sum;
}

void updateBIT(ll BITree[], ll newIndex,
               ll index, ll val)
{
    while (index <= newIndex)
    {
        BITree[index] = max(val, BITree[index]);
        index += index & (-index);
    }
}

ll maxSumIS(ll arr[], ll n)
{
    ll newindex = 0, max_sum;

    map<ll, ll> uniqueArr;

    for (ll i = 0; i < n; i++)
    {
        uniqueArr[arr[i]] = 0;
    }

    for (map<ll, ll>::iterator it = uniqueArr.begin();
         it != uniqueArr.end(); it++)
    {

        newindex++;

        uniqueArr[it->first] = newindex;
    }

    ll *BITree = new ll[newindex + 1];

    for (ll i = 0; i <= newindex; i++)
    {
        BITree[i] = 0;
    }

    for (ll i = 0; i < n; i++)
    {
        max_sum = getSum(BITree, uniqueArr[arr[i]] - 1);

        updateBIT(BITree, newindex,
                  uniqueArr[arr[i]], max_sum + b[i]);
    }

    return getSum(BITree, newindex);
}

int main()
{
    //freopen("input.txt", "r", stdin);
    ll n;
    cin >> n;

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

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

    if (n == 1)
    {
        cout << b[0];
        return 0;
    }

    cout << maxSumIS(arr, n);

    return 0;
}


Measured memory_bytes: 17408
#include<stdio.h>

int main(void)
{
	int n,N,S[15]={0},H[15]={0},C[15]={0},D[15]={0},i;
	
	char m;
	
	for(i=0;i<13;i++){
		
		S[i]=i+1;
		H[i]=i+1;
		C[i]=i+1;
		D[i]=i+1;
	}
	//printf("%d",S[12]);
	
	scanf("%d",&n);
	
	for(i=0;i<n*2;i++){
		
		scanf("%c",&m);
		scanf("%d",&N);
		if(m=='S'){
			
			S[N-1]=0;
		}
		else if(m=='H'){
			
			H[N-1]=0;
		}
		else if(m=='C'){
			
			C[N-1]=0;
		}
		else if(m=='D'){
			
			D[N-1]=0;
		}
		//printf("%d\n",i);
	}
	for(i=0;i<15;i++){
		
		if(S[i]!=0){
			
			printf("S %d\n",S[i]);
		}
	}
	for(i=0;i<15;i++){
		
		if(H[i]!=0){
			
			printf("H %d\n",H[i]);
		}
	}
	for(i=0;i<15;i++){
		
		if(C[i]!=0){
			
			printf("C %d\n",C[i]);
		}
	}
	for(i=0;i<15;i++){
		
		if(D[i]!=0){
			
			printf("D %d\n",D[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 2732
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

int main()
{
	string S; cin >> S;
	int ans = 0;
	for (int i = 0; i < S.size() / 2; i++) {
		if (S[i] != S[S.size() - 1 - i]) {
			ans++;
		}
	}
	cout << ans << endl;
}


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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
p_ll pbcnt[51];
ll pbp[51];
vector<ll> pcnt[51];
ll ansp = 0;
bool fin = false;

void search(ll now,ll rem) {
	if (!fin) {
		if (now == 0) {
			ansp += 1;
			fin = true;
		} else {
			if (rem == 1) {
				fin = true;
			} else if (rem < 1 + pbcnt[now-1].first + pbcnt[now-1].second + 1) {
				search(now-1,rem-1);
				// cout << "colled" << endl;
			} else if (rem == 1 + pbcnt[now-1].first + pbcnt[now-1].second + 1) {
				ansp = ansp + pbp[now-1] + 1;
				fin = true;
			} else if (rem != pbcnt[now].first + pbcnt[now].second) {
				ansp = ansp + pbp[now-1] + 1;
				search(now-1,rem-2-(pbcnt[now-1].first + pbcnt[now-1].second));
				// cout << "colleded" << endl;
			} else {
				ansp = ansp + pbp[now-1] * 2 + 1;
				fin = true;
			}
		}
	}
}

int main() {
	pbcnt[0].first = 1;pbcnt[0].second = 0;pbp[0] = 1;
	for (int i = 1;i < 51;i++) {
		pbcnt[i].first = pbcnt[i-1].first * 2 + 1;
		pbcnt[i].second = pbcnt[i-1].second * 2 + 2;
		pbp[i] = pbcnt[i].first;
	}
	ll n,x;
	cin >> n >> x;
	search(n,x);
	cout << ansp << endl;
}

Measured memory_bytes: 256
/*
 * main.cpp
 *
 *  Created on: 2011/04/08
 *      Author: satoki
 *      5:09 ~ 6:03
 *      Wrong Answer : 2
 *      nÈºÌfð¢ÅÀ
 *      Runtime Error : 4
 *      PÂ½ßÉfðZbg
 */
#include <iostream>
#include <string.h>
using namespace std;

int iN;
int iDp[78499];

void init() {
  int i, j, cnt = 0;
  for (i = 2; i < 1000004; i++) {
    for (j = 0; j < cnt; j++) {
      if (iDp[j] * iDp[j] > i) {
        j = cnt;
        break;
      } else if (i % iDp[j] == 0) break;
    }
    if (j == cnt) {
      iDp[cnt] = i;
      cnt++;
    }
  }
}

bool input() {
  if (scanf("%d", &iN) == EOF) return false;
  return true;
}

int manage() {
  int i;
  for (i = 0; iDp[i] <= iN; i++);
  return i;
}

int main() {
  init();
  while (1) {
    if (!input()) break;
    printf("%d\n", manage());
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define VI vector<int>
#define PII pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
#define out(x) cout<<(#x)<<" = "<<x<<endl
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x){return mrand()%x;}
clock_t ac; double TLE(){return (double)(clock()-ac)/CLOCKS_PER_SEC;}

int main(){
 ios::sync_with_stdio(0);
 cin.tie(0);
 int d,l,r;
 cin>>l>>r>>d;
 if(l%d==0){
 	cout<<((r/d)-(l/d)+1);
 }
 else{
 	cout<<((r/d)-(l/d));
 }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;cin>>s;
	int n=s[s.size()-1]-'0';
	if(n==2||n==4||n==5||n==7||n==9) cout<<"hon\n";
	if(n==0||n==1||n==6||n==8) cout<<"pon\n";
	if(n==3) cout<<"bon\n";
	return 0;
}

Measured memory_bytes: 3648
n = int(input())
a = list(map(int, input().split()))
a2 = []
for i in a:
  count = 0
  while True:
    if i % 2 == 0:
      i //= 2
      count += 1
    else:
      break
  a2.append(count)
print(min(a2))

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    map<string, int> mp;
    int N;
    cin >> N;

    string s;
    for (int i = 0; i < N; i++) {
        cin >> s;
        mp[s]++;
    }

    int nmax = 0;
    for (auto iter = mp.begin(); iter != mp.end(); iter++) {
        nmax = max(nmax, iter->second);
    }

    vector<string> strs;
    for (auto iter = mp.begin(); iter != mp.end(); iter++) {
        if (iter->second == nmax) {
            strs.push_back(iter->first);
        }
    }

    sort(all(strs));
    for (int i = 0; i < strs.size(); i++) {
        cout << strs[i] << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}



Measured memory_bytes: 26868
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main() {
    int n;
    scanf("%d",&n);
    long long int a[100005],b[100005];
    int i;
    for(i=0;i<=n-1;i++)scanf("%lld %lld\n",&a[i],&b[i]);
    long long int ans=0;
    
    for(i=n-1;i>=0;i--){
        if((a[i]+ans)%b[i]!=0)ans+=b[i]-(a[i]+ans)%b[i];
    }
    
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>


int main(void){
    char *s = (char*)malloc(101 * sizeof(char));
    char *t = (char*)malloc(101 * sizeof(char));
    scanf("%s", s);
    scanf("%s", t);


    int S = strlen(s);
    int T = strlen(t);
    int i, j;
    for(i=0; i<S-1; i++) {
        for(j=S-1; j>= i+1; j--) {
            if(s[j] < s[j-1]) {
                char temp;
                temp = s[j];
                s[j] = s[j - 1];
                s[j - 1] = temp;
            }
        }
    }
    for(i=0; i<T-1; i++) {
        for(j=T-1; j>= i+1; j--) {
            if(t[j] > t[j-1]) {
                char temp;
                temp = t[j];
                t[j] = t[j - 1];
                t[j - 1] = temp;
            }
        }
    }

    if(strcmp(s, t) < 0) {
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
  free(s);
  free(t);
  return 0;
}

Measured memory_bytes: 128
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long N = lread();
    auto A = aryread();
    (A.reduce!max - A.reduce!min).writeln();

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
ll test[1234][1234];
signed main() {
	ll n = 0, m = 0, k, l, cnt = 0, z = 0; cin >> k >> n;
	k %= 500;
	if (k <= n) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	cin >> n; return 0;
}

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

int main(){
  int c1, c2, c3;
  while(cin>>c1>>c2>>c3){
    int n=0;
    for(int i=1; i<=10; i++){
      if(i==c1 || i==c2 || i==c3)continue;
      if(c1+c2+i<=20)n++;
    }
    if(n>3)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
using namespace std;
double ans(long long x) {
	long long sum = 0;
	long long ans = x;
	while (x) {
		sum += x % 10;
		x /= 10;
	}
	return ans * 1.0 / (sum*1.0);
}

int main()
{
	long long k;
	cin >> k;
	long long x = 1, z = 0;
	while (k > 0) {
		if ((z/x)%10!=9) {
			z += x;
			cout << z << endl;
		}
		else {
			if (ans(z + x) > ans(z + 10 * x)) {
				x = 10 * x;
			}
			z += x;
			cout << z << endl;
		}
		k--;
	}
	return 0;
}

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

int main(){
    long long x;
    cin >> x;

    long long amountOf500, amountOf5;
    long long ans = 0;

    amountOf500 = x / 500;
    ans += 1000 * amountOf500;
    x -= amountOf500 * 500;
    amountOf5 = x / 5;
    ans += 5 * amountOf5;

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

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

typedef long long ll;
typedef double db;

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, MOD = 1e9 + 7, N = 1e5 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

void test() {
    int n; cin >> n;
    int div = n / 1000;
    if (n % 1000) {
        ++div;
    }
    cout << 1000 * div - n << "\n";
}

int main() {
      fast_io();
      #ifdef HOME
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
      #endif
      cout << fixed << setprecision(15);
      int t = 1;
      // cin >> t;
      for (int i = 1; i <= t; ++i) {
          test();
      }
      #ifdef HOME
          cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
      #endif
      return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
#define STACK_SIZE 100
#define MAX_LEN 1000

int stack[STACK_SIZE];
int stack_size = 0;

int pop()
{
	if (stack_size <= 0) return 0;
	return stack[--stack_size];
}

int push(int a)
{
	stack[stack_size++] = a;
}

int is_digit(char *s)
{
	if (*s == '+' || *s =='-') {
		s++;
		if (*s >= '0' && *s <= '9') return 1;
		return 0;
	}
	if (*s >= '0' && *s <= '9') return 1;
	return 0;
}

int get_number(char *s)
{
	int sign = 0, n = 0;
	
	if (*s == '+') {
		s++;
	} else if (*s == '-') {
		sign = 1;
		s++;
	}
	while (*s >= '0' && *s <= '9') {
		n = n * 10 + (*s - '0');
		s++;
	}
	if (sign) return -n;
	return n;
}

int calc_rpn(char *s)
{
	int a, b, n;

	while (*s) {
		
		if (is_digit(s)) {
			n = get_number(s);
			push(n);
			while (*s == '-' || *s == '+') {
				s++;
			}
			while (n) {
				n /= 10;
				s++;
			}
			
		} else {
			switch (*s) {
			case '+':
				a = pop();
				b = pop();
				push(b+a);
				break;
			case '-':
				a = pop();
				b = pop();
				push(b-a);
				break;
			case '*':
				a = pop();
				b = pop();
				push(b*a);
				break;
			case '/':
				a = pop();
				b = pop();
				if (a == 0) break;
				push(b/a);
				break;
			case '%':
				a = pop();
				b = pop();
				if (a == 0) break;
				push(b%a);
			}
			s++;
		}
	}
	return pop();
}

int main()
{
	char s[MAX_LEN];
	scanf("%[^\n]*s", s);
	printf("%d\n",calc_rpn(s));
return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    string s;
    cin >> s;
    vector<int> count(2, 0);
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '0') {
            count[0]++;
        } else {
            count[1]++;
        }
    }
    cout << min(count[0], count[1]) * 2 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include<bits/stdc++.h>
using namespace std;
using ll =long long;

main (void) {
  int A[26]={0},x=0,i;
  char s;
  while(cin >> s){
    ++A[s-'a'];
  }
  for (i=0;i<26;++i){
    A[i]%2? x=x+1:x=x+0;
  }
  cout << (x? "No":"Yes");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

template <class T> T div_minus (T a, T b) {
	if (a % b < 0) return a / b - 1;
	else return a / b;
}
template <class T> T mod_minus (T a, T b) {
	if (a % b < 0) return a % b + b;
	else return a % b;
}
int main(void)
{
	ll n, l, t;
	cin >> n >> l >> t;
	vector<ll> x(n), w(n);
	vector<P> res(n);
	rep (i, n) {
		cin >> x[i] >> w[i];
		if (w[i] == 1) res[i].first = (x[i] + t) % l;
		else res[i].first = mod_minus(x[i] - t, l);
		res[i].second = i;
	}
	ll count = 0;
	repp (i, 1, n) {
		if (w[0] == 1) {
			if (w[i] == 2) {
				// cout << i << ": " << div_minus(2 * t - (x[i] - x[0]), l) + 1 << endl;
				count += div_minus(2 * t - (x[i] - x[0]), l) + 1;
			}
		} else {
			if (w[i] == 1) {
				// cout << i << ": " << div_minus(2 * t - (l + x[0] - x[i]), l) + 1 << endl;
				count -= div_minus(2 * t - (l + x[0] - x[i]), l) + 1;
			}
		}
	}
	sort(all(res));
	ll k;
	for (k = 0; k < n; k++) {
		if (res[k].second == 0) break;
	}
	if (w[0] == 1 && res[(k + 1) % n].first == res[k].first) k++;
	// cout << count << " " << k << endl;
	count = mod_minus(k - count, n);
	rep(i, n) {
		cout << res[(i + count) % n].first << endl;
	}
	return 0;
}

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

int main(void) {
    string s;
    cin >> s;
    vector<int> chk(26,0);
    for(int i=0;i<s.size();i++) {
        chk[s[i] - 'a']++;
    }
    for(int i=0;i<26;i++) {
        if(chk[i] > 1) {
            cout << "no\n";
            return 0;
        }
    }

    cout << "yes\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, a[214514];
bool used[30];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	int ans = 0;
	int ri = 0;
	rep(i, n) {
		while (ri < n) {
			rep(j, 20) {
				if ((a[ri] >> j & 1) && used[j])goto ng;
			}
			rep(j, 20) {
				if (a[ri] >> j & 1)used[j] = true;
			}
			ri++;
		}
	ng:;
		ans += ri - i;
		rep(j, 20) {
			if (a[i] >> j & 1)used[j] = false;
		}
	}
	cout << ans << endl;
}

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

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2 - x1;
	int dy = y2 - y1;
	cout << x2 - dy << " " << y2 + dx << " ";
	cout << x1 - dy << " " << y1 + dx << endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  if(n/100==9) n-=800;
  else if(n/100==1) n+=800;
  if((n%100)/10==9) n-=80;
  else if((n%100)/10==1) n+=80;
  if((n%100)%10 ==9) n-= 8;
  else if((n%100)%10==1) n+=8;
  
  cout<<n<<endl;
  return 0;
  
  }

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), W = getint();

	ll dp[100001] = {};
	rep(i, N) {
		int w = getint();
		int v = getint();
		for (int j = W - 1; j >= 0; j--) {
			if (j + w <= W) chmax(dp[j + w], dp[j] + v);
		}
	}

	ll kotae = 0;
	rep1(i, W) chmax(kotae, dp[i]);
	
	printf("%lld", kotae);

	Would you please return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	vector<int64> vs;
	vs.reserve(s.size());
	vector<char> ss;
	REP(i, s.size()) {
	  if (vs.size() == 0 || s[i] != s[i-1]) {
	    vs.push_back(1);
	    ss.push_back(s[i]);
	  } else {
	    vs.back()++;
	  }
	}
	int64 res = 0;
	int64 ls = 0;
	REP(i, vs.size()) {
	  res += vs[i] * (vs[i]-1) / 2;
	  if (i > 0 && ss[i] == '>') {
	    res += max(vs[i], vs[i-1]);
	  }
	}
	if (ss[0] == '>') {
	  res += vs[0];
	}
	if (ss.back() == '<') {
	  res += vs.back();
	}

	cout << res << endl;
}


Measured memory_bytes: 4636
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <random>
#include <time.h>
#include <chrono>
#include <cmath>
using namespace std;

struct Data {
    int pref;
    int year;
    int index;
    int num;
};

bool CompData(const Data &d1, const Data &d2) {
    return d1.year < d2.year;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<Data> data(M);
    Data d;

    for (int i = 0; i < M; ++i) {
        cin >> d.pref >> d.year;
        d.index = i;
        data[i] = d;
    }

    vector<vector<Data>> data2(N);
    for (int i = 0; i < M; ++i) {
        data2[data[i].pref - 1].push_back(data[i]);
    }

    for (int i = 0; i < N; ++i) {
        sort(data2[i].begin(), data2[i].end(), CompData);
        for (int j = 0; j < data2[i].size(); ++j) {
            //data2[i][j].num = j + 1;
            data[data2[i][j].index].num = j + 1;

        }
    }


    for (int i = 0; i < M; ++i) {
        printf("%06d%06d\n", data[i].pref, data[i].num);
    }

    return 0;
}

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

signed main() {
	int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
	b += 60 * a; d += 60 * c;
	cout << d - b - e << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  struct Arm { int x, l, r; };
  vector<Arm> v(n);
  rep (i, n) {
    int a, b;
    cin >> a >> b;
    v[i].x = a;
    v[i].l = a - b;
    v[i].r = a + b;
  }
  auto comp = [](Arm &a, Arm &b) { return a.r < b.r; };
  sort(all(v), comp);
  int cnt = 0, now = INT_MIN;
  rep (i, n) {
    if (now <= v[i].l) {
      ++cnt;
      now = v[i].r;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

using namespace std;

int main(){
//	int input = 0;
	char input[10];
	cin >> input;
//	int angka1 = input%10;
//	int angka2 = input-100-angka1;
//	angka2 = angka2/10;
//	int angka3 = input-angka2-angka1;
//	angka3 = angka3/100;
	if(input[0] == '7' || input[1] == '7' || input[2] == '7'){
		cout << "Yes" <<endl;
		}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3020
#include<iostream>
#include<vector>
#include<queue>
#include<map>
using namespace std;

constexpr int N = 3, N_2D = 9;

struct Puzzle {
    int location[N_2D];
    int space;
    string path;

    bool operator<(const Puzzle& puzzle) const {
        for(int i = 0; i < N_2D; ++i){
            if(location[i] == puzzle.location[i]){
                continue;
            }
            return location[i] > puzzle.location[i];
        }
        return false;
    }
};

/**
 *  位置があっているかどうか判定する
 */
bool isTarget(const Puzzle& puzzle){
    for(int i = 0; i < N_2D; ++i){
        if(puzzle.location[i] != i+1){
            return false;
        }
    }
    return true;
}

/**
 *  幅優先探索
 */
string bfs(const Puzzle& origin){
    queue<Puzzle> que;
    map<Puzzle, bool> mp;    // 配置を記録していく
    que.push(origin);
    mp[origin] = true;

    constexpr int dx[] = {-1, 0, 1, 0};
    constexpr int dy[] = {0, -1, 0, 1};
    constexpr char direction[] = {'u', 'l', 'd', 'r'};
                                 // up, left, down, right
    while(!que.empty()){
        Puzzle parent = que.front();
        que.pop();
        if(isTarget(parent)){    // もしパズルuがターゲットと合致していれば終わり
            return parent.path;
        }
        int sx = parent.space / N;   // space x
        int sy = parent.space % N;   // space y

        for(int i = 0; i < 4; ++i){
            int tx = sx + dx[i];    // transfer x
            int ty = sy + dy[i];    // transfer y
            if(tx < 0 || ty < 0 || tx >= N || ty >= N){
                continue;    // 移動先がパズルの枠を超えてしまわないようにする
            }

            Puzzle child = parent;
            swap(child.location[parent.space], child.location[tx * N + ty]);
            child.space = tx * N + ty;    // spaceの位置も移動

            if(!mp[child]){    // 既に同じ配置のパズルを動かし済みの場合はスルーする
                mp[child] = true;
                child.path += direction[i];
                que.push(child);
            }
        }
    }
    return "unsolvable";
}


int main(){

    Puzzle puzzle;

    for(int i = 0; i < N_2D; ++i){
        cin >> puzzle.location[i];
        if(puzzle.location[i] == 0){
            // spaceの場所をセットする
            puzzle.location[i] = N_2D;
            puzzle.space = i;
        }
    }
    puzzle.path = "";

    string ans = bfs(puzzle);
    if(ans != "unsolvable"){
    	cout << ans.size() << endl;
    }

    return 0;
}



Measured memory_bytes: 30616
// @ts-ignore
import * as fs from 'fs';
import { kMaxLength } from 'buffer';

// main
function main(input: string[]) {
    // param
    var work0: number[] = input.shift().split(" ").map(x => Number(x));
    var n: number = work0[0];
    var m: number = work0[1];
    var node: number[][] = input.map(x => x.split(" ").map(x => Number(x) - 1));
    // process
    UF_initRoot(n);
    node.forEach(value => {
        var a: number = value[0];
        var b: number = value[1];
        UF_mergeRoot(a, b);
    });
    // answer
    console.log(Math_max(g_uf_count));
}

function Math_max(arr: number[]) {
    return arr.reduce(function(x, y) {
        return Math.max(x, y);
    });
}

// entrypoint
function entrypoint() {
    try {
        var input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        console.log("----");
        console.log("file='%s'", __filename.split("\\").slice(-1)[0]);
        console.log("----");
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            input = lines;
            console.log("input=%o", input);
            console.time();
            console.log("----")
            main(input);
            console.log("----")
            console.timeEnd();
        });
    }
}
entrypoint();

// union-find library
var g_uf_root: number[];
var g_uf_count: number[];
function UF_initRoot(num: number) {
    g_uf_root = new Array(num).fill(-1);
    g_uf_count = new Array(num).fill(1);
}
function UF_getRoot(index: number) {
    if (g_uf_root[index] < 0) {
        return index;
    } else {
        var work0: number = UF_getRoot(g_uf_root[index]);
        g_uf_root[index] = work0;
        return work0
    }
}
function UF_mergeRoot(a: number, b: number) {
    var root0: number = UF_getRoot(a);
    var root1: number = UF_getRoot(b);
    if (root0 == root1) return;
    if (root0 > root1) [root0, root1] = [root1, root0];
    g_uf_count[root0] += g_uf_count[root1];
    g_uf_count[root1] = 0;
    g_uf_root[root1] = root0;
}

Measured memory_bytes: 87596
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=20;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}int n,a[MAXN];
ll Solve(int l,int r,int cl,int cr){
	if(l>r)return 0;ll tmp=1e18;
	Rep(i,l,r)tmp=min(tmp,Solve(l,i-1,cl,cl+cr)+1ll*a[i]*(cl+cr)+Solve(i+1,r,cl+cr,cr));
	return tmp;
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();Rep(i,0,n-1)a[i]=read();n-=2;
	cout<<Solve(1,n,1,1)+a[0]+a[n+1]<<"\n";
	return 0;
}




Measured memory_bytes: 3616