akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<ld> p(N);
    rep(i,N){
        cin >> p[i];
    }
    ld dp[N+1][N+1];//sum,omote
    rep(i,N+1){
        rep(j,N+1){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    rep(i,N){
        rep(j,N+1){
            dp[i+1][j]=dp[i][j]*(1-p[i]);
            if(j)dp[i+1][j]+=dp[i][j-1]*p[i];
        }
    }
    ld ans=0;
    rep(j,N+1){
        if(j>N-j){
            ans+=dp[N][j];
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 144480
#include<stdio.h>

int main(void)
{
	int a, b, c;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	if ((a < b) && (b < c))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}


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

  
public class Main 
{ 
    public static void main(String[] args) 
    { 
        FastReader sc=new FastReader(); 
       // int t = sc.nextInt(); 
        
		    long a=sc.nextInt();
		    long b=sc.nextInt();
		    long c=sc.nextInt();
		    long k=sc.nextInt();
		    long count=0;
		    while(b<=a){
		        b*=2;
		        count++;
		    }
		    while(c<=b){
		        c*=2;
		        count++;
		    }
		    if(count<=k)
		    System.out.println("Yes");
		    else
		    System.out.println("No");
		
         
        
    } 
     public static String sort(String inputString) 
    { 
        char tempArray[] = inputString.toCharArray(); 
          
        Arrays.sort(tempArray); 
          
        return new String(tempArray); 
    } 
    static void shuffleArray(int[] arr){
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            int tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }   
}
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
} 











Measured memory_bytes: 32840
#include <stdio.h>

int gcd(int a, int b) {
  int t;
  while(b) {
    t = a % b;
    a = b;
    b = t;
  }
  return a;
}
  
int main(void) {
  int x, y, i;
  scanf("%d%d", &x, &y);
  int ans = x + y + 1;
  ans -= gcd(x, y);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2752
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;


int main(){
    double a, b, C, S, L, h;
    double const pi = 2*acos(0);
    cin >> a >> b >> C;
    h = b*sin(C*pi/180.0);
    S = 0.5*a*h;
    L = a + b + pow( a*a + b*b - 2*a*b*cos(C*pi/180.0) , 0.5);
    printf( "%.10f\n",S);
    printf( "%.10f\n",L);
    printf( "%.10f\n",h);
    
    return 0;
}



Measured memory_bytes: 3660
from math import gcd

N = int(input())
a = list(map(int, input().split()))

am = max(a)

memo = [1] * (am+1)
memo[0] = 0
memo[1] = 0

d = set([])

for ai in range(2, am+1):
    for j in range(2, am // ai + 1):
        memo[ai * j] = 0

cs = set([])
for i, memoi in enumerate(memo):
    if memoi:
        cs.add(i)

# print(cs)


f1 = 1
f2 = 1

for ai in a:
    lim = int(ai**0.5)+1
    f0 = 0
    if ai in cs:
        if ai in d:
            f0 = 1
            f1 = 0
        else:
            d.add(ai)
    else:  
        for i in cs:
            if i >= lim:
                break
            if ai % i == 0:
                if i in d or ai//i in d:
                    f1 = 0
                    f0 = 1
                    break
                else:
                    d.add(i)
                    d.add(ai//i)
    if f0:
        break


if f1:
    print('pairwise coprime')
else:
    g = a[0]
    for ai in a:
        g = gcd(ai, g)
    if g == 1:
        print('setwise coprime')
    else:
        print('not coprime')


Measured memory_bytes: 189876
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;
    out(n*n*n);
    re0;
}

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

int main() {
  vector<bool> B(1e6 + 1, 1);
  B.at(0) = B.at(1) = 0;
  for (long i = 2; i <= 1e6; i++) {
    if (B.at(i)) for (long j = i * i; j <= 1e6; j += i) B.at(j) = 0;
  }
  vector<vector<int>> V(1e6+1);
  for (int i = 2; i <= 1e6; i++) {
    if (B.at(i)) for (int j = i; j <= 1e6; j += i) V.at(j).push_back(i);
  }

  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<bool> B2(1e6+1);
  for (auto a : A) {
    for (auto b : V.at(a)) {
      if (B2.at(b)) goto NG;
      B2.at(b) = 1;
    }
  }
  return cout << "pairwise coprime" << "\n", 0;
  NG:;
  int G = 0;
  for (int i = 0; i < N; i++) {
    G = gcd(G, A.at(i));
  }
  cout << ((G == 1) ? "setwise coprime" : "not coprime") << "\n";
}

Measured memory_bytes: 62832
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vector<int>>
int main(void){
    int n,ans=0;
    cin>>n;
    for(int i=1; i<=n; i++){
        int a;
        cin>>a;
        if(a!=i){
            ans++;
        }
    }
    if(ans==2 || ans==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int N, K;
    cin >> N >> K;
    int num = 1;
    int cnt = 1;
    while (num * K <= N)
    {
        cnt += 1;
        num *= K;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

void inverse(ll n,vector<ll> &inv){
    //要素数:n+1 (0~n)
    inv[0]=1;
    inv[1]=1;
    for(ll i=2;i<=n;i++){
        inv[i]=(MOD-inv[MOD%i]*(MOD/i))%MOD;
    }
}

void inverse_(ll n,vector<ll> &inv){
    for(ll i=2;i<=n;i++){
        inv[i]=(inv[i]*inv[i-1])%MOD;
    }
}

void f(ll n,vector<ll> &fac){
    //要素数:n+1 (0~n)
    fac[1]=1;
    for(ll i=2;i<=n;i++){
        fac[i]=(fac[i-1]*i)%MOD;
    }
}

int main() {
    ll n,k,l=0,r=0,ad; cin>>n>>k;
    vector<ll> a(n,0),fac(n+1,0),inv(n+1,0);
    rep(i,n) cin>>a[i];
    inverse(n,inv); f(n,fac);
    inverse_(n,inv);
    sort(al(a));
    for(int i=0;i<n-k+1;i++){
        ad=((fac[n-1-i]*inv[k-1])%MOD)*inv[n-k-i]%MOD;
        r=(r+ad*a[i])%MOD;
    }
    reverse(al(a));
    for(int i=0;i<n-k+1;i++){
        ad=((fac[n-1-i]*inv[k-1])%MOD)*inv[n-k-i]%MOD;
        l=(l+ad*a[i])%MOD;
    }
    cout<<(l-r+100*MOD)%MOD<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, one, ten, hnd;
  cin >> a;
  hnd = a / 100;
  ten = a / 10 - hnd * 10;
  one = a - ten * 10 - hnd * 100;
  int result = hnd + ten + one;
  cout << result << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a[2][100],s[1000]={0},n,i,j,k;

    scanf("%d",&n);

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

    for(k=0;k<n;k++){
        for(i=0;i<=k;i++){
            s[k]=s[k]+a[0][i];
            }
        for(j=i-1;j<n;j++){
            s[k]=s[k]+a[1][j];
        }
    }

    for(i=0;i<n;i++){
        if(s[0]<s[i]){
            s[0]=s[i];
        }
    }

    printf("%d",s[0]);

    return 0;
}


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

int main() {
	int N, dp[3];
	cin >> N >> dp[0] >> dp[1] >> dp[2];
    for (int i = 1; i < N; ++i){
        int a, b, c;
        cin >> a >> b >> c;

        a += max(dp[1], dp[2]);
        b += max(dp[2], dp[0]);
        c += max(dp[1], dp[0]);
        dp[0] = a;
        dp[1] = b;
        dp[2] = c;
    }

    cout << max(dp[0], max(dp[1], dp[2])) << endl;
	return 0;
}

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

using namespace std;

int a, b, n;
int main()
{
    cin >> n >> a >> b;
    cin.sync_with_stdio(false);

    if(a>b) cout << 0 << '\n';
        else if(n==1) cout << (a==b) << '\n';
            else cout << 1LL*(n-2)*(b-a) + 1 << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		int N = scan.nextInt();
		for(int i = 0; i < N; i++){
			double xa = scan.nextDouble();
			double ya = scan.nextDouble();
			double ra = scan.nextDouble();
			double xb = scan.nextDouble();
			double yb = scan.nextDouble();
			double rb = scan.nextDouble();

			double l = Math.sqrt((xb - xa)*(xb - xa)+(yb - ya)*(yb - ya));
			if(l > ra + rb){
				System.out.printf("%d\n", 0);
			} else if(ra > l + rb){
				System.out.printf("%d\n", 2);
			} else if(rb > l + ra){
				System.out.printf("%d\n", - 2);
			} else{
				System.out.printf("%d\n", 1);
			}
		}
	}
}

Measured memory_bytes: 28656
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    have = 1000
    for i in range(n-1):
        kabu = 0
        if a[i] < a[i+1]:
            kabu = have//a[i]
        have += (a[i+1] - a[i])*kabu
    print(have)

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

using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n;
    cin>>n;
    long long int arr[n];
    for(int i=0;i<n;i++)
    {
         cin>>arr[i];
    }
    long long int sum=0,s=0;
    for(int i=0;i<n;i++)
    {
         s=max(s,arr[i]);
         if(s>arr[i])
         sum=sum+abs(s-arr[i]);
    }
    cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 5172
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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;
}
///////////////////////////////////////////////////////////////

template< typename T >
struct edge {
    int src,to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    bool operator<(const edge &e) const {
        return cost < e.cost;
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int L; cin >> L;
    int sz = 1;
    int N = 1;
    while (sz*2 <= L) {
        sz *= 2;
        N++;
    }
    int k = sz;
    vector<vector<edge<int>>> G(N);
    vector<int> dist(N);
    int M = 0;
    rep(i,N-1) {
        G[i].emplace_back(i+1,0);
        G[i].emplace_back(i+1,k/2);
        dist[i] = k-1;
        k /= 2;
        M += 2;
    }
    int p = sz;
    while (p <= L-1) {
        rep(i,N) {
            if (p+dist[i]>L-1) continue;
            G[0].emplace_back(i,p);
            p += dist[i]+1;
            M++;
            break;
        }
    }

    cout << N << " " << M << endl;
    rep(i,N) {
        for (auto e : G[i]) {
            cout << i+1 << " " << e.to+1 << " " << e.cost << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int N;
    cin >> N;
    vector<int> d;
    rep(i, N) {
        int di;
        cin >> di;
        d.pb(di);
    }
    sort(all(d));
    // rep(i, d.size()) DEBUG(d[i]);
    // DEBUG(d[N/2-1]);
    // DEBUG(d[N/2]);
    int result = d[N/2] - d[N/2-1];
    cout << result << endl;
}

Measured memory_bytes: 892
while True:
    H,W=map(int,input().split())
    if W==0 and H==0:
        break
    for h in range(W):
        print("#",sep='',end='')
    print()
    for i in range(H-2):
        print('#',end='')
        for j in range(W-2):
            print('.',sep='',end='')
        print('#')
    for k in range(W):
        print('#',sep='',end='')
    print('\n')


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

using namespace std;
#define ll long long
int main()
{
   ll x;
   cin>>x;
   map<ll,ll>mp;
   mp[0]=0;
   ll b=1;
   while(1)
   {
       ll nb=b*b*b*b*b;
       ll nmb=-nb;
       mp[nb]=b;
       mp[nmb]=-b;
       if (mp[x+nb]!=0)
       {
           cout<<mp[x+nb]<<" "<<b<<'\n';
           break;
       }
       if (mp[x+nmb]!=0 || x+nmb==0)
       {
           cout<<mp[x+nmb]<<" "<<-b<<'\n';
           break;
       }
       b++;
   }
   return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#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,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main() {
    ll n, mod, ans;
    cin >> n;
    mod = 1000000007;
    if(n==1) {
        ans = 0;
    } else {
        ans = (modpow(10, n, mod) - 2*modpow(9, n, mod) + modpow(8, n, mod))%mod;
        if(ans<0) ans += mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

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

        int age = sc.nextInt();
        int price = sc.nextInt();

        if (age >= 13) {
            System.out.println(price);
        } else if (age > 5) {
            System.out.println(price / 2);
        } else {
            System.out.println(0);
        }

        sc.close();
    }
}

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

const int  maxn=200008;
int a[maxn]; int b[maxn]; int p[maxn];
int n; 
int base;
int main(){
  cin>>n;
  base=20000;
  for (int i=1;i<=n;i++)
    {
      scanf("%d",&p[i]);
      a[p[i]]=i;
    }
  for (int i=1;i<=n;i++)
    a[i]=(i-1)*20000+a[i];
  for (int i=n;i>=1;i--)
    b[i]=(n-i+1)*20000;
  for (int i=1;i<=n-1;i++)
     printf("%d ",a[i]);
  printf("%d\n",a[n]);
  for (int i=1;i<=n-1;i++)
     printf("%d ",b[i]);
  printf("%d\n",b[n]);
  return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstdio>

#include<string>
#include<vector>
using namespace std;
int n;
vector <int> cnt(26,1e9);
string ans;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        vector <int> v(26);
        for(int j=0;j<s.size();j++){
            v[(int)s[j]-'a']++;
        }
        for(int i=0;i<26;i++){
            cnt[i]=min(cnt[i],v[i]);
        }
    }
    for(int i=0;i<26;i++){
        cout<<string(cnt[i],i+'a');
    }
    puts("");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll n ; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);

    vector<ll> kosuu(200001,0);
    rep(i,n){
        kosuu.at(a.at(i))++;
    }
    ll all = 0;
    rep(i,200001){
        ll k = kosuu.at(i);
        if(kosuu.at(i)>=2){
            all += k*(k-1)/2;             
        }
    }
    rep(i,n){
        ll x = a.at(i);

        ll minus = 0;

        if(kosuu.at(x)>=2){
            minus = kosuu.at(x)-1;
        }
        cout << all - minus << endl;
    }
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	char name[27]={"abcdefghijklmnopqrstuvwxyz"};
	char s[201];
	string ss,sss;
	ss.resize(201);
	sss.resize(201);
	int flg=0,i,x;
	cin>>s;
	while(1) {
		x=0;
		ss='\0';
		sss='\0';
		if(strlen(s)%2==0) {
			for(i=0;i<strlen(s);i++) {
				if(strlen(s)/2>i) ss+=s[i];
				else sss+=s[i];
			}
			if(ss==sss&&flg==1) {
				break;
			}
		}
		s[strlen(s)-1]='\0',flg=1;
		
	}cout<<strlen(s)<<endl;
}
	

Measured memory_bytes: 256
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

int main() {
    vector<string> vc = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin >> s;
    for (int i = 0; i < 7; ++i) {
        if (s == vc[i]) cout << 7 - i;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  cin>>s>>t;
  int sum=s.size(),som=t.size();
  rep(i,max(sum,som)){
      if(i<sum){
	  cout<<s[i];
      }
      if(i<som){
	  cout<<t[i];
      }
  }
  cout<<'\n';
  
  return 0;
}


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

int main()
{
	string S;
	cin >> S;
	if (S == "Sunny")
		cout << "Cloudy\n";
	else if (S == "Cloudy")
		cout << "Rainy\n";
	else
		cout << "Sunny\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

int main()
{
	string S;
	cin>>S;
	int n=S.length();
	bool flag =true;
	for(int i=0;i<n/2;i++)
	{
		if(S[i]!=S[n-1-i]){flag=false;}
	}
	for(int i=0;i<(n-1)/2;i++)
	{
		if(S[i]!=S[(n-1)/2-1-i]){flag=false;}
	}
	for(int i=(n+3)/2-1;i<n/2;i++)
	{
		if(S[i]!=S[(n+3)/2+n-2-i]){
			flag=false;}
		
	}
	cout<<(flag?"Yes":"No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXQ = 1e7 + 5;
const int MAXN = 1e3 + 5;
const int MAXP = 5e3 + 5;
const int INF = 1e9;
const long long INFLL = 1e18;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
struct edge {int dest, flow, pos, cost; };
vector <edge> a[MAXP];
int s, t, tot, flow; ll cost;
ll dist[MAXP]; int path[MAXP], home[MAXP];
void FlowPath() {
	int p = t, ans = INF;
	while (p != s) {
		ans = min(ans, a[path[p]][home[p]].flow);
		p = path[p];
	}
	flow += ans;
	cost += ans * dist[t];
	p = t;
	while (p != s) {
		a[path[p]][home[p]].flow -= ans;
		a[p][a[path[p]][home[p]].pos].flow += ans;
		p = path[p];
	}
}
bool spfa() {
	static int q[MAXQ];
	static bool inq[MAXP];
	static int l = 0, r = 0;
	for (int i = 0; i <= r; i++)
		dist[q[i]] = -INFLL;
	q[l = r = 0] = s, dist[s] = 0, inq[s] = true;
	while (l <= r) {
		int tmp = q[l];
		for (unsigned i = 0; i < a[tmp].size(); i++)
			if (a[tmp][i].flow != 0 && dist[tmp] + a[tmp][i].cost > dist[a[tmp][i].dest]) {
				dist[a[tmp][i].dest] = dist[tmp] + a[tmp][i].cost;
				path[a[tmp][i].dest] = tmp;
				home[a[tmp][i].dest] = i;
				if (!inq[a[tmp][i].dest]) {
					q[++r] = a[tmp][i].dest;
					inq[q[r]] = true;
				}
			}
		l++, inq[tmp] = false;
	}
	return dist[t] != -INFLL;
}
void addedge(int x, int y, int z, int c) {
	a[x].push_back((edge){y, z, a[y].size(), c});
	a[y].push_back((edge){x, 0, a[x].size() - 1, -c});
}
int n, mid[4], cntx[MAXN], cnty[MAXN];
pair <int, int> posx[MAXN], posy[MAXN];
int main() {
	read(n), tot = 2 * n;
	s = ++tot, t = ++tot;
	for (int i = 0; i <= 3; i++)
		mid[i] = ++tot;
	for (int i = 1; i <= n; i++) {
		read(posx[i].first), read(posx[i].second), read(cntx[i]);
		addedge(s, i, cntx[i], 0);
		addedge(i, mid[0], INF, -posx[i].first - posx[i].second);
		addedge(i, mid[1], INF, posx[i].first - posx[i].second);
		addedge(i, mid[2], INF, -posx[i].first + posx[i].second);
		addedge(i, mid[3], INF, posx[i].first + posx[i].second);
	}
	for (int i = 1; i <= n; i++) {
		read(posy[i].first), read(posy[i].second), read(cnty[i]);
		addedge(n + i, t, cnty[i], 0);
		addedge(mid[0], n + i, INF, posy[i].first + posy[i].second);
		addedge(mid[1], n + i, INF, -posy[i].first + posy[i].second);
		addedge(mid[2], n + i, INF, posy[i].first - posy[i].second);
		addedge(mid[3], n + i, INF, -posy[i].first - posy[i].second);
	}
	for (int i = 1; i <= tot; i++)
		dist[i] = -INFLL;
	while (spfa()) FlowPath();
	writeln(cost);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	int n;
	cin >> n;
	vector <int> a(n);
	vector <int> hash((int)1e6 + 1,0);
	for(int i = 0;i < n;++i){
		cin >> a[i]; 
		++hash[a[i]];
	}
	if(hash[1] == 1){
		cout << 1 << newl;
		return;
	}
	else if(hash[1] > 1){
		cout << 0 << newl;
		return;
	}
	int count = 0;
	for(int i = 0;i < n;++i){
		if(hash[a[i]] > 1) continue;
		++count;
		for(int j = 2;j * j <= a[i];++j){
			if(a[i] % j == 0){
				if(!(hash[j] == 0 and hash[a[i] / j] == 0)){
					--count;
					break;
				}
			}
		}
	}
	cout << count << newl;

	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 7948
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;

    int r = 0;
    for (const auto& c : s) {
        r += c - '0';
    }

    cout << (r % 9 == 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3752
h,w=map(int,input().split())
s=[]
for _ in range(h):
	s.append(input())
num=[[-1]*w for _ in range(h)]
stack=[]
def dfs():
	while stack:
		r=stack.pop()
		for x in ((1,0),(-1,0),(0,1),(0,-1)):
			a,b,c,d=r[0],r[1],x[0],x[1]
			if 0<=a+c<h and 0<=b+d<w:
				if s[a+c][b+d]!=s[a][b] and num[a+c][b+d]==-1:
					num[a+c][b+d]=num[a][b]
					stack.append((a+c,b+d))
color=0
for i in range(h):
	for j in range(w):
		if num[i][j]==-1:
			stack.append((i,j))
			num[i][j]=color
			dfs()
			color+=1
color_num=[[0,0]for _ in range(color)]
for i in range(h):
	for j in range(w):
		if s[i][j]==".":
			color_num[num[i][j]][0]+=1
		else:
			color_num[num[i][j]][1]+=1
ans=0
for x in color_num:
	ans+=x[0]*x[1]
print(ans)

Measured memory_bytes: 23028
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,sum;
    cin>>n>>m>>sum;
    long long num=n/m+1;
    if (n%num==0) num-=1;

    for (int i=0;i<m;i++){
      cout<<sum<<" ";
    }
    if (sum!=1e9){
    for (int i=0;i<n-m;i++){
            cout<<(long long)1e9<<" ";
    }
}
    else{
        for (int i=0;i<n-m;i++){
            cout<<(long long)1e9/(n-m+3)<<" ";
    }
    }
    return 0;
}


Measured memory_bytes: 3588
import sys
from operator import itemgetter
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

k,x = na()
r = x - (k -1)
l = x + (k - 1)
for i in range(r, l):
    print(i, end=" ")
print(l)



Measured memory_bytes: 3188
program main
    implicit none
    integer,allocatable:: A(:,:)
    integer N,tmp,max,i,j

    read(*,*) N
    allocate(A(N,2))
    
    read(*,*) A(:,1)
    read(*,*) A(:,2)

    max=0
    do i=1,N
        tmp=0
        do j = 1,i
            tmp = tmp+A(j,1)
        enddo
        do j=i,N
            tmp = tmp+A(j,2)
        enddo

        if(tmp>max) max=tmp
    enddo

    write(*,*) max

end program

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

const int C = 50;

ll solve(vector<int> a, vector<int> b) {
    int n = a.size();

    vector<vector<set<ll>>> e(C + 1, vector<set<ll>>(C + 1));
    for (int i = 0; i <= C; i++) {
        for (int j = 0; j <= C; j++) {
            function<void(int, ll)> rec = [&](int cur, ll mask) {
                if (cur < j) return;
                if (cur == j) {
                    e[i][j].insert(mask);
                    return;
                }
                for (int t = j + 1; t <= cur; t++) {
                    rec(cur % t, mask | (1LL << t));
                }
            };
            rec(i, 0);
        }
    }

    auto can = [&](ll mask) {
        for (int i = 0; i < n; i++) {
            bool ok = 0;
            for (ll cmask : e[a[i]][b[i]]) {
                if ((cmask & mask) == cmask) {
                    ok = 1;
                }
            }
            if (!ok) return false;
        }
        return true;
    };

    ll taken = (1LL << (C + 1)) - 1;
    if (!can(taken)) return -1;
    for (int i = C; i >= 0; i--) {
        taken ^= 1LL << i;
        if (!can(taken)) {
            taken ^= 1LL << i;
        }
    }
    return taken;

}

void test() {
    int n = 50;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        a[i] = rand() % 10 + 40;
        b[i] = rand() % 20;
    }
    solve(a, b);
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
    exit(0);
}

int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif
    //test();

    int n;
    while (cin >> n) {
        vector<int> a(n);
        for (int i = 0; i < n; i++) scanf("%d", &a[i]);
        vector<int> b(n);
        for (int i = 0; i < n; i++) scanf("%d", &b[i]);

        cout << solve(a, b) << endl;
    }

#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>



int main() {
	ll n, r;
	cin >> n >> r;
	cout << r + max(0ll, 10 - n) * 100 << endl;
}



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

using ll  = long long;
using pii = pair<int,int>;
#define dbg(n) cout<<'\n'<<#n<<" is "<<n<<'\n';
#define pb push_back
#define all(v) v.begin(), v.end()
#define cs(i) cout<<"Case "<<i+1<<": \n"; 
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"

const int N   = 2e5+5;
const int INF = 0x7fffffff;



int main(){
    int n,t,hold=0; 
    FAST
    
    cin>>n;
    cout<<n+n*n+n*n*n<<endl;
    
    return 0;
}

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

const int sz = 1e6+5;
int cnt[sz];
int hit[sz];
int pos[sz];

int main() {
  int N;
  cin >> N;
  memset(pos, -1, sizeof pos);
  int dat[N];
  for (int i = 0; i < N; ++i) {
    cin >> dat[i];
    pos[dat[i]] = i + 1;
    ++cnt[dat[i]];
  }
  for (int i = 1; i < sz; ++i) {
    if (cnt[i]) {
      hit[i] |= cnt[i] > 1;
      for (int j = i + i; j < sz; j += i) {
        hit[j] = 1;
      }
    }
  }
  int valid = 0;
  for (int i = 1; i < sz; ++i) {
    if (!hit[i] && pos[i] != -1) {
      ++valid;
    }
  }
  cout << valid << '\n';
  return 0;
}


Measured memory_bytes: 16016
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
int N;
ll x, A[100001], B[100001];

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

  cin >> N >> x;
  ll a;
  rep(i, N){
    cin >> a;
    A[i] = a;
    B[i] = a;
  }
  ll cnt = 0ll;
  rep(i, N-1){
    ll sm = A[i]+A[i+1];
    if (sm <= x) continue;
    
    if (A[i+1] >= sm-x){
      A[i+1]-=(sm-x);
      cnt += (sm-x);
    } else {
      A[i] -= (sm - x - A[i+1]);
      A[i+1] = 0;
      cnt += sm -x;
    }
  }
  ll cnt2 = 0ll;
  for (int i=N-1; i>=1; i--){
    ll sm2 = B[i]+B[i-1];
    if (sm2 <= x) continue;
    if (B[i-1] >= sm2-x){
      B[i-1]-=sm2-x;
      cnt2 += sm2-x;
    }else{ 
      B[i] -= (sm2 - x - B[i-1]);
      B[i-1] = 0;
      cnt2 += sm2 - x;
    }
  }

  cout << min(cnt, cnt2) << "\n";
  return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
	int a,b=0,c=0;
	scanf("%d",&a);
	c=a;
	
	while(a>0){
	b+=a%10;
	b*=10;
	a/=10;
	}
	b/=10;
	
	if(b==c)
		printf("Yes\n");
	else
		printf("No\n");
	
	return 0;
}

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

int main(int argc, const char * argv[]) {
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    
    int t=0;
    for(;t<=K&&B<=A;++t){
        B<<=1;
    }
    for(;t<=K&&C<=B;++t){
        C<<=1;
    }
    cout<<((t<=K)?"Yes":"No")<<endl;
    
    return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;
typedef long long ll;
int maxn = 1e8;
int T;

int main() {
   int T;
   int ans=0;
   int a,b;
   cin>>T;

   while(T--)
   {
       cin>>a>>b;
       ans+=(b-a+1);
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
  string s, t;
  int ans = 1e9;
  cin >> s >> t;
  rep(si, s.size()){
  	if(si+t.size() > s.size()) break;
    int count = 0;
    rep(i, t.size()){
      if(s[si + i] != t[i]) count++;
    }
    ans = min(ans, count);
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef pair<long long, long long>pll;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 200050;
const double pi = acosl(-1); constexpr double EPS = 1e-10;
constexpr ll INF = 1e16;
void yes(bool c) { if (c)print("Yes"); else print("No"); };

int las[300020];
int nxt[400020];
void solve() {
	int N, K; cin >> N >> K;
	vector<int>A(2*N);
	REP(i, N) {
		cin >> A[i];
		A[i + N] = A[i];
	}
	REPR(i, 2 * N) {
		nxt[i] = las[A[i]]%N;
		las[A[i]] = i;
	}
	vector<int>v;
	int now = 0;
	while (true) {
		int nx = nxt[now];
		if (nx <= now) {
			v.push_back(now);
		}
		now = (nx + 1) % N;
		if (now == 0) break;
	}
	int k = v.size();
	//print(v.size());
	//for (auto x : v)pe(x);
	K = K % (k+1);
	K--;
	if (K >= 0) {
		for (int i = v[K]; i < N;) {
			if (nxt[i] > i) {
				i = nxt[i] + 1;
			}
			else {
				pe(A[i]);
				i++;
			}
		}
		//FOR(i, v[K], N)pe(A[i]);
	}cout << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 10992
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
//#include <map>
#include <iomanip>
#include <vector>

using namespace std;


char map[100][100];
int dh[] = {0, -1, 1, 0};
int dw[] = {-1, 0, 0, 1};
int H, W, cnt;


void dfs(int h, int w, char fruit)
{
	map[h][w] = '.';
	
	for (int i=0; i<4; i++)
	{
		int nh, nw;
		
		nh = h + dh[i];
		nw = w + dw[i];
		if (0<=nh && nh<H && 0<=nw && nw<W && map[nh][nw]==fruit)
		{
			dfs(nh, nw, fruit);
		}
	}
}


int main()
{
	while (cin >> H >> W)
	{
		if (H == 0 && W == 0) break;
		
		//入力
		for (int i=0; i<H; i++)
		{
			cin >> map[i];
		}
		
		//dfs(0, 0, map[0][0]);
		
		cnt = 0;
		for (int i=0; i<H; i++)
		{
			for (int j=0; j<W; j++)
			{
				if (map[i][j] != '.')
				{
					cnt++;
					dfs(i, j, map[i][j]);
				}
			}
		}
		cout << cnt << endl;
		
		/*
		for (int i=0; i<H; i++)
		{
			cout << map[i] << endl;
		}
		*/
	}
	
	return 0;
}

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string a;
	cin >> a;
	for (int i = 0; i < 3; i++)
	{
		cout << a[i];
	 } 
	return 0;
}


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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

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

    vector<int> sn(n);
    rep(k,i)
    {
        int d;
        cin >> d;
        rep(d,j)
        {
            int a;
            cin >> a;
            a--;
            sn[a]++;
        }
    }

    int ans = 0;
    for (auto &&s : sn)
    {
        if (s<=0) ans++;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  lvector A(n);rep(i,n) cin>>A[i];
  lvector div(1000001,0);
  rep(i,n) {
    ll tmp=A[i];
    if(tmp%2==0) {div[2]++;while(tmp%2==0) tmp/=2;}
    for(ll d=3;d*d<=tmp;d+=2) if(tmp%d==0) {div[d]++;while(tmp%d==0) tmp/=d;}
    if(tmp>1) div[tmp]++;
  }
  ll m=*max_element(ALL(div));
  if(m<2) print("pairwise coprime");
  else if(m<n) print("setwise coprime");
  else print("not coprime");
  return 0;
}

Measured memory_bytes: 18652
N,M,Q = map(int,input().split())

a = map(int,input().split())
q = map(int,input().split())

t = [ i for i in range(N) ]
n = N
i = 0
for aa in a:
    if aa % 2 == 1:
        i = (i - aa) % n
    else:
        i = (i + aa) % n
    del t[i]
    n -= 1
    
for i in q:
    if i in t:
        print(1)
    else:
        print(0)



Measured memory_bytes: 26972
// https://atcoder.jp/contests/abc123/tasks/abc123_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<int> A(X), B(Y), C(Z);
    for (auto &x : A)
        cin >> x;
    for (auto &x : B)
        cin >> x;
    for (auto &x : C)
        cin >> x;
    sort(ALLR(A));
    sort(ALLR(B));
    sort(ALLR(C));
    vector<int> ans;
    for (int a = 0; a < X; a++) {
        for (int b = 0; b < Y && (a + 1) * (b + 1) <= K; b++) {
            for (int c = 0; c < Z && (a + 1) * (b + 1) * (c + 1) <= K; c++) {
                ans.emplace_back(A[a] + B[b] + C[c]);
            }
        }
    }
    sort(ALLR(ans));
    REP(i, K) { cout << ans[i] << "\n"; }

    return 0;
}


Measured memory_bytes: 1404
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;


int main()
{
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 1;i < n;i++) {
		string a = s.substr(i);
		string b = s.substr(0, i);
		int cnt = 0;
		map<char, int> mp;
		rep(j, b.length()) {
			if (mp[b[j]] != 0) continue;
			mp[b[j]]++;
			rep(h, a.length()) {
				if (b[j] == a[h]) {
					cnt++;
					break;
				}
			}
		}ans = max(ans, cnt);
	}cout << ans;
}

Measured memory_bytes: 3632
n,k = map(int,input().split())
A = list(map(int,input().split()))
if n == 1:
    print(1)
else:
    for _ in range(k):
        flag = 0
        imos = [0]*(n+1)
        for i,a in enumerate(A):
            imos[max(0,i-a)] += 1
            imos[min(n,i+a+1)] -= 1
        flag = (imos[0] != n)
        for i in range(n-1):
            imos[i+1] += imos[i]
            if imos[i+1] != n:
                flag = 1
        A = imos[:n].copy()
        if not flag:break
    print(' '.join(str(i) for i in A))


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

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var x = int.Parse(line[1]);
        var m = int.Parse(line[2]);
        var a = new int[m, 3];
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            a[i, 0] = int.Parse(line[0]);
            a[i, 1] = int.Parse(line[1]);
            a[i, 2] = int.Parse(line[2]);
        }
        getAns(n, x, m, a);
    }
    static void getAns(int n, int x, int m, int[,] a)
    {
        var q = new Queue<string>();
        q.Enqueue("");
        while (true)
        {
            var p = q.Peek();
            if (p.Length == n) break;
            var p2 = q.Dequeue();
            for (int i = 0; i <= x; i++)
                if (i < 10) q.Enqueue(p2 + i.ToString());
                else q.Enqueue(p2 + "a");
        }
        var ansmax = -1;
        var ansS = "";
        while (q.Count() > 0)
        {
            var p = q.Dequeue();
            var aa = getArray(p);
            if (check(a, aa))
            {
                var gs = getSum(p);
                if (gs > ansmax) { ansmax = gs; ansS = p; }
            }
        }
        if (ansS == "") Console.WriteLine(-1);
        else print(ansS);
    }
    static void print(string s)
    {
        var ans = new int[s.Length];
        for (int i = 0; i < s.Length; i++)
            if (s[i] == 'a') ans[i] = 10;
            else ans[i] = s[i] - '0';
        Console.WriteLine(string.Join(" ", ans));
    }
    static int getSum(string s)
    {
        var ans = 0;
        for (int i = 0; i < s.Length; i++)
            if (s[i] == 'a') ans += 10;
            else ans += s[i] - '0';
        return ans;
    }
    static bool check(int[,] a, int[] b)
    {
        var imax = a.GetLength(0);
        for (int i = 0; i < imax; i++)
            if (b[a[i, 1]] - b[a[i, 0] - 1] != a[i, 2]) return false;
        return true;
    }
    static int[] getArray(string s)
    {
        var sL = s.Length;
        var a = new int[sL + 1];
        for (int i = 0; i < sL; i++)
        {
            var w = s[i] == 'a' ? 10 : s[i] - '0';
            a[i + 1] = a[i] + w;
        }
        return a;
    }
}



Measured memory_bytes: 111404
using System;
using System.Linq;

class D
{
	static void Main()
	{
		Console.ReadLine();
		var d = Console.ReadLine().Select((c, i) => new { c, i }).ToLookup(_ => _.c, _ => _.i);

		var q = from i1 in d.Select(g => g.First())
			from i2 in d.Select(g => g.FirstOrDefault(x => x > i1)).Where(x => x > 0)
			select d.Count(g => g.Any(x => x > i2));
		Console.WriteLine(q.Sum());
	}
}


Measured memory_bytes: 13920