akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 
int main(void){
	int n,max =0,ans =0;
	scanf("%d",&n);
	char s[n];
	int flag_a[26];
	int flag_b[26];
	scanf("%s",&s);
	
	int i,j;
	for(i=0;i<n;i++){
		//flagの初期化
		for(j=0;j<26;j++){
		flag_a[j]=0;
		flag_b[j]=0;
		}
		//0からiまでにa-zがあるかどうか判別する
		for(j=0;j<i;j++){
			if( s[j] =='a')flag_a[0] =1;
			if( s[j] =='b')flag_a[1] =1;
			if( s[j] =='c')flag_a[2] =1;
			if( s[j] =='d')flag_a[3] =1;
			if( s[j] =='e')flag_a[4] =1;
			if( s[j] =='f')flag_a[5] =1;
			if( s[j] =='g')flag_a[6] =1;
			if( s[j] =='h')flag_a[7] =1;
			if( s[j] =='i')flag_a[8] =1;
			if( s[j] =='j')flag_a[9] =1;
			if( s[j] =='k')flag_a[10] =1;
			if( s[j] =='l')flag_a[11] =1;
			if( s[j] =='m')flag_a[12] =1;
			if( s[j] =='n')flag_a[13] =1;
			if( s[j] =='o')flag_a[14] =1;
			if( s[j] =='p')flag_a[15] =1;
			if( s[j] =='q')flag_a[16] =1;
			if( s[j] =='r')flag_a[17] =1;
			if( s[j] =='s')flag_a[18] =1;
			if( s[j] =='t')flag_a[19] =1;
			if( s[j] =='u')flag_a[20] =1;
			if( s[j] =='v')flag_a[21] =1;
			if( s[j] =='w')flag_a[22] =1;
			if( s[j] =='x')flag_a[23] =1;
			if( s[j] =='y')flag_a[24] =1;
			if( s[j] =='z')flag_a[25] =1;
		}
		//i+1からnまでにa-zがあるかどうか判別する
		for(j=i;j<n;j++){
			if( s[j] =='a')flag_b[0] =1;
			if( s[j] =='b')flag_b[1] =1;
			if( s[j] =='c')flag_b[2] =1;
			if( s[j] =='d')flag_b[3] =1;
			if( s[j] =='e')flag_b[4] =1;
			if( s[j] =='f')flag_b[5] =1;
			if( s[j] =='g')flag_b[6] =1;
			if( s[j] =='h')flag_b[7] =1;
			if( s[j] =='i')flag_b[8] =1;
			if( s[j] =='j')flag_b[9] =1;
			if( s[j] =='k')flag_b[10] =1;
			if( s[j] =='l')flag_b[11] =1;
			if( s[j] =='m')flag_b[12] =1;
			if( s[j] =='n')flag_b[13] =1;
			if( s[j] =='o')flag_b[14] =1;
			if( s[j] =='p')flag_b[15] =1;
			if( s[j] =='q')flag_b[16] =1;
			if( s[j] =='r')flag_b[17] =1;
			if( s[j] =='s')flag_b[18] =1;
			if( s[j] =='t')flag_b[19] =1;
			if( s[j] =='u')flag_b[20] =1;
			if( s[j] =='v')flag_b[21] =1;
			if( s[j] =='w')flag_b[22] =1;
			if( s[j] =='x')flag_b[23] =1;
			if( s[j] =='y')flag_b[24] =1;
			if( s[j] =='z')flag_b[25] =1;
		}
		for(j=0;j<26;j++){
			if( flag_a[j] == flag_b[j] && flag_a[j]==1){
				ans++;
			}
		}
		if( max < ans) max = ans;
		ans =0;
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	int n, m;
	cin >> n >> m;
	vi cand;
	for(int x = 1; x * x <= m ; ++x) {
		if(m%x == 0) {
			cand.pb(x);
			cand.pb(m/x);
		}
	}
	int ret = 1;
	rep(i,0,sz(cand)) {
		int x = cand[i];
		if(m/x >= n) {
			ret = max(ret, x);
		}
	}
	cout << ret << '\n';
	return 0;
}


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

int main(void)
{
  int a, b, c;
  std::cin >> a >> b >> c;

  int cnt = 3;
  if (a == b) {
    cnt--;

    if (b == c) {
      cnt--;
    }
  }
  else {
    if (b == c) {
      cnt--;
    }
    else if (a == c) {
      cnt--;
    }
  }
  std::cout << cnt << std::endl;
  
  return 0;
}

Measured memory_bytes: 3604
import numpy as np

n = int(input())
arr = list(map(int,input().split()))
d = {}

for a in arr:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1


if len(d) == 1:
    if 0 in d:
        print("Yes")
    else:
        print("No")
elif len(d) == 2:
    if n%3 != 0:
        print("No")
    elif 0 in d:
        flag = True
        for key in d.keys():
            if key == 0:
                if not d[key] == n//3:
                    flag = False
            else:
                if not d[key] == 2*n//3:
                    flag=False
        if flag:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

elif len(d) != 3:
    print("No")

else:
    if n % 3 != 0:
        print("No")
    elif 0 in d:
        print("No")
    else:
        tartar = [0,0,0]
        num = [0,0,0]
        temp = 0
        for key in d.keys():
            tartar[temp] = key
            num[temp] = d[key]
            temp+=1
        if not (num[0] == num[1] and num[1] == num[2]):
            print("No")
        else:
            tar2 = [
                [tartar[0], tartar[1], tartar[2]],
                [tartar[0], tartar[2], tartar[1]],
                [tartar[1], tartar[0], tartar[2]],
                [tartar[1], tartar[2], tartar[0]],
                [tartar[2], tartar[1], tartar[0]],
                [tartar[2], tartar[0], tartar[1]],

            ]
            flag = False
            for tar in tar2:
                x1 = tar[0]^tar[2]
                x2 = tar[0]^tar[1]
                x3 = tar[1]^tar[2]

                if x1 == tar[1] and x2 == tar[2] and x3 == tar[0]:
                    flag = True
            if flag:
                print("Yes")
            else:
                print("No")


Measured memory_bytes: 23896
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;
 
#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
int main(int argc, char **argv)
{
	string s; cin >> s;
	ll N = s.size();
 
	ll cnt{0};
	for (auto &c : s)
	{
		if (c == 'p')
			++cnt;
	}
 
	std::cout << N/2 - cnt << std::endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
double ans[200005];
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int lli;
int main()
{
    fio;
    int n;
    cin>>n;
    int a,b,c;
    cin>>a>>b>>c;
    int la=a,pa=1,lb=b,pb=b,lc=c,pc=c;
    int dp[n+1][3]={0};
    dp[0][0]=a;dp[0][1]=b;dp[0][2]=c;

        for(int i=1;i<n;i++)
        {

            int in[3];
            cin>>in[0]>>in[1]>>in[2];
            for(int j=0;j<3;j++)
            {

                for(int k=0;k<3;k++)
                {
                    if(j!=k)
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+in[j]);
                }
               // cout<<dp[i][j]<< " ";
            }
            //cout<<"\n";


        }

        cout<<*max_element(dp[n-1],dp[n-1]+3);
    return 0;
}


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


int main(){
    int n;  cin >> n;
    map<pair<string, int>, int> v;
    for(int i=0; i<n; i++){
        string a; int b;   cin >> a >> b;
        v[{a, -b}]= i;
    }

    for(auto x:v)
        cout << x.second+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    char sym;
    long long a, b;
    do {
        cin >> a >> sym >> b;
        if (sym == '+') {
            cout << a + b;
        } else if (sym == '-') {
            cout << a - b;
        } else if (sym == '*') {
            cout << a * b;
        } else if (sym == '/') {
            cout << a / b;
        } else if (sym == '?') {
            break;
        }
        cout << '\n';
    } while (true);
    return 0;
}


Measured memory_bytes: 3092
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
string s[50];
int dis[50][50]; 
int h,w;
struct st{
	int x,y,temp;
	st() {
		temp=0;
	}
};
int vis[50][50];
void out() {
	cout<<"****\n";
	for(int i=1;i<=h;i++) {
		for(int j=1;j<=w;j++) {
			cout<<dis[i][j]<<' ';
		}
		cout<<'\n';
	}
	cout<<"****\n";
}
int bfs(int x,int y) 
{
	memset(dis,0x3f,sizeof dis);
	memset(vis,0,sizeof(vis));
	struct st node;
	node.x=x,node.y=y,node.temp=0;
	queue<st>q;
	q.push(node);
	vis[x][y]=1;
	dis[x][y]=1;
	while(q.size()) {
		auto t=q.front();
		q.pop();
		for(int i=0;i<4;i++) {
			int xx=t.x+dx[i];
			int yy=t.y+dy[i];
			if(xx<1||xx>h||yy<1||yy>w) continue;
			if(s[xx][yy]=='#') continue;
 			if(dis[xx][yy]>t.temp+1) {
				dis[xx][yy]=t.temp+1;
				if(!vis[xx][yy]) {
					vis[xx][yy]=1;
					node.x=xx,node.y=yy,node.temp=t.temp+1;
					q.push(node);
				}
			} 
		}
	}
	int mx=0;
	for(int i=1;i<=h;i++) {
		for(int j=1;j<=w;j++) {
			if(dis[i][j]!=0x3f3f3f3f&&s[i][j]!='#') mx=max(mx,dis[i][j]);
		}
	}
//	out();
	return mx;
}
int Xiaobo()
{
	cin>>h>>w;
	for(int i=1;i<=h;i++) {
		cin>>s[i];
		s[i]=" "+s[i];
	}
	int ans=0;
	for(int i=1;i<=h;i++) {
		for(int j=1;j<=w;j++) {
		//	cout<<s[i][j]<<' ';
			if(s[i][j]=='.') ans=max(ans,bfs(i,j)); 
		}
		//cout<<'\n';
	}
	cout<<ans<<'\n';
	return 0;	
}

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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m = 0; cin >> n;
    map<int, int> ma;
    rep (i, n) {
        int a; cin >> a;
        ma[a]++;
    }
    for (auto p : ma) m += p.second - 1;
    cout << n - m - m % 2 << "\n";
    return 0;
}

