akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main()
{
  int N;
  cin >> N;
  int A, B;
  cin >> A >> B;
  int cntA = 0, cntB = 0, cntC = 0;
  for(int i=0; i<N; i++) {
    int a;
    cin >> a;
    if (a<=A) {
      cntA++;
    }
    else if (a > A && a <= B) {
      cntB++;
    }
    else if (a>B) {
      cntC++;
    }
  }
  int ans = min(cntA, min(cntB, cntC));
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

ll AN(ll A, ll N){
  if (N == 0){
    return 1;
  }else{
    if (N % 2 == 0){
      return AN(A * A % nmax, N / 2) % nmax;
    }else{
      return A * AN(A * A % nmax, N / 2) % nmax;
    }
  }
}



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

  vector <int> A(N + 1), where(N + 1);
  int here1, here2;

  for (int i = 0; i < N + 1; i++){
    cin >> A[i];
    if (where[A[i]] == 0){
      where[A[i]] = i + 1;
    }else{
      here1 = where[A[i]];
      here2 = i + 1;
    }
  }

  int L = (N + 1 - here2) + here1;

  vector <ll> ans(N + 1);

  vector <ll> DP1(N + 1);
  DP1[0] = N + 1;
  for (ll i = 1; i < N + 1; i++){
    DP1[i] = DP1[i - 1] * (N + 1 - i);
    DP1[i] %= nmax;
    DP1[i] = DP1[i] * AN(i + 1, nmax - 2);
    DP1[i] %= nmax;
  }

  vector <ll> DP2(L);
  DP2[0] = 1;
  for (ll i = 1; i < L; i++){
    DP2[i] = DP2[i - 1] * (L - i);
    DP2[i] %= nmax;
    DP2[i] = DP2[i] * AN(i, nmax - 2);
    DP2[i] %= nmax;
  }
  
  for (int i = 0; i < N + 1; i++){
    if (i < L){
      ans[i] = DP1[i] - DP2[i] + nmax;
      ans[i] %= nmax;
    }else{
      ans[i] = DP1[i];
    }
    cout << ans[i] << endl;
  }
  


  return 0;
}


Measured memory_bytes: 4352
# ABC 155 C
from collections import Counter
import numpy as np
N = int(input())
S = [str(input()) for i in range(N)]
S = np.array(S)

count = Counter(S)
max_num = max(count.values())
max_list = [i for i,j in count.items() if j==max_num]

max_list.sort()
print('\n'.join(max_list))

