akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
bool dp[100005];
string S;
string can[4]={"dream","dreamer","erase","eraser"};
int main(){
	ios::sync_with_stdio(false);
	cin>>S;
	dp[0]=true;
	rep(k,S.length()){
		dp[k+1]=false;
		rep(i,4){
			if(k<int(can[i].size()-1))continue;
			if(dp[k-can[i].size()+1]&&S.substr(k-can[i].size()+1,can[i].size())==can[i]){
				dp[k+1]=true;
				break;
			}
		}
	}
	if(dp[S.length()])cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 592
#include <stdio.h>


int main(void){
	int lineMax = 0;
	int argnum = 0;
	int line = 0;
	int x = 0;
	int y = 0;
	int z = 0;
	char c;
	while(1){
		c = getchar();
		if(c =='\n'){break;}
		lineMax = lineMax*10 + (c - '0');
	}
	while(1){
		c = getchar();
		if(lineMax <= line){break;}
		if(c == ' '){
			argnum++;
		}else if(c == '\n'){
			printf("%s\n",x*x == y*y + z*z || y*y == z*z + x*x || z*z == x*x + y*y ? "YES":"NO");
			argnum = 0;
			x = 0;
			y = 0;
			z = 0;
			line++;
		}else if(argnum == 0){
			x = x * 10 + (c - '0');
		}else if(argnum == 1){
			y = y * 10 + (c - '0');
		}else if(argnum == 2){
			z = z * 10 + (c - '0');
		}
	}
	return 0;
}

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

int main(){
    string S;
    int n, i;
    cin >> S;
    n = S.size();
    for(i = 0; i < n; i++){
        if(i % 2 == 0 && S[i] == 'L' || i % 2 == 1 && S[i] == 'R')break;
    }
    if(i == n)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = Long.parseLong(sc.next());
		long a = Long.parseLong(sc.next());
		long b = Long.parseLong(sc.next());
		System.out.println((long) Math.floor(n / (a + b)) * a + Math.min(n % (a + b), a));
	}
}

Measured memory_bytes: 23252
s = input()

s = s[::-1]
if len(s) % 2 ==1:
    s = s[1:]
else:
    s = s[2:]

while len(s) >= 2:
    half = len(s) // 2
    if s[:half] == s[half:]:
        print(len(s))
        break
    s = s[2:]

