akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
//#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(s, v, it) for (s::iterator it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 1010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
const double eps = 1e-7 ;
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }
template <class T> void print(T a) { cout << a << endl ; exit(0) ; }
template <class T> void chmin(T &a, T b) { if (a > b) a = b ; }
template <class T> void chmax(T &a, T b) { if (a < b) a = b ; }
template <class T> void upd(T &a, T b) { (a += b) %= MOD ; }
template <class T> void mul(T &a, T b) { a = (ll) a * b % MOD ; }

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

struct node {
	int x, y, dep ;
};

queue <node> q ;

int n, m, ans ;
char a[N][N] ;
int vis[N][N] ;

signed main(){
    scanf("%d%d", &n, &m) ;
	rep(i, 1, n) {
		string s ; cin >> s ;
		rep(j, 1, m) a[i][j] = s[j - 1] ;
	}
	rep(i, 1, n) rep(j, 1, m) if (a[i][j] == '#') q.push((node) {i, j, 0}), vis[i][j] = 1 ;
	while (!q.empty()) {
		int x = q.front().x, y = q.front().y, dep = q.front().dep ; q.pop() ;
		rep(i, 0, 3) {
			int tx = x + dx[i], ty = y + dy[i] ;
			if (tx < 1 || ty < 1 || tx > n || ty > m || vis[tx][ty]) continue ;
			vis[tx][ty] = 1 ; ans = dep + 1 ;
			q.push((node) {tx, ty, dep + 1}) ;
		}
	}
	printf("%d\n", ans) ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/




Measured memory_bytes: 17296
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

const ll M = 1000000007;

int main(){
	int cnt[5] = {};
	rep(i,6){
		int a;
		cin >> a;
		cnt[a] ++;
	}
	rep1(i,4){
		if(cnt[i] == 3){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,q,a[1000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  cin>>q;
  for(int i=0; i<q;i++){
    int x,y,z;
    cin>>x>>y>>z;
    cout<<count(a+x,a+y,z)<<endl;
  }
    
  return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0;i<n;i++){
    cin >> a[i];
  }
  if (n%2==0){
    for (int i=n-1;i>=1;i-=2){
      cout << a[i] << ' ';
    }
    for (int i=0;i<n;i+=2){
      cout << a[i] << ' ';
    }
  }
  else {
    for (int i=n-1;i>=0;i-=2){
      cout << a[i] << ' ';
    }
    for (int i=1;i<n;i+=2){
      cout << a[i] << ' ';
    }
  }
  cout << endl;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll pw(ll a, ll b) {
    if (b == 0) return 1;
    ll t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
int main()
{
	ll n,m,k;cin>>n>>m>>k;
	ll sm=0,bs=0,bp=0,ans=0;
	ll a[n+1];for(ll i=0;i<n;i++)cin>>a[i],sm+=a[i];
	ll b[m+1];for(ll i=0;i<m;i++)cin>>b[i];
	for(ll i=n;i>=0;i--)
	{
		if(i<n)sm-=a[i];
		if(sm<=k)
		{
			while(bp<m&&sm+bs+b[bp]<=k)
			{
				bs+=b[bp];
				bp++;
			}
			ans=max(ans,i+bp);
		}
	}
	cout<<ans;
}


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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

typedef pair<int, int> Pii;
typedef struct{ int x, y; } Point;

int N, A, B;
string s;

void check()
{
    int n = 0;
    int b = 1;
    for(int i = 0; i < N; i++){
        if(s[i] == 'a'){
            if(n < A + B){
                n++;
                printf("Yes\n");
            }
            else{
                printf("No\n");
            }

        }
        else if(s[i] == 'b'){
            if(n < A + B && b <= B){
                n++;
                b++;
                printf("Yes\n");
            }
            else{
                printf("No\n");
            }
        }
        else if(s[i] == 'c'){
            printf("No\n");
        }
    }
}

int main(void)
{
    scanf("%d %d %d", &N, &A, &B);
    cin >> s;
    check();
    
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string s;
  cin >> s;
  int sum;
  // ASCII Code
  // o: 111
  // x: 120
  for (char c : s) {
    sum += int(c);
  }
  if (sum == 333) cout << 1000 << endl;
  else if (sum == 342) cout << 900 << endl;
  else if (sum == 351) cout << 800 << endl;
  else cout << 700 << endl;

  return 0;
}


Measured memory_bytes: 256
/*___________Bismillahir Rahmanir Rahim__________*/
//Think positive, be positive and never use negative words
#include<bits/stdc++.h>
#define ll               long long int
#define uni(a)           a.erase(unique(a.begin(),a.end()),a.end())
#define vsum(a)          accumulate(a.begin(),a.end(),0)
#define vmax(a)          *max_element(a.begin(),a.end())
#define vmin(a)          *min_element(a.begin(),a.end())
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b
#define yes              cout<<"YES"<<endl
#define no               cout<<"NO"<<endl
#define p                3.14
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    float n;
    cin>>n;
    float a=2*p*n;
    cout<<a<<endl;
    return 0;
}
/*_________________Alhamdulillah_________________*/


Measured memory_bytes: 3772
#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 watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

bool DEBUG=0;
const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll a; cin>>a;
	cout<<a+a*a+a*a*a<<'\n';
	
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX],n;
    
    cin >> n;
    for(int i=0;i<n;i++) cin>>R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1; i<n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3892
n = int(input())
a = [0]+list(map(int,input().split()))
ans = [-1]*(n+1)
for i in range(n,0,-1):
    res = 0
    for j in range(i+i,n+1,i):
        res += ans[j]
    ans[i] = (res - a[i])%2
p = []
for ind,v in enumerate(ans):
    if v== -1:continue
    if v == 1:p.append(ind)

print(len(p))
print(*p)

        
        


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

#define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define test ll t; cin>>t; while(t--)
#define ub(a,x) upper_bound(a.begin(),a.end(),x)-a.begin()
#define lb(a,x) lower_bound(a.begin(),a.end(),x)-a.begin()
#define ll long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define PI 3.1415926535897932384626
#define inf 1e18
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define MOD 1000000007

int main()
{
    speed;
//    test{}
    ll n,W;
    cin>>n>>W;
    ll v[n],wt[n];
    forn(i,n)
    	cin>>wt[i]>>v[i];

    ll dp[n+1][W+1];
    forn(i,n+1)
    {
    	forn(w,W+1)
    	{
    		if(i==0||w==0)
    			dp[i][w]=0;
    		else if(wt[i-1]<=w)
    			dp[i][w]=max(v[i-1]+dp[i-1][w-wt[i-1]],dp[i-1][w]);
    		else
    			dp[i][w] = dp[i-1][w];

    	}
    }
    cout<<dp[n][W]<<endl;
    return 0;
}


Measured memory_bytes: 79232
#include<cstdio>
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
int n,c;
const long long mod=1e9+7;
int A[405],B[405];
long long matmod(long long val,long long k){
	long long ret=1;
	for(;k;k>>=1){
		if(k&1) ret=(val*ret)%mod;
		val=(val*val)%mod;
	}
	return ret;
}
void add(long long &des,long long sor){des+=sor;des%=mod;return ;}
long long sum[405][405],f[405][405];
int main(){
	//freopen("candies.in","r",stdin);
	//freopen("candies.out","w",stdout);
	scanf("%d%d",&n,&c);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]);
	for(int i=1;i<=n;i++) scanf("%d",&B[i]);
	for(int i=0;i<=c;i++){
		for(int j=1;j<=400;j++)
			add(sum[i][j],sum[i][j-1]+matmod(j*1ll,i*1ll));
	}
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=c;j++)
			for(int k=0;k<=j;k++)
				add(f[i][j],f[i-1][j-k]*(sum[k][B[i]]-sum[k][max(A[i]-1,0)]+mod)%mod);
	}
	printf("%lld\n",f[n][c]);
	return 0;
}