Measured memory_bytes: 60120
#include<cstdio>
int main(){
	int n;
	scanf("%d",&n);
	int a[n+1]={};
	int l=0;
	int m=n;
	printf("0\n");
	fflush(stdout);
	char s[7]={};
	scanf("%s",s);
	if(s[0]=='M'){
		a[0]=1;
		a[n]=1;
	}else{
		a[0]=2;
		a[n]=2;
	}
	int x;
	while(s[0]!='V'){
		x=(m+l)/2;
		printf("%d\n",x);
		fflush(stdout);
		scanf("%s",s);
		if(s[0]=='M'){
			a[x]=1;
		}else{
			a[x]=2;
		}
		if((x-l+a[l]-a[x])%2==1)m=x;
		else l=x;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>

int main(void){
	int a,b,r;
	char c;
	c='1';
	while(c!='?'){
		scanf("%d %c %d",&a,&c,&b);
		switch(c){
			case '+':r = a+b;break;
			case '-':r = a-b;break;
			case '*':r = a*b;break;
			case '/':r = a/b;break;
			case '?':break;
		}
		if(c != '?')printf("%d\n",r);
	}
	return 0;
}

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

//const int MAX_N = 100;

int main(){
	int x,ans=1,num;
	cin>>x;

	for (int i = 2; i <= x; i++){
		num=i*i;
		while(num<=x){
			ans=max(ans, num);
			num*=i;
		}
	}
	cout<<ans<<endl;
}


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

using namespace std;

int get(int n){
	int ret=1;
	while(1){
		if(n/10 !=0){
			ret++;
			n/=10;
		}
		else return ret;
	}
}
int main(){
	while(1){
		int a,b;
		if( !(cin>>a>>b) )break;

		int sum=a+b;
		cout<<get(sum)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	cout<<a*(a-1)/2+b*(b-1)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 3e18;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

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

    vi a(N);
    rep(i, N) cin >> a[i];

    int ans = inf;

    rep(bit, 1 << N) {
        int cnt = 0;
        int ma = 0;
        int cost = 0;

        rrep(i, N) {
            if (bit >> i & 1) {
                if (ma >= a[N - i - 1]) {
                    cost += ma + 1 - a[N - i - 1];
                    ma += 1;
                }
                cnt += 1;
            }

            ma = max(ma, a[N - i - 1]);
        }

        if (cnt < K) continue;
        //rrep(i, N) cout << (bit >> i & 1) ? 1 : 0;
        //cout<<endl;
        //ma = 0;
        //rrep(i, N) {
        //    if (bit >> i & 1) {
        //        if (ma >= a[N - i - 1]) {
        //            cout << "ma = " << ma << endl;
        //            cout << "cost += " << ma + 1 - a[N - i - 1] << endl;
        //            ma = a[N - i - 1] + 1;
        //        }
        //        cnt += 1;
        //    }
        //    ma = max(ma, a[N - i - 1]);
        //}
        //cout << "cost = " << cost << endl;
        ans = min(ans, cost);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer

object Main extends App {

  import scala.io.StdIn._

  solve
  def solve: Unit = {
    val Array(m, n) = readLine.trim.split(' ').map(_.toInt)
    if (m == 0) return
    val blue = readWhile(m)
    val red = readWhile(n)
    println(new Dinic(m, n, blue.indices.flatMap{i ⇒ red.indices.withFilter(j ⇒ gcd(blue(i), red(j)) != 1).map{j ⇒ (i, j)}}.toArray).calMaxMatching)
    solve
  }
  def readWhile(n: Int): Array[Int] = {
    var count = n
    var result = Nil: List[Array[Int]]
    while (count > 0){
      val line = readLine.trim.split(' ').map(_.toInt)
      count -= line.length
      result ::= line
    }
    result.flatten.toArray
  }

  implicit class Extend[T](value: T){
    def also(func: T ⇒ Unit): T = {func(value); value}
    def let[A](func: T ⇒ A): A = func(value)
  }
  def gcd(a: Int, b: Int): Int = {
    b match {
      case 0 ⇒ a
      case _ ⇒ gcd(b, a % b)
    }
  }
  def maxMatching(s: Int, t: Int, edges: Array[(Int, Int)]): Int = {
    new Dinic(s, t, edges).calMaxMatching
  }
  private class Dinic(s: Int, t: Int, edges: Array[(Int, Int)]) {
    val edge = Array.tabulate(s + t + 2){_ ⇒ ArrayBuffer[(Int, Int, Boolean)]()}
    for (x ← 1 to s){
      edge(x).append((0, edge(0).length, false))
      edge(0).append((x, 0, true))
    }
    for (y ← (s + 1) to s + t){
      edge(y).append((s + t + 1, edge(s + t + 1).length, true))
      edge(s + t + 1).append((y, 0, false))
    }
    edges.foreach{
      case (from, to) ⇒
        edge(from + 1).append((to + s + 1, edge(to + s + 1).length, true))
        edge(to + s + 1).append((from + 1, edge(from + 1).length - 1, false))
    }
    val levels = Array.tabulate(s + t + 2){_ ⇒ -1}
    val dfsLast = Array.tabulate(s + t + 2){_ ⇒ 0}
    def bfs: Unit = {
      dfsLast.indices.foreach(i ⇒ dfsLast(i) = 0)
      levels.indices.foreach(i ⇒ levels(i) = -1)
      levels(0) = 0
      val queue : mutable.Queue[Int]= mutable.Queue()
      queue.enqueue(0)
      while(queue.nonEmpty){
        val top = queue.dequeue()
        for ((to, _, b) ← edge(top) if b && levels(to) == -1) {
          levels(to) = levels(top) + 1
          queue.enqueue(to)
        }
      }
    }
    def dfs(from: Int): Boolean= {
      if (from == s + t + 1) true
      else {
        var makePath = false
        for (i ← dfsLast(from) until edge(from).length if  !makePath && edge(from)(i)._3) {
          dfsLast(from) = i
          val (to, j, _) = edge(from)(i)
          if (levels(to) > levels(from) && dfs(to)) {
            edge(from)(i) = (to, j, false)
            edge(to)(j) = (from, i, true)
            dfsLast(from) += 1
            makePath = true
          }
        }
        makePath
      }
    }
    def calMaxMatching: Int = {
      var count = 0
      var canMatch = true
      while (canMatch){
        canMatch = false
        bfs
        if (levels.last != -1) {
          canMatch = true
          while (dfs(0)) {
            count += 1
          }
        }
      }
      count
    }
  }
}


Measured memory_bytes: 480592
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int field[10][10];
int x,y,size;


int main(void)
{
    for(int i=0; i<10; i++) {
        for(int j=0; j<10; j++) {
            field[i][j] = 0;
        }
    }

    char tmp;
    while(cin>>x>>tmp>>y>>tmp>>size) {
        if(size==1) {
            for(int dx=-1; dx<=1; dx++) {
                int nx = x + dx;
                if(0 <= nx && nx < 10)
                    field[y][nx]++;
            }
            for(int dy=-1; dy<=1; dy++) {
                int ny = y + dy;
                if(0 <= ny && ny < 10)
                    field[ny][x]++;
            }
            field[y][x]--;
        } else if(size == 2) {
            for(int dy=-1; dy<=1; dy++) {
                for(int dx=-1; dx<=1; dx++) {
                    int nx = x + dx, ny = y+dy;
                    if(0 <= nx && nx < 10)
                        if(0 <= ny && ny < 10)
                            field[ny][nx]++;
                }
            }
        } else if(size == 3) {
            for(int dy=-1; dy<=1; dy++) {
                for(int dx=-1; dx<=1; dx++) {
                    int nx = x + dx, ny = y+dy;
                    if(0 <= nx && nx < 10)
                        if(0 <= ny && ny < 10)
                            field[ny][nx]++;
                }
            }
            //field[y][x]--;
            for(int dx=-2; dx<=2; dx+=2) {
                int nx = x + dx;
                if(0 <= nx && nx < 10)
                    field[y][nx]++;
            }
            for(int dy=-2; dy<=2; dy+=2) {
                int ny = y + dy;
                if(0 <= ny && ny < 10)
                    field[ny][x]++;
            }
            field[y][x]--;

        }
    }

    int cnt=0, max=0;
    for(int i=0; i<10; i++) {
        for(int j=0; j<10; j++) {
            if(field[i][j] == 0) cnt++;
            if(max < field[i][j]) max = field[i][j];
        }
    }

    printf("%d\n%d\n", cnt, max);

    return 0;
}

Measured memory_bytes: 1144
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX-1
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };




int main(){
	int n;
	cin >> n;
	ll sum = 0;
	vector<int>a(n);
	rep(i, 0, n) { 
		cin >> a[i];
		sum += a[i];
	}

	sort(all(a));

	ll ans = 0;
	if (n % 2 == 1) {
		ll ans1 = 0;
		ll cnt_mx = 0;
		rep(i, 0, n / 2) {
			cnt_mx += a[n - 1 - i];
		}
		ll cnt_mi = 0;
		rep(i, 0, n / 2 - 1) {
			cnt_mi += a[i];
		}
		ll cnt_mid = sum - cnt_mx - cnt_mi;

		ans1 = 2 * cnt_mx - 2 * cnt_mi - cnt_mid;


		ll ans2 = 0;
		cnt_mx = 0;
		rep(i, 0, n / 2 -1) {
			cnt_mx += a[n - 1 - i];
		}
		cnt_mi = 0;
		rep(i, 0, n / 2) {
			cnt_mi += a[i];
		}
		cnt_mid = sum - cnt_mx - cnt_mi;

		ans2 = 2 * cnt_mx + cnt_mid - 2*cnt_mi;
		ans = max(ans1, ans2);
	}
	else {
		ll cnt_mx = 0;
		rep(i, 0, n / 2 - 1) {
			cnt_mx += a[n - 1 - i];
		}
		ll cnt_mi = 0;
		rep(i, 0, n / 2 - 1) {
			cnt_mi+= a[i];
		}

		ans = 2 * cnt_mx - 2 * cnt_mi + max(a[n/2],a[n/2-1]) - min(a[n / 2], a[n / 2 - 1]);
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
using int64 = long long int;

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

	vector<int64> charIndexes[26];
	for (int64 i = 0; i < s.length(); i++)
	{
		charIndexes[s[i] - 'a'].push_back(i);
	}

	int64 totalIndex = 0;
	for (auto c : t)
	{
		int64 i = c - 'a';

		if (charIndexes[i].size() == 0)
		{
			cout << -1 << endl;
			return 0;
		}

		auto it = lower_bound(begin(charIndexes[i]), end(charIndexes[i]), totalIndex % s.length());
		if (it != end(charIndexes[i]))
		{
			totalIndex += *it - totalIndex % s.length() + 1;
		}
		else
		{
			if (totalIndex % s.length() != 0)
			{
				totalIndex += s.length() - totalIndex % s.length();
			}

			totalIndex += charIndexes[i][0] + 1;
		}
	}

	cout << totalIndex << endl;
}

Measured memory_bytes: 1724
def rotate(S):
	S_list = list(S)
	S_last = S[-1]
	S_list.pop(-1)
	S_list.insert(0,S_last)
	return ''.join(S_list)

S = input()
check = input()
for i in range(len(S)):
	S = rotate(S)
	if S == check:
		print('Yes')
		exit()

print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A, B, X = 0;
  cin >> A >> B;
  
  for(int i=A; i<=B; i++){
    if((i/10000) == (i%10) && ((i/1000)%10) == ((i%100)/10)){
      X++;
    }
   }
  cout << X << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)

int main(){
  int N;
  cin >> N;
  int ans = 0;
  for(int a=1; a<N; a++){
    ans += N/a;
    if(N%a==0) ans--;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int MAX = 1e5+10;
const int MAX1 = 1e5+10;
const int INF = 1e9+10;



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string n;
    cin >> n;
    if(n[0] == n[1] && n[1] == n[2]){
        cout << "Yes\n";
    }
    else if(n[1] == n[3] && n[1] == n[2]){
        cout << "Yes\n";
    }
    else {
        bool tr = 0;
        char x = n[0];
        for(int i = 0;i < 4;i++){
            if(n[i] != x ){
                tr = 1;
            }
        }
        if(tr){
            cout << "No\n";
        }
        else{
            cout << "Yes\n";
        }
    }

}


/*
3 4
1 2
2 3
4 1
2 1
3
1 2
2 3
1 2

*/


Measured memory_bytes: 3592
# 整数 X を十進法で表したときの各桁の数字の和を f(X) としたとき、
# X が f(X) で割り切れる場合、X はハーシャッド数です。
# 整数 N が与えられるので、ハーシャッド数かどうか判定してください。

n = gets

sum = 0
n.length.times do |i|
  sum += n[i].to_i
end

if n.to_i % sum == 0
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
bool cmp(char a[],char b[])
{
    int len=strlen(a);
    int i,j;
    for(j=0;j<len;j++)
    {
        for(i=0;i<len;i++)
        {
           if(a[i]!=b[(i+j)%len])
                break;
        }
        if(i==len)
        {
            return true;
        }
    }
    return false;
}
int main()
{
    char s[100],t[100];
    scanf("%s",s);
    getchar();
    scanf("%s",t);
    if(cmp(s,t)==true)
        printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
const int N = 2e5 + 5;
ll n, arr[N], pre[N], suf[N], mx;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 0;i < n;++i)
    {
        cin >> arr[i];
        mx = __gcd(mx, arr[i]);
    }
    for(int i = 0;i < n;++i)
    {
        pre[i] = arr[i];
        if(i)               pre[i] = __gcd(pre[i], pre[i - 1]);
    }
    for(int i = n - 1;i >= 0;--i)
    {
        suf[i] = arr[i];
        if(i + 1 < n)       suf[i] = __gcd(suf[i], suf[i + 1]);
    }
    for(int i = 0;i < n;++i)
    {
        ll l = 0, r = 0;
        if(i)           l = pre[i - 1];
        if(i + 1 < n)   r = suf[i + 1];
        mx = max(mx, __gcd(l, r));
    }
    cout << mx;
    return 0;
}


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


string s;
bool a = true;


int main() {

	cin >> s;

	rep(i, s.size() - 1) {
		if (s[i] == s[i + 1])a = false;
	}

	if (a)cout << "Good" << endl;
	else cout << "Bad" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a,b,c;
    cin>>a>>b>>c;
    int a1=0,b1=0,c1=0;
    char cur='a';
    while(1)
    {
      if(cur=='a')
      {
        if(a1==a.length())
        {
          cout<<"A"<<endl;
          break;
        }
        else cur=a[a1++];
      }
      else if(cur=='b')
      {
        if(b1==b.length())
        {
          cout<<"B"<<endl;
          break;
        }
        else cur=b[b1++];
      }
      else if(cur=='c')
      {
        if(c1==c.length())
        {
          cout<<"C"<<endl;
          break;
        }
        else cur=c[c1++];
      }
    }
  return 0;
}
   

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

int n, t;
vector<pair<int, int>> ab;
vector<vector<int>> memo;
int solve (int cn, int ct) {
    if (cn == n)
        return 0;
    if (ct <= 0)
        return 0;
    if (memo[cn][ct] != -1)
        return memo[cn][ct];
    return memo[cn][ct] = max(solve(cn + 1, ct), ab[cn].second + solve(cn + 1, ct - ab[cn].first));
}

int main() {
    cin >> n >> t;
    ab.resize(n);
    for (int i = 0; i < n; i++)
        cin >> ab[i].first >> ab[i].second;
    sort(ab.begin(), ab.end());
    memo.resize(n, vector<int>(t + 1, -1));
    cout << solve(0, t) << endl;
} 

Measured memory_bytes: 35712
import java.util.Scanner;

public class Main{
	private static Scanner scan;
	public static void main(String[] args) {
		scan = new Scanner(System.in);
		while(true){
			int m = scan.nextInt();
			int d = scan.nextInt();
			if(m == 0)break;
			int a = 3;
			for(int i = 1;i < m;i++){
				if(i == 2){
					a += 29;
				}else if(i == 4||i == 6||i == 9||i == 11){
					a += 30;
				}else{
					a+= 31;
				}				
			}
			a += d;
			int b = a % 7;
			switch(b){
			case 0:
				System.out.println("Sunday");
				break;
			case 1:
				System.out.println("Monday");
				break;
			case 2:
				System.out.println("Tuesday");
				break;
			case 3:
				System.out.println("Wednesday");
				break;
			case 4:
				System.out.println("Thursday");
				break;
			case 5:
				System.out.println("Friday");
				break;
			case 6:
				System.out.println("Saturday");
				break;
			}
		}
		System.exit(0);
	}

}

Measured memory_bytes: 12000
/**Bismillahir Rahmanir Rahim**/


#include<bits/stdc++.h>
using namespace std;
#define ll long long

#define pb push_back
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define clr(v) v.clear()
vector<ll>v;
pair<ll,ll>p;
map<ll,ll>mp;
set<ll>st;
deque<ll>dq;
priority_queue<ll>pq;
#define f(i,b) for(i=0;i<b;i++)
#define f1(i,b) for(i=1;i<=b;i++)
#define fr(i,b)for(i=b-1;i>=0;i--)
ll mn=INT_MAX,mx=INT_MIN;
ll n,m,tc,i,j,tmp,sum,cn,ans,res,pos,flag,l,x,k,dif;

string s,str;


ll a[200007],b[200007];
int main()
{

   io;
ll a,b,c,d;
cin>>a;
cout<<a/3;
return 0;
}





Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<double,double> pint;
typedef pair<pint,int> p3;
typedef long long ll;
const int inf   = 1<<29;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
	string s;
	cin>>s;
	int ans=0;
	int n=s.size();
       if(n==1){cout<<s<<endl;return 0;}
      rep(i,n)ans+=s[i]-'0';
	rep(i,n)if(s[i]!='0'){
		int res=0;
		rep(j,i+1){
			res+=s[j]-'0';
		}
		rep(j,n-i-1){
			res+=9;
		}
		ans=max(ans,res-1);
	}
	cout<<ans<<endl;
	return 0;

}


Measured memory_bytes: 256
import collections
n = int(input())
d = [int(i) for i in input().split()]
ans = 0
if d[0] == 0:
    s = collections.Counter(d)
    ss = sorted(s.items())
    if ss[0][1] == 1:
        ans = 1
        for i in range(1,len(ss)):
            if ss[i][0] != ss[i-1][0] + 1:
                ans = 0
                break
            ans *= ss[i-1][1]**ss[i][1]
print(ans%998244353)

Measured memory_bytes: 21468
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i,a,b) for(int i=int(a),nn=int(b);i<=nn; ++i)
#define vep(i,a,b) for(int i=int(a),nn=int(b);i>=nn; --i)
#define xep(i,b) for(int i=0,nn=int(b);i<nn; ++i)

#define pb push_back
#define sz(x) (int)(x.size())

const int N = 100100;

vector<int> v[N];
int n;

inline void in(int &x) {
	char c = getchar(); int f=1;
	for (; c<'0'||c>'9'; c=getchar()) f=(c=='-'?-1:f);
	for (x=0; c>='0'&&c<='9'; c=getchar()) x=x*10+c-48;
	x *= f;
}

int as = 1;
bool vs[N];

void dfs(int x, int fa = 0) {
	int y;
	xep(i, sz(v[x]))
		if (y=v[x][i], y!=fa)
			dfs(y, x);
	if (!vs[x]) {
		if (!fa || vs[fa]) as = 0;
		else vs[x] = vs[fa] = 1;
	}
}

int main() {
	in(n);
	int x, y;
	rep(i, 1, n-1) {
		in(x), in(y);
		v[x].pb(y), v[y].pb(x);
	}

	dfs(1);
	puts((as ? "Second" : "First"));

	return 0;
}


Measured memory_bytes: 5888
// 5/22
// 過去問ガリガリ
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    int N;
    string S;
    cin >> N >> S;

    int ans = 0;

    for (int i = 0; i < N - 2; i++) {
        if (S.substr(i, 3) == "ABC") ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<numeric>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<utility>
#include<sstream>
#include<complex>
#include<fstream>
#include<bitset>
#include <iostream>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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

int main() {
	string s;
	while (getline(cin, s)) {
		if (s.size() == 1 && s[0] == '.') {
			break;
		}
		int a, b;
		a = b = 0;
		bool h = true;
		stack<int> stk;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == '(') {
				a++;
				stk.push(1);
			}
			else if (s[i] == ')') {
				a--;
				if (!stk.empty()) {
					int r = stk.top();
					stk.pop();
					if (r == 2) {
						h = false;
					}
				}
			}
			else if (s[i] == '[') {
				b++;
				stk.push(2);
			}
			else if (s[i] == ']') {
				b--;
				if (!stk.empty()) {
					int r = stk.top();
					stk.pop();
					if (r == 1) {
						h = false;
					}
				}
			}
			if (a < 0 || b < 0) {
				h = false;
			}
		}
		if (a != 0 || b != 0) {
			h = false;
		}
		if (h) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}
}

Measured memory_bytes: 3108
using System;
namespace _1_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int S;
            S = int.Parse(Console.ReadLine());
            Console.WriteLine("{0}:{1}:{2}",S/3600,S%3600/60, S % 3600 %60);
            Console.ReadLine();

        }
    }
}




