akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int N;
	string s;
	cin >> N >> s;
	int a=0,b=0;
	for(auto c:s){
		if(c=='R'){
			a++;
		}
		else{
			b++;
		}
	}
	if(a>b){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 888
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<deque>
#include<cstdio>
#include<ctime>
#include<bitset>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
#define ULL unsigned long long
int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
#define MAXN 200000
#define INF 0x3f3f3f3f
int main(){
	int n=read(),dif=0;
	for(int i=1;i<=n;i++)
		if(read()!=i) dif++;
	if(dif<=2) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);
		int a =sc.nextInt();
		int b =sc.nextInt();
		int c =sc.nextInt();
		int d =sc.nextInt();
		int e =sc.nextInt();
		int k =sc.nextInt();

		if(e-a>k) {
			System.out.println(":(");
		}
		else {
			System.out.println("Yay!");
		}
	}

}





Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;
int main() {
    int x[5];
    for (int i = 0; i < 5; i++)
    {
        cin>>x[i];
    }
    
    
    for (int i = 0; i < 5; i++)
    {
        if(x[i]==0){
            cout<<i+1<<endl;
            return 0;
        }    
    }
    
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
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 < (int)b; i++)
const int INF = 1<<28;

int m[50][50];
int w, h;
int cnt;

void dfs(int x, int y, int z) {
	if(m[y][x]) {
		if(!z)
			cnt++;
		m[y][x] = false;
		if(y > 0 && m[y-1][x])
			dfs(x, y-1, 1);
		if(y > 0 && x > 0 && m[y-1][x-1])
			dfs(x-1, y-1, 1);
		if(x > 0 && m[y][x-1])
			dfs(x-1, y, 1);
		if(x > 0 && y < h-1 && m[y+1][x-1])
			dfs(x-1, y+1, 1);
		if(x < w-1 && m[y][x+1])
			dfs(x+1, y, 1);
		if(x < w-1 && 0 < y && m[y-1][x+1])
			dfs(x+1, y-1, 1);
		if(y < h-1 && m[y+1][x])
			dfs(x, y+1, 1);
		if(y < h-1 && x < w-1 && m[y+1][x+1])
			dfs(x+1, y+1, 1);
	}
	return;
}

