akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#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 pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 100010
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}

vi g[N];
int dp[N],d[N];
int main(){
    //srand(time(NULL)+clock());
    int ca=0,T,k,i,j,m=0,K,n;
    double start=clock();
    scanf("%d%d",&n,&m);
    rep(i,0,m){
        scanf("%d%d",&j,&k),j--,k--;
        g[j].pb(k);d[k]++;
    }
    queue<int>q;
    rep(i,0,n)if(d[i]==0)q.push(i);
    while(!q.empty()){
        int u=q.front();q.pop();
        for(auto &v:g[u]){
            d[v]--;
            if(d[v]==0)Max(dp[v],dp[u]+1),q.push(v);
        }
    }
    int ans=0;
    rep(i,0,n)Max(ans,dp[i]);
    printf("%d\n",ans);
    cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}


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


int main(){
	ll n;
	cin >> n;
	string ans;
	while(n>26){
		int x = n%26;
		n=n/26;
		if(x==0){
			ans.insert(0,"z");
			n--;
		}
		else{
			string i;
			i.push_back((char) (x+96));
			ans.insert(0,i);
		}
	}
	string j;
	j.push_back((char)(n+96));
	ans.insert(0,j);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

const int N = 1e5 + 10;

int n, d[3];
int a[3][N], step[N];

int finddif(int x, int y) {
    for (int i = 0; i < 3; i++)
        if (a[i][x] && i != y)
            return i;
}

void findp(int x, int &p0, int &p1) {
    if (!a[0][x]) p0 = 1, p1 = 2;
    if (!a[1][x]) p0 = 0, p1 = 2;
    if (!a[2][x]) p0 = 0, p1 = 1;
}

void solve(int p0, int p1, int p2) {
//    fill(step, step + n, 0);
    int t[3];
    t[0] = d[0]; t[1] = d[1]; t[2] = d[2];
    for (int i = 0; i < n; i++) {
        if (a[p0][i]) {
            t[p0]++; t[finddif(i, p0)]--;
            step[i] = p0;
        } else {
            t[p1]++; t[finddif(i, p1)]--;
            step[i] = p1;
        }
        if (t[0] < 0) return;
        if (t[1] < 0) return;
        if (t[2] < 0) return;
    }
    puts("Yes");
    for (int i = 0; i < n; i++)
        cout << (char)(step[i] + 'A') << endl;
    exit(0);
}

void Try1() {
//    fill(step, step + n, 0);
    int t[3];
    t[0] = d[0]; t[1] = d[1]; t[2] = d[2];
    for (int i = 0; i < n; i++) {
        int x, y;
        findp(i, x, y);
        if (!t[x] || !t[y]) {
            if (!t[x]) swap(x, y);
            t[x]++; t[y]--;
            step[i] = x;
        } else {
            if (rand() % 2) swap(x, y);
            t[x]++; t[y]--;
            step[i] = x;
        }
        if (i != n - 1) {
            int x2, y2;
            findp(i + 1, x2, y2);
            if (!t[x2] && !t[y2]) {
                step[i] = y;
                t[x] -= 2; t[y] += 2;
            }
        }
        if (t[0] < 0) return;
        if (t[1] < 0) return;
        if (t[2] < 0) return;
    }
    puts("Yes");
    for (int i = 0; i < n; i++)
        cout << (char)(step[i] + 'A') << endl;
    exit(0);
}

void Try2() {
//    fill(step, step + n, 0);
    int t[3];
    t[0] = d[0]; t[1] = d[1]; t[2] = d[2];
    for (int i = 0; i < n; i++) {
        int x, y;
        findp(i, x, y);
        if (t[x] > t[y]) swap(x, y);
        t[x]++; t[y]--;
        step[i] = x;
        if (i != n - 1) {
            int x2, y2;
            findp(i + 1, x2, y2);
            if (!t[x2] && !t[y2]) {
                step[i] = y;
                t[x] -= 2; t[y] += 2;
            }
        }
        if (t[0] < 0) return;
        if (t[1] < 0) return;
        if (t[2] < 0) return;
    }
    puts("Yes");
    for (int i = 0; i < n; i++)
        cout << (char)(step[i] + 'A') << endl;
    exit(0);
}

int main() {
    srand(time(NULL));
    if (fopen("A.inp", "r"))
    freopen("A.inp", "r", stdin),
    freopen("A.out", "w", stdout);
    cin >> n >> d[0] >> d[1] >> d[2];
    for (int i = 0; i < n; i++) {
        string str; cin >> str;
        a[str[0] - 'A'][i] = a[str[1] - 'A'][i] = 1;
    }
    solve(0, 1, 2);
    solve(0, 2, 1);
    solve(1, 0, 2);
    solve(1, 2, 0);
    solve(2, 0, 1);
    solve(2, 1, 0);
    for (int i = 0; i < 500; i++)
        Try1();
    Try2();
    puts("No");
}


Measured memory_bytes: 5200
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var @as = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        Func<int, int, int> gcd = (x, y) =>
        {
            while (x > 0)
            {
                y %= x;
                y += x;
                x = y - x;
                y -= x;
            }
            return y;
        };

        var ls = new int[@as.Length + 1];
        ls[1] = @as[0];
        for (int i = 1; i < @as.Length; i++)
        {
            ls[i + 1] = gcd(ls[i], @as[i]);
        }

        Array.Reverse(@as);
        var rs = new int[@as.Length + 1];
        rs[1] = @as[0];
        for (int i = 1; i < @as.Length; i++)
        {
            rs[i + 1] = gcd(rs[i], @as[i]);
        }
        Array.Reverse(rs);

        var max = 0;
        for (int i = 0; i < @as.Length; i++)
        {
            max = Math.Max(max, gcd(ls[i], rs[i + 1]));
        }
        Console.WriteLine(max);
    }
}