Measured memory_bytes: 2688
#include <stdio.h>

#define MAX 100

int main(){
  int n,a[MAX],i,j,mini,tmp,ans = 0;

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

  for(i = 0 ; i < n-1 ; i++){
    mini = i;
    for(j = i+1 ; j < n ; j++){
      if(a[mini] > a[j]){
	mini = j;
      }
    }
    if(mini != i){
      tmp = a[i];
      a[i] = a[mini];
      a[mini] = tmp;
      ans++;
    }
  }

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

Measured memory_bytes: 600
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
using namespace std;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-10
#define PB push_back
#define fi first
#define se second
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
typedef pair<int,int> Pii;
typedef vector<int> vi;
class Data{
	public:
	char field[10][10];
	int cnt;
	Data(){}
	Data(char _field[10][10],int _cnt){
		cnt = _cnt;
		rep(i,10){
			rep(j,10){
				field[i][j] = _field[i][j];
			}
		}
	}
};
bool check(char stage[10][10],int w,int h){
	int top = stage[0][0];
	rep(i,h){
		rep(j,w){
			if(top != stage[i][j])return false;
		}
	}
	return true;
}
void copy(char sub[2][10][10],char stage[10][10],int w,int h){
	rep(i,h){
		rep(j,w){
			sub[0][i][j] = stage[i][j];
			sub[1][i][j] = stage[i][j];
		}
	}
	return ;
}
void dfs(int y,int x,bool memo[10][10],int w,int h,char stage[2][10][10],int col){
	rep(i,4){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(nx < 0 || nx > w-1 || ny < 0 || ny > h-1 || memo[ny][nx]==1 )continue;
		if(col == stage[0][ny][nx] || col == stage[1][ny][nx]){
			stage[0][ny][nx] = (col+1)%3;
			stage[1][ny][nx] = (col+2)%3;
			memo[ny][nx] = 1;
			dfs(ny,nx,memo,w,h,stage,col);
		}
	}
	return ;
}
int bfs(char stage[10][10],int w,int h){
	int ans = -1;
	queue < Data > Q;
	Q.push(Data(stage,0));
	while( !Q.empty() ){
		Data d = Q.front();Q.pop();
		if(check(d.field,w,h)){
			ans = d.cnt;
			break;
		}
		bool memo[10][10]={{0}};
		char sub[2][10][10]={{0}};
		copy(sub,d.field,w,h);
		memo[0][0] = 1;
		sub[0][0][0] = (d.field[0][0]+1)%3;
		sub[1][0][0] = (d.field[0][0]+2)%3;
		dfs(0,0,memo,w,h,sub,d.field[0][0]);
		Q.push(Data(sub[0],d.cnt+1));
		Q.push(Data(sub[1],d.cnt+1));
	}
	return ans;
}
int main(){
	int w,h;
	while(scanf("%d%d",&w,&h),w){
		char stage[10][10];
		rep(i,h){
			rep(j,w){
				char tmp;
				scanf(" %c",&tmp);
				stage[i][j] = ((tmp == 'R')? 0 : (tmp == 'G') ? 1 : 2);
			}
		}
		int ans = bfs(stage,w,h);
		printf("%d\n",ans);	
	}
	return 0;
}

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

int main(void){
	int a[31] = {0};
	int tmp;
	for(int i = 0; i < 28; i++){
		cin >> tmp;
		a[tmp] = 1;
	}
	for(int i = 1; i < 31; i++)
		if(a[i] == 0)
			cout << i << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    char abc[26];
    abc[0]='A';
    abc[1]='B';
    abc[2]='C';
    abc[3]='D';
    abc[4]='E';
    abc[5]='F';
    abc[6]='G';
    abc[7]='H';
    abc[8]='I';
    abc[9]='J';
    abc[10]='K';
    abc[11]='L';
    abc[12]='M';
    abc[13]='N';
    abc[14]='O';
    abc[15]='P';
    abc[16]='Q';
    abc[17]='R';
    abc[18]='S';
    abc[19]='T';
    abc[20]='U';
    abc[21]='V';
    abc[22]='W';
    abc[23]='X';
    abc[24]='Y';
    abc[25]='Z';

    int i;
    for(i=0; i<s.size(); i++){
        for(int j=0; j<26; j++){
            if(s[i]==abc[j]){
                s[i]=abc[(j+n)%26];
                break;
            }
        }
    }

     cout << s << endl;
}

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

long long a, b, c, d, m = 0;
const long long M = 1e9 + 7;
long long g[2000003], h[2000003];

long long pow(long long p, long long q) {
	long long r = 1, s = p;

	while (q) {
		if (q & 1)
			r = r * s % M;

		s = s * s % M;
		q >>= 1;
	}

	return r;
}

long long com(long long n, long long r) {
	return (g[n] * h[r] % M) * h[n - r] % M;
}

int main()
{
	cin >> a >> b >> c >> d;

	g[0] = 1;
	h[0] = 1;

	for (long long i = 1; i <= c + d + 2; i++) {
		g[i] = g[i - 1] * i % M;
		h[i] = pow(g[i], M - 2);
	}

	m = com(c + d + 2, c + 1);
	m = (m + com(a + b, b)) % M;
	m = (m + M - com(b + c + 1, b)) % M;
	m = (m + M - com(a + d + 1, a)) % M;

	cout << m << endl;
}


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

int main(){
  int N;
  cin >> N;
  int cnt=0;
  for(int i=1; i<=N; i++){
    if(i%2==0) continue;
    int div=0;
    for(int j=1; j<=i; j++){
      if(i%j==0) div++;
    }
    if(div==8) cnt++;
  }
  cout << cnt <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<pair<ll, ll>> A(N);
  ll a;
  for (int i = 0; i < N; i++) {
    cin >> a;
    A[i] = {a, i};
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++) {
    cout << A[i].second + 1 << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2432
/*  ex7_3
    L40S38  */
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int high,wide,i,j;
    //high,wide:マス目の縦,横の長さ
    char **cells;
    scanf("%d %d",&high,&wide);

    int *black_exist_high,*black_exist_wide;
    //black_exist_high:黒いマスがあった行番号を格納
    //black_exist_wide:黒いマスがあった列番号を格納

    //cellsのメモリを確保、もしできなければエラー出力
    cells=(char**)calloc(high,sizeof(char*));
    if(cells==NULL){
        printf("memory allocation error.");
        exit(1);
    }
    for(i=0;i<high;i++){
        cells[i]=(char*)calloc(wide,sizeof(char));
        if(cells[i]==NULL){
            printf("memory allocation error.");
            exit(1);
        }
    }
    
    //black_exist_highのメモリを確保、もしできなければエラー出力
    black_exist_high=(int*)calloc(high,sizeof(int));
    if(black_exist_high==NULL){
        printf("memory allocation error.");
        exit(1);
    }

    //black_exist_wideのメモリを確保、もしできなければエラー出力
    black_exist_wide=(int*)calloc(wide,sizeof(int));
    if(black_exist_wide==NULL){
        printf("memory allocation error.");
        exit(1);
    }
    for(i=0;i<high;i++){
        for(j=0;j<wide;j++){
            scanf(" %c",&cells[i][j]);
            if(cells[i][j]=='#'){
                black_exist_high[i]=1;
                black_exist_wide[j]=1;
                //黒いマスがあったらその行、列に印（1）をつける
            }
        }
    }

    for(i=0;i<high;i++){
        if(black_exist_high[i]==1){
            for(j=0;j<wide;j++){
                if(black_exist_wide[j]==1){
                    printf("%c",cells[i][j]);
                    //行・列の両方に印があった要素だけ出力
                }
            }
            printf("\n");
        }
        //不要になった部分のメモリの解放
        free(cells[i]);
    }

    //メモリの解放
    free(cells);
    free(black_exist_high);
    free(black_exist_wide);
    return 0;
}


Measured memory_bytes: 1676
b, = map(str, input().split())

alpha = [chr(ord('A') + i) for i in range(26)]
acgt = ["A","C","G","T"]
for i in acgt:
    alpha.remove(i)

for i in alpha:
    b = b.replace(i," ")
    words = b.split(" ")
    
const = 0
length = 0

for word in words:
    const = len(word)
    if const>length:
        length = const

print(length)
        

Measured memory_bytes: 3060
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimize("02")
#define pb push_back
#define F first
#define S second
using namespace std;
using ll =long long;
const ll maxn=2250,inf=1e18+18;
ll n,m,t,x;
bool b,mark[maxn];
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>x>>n;
	for(int i=0;i<n;i++){
		cin>>t;
		mark[t+150]=1;
	}
	for(int i=0;i<=10000;i++){
		if(!mark[x-i+150]){
			cout<<x-i;
			return 0;
		}
		if(!mark[x+i+150]){
			cout<<x+i;
			return 0;
		}
	}
}


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

#define LL long long
#define lowbit(x) ((x) & -(x))

const int maxn = (int) 1e5 + 20;
const int MOD = 998244353;

LL fp(LL a, LL n, LL m = MOD)
{
    LL res = 1;
    for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m;
    return res;
}

void work()
{
    int x, a;
    cin >>x >>a;
    if(x >= a) putchar('1');
    puts("0");
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
H = list(map(int, input().split()))
DP=[0]*N
if len(H)-1<K:
    K = len(H)-1
for i in range(1,K+1):
    DP[i] = abs(H[i]-H[0])
for i in range(K+1,N):
    kouho =[0]*K
    for j in range(K):
        kouho[j] = DP[i-j-1]+abs(H[i]-H[i-j-1])
    DP[i] = min(kouho)
print(DP[N-1])
    


Measured memory_bytes: 52448
#include <iostream>
#include <stdlib.h>
using namespace std;

int compare(const void* a, const void* b){return *((int*)b)-*((int*)a);}

int main(){
	int hight[10];
	for(int i =0;i<=9;i++) cin >> hight[i];
	qsort(hight,10,sizeof(int),compare);
	for(int i = 0;i<=2;i++) cout << hight[i] << endl;
	return 0;
	}

Measured memory_bytes: 0
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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)*}
    };
}

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

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

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

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    println!("{}", solve(&stdin!()));
}
fn solve(src: &str) -> String {
    input! {
        source = src,
        n:isize,
        k:isize,
    }
    let px = n % k;
    let mx = (px - k).abs();
    if px < mx { px } else { mx }.to_string()
}
test! {
    "7 4" => "1",
    "2 6" => "2",
    "1000000000000000000 1" => "0",
}