Measured memory_bytes: 8256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
    int n; cin >> n;
    vector<string> S(n);
    for (int i = 0; i < n; i++) {
        cin >> S[i];
        sort(S[i].begin(), S[i].end());
    }

    sort(S.begin(), S.end());
    ll out = 0;
    ll cnt = 1;
    string pat = S[0];
    for (int i = 1; i < n; i++) {
        if (pat != S[i]) {
            if (cnt > 1) out += cnt * (cnt - 1) / 2;
            cnt = 1;
            pat = S[i];
        } else {
            cnt++;
        }
    }
    if (cnt > 1) out += cnt * (cnt - 1) / 2;

    cout << out << endl;
}


Measured memory_bytes: 7296
#![allow(unused)]

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Self {
        Self { reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get_str(&mut self) -> &str {
        if let Some(t) = self.iter.next() {
            return t;
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get_str()
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        self.get_str().parse().ok().expect("Parse error")
    }
}

fn main() {
    let stdin = std::io::stdin();
    solve(Scanner::new(stdin.lock()));
}

fn solve<R: std::io::BufRead>(mut sc: Scanner<R>) {
    let n: usize = sc.get();
    let k: usize = sc.get();
    let teleps: Vec<usize> = (0..n).map(|_| sc.get()).collect();

    let mut visited = vec![false; n];
    let mut lead = vec![];
    let mut city = 0;
    loop {
        if visited[city] {
            break;
        }
        visited[city] = true;
        lead.push(city);
        city = teleps[city] - 1;
    }

    let looppos = lead.iter().position(|&c| c == city).unwrap();
    let cityloop: Vec<usize> = lead[looppos..].iter().cloned().collect();

    if k < lead.len() {
        println!("{}", lead[k] + 1);
    } else {
        println!("{}", cityloop[(k - lead.len()) % cityloop.len()] + 1);
    }
}


Measured memory_bytes: 8076
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x->left!=NIL){
    x=x->left;
  }
  return x;

}