Measured memory_bytes: 31068
ls = sorted(list(map(int,input().split())))
if ls[0] == ls[1] and ls[0] != ls[2]:
    print('Yes')
elif ls[1] == ls[2] and ls[0] != ls[1]:
    print('Yes')
elif ls[0] == ls[2] and ls[0] != ls[1]:
    print('Yes')
else:
    print('No')

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

int main(){
        int n;
        long long int a[200010];
        cin>>n;
        for(int i=0; i<n; ++i) cin>>a[i];
        int count;
        for( count=n-1; count>=0; count-=2) cout<<a[count]<<" ";
        for( ((n-1)%2==0 ? count=1: count=0); count<n; count+=2) cout<<a[count]<<" ";
        cout<<endl;
	return 0;
}


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int i=1;
do{
  int x=i;
  if(x%3==0){
	  System.out.print(" "+i);
  } else{
 do{
  if(x%10==3){
  System.out.print(" "+i);
  break;
}
x/=10;
 }while(x!=0);
 }
} while (++i <= n);
System.out.println();
}
}

Measured memory_bytes: 28824
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 200009;

ll sum[maxn],a[maxn];
map<ll,int> mp;
int n;
ll ans;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read(),sum[i]=sum[i-1]+a[i];
	mp[0]++;
	for(int i=1;i<=n;i++)
	{
		ans+=mp[sum[i]];
		mp[sum[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
  int n;
  int cou = 1;
  cin >> n;
  vector<int> A(n,0);

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

  for(int j = 1;j < n;j++){
    int l = 0;
    if(A[j-1] <= A[j]){
      for(int k = 0;k < j;k++){if(A[k]<=A[j]){l++;}}
      if(l == j){cou++;}
  }
  }

  cout << cou << endl;
  return 0;
  }


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()         

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N+2];


void solve()
{     
      int x, y, n1, n2 , n3;
      cin >> x >> y >> n1 >> n2 >> n3;
      vector<int> a1(n1), a2(n2), a3(n3);

      lop(i,0,n1) cin >> a1[i];
      lop(i,0,n2) cin >> a2[i];
      lop(i,0,n3) cin >> a3[i];

      sort( a1.rbegin(), a1.rend() );
      sort( a2.rbegin(), a2.rend() );

      lop(i,0,x) a3.pb(a1[i]);
      lop(i,0,y) a3.pb(a2[i]);

      sort( a3.rbegin(), a3.rend() );
      int ans = 0;
      lop(i,0,x+y) ans += a3[i];
      cout << ans;

      
}

int32_t main()
{
      ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
    //  INP(); 
      int test = 1;
      // cin >> test;

      // cout << setprecision(9) << fixed;
      // clock_t z = clock();
      while(test--)solve();
      // cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
}











inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //






Measured memory_bytes: 6256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

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

ll lcm(ll a, ll b){
  ll g = gcd(a,b);
  return a/g*b;
}

int main(){
  ll n;
  cin >> n;
  ll t[n];
  REP(i,n) cin >> t[i];
  ll ans = 1;
  REP(i,n) ans = lcm(ans,t[i]);
  cout << ans << endl;
  return 0;
}


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


int main() {
	int K;
	cin >> K;
	int count = 0;
	int keta = 0;
	vector<long long> num;
	for (int i = 0; i < 9; i++)num.push_back(i + 1);
	count = 9;
	int head1 = 0;
	int head2 = 8;

	while (true) {
		for (int i = head1; i <= head2; i++) {
			if (num[i] % 10 == 0) {
				num.push_back(num[i] * 10);
				num.push_back(num[i] * 10 + 1);
				count += 2;
			}
			else if (num[i] % 10 == 9) {
				num.push_back(num[i] * 10 + 8);
				num.push_back(num[i] * 10 + 9);
				count += 2;
			}
			else {
				int d = num[i] % 10;
				num.push_back(num[i] * 10 + d - 1);
				num.push_back(num[i] * 10 + d);
				num.push_back(num[i] * 10 + d + 1);
				count += 3;
			}
		}
		//cout << count << endl;
		//for (int j = 0; j < count; j++)cout << num[j] << endl;
		if (count >= K)break;
		head1 = head2 + 1;
		head2 = count - 1;
		/*cout << head1 << "," << head2 << endl;
		cout << "----" << endl;*/
	}

	cout << num[K-1] << endl;
}

Measured memory_bytes: 2420
#include <stdio.h>
#include <limits.h>
#include <string.h>

#define MAX_H 2000000
#define INF INT_MIN

int H;

int heapExtractMax(int*);
void maxHeapify(int*,int);
void maxHeapInsert(int*,int);
void heapIncreseKey(int*,int,int);
void swap(int*,int*);

int main(){
  int val;
  static int a[MAX_H];
  char command[8];
  H = 0;
  while(1){
    scanf("%s",command);
    if(!strcmp(command,"end")){
      break;
    }else if(!strcmp(command,"insert")){
      scanf("%d",&val);
      maxHeapInsert(a,val);
    }else{
      printf("%d\n",heapExtractMax(a));
    }
  }

  return 0;
}

int heapExtractMax(int *A){
  int max;
  if(H < 1){ return -1; }
  max = A[0];
  A[0] = A[H-1]; H--;
  maxHeapify(A,0);
  return max;
}

void maxHeapify(int *A,int i){
  int l = i*2+1, r = i*2+2;
  int largest;
  if(l <= H && A[l] > A[i]){
    largest = l;
  }else{ largest = i; }

  if(r <= H && A[r] > A[largest]){
    largest = r;
  }
  if(largest != i){
    swap(&A[i],&A[largest]);
    maxHeapify(A,largest);
  }
}

void maxHeapInsert(int *A,int val){
  H++;
  A[H-1] = INF;
  heapIncreseKey(A,H-1,val);
}

void heapIncreseKey(int *A,int i,int val){
  int j;
  if(val < A[i]){ return; }
  A[i] = val;
  j = (i & 1 ? i/2 : (i-1)/2);
  while(i > 0 && A[j] < A[i]){
    swap(&A[i],&A[j]);
    i = j;
    j = (i & 1 ? i/2 : (i-1)/2);
  }
}

void swap(int *a,int *b){
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

Measured memory_bytes: 4700
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;


long long factorial(int n) {
    long long res = 1;
    irep(i, 1, n) {
        res = (res * i) % MOD;
    }
    return res;
}



int main() {
    int n, m;
    cin >> n >> m;
    long long res = 1;
    if (n < m)
        swap(n, m);
    if (n - m >= 2)
        cout << 0 << endl;
    else {
        res = (res * factorial(n)) % MOD;
        res = (res * factorial(m)) % MOD;
        if (n == m)
            res = (res * 2) % MOD;

        cout << res << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std; 

long long int f(long long int a){
 long long int  res=0;
 if(a%2==0)res=a;

 if(((a+1)/2)%2==0)return res^1;
 else return res;

}

int main(void){
 long long int A,B;
 cin>>A>>B;

 cout<<(f(A-1) ^ f(B))<<endl;
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    string s;
    cin >> s;
    ll i;
    ll tmp=0;
    ll mx=0;
    for(i=0;i<s.size();i++){
      if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')tmp++;else tmp=0;
      mx=max(tmp,mx);
    }
    cout << mx;
    return 0;
}


Measured memory_bytes: 256
N,M = map(int, input().split())
foods = [0]*M
for i in range(N):
    tmp = list(map(int, input().split()))
    for f in tmp[1:]:
        foods[f-1] += 1
cnt = 0
for i in range(1,M+1):
    if foods[i-1]==N:
        cnt += 1
print(cnt)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int h,w;
const int m=50;
char s[m][m];
int t[m][m];
queue<pair<int,int>> q;

int bfs(int a,int b,int x,int y){
  q.push(make_pair(a,b));
  t[a][b]=1;
  while(q.size()){
    pair<int,int> f=q.front();
    int u=f.first,v=f.second;
    if(u!=0&&s[u-1][v]=='.'&&t[u-1][v]==0){
      q.push(make_pair(u-1,v));
      t[u-1][v]=t[u][v]+1;
    }
    if(u!=h-1&&s[u+1][v]=='.'&&t[u+1][v]==0){
      q.push(make_pair(u+1,v));
      t[u+1][v]=t[u][v]+1;
    }
    if(v!=0&&s[u][v-1]=='.'&&t[u][v-1]==0){
      q.push(make_pair(u,v-1));
      t[u][v-1]=t[u][v]+1;
    }
    if(v!=w-1&&s[u][v+1]=='.'&&t[u][v+1]==0){
      q.push(make_pair(u,v+1));
      t[u][v+1]=t[u][v]+1;
    }
    q.pop();
  }
  return t[x][y];
}

int main(){
  cin >> h >> w;
  int cnt=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i][j];
      if(s[i][j]=='.'){
        cnt++;
      }
    }
  }
  int r=bfs(0,0,h-1,w-1);
  if(r==0){
    cout << -1 << endl;
  }
  else{
    cout << cnt-r << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long k=sqrt(n);
    set<long long>s;
    if(n==2)
    {
        cout<<1;
        return 0;
    }
    for(int i=2;i<=k;i++)
    {
        if(n%i==0)
        {
            long long j=n;
            while(j%i==0)
            j=j/i;
            if(j==1)
            s.insert(i);
            else
            {
                if(j%i==1)
                s.insert(i);
            }
        }
        else
        {
            if(n%i==1)
            {
                s.insert(i);
                s.insert(n/i);
            }
        }
    }
    s.insert(n-1);
    s.insert(n);
    cout<<s.size();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int id;
    edge(int t, int w) : to(t),id(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<edge>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

Graph G;
vector<int> ans;
int ans_ko;
void dfs(int v,int c = -1, int p = -1){
    chmax(ans_ko,c);
    int k = 1;
    for(auto n : G[v]){
        int nv = n.to; int ei = n.id;
        if(nv == p) continue;
        if(k == c) ++k;
        ans[ei] = k;
        ++k;
        dfs(nv,ans[ei],v);
    }
}

int main(){

    int n; cin >> n;
    G.resize(n);
    ans.resize(n-1);
    rep(i,n-1){
        int a,b; cin >> a >> b;
        --a;--b;
        G[a].push_back(edge(b,i));
        G[b].push_back(edge(a,i));
    }
    ans_ko = 0;
    dfs(0);
    cout << ans_ko << endl;
    rep(i,n-1) cout << ans[i] << endl;

}

Measured memory_bytes: 8320
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);

                long N = scan.nextLong();
                long rootN = (long)Math.sqrt(N);
                int count = 0;
                int pcount;
                int ncount;
                
                for (long i = 2; i < rootN; i++) {
                	
                	pcount = 0;
                	
                	while (N%i == 0) {
                		pcount++;
                		N /= i;
                	}
                	
                	ncount = 1;
                	
                	while (pcount - ncount >= 0) {
                		pcount -= ncount;
                		count++;
                		ncount++;
                	}
                	
                }
                
                if (N != 1) {
                	count++;
                }
                
                System.out.println(count);
                
        }
}

Measured memory_bytes: 35768
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define N 100001
using namespace std;

char s[N][11];
int p[N];

int cmp(int x, int y)
{
	return strcmp(s[x], s[y]) < 0;
}

int main() 
{
	int n, i, max = 0, j, pi, t;
	long long ans = 0, x;
				
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%s", s[i]);
		sort(s[i], s[i] + 10);
		p[i] = i;
	} 
	sort(p, p + n, cmp);
	
	for(i = 0; i < n; i = j){
		pi = p[i];
		for(j = i + 1; j < n && !strcmp(s[pi], s[p[j]]); j++);
		t = j - i;
		if(t == 1) continue;
		x = (long long)t;
		ans += x * (x - 1) / 2;
	}
	printf("%lld\n", ans);
			
	return 0;
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
	
		try{
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

	while(true){
    String input = buf.readLine();
	String[] strAry = input.split(" ");
    int H = Integer.parseInt(strAry[0]);
    int W = Integer.parseInt(strAry[1]);
	
	if(H == 0  && W == 0){
		break;
	}
	
	for (int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++){
			if((i + j)%2 == 0 ){
			System.out.printf("#");
				}else{
			System.out.printf(".");
			}
		}
		System.out.printf("\n");
	}
	System.out.printf("\n");
	}
} catch (Exception e) {

	System.out.println("????????????");
	
}
		 }
    }

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