Measured memory_bytes: 2132
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, std::string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

signed main()
{
  int n = in();
  vi a(n); REP(i, n) a[i] = in() - 1;

  map<pii, int> chie;
  REP(i, n) {
    chie[mp(min(i, a[i]), max(i, a[i]))]++;
  }

  int ans = 0;
  for (auto v : chie) {
    if (v.Se == 2) ans++;
  }
  print(ans);

  return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

// 00000000-00000001 [  0,   1] [  0,   1]
// 00000010-00000011 [ -2,  -1] [ -2,   1]
// 00000100-00000111 [  2,   5] [ -2,   5]
// 00001000-00001111 [-10,  -3] [-10,   5]
// 00010000-00011111 [  6,  21] [-10,  21]
// 00100000-00111111 [-42, -11] [-42,  21]
// 01000000-01111111 [ 22,  85] [-42,  85]
// 10000000-11111111 [-170,-43] [-170, 85]

void solve(ll n, ll b) {
	ll c, m, v;
	if (n == 0) {
		REP(i, b+1) cout << "0";
		return;
	}
	if (n > 0) {
		m = (n+2)/4;
		c = 0;
		v = 1;
	} else {
		m = ((-n+1)/2+2)/4;
		c = 1;
		v = -2;
	}
	for (; m > 0; m = (m+2)/4, c += 2, v *= 4);
	REP(i, b-c) cout << "0";
	cout << "1";
	solve(n-v, c-1);
}

int main(int argc, char **argv) {
	ll n;
	cin >> n;
	solve(n, 0);
	cout << endl;
	return 0;
}


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

int main(){
  int a = 0, b = 0;
  
  for(int i = 0; i < 3; i++){
    int s;
    cin >> s;
    
    if(s == 5){
      a++;
    }
    else if(s == 7){
      b++;
    }
  }
  
  if(a == 2 && b == 1)
    cout << "YES" << endl;
  
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())

if a == b and a == c:
	if a % 2 == 1:
		print(0)
		exit()
	else:
		print(-1)
		exit()
	
ans = 0
s, t, u = 0, 0, 0
while a%2==0 and b%2==0 and c%2==0:
	s = b//2 + c//2
	t = a//2 + c//2
	u = a//2 + b//2
	a, b, c = s, t, u
	ans += 1
	
print(ans)

Measured memory_bytes: 3188
import sys
from collections import deque
input = sys.stdin.readline
n, q = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = list(map(lambda x: int(x)-1, input().split()))
    edges[a].append(b)
    edges[b].append(a)

values = [0]*n
for _ in range(q):
    p, x = map(int, input().split())
    values[p-1] += x

queue = deque([0])
visited = [0]*n
while queue:
    v = queue.pop()
    if visited[v]:
        continue
    visited[v] = 1
    for v2 in edges[v]:
        if visited[v2]:
            continue
        values[v2] += values[v]
        queue.append(v2)
print(*values)

Measured memory_bytes: 95892
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n, x;
    cin >> n >> x;
    set<int> st;
    int sum = 0;
    forn(i, n) {
        int v;
        cin >> v;
        sum += v;
        st.insert(v);
    }

    cout << n + max(x - sum, 0) / (*st.begin()) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int k = sc.nextInt();
        long sum = 0;
        for (int a = 1; a <= k; a++) {
            for (int b = 1; b <= k; b++) {
                for (int c = 1; c <= k; c++) {
                    sum += gcd(gcd(a, b), c);
                }
            }
        }
        out.println(sum);

        out.flush();
    }

    HashMap<Integer, Integer> map = new HashMap<>();
    int gcd(int a, int b) {
        if (map.containsKey(a * 1000 + b)) return map.get(a * 1000 + b);
        if (b == 0) {
            map.put(a * 1000 + b, a);
            return a;
        }
        int ret = gcd(b, a % b);
        map.put(a * 1000 + b, ret);
        return ret;
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 63956
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K = ii()

    ret = []
    for i in range(K + 1):
        if i == 0:
            ret.append(7 % K)
        else:
            ret.append((ret[i - 1] * 10 + 7) % K)
    for i in range(K + 1):
        if ret[i] == 0:
            print(i + 1)
            exit()
    else:
        print(-1)


if __name__ == '__main__':
    main()


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

const int maxn=200007;
int n,k,cnt;
int a[maxn],s[maxn];
map<int,int> p;
queue<int> q[maxn];
int main(){
    scanf("%d%d",&n,&k);
    for (int i=1;i<=n;++i){
        scanf("%d",&a[i]);
        a[i]=(a[i]-1)%k;
    }
    for (int i=1;i<=n;++i){
        s[i]=(s[i-1]+a[i])%k;
    }
    long long ans=0;
    for (int i=0;i<=n;++i){
        if (p.find(s[i])==p.end()) p[s[i]]=++cnt;
        while (q[p[s[i]]].size()&&q[p[s[i]]].front()<=i-k) q[p[s[i]]].pop();
        ans+=q[p[s[i]]].size();
        q[p[s[i]]].push(i);
    }
    printf("%lld\n",ans);
}

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

int main() {
  int a,b,c,d,num;
  cin >> a>>b>>c>>d;
  d=d/50;
  num=0;

  for(int i=0;i <c+1; i++){
  	for(int j=0; j < b+1;j++){
      for(int k=0; k < a+1;k++){
        if(d-(i+j*2+k*10)==0){
          num++;
        }
      }
  	}
  }
  cout << num <<endl;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
#define br "\n"
#define MAX  1000001
#define ff first
#define ss second

ll n,k;
vector<vll> pref;
vll c,p;
ll ans= -(ll)1*1e10;

void find_ans(ll x){
    ll cyc = k/(pref[x].size() - 1);
    ll rem = k % (pref[x].size() - 1);
    ll maxi = ans;
    rep(i,1,pref[x].size()){
        ll repet;
        if(i > rem) repet = cyc - 1;
        else repet = cyc;
        ll val;
        if(pref[x][pref[x].size() - 1] > 0) val = pref[x][i] + repet*(pref[x][pref[x].size() - 1]);
        else val = pref[x][i];
        ans = max(ans,val);
    }
}

void solve(){
    cin >> n >> k;
    pref.assign(n + 1,vll(1,0));
    c.resize(n + 1);
    p.resize(n + 1);
    rep(i,1,n + 1) cin >> p[i];
    rep(i,1,n + 1) cin >> c[i];
    rep(i,1,n + 1){
        ll j = i;
        while(p[j] != i){
            pref[i].pb(pref[i][pref[i].size() - 1] + c[p[j]]);
            j = p[j];
        }
        pref[i].pb(pref[i][pref[i].size() - 1] + c[p[j]]);
    }
    rep(i,1,n + 1) find_ans(i);
    cout << ans << br;

}
	

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif  

    ll t = 1;
    // cin >> t;
    rep(i,0,t){
        solve();
    }
 
}	

Measured memory_bytes: 218888
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)

    val n, m = sc.nextInt()

    val even = (m + 1) / 2
    val odd = m - even
    debug(even, odd)

    var oddLeft = 1
    var oddRight = oddLeft + odd * 2
    debug(oddLeft, oddRight)

    var evenLeft = oddRight + 1
    var evenRight = evenLeft + even * 2 - 1
    debug(evenLeft, evenRight)

    while (oddLeft < oddRight) {
      println(s"$oddLeft $oddRight")
      oddLeft += 1
      oddRight -= 1
    }

    while (evenLeft < evenRight) {
      println(s"$evenLeft $evenRight")
      evenLeft += 1
      evenRight -= 1
    }
  }

  @scala.annotation.tailrec
  def gcd(a: Int, b: Int): Int = {
    if (b == 0) a else gcd(b, a % b)
  }
  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }
}


