akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        if (n == 1)
        {
            Console.WriteLine("1\n0");
            return;
        }
        if (n == 2)
        {
            Console.WriteLine("2\n0\n11");
            return;
        }
        Console.WriteLine(n - 1);
        for (int i = 2; i <= n; i++)
        {
            Console.WriteLine($"1{string.Join("", Enumerable.Repeat("0", i - 2))}1");
        }
    }
}



Measured memory_bytes: 18336
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/05/20 00:39:46
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,k; cin>>n>>k;
  vector<int> K = {k};
  {
    int m = k;
    while (m) {
      K.push_back(m-1);
      m &= m-1;
    }
  }
  map<int, ll> sum;

  for (int i = 0; i < n; i++) {
    int a,b; cin>>a>>b;
    for (auto kk : K) {
      if ((a | kk) == kk) {
        sum[kk] += b;
      }
    }
  }
  ll ans = 0;
  for (auto [_, s] : sum)
    ans = max(ans, s);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.length();
    int ans=1;
    string t="";
    t+=s[0];
    for(int i=1;i<n;i++){
        if(s[i]==t[0]&&1==t.length()){
            if(i==n-1){
                continue;
            }
            else{
                t+=s[i+1];
                i++;
                ans++;
            }
        }
        else{
            ans++;
            t="";
            t+=s[i];
        }
    }
    cout << ans<<endl;
    return 0;
}



Measured memory_bytes: 720
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const long double EPS = 1e-14;
const long double INF = 1e+20;
const long double PI = acos(-1);
char S[100];
int mm[26];
int tmp[26];
int main(){
	for(int i=0;i<26;i++)mm[i]=mod;
 
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%s",S);
		for(int j=0;j<26;j++)tmp[j]=0;
		for(int j=0;S[j];j++)tmp[S[j]-'a']++;
		for(int j=0;j<26;j++)mm[j]=min(mm[j],tmp[j]);
	}
	for(int i=0;i<26;i++){
		for(int j=0;j<mm[i];j++)printf("%c",'a'+i);
		
	}printf("\n");
}

Measured memory_bytes: 128
import std.stdio;
import std.conv;
import std.array;
import std.string;
import std.algorithm;
import std.math;