int main() {
  std::string S;
  std::cin >> S;
  int cnt_p;
  for (char c : S) {
    if (c == 'p') cnt_p++;
  }
  int ans = S.size() / 2 - cnt_p;
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<set>

using namespace std;

int main(){
    int N;
    cin >> N;
    int loc[N];
    
    int p;
    for(int i=0; i<N; i++){
        cin >> p;
        p--;
        loc[p] = i;
    }

    multiset<int> ms{-1, -1, N, N};

    long w, x, y, z;
    long ans = 0;

    for(long i = N-1; i >= 0; i--){
        ms.insert(loc[i]);
        auto itr = ms.find(loc[i]);
        auto itr2 = itr;

        x = *(--itr);
        w = *(--itr);
        y = *(++itr2);
        z = *(++itr2);

        ans += (i+1) * ((x-w) * (y-loc[i]) + (loc[i]-x) * (z-y));

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    string w;
    cin >> w;
    map<char, int> m;
    int ans = 'a';
    while(1){
        m[ans] = 0;
        if(ans != 'z') ans++;
        else break;
    }
    rep(i,w.size()){
        m[w[i]]++;
    }
    for(auto x:m){
        if(x.second%2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    int k,a,b;
    cin>>k;
    cin>>a>>b;
    bool flag=false;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            flag=true;
            break;
        }
    }
    if(flag){
        cout<<"OK";
    }else{
        cout<<"NG";
    }
    return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cctype>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
#define init(x) memset(x,0,sizeof(x))
int n;
ll a[10005],ans=0;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=1;i<=n;++i) cin>>a[i];
	for (int i=1;i<=n;++i){
		ll cnt=0;
		while(a[i]%2==0){
			a[i]=a[i]>>1;++cnt;
		}
		ans+=cnt;
	}
	cout<<ans;
	return 0;
}

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

int main()
{
	int A, B,ans = 1;
	string S;

	cin >> A >> B >> S;

	if (S[A] != '-')ans = 0;

	for (int i = 0; i < A + B; i++) {
		if (i == A)continue;
		if (S[i] == '-')ans = 0;
		int a = S[i] - '0';
		if (a < 0 || a > 9)ans = 0;
	}

	if (ans)cout << "Yes";
	else cout << "No";

	return 0;
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int,string> Pis;

int main() {
  int n,m;
  cin>>n>>m;
  int dp[n+1];
  int wa[n+1];
  int ans=0;
  int pna=0;
  memset(dp,0,sizeof(dp));
  memset(wa,0,sizeof(wa));
  REP(i,m){
    Pis ex;
    cin>>ex.first>>ex.second;
    if(dp[ex.first]==0&&ex.second=="AC"){
      ans++;
      dp[ex.first]=1;
    }else if(dp[ex.first]==0&&ex.second=="WA"){
      wa[ex.first]++;
    }
  }
  REP(i,n){
    if(dp[i+1]==1){
      pna+=wa[i+1];
    }
  }
  cout<<ans<<" "<<pna<<endl;
}


Measured memory_bytes: 1024
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect


if __name__ == '__main__':
    n = int(input())
    data = list(map(int, input().split()))

    subordinate_data = [None] * n
    for i, _ in enumerate(subordinate_data):
        subordinate_data[i] = []
    i = 2 # id
    for v in data:
        boss = v - 1
        subordinate_data[boss].append(i)
        i += 1
    #print('subordinate_data') # debug
    #print(subordinate_data) # debug
    for l in subordinate_data:
        print(len(l))


    #print('\33[32m' + 'end' + '\033[0m') # debug


Measured memory_bytes: 109336
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int a, b, x, hasil;
int main(){
	while(cin >> a >> b){
		hasil = 0;
		x = a + b;
		while(x >= 1){
			hasil++;
			x = x / 10;
		}
		cout << hasil << "\n";
	}
	return 0;
}

Measured memory_bytes: 3080
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        int M = sc.nextInt();
	        int[] a = new int[M];
	        int[] b = new int[M];
	        for(int i=0;i<N;i++)list.add(new ArrayList<Integer>());
	        for (int i=0 ; i<M; i++) {
	            a[i] = Integer.parseInt(sc.next())-1;
	            b[i] = Integer.parseInt(sc.next())-1;
	        	list.get(a[i]).add(b[i]);
	        	list.get(b[i]).add(a[i]);
	        }
	        int[] visited = new int[N];
	        LinkedList<Integer> q= new LinkedList<Integer>();
	        q.add(0);
	        q.add(-1);
	        while(!q.isEmpty()) {
	        	int now = q.poll();
	        	int pre = q.poll();
//        		visited[now]=pre+1;
	        	for(int i=0;i<list.get(now).size();i++) {
	        		int next = list.get(now).get(i);
	        		if(next==pre)continue;
	        		if(visited[next]!=0)continue;
	        		q.add(next);
	        		q.add(now);
	        		visited[next]=now+1;
	        	}
	        }
	        System.out.println("Yes");
	        for(int i=1;i<N;i++) {
	        	System.out.println(visited[i]);
	        }
	       
	    }

	}