int main() {
	while(cin >> w >> h, w|h) {
		REP(i, h) REP(j, w)
			cin >> m[i][j];

		cnt = 0;
		REP(i, h) REP(j, w)
			dfs(j, i, 0);

		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1384
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ull i=a;i<b;i++)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define trace(s,a) cout<<s<<a,nl

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

    if(l == 0){
    	cout<<n*(n-1)/2<<endl;
    }else if(l < 0){
    	if(l + n - 1 <= 0){
    		ll c = l+n-1;
    		l = (-1)*l;
    		cout<<(-1)*(l*(l+1)/2 - (c)*(c-1)/2)<<endl;
    	}else{
    		ll c = l + n - 1;
    		l = (-1)*l;
    		cout<<(-1)*(l*(l+1)/2) + c*(c+1)/2<<endl;
    	}
    }else{
    	cout<<(l+n-1)*(l+n)/2 - l*(l+1)/2<<endl;
    }

}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define reps(i, s, n) for (int i = s; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define repsl(i, s, n) for (ll i = s; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl
#define readVarll(nam) ll nam; cin >> nam

ll d[20];
ll n, k;

ll calc1()
{
  ll ans = pow(10, 10) * n;
  rep(i, 1 << (n-1))
  {
    if(__builtin_popcount(i) != k-1)
    {
      continue;
    }

    ll befh = d[0];
    ll tmp = 0;
    reps(j, 1, n)
    {
      if(i & 1 << (j-1))
      {
        tmp += max(0LL, befh - d[j] + 1);
        befh = max(befh+1, d[j]);
      }
      else
      {
        befh = max(befh, d[j]);
      }
      
    }
    ans = min(ans, tmp);
  }

  return ans;
}

ll calc2()
{
  ll ans = 0;
  ll bef = d[0];
  reps(i, 1, n)
  {
    if(d[i] <= bef)
    {
      ans += bef - d[i] + 1;
      bef++;
    }
    else
    {
      bef = d[i];
    }
  }

  return ans;
}

int main()
{
  cin >> n >> k;
  
  repl(i, n)
  {
    cin >> d[i];
  }
  
  // srand((unsigned)time(NULL));
  // rep(i, 10)
  // {
  //   n = (rand() % 15) + 1;
  //   k = (rand() % n) + 1;
  //   rep(j, n)
  //   {
  //     d[j] = (rand() % 1000000000) + 1;
  //   }

  //   ll an1 = calc1();
  //   ll an2 = calc2();
  //   if(an1 != an2)
  //   {
  //     outdeb("wrong", an1, an2);
  //     outdeb("n,k=",n,k);
  //     rep(j, n)
  //     {
  //       cout << d[j] << " ";
  //     }
  //     cout << endl;
  //   }
  // }

  cout << calc1() << endl;
  //cout << calc2() << endl;
  return 0;
}

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

bool compare_by_greater_y(pair<int,int>a, pair<int,int>b){
  if(a.second!=b.second) return a.second>b.second;
  else return a.first>b.first;
}

int main(){
  int n,ans=0;
  pair<int,int> r[100],b[100];
  bool rf[100];
  cin>>n;
 
  REP(i,n){
    int x,y;cin>>x>>y;
    r[i]=make_pair(x,y);
    rf[i]=0;
  }
  sort(r,r+n,compare_by_greater_y);  

  REP(i,n){
    int x,y;cin>>x>>y;
    b[i]=make_pair(x,y);
  }
  sort(b,b+n);

  REP(i,n){
    REP(j,n){
      if(!rf[j]&&r[j].first<b[i].first&&r[j].second<b[i].second){
        ans++;
        rf[j]=1;
        break;
      }
    }
  }

  cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    char i,h;
    int j=0,k[1000]={0},a;
    while(scanf("%c",&i)!=EOF){
        /*scanf("%c",&i);
        if(i=='\n'){
            break;
        }
        else */if('a'<=i&&i<='z'){
            k[i]++;
        }
        else if('A'<=i&&i<='Z'){
            i=i+32;
            k[i]++;
        }
    }
    for(a='a';a<='z';a++){
        printf("%c : %d\n",a,k[a]);
    }
    return 0;
}

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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    
    ll ans = 0;
    int pos = A[0];
    for ( int i = 1; i < N; ++i){
        if ( pos > A[i] ){
            ans += ( pos - A[i] );
        } else {
            pos = A[i];
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4044
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>
#include <fstream>

using namespace std;

long long mod = 1000000007;

void dfs(int p, int prev, vector<int> &a, vector<int> &dp, int dpl, vector<vector<int>> &v, vector<int> &res)
{
    int l = -1, r = dpl, mid;
    while (r - l > 1)
    {
        mid = (l + r) / 2;
        if (dp[mid] >= a[p])
        {
            r = mid;
        }
        else
        {
            l = mid;
        }
    }
    int temp = dp[r];
    dp[r] = a[p];
    if (temp == -1)
    {
        dpl++;
    }
    res[p] = dpl;
    for (int i = 0; i < v[p].size(); i++)
    {
        if (v[p][i] == prev)
        {
            continue;
        }
        dfs(v[p][i], p, a, dp, dpl, v, res);
    }
    dp[r] = temp;
}

int main()
{
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    // ifstream cin("in.txt");
    // ofstream cout("out.txt");
    
    
    // int t;
    // cin >> t;
    // for (int qwe = 0; qwe < t; qwe++)
    // {
    //     cout << "Case #" << qwe + 1 << ": ";
    // }


    int x;
    cin >> x;
    for (long long i = -1000; i <= 1000; i++)
    {
        for (long long j = -1000; j <= 1000; j++)
        {
            if (i * i * i * i * i - j * j * j * j * j == x)
            {
                cout << i << " " << j << '\n';
                return 0;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 3168
#include <cstdio>
#include <algorithm>

using namespace std;
const int maxn = 100000;
int arr[maxn][3], dp[maxn][3];

int main() {
    int n, a, b, c;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d%d%d", &a, &b, &c);
        arr[i][0] = a;
        arr[i][1] = b;
        arr[i][2] = c;
        for (int j = 0; j < 3; ++j) {
            if (i == 0) {
                dp[i][j] = arr[i][j];
            } else {
                dp[i][j] = max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + arr[i][j];
            }
        }
    }
    int ans = -1;
    for (int j = 0; j < 3; ++j) {
        if (dp[n - 1][j] > ans) {
            ans = dp[n - 1][j];
        }
    }
    printf("%d", ans);
    return 0;
}




Measured memory_bytes: 2560
// A.cpp
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    ll n, A, B, ans = 0x7fffffffffffffff;
    scanf("%lld%lld%lld", &n, &A, &B);
    ans = min(A - 1, n - B) + 1 + ((B - A - 1) >> 1);
    if (!((A^B) & 1))
        ans = min(ans, (B - A) >> 1);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3816
using System;
using System.Collections.Generic;
using System.Text;


namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            // ????????????????????¶????????????????¬??????????
            int[,] card = new int[4, 13];

            // ??\?????????????????????????????°?????????
            int inputNum = int.Parse(Console.ReadLine());

            // ?????????????????°????????°?????????
            for (int i = 0; i < inputNum; i++)
            {
                // ??????????????±?????????
                string[] ss = Console.ReadLine().Split(' ');

                // ?????????????¨???????????????????????????????????¨??????????
                int markIndex = 0;
                //if(ss[0] == "S")
                //{
                //    markIndex = 0;
                //}
                //if (ss[1] == "H")
                //{
                //    markIndex = 1;
                //}
                //if (ss[2] == "C")
                //{
                //    markIndex = 2;
                //}
                //if (ss[3] == "D")
                //{
                //    markIndex = 3;
                //}

                switch (ss[0])
                {
                    case "S": markIndex = 0; break;
                    case "H": markIndex = 1; break;
                    case "C": markIndex = 2; break;
                    case "D": markIndex = 3; break;
                }

                card[markIndex, int.Parse(ss[1]) - 1] = 1;
            }

            for (int mark = 0; mark < 4; mark++)
            {
                for (int num = 0; num < 13; num++)
                {
                    if (card[mark, num] == 0)
                    {
                        string m = "";
                        switch(mark)
                        {
                            case 0: m = "S"; break;
                            case 1: m = "H"; break;
                            case 2: m = "C"; break;
                            case 3: m = "D"; break;
                        }

                        Console.WriteLine(m + " " + (num + 1));
                    }
                }
            }
        }
    }
}

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

using namespace std;

int H, W, N;

bool check(int r, int c)
{
  return r == 0 || r == H || c == 0 || c == W;
}

int calc(int r, int c)
{
  if (r == 0) return c;
  if (c == W) return W + r;
  if (r == H) return 2 * W + H - c;
  if (c == 0) return 2 * (H + W) - r;
  return -1;
}

bool solve()
{
  cin >> H >> W >> N;
  vector<pair<int, int>> v;
  for (int i = 0; i < N; i++) {
    int r1, c1;
    int r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    if (!check(r1, c1) || !check(r2, c2)) continue;
    v.emplace_back(calc(r1, c1), i);
    v.emplace_back(calc(r2, c2), i);
  }
  sort(v.begin(), v.end());
  if (v.size() == 0) return true;
  vector<int> p;
  for (int i = 0; i < v.size(); i++) {
    int t = v[i].second;
    if (p.size() && p.back() == t) p.pop_back();
    else p.push_back(t);
  }
  return p.size() == 0;
}

int main()
{
  if (solve()) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 2672
N = int(input())
A = [[-1 for i in range(N)] for i in range(N)]
for i in range(N):
    m = int(input())
    for j in range(m):
        x,y = map(int,input().split())
        A[i][x-1] = y
#print(A)
ans = 0
for i in range(1<<N):
    honets = [0 for i in range(N)]
    for j in range(N):
        if (i>>j) & 1:
            honets[j] = 1
    ok = True
    for j in range(N):
        if honets[j] == 1:
            for k in range(N):
                if A[j][k] == -1: continue
                if A[j][k] != honets[k]: ok = False
    if ok:
        ans = max(ans, honets.count(1))
print(ans)


Measured memory_bytes: 45276
k = int(input())
L = []
ans = 0
for i in range(1, 11):
    L.append([])
if k <= 9:
    print(k)
else:
    for i in range(1,10):
        L[0].append(str(i))
        ans = 9
    for i in range(1,10):
        for j in range(len(L[i-1])):
            if L[i-1][j][i-1] == '9':
                L[i].append(L[i-1][j]+'8')
                L[i].append(L[i-1][j]+'9')
            elif L[i-1][j][i-1] == '0':
                L[i].append(L[i-1][j]+'0')
                L[i].append(L[i-1][j]+'1')
            else:
                L[i].append(L[i-1][j]+str(int(L[i-1][j][i-1])-1))
                L[i].append(L[i-1][j]+str(int(L[i-1][j][i-1])))
                L[i].append(L[i-1][j]+str(int(L[i-1][j][i-1])+1))
    templist = []
    for i in range(10):
        templist = templist + L[i]
    print(templist[k-1])


Measured memory_bytes: 60504
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000007
using namespace std;

int main(){
  long n,d;
  cin >> n >> d;
  int ans = 0;
  rep(i,n){
    long x,y;
    cin >> x >> y;
    if(x*x + y*y <= d*d)ans++;
  }
  cout << ans << endl;
  return 0;
}



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

long long int mpow(long long int x, int n, int MOD)
{
    if(n == 0)
        return 1;

    long long int k = 1;
    while(n > 1)
    {
        if(n % 2 == 1)
        {
            k *= x;
            k %= MOD;
        }
        x *= x;
        x %= MOD;
        n /= 2;

    }
    return (k * x) % MOD;
}

int main()
{
    int n;
    string s;
    cin >> n >> s;
    ll pop = 0;
    rep(i,n) if(s[i] == '1') pop++;

    if(pop == 0)
    {
        rep(i,n) cout << 1 << "\n";
        return 0;
    }
    else if(pop == 1)
    {
        rep(i,n)
        {
            if(s[i] == '1')
            {
                cout << 0 << endl;
            }
            else
            {
                if(i == n-1 || s[n-1] == '1')
                {
                  cout << 2 << endl;
                }
                else
                {
                  cout << 1 << endl;
                }
            }
        }
        return 0;
    }

    ll sum1 = 0, sum2 = 0;
    rep(i,n)
    {
        if(s[i] == '0') continue;
        sum1 += mpow(2, n-i-1, pop+1);
        sum2 += mpow(2, n-i-1, pop-1);
    }
    rep(i,n)
    {
        if(s[i] == '0')
        {
            ll MOD = pop+1;
            ll sum = sum1 + mpow(2, n-i-1, MOD);
            sum %= MOD;
            int ans = 1;
            while(sum)
            {
                sum = sum % __builtin_popcount(sum);
                ans++;
            }
            printf("%d\n", ans);
        }
        else if(s[i] == '1')
        {
            ll MOD = pop-1;
            ll sum = sum2 - mpow(2, n-i-1, MOD);
            sum %= MOD;
            int ans = 1;
            while(sum)
            {
                sum = sum % __builtin_popcount(sum);
                ans++;
            }
            printf("%d\n", ans);
        }

    }
    return 0;
}


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

int main(){
	int x,y;
	cin >> x >> y;
	while(!(x==0&&y==0)){
		if(x<y) cout << x << " " << y << endl;
		else cout << y << " " << x << endl;
		cin >> x >> y;
	}
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
//#include <cstdio>
//#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
//#include <set>
#include <queue>
//#include <limits>
#include <sstream>
//#include <functional>
using namespace std;

#define len(array)  (sizeof (array) / sizeof *(array))
#define rep(i, s, e) for(int i = s;i < e;i++)
#define rrep(i, e, s) for(int i = e;s <= i;i--)
#define mfill(a, v) fill(a, a + len(a), v)
#define mfill2(a, v, t) fill((t *)a, (t *)(a + len(a)), v)
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v, t) sort(v.begin(), v.end(), greater<t>())
#define asort(a) sort(a, a + len(a))
#define rasort(a, t) sort(a, a + len(a), greater<t>())
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-10;
const int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};
const int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
const int weight[] = {0,1,10,100,1000,10000,100000,1000000,10000000};


const int MAX_N = 100000 + 2;
ll bit[MAX_N], input[MAX_N], n;


void add(int idx, ll val, ll* ary){
  int p = idx;
  while(p < MAX_N){
	ary[p] = max(ary[p], val);
	p += p & -p;
  }
}

ll get(int idx, ll *ary){
  ll res = 0;
  int p = idx;
  while(0 < p){
	res = max(res, ary[p]);
	p -= p & -p;
  }
  return res;
}

void doIt(){
  cin >> n;
  rep(i, 0, n) cin >> input[i];
  mfill(bit, 0);
  rep(i, 0, n){
	add(input[i], get(input[i], bit) + input[i], bit);
  }
  cout << n*(n+1)/2 - get(n, bit) << endl;
}

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

Measured memory_bytes: 2720
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]
a = [0] * 100010
count = 0 
for i in range(1,len(s)):
    if s[i] == 'C' and s[i-1] == 'A':
        count += 1
    a[i] = count
# print(a)
for index in lr:
    # print(index)
    print(a[index[1]-1] - a[index[0]-1])



Measured memory_bytes: 30688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[M];
		for(int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
		}
		for(int i = 0; i < M; i++) {
			y[i] = sc.nextInt();
		}

		boolean warflag = true;

		for(int z = X + 1; z <= Y; z++) {
			boolean flag = false;
			for(int j = 0; j < x.length; j++) {
				if(!(x[j] < z)) {
					flag = true;
					break;
				}
			}
			if(flag)continue;
			for(int j = 0; j < y.length; j++) {
				if(!(y[j] >= z)) {
					flag = true;
					break;
				}
			}
			if(!flag) {
				warflag = false;
				break;
			}


		}
		System.out.println(warflag ?  "War" : "No War");

	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
#define pii pair <int , int > 
#define pll pair < ll , ll >
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n , d ;
  cin >> n >> d ;
  d = 2*d ;
  d++ ;
  if(n%d)
    cout << n/d + 1;
  else cout << n/d ;
}

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

using namespace std;

#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	int n = (int)s.size();
	int k;
	cin >> k;
	vector<int> cnt;
	for (int i = 0; i < n; i++) {
		int r = i;
		while (r + 1 < n && s[r] == s[r + 1]) {
			r++;
		}
		cnt.push_back(r - i + 1);
		i = r;
	}
	if ((int)cnt.size() == 1) {
		cout << ((n * k)) / 2 << endl;
		return 0;
	}
	if (s[0] == s[n - 1]) {
		int ans = 0;
		for (int i = 1; i + 1 < (int)cnt.size(); i++) {
			ans += k * ((cnt[i]) / 2);
		}
		ans += (k - 1) * (((cnt.front() + cnt.back())) / 2);
		ans += (cnt.front()) / 2;
		ans += (cnt.back()) / 2;
		cout << ans << endl; 
	} else {
		int ans = 0;
		for (int i = 0; i < (int)cnt.size(); i++) {
			ans += k * ((cnt[i]) / 2);
		}
		cout << ans << endl;
	}
}

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

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n;
   cin >> n;
   vector<int> a(n + 2, 0), l(n + 2, 0), r(n + 2, 0);
   for (int i = 1; i <= n; i++)
      cin >> a[i];
   for (int i = 1; i <= n; i++)
   {
      l[i] = max(a[i], l[i - 1]);
      r[n - i + 1] = max(a[n - i + 1], r[n - i + 2]);
   }
   for (int i = 1; i <= n; i++)
      cout << max(l[i - 1], r[i + 1]) << endl;
   return 0;
}