void main() {
	string [] t;
	t = chomp(readln()).split();
	int N, M, R;
	N = to!int(t[0]); M = to!int(t[1]); R = to!int(t[2]);
	t = chomp(readln()).split();
	int [] r;
	for(int i = 0; i < R; i++) r ~= to!int(t[i]);

	long [210][210]C;
	const long INF = to!long(1e15);
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			C[i][j] = INF;
		}
		C[i][i] = 0;
	}


	for(int i = 0; i < M; i++) {
		int a, b;
		long c;
		t = chomp(readln()).split();
		a = to!int(t[0]); b = to!int(t[1]); c = to!long(t[2]);
		a--; b--;
		C[a][b] = min(C[a][b], c);
		C[b][a] = min(C[b][a], c);
	}

	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			for(int k = 0; k < N; k++) {
				C[j][k] = min(C[j][k], C[j][i] + C[i][k]);
			}
		}
	}

	sort(r);
	long res = INF;
	do {
		long tmp = 0;
		for(int i = 1; i < r.length; i++) {
			tmp += C[r[i-1]-1][r[i]-1];
		}
		res = min(res, tmp);
	} while(nextPermutation(r));
	writeln(res);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c;

    cin >> a >> b >> c;

    cout << (a + b + c) - max(a, max(b, c)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque> 
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype> 
using namespace std;

int main(){
    string o, e;
    cin >> o >> e;
    if (o.size()-e.size()==1) {
        cout << o.at(0);
        for (int i=0; i<e.size(); i++) {
            cout << e.at(i) << o.at(i+1);
        }
    }
    else {
        for (int i=0; i<o.size(); i++) {
            cout << o.at(i) << e.at(i);
        }
    }
    cout << endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=2e5+1;
#define PI (atan(1)*4)
void solve()
{
	ll R;
	cin>>R;
	double ans=R*2*PI;
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++){
        for (int j = i + 1; j < s.size(); j++){
            if (s[j] == s[i]){
                cout << "no" << endl;
                return 0;
            }
        }
    }
    cout << "yes" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 133 abc b
# input
import numpy as np
n, d = map(int, input().split())
x = []
counter = 0
for i in range(n):
    x.append(list(map(int, input().split())))
temp = np.array(x)
all_diffs = np.expand_dims(temp, axis=1) - np.expand_dims(temp, axis=0)
degree_distance = np.sqrt(np.sum(all_diffs ** 2, axis=-1))
for i in range(n):
    for j in range(n):
        if degree_distance[i][j].is_integer() == True:
            counter += 1
# output
print(int((counter-n)/2))



Measured memory_bytes: 12428
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define ALL(obj)		obj.begin(), obj.end()
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<double> v(n);
	FOR(n)
		cin >> v[i];
	sort(ALL(v));
	FORR(1, n)
		v[i] = (v[i - 1] + v[i]) / 2.0;
	cout << v[n - 1] << endl;
	return 0;
}

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

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    if(a + b > c){
        cout << "No" << endl;
        return 0;
    }
    if((c - a - b) * (c - a - b) > 4 * a * b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
     
    #define ff first
    #define ss second
    #define sz size()
    #define mp make_pair
     
    #define pb push_back
    #define endl "\n"
     
    #define int long long int
    #define double long double
     
    #define bp __builtin_popcountll
    #define inf 1e17
    const int N=1e5+6;
    const int M=998244353;
    int dp[N][3];//r,s,p;
    signed main()
    {
        FAST
        int n,k;
        cin>>n>>k;
        int r,s,p;
        cin>>r>>s>>p;
        string tt;
        cin>>tt;
        
        for(int i=0;i<n;i++)
        {
        	if(tt[i]=='r')
        	{
        		if(i-k>=0)
        		dp[i][2]=max(dp[i-k][0],dp[i-k][1])+p;
        		else
        		dp[i][2]=p;
        	}
        	else if(tt[i]=='s')
        	{
        		if(i-k>=0)
        		dp[i][0]=max(dp[i-k][2],dp[i-k][1])+r;
        		else
        		dp[i][0]=r;
        	}
        	else
        	{
        		if(i-k>=0)
        		dp[i][1]=max(dp[i-k][2],dp[i-k][0])+s;
        		else
        		dp[i][1]=s;
        	}
        	if(i-k>=0)
        	{
        		dp[i][0]=max(dp[i][0],max(dp[i-k][1],dp[i-k][2]));
        		dp[i][1]=max(dp[i][1],max(dp[i-k][0],dp[i-k][2]));
        		dp[i][2]=max(dp[i][2],max(dp[i-k][0],dp[i-k][1]));
        	}
        }
        int j=n-1,cnt=0,ans=0;
        while(cnt<k)
        {
        	ans+=max(max(dp[j][0],dp[j][1]),dp[j][2]);
        	--j;
        	cnt++;
        	
        }
        cout<<ans;
    }


Measured memory_bytes: 2768
n,m=map(int,input().split())
dic = {}
for i in range(1,n+1):
  dic[i]=0
for i in range(m):
  a,b = map(int,input().split())
  dic[a] += 1
  dic[b] += 1
ret = 'YES'
for i in range(1,n+1):
  if dic[i]%2==1:
    ret = 'NO'
    break
print(ret)

Measured memory_bytes: 19336
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>

using namespace std;


int main(){
    long long int x;
    cin >> x;
    int year = 0;
    long long int money = 100;

    while(x > money){
        money = money + money/100;
        year++;
    }

    cout << year << endl;
}   

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<string> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  for(int i=0;i<N;i++){
    cout << A[i];
  }
  cout << endl;
}

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

using ll = long long;

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

    int N, M;
    cin >> N >> M;

    vector<int> res;
    for (int i = 2; i * i <= M; ++i) {
        if (M % i == 0) {
            res.push_back(i);
            if (i != M / i) res.push_back(M / i);
        }
    }
    res.push_back(1);
    res.push_back(M);
  
    sort(res.begin(), res.end());
    auto it = lower_bound(res.begin(), res.end(), N);
    
    cout << M / *it << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define assign_if_greater(V, T) V=max(V,T)
using namespace std;
typedef long long ll;
typedef long double ld;
//

//
// inputs
ll N,M;
typedef pair<ll,ll> P;
vector<P> ABs;
//

int main(){
//startmain
  cout << fixed << setprecision(0);
//
cin >> N >> M;
ABs.resize(N);
REP(i,N)
    cin >> ABs[i].fi >> ABs[i].se;
//
([&](){
    ll ans=0;
    sort(ALL(ABs));
    for(int i=0;i<N;++i) {
        ll s=min(M,ABs[i].se);
        ans+=s*ABs[i].fi;
        M-=s;
    }
    cout << ans << endl;
})();
//

//

return 0;}
//endmain
//


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

using ll = long long;

int main() {
    ll N, D;  cin >> N >> D;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        ll x, y;  cin >> x >> y;
        if (x * x + y * y <= D * D) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  map<char,int> m;
  string s;
  cin >> s;
  rep(i,s.size()){
    m[s[i]]++;
  }
  for (auto w:m){
    if (w.second >= 2) {
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;

  return 0; 
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
 
	public static void main(String[] args)
	{
			Scanner in = new Scanner(System.in);
 
			int n = in.nextInt();
			int a = in.nextInt();
 
			int mo = n % 500;
			int r = a - mo;
			if(r >= 0)
				System.out.println("Yes");
			else
				System.out.println("No");
}}

Measured memory_bytes: 22100
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<sstream>
#include<iomanip>
#define pb push_back
#define LL long long
#define ff first
#define ss second
#define in inline
#define RE register
#define pa pair<int,int>
using namespace std;
const int MAXN=0x3f3f3f3f;
const int MAXL=0x7ffff;
in void read(int &x){
   x=0;
   char c=getchar();
   while(c>'9'||c<'0')c=getchar();
   while(c<='9'&&c>='0'){
   x=x*10+c-'0';
   c=getchar();
   }
}
inline void write(int re)
 {     /*
     if (re<0)
     {
         putchar('-');
         re=-re;
     }
     */
     if (re>9) write(re/10);
     putchar(re%10+'0');
}
map<char,int>h;
int s;
char a[101010];
int main()
{
	cin>>a;
	int len =  strlen(a);
	for ( int i = len-1; i >= 0; i-- )
	{
		h[a[i]] = 1;
	}
	for( int i = 0; i < 26; i++ )
	{
		char c = 'a' + i;
		if( h[c] == 0 )
		{
			cout << a << c;
    		return 0;
		}
	}
	for ( int i = len-1; i >= 0; i-- )
	{
		char c = 'a';
		bool hn = 0;
		for(int j = 0;j < 26; j++)
		{
			c+=j;
			if(h[c]==2 && c>a[i])
			{
				hn=1;
				break;
			}
			c-=j;
		}
		if(hn == 0) {
			h[a[i]] = 2;
			continue;
		}
		if( h[c] == 2 )
		{
			for(int j = 0; j < i; j++ )
			cout << a[j];
			cout << c;
			return 0;
		}
		
	}
	cout<<-1;
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
int afa[maxn],bfa[maxn];
int getfa(int n,int *fa) {
	return fa[n]==n?fa[n]:fa[n]=getfa(fa[n],fa);
}
int main() {
	int n,k,l;cin>>n>>k>>l;
	for(int i=1;i<=n;i++) afa[i]=bfa[i]=i;
	for(int i=1;i<=k;i++) {
		int u,v;cin>>v>>u;
		u=getfa(u,afa);v=getfa(v,afa);
		if(u==v) continue;
		afa[u]=v;
	}
	for(int i=1;i<=l;i++) {
		int u,v;cin>>u>>v;
		u=getfa(u,bfa);v=getfa(v,bfa);
		if(u==v) continue;
		bfa[v]=u;
	}
	map<int,pii> M;
	map<pii,int> ans;
	for(int i=1;i<=n;i++) M[i]={getfa(i,afa),getfa(i,bfa)},ans[{getfa(i,afa),getfa(i,bfa)}]++;
	for(int i=1;i<=n;i++) cout<<ans[M[i]]<<' ';
    return 0;
}

Measured memory_bytes: 28472
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		a,b,c,i,j,k,n,m,x,y;
	char	s[256];
	char	ans[] = "Yes";
	
	scanf("%s", &s[1]);

	n = strlen(&s[1]);
	
	for(i=1;i<=n;i++) {
		if ((s[i] == 'L') && (i%2==1)) {
			strcpy(ans, "No");
		}
		if ((s[i] == 'R') && (i%2==0)) {
			strcpy(ans, "No");
		}
	}
			
	printf("%s\n",ans);


	return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int x, a, b; cin >> x >> a >> b;
  cout << (abs(x - a) < abs(x - b) ? 'A' : 'B') << "\n";
}


Measured memory_bytes: 256
let n = stdin.ReadLine() |> int

let a =
  stdin.ReadLine().Split(' ') |> Array.map int

let ans =
  let cost x =
    a |> Array.sumBy (fun y -> (y - x) * (y - x))

  [-100 .. 100]
  |> List.minBy cost
  |> cost

ans |> stdout.WriteLine

Measured memory_bytes: 13396
#include <iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<math.h>
using namespace std;
#define c(v) cout << fixed << setprecision(10) << v << endl;
int x[1110]; int y[110]; vector<double> v;
int main()
{
    int n; 
    for (;;) {
        cin >> n; double sum = 0; double sm = 0;
        if (n == 0)
            break;
        for (int i = 0; i < n; i++) {
            cin >> x[i];
            sum += x[i];
            sm += pow(x[i], 2);
        }
        sum /= n; sm /= n; sum = pow(sum, 2);
        v.push_back(sqrt(sm - sum));
    }
    for (int i = 0; i < v.size(); i++) {
        c(v[i])
    }
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int cnt[10][10];
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int top = i, btm = -1;
		btm = i % 10;
		while( top >= 10 ){
			top /= 10;
		}
		cnt[top][btm]++;
	}
	int ans = 0;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			ans += cnt[i][j] * cnt[j][i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

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


def main():
    N, M = map(int, input().split())
    A = [[] for _ in range(N)]
    for i in range(M):
        p, y = map(int, input().split())
        A[p-1].append([y, i])
    
    B = ['']*M
    for i in range(N):
        if len(A[i])==0:
            continue
        A[i].sort()
        for j in range(len(A[i])):
            S = str(i+1).zfill(6) + str(j+1).zfill(6)
            B[A[i][j][1]] = S
    
    for i in range(M):
        print(B[i])


if __name__ == '__main__':
    main()

Measured memory_bytes: 39036
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} 



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

string s; cin >> s;
i64 cnt = 0;
if (s.size() < 3){
    cout << "0\n";
    return 0;
}
rep(i, 0, s.size()){
    if (s[i] == 'A'){
        ++i;
        int m = 1;
        for(; i < s.size(); ++i){
            if (s[i] == 'B' && s[i+1] == 'C') {++i; cnt += m;}
            else if (s[i] == 'A') ++m;
            else break;
        }
    }
}


cout << cnt << "\n";
return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 720
class UnionFind:
    def __init__(self, n):
        self.root = list(range(n))
        self.size = [1] * (n)
    def find_root(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x
    """
    def find_root(self, x):
        root = self.root
        if root[x] == x:
            return x
        else:
            root[x] = self.find_root(root[x])
            return root[x]
    """
    def merge(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return
        sx, sy = self.size[x], self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy

n, m, k = map(int, input().split())

uf = UnionFind(n)

ab = []
for _ in range(m):
    a, b = map(int, input().split())
    ab.append((a, b))
    uf.merge(a-1, b-1)
cd = []
for _ in range(k):
    c, d = map(int, input().split())
    cd.append((c, d))

#print(uf.root, uf.size)

ans = [uf.size[uf.find_root(i)] - 1 for i in range(n)]

#print(' '.join(map(lambda x: str(x), ans)))
for a, b in ab:
    ans[a-1] -= 1
    ans[b-1] -= 1
#print(' '.join(map(lambda x: str(x), ans)))
for c, d in cd:
    #if uf.find_root(uf.root[c-1]) == uf.find_root(uf.root[d-1]):
    if uf.find_root(c-1) == uf.find_root(d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1
print(' '.join(map(lambda x: str(x), ans)))



Measured memory_bytes: 42564
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
#define what(x) cerr << #x << " is " << x << endl;
const int INF = 1 << 28;

int main() {
    int A, B, T;
    cin >> A >> B >> T;
    cout << B * (T / A) << endl;
    return 0;
}

Measured memory_bytes: 764
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../../abc/nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
l,r,d=gsmi
d1=r/d
d2=(l-1)/d
puts d1-d2

Measured memory_bytes: 14268
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int sum=0,l;
    vector<int>L;
    for(int i=0;i<N;i++){
        cin>>l;
        L.push_back(l);
        sum+=l;
    }
    bool flag=true;
    for(int i=0;i<N;i++){
        if(sum-L[i]<=L[i]){flag=false;}
    }
    cout<<(flag?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;cin>>N>>M;
  string s;cin>>s;
  int64_t a=N;
  vector<int>ans;bool x=true;ans.push_back(N);
  while(0<a){
  int b=-1;
    for(int i=1;(i<=M &&0<=a-i);i++)
    if(s.at(a-i)=='0')b=a-i;
    if(b!=-1){ans.push_back(b);a=b;}else{x=false;break;}
  
  }int n=ans.size();
 if(x){ for(int i=n-1;2<=i;i--)
    cout<<ans.at(i-1)-ans.at(i)<<" ";
  cout<<ans.at(0)-ans.at(1)<<endl;
      }else
   cout<<-1<<endl;
    
  return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
  ll n,c ;
  cin >> n>>c ;
  vector<ll> x(n);
  vector<ll> v(n);
  rep(i,n) cin >>x[i] >>v[i] ;
  //利益の最大右回り
  vector<ll> rieki(n) ;
  rep(i,n){
    if(i==0) rieki[i] = v[0]-x[0] ;
    else 
    rieki[i]=rieki[i-1]+x[i-1]+v[i]-x[i] ;
  }
  vector<ll> rmax(n) ;
  rep(i,n){
    if(i==0) rmax[i] =rieki[i] ;
    else rmax[i] =max(rmax[i-1],rieki[i]) ;
  }
  //利益の最大左回り　 
  ll sum =0 ;
  rep(i,n) sum += v[i]  ;
  vector <ll> lieki(n) ;
  rep(i,n) lieki[i] = sum -c +v[i]-rieki[i] ;
  vector<ll> lmax(n) ;
  rep(i,n){
  if(i==0) lmax[n-1] =lieki[n-1];
  else lmax[n-1-i] = max(lmax[n-i],lieki[n-1-i]) ;
  } 
   ll rans =0ll ;
  rep2(i,1,n-1){
   rans =max(rans, rmax[i-1]+lieki[i]-(c-x[i])) ;
  }
  ll lans = 0ll;
  rep2(i,0,n-2){
    lans =max(lans ,rieki[i]-x[i]+lmax[i+1]) ;
  }
  ll ans=max(0ll,max(lans,max(rans,max(rmax[n-1],lmax[0])))) ;
   cout<< ans<< endl;
    return 0;
}

Measured memory_bytes: 4992
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); long d = sc.nextInt();
        long dist = d*d;
        int ans = 0;
        for(int i=0;i<n;i++){
            long a = sc.nextInt(); long b = sc.nextInt();
            if((a*a)+(b*b) <= dist){
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 60968
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  string s;
  cin >> s;
  for (auto &i : s) {
    if (i == '9') i = '1';
    else i = '9';
  }
  cout << s << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

#define llint long long int

using namespace std;

int main(){
  int n;
  cin >> n;
  llint a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a, a+n);
  cout << abs(a[n-1] - a[0]);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	
	static int[] a = new int[]{1,0,0};
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str;
		String[] st;
		int x = 0;
		int y = 0;
		while(sc.hasNext()){
			str = sc.next();
			st = str.split(",",0);
			
			if(st[0].equals("A"))x = 0;
			if(st[1].equals("A"))y = 0;
			if(st[0].equals("B"))x = 1;
			if(st[1].equals("B"))y = 1;
			if(st[0].equals("C"))x = 2;
			if(st[1].equals("C"))y = 2;
			change(x, y);
		}
		
		if(a[0] == 1)
			System.out.println("A");
		if(a[1] == 1)
			System.out.println("B");
		if(a[2] == 1)
			System.out.println("C");
		}
	static void change(int x, int y){
		int n = a[x];
		a[x] = a[y];
		a[y] = n;
	}
}

Measured memory_bytes: 17152
let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.make n 0 in
  let bs = Array.make n 0 in
  for i = 0 to n - 1 do
    Scanf.scanf "%d %d\n" @@ fun a b ->
      as_.(i) <- a;
      bs.(i) <- b
  done;
  Array.sort compare as_;
  Array.sort compare bs;
  Printf.printf "%d\n" @@
  if n mod 2 = 1
  then bs.(n / 2) - as_.(n / 2) + 1
  else bs.(n / 2) + bs.(n / 2 - 1) - as_.(n / 2) - as_.(n / 2 - 1) + 1



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

int main() {
	ll N,L;
	string t;
    vector<string> S;
scanf("%lld%lld",&N,&L);
rep(i,N){
	cin>>t;
	S.push_back(t);
}
     std::sort(S.begin(), S.end() ) ;//昇順にソート
    //  std::sort(S.begin(), S.end(), greater<string>()) ;//降順にソート

	rep(i,N){
        // std::cout <<S [i]<<endl;
        std::cout <<S [i];
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int i,a[3];
    for(i=0; i<3; i++){
        cin>>a[i];
    }
    sort(a, a+3);
    if(a[0]+a[1]==a[2]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

int main() {
	int H, W = 0;
	cin >> H >> W;
	int i;
	for(i = 0;true;i++){
		string s;
		cin >> s;
		if(s == "snuke"){
			break;
		}
	}
	int a;
	a = i / W + 1;
	char b;
	if(i % W == 0){
		b = 'A';
	}
	if(i % W == 1){
		b = 'B';
	}
	if(i % W == 2){
		b = 'C';
	}
	if(i % W == 3){
		b = 'D';
	}
	if(i % W == 4){
		b = 'E';
	}
	if(i % W == 5){
		b = 'F';
	}
	if(i % W == 6){
		b = 'G';
	}
	if(i % W == 7){
		b = 'H';
	}
	if(i % W == 8){
		b = 'I';
	}
	if(i % W == 9){
		b = 'J';
	}
	if(i % W == 10){
		b = 'K';
	}
	if(i % W == 11){
		b = 'L';
	}
	if(i % W == 12){
		b = 'M';
	}
	if(i % W == 13){
		b = 'N';
	}
	if(i % W == 14){
		b = 'O';
	}
	if(i % W == 15){
		b = 'P';
	}
	if(i % W == 16){
		b = 'Q';
	}
	if(i % W == 17){
		b = 'R';
	}
	if(i % W == 18){
		b = 'S';
	}
	if(i % W == 19){
		b = 'T';
	}
	if(i % W == 20){
		b = 'U';
	}
	if(i % W == 21){
		b = 'V';
	}
	if(i % W == 22){
		b = 'W';
	}
	if(i % W == 23){
		b = 'X';
	}
	if(i % W == 24){
		b = 'Y';
	}
	if(i % W == 25){
		b = 'Z';
	}
	cout << b << a << endl;
}

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

int main(void)
{
	int n, m, l;
	cin >> n >> m >> l;

	vector<vector<long>> a,b,c;
	for (int i = 0; i < n; i++)
	{
		a.emplace_back();
		for (int j = 0; j < m; j++)
		{
			int tmp;
			cin >> tmp;
			a.at(i).push_back(tmp);
		}
	}
	for (int i = 0; i < m; i++)
	{
		b.emplace_back();
		for (int j = 0; j < l; j++)
		{
			int tmp;
			cin >> tmp;
			b.at(i).push_back(tmp);
		}
	}

	for (int i = 0; i < n; i++)
	{
		c.emplace_back();
		for (int j = 0; j < l; j++)
		{
			long tmp = 0;
			for (int k = 0; k < m; k++)
			{
				tmp += a[i][k] * b[k][j];
			}
			c.at(i).push_back(tmp);
			cout << c[i][j];
			if(j != l-1)cout << " ";
		}
		cout << endl;
	}
	
	return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    int ans = max(a*b,max(a+b,a-b));
    cout << ans << endl;
}

Measured memory_bytes: 3580
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var l     = int.Parse(spl[1]);

        var dd = new int[n];
        for(int i=0; i<n; i++) {
            dd[i] = l + i;
        }

        var x = dd.Sum();
        var xx = new int[n];
        var min = int.MaxValue;
        var minV = 0;

        for(int i=0; i<n; i++) {
            var v = dd.Where((y, j) => j != i).Sum();
            if(min > Math.Abs(x - v)) {
                min = Math.Abs(x - v);
                minV = v;
            }
        }

        return minV;
    }
}

Measured memory_bytes: 13268
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,m,h,sum;
const int d[105][105]={{4,2,0,9,7},{1,10,8,6,4},{9,7,5,3,1},{6,4,2,0,9},{3,1,10,8,6},{0,9,7,5,3},{8,6,4,2,0},{5,3,1,10,8},{2,0,9,7,5},{10,8,6,4,2},{7,5,3,1,10}};
int main(){
	scanf("%d%d",&h,&m);
	int ans=(h-2)%11;
	n=(h-2)/11;
	for(int i=0;i<ans;i++)
		for(int j=0;j<5;j++)
			if(d[i][j]==m)sum++;
	printf("%d\n",sum+n*5);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5, mod = 1e9 + 7;
char s[maxn + 10];
int a[maxn + 10], b[maxn + 10], tr[maxn + 10][3];
int to[maxn + 10], n, ans, f[maxn + 10];
int main() {
	scanf("%s", s + 1); n = strlen(s + 1);
	for (int i = 1; i <= n; ++i) {
		if (s[i] == 'a') a[i] = 1;
		else a[i] = 2;
		b[i] = (b[i - 1] + a[i]) % 3;
	}
	for (int i = 0; i < 3; ++i) tr[n + 1][i] = n + 1;
	for (int i = n; i >= 1; --i) {
		if (i == n) to[i] = n + 1;
		else if (a[i] == a[i + 1]) to[i] = i + 1;
		else to[i] = to[i + 1];
		for (int j = 0; j < 3; ++j) tr[i][j] = tr[i + 1][j];
		tr[i][b[i]] = i;
	}
	if (to[1] == n + 1) {
		printf("1"); return 0;
	}
	f[0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 1; j < 3; ++j)
			if (a[i + 1] == j) (f[i + 1] += f[i]) %= mod;
			else {
				int p = to[i + 1];
				if (p <= n) p = tr[p][(b[i] + j) % 3];
				if (p <= n) (f[p] += f[i]) %= mod;
			}
	}
	int sum = 0;
	for (int i = n; i >= 1; --i) {
		if (!sum) (ans += f[i]) %= mod;
		sum = (sum + a[i]) % 3;
	}
	printf("%d", ans);
}


Measured memory_bytes: 3072
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
m = max(A)
L = [m for _ in range(N)]
if A.count(m) == 1:
    for i in range(N):
        if A[i] == m:
            A[i] = 0
            L[i] = max(A)
for i in range(N):
    print(L[i])

Measured memory_bytes: 70872
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int main(){
  int n;
  cin >> n;
  vector<ll> a(n);

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

  sort(a.begin(),a.end());
  if(n % 2 == 0){//1,1,3,3,5,5,...
    ll ans = 1;
    for(int i = 0;i < n;i+=2){
      if(a[i] != a[i+1])ans = 0;
    }

    if(ans == 0)cout << ans << endl;
    else{
      for(int i = 0;i < n/2;i++){
        ans *= 2;
        ans %= MOD;
      }
      cout << ans << endl;
    }
  }
  else{//0,2,2,4,4,...
    ll ans = 1;
    if(a[0] != 0)ans = 0;

    for(int i = 1;i < n;i+=2){
      if(a[i] != a[i+1])ans = 0;
    }

    if(ans == 0)cout << ans << endl;
    else{
      for(int i = 0;i < n/2;i++){
        ans *= 2;
        ans %= MOD;
      }
      cout << ans << endl;
    }
  }

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define MOD 1000000007;

using namespace std;
using namespace __gnu_pbds;
//typedef tree<TYPE, null_type, less<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//typedef tree<TYPE, null_type, less_equal<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

int arr[4];

int main(){
	//IO("input.txt", "output.txt");
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b;
	cin >> a >> b;
	arr[a] = 1;
	arr[b] = 1;
	for(int i = 1; i <= 3; i++)
		if(!arr[i]){
			cout << i << "\n";
			break;
		}
 	return 0;
}

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


struct Seg {
  int l, m, r;
  long long ma = 0;
  Seg* ch[2] = {0};
  void pull() {
    ma = max(ch[0]->ma, ch[1]->ma);
  }
  Seg(int l, int r) : l(l), r(r), m(l + r >> 1) {
    if (r - l > 1) {
      ch[0] = new Seg(l, m);
      ch[1] = new Seg(m, r);
    }
  }
  void mod(int x, long long v) {
    if (r - l == 1) ma = v;
    else {
      ch[x >= m]->mod(x, v);
      pull();
    }
  }
  long long rmq(int ql, int qr) {
    if (ql <= l and r <= qr) return ma;
    else {
      long long ans = 0;
      if (ql < m) ans = max(ans, ch[0]->rmq(ql, qr));
      if (m < qr) ans = max(ans, ch[1]->rmq(ql, qr));
      return ans;
    }
  }
};

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  vector<int> p(n);
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) cin >> p[i], --p[i];
  for (int i = 0; i < n; ++i) cin >> a[i];
  Seg root(0, n);
  for (int i = 0; i < n; ++i) {
    if (p[i] == 0) root.mod(0, a[i]);
    else {
      auto dp = root.rmq(0, p[i]);
      root.mod(p[i], dp + a[i]);
    }
  }
  cout << root.ma << '\n';
}


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


int main()
{
    int n=0;
    cin >> n;

    string s[n];
    int t[n];

    for(int i=0; i<n; i++){
        cin >> s[i] >> t[i];
    }

    string x;
    cin >> x;
    int sum = 0;
    bool c = false;
    for(int i=0; i<n; i++){
        if(s[i]==x){
            c = true;
        }
        else if(c==true){
            sum += t[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string x;
  while (cin >> x) {
    if (x[0] == '0')
      break;
    int ans = 0;
    rep(i, 0, x.size()) { ans += x[i] - '0'; }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3172
#include<cstdio>

int main(){
  char s[1201];//ヌル文字の分を加えなくちゃいけないから＋１
  scanf("%[^\n]",s);
 
  for(int i = 0; s[i]!= '\0'; i++){
    char c = s[i];

    if(c >= 65 && c <= 90){
      s[i] = c + 32;
    }
    else if(c >= 97 && c <= 122){
      s[i] = c - 32;
    }
  }

  //出力
      printf("%s\n",s);
}
    


Measured memory_bytes: 2604
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

ans = [1] * n
for abi in ab:
    if h[abi[0] - 1] == h[abi[1] - 1]:
        ans[abi[0] - 1] = 0
        ans[abi[1] - 1] = 0
    elif h[abi[0] - 1] < h[abi[1] - 1]:
        ans[abi[0] - 1] = 0
    elif h[abi[0] - 1] > h[abi[1] - 1]:
        ans[abi[1] - 1] = 0

print(sum(ans))

Measured memory_bytes: 31952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    string s; cin >> s;
    ll d = 0, cnta=0;
    for(ll i = 0 ; i < s.size(); i++)
    {
        if(s[i] == 'A') cnta++;
        else d++;
    }
    if(d != 0 && cnta != 0)
    {
        cout << "Yes" << '\n';
    }
    if(d == 0 || cnta == 0)
    {
        cout << "No" << '\n';
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MEM 300001
#define sanic ios_base::sync_with_stdio(0)
using namespace std;
typedef long long ll;
const ll INF = 1e9+9;
ll n;
ll ba[MEM];
ll c[MEM];
ll ans[MEM];
ll res[MEM];
int main() {
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> ba[i];
    for(int i=0; i<n; i++)
        c[ba[i]]++;
    ans[2] = 1;
    for(int i=2; i<n; i++)
        ans[i+1] += ans[i]+i;
    for(int j=1; j<=n; j++){
        ll o=c[j];
        res[j+1] += res[j]+ans[o];
    }
    for(int i=1; i<=n; i++){
        ll o=c[ba[i-1]];
        cout << res[n+1]-ans[o]+ans[o-1] << '\n';
    }

}


Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c;
    cin>>a>>b>>c;
    if(c>a)
    {
    	c=c-a;
    	a=0;
	}
	else
	{
		a=a-c;
		c=0;
	}
	if(c>b)
    {
    	c=c-b;
    	b=0;
	}
	else
	{
		b=b-c;
		c=0;
	}
	cout<<a<<" "<<b;
}

Measured memory_bytes: 256
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int MAX3(int a,int b,int c){return MAX(a,MAX(b,c));}
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,m,d,v,s,i,j,min=1e9,b[1010]={};
  int a[2000]={};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&m,&d,&v,&s);
    for(j=0;j<v;j++)a[j+(m-1)*30+(d-1)+360]=MAX(a[j+(m-1)*30+(d-1)+360],s);
  }
  for(i=0;i<1200;i++)a[i+1]=MAX(a[i+1],a[i]-1);
  for(i=1200;i;i--)  a[i-1]=MAX(a[i-1],a[i]-1);
  for(i=0;i<360;i++)min=MIN(min,MAX3(a[i],a[i+360],a[i+720]));
  printf("%d\n",min);
  return 0;
}


  

Measured memory_bytes: 1816
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++) {
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

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

	vector<int> A(N, 0);
	map<int, ll> m;
	rep(i, N) {
		int a;
		cin >> a;
		A[i] = a;
	}

	ll result = 0;
	int x1 = 0;
	int x2 = 0;
	rep(i, N) {
		int a = A[i];

		rep(j, N) {
			if (j < i) {
				if (A[j] < a) x1 += 1;
			} else if (i < j) {
				if (A[j] < a) x2 += 1;
			}
		}

	}
	result = x2 * K;
	result %= MOD;
	result += (x1+x2) * ((K * (K - 1)/2) % MOD);
	result %= MOD;

	cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main() {
	int N, K, a, b, c, Q;
	vector<pair<int, ll>> v[100000];

	cin >> N;
	REP(i, N - 1) {
		cin >> a >> b >> c;
		v[a - 1].push_back(make_pair(b - 1, c));
		v[b - 1].push_back(make_pair(a - 1, c));
	}

	cin >> Q >> K;

	ll dist[100000];
	int color[100000] = { 0 };
	dist[K - 1] = 0;
	queue<int> qu;
	qu.push(K - 1);
	color[K - 1] = 1;
	while (1) {
		if (qu.empty()) {
			break;
		}
		int u = qu.front();
		qu.pop();
		REP(i, v[u].size()) {
			if (color[v[u][i].first] == 0) {
				qu.push(v[u][i].first);
				color[v[u][i].first] = 1;
				dist[v[u][i].first] = dist[u] + v[u][i].second;
			}
		}
	}
	
	int x, y;
	REP(i, Q) {
		cin >> x >> y;
		cout << dist[x - 1] + dist[y - 1] << endl;
	}



	return 0;
}

Measured memory_bytes: 10368
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			// 町と町の間の移動最短距離
			int[][] a = new int[n][n];
			IntStream.range(0, n).forEach(i -> IntStream.range(0, n).forEach(j -> a[i][j] = scanner.nextInt()));
			if (!warshallFloyd(a, n)) {
				System.out.println(-1);
				return;
			}
			System.out.println(IntStream.range(0, n)
					.mapToLong(i -> IntStream.range(i + 1, n).mapToLong(j -> getResult(i, j, a, n)).sum()).sum());
		}
	}

	/**
	 * 町と町の間の移動最短距離をワーシャル–フロイド法で計算する
	 * 
	 * @param d 町と町の間の移動最短距離の配列
	 * @param n 町の数
	 * @return すでに最短距離であるかどうか
	 */
	private static boolean warshallFloyd(int[][] d, int n) {
		for (int k = 0; k < n; k++) {
			for (int j = 0; j < n; j++) {
				for (int i = 0; i < n; i++) {
					if (d[i][k] + d[k][j] < d[i][j]) {
						return false;
					}
				}
			}
		}
		return true;
	}

	/**
	 * @param u 始点の町
	 * @param v 終点の町
	 * @param a 町の町の間の最短距離
	 * @param n 町の数
	 * @return uとvの間に道路が存在する場合、その長さ。存在しない場合は0
	 */
	private static long getResult(final int u, final int v, final int[][] a, final int n) {
		if (u == v) {
			return 0L;
		}
		for (int i = 0; i < n; i++) {
			if ((i != u) && (i != v) && (a[u][i] + a[i][v] == a[u][v])) {
				return 0L;
			}
		}
		return a[u][v];
	}
}


Measured memory_bytes: 51556
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100010;
long long int m, n;
int par[MAX_N];    //親
int deapth[MAX_N]; //木の深さ
long long int cnt[MAX_N];
long long int num;

//n要素で初期化
void init(int n)
{
    for (int i = 0; i < n; i++)
    {
        par[i] = i;
        deapth[i] = 0;
        cnt[i] = 1;
    }
}
//木の根を求める
int find(int x)
{
    if (par[x] == x)
    {
        return x;
    }
    else
    {
        return par[x] = find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;
    if (deapth[x] < deapth[y])
    {
        par[x] = y;
        cnt[y] += cnt[x];
    }
    else
    {
        par[y] = x;
        cnt[x] += cnt[y];
        if (deapth[x] == deapth[y])
            deapth[x]++;
    }
}

bool same(int x, int y)
{
    return find(x) == find(y);
}

int main()
{
    cin >> n >> m;
    init(n);
    num = n * (n - 1) / 2;
    vector<int> a(m);
    vector<int> b(m);
    vector<long long int> ans(m);
    int i = 0;
    for (i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
    }
    ans[m - 1] = num;
    for (i = m - 1; i > 0; i--)
    {
        if (same(a[i], b[i]))
            ans[i - 1] = ans[i];
        else
        {
            int para = find(a[i]);
            int parb = find(b[i]);
            ans[i - 1] = ans[i] - cnt[para] * cnt[parb];
            unite(a[i], b[i]);
        }
    }
    for (int i = 0; i < m; i++)
    {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4480
from numpy import argmax as mode
from numpy import bincount as bc
N = int(input())
V = list(map(int, input().split()))
a = [V[2 * i] for i in range(N // 2)]
b = [V[2 * i + 1] for i in range(N // 2 + N % 2)]
bca = bc(a)
bcb = bc(b)
#print(bca, bcb)
if mode(bca) == mode(bcb):
  print(N - a.count(mode(bca)) - max(sorted(bca)[-2], sorted(bcb)[-2]))
else:
  print(N - a.count(mode(bca)) - b.count(mode(bcb)))

Measured memory_bytes: 23388