Measured memory_bytes: 80448
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
#define ALL(v) (v).begin(), (v).end()
const int mod = INF+7;
using namespace std;

bool dfs(int *alpha, int a, int b){
  if(alpha[a]==b){
    return true;
  }
}

int main(){
  string S,T;
  cin >> S;
  cin >> T;
  int N=S.length();

  int *alpha=(int *)malloc(sizeof(int)*26);
  rep(i,26){
    alpha[i]=-1;
  }
  bool flag=true;
  rep(i,N){
    if(alpha[S[i]-'a']==-1){
      alpha[S[i]-'a']=T[i]-'a';
    }
    else if(alpha[S[i]-'a']!=-1 && alpha[S[i]-'a']!=T[i]-'a'){
      flag=false;
      break;
    }
  }

  if(flag==false){
    printf("No\n");
  }
  else{
    int *count=(int *)calloc(26,sizeof(int));
    rep(i,26){
      if(alpha[i]!=-1){
        count[alpha[i]]++;
      }
    }
    flag=true;
    rep(i,26){
      if(count[i]>=2){
        flag=false;
        break;
      }
    }
    if(flag==false){
      printf("No\n");
    }
    else{
      printf("Yes\n");
    }
  }
}


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

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        i: usize1,
    }
    println!("{}", n - i);
}


Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    
    
    int a, b;
    vector<int> k(10), p(10);
    
    for ( int i = 0; i < m; i++ ){
        cin >> a;
        for ( int j = 0; j < a; j++ ){
            cin >> b;
            k[i] += 1 << (b-1);
        }
    }
    
    for ( int i = 0; i < m; i++ )
        cin >> p[i];
    
    int ans = 0;
    
    
    for ( int i = 0; i < 1 << n; i++ ){
        
        int flag = 1;
        
        for ( int j = 0; j < m; j++ ){
            
            int sw = 0;
            int s = k[j];
            int t = i;
            
            while ( s > 0 ){
                if ( s % 2 == 1 && s % 2 == t % 2 ) ++sw;
                s /= 2;
                t /= 2;
            }
            
            if ( sw % 2 != p[j] ){
                flag = 0;
                break;
            }
        }
        if ( flag == 1 ) ans++;
    }
    
    cout << ans << endl;
    
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  ll N,K;
  cin>>N>>K;
  if(N==K){
    cout<<0<<endl;
  }
  else if(N<K){
    cout<<min(abs(K-N),N)<<endl;
  }
  else{
    N%=K;
    cout<<min(abs(K-N),N)<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
public:
    double x, y;

    Point(double x = 0.0, double y = 0.0): x(x), y(y) {};

    Point operator + (Point &p) {return Point(x + p.x, y + p.y);}
    Point operator - (Point &p) {return Point(x - p.x, y - p.y);}
    Point operator * (double k) {return Point(x * k, y * k);}
    Point operator / (double k) {return Point(x / k, y / k);}

    double norm(void) {return x * x + y * y;}
    double abs(void) {return sqrt(norm());}

    bool operator == (const Point &p) const {
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    double dot(Point a) {
        return x * a.x + y * a.y;
    }

    double cross(Point a) {
        return x * a.y - y * a.x;
    }
};

struct Segment {
    Point p1, p2;
};


Point project(Segment s, Point p) {
    Point base = s.p2 - s.p1;
    double r = base.dot(p - s.p1) / base.norm();
    return base * r + s.p1;
}

int main(void) {
    int x1, x2, y1, y2, q, px, py;
    Segment s;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    s.p1 = Point(x1, y1); s.p2 = Point(x2, y2);

    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d %d", &px, &py);
        Point ans = Point(project(s, Point(px, py)));
        printf("%.10f %.10f\n", ans.x, ans.y);
    }

    return 0;
}