Measured memory_bytes: 57112
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    R, G, B, N = map(int, input().split())

    ans = 0
    for r in range(3001):
        rest = N - r * R
        if rest < 0:
            break
        for g in range(3001):
            rest_2 = rest - g * G
            if rest_2 >= 0 and rest_2 % B == 0:
                ans += 1
                # print('r {}, g {}, b {}'.format(r, g, rest // B))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
program main;
var
  a, b, c : longint;
  poor : boolean;

begin
  readln(a, b, c);
  if ((a=b) and (a<>c)) or ((a=c) and (a<>b)) or ((b=c) and (a<>b)) then poor := true
  else poor := false;
  if poor then writeln('Yes')
  else writeln('No');

end.

Measured memory_bytes: 1372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	inline char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=gc();}
	}
};
using io::gi;
template<class IT>inline void _int(      IT &a,      IT &b  ){if(a>b)swap(a,b);}
template<class IT>inline void cmin(      IT &a,const IT &b=0){if(a>b)a=b;}
template<class IT>inline void cmax(      IT &a,const IT &b=0){if(a<b)a=b;}
template<class IT>inline IT   _min(const IT &a,const IT &b=0){return a>b? b:a;}
template<class IT>inline IT   _max(const IT &a,const IT &b=0){return a<b? b:a;}
template<class IT>inline IT   _abs(const IT &a              ){return a<0?-a:a;}