Measured memory_bytes: 3968
#include <stdio.h>
int main(){
  long long int n,a[99];
  scanf("%lld",&n);
  a[0]=2;a[1]=1;
  for(int i=2;i<=n;i++){
    a[i]=a[i-1]+a[i-2];
  }
  printf("%lld",a[n]);
  return 0;
}

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

int main() {
  string str;
  cin >> str;
  if(str == "SAT") cout << 1 << endl;
  else if(str == "FRI") cout << 2 << endl;
  else if(str == "THU") cout << 3 << endl;
  else if(str == "WED") cout << 4 << endl;
  else if(str == "TUE") cout << 5 << endl;
  else if(str == "MON") cout << 6 << endl;
  else if(str == "SUN") cout << 7 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}


int main() {
	int n, m;
	cin >> n;
	vector<int> a(n);
	vector<ll> s(n + 1);
	map<ll, ll> mp;
	s[0] = 0;
	ll ans = 0;
	REP(i, n) {
		cin >> a[i];
		s[i + 1] = (s[i] + a[i]);
	}
	REP(i, s.size()) {
		ans += mp[s[i]];
		mp[s[i]]++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MP make_pair
#define endl '\n'
const int mod = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int INF = 0x3f3f3f3f;

int n, k, r, s, p;
char str[MAXN];
int iswin[MAXN];

int getp(char c) {
    switch (c) {
        case 'r': return p;
        case 's': return r;
        case 'p': return s;
    }
}

int main(int argc, char* argv[]) {
#ifdef local
    freopen("in.txt", "r", stdin);
#endif
    cin >> n >> k >> r >> s >> p >> str;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (i < k) {
            iswin[i] = 1;
            sum += getp(str[i]);
        } else {
            if (str[i] != str[i - k]) {
                iswin[i] = 1;
                sum += getp(str[i]);
            } else {
                if (iswin[i - k])
                    iswin[i] = 0;
                else {
                    iswin[i] = 1;
                    sum += getp(str[i]);
                }
            }
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
using namespace std;
int main(void){
    int N,X;
    cin>>N>>X;
    int P[N];
    int min=1000;
    int rest=X;
    for(int i=0;i<N;i++){
        cin>>P[i];
        if(min>P[i]){
            min=P[i];
        }
        rest-=P[i];
    }
    cout<<N+rest/min<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;

#define ceil(a,b) ((a+b-1)/(b))

struct enemy{
	int c,d,s; // 倒すまでに叩くべき回数, 一回の攻撃で自分が受けるダメージ, 敏捷度
	bool operator<(const enemy &e)const{ return (ll)c*e.d<(ll)d*e.c; }
};

int main(){
	int n; scanf("%d",&n);
	int h[40001],a[40001],d[40001],s[40001];
	rep(i,n+1) scanf("%d%d%d%d",h+i,a+i,d+i,s+i);

	// 無敵の敵について例外処理
	rep(i,n) if(a[0]<=d[i+1]) {
		if(d[0]<a[i+1]){ // 無敵の敵からダメージを受けるなら負けるしかない
			puts("-1");
			return 0;
		}
		else{ // 無敵の敵からダメージを受けないならそんな敵はいないことにしてしまう
			swap(h[i+1],h[n]);
			swap(a[i+1],a[n]);
			swap(d[i+1],d[n]);
			swap(s[i+1],s[n]);
			n--;
			i--;
		}
	}

	int n_tmp=0;
	enemy E[40000];
	rep(i,n){
		if(a[i+1]<=d[0]) continue;
		E[n_tmp].c=ceil(h[i+1],a[0]-d[i+1]);
		E[n_tmp].d=a[i+1]-d[0];
		E[n_tmp].s=s[i+1];
		n_tmp++;
	}
	n=n_tmp;

	sort(E,E+n);

	ll dmg=0;
	// 1 ターン目に自分より速い敵の攻撃を受ける
	rep(i,n) if(s[0]<E[i].s) {
		dmg+=E[i].d;
		dmg=min(dmg,(ll)h[0]);
	}
	// しかるべき順で敵を倒したときの合計被ダメージを計算
	ll c_sum=0;
	rep(i,n){
		c_sum+=E[i].c;
		c_sum=min(c_sum,2000000000LL);
		dmg+=(c_sum-1)*E[i].d;
		dmg=min(dmg,(ll)h[0]);
	}
	if(h[0]<=dmg) puts("-1");
	else          printf("%lld\n",dmg);

	return 0;
}

Measured memory_bytes: 2084
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int n;
  string c,m;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>c>>m;
    int size=m.size();
    for(int j=c.size()-1;j>=0;j--){
      if(c[j]=='C'){
        m+=m[0];
        m.erase(m.begin());
      }
      if(c[j]=='J'){
        m=m[size-1]+m;
        m.erase(m.end()-1);
      }
      if(c[j]=='M'){
        for(int k=0;k<size;k++){
          if('0'<=m[k]&&m[k]<='8')m[k]++;
          else if(m[k]=='9')m[k]='0';
        }
      }
      if(c[j]=='P'){
        for(int k=0;k<size;k++){
          if('1'<=m[k]&&m[k]<='9')m[k]--;
          else if(m[k]=='0')m[k]='9';
        }
      }
      if(c[j]=='A')reverse(m.begin(),m.end());
      if(c[j]=='E'){
        if(size%2==0){
          string a;
          for(int k=size/2;k<size;k++)a+=m[k];
          for(int k=0;k<size/2;k++)a+=m[k];
          m=a;
        }else{
          string a;
          for(int k=size/2+1;k<size;k++)a+=m[k];
          a+=m[size/2];
          for(int k=0;k<size/2;k++)a+=m[k];
          m=a;
        }
      }
    }
    cout<<m<<endl;
  }
  return 0;
}

Measured memory_bytes: 3060
N = int(input())

dp = [i for i in range(N+1)]

for i in range(1,N+1):
    dp[i] = min(dp[i], 1+dp[i-1])
    tmp = 1
    while tmp <= i:
        dp[i] = min(dp[i], 1+dp[i-tmp])
        tmp *= 6
    tmp = 1
    while tmp <= i:
        dp[i] = min(dp[i], 1+dp[i-tmp])
        tmp *= 9

print(dp[-1])


Measured memory_bytes: 78316
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int ans = 1000;

  int MIN = A[0];
  REP(i, N){
    if(i != 0 && MIN < A[i]){
      int cnt = ans/MIN;
      ans -= cnt*MIN;
      ans += cnt*A[i];
      MIN = A[i];
    }else{
      chmin(MIN, A[i]);
    }
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i++)
typedef long long ll;
#define repran(i, a,b) for (int i = a; i<b;i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using LP = pair<ll,ll>;
using P = pair<int,int>;
const int inf = 500;
int h, w;
char g[21][21];
int di[4] = {-1, 0, 1, 0};
int dj[4] = {0, 1, 0, -1};

int bfs(int si, int sj){
    if (g[si][sj] == '#') return 0;
    vector<vector<int>> dist(h, vector<int>(w, inf));
    dist[si][sj] = 0;
    deque<P> q;
    int mdist = 0;
    q.emplace_back(si, sj);
    while (!q.empty())
    {
        P now = q.front();q.pop_front();
        int i = now.first;
        int j = now.second;
        rep(k, 4){
            int ni = i + di[k];
            int nj = j + dj[k];
            if (ni < 0 or ni >= h or nj < 0 or nj >= w) continue;
            if (g[ni][nj] == '#') continue;
            if (dist[ni][nj] > dist[i][j]+1){
                dist[ni][nj] = dist[i][j] + 1;
                q.emplace_back(ni, nj);
                mdist = max(mdist, dist[ni][nj]);
            }
        }
        
    }
    return mdist;
}

int main()
{
    cin >> h >> w;
    rep(i, h) rep(j, w) cin >> g[i][j];
    int ans = 0;
    rep(i, h) rep(j, w) {
        ans = max(ans, bfs(i, j));
    }
    
    cout << ans << endl;

}

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

void solve() {
  string s;
  cin >> s;
  int a, b;
  a = stoi(s.substr(0,2));
  b = stoi(s.substr(2));
  if ((a >= 1 && a <= 12) && (b >= 1 && b <= 12)) {
    cout << "AMBIGUOUS" << endl;
  } else if (a >= 1 && a <= 12) {
    cout << "MMYY" << endl;
  } else if (b >= 1 && b <= 12) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
}

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

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

int main() {
	int n; cin >> n;
	int ans = 0;
	for(int i = 1; i < n+1; i++){
		if(to_string(i).size() % 2 == 1){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const ll INF = 1ll<<60;
const double EPS = 1e-8;
const int MOD = 1000000007;

int T, n, a, b;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin >> n >> a >> b;
    if (n < a + b - 1 || (ll)a * b < n) {
        cout << -1 << endl;
        return 0;
    }
    vi ans;
    REP(i, b) ans.push_back(b - i);
    int consumed = b + 1;
    a --;
    if (a) {
        int x = (n - b) % a;
        int y = (n - b) / a;
        REP(i, a) {
            int p = y + (i < x);
            REPS(j, p) ans.push_back(consumed + p - j);
            consumed += p;
        }
    }
    REP(i, ans.size()) cout << ans[i] << " \n"[i + 1 == ans.size()];
    return 0;
}

Measured memory_bytes: 3440
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,H,W,ans;
  set<ll> se;
  cin>>N;
  rep(i,N)cin>>j,se.insert(j);
  if(se.size()==N)printYES;
  else printNO;
  return 0;
}

Measured memory_bytes: 9600
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scan()
	x, y := 0, 0
	for i, v := range s {
		if stringToInt(string(v)) == i%2 {
			x++
		} else {
			y++
		}
	}
	fmt.Println(smaller(x, y))

}


Measured memory_bytes: 2104
iterator = [["NS", "S"], ["NT", "T"]]
var = {}
for i, j in iterator:
    var[i] = int(input())
    var[j] = [int(k) for k in input().split()]
res = 0
for T in var["T"]:
    if T in var["S"]:
        res += 1
print(res)

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

int N;
int W[101];
int S[101];
void solve()
{
	S[0] = W[0];
	for(int i = 1; i < N; i++){
		S[i] = S[i-1] + W[i];
	}
	int ans = S[N-1];
	for(int i = 0; i < N; i++){
		int S1 = S[i];
		int S2 = S[N-1] - S[i];
		int ad = abs(S2 - S1);
		if(ans > ad)
			ans = ad;
	}
	cout << ans << endl;
}
int main()
{
	cin >> N;
	for(int i = 0; i < N; i++)
		cin >> W[i];
	solve();
	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <queue>
using namespace std;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
 
int main() {
	//freopen("test.txt", "r", stdin);
	FASTER;
	int a,b,c,d; cin>>a>>b>>c>>d;
	int t=1;
	while(1){
		if(t){
			c-=b;
			if(c<=0) {cout<<"Yes"<<endl; break;}
		}
		else{
			a-=d;
			if(a<=0) {cout<<"No"<<endl; break;}
		}
		t=!t;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f;








void sol()
{   
    cin>>n;
    map<string,int> m;
    while(n--)
    {   string s;
        cin>>s;
        m[s]++;
    }
    int mx=0;
    set<string> s;
    for(auto p:m)mx=max(mx,p.ss);
    for(auto p:m)
    {
        if(p.ss==mx)s.insert(p.ff);
    }

    for(auto c:s)cout<<c+'\n';
    
    
    
    //cout<<  <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 34856
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}


const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s;
  cin>>s;
  bool flag=true;
  rep(i,s.size()-1){
    if(s[i]==s[i+1]){
      flag=false;
    }
  }
  if(flag) cout<<"Good"<<endl;
  else cout<<"Bad"<<endl;
}

Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int a[N], b[N], out_degree[N];
bool seen[N];
vector<pii> g[N];

void dfs(int u, int id);

int main() {
	fast_cin();
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		cin >> a[i] >> b[i];
		g[a[i]].pb({b[i], i});
		g[b[i]].pb({a[i], i});
		++out_degree[a[i]];
	}
	if (m % 2 == 1) {
		cout << -1 << '\n';
	} else {
		dfs(1, 0);
		for (int i = 1; i <= m; ++i) {
			cout << a[i] << ' ' << b[i] << '\n';
		}
	}
}

void dfs(int u, int id) {
	seen[u] = true;
	for (auto &e : g[u]) {
		int v = e.first, n_id = e.second;
		if (!seen[v]) {
			dfs(v, n_id);
		}
	}
	if (out_degree[u] % 2) {
		--out_degree[a[id]];
		++out_degree[b[id]];
		swap(a[id], b[id]);
	}
}

Measured memory_bytes: 12800