Measured memory_bytes: 1068
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		for(int p=0;p<N;p++) {
			for(int q=0;q<N;q++) {
				if(4*p+7*q==N) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}

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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}

const int N=5e5+10;

template<typename T>
struct Fenwick{
    vector<T> tree;
    Fenwick(int n){
        tree.resize(n);
    }

    T query(int i){
        int sum=0;
        while(i){
           sum+=tree[i];
           i-=i&(-i);
       }  
       return sum;
    }
    void update(int i,int n,T val){
       while(i<=n){
          tree[i]+=val;
          i+=i&(-i);
       }
    }
};


int solve(){
 	int n,d;cin>>n>>d;
 	int cnt=0;
 	rep3(n){
 		int x,y;cin>>x>>y;
 		if(x*x+y*y<=d*d)cnt++;
 	}cout<<cnt<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 3652
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    H, N = input(int, int)
    A = input([int, N])
    yesno(H <= sum(A))


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


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

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

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    if (i % 2 == 1 && a % 2 == 1) {
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}



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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

map<ll, ll> factor(ll n){
    map<ll, ll> res;

    for (ll i = 2; i*i <= n; ++i) {
        while(n % i == 0){
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;

    return res;
}

int main(){

    ll n;
    cin >> n;

    map<ll, ll> mp = factor(n);
    ll ans = 0;
    for(auto q : mp){
        //cout << q.first << " " << q.second << "\n";
        ll cnt = 0;
        while(cnt * (cnt + 1) / 2 < q.second){
            cnt++;
        }
        if(cnt * (cnt + 1) / 2 != q.second) cnt--;
        ans += cnt;
        //cout << cnt << "\n";
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    public static void main(String[] a) throws IOException{
    	;
    	String strLine ="";
    	BufferedReader stdReader =
            new BufferedReader(new InputStreamReader(System.in));

    	Integer[] hill = new Integer[10];
    	int i = 0;

    	while((strLine = stdReader.readLine()) != null){
    		hill[i] = Integer.parseInt(strLine);
    		i++;
    	}

    	Arrays.sort(hill);

    	for(i = 9; i >= 7; i--){
    		System.out.println(hill[i]);
    	}
    }

}

Measured memory_bytes: 24212
n=int(input())
a=list(map(int,input().split()))
import math
def ncr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
import collections
d=collections.defaultdict(int)

for i in a:
    d[i]+=1

total=0
for i in d.values():
    if i>=2:
        total+=ncr(i,2)

for i in a:
    print(total-d[i]+1)

Measured memory_bytes: 24748
num = int(raw_input())
array = map(int, raw_input().split(" "))

a = sorted(array)

if num % 2 == 0:
    for i in xrange(0, num, 2):
        if a[i] != a[i + 1]:
            print 0
            break
    else:
        div = pow(10, 9) + 7
        print pow(2, num / 2) % div
else:
    for i in xrange(1, num, 2):
        if a[i] != a[i + 1]:
            print 0
            break
    else:
        div = pow(10, 9) + 7
        print pow(2, num / 2) % div


Measured memory_bytes: 11304
n = int(input())
a = list(map(int,input().split()))
flg = 0
counter = 0
for i in range(n-1):
    if a[i] == a[i+1]:
        if flg == 0:
            counter +=1
            flg = 1
        else:
            flg = 0
    else:
        flg = 0
print(counter)       

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, a[1000][1000];
string s[1000];

void check(ll si, ll sj){
	//print('s')
	rep(i, 0, n){
		rep(j, 0, n){
			//print(s[si+i][sj+j])
			//print(s[sj+j][si+i])
			if(s[si+i][sj+j] != s[si+j][sj+i]){
				rep(k, 0, (min(i, j)+1)){
					a[si+k][sj+k] = -1;
				}
				return;
			}
		}
	}
	a[si][sj] = 1;
}

void mcheck(ll si, ll sj){
	rep(i, 0, n){
		ll j = n;
		if(s[si+i][sj+j] != s[si+j][sj+i]){
			rep(k, 0, (min(i, j)+1)){
				a[si+k][sj+k] = -1;	
			}
			return;
		}
	}
	a[si][sj] = 1;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	rep(i, 0, n){
		cin >> s[i];
		s[i] += s[i];
		s[i+n] = s[i];
	}
	//rep(i, 0, 2*n){print(s[i])}
	memset(a, 0, sizeof(a));
	
	rep(i, 0, n){
		rep(j, 0, n){
			if(i == 0 || j == 0 || (a[i][j] == 0 && a[i-1][j-1] != 1)){
				check(i, j);
			}
			else{
				if(a[i][j] == 0 && a[i-1][j-1] == 1){
					mcheck(i, j);
				}
			}
		}
	}
	
	ll ans = 0;
	rep(i, 0, n){rep(j, 0, n){
		//print(a[i][j]);
		if(a[i][j] == 1){ans++;}
	}}
	print(ans)
	return 0;
}

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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define LOCAL
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound
#define lowbit(x) x&(-x)
#define testbit(x,i) x&(1<<i)

inline void checkmin(int &x,int y){x=min(x,y);}
inline void checkmax(int &x,int y){x=max(x,y);}

int n,m;
int a[110];

int main() 
{
	#ifndef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    int sum=0;
    for(int i=1;i<=n;i++) sum+=a[i];
    int x=4*m,y;
    if(sum%x==0) y=sum/x;
    else y=sum/x+1;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
    	if(a[i]>=y) cnt++;
	}
	cout<<(cnt>=m?"Yes":"No")<<endl;
    /* end code */
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;
typedef long long ll;

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

int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    while(1){
        C-=B;
        if(C<=0){
            cout<<"Yes"<<endl;
            break;
        }
        A-=D;
        if(A<=0){
            cout<<"No"<<endl;
            break;
        }
        
        

    }


return 0;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =2e5+10;
const int mod=1e9+7;

ll fac[maxn];
ll inv[maxn];

ll power(ll base,ll n)
{
    ll r=1;
    while(n)
    {
        if(n%2) r=r*base%mod;
        base=base*base%mod;
        n/=2;
    }
    return r;
}
void init()
{
    fac[0]=1;
    for(int i=1;i<maxn;i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
    inv[maxn-1]=power(fac[maxn-1],mod-2);
    for(int i=maxn-2;i>=0;i--)
    {
        inv[i]=inv[i+1]*(i+1)%mod;
    }
}

ll C(ll m,ll n)
{
    return fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h,w,a,b;
    cin>>h>>w>>a>>b;
    init();
    ll ans=0;
    for(int i=1;i<=h-a;i++)
    {
        ll temp1=C(i-1,i+b-2);
        ll temp2=C(w-(b+1),h+w-(i+b+1));
        temp1%=mod;
        temp2%=mod;
        ll sum=temp1*temp2%mod;
        ans+=sum;
        ans%=mod;
    }
    cout<<ans<<'\n';


}


Measured memory_bytes: 6732
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

int main() {
  string S;
  cin >> S;
  REP(i, S.size()) { cout << "x"; }
  cout << endl;
}


Measured memory_bytes: 256
main(){float a,b,c,d,e,f,g,h,i,j,k,l,x,y,t,u;while(scanf("%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f)!=-1){j=g=a*d;k=e*a;h=d*b;i=c*d;l=f*a;t=h-k;u=i-l;y=u/t;h=k=b*e;g=e*a;i=c*e;j=d*b;l=f*b;t=g-j;u=i-l;x=u/t;if(x==-0)x=0;if(y==-0)y=0;printf("%.3lf %.3lf\n",x,y);}exit(0);}

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

int main(){
  char s[2];
  cin >> s;
  int a=0;
  for (int i=0; i<3; i++ )
  {
     if (s[i]=='1')
	{
          a++;
         }
  }
  cout << a << endl;
}




Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

# a = [0, 10, 10, 10, 10]

a.sort()
r = 1
t = 10 ** 18
for x in a:
  r *= x
  if r > t:
    break
if r <= t:
  print(r)
else:
  print(-1)

Measured memory_bytes: 21636