Measured memory_bytes: 9240
#include <iostream>

int main() {
  int r, g, b;
  std::cin >> r >> g >> b;
  int sum = g * 10 + b;
  if (sum % 4 == 0) std::cout << "YES" << std::endl;
  else std::cout << "NO" << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if (u == s) --a;
    else --b;
    cout << a << " " << b << endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


ll ans = 1e18;
void solve(int n, vector<int> a, int key) {
    ll sum = 0;
    ll cnt = 0;
    rep(i, n) {
        if ((key == 0 && i % 2 == 0) || (key == 1 && i % 2 != 0)) { // 正に
            sum += a[i];
            if (sum == 0) { cnt++; sum = 1; }
            else if (sum < 0) {
                cnt += -sum + 1;
                sum = 1;
            }
            
        } else {
            sum += a[i];
            if (sum == 0) { cnt++; sum = -1; }
            else if (sum > 0) {
                cnt += sum + 1;
                sum = -1;
            }
        }
    }
    chmin(ans, cnt);
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &ai : a) cin >> ai;
    solve(n, a, 0);
    solve(n, a, 1);
    cout << ans << endl;
}



Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  vector<vector<P>> HH(H, vector<P>(0)), WW(W, vector<P>(0));
  for(int i = 0; i < H; i++){
    cin >> S.at(i);
    for(int j = 0; j < W; j++){
      if(S.at(i).at(j) == '#') continue;
      else{
        int counter = 0;
        int start = j;
        for(int k = j; k < W; k++){
          if(S.at(i).at(k) == '.'){
            counter++;
            if(k == W-1){
              j = W-1;
              break;
            }
          }
          else{
            j = k-1;
            break;
          }
        }
        HH.at(i).push_back(P(start, counter));
      }
    }
  }

  for(int j = 0; j < W; j++){
    for(int i = 0; i < H; i++){
      if(S.at(i).at(j) == '#') continue;
      else{
        int counter = 0;
        int start = i;
        for(int k = i; k < H; k++){
          if(S.at(k).at(j) == '.'){
            counter++;
            if(k == H-1){
              i = H-1;
              break;
            }
          }
          else{
            i = k-1;
            break;
          }
        }
        WW.at(j).push_back(P(start, counter));
      }
    }
  }

  if(H == 1){
    int ans = 0;
    for(int i = 0; i < HH.at(0).size(); i++){
      chmax(ans, HH.at(0).at(i).second);
    }
    cout << ans << endl;
    return 0;
  }
  if(W == 1){
    int ans = 0;
    for(int i = 0; i < WW.at(0).size(); i++){
      chmax(ans, WW.at(0).at(i).second);
    }
    cout << ans << endl;
    return 0;
  }

  int ans = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < HH.at(i).size(); j++){
      int p = HH.at(i).at(j).first;
      int q = HH.at(i).at(j).first + HH.at(i).at(j).second - 1;
      for(int k = p; k <= q; k++){
        for(int l = 0; l < WW.at(k).size(); l++){
          int r = WW.at(k).at(l).first;
          int s = WW.at(k).at(l).first + WW.at(k).at(l).second - 1;
          if(r <= i && i <= s){
            chmax(ans, HH.at(i).at(j).second + WW.at(k).at(l).second - 1);
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 20480
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll a[100010];
int main(){
    int n;
    while(cin>>n){
        ll ans=0;
        for(int i=0; i<n; ++i){
            scanf("%lld",a+i);
            for(int j=0; j<i; ++j){
                ans+=a[i]*a[j];
            }
        }
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

char a='a',b='a',c='a';
string s;
set<string> S;

int main(){
	while(1){
		printf("?%c%c%ca\n",a,b,c);//fflush(stdout);
		string t="";
		t+=a,t+=b,t+=c,t+='a';
		S.insert(t);
		cin>>s;
		if(s[0]!='a'||S.count(s)){
			printf("!OUT\n");//fflush(stdout);
			return 0;
		}
		S.insert(s);
		a=s[s.sz-1];
		c++;
		if(c=='{')b++,c='a';
	}
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://arc092.contest.atcoder.jp/tasks/arc092_b>
問題文============================================================
 2 つの長さ N の非負整数列 a1,…,aN,b1,…,bN が与えられます。
 
 1≤i,j≤N となるように整数 i,j を選ぶ方法は N2 通りありますが，
 この N^2 通りの i,j それぞれについて，ai+bj を計算し，紙に書き出します。
 つまり，紙に N^2 個の整数を書きます。
 
 この N^2 個の整数のxorを計算してください。
=================================================================

解説=============================================================

 解説を見た
 
 各桁について順番に1が ai + bj のうち aiを固定した時にいくつあるかを確認すれば良い
 
 k-bit目を見る時,T = 2^k とすれば
 [0,T) => 0
 [T,2T) => 1
 [2T,3T) => 0
 [3T,4T) => 1
 と2T周期になるので
 ai %= 2T , bj %= 2T として
 
 T <= ai + bj < 2T / 3T <= ai + bj < 4T
 となるものの個数が 1となるものの個数である
 これは ai,bj をソートしておけば aiを固定してにぶたんで求めることができる
 
================================================================
*/
ll solve(){
    ll res = 0;
    ll N; cin >> N;
    vector<ll> a(N),b(N),A(N),B(N);
    for(auto &in:a) cin >> in; for(auto &in:b) cin >> in;
    for(int k = 28; k >= 0; k--){
        ll T = (1<<k);
        for(int i = 0; i < N;i++){ A[i] = a[i]%(2*T); B[i] = b[i]%(2*T); }
        sort(A.begin(),A.end()); sort(B.begin(),B.end());
        ll cnt = 0,cnt2 = 0; // cnt : 0 cnt2 : 1
        for(int i = 0; i < N;i++){
            
            // [0,T) : 0
            if(A[i] < T) cnt += (lower_bound(B.begin(), B.end(),T-A[i]) - B.begin());
            
            // [2T,3T) : 0
            cnt += (lower_bound(B.begin(),B.end(),3*T-A[i]) - lower_bound(B.begin(),B.end(),2*T-A[i]));
        }
        cnt2 = N*N - cnt;
        cnt2 %= 2;
        res += (cnt2)*T;
    }
    return res;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


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

namespace AtTest.ABC_122
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            string s = Read();
            int max = 0;
            for(int i = 0; i < s.Length; i++)
            {
                int len = 0;
                for(int j = i; j < s.Length; j++)
                {
                    if (s[j] == 'A' || s[j] == 'C'
                        || s[j] == 'G' || s[j] == 'T')
                    {
                        len++;
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }
                max = Max(max, len);
            }
            WriteLine(max);
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int N, X[200005], Y[200005];
char P[200005];

int main() {
    cin >> N;
    for_(i,0,N) cin >> X[i] >> Y[i] >> P[i];

    int ans = 1L << 30;
    {
        vector<vector<int>> U(200005), D(200005);
        vector<vector<int>> L(200005), R(200005);
        for_(i,0,N) {
            if (P[i] == 'U') U[X[i]].push_back(Y[i]);
            if (P[i] == 'D') D[X[i]].push_back(Y[i]);
            if (P[i] == 'L') L[Y[i]].push_back(X[i]);
            if (P[i] == 'R') R[Y[i]].push_back(X[i]);
        }

        for_(v,0,200005) {
            sort(ALL(U[v]));
            sort(ALL(D[v]));
            sort(ALL(L[v]));
            sort(ALL(R[v]));
        }

        for_(v,0,200005) {
            int x = v;
            for (int y : U[x]) {
                auto it = upper_bound(ALL(D[x]), y);
                if (it != D[x].end()) ans = min(ans, *it - y);
            }
            int y = v;
            for (int x : R[y]) {
                auto it = upper_bound(ALL(L[y]), x);
                if (it != L[y].end()) ans = min(ans, *it - x);
            }
        }
    }

    // rotate
    {
        for_(i,0,N) {
            int x = X[i] - Y[i];
            int y = X[i] + Y[i];
            X[i] = x + 200000;
            Y[i] = y;
        }

        vector<vector<int>> Ux(400005), Uy(400005), Dx(400005), Dy(400005);
        vector<vector<int>> Lx(400005), Ly(400005), Rx(400005), Ry(400005);
        for_(i,0,N) {
            if (P[i] == 'U') Ux[X[i]].push_back(Y[i]), Uy[Y[i]].push_back(X[i]);
            if (P[i] == 'D') Dx[X[i]].push_back(Y[i]), Dy[Y[i]].push_back(X[i]);
            if (P[i] == 'L') Ly[Y[i]].push_back(X[i]), Lx[X[i]].push_back(Y[i]);
            if (P[i] == 'R') Ry[Y[i]].push_back(X[i]), Rx[X[i]].push_back(Y[i]);
        }

        for_(v,0,400005) {
            sort(ALL(Ux[v]));
            sort(ALL(Dx[v]));
            sort(ALL(Lx[v]));
            sort(ALL(Rx[v]));
            sort(ALL(Uy[v]));
            sort(ALL(Dy[v]));
            sort(ALL(Ly[v]));
            sort(ALL(Ry[v]));
        }

        for_(v,0,400005) {
            int x = v;
            for (int y : Ux[x]) {
                auto it = upper_bound(ALL(Lx[x]), y);
                if (it != Lx[x].end()) ans = min(ans, *it - y);
            }
            for (int y : Rx[x]) {
                auto it = upper_bound(ALL(Dx[x]), y);
                if (it != Dx[x].end()) ans = min(ans, *it - y);
            }

            int y = v;
            for (int x : Ry[y]) {
                auto it = upper_bound(ALL(Uy[y]), x);
                if (it != Uy[y].end()) ans = min(ans, *it - x);
            }
            for (int x : Dy[y]) {
                auto it = upper_bound(ALL(Ly[y]), x);
                if (it != Ly[y].end()) ans = min(ans, *it - x);
            }
        }
    }
    
    if (ans == 1L << 30) puts("SAFE");
    else cout << ans * 5 << endl;
}


Measured memory_bytes: 92400
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

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

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

    ll ans_1 = 1, ans_2 = 0;
    // K: Nの約数じゃない
    map<ll, ll> factors1 = prime_factor(N-1);
    for(auto p = factors1.begin(); p != factors1.end(); ++p) {
        ans_1 *= (p->second + 1);
    }
    ans_1 -= 1;
    // cerr << "ans1 = " << ans_1 << endl;

    // K: Nの約数
    vector<ll> divs = divisor(N);
    for(ll d: divs) {
        if(d == 1) continue;
        ll n = N;
        while(n%d == 0) n = n / d;
        if((n-1)%d == 0) ans_2++;
    }

    cout << ans_1 + ans_2 << endl;
    return 0;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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 rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int N; cin >> N;
  vector<l_l> x(N);
  rep(i,N){
    int a,b;
    cin >> a >> b;
    x[i].first=a+b;
    x[i].second=a-b;
  }
  sort(all(x));
  ll right=x[0].first;
  ll ans=1;
  rep(i,N){
    if(x[i].second>=right){
      ans++;
      right=x[i].first;
    }
  }
  cout << ans << endl;
}

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

int main() {
    string X;
    cin >> X;
    for(int i = 1;i < X.size();i++) {
        if(X[i-1] == 'S' && X[i] == 'T') {
            X.erase(i-1,2);
            i -= 2;
        }
    }
    cout << X.size() << endl;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    W=[input() for _ in range(n)]
    for i in range(n):
        w=W.pop()
        if w in W:
            print("No")
            return
        if W:
            if not w[0]==W[-1][-1]:
                print("No")
                return
    print("Yes")
resolve()

Measured memory_bytes: 38256
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<iomanip>
#include<bitset>
using ll=long long;
using P =pair<int,int>;



int main(){
  ll n,m;
  cin >> n >> m;
  vector<int>a(n);
  rep(i,n)cin >> a[i];
  sort(a.begin(),a.end());
  vector<ll>s(n+1);
  rep(i,n)s[i+1]=s[i]+a[i];

  auto calc =[&](int x){
    ll tot=0,num=0;
    rep(i,n){
      int j=lower_bound(a.begin(),a.end(),x-a[i])-a.begin();
      num+=n-j;
      tot+=s[n]-s[j];
      tot+=a[i]*ll(n-j);
    }
    return make_pair(tot,num);
  };

  int l=0,r=200005;
  while(l+1<r){
    int c=(l+r)>>1;
    if(calc(c).second>=m)l=c;else r=c;
  }
  auto p=calc(l);
  ll ans=p.first;
  ans-=(p.second-m)*l;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
use std::collections::HashMap;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut dic = HashMap::with_capacity(3*n);

    for &ai in a.iter() {
        for aa in ai-1 .. ai+2 {
            let mut entry = dic.entry(aa).or_insert(0);
            *entry += 1;
        }
    }

    let max = dic.values().into_iter().max().unwrap();
    println!("{}", max);
}


Measured memory_bytes: 16636
// Vivek Rai
// Blazer_007

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/detail/standard_policies.hpp>

#define fastio      ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp       make_pair
#define inf         0x3f3f3f3f
//#define INF         0x3f3f3f3f3f3f3f3fLL
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define ppi     pair<ll,pii>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define see(x)      cout<<x<<endl;
#define see2(x,y)   cout<<x<<" "<<y<<endl;
#define see3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define bit(x, y)   (((x)>>(y))&1)
#define bpt(x)      (__builtin_popcount(x))
#define bptl(x)     (__builtin_popcountll(x))
#define loop(i,a,b)  for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define N 2000010

using namespace std;
//using namespace __gnu_pbds;

//typedef priority_queue<int> maxHeap;
// typedef priority_queue<int,vector<int>,greater<int> > minHeap;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// find_by_order(index) -> value at given index or Kth smallest element in set
// order_of_key(X) -> number of elements strictly less than X
//typedef tree<pii , null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

ll dp[3001][3001];
ll sum[3001][3001];

ll solve(vi& v,int i,int j){
    if( i==j )
        return 0;
    if(dp[i][j] != -1)
        return dp[i][j];
    ll minCost = LLONG_MAX;
    loop(k,i,j){
        minCost = min(minCost,sum[i][j] + solve(v,i,k) + solve(v,k+1,j)) ;
    }
    return dp[i][j] = minCost ;
}

void solution(){
    int n;
    cin >> n ;
    vi slimes(n+1);
    memset(dp,-1,sizeof dp);
    loop(i,1,n+1) cin >> slimes[i] ;
    loop(i,1,n+1){
        loop(j,i,n+1){
            sum[i][j] = slimes[j] + ((j == i) ? 0 : sum[i][j-1]) ;
        }
    }
    cout << solve(slimes,1,n) << endl;
}

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

    ll t=1;
    // cin>>t;
    loop(i,1,t+1){
        //cout<<"Case #"<<i<<": ";
        solution();
    }
}




Measured memory_bytes: 80256