Node treeMaximum(Node x){

  while(x->right!=NIL){
    x=x->right;
  }
  return x;

}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;
  if(k<u->key){
    return treeSearch(u->left,k);
  }
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)
    return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL || z->right==NIL)
    y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL) x=y->left;
  else x=y->right;

  if(x!=NIL) x->parent=y->parent;
  if(y->parent==NIL) root=x;
  else if(y==y->parent->left) y->parent->left=x;
  else y->parent->right=x;

  if(y!=z) z->key=y->key;
  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }

  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key<y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }


}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

 
  return 0;
}



Measured memory_bytes: 25136
#!/usr/bin/python

def input_datas():
    n = int(input())
    h = int(input())
    w = int(input())
    return (n, h, w)

def main():
    n, h, w = input_datas()
    print((n-w+1) * (n-h+1))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool comp(pair<int,int> p1,pair<int,int> p2)
{
	if(p1.first!=p2.first)return p1.first<p2.first;
	else return p1.second>p2.second;
}
main()
{
	int n,m;
	while(cin>>n>>m,n)
	{
		vector<pair<int,int> > A(m,make_pair(0,0));
		for(int i=0;i<m;i++)A[i].second=i+1;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				int a;cin>>a;
				if(a)A[j].first++;
			}
		}
		sort(A.begin(),A.end(),comp);
		for(int i=m;i--;)cout<<A[i].second<<(i?" ":"\n");
	}
}

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