const int N=200005;

struct qwq{
	int a,b;
	inline qwq(){}
	inline qwq(int a,int b):a(a),b(b){}
	inline bool operator<(const qwq &x)const{return a<x.a;}
};

int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=9;++i)if(!(n%i)&&n<=i+(i<<3)){printf("Yes");return 0;}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] s = br.readLine().toCharArray();
        char[] t = br.readLine().toCharArray();
        int minCount = t.length, count = 0;
        for(int i=0; i<=s.length-t.length; i++) {
            int temp = 0;
            count = 0;
            while(temp < t.length) {
                if(s[temp+i] != t[temp])
                    count++;
                temp++;
            }
            minCount = Math.min(minCount, count);
        }
        System.out.println(minCount);
        br.close();
    }
}

Measured memory_bytes: 25692
import java.io.*;
import java.util.function.*;
import java.util.stream.*;

class Main
{
    /**
     * ABC 062 B: Picture Frame
     *     (周囲1ピクセルを'#'で囲む)
     */ 
    public static void main(String[] args) throws IOException
    {
        // 入力
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));
        int[] HW = Stream.of(br.readLine().split(" ")).mapToInt(
                item -> new Integer(item)).toArray();
        Stream<String> lines = br.lines();
        
        // データ部分を抽出
        Stream<String> a = lines.filter(item -> item.indexOf(" ") < 0);

        // 枠線を決める
        // Streamは同じインスタンスで2度処理を実行できないため、Supplierを通す
        Supplier<Stream<String>> frame = () ->
                Stream.of(new String(new char[HW[1]]).replace("\0", "#"));
        Stream<String> frameS = frame.get();
        Stream<String> frameE = frame.get();
        Stream<String> out = Stream.concat(frame.get(), Stream.concat(a, frame.get())).map(
                item -> "#" + item + "#") ;        

        // 出力(末尾は改行を入れない)
        System.out.print(out.collect(Collectors.joining("\n")).replaceFirst("\n$", ""));
    }
}


Measured memory_bytes: 28756
n,k=map(int,input().split())
h=list(map(int,input().split()))
h+=[0]*k
inf=float('inf')
dp=[inf]*(n+k)
dp[0]=0
for i in range(n):
    for j in range(1,k+1):
        dp[i+j]=min(dp[i]+abs(h[i]-h[i+j]),dp[i+j])
print(dp[n-1])


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

int main(){
    string s;
    cin >> s;
    long long n=s.size();
    long long cnt[26];
    fill(cnt,cnt+26,0);
    long long ans = 1;
    for(int i=0; i<n; i++){
        ans += cnt[s[i]-'a'];
        for(int j=0; j<26; j++){
            if(s[i]-'a' != j){
                cnt[j]++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import sys

A = list(map(int,sys.stdin.readline().rstrip()))

from itertools import product

X = ['+','-']
for a in product(X,repeat=3):
    b = A[0]
    for i in range(3):
        if a[i] == '+':
            b += A[i+1]
        else:
            b -= A[i+1]
    if b == 7:
        print(str(A[0])+a[0]+str(A[1])+a[1]+str(A[2])+a[2]+str(A[3])+'=7')
        break


Measured memory_bytes: 62196
#include <bits/stdc++.h>
using namespace std;
int main()
{long long i,k,sum,x,y,z,n,t,d,l,m,j;
cin>>n;
y=0;
for(i=1;i<=n;i++)
{cin>>x;
if(i%2==1&&x%2==1)y=y+1;}
cout<<y;
return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

ll memo[100001]={0};

ll rec(ll n);

int main(void) {
    double n, m, d;
    cin >> n >> m >> d;
    
    if(d==0)
        printf("%.10lf\n",(m-1)/n);
    else
        printf("%.10lf\n",(m-1)*2*(n-d)/(n*n));
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long x;
    scanf("%ld", &x);

    long max=1;
    long i, j;
    for(i=2; i<40; i++) {
        for(j=2; j<10; j++) {
            long tmp = (long)(pow((double)i,j)+0.1);
            if(tmp<=x) {
                if(tmp>max) max=tmp;
            }
            else break;
        }
    }
    printf("%ld\n", max);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

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

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    cout<<C<<" "<<A<<" "<<B;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int a = Integer.parseInt(str[1]);
		int b = Integer.parseInt(str[2]);
		String s = br.readLine();
		int cnt = 0;
		int foreign = 0;
		for(int i = 0; i < n; i++){
			char c = s.charAt(i);
			if(c=='c'){
				sb.append("No").append("\n");
				continue;
			}
			if(c=='a'){
				if(a+b>cnt){
					cnt++;
					sb.append("Yes").append("\n");
					continue;
				}else{
					sb.append("No").append("\n");
					continue;
				}
			}
			if(c=='b'){
				foreign++;
				if(a+b>cnt && foreign<=b){
					cnt++;
					sb.append("Yes").append("\n");
					continue;
				}else{
					sb.append("No").append("\n");
					continue;
				}
			}
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 14804
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    a = [];b = []
    for _ in range(N):
        x,y = map(int,input().split())
        a.append(x)
        b.append(y)
    
    a.sort()
    b.sort()
    if N%2 == 0:
        l = (a[N//2]+a[N//2-1])*2
        r = (b[N//2]+b[N//2-1])*2
        print((r-l)//2+1)
    else:
        l = a[N//2]
        r = b[N//2]
        print(r-l+1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 88196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll mo = 1000000007;
auto mod = [](ll modx) {modx%=mo;modx+=mo;modx%=mo;return modx; };
map<ll, ll> primefactor(ll n)
{
  map<ll, ll> div;
  ll nn = n;
  for (ll i = 2; i * i <= nn; i++)
  {
    if (n % i == 0)
    {
      div[i]++;
      n /= i;
      i--;
    }
  }
  if (n != 1)
    div[n]++;
  return div;
}
ll mypow(ll a, ll b)
{
  ll res = 1;
  a %= mo;
  while (b)
  {
    if (b & 1)
      res = res * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return res;
}
int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
map<ll,ll> m;
rep(i, n){
  cin >> a[i];
  auto r=primefactor(a[i]);
  for (auto i = r.begin(); i != r.end(); ++i)
  {
    if(m[i->first]<i->second)m[i->first]=i->second;
  }
}
ll k=1;
for (auto i = m.begin(); i != m.end(); ++i)
{
  rep(j,i->second)k=mod(k*i->first);
}
rep(i,n){
  ans=mod(ans+k*mypow(a[i],mo-2));
}
cout << ans << endl;
return 0;
}

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

int n,k,a,p;

int main(){
	scanf("%d%d%d",&n,&k,&a);
	while(a!=1)scanf("%d",&a),p++;
	printf("%.0f\n",ceil((float)(p)/(k-1))+ceil((float)(n-ceil((float)(p)/(k-1))*(k-1)-1)/(k-1)));
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    string s;
    int k;
    cin >> s;
    cin >> k;
    int len = (int)s.length();
    vector<int>S(len);
    rep(i,len){
        S[i] = 26-(s[i]-'a');
        if(S[i]==0)S[i]=26;
    }
    /*rep(i,len){
        cout << S[i] << endl;
    }*/
    rep(pos,len){
        if(S[pos]<=k&&S[pos]!=26&&pos!=len-1){
            k -= S[pos];
            S[pos] = 26;
        }else{
            if(pos == len-1){
                k= k%26;
                S[pos] = S[pos] - k;
                if(S[pos]<=0){
                    S[pos]+=26;
                }
            }
            
        }
    }
    rep(i,len){
        cout << (char)('a'+(26-S[i]));
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long

int main(){
    int N;
    cin>>N;
    vector<int>H(N);
    vector<bool>a(N);
    rep(i,N){
        cin>>H[i];
    }
    H[0]--;
    for(int i=0;i<N-1;i++){
        if(H[i]<H[i+1]){
            H[i+1]--;
        }
    }
    for(int i=0;i<N-1;i++){
        if(H[i]>H[i+1]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


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

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

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

    sort(A.begin(), A.end());
    
    int cost = 0;
    REP(i, 2){
        cost += A[i + 1] - A[i];
    }
    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int maxn=1000;
int main()
{
    int a[100000];
    int flag=0,n,k,q,m;
    scanf("%d%d%d",&n,&k,&q);
    memset(a,0,sizeof(a));
    for(int i=1;i<=n;i++){
        a[i]=k-q;
    }
    for(int i=0;i<q;i++){
        scanf("%d",&m);
        a[m]++;
    }
    for(int i=1;i<=n;i++){
        if(a[i]>0){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 1024