Measured memory_bytes: 8988
#include <bits/stdc++.h>
using namespace std;
int main(){
	int k;cin>>k;
	queue <long long> q;
	for(int i=1;i<=9;i++)q.push(i);
	while(!q.empty()){
		long long x=q.front();
		q.pop();
		k--;
		if(k==0){
			cout<<x;
			return 0;
		}
		for(int j=x%10-1;j<=x%10+1;j++){
			if(j>9 || j<0)continue;
			else q.push(x*10+j);
		}
	}
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
    int n, m, a[50], b[50], i, j, count;
    scanf("%d%d", &n, &m);
    for (i=1; i<=m; i++)
    {
        scanf("%d %d", &a[i], &b[i]);
    }
    for (i=1; i<=n; i++)
    {
        count = 0;
        for (j=1; j<=m; j++)
        {
            if (a[j] == i) {
                count ++;
            }
            if (b[j] == i) {
                count ++;
            }
        }
        printf("%d\n", count);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

void DFS(int V,int Depth,vector<vector<int> > & GRAPH,vector<int>& path)
{
  path[V] = Depth;
  for (int i = 0; i < GRAPH[V].size(); i++)
  {
    int P_N = GRAPH[V][i];
    DEBUG("call");
    if(path[P_N] == -1)
    {
      DFS(P_N,Depth+1,GRAPH,path);
    }
  }
  
}
 
void solve(void)
{

  int N;
  cin>>N;
  // DEBUG(N);
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);

  for (int i = 0; i < N; i++)
  {
    cin>>A[i];
  }
  
    for (int i = 0; i < N; i++)
  {
    cin>>B[i];
  }

    for (int i = 0; i < N; i++)
  {
    cin>>C[i];
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());

  int ANS = 0;
  vector<int> AB(N,0);
  vector<int>BC(N,0);

  for (int i = 0; i < N; i++)
  {

    int Q = B[i];
    auto itr_A =lower_bound(A.begin(),A.end(),Q);
    auto itr_C = upper_bound(C.begin(),C.end(),Q);
    ANS += (int)(itr_A - A.begin())*(int)(C.end() - itr_C);
  } 
  cout<<ANS<<endl;
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

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

const int maxn = 1e5, mod = 1e9 + 7;
int n, a[maxn + 3], pos[maxn + 3][3], dp[maxn + 3], lst[maxn + 3];
char s[maxn + 3];

void upd(int &x, int y) {
	x += y, x < mod ? 0 : x -= mod;
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	bool flag = true;
	for (int i = 1; i < n; i++) {
		flag &= s[i] != s[i + 1];
	}
	if (flag) {
		puts("1");
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		a[i] = s[i] == 'a' ? 1 : 2;
		a[i] = (a[i] + a[i - 1]) % 3;
	}
	for (int i = n; i; i--) {
		lst[a[i]] = i;
		for (int j = 1; j <= 2; j++) {
			pos[i][j] = lst[(a[i - 1] + j) % 3];
		}
	}
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= 2; j++) {
			if (pos[i + 1][j]) {
				upd(dp[pos[i + 1][j]], dp[i]);
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if ((a[n] - a[i] + 3) % 3 == 0) {
			upd(ans, dp[i]);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2304
from collections import defaultdict

N, M = map(int, input().split())
A = list(map(int, input().split()))

d = defaultdict(int)
for i in range(N):
    d[A[i]] += 1
for i in range(M):
    b, c = map(int, input().split())
    d[c] += b
    

key = sorted(list(d.keys()))

num = N
i = 0
S = 0
while num > 0:
    i -= 1
    n = d[key[i]]
    num -= n
    S += key[i] * n
    
S += key[i] * num

print(S)

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];

	rep(i, n) a[i]--;
	vi cnt(n, 0);
	rep(i, n) cnt[a[i]]++;
	ll total = 0;
	rep(i, n)
		total += choose2((ll)cnt[i]);
	rep(i, n)
	{
		ll ans = total;
		ans -= choose2((ll)cnt[a[i]]);
		ans += choose2((ll)cnt[a[i]] - 1);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;


int main(){
    int n,m;
    cin >> n >> m;
    vector<int> tar(m);
    for(int i=0;i<m;i++) cin >> tar[i];
    vector<int> point(n,0);
    for (int i=0; i<m; i++) {
        for(int j=0;j<n;j++){
            int inp;
            cin >> inp;
            if (inp==tar[i]) {
                point[j]++;
            }else{
                point[tar[i]-1]++;
            }
        }
    }
    for(int i=0;i<n;i++) cout << point[i]<<endl;
}

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

int main(){
    int n;
    cin >> n;
    int l[n];
    for(int i=0; i<n; i++){
        cin >> l[i];
    }
    sort(l,l+n);
    long long ans = 0;
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            int a = l[i];
            int b = l[j];
            int k = lower_bound(l,l+n,a+b) - l;
            k--;
            if(k > j) ans += k - j;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

vector<int> sieve(int n){
    vector<bool> is_prime(n+1, true);
    vector<int> p;
    for(int i=2; i<=n; i++){
        if(is_prime[i]) {
            for(int j=2*i; j<=n; j+=i){
                is_prime[j] = false;
            }
            p.emplace_back(i);
        }
    }
    return p;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<int> p = sieve(55555);
    int cnt = 0;
    for(auto a : p){
        if(a % 5 == 1){
            cout<<a<<" ";
            cnt++;
        }
        if(cnt == n) break;
    }
    cout<<endl;
    return 0;
}
// abc096_d

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nd = ReadInts();
            var s = nd[1] * 2 + 1;
            if (nd[0] % s == 0)
            {

                WriteLine(nd[0] / s);
            }
            else
            {

                WriteLine((nd[0] / s) + 1);
            }
        }


        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        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); }

        //最大公約数

        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


Measured memory_bytes: 11220
#include<stdio.h>

int main(){
  int i, j, n, v, count = 0;
  int A[100];

  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&A[i]);

  for(i = 0; i < n; i++){
    for(j = n - 1; j > i; j--){
      if(A[j - 1] > A[j]){
        v = A[j];
        A[j] = A[j - 1];
        A[j - 1] = v;
        count++;
      }
    }
  }

  for(i = 0; i < n; i++){
    printf("%d",A[i]);
    if(i != n - 1) printf(" ");
  }
  printf("\n%d\n",count);

  return 0;
}

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

int main(){
  string S, T;
  cin >> S >> T;
  int ans=0;
  for(int i=0; i<S.size(); i++){
    S.push_back(S.at(0));
    S.erase(S.begin());
    if(S==T) ans++;
  }
  if(ans>0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAX = 100005;
const int MOD = 1000000007;
//
int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(){
    int n;
    cin >>n;
    int a[n+1],b[n]={},k;
    for(int i=0;i<=n;i++){
        cin>>a[i];
        if(b[a[i]-1]==0)  b[a[i]-1]=i+1;
        else k= i+1-b[a[i]-1]+1;
        
    }
   // cerr<<k<<endl;
    COMinit();
    for(int i=1;i<=n+1;i++){
       // cerr<<COM(n+1,i)<<' '<<COM(n+1-k,i-1)<<endl;
        cout << (COM(n+1,i)+(MOD-COM(n+1-k,i-1)))%MOD<<endl;
    }


    return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <cstdint>
#include <set>
#include <deque>
#include <iomanip>
#include <queue>

using namespace std;
using ull = unsigned long long;
using ll = long long;

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

#define EPS (1e-7)
#define ALL(x) begin(x), end(x)

bool canGoal(const string& s, ll start, ll goal) {
	string sub = s.substr(start, goal - start);
	auto it = sub.find("##");
	return it == string::npos;
}

bool canCross(const string& s, ll start, ll goal) {
	string sub = s.substr(start-1, goal - start + 3);
	auto it = sub.find("...");
	return it != string::npos;
}

int main() {
	ll N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	string S;
	cin >> S;

	// index計算のため0-origin
	A--;
	B--;
	C--;
	D--;

	bool ok = false;
	if (C < D) {
		// A C B D
		// A B C D
		// BがDにたどり着ける && AがCにたどり着ける
		ok = canGoal(S, B, D) && canGoal(S, A, C);
	} else {
		// A B D C
		// AがBを追い抜ける場所がある && AがCにたどり着ける &&BがDにたどり着ける(これは追い抜くので自明のような気もするが)
		ok = canCross(S, B, D) && canGoal(S, B, D) && canGoal(S, A, C);
	}
	const string ans = ok ? "Yes" : "No";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 772
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int[] a=new int[N];
        boolean[] check=new boolean[N];
        
        for(int i=0;i<N;i++){
            a[i]=sc.nextInt();
            check[i]=false;
        }
        
        int target=a[0];
        check[0]=true;
        int ans=1;
        
        while(target!=2){
            ans++;
            if(check[target-1]){
                System.out.println(-1);
                return ;
            }
            check[target-1]=true;
            target=a[target-1];
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 51164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int n;
	ll d,x,y;
	cin >> n >> d;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		cin >> x >> y;
		ll dist = x*x + y*y;
		if (dist <= d*d)
			ans++;
	}
	cout << ans;
	return 0;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    int a, b;
    cin >> a >> b;
    
    if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) {
        cout << "Possible";
    } else {
        cout << "Impossible";
    }
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,t=0;
	cin>>n;
	char a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=2;i<=n;){// a a b b b b a a c a i=3
		if(a[i]==a[i-1]){//i=2
			for(int j=i+1;j<=n;j++){//j=9
				if(a[j]!=a[j-1]){
					t++;       //t=3
					i=j+1;	   //i=10
					break;
				}
				if(j==n){
					t++;
					cout<<t;
					return 0;
				}
			}
			
		}
		else {
			i++;
			t+=1;
		}
	}
	cout<<t+1;
	return 0;
}

Measured memory_bytes: 384
import sys
from collections import deque, OrderedDict
sys.setrecursionlimit(10 ** 7)

N = int(input())
edge = [[] for _ in range(N)]
inputs = OrderedDict()

for _ in range(N - 1):
    a, b = map(int, input().split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)
    inputs["-".join(list(map(str, sorted([a - 1, b - 1]))))] = 0

K = 0
for e in edge:
    K = max(K, len(e))
print(K)

def dfs(root, edge, inputs):
    done = [True for _ in range(N)]
    done[root] = False
    d = deque([])
    tmp = 1
    for e in edge[root]:
        if done[e]:
            d.append([e, root, tmp])
            tmp += 1
            done[e] = False
    while d:
        data = d.pop()
        inputs["-".join(list(map(str, sorted(data[:2]))))] = data[2]
        tmp = 1
        for e in edge[data[0]]:
            if done[e]:
                if tmp != data[2]:
                    d.append([e, data[0], tmp])
                else:
                    tmp += 1
                    d.append([e, data[0], tmp])
                tmp += 1
                done[e] = False
    
    return inputs

inputs = dfs(0, edge, inputs)

for i in inputs.values():
    print(i)

Measured memory_bytes: 59948
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s1, s2;
    cin >> s1 >> s2;
    int ans  = 0;
    for (int i = 0; i < s1.size(); i++)
        if (s1[i] == s2[i])
            ans++;
    cout << ans << endl;

    return 0;


}


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

char a[22][22];
int n,m;

struct pos{
	int x;
	int y;
	int step;
};

pos make_pos(int a,int b,int c){
	pos ret;
	
	ret.x=a;
	ret.y=b;
	ret.step=c;
	
	return ret;
}

int bfs(int sx,int sy,int ex,int ey){
	bool vis[n+2][m+2];
	
	for(int i=0;i<=n+1;++i)
		for(int j=0;j<=m+1;++j)
			if(a[i][j]=='#')
				vis[i][j]=true;
			else
				vis[i][j]=false;
	
	queue<pos> q;
	q.push(make_pos(sx,sy,0));
	vis[sx][sy]=true;
	int move[2][4]={{0,0,-1,1},{-1,1,0,0}};
	
	while(!q.empty()){
		pos fr=q.front();
		q.pop();
		if(fr.x==ex&&fr.y==ey)
			return fr.step;
			
		pos newpo;
		for(int i=0;i<4;++i){
			int nx=fr.x+move[0][i];
			int ny=fr.y+move[1][i];
			if(vis[nx][ny])
				continue;
			vis[nx][ny]=true;
			newpo=make_pos(nx,ny,fr.step+1);
			q.push(newpo);
		}
	}
	return 0;
}

int main(){
	for(int i=0;i<22;++i)
		for(int j=0;j<22;++j)
			a[i][j]='#';
	
	cin>>n>>m;
	
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			cin>>a[i][j];
	
	int maxv=0;
	
	for(int i1=1;i1<=n;++i1)
		for(int j1=1;j1<=m;++j1){
			if(a[i1][j1]=='#')
				continue;
			for(int i2=1;i2<=n;++i2)
				for(int j2=1;j2<=m;++j2){
					if(a[i2][j2]=='#')
						continue;
					if(i1==i2&&j1==j2)
						continue;
					
					maxv=max(maxv,bfs(i1,j1,i2,j2));
				}
		}
	
	cout<<maxv<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int t;
    t=1;
    // cin>>t;
    while(t--){
        string s;
        cin>>s;
        if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
        else cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
import heapq

def prim_heap():
    used = [True] * n #True:不使用
    edgelist = []
    for e in edge[0]:
      heapq.heappush(edgelist,e)
    used[0] = False
    res = 0
    while len(edgelist) != 0:
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,e)
        res += minedge[0]
    return res

#########################
n,w = map(int,input().split())

edge = [[] for i in range(n)]
#隣接リスト edge[i]:[コスト,行先]
for i in range(w):
    x,y,z = map(int,input().split())
    #heapqを用いて、なるべく軽い辺から採用するため、zが先
    edge[x].append([z,y])
    edge[y].append([z,x])#無向のとき
print(prim_heap())





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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int min = 9999;
  int tmp;
  
  tmp = abs(b-a) + abs(c-b); if (tmp < min) min = tmp;
  tmp = abs(c-a) + abs(b-c); if (tmp < min) min = tmp;
  tmp = abs(a-b) + abs(c-a); if (tmp < min) min = tmp;
  tmp = abs(c-b) + abs(a-c); if (tmp < min) min = tmp;
  tmp = abs(a-c) + abs(b-a); if (tmp < min) min = tmp;
  tmp = abs(b-c) + abs(a-b); if (tmp < min) min = tmp;
  
  cout << min << endl;
}

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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N;
    cin >> N;
    int res = -1;
    int ans = 1;
    for (int i = 1; i <= N; i++) {
        int t = i;
        int p = 0;
        while(t%2==0&t>0){
            t /= 2;
            p++;
        }
        if(res<p){
            res = p;
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

_, _, m = map(int, input().split())
a = [int(item) for item in input().split()]
b = [int(item) for item in input().split()]
ans = min(a) + min(b)
for _ in range(m):
    x, y, c = map(int, input().split())
    x -= 1; y -= 1
    val = a[x] + b[y] - c
    if val < ans:
        ans = val

print(ans)

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

int main() {
  int N,n;
  cin >> N;
  int X = N;
  for (int i = 0; i <= N; i++) {
    if (N == 10) {
      n += 1;
      break;
    } else if (N % 10 != 0) {
      n += N % 10;
      N /= 10;
      if (N < 10) {
        n += N;
        break;
        }
    } else if (N > 10) {
      N /= 10;
    }
  }
  if (X % n) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int AB, BC, CA;
    io.read(AB, BC, CA);
    priority_queue<int, vector<int>, greater<int>> q;
    q.push(AB);
    q.push(BC);
    q.push(CA);
    int x = q.top(); q.pop();
    int y = q.top(); q.pop();
    cout << (x * y) / 2;
    return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
    int i, j;
    FOR(i, 1, 10){
        FOR(j, 1, 10){
            printf("%dx%d=%d\n", i, j, i*j);
        }
    }
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<ll> v(n);
    for(auto &i:v) cin>>i;
    ll sum = 0;
    for(int i=1;i<n;i++){
        if(v[i]<=v[i-1]){
            sum += v[i-1]-v[i];
            v[i] = v[i-1];
        }
        //cout<<" sum "<<sum<<" v["<<i<<"] "<<v[i]<<endl;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4764
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
# import numpy as np
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())
 
def inp_list(): return list(map(int, sys.stdin.readline().split()))

def lcm(x, y): return (x * y) // gcd(x, y)


N, R = inp_list()
I = 0
if N >= 10:
    I = R
else:
    I = R + 100 * (10 - N)
print(I)


Measured memory_bytes: 5328
N,M = [int(x) for x in input().split()]
#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
par = [-1]*(N+1)
for i in range(M):
    a,b = [int(x) for x in input().split()]
    unite(a,b)
ans = 0
for i in range(1,N):
    ans = max(ans,size(i))
print(ans)

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

using namespace std;

int main()
{
int n,i,max=0,sum=0;
char array[100];
scanf("%d",&n);
scanf("%s",array);
for(i=0;i<n;i++){
    if(array[i]=='I'){
        sum++;
    }
    if(array[i]=='D'){
        sum--;
    }
    if(sum>max){
        max=sum;
    }
}
printf("%d",max);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int
main()
{
        int c_sum[11] = {0}, r_sum = 0, n, i, buf;

        while (scanf("%d", &n), n != 0) {
                for (i = 1; i <= n * n; i++) {
                        scanf("%d", &buf);
                        printf("%5d", buf);
                        r_sum += buf;
                        c_sum[(i - 1) % n] += buf;
                        if (i % n == 0) {
                                printf("%5d\n", r_sum);
                                r_sum = 0;
                        }
                }
                r_sum = 0;
                for (i = 0; i < n; i++) {
                        printf("%5d", c_sum[i]);
                        r_sum += c_sum[i];
                        c_sum[i] = 0;
                }
                printf("%5d\n", r_sum);
                r_sum = 0;
        }

        return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#include <math.h>

int main(void){
    float sum=0,sum2;
    int sum1=0,num,price,count=0;
    while(scanf("%d,%d",&price,&num) != EOF){
        sum+=num;
        sum1+=(price*num);
        count++;
    }
   sum2=roundf(sum/count);
   printf("%d\n%.0f\n",sum1,sum2);
   return 0;
}

Measured memory_bytes: 636
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int[] a = new int[3];
		int Max = 0;
		int res = 0;
		for(int i=0;i<3;i++) {
			int t = nextInt();
			res += t;
			Max = Math.max(t,Max);
		}
		out.println(res-Max);
	}


	private static int nextInt() {
		return Integer.parseInt(next());
	}
	private static long nextLong() {
		return Long.parseLong(next());
	}
	private static String next() {
		return sc.next();
	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int x[4000], y[4000], z[4000];
int mypow(int fa, int fb, int fc) {
	if (fb == 0)return 1;
	if (fb % 2)return mypow(fa, fb - 1, fc)*fa%fc;
	int z = mypow(fa, fb / 2, fc);
	return z * z%fc;
}
int k(int fa) {
	int x = 0;
	while (fa) {
		x++;
		fa /= 10;
	}
	return x;
}
int gcd(int fa, int fb) {
	if (fb == 0)return fa;
	return gcd(fb, fa%fb);
}
signed main() {
	int n, ans = 0;
	string s;
	cin >> n >> s;
	f(i, n) {
		if (s[i] == 'R')x[i]++;
		if (s[i] == 'G')y[i]++;
		if (s[i] == 'B')z[i]++;
		if (i) {
			x[i] += x[i - 1];
			y[i] += y[i - 1];
			z[i] += z[i - 1];
		}
	}
	f(i, n-2) {
		for (int j = i + 1; j < n - 1; j++) {
			if (s[i] == s[j])continue;
			if (s[i] != 'B'&&s[j] != 'B') {
				ans += z[n - 1] - z[j];
				if (j * 2 - i < n&&s[j + j - i] == 'B')ans--;
			}
			if (s[i] != 'R'&&s[j] != 'R') {
				ans += x[n - 1] - x[j];
				if (j * 2 - i < n&&s[j + j - i] == 'R')ans--;
			}
			if (s[i] != 'G'&&s[j] != 'G') {
				ans += y[n - 1] - y[j];
				if (j * 2 - i < n&&s[j + j - i] == 'G')ans--;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3704
#include <stdio.h>

int main(void){
 int b,c,a=1;
 while(a==1){
 scanf("%d %d",&b,&c);
 if(b==0&&c==0){
 goto c;
 }
  if(b>c){
   printf("%d %d\n",c,b);
}else{
   printf("%d %d\n",b,c);
}
}
c:
return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define M 300005 
using namespace std;
int A[M],B[M],C[M];
bool cmp(int a,int b){
	return a>b;
}
int main(){
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	for(int i=0;i<a;i++)scanf("%d",&A[i]);
	for(int i=0;i<b;i++)scanf("%d",&B[i]);
	for(int i=0;i<c;i++)scanf("%d",&C[i]);
	sort(A,A+a,cmp);
	sort(B,B+b,cmp);
	sort(C,C+c,cmp);
	for(int i=x;i<x+y;i++)A[i]=B[i-x]; 
	for(int i=x+y;i<x+y+c;i++)A[i]=C[i-x-y];
	sort(A,A+x+y+c,cmp); 
	long long ans=0;
	for(int i=0;i<x+y;i++)ans+=A[i]; 
	cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 2176
n,m=map(int,input().split())
 
a=["0"]*n
 
for i in range(m):
    s,c=map(int,input().split())
    if a[s-1]=="0":
        a[s-1]=c
    elif a[s-1]!=c:
        print(-1)
        exit()

if n>1 and a[0]==0:
    print(-1)
    exit()

if n>1 and a[0]=="0":
    a[0]=1

print(*a,sep="")

Measured memory_bytes: 3064
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        n: usize,
        ts: [u64; n],
    }
    let mut ts = ts;
    ts.sort();
    ts.dedup();
    let mut sum = 1;
    for i in ts.into_iter() {
        sum *= i / gcd(sum, i);
    }
    println!("{}", sum);
}

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 60;

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	vector<int> bits(MB);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < MB; j++) {
			if ((a[i] >> j) & 1) bits[j]++;
		}
	}

	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < MB; j++) {
			if ((a[i] >> j) & 1) bits[j]--;
		}
		for (int j = 0; j < MB; j++) {
			int x = (1LL << j) % MOD;
			if ((a[i] >> j) & 1) ans += x * (n - i - 1 - bits[j]) % MOD;
			else ans += x * bits[j] % MOD;
			ans %= MOD;
		}
	}
	cout << ans % MOD;
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}


Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
    int i, j;

    for (i = 1; i <= 9; i++) {
        for (j = 1; j <= 9; j++) {
            printf("%dx%d=%d\n", i, j, i * j);
        }
    }

    return 0;
}

Measured memory_bytes: 3100
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Anirudh Rayabharam (mail@anirudhrb.com)
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        i18n solver = new i18n();
        solver.solve(1, in, out);
        out.close();
    }

    static class i18n {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            int mid = s.length() - 2;
            out.printf("%c%d%c\n", s.charAt(0), mid, s.charAt(mid + 1));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
signed main(signed argc, char* argv[]) {
    int n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0){
        cout<<(b-a)/2<<endl;
    }
    else{
        int aa=a,bb=n-b+1;
        cout<<min(a+(b-a)/2,(n-b+1)+(b-a)/2)<<endl;
    }
}

Measured memory_bytes: 256
n=int(input())

if 400<=n and n<=599:
  print(8)
elif 600<=n and n<=799:
  print(7)
elif 800<=n and n<=999:
  print(6)
elif 1000<=n and n<=1199:
  print(5)
elif 1200<=n and n<=1399:
  print(4)
elif 1400<=n and n<=1599:
  print(3)
elif 1600<=n and n<=1799:
  print(2)
elif 1800<=n and n<=1999:
  print(1)
  

Measured memory_bytes: 9188
import math
def divisor(n):
    res = []
    for i in range(1,int(math.sqrt(n))+2):
        if n % i == 0:
            res.append(i)
            if n // i != i:
                res.append(n // i)
    return res
    
N, M = map(int, input().split())
maxd = 0
for d in divisor(M):
    if M // d >= N:
        maxd = max(maxd, d)
print(maxd)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const char nl = '\n';

// INT VS LL

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

    string s,t;
    cin>>s>>t;
    cout<<(string)t+s<<nl;

    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n,m; cin >> n >> m;
  if(n==m) cout << "Yes";
  else cout << "No";

  

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    string S;
    cin >> S;
    S += 'D';
    int N = sz(S);
    int j = 0; ll cnt = 0, sum = 0;
    ll ans = 0;
    for(int i = 0; i < N;){
        if(S[i] == 'A') i++, j++;
        elif(i+1 < N && S[i] == 'B' && S[i+1] == 'C'){
            sum += j, i += 2, j++, cnt++;
        }
        else{
            ans += sum - cnt*(cnt-1)/2;
            j = cnt = sum = 0;
            i++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 644
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

	int K, T;
	cin >> K >> T;
	typedef array<int, 2> arr;
	priority_queue<arr>a;
	rep(i, T) {
		int n;
		cin >> n;
		a.push({ n, i });
	}

	int ans = 0, num = -1;

	while (!a.empty()) {
		arr No1 = a.top(); a.pop();
		if (a.empty()) {
			if (No1[1] == num) {
				ans += No1[0];
				break;
			}
			else {
				ans += No1[0] - 1;
				break;
			}
		}
		if (num != No1[1]) {
			No1[0]--;
			num = No1[1];
			if(0 < No1[0])a.push(No1);
			continue;
		}

		arr No2 = a.top(); a.pop();

		No2[0]--;
		num = No2[1];
		if (0 < No1[0])a.push(No1);
		if (0 < No2[0])a.push(No2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,w,k;
    cin >> h >> w >> k;
    string grid[h];
    int black = 0;
    for(int i = 0; i < h;i++){
        cin >> grid[i];
        for(int j = 0; j < w;j++){
            if(grid[i][j] == '#')
                black++;
        }
    }
    int ans = 0;
    for(int i = 0; i < (int)pow(2,h);i++){
        for(int j = 0;j < (int)pow(2,w);j++){
            int count = 0;
            vector<int> row,col;
            int temp = i;
            for(int r = 0;r < h;r++){
                if(temp&1){
                    row.push_back(r);
                }
                temp >>= 1;
            }
            temp = j;
            for(int c = 0; c < w;c++){
                if(temp&1){
                    col.push_back(c);
                }
                temp >>= 1;
            }
            for(int r = 0;r < row.size();r++){
                for(int c = 0;c < w;c++){
                    if(grid[row[r]][c] == '#')
                        count++;
                }
            }
            for(int c = 0;c < col.size();c++){
                for(int r = 0;r < h;r++){
                    if(grid[r][col[c]] == '#')
                        count++;
                }
            }
            for(int r = 0; r < (int)row.size();r++){
                for(int c = 0; c < (int)col.size();c++){
                    if(grid[row[r]][col[c]] == '#')
                        count--;
                }
            }
            if(black - count == k)
                ans++;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3968
//Volume5-0511
import java.util.Arrays;
import java.util.Scanner;

class Main {

	public static void main(String[] args){

		final int   N       = 31;
		      int[] student = new int[N],
		    		yet     = new int[2];

		Scanner sc = new Scanner(System.in);
		for(int i=0;i<28;i++){
			student[sc.nextInt()]++;
		}
		for(int i=1,j=0;i<31;i++){
			if(student[i]==0){
				yet[j] = i;
				j++;
			}
		}
		Arrays.sort(yet);
		System.out.printf("%d\n%d\n",yet[0],yet[1]);
	}
}

Measured memory_bytes: 17188
/*input
5
abcad
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

void solve(){
	int n;cin >> n;
  	string s;cin >> s;
  	if(n%2){
  		cout << "No";
  		return;
  	}
  	string hehe = "";
  	REP(i,n/2)hehe += s[i];
  	if(hehe+hehe == s){
  		cout << "Yes";
  	}
  	else cout << "No";
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

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

int main(){
    int a[1000]={};
    a[0]=0;
    for(int i=1;i<1000;i++){
      a[i]=a[i-1]+i;
    }
    int n,m;cin>>n>>m;
    int ans = a[m-n];
    cout << ans-m << endl;
    return 0;
}


Measured memory_bytes: 256