int main()
{
    int N,M;
    cin >> N >> M;
    
    priority_queue<int> Ai;
	rep(i,N){
        int tmpAi;
		cin >> tmpAi;
        Ai.push(tmpAi);
	}

    rep(i,M){
        int MAXYEN = Ai.top();
        Ai.pop();
        Ai.push(MAXYEN / 2);
    }

    int64_t sum = 0;
    while (!Ai.empty()) {
        sum += Ai.top();
        Ai.pop();
    }

    cout << sum << endl;
    return 0;
}


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

const ll INF = 2000000000000000000;

int main()
{
    int n;
    cin >> n;
    ll a[100005];
    ll ans = 1;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    for(int i = 0; i < n; i++){
        if(INF / a[i] < ans){
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
        if(ans > INF / 2){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4404
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int ans = 0;
  string s;

  cin >> s;

  int l = s.size();
  int tmp = 0;
  // if(l == 1)l++;
  for(int i = 0; i < l; i++){
    if(s[i] == 'A' 
        || s[i] == 'C' 
        || s[i] == 'G' 
        || s[i] == 'T' )
    {
      tmp++;
    }else{
      ans = max(ans, tmp);
      tmp = 0;
    }

    if(i == (l-1)){
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 3608
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int n;
ll memo[110][5][5][5] = {0};
ll dp(int now, int last1, int last2, int last3){
    if(now == n) return 1;
    if(memo[now][last1][last2][last3] != -1){
        return memo[now][last1][last2][last3];
    }

    ll res = 0;
    for(int i = 1; i < 5; i++){
        // if(last1 == 3 || last2 == 2 || last3 == 1) continue;
        // if(last1 == 3 || last2 == 1 || last3 == 2) continue;
        // if(last1 == 2 || last2 == 3 || last3 == 1) continue;
        if(i == 3 && last1 == 2 && last2 == 1) continue;
        if(i == 3 && last1 == 1 && last2 == 2) continue;
        if(i == 3 && last2 == 2 && last3 == 1) continue;
        if(i == 3 && last1 == 2 && last3 == 1) continue;
        if(i == 2 && last1 == 3 && last2 == 1) continue;
        res += dp(now + 1, i, last1, last2);
        res %= MOD;
    }
    return memo[now][last1][last2][last3] = res;

}
int main(void){
    cin >> n;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j < 5; j++){
            for(int k = 0; k < 5; k++){
                for(int l = 0; l < 5; l++){
                    memo[i][j][k][l] = -1; 
                }
            }
        }
    }
    cout << dp(0, 0, 0, 0) << endl;
}

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

signed main(void)
{
	string s;
	ll cnt;
	cin >> s;
	cnt = 0;
	rep(i, s.size())
		cnt += s[i] - '0';
	if (cnt % 9 == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3752
H, W = map(int, input().split())
if H > W:
    tmp = H
    H = W
    W = tmp

if H%3 == 0 or W%3 == 0:
    print(0)
else:
    w1 = W//3
    w2 = w1+1
    rw1 = W - w1
    rw2 = W - w2
    h1 = H//2
    h2 = H - h1
    s11 = H * w1
    s12 = rw1 * h1
    s13 = rw1 * h2
    diff1 = max(abs(s11-s12), abs(s12-s13), abs(s13-s11))
    s21 = H * w2
    s22 = rw2 * h1
    s23 = rw2 * h2
    diff2 = max(abs(s21-s22), abs(s22-s23), abs(s23-s21))
    delta1 = min(diff1, diff2)

    s31 = w1 * H
    s32 = s31
    s33 = (W - 2 * w1) * H
    delta2 = abs(s33 - s31)

    s41 = w2 * H
    s42 = s41
    s43 = (W - 2 * w2) * H
    delta3 = abs(s43 - s41)
    
    tmp = H
    H = W
    W = tmp
    
    w1 = W//3
    w2 = w1+1
    rw1 = W - w1
    rw2 = W - w2
    h1 = H//2
    h2 = H - h1
    s11 = H * w1
    s12 = rw1 * h1
    s13 = rw1 * h2
    diff1 = max(abs(s11-s12), abs(s12-s13), abs(s13-s11))
    s21 = H * w2
    s22 = rw2 * h1
    s23 = rw2 * h2
    diff2 = max(abs(s21-s22), abs(s22-s23), abs(s23-s21))
    delta4 = min(diff1, diff2)

    s31 = w1 * H
    s32 = s31
    s33 = (W - 2 * w1) * H
    delta5 = abs(s33 - s31)

    s41 = w2 * H
    s42 = s41
    s43 = (W - 2 * w2) * H
    delta6 = abs(s43 - s41)    

    print(min(delta1, delta2, delta3, delta4, delta5, delta6))
    


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

#define int long long
#define inf (int)1000000007

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n); i >= 0; i--)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
#define rfor(i, s, t) for(int i = (t) - 1; i >= (s); i--)

int a[114514];

int gcd(int a, int b) {
  if(a % b == 0) {
    return b;
  }
  return gcd(b, a % b);
}

bool solve(int n) {
  int g = 0;
  int o = 0;
  rep(i, n) {
    if(a[i] % 2 == 0) {
      g++;
    }
  }
  if(g % 2 == 1) {
    return true;
  }
  else if(g == n - 1) {
    int y;
    if(a[0] % 2 == 0) {
      y = a[0];
    }
    else {
      if(a[0] == 1) {
        return false;
      }
      y = a[0] - 1;
    }
    mfor(i, 1, n) {
      if(a[i] % 2 == 0) {
        y = gcd(y, a[i]);
      }
      else {
        if(a[i] == 1) {
          return false;
        }
        y = gcd(y, a[i] - 1);
      }
    }
    rep(i, n) {
      a[i] /= y;
    }
    return !solve(n);
  }
  else {
    return false;
  }
}

signed main() {
  int n;
  cin >> n;
  rep(i, n) {
    cin >> a[i];
  }
  if(solve(n)) {
    cout << "First" << endl;
  }
  else {
    cout << "Second" << endl;
  }
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt(), x = sc.nextInt();
        int[] c = new int[n];
        int[][] a = new int[n][m];
        for(int i=0;i<n;i++){
            c[i] = sc.nextInt();
            for(int j=0;j<m;j++){
                a[i][j] = sc.nextInt();
            }
        }

        //2^12=4096なので総当たりでいい。

        int size = (int)Math.pow(2, n);
        int[] bin = new int[n];
        for(int i=0;i<n;i++){
            bin[i] = (int)Math.pow(2, i);
        }

        int[] skill;
        int expense;
        int min = 99999999;
        for(int i=0;i<size;i++){
            skill = new int[m];
            expense = 0;
            for(int j=0;j<n;j++){
                if((i & bin[j]) == 0){
                    continue;
                }
                expense += c[j];
                for(int k=0;k<m;k++){
                    skill[k] += a[j][k];
                }
            }

            for(int k=0;k<m;k++){
                if(skill[k] < x){
                    break;
                }
                if(k == m-1 && expense < min){
                    min = expense;
                }
            }
        }
        System.out.println(min == 99999999 ? -1 : min);
    }
}

Measured memory_bytes: 28504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
set<pi> st;
int n,q;
multiset<int> ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> q;
    for(int i=1;i<=n;i++)
    {
        int s,t,x;
        cin >> s >> t >> x;
        st.insert({s-x, -x});
        st.insert({t-x, x});
    }
    auto it = st.begin();
    for(int i=1;i<=q;i++){
        int d;
        cin >> d;
        while(it != st.end() && d >= it->first)
        {
            if(it->second > 0)
            {
                auto it2 = ans.find(it->second);
                ans.erase(it2);
            }
            else
                ans.insert(-(it->second));
            it++;
        }
        if(ans.empty()) cout << "-1\n";
        else cout << *ans.begin() << '\n';
    }
}

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

int main(){
  int n,p;
  int w, ss[50], i;

  while( true ){
    cin >> n >> p;
    if( !n && !p ) break;

    w = p;
    for( i=0;i<n;i++ ) ss[i]=0;

    i=0;
    while( true ){
      if( w>0 ){
	w--; ss[i]++;
	if( ss[i]==p ){
	  cout << i << endl;
	  break;
	}
      }else{
	w+=ss[i]; ss[i]=0;
      }
      i = (i+1)%n;
    }
  }
  return 0;
}

Measured memory_bytes: 864
#include<bits/stdc++.h>
using namespace std;
int main()
{  string str;
    cin>>str;
    if(str.size()%2!=0)
    {cout<<"No";exit(0);}
    else
    {  for(int i=0;i<str.size();i++)
        {  if(i%2==0)
            {  if(str[i]!='h')
                {cout<<"No";exit(0);}
            }
            else
            {if(str[i]!='i')
                {cout<<"No";exit(0);}}
        }cout<<"Yes";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long

using namespace std;

int N,A,B,C,D;
int main(){
    cin >> N >> A >> B >> C >> D;
    A--;
    B--;
    C--;
    D--;
    string S;
    cin >> S;
    int cnt;
    int tobi=0;
    
    for(int i=B-1;i<D-1;i++){
        cnt=0;
        while(S[i]==S[i+1]&&S[i]=='.'){
            cnt++;
            i++;
        }
        if(cnt==2){
            tobi++;
        }
    }
    
    //戦闘
    if(C<D){
        for(int i=B;i<D;i++){
            if(S[i]=='#'){
                if(S[i+1]=='#'){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        S[D]='#';
        for(int i=A;i<C;i++){
            if(S[i]=='#'){
                if(S[i+1]=='#'){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        cout << "Yes" << endl;
    }
    else if(tobi>0){
        for(int i=A;i<C;i++){
            if(S[i]=='#'){
                if(S[i+1]=='#'){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        S[C]='#';
        for(int i=B;i<D;i++){
            if(S[i]=='#'){
                if(S[i+1]=='#'){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        cout << "Yes" << endl;
    }
    else if(S[D-1]=='#'||S[D+1]=='#'){
        cout << "No" << endl;
    }
    else{
        for(int i=B;i<D;i++){
            if(S[i]=='#'){
                if(S[i+1]=='#'){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        S[D]='#';
        for(int i=A;i<C;i++){
            if(S[i]=='#'){
                if(S[i+1]=='#'){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main(void) {

    ld r; cin >> r;
    ld ans = r * 6.28318530717958623200;
    printf("%.12Lf\n", ans);
    


    


    return 0;
}











Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;



int main(){
int n; cin>>n;
int a[n]; REP(i,n)cin>>a[i];
ll min_sum=pow(200,2)*100;
FOR(b,-100,101){
  int sum=0;
  REP(i,n)sum+=pow(a[i]-b,2);
  if(sum<=min_sum)min_sum=sum;
}

cout<<min_sum<<endl;
}



Measured memory_bytes: 256
H = int(input())
W = int(input())
M = int(input())

if H <= W:
    for i in range(1, H + 1):
        if W * i >= M:
            print(i)
            break
            
else:
    for k in range(1, W + 1):
        if H * k >= M:
            print(k)
            break

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1), b(n);
    for (int i = 0; i <= n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] <= b[i]) {
            ans += a[i];
            b[i] -= a[i];
            if (a[i+1] <= b[i]) {
                ans += a[i+1];
                a[i+1] = 0;
            } else {
                ans += b[i];
                a[i+1] -= b[i];
            }
        } else {
            ans += b[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4004
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-100
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
map<char, int> mp{ {'B', 0}, {'R', 1}, {'G', 2} };
vi arr[3];
int main() {
//	file();
	fast();
	int n; cin >> n;
	string str; cin >> str;
	for (int i = 0; i < n; i++) {
		arr[mp[str[i]]].push_back(i);
	}
	ll Last = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (str[i] == str[j]) continue;
			int num = 0;
			for (int k = 0; k < 3; k++)
				if (k != mp[str[i]] && k != mp[str[j]])
					num = k;
			int start = 0, end = sz(arr[num]) - 1, mid, ans = 0;
			while (start <= end) {
				mid = (start + end) / 2;
				if (arr[num][mid] < j) {
					start = mid + 1;
				}
				else {
					end = mid - 1;
					ans = sz(arr[num]) - mid;
				}
			}
			ans -= binary_search(all(arr[num]), j + (j - i));
			Last += ans;
		}
	}
	cout << Last << endl;
	return 0;
}

Measured memory_bytes: 3684
from sys import stdin,stdout
inp = stdin.readline
out = stdout.write
n,K = map(int,inp().split())
h = list(map(int,inp().split()))
dp = [0 for i in range(n)]
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
    dp[i] = 99999999999
    for k in range(1,K+1):
        if i-k<0: break
        if dp[i-k]+abs(h[i]-h[i-k]) < dp[i]:
            dp[i] = dp[i-k]+abs(h[i]-h[i-k])

out(str(dp[n-1]))

Measured memory_bytes: 56540
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  vector<pair<ll, pair<ll,ll>> > a(n);
  REP(i,n){
      ll aa,bb;cin >> aa >> bb ;
      a[i] = mp(aa+bb,mp(aa,bb));
  }
  sort(all(a) , greater<pair<ll,pair<ll,ll>>>());
  ll ans = 0;
  REP(i,n){
      if(i%2==0)
      ans += a[i].second.first;
      else
      ans -= a[i].second.second;
  }
  cout << ans << endl;


}

Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
int H,W;
int N;
int ans[10000];

void print_(){
  for(int i=0;i<H*W;i++){
    printf("%d",ans[i]);
    if(i%(W)==W-1)printf("\n");
    else printf(" ");
  }
}
int main(){
  cin >> H >> W;
  cin >> N;
  vector<pair <int,int> > color;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    pair <int,int> p;
    p.first=a;
    p.second=i;
    color.push_back(p);
  }
  //sort(color.begin(),color.end());
  
  int pos=0;
  int d=0;//right=0 left=1
  for(int i=0;i<color.size();i++){
    int x=color[i].first,y=color[i].second+1;
    while(x>0){
      ans[pos]=y;
      x--;
      if(d==0){
	if(pos%(W)==W-1){
	  pos+=(W);
	  d=1;
	}
	else pos++;
      }
      else{
	if(pos%(W)==0){
	  pos+=(W);
	  d=0;
	}
	else pos--;
      }
    }
  }
  print_();
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"

#define oa(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define o1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define o2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define o3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define o4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	string s;
    cin>>s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
        cout<<"Yes";
    }else{
        cout<<"No";
    }








	
return 0;
}


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

int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll> x(m);
  for(int i=0;i<m;i++){
    cin >> x[i];
  }
  sort(x.begin(),x.end());
  vector<ll> cost(m-1);
  ll total_cost=0;
  for(int i=1;i<m;i++){
    cost[i-1] = x[i] - x[i-1];
  }
  sort(cost.begin(),cost.end());
  for(int i=0;i<m-n;i++){
    total_cost += cost[i];
  }
  cout << total_cost << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[16][1<<16];
signed main(){
  int n,m,l,t,s;
  while(cin>>n>>m>>l>>s>>t,n){
    s--;
    int a[m],b[m],c[m];
    for(int i=0;i<m;i++) cin>>a[i]>>b[i]>>c[i];
    int d[l],e[l];
    for(int i=0;i<l;i++) cin>>d[i]>>e[i];
    int INF=1LL<<55LL;
    int g[n][n];
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	g[i][j]=INF*(i!=j);
    for(int i=0;i<m;i++){
      a[i]--;b[i]--;
      g[a[i]][b[i]]=g[b[i]][a[i]]=c[i];
    }
    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
    map<int,int> mi;
    for(int i=0;i<l;i++){
      d[i]--;
      mi[d[i]]=i;
    }
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<l;i++)
      dp[i][1<<i]=g[s][d[i]]+e[i];
    int ans=0;
    for(int b=0;b<(1<<l);b++){
      for(int i=0;i<l;i++){
	if(dp[i][b]<0||dp[i][b]>t) continue;
	//cout<<i<<" "<<b<<endl;
	if(dp[i][b]+g[d[i]][s]<=t)
	  ans=max(ans,(int)__builtin_popcountll(b));
	for(int j=0;j<l;j++){
	  if((b>>j)&1) continue;
	  if(dp[j][b+(1<<j)]<0||dp[j][b+(1<<j)]>dp[i][b]+g[d[i]][d[j]]+e[j])
	    dp[j][b+(1<<j)]=dp[i][b]+g[d[i]][d[j]]+e[j];
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 12076
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(std::string A){
    map<char, ll> rec;
    REP(i, A.length()){
        rec[A[i]]++;
    }
    vll cnt;
    for(auto x: rec){
        cnt.push_back(x.second);
    }
    ll M = cnt.size();
    ll ans = 0;
    REP(i, M){
        for(ll j = i+1; j < M; j++){
            ans += cnt[i] * cnt[j];
        }
    }
    cout<<ans+1<<endl;
}

int main(){
    std::string A;
    std::cin >> A;
    solve(A);
    return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> h(N);
	for (int i = 0; i < N; i++) cin >> h[i];
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (K <= h[i])cnt++;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int x[5];
    int num=-1;
    rep(i,0,5){
        cin>>x[i];
        if(x[i]==0)num=i+1;
    }
    cout<<num<<endl;
}


Measured memory_bytes: 3608
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

#define rep(i,n) for(int i=0; i<int(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll d[200010],sum[200010];
map<ll,int>m;

int main() {
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> d[i];
	}
	sum[0] = 0;
	int  mx = 0;
	for (int i = 1; i <= N; i++) {
		sum[i] = sum[i - 1] + d[i];
		if(m.find(sum[i]) == m.end()){ //not found
		  m[sum[i]] = i;
		}else{
		  int j = m[sum[i]];
		  mx = max(mx,i-j);
		}
		if(sum[i] == 0)
		  mx = max(mx,i);
	}
	cout << mx << endl;
	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var raw = ReadLine().Split().Select(int.Parse).ToArray();
            WriteLine(raw[2] + " " + raw[0] + " " + raw[1]);
        }
    }
}


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

int main()
{
  string s;
  int ans = 26;
  vector<int> v(26, 0);

  cin >> s;
  for (auto c: s)
    v[c - 'a']++;
  for (int i = 0; i < 26; i++)
  {
    if (!v[i])
    {
      ans = i;
      break;
    }
  }
  if (ans == 26)
    cout << "None" << endl;
  else
    cout << (char)(ans + 'a') << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	char s[5];
	scanf("%s", s);
  	sort(s, s + 4);
  	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) printf("Yes");
  	else printf("No");
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  int n, k, j;
  int num = 1;
  int i = 0;
  cin >> n;
  cin >> k;
  while(k >= pow(2, i)) i++;
  int temp = i;
  if(i > n) temp = n;
  for(j = 0; j < temp; j++) num *= 2;
  for(j = i; j < n; j++) num += k;
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
program main;
var
    n, k, i, j, t1, t2, ans : integer;
    e : array[1..100] of boolean;
begin
    readln(n, k);

    for i := 1 to n do
        e[i] := true;

    ans := n;
    for i := 1 to k do begin
        readln(t1);
        for j := 1 to t1 do begin
            read(t2);
            if (e[t2]) then begin
                e[t2] := false;
                ans := ans - 1;
            end;
        end;
    end;

    writeln(ans);
end.

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, m;
vector<int> g[100005];
int col[100005];

bool ok;
int sz;

void dfs(int v, int c) {
    if (col[v] != -1) {
        if (col[v] != c) {
            ok = false;
        }
        return;
    }
    ++sz;
    col[v] = c;
    for (int to : g[v]) {
        dfs(to, c ^ 1);
    }
}

vector<int> s;
int cnt, bp;

int main() {
    scanf("%d%d", &n, &m);
    forn(i, m) {
        int from, to;
        scanf("%d%d", &from, &to), --from, --to;
        g[from].pb(to);
        g[to].pb(from);
    }
    memset(col, -1, sizeof col);
    cnt = 0;
    bp = 0;
    int sum = 0;
    forn(i, n) if (col[i] == -1) {
        ok = true;
        sz = 0;
        dfs(i, 0);
        if (sz == 1) {
            continue;
        }
        sum += sz;
        s.pb(sz);
        ++cnt;
        if (ok) {
            ++bp;
        }
    }
    LL ans = (LL)n * n;
    ans -= (LL)sum * sum;
    ans += (LL)cnt * cnt;
    ans += (LL)bp * bp;
    //cerr << sum << ' ' << cnt << ' ' << bp << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8960
N = int(input())
F= [list(map(int, input().split())) for _ in range(N)]
P= [list(map(int, input().split())) for _ in range(N)]

ans = -10000000000
for mask in range(1, 2**10):
    tmp = 0
    for j in range(N):
        cnt = 0
        for k in range(10):
            if((mask>>k)%2 == 1 and F[j][k] == 1):
                cnt += 1
        tmp += P[j][cnt]
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 3064