akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    ll n1,n2,n3,n4,n5;
    cin >> n1 >> n2>>n3>>n4>>n5;
    if(n1 == 0)cout << 1 << endl;
    if(n2 == 0)cout << 2 << endl;
    if(n3 == 0)cout << 3 << endl;
    if(n4 == 0)cout << 4 << endl;
    if(n5 == 0)cout << 5 << endl;
}

Measured memory_bytes: 3636
# import numpy as np
# import math
import sys
input = sys.stdin.readline

S = input()

N = len(S) - 1

numW = S.count('W')
numB = N - numW
if (numW == N) | (numW == 0):
    print(0)
    sys.exit()

res = 0
checked = 0

for i in range(1,N):
    if S[i] != S[i-1]:
        res += 1

print(res)

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;
const ll INF = 1000000000000LL;

int main(void)
{
	int n, k;
	ll ans = INF;
	vector<ll> a[2];
	cin >> n >> k;
	rep(i, n){
		int t;
		cin >> t;
		if(t >= 0) a[1].push_back(t);
		else a[0].push_back(-1 * t);
	}
	sort(all(a[0]));
	sort(all(a[1]));
	rep(i, k + 1){
		int j = k - i;
		if(i == 0 && a[1].size() >= k) chmin(ans, a[1][k - 1]);
		else if(j == 0 && a[0].size() >= k) chmin(ans, a[0][k - 1]);
		else if(a[0].size() >= i && a[1].size() >= j){
			chmin(ans, 2 * a[1][j - 1] + a[0][i - 1]);
			chmin(ans, 2 * a[0][i - 1] + a[1][j - 1]);
		}
		// cout << ans << " ";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1656
#include <stdio.h>

int main(){
  int n, m;  scanf("%d%d", &n, &m);
  long long int h[100002];
  int hisno[100002] = {0};
  for(int i=1; i<=n; i++)  scanf("%lld", &h[i]);

  for(int i=0; i<m; i++){
    int a, b;
    scanf("%d%d", &a, &b);

    if(h[a] > h[b]){
      hisno[b] = 1;
    }else if(h[a] < h[b]){
      hisno[a] = 1;
    }else if(h[a] == h[b]){
      hisno[a] = 1;
      hisno[b] = 1;
    }
  }

  int count = 0;
  for(int i=1; i<=n; i++){
    if(hisno[i] == 0){
      count++;
    }
  }

  printf("%d\n", count);
  return 0;
}

  
  


Measured memory_bytes: 2904
s = input()
n = len(s)
ans = 0

def pm(i,j,k):
  global ans
  if i == n-1:
    k += int(s[j+1:])
    ans += k
  else:
    pm(i+1,i,k+int(s[j+1:i+1]))
    pm(i+1,j,k)
pm(0,-1,0)
print(ans)

Measured memory_bytes: 38256
#coding:utf-8
from collections import deque
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True

def index(a,b):
    return str(min(a,b)) + "," +  str(max(a, b))

def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]


    x = II()
    y = x // 100
    if y*100 <= x <= y*100+y*5 or x >= 2000:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    int n; cin >> n;
    V<int> B(n);
    loop (n - 1, i) cin >> B[i];
    B[n - 1] = B[n - 2];
    ll ans = B[0];
    loop (n - 1, i) {
        ans += min(B[i], B[i + 1]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0'){
	t=(t<<3)+(t<<1)+v-48;
	v=getchar();}
	return t;
}
inline int ksm(re int x,re int y){
	int ans=1;
	while(y){
		if(y&1)ans*=x;
		x*=x;
		y>>=1;
	}
	return ans;
}long long n,k,a[102];
inline int check(re int x){
	int ans=0;
	for(re int i=1;i<=n;++i){
		ans+=(a[i]-x)*(a[i]-x);
	}
	return ans;
}
int ans;
signed main(){
	n=read();
	for(re int i=1;i<=n;++i)a[i]=read();
	ans=1e18;
	for(re int i=1;i<=100;++i)if(check(i)<ans)ans=check(i);
	printf("%lld",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int k;
	cin >> k;
	int a[n];
	zip(i, 0, n)
	{
		cin >> a[i];
	}
	pii c[n];
	zip(i, 0, n)
	{
		int x = a[i];
		int y = 0;
		int z = 0;
		zip(j, i + 1, n)
		{
			if (a[j] < a[i])
			{
				y++;
			}
		}
		zip(j, 0, n)
		{
			if (a[j] < a[i])
			{
				z++;
			}
		}
		c[i].ff = y;
		c[i].ss = z;
	}
	int ans = 0;
	zip(i, 0, n)
	{
		ans += (k % mod * c[i].ff % mod) % mod;
		ans = (ans + (((k - 1) * k / 2 % mod) * c[i].ss) % mod) % mod;
	}
	cout << ans << en;

	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
i = 1
manzoku = sum(B)
while N>i:
    if A[i]-A[i-1] == 1:
      j = A[i-1]
      manzoku += C[j-1]
    i += 1
print(manzoku)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	String[] word = scan.next().split(",");
	
	System.out.println(word[0] + ' ' + word[1] + ' ' + word[2]);
	scan.close();
    }
}


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

int main()
{
    int k, a, b;
    string ans("NG");

    cin >> k >> a >> b;

    for (int i = 0; i <= b - a; i++)
    {
        if ((a + i) % k == 0)
        {
            ans = "OK";
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
S = list(input().strip())
is_irrversible = 0
answer = 0
position_key_sum = 0
number_of_white = 0
sigma = 0
for i in range(len(S)):
    if S[i] == 'W':
        position_key_sum += (i+1)
        number_of_white += 1
        sigma += number_of_white
answer = position_key_sum - sigma
print(answer)

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
#define MOD 1'000'000'007

int c[N];
set<int> s[N];
ll a[N];

int main(){
	int n; scanf("%d", &n);
	REP(i, n){
		scanf("%d", c+i);
		s[c[i]].insert(i);
	}
	REP(i, N) s[i].insert(n);
	a[n]=1;
	for(int i=n-1; i>=0; i--){
		a[i]=a[i+1];
		int p=*s[c[i]].upper_bound(i);
		if(p!=n && p-i>=2){
			a[i]+=a[p];
		}
		a[i]%=MOD;
	}
	printf("%lld\n", a[0]);
}


Measured memory_bytes: 32000
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
	char a[1100];
	char b[1100];
	int i, j;
	int la, lb;
	int l;
	scanf("%s", &a);
	scanf("%s", &b);
	la = strlen(a);
	lb = strlen(b);
                                // 	l = (la >= lb ? la : lb);
                              //	printf("%d\n", l);
	if(la == lb)
	{
	for(i = 0; ; i++)
	{
		if(a[i] > b[i])
		{
			printf("GREATER\n");
			break;
		}
			else if(a[i] < b[i])
			{
				printf("LESS\n");
				break;
			}
				else if(a[i] == b[i])
				{
					if(i != la - 1)
						continue;
						else if(i == la - 1)
						{
							printf("EQUAL\n");
							break;
						}
							
				}

	}
	}
	else if(la < lb)
		printf("LESS\n");
		else if(la > lb)
			printf("GREATER\n");

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

int main() {
    ll n;
    ll a[101], b[101];
    cin>>n;
    REP(i, 0, n) a[i]=inf;
    REP(i, 0, n-1) cin>>b[i];

    REP(i, 0, n-1){
        a[i]=min(a[i], b[i]);
        a[i+1]=min(a[i+1], b[i]);
    }
    ll sum=0;
    REP(i, 0, n) sum+=a[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef struct node {
  int parent;
  int left;
  int right;
}Node;

int Depth(int);
Node trees[100000];
int depth[100000];
int main(){
  int c,n,i,j,k,id,l=0,r,H;

    scanf("%d",&n);
    
    for(i=0;i<n;i++){
    trees[i].parent=-1;
    trees[i].left=-1;
    trees[i].right=-1;
  }
    
  for(i=0;i<n;i++) {
    scanf("%d %d",&id,&k);
    for(j=0;j<k;j++) {
      scanf("%d",&c);
      if(j==0) trees[id].left=c;
      else trees[l].right=c;
      l=c;
      trees[c].parent=id;
    }
  }
  
    for(i=0;i<n;i++){
    depth[i] = Depth(i);
     
    if ( depth[i] > H ) {
      H = depth[i];
    }
     
  }

    for(i=0;i<n;i++) {
      printf("node %d: ",i);
      printf("parent = %d, ",trees[i].parent);
      printf("depth = %d, ",depth[i]);
      if(trees[i].parent == -1)printf("root, ");
      else if(trees[i].left == -1)printf("leaf, ");
      else printf("internal node, ");
      printf("[");
      for(j = 0,c=trees[i].left;c!=-1;j++,c=trees[c].right){
	if(j!=0)printf(", ");
	printf("%d",c);
	
      }
      printf("]\n");
    }
    return 0;
}

int Depth(int u){
   int d = 0;
   
  while(1){
     
    u = trees[u].parent;
    if ( u == -1 ) break;
    d++;
     
  }
  return d;
   
}

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

int main(){

int N;
cin >> N;

vector<int>V(N), C(N);

for(int i = 0; i < N; i++){ 
    cin >> V.at(i);
}

for(int i = 0; i < N; i++){ 
    cin >> C.at(i);
}

int ans = 0;

for(int i = 0; i < N; i++){ 
     if(V.at(i) > C.at(i)){
         ans += V.at(i) - C.at(i);
     }
}

cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int check(int a, int b, int c){
    if (a>b){
        if (a<c){
            return 1;
        }
        return 0;
    }
    else{
        if (a>c){
            return 1;
        }
        return 0;
    }
}

int main(){   
    int n = 0;
    cin >> n;  
    int prev = 0;
    int current = 0;
    int next = 0;

    cin >> prev;
    cin >> current;
    cin >> next;
    int sum = 0;
    sum += check(current, prev, next);

    for (int i=0 ;i<n-3; ++i){
        int x = 0;
        cin >> x;
        prev = current;
        current = next;
        next = x;
        sum += check(current,prev, next);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace Atcoder_0404
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = GetInput_long()[0];
            var checklist = new bool[K + 1];
            for(int i = 0; i < checklist.Length; i++)
            {
                checklist[i] = false;
            }
            long result = 1;
            //モッド使って調べていく
            long check = 7;
            while (check % K != 0)
            {
                check = check * 10 + 7;
                check %= K;
                result++;
                if (checklist[check])
                {
                    result = -1;
                    break;
                }
                else
                {
                    checklist[check] = true;
                }
            }

            Console.WriteLine(result);
        }

        #region input


        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion
        
    }
}

Measured memory_bytes: 28320
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <deque>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/


int main()
{
	ll n;
	
	scanf("%lld", &n);
	ll m = sqrt(2 * n);
	m -= 1;
	while (1) {
		if (m * (m + 1) >= 2 * n)  {
			break;
		}
		m++;
	}
	printf("%lld\n", m);
}

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

int main(){
  int N;
  cin >> N;
  double ans;
  double x;
  string u;
  for (int i;i<N;i++){
    cin >>x>>u;
    ans=u=="JPY"?ans+x:ans+x*380000.0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>
#include <chrono>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const double EPS = 1e-9;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << (a.back() == b.front() && b.back() == c.front() ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

string s1, s2;
int dp[3001][3001];
pii prv[3001][3001];
string ans;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> s1 >> s2;
	for (int i = 1; i <= s1.size(); i++) 
		for (int j = 1; j <= s2.size(); j++) {
			if (s1[i - 1] == s2[j - 1]) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
			else dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);

			if (dp[i][j] == dp[i - 1][j - 1] + 1) prv[i][j] = { i - 1,j - 1 };
			if (dp[i][j] == dp[i][j - 1]) prv[i][j] = { i,j - 1 };
			if (dp[i][j] == dp[i - 1][j]) prv[i][j] = { i - 1,j };
		}
	
	int pos1 = s1.size(), pos2 = s2.size();
	while (pos1 != 0 && pos2 != 0) {
		if (prv[pos1][pos2] == pii(pos1 - 1, pos2 - 1)) {
			ans += s1[pos1 - 1];
			pos1--, pos2--;
		}
		else if (prv[pos1][pos2] == pii(pos1 - 1, pos2)) pos1--;
		else if (prv[pos1][pos2] == pii(pos1, pos2 - 1)) pos2--;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 105856
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pii pair<int,int>
#define reset(x,n) memset((x),(n),sizeof(x))
#define all(n) (n).begin(),(n).end()
#define pb push_back
#define IOS ios::sync_with_stdio(0),cin.tie(0);
bitset<10010> ok[5005];
int stick[] = {0,2,5,5,4,5,6,3,7,6};
bool used[10];
int n,m;

int main(){
	ok[0][0] = 1;
	cin>>n>>m;
	for(int i=1,x;i<=m;i++){
		cin>>x;
		used[x] = 1;
	}
	for(int i=0;i<5000;i++){
		for(int j=0;j<=10000;j++){
			if(ok[i][j]){
				for(int k=1;k<=9;k++){
					if(used[k]){
						ok[i+1][j+stick[k]] = 1;
					}
				}
			}
		}
	}
	int now = n;
	string ans = "";
	int st = 5000;
	while(!ok[st][now]) st--;
	for(int i=st;i>=1;i--){
		for(int j=9;j>=1;j--){
			if(used[j] && now >= stick[j] && ok[i-1][now-stick[j]]){
				ans += j + '0';
				now -= stick[j];
				break;
			}
		}
	}
	cout<<ans<<'\n';	
}


Measured memory_bytes: 9740
#pragma comment(linker, "/STACK:512000000")
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(__attribute__((unused)) bool);
void precalc();
clock_t start;
#define FILENAME ""

int main() {
#ifdef AIM
    string s = FILENAME;
//    assert(!s.empty());
    freopen("/home/alexandero/ClionProjects/cryptozoology/input.txt", "r", stdin);
#else
//    freopen(FILENAME ".in", "r", stdin);
//    freopen(FILENAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
#ifndef AIM
    cout.sync_with_stdio(0);
    cin.tie(0);
#endif
    precalc();
    cout.precision(10);
    cout << fixed;
    //cin >> t;
    int testNum = 1;
    while (t--) {
        //cout << "Case #" << testNum++ << ": ";
        solve(true);
    }
    cout.flush();
#ifdef AIM1
    while (true) {
      solve(false);
  }
#endif

#ifdef AIM
    cout.flush();
    auto end = clock();

    usleep(10000);
    print_stats(end - start);
    usleep(10000);
#endif

    return 0;
}

template<typename T>
T binpow(T q, T w, T mod) {
    if (!w)
        return 1 % mod;
    if (w & 1)
        return q * 1LL * binpow(q, w - 1, mod) % mod;
    return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
    while (w) {
        q %= w;
        swap(q, w);
    }
    return q;
}
template<typename T>
T lcm(T q, T w) {
    return q / gcd(q, w) * w;
}

template <typename T>
void make_unique(vector<T>& a) {
    sort(all(a));
    a.erase(unique(all(a)), a.end());
}

template<typename T>
void relax_min(T& cur, T val) {
    cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
    cur = max(cur, val);
}

void precalc() {
}

//#define int li
//const int mod = 1000000007;

void solve(__attribute__((unused)) bool read) {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    li res = 0;
    for (int w = 0; w < 2; ++w) {
        set<pair<int, int>> rig;
        set<pair<int, int>, greater<pair<int, int>>> lef;
        for (int i = 0; i < n; ++i) {
            rig.insert({a[i].second, i});
            lef.insert({a[i].first, i});
        }
        int x = 0;
        li cur_res = 0;
        for (int s = 0; s < n; ++s) {
            int to_erase = -1;
            if ((s + w) % 2 == 0) {
                to_erase = lef.begin()->second;
            } else {
                to_erase = rig.begin()->second;
            }
            lef.erase({a[to_erase].first, to_erase});
            rig.erase({a[to_erase].second, to_erase});
            if (x > a[to_erase].second) {
                cur_res += x - a[to_erase].second;
                x = a[to_erase].second;
            } else if (x < a[to_erase].first) {
                cur_res += a[to_erase].first - x;
                x = a[to_erase].first;
            }
        }
        cur_res += abs(x);
        relax_max(res, cur_res);
    }
    cout << res << "\n";
}

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

using namespace std;

int main() {
    int h, w;
    string a;
    cin >> h >> w;
    ++w;
    for (int i = 0; i <= w; ++i) cout << '#';
    cout << endl;
    for (int i = 0; i < h; ++i) {
        cin >> a;
        cout << '#' << a << '#' << endl;
    }
    for (int i = 0; i <= w; ++i) cout << '#';
    cout << endl;
    return 0;
}


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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << endl;
#define endl "\n"
#define MOD (int) 1e9+7
#define inf (int) (1e18)

ll findCut(ll a[],ll n,ll mid){
    ll res=0;
    for(long int i=0;i<n;i++)
        res+=(a[i]-1)/mid;
    return res;
}

void solve() {
    ll n, k;
    cin >> n >> k;
    ll a[n];
    for (long int i = 0; i < n; i++)
        cin >> a[i];

    ll l = 1, r = INT_MAX, ans = INT_MAX;
    while (l <= r) {
        ll mid = (l + r) / 2;
        ll x = findCut(a, n, mid);
        if (x <= k) {
            ans = min(ans, mid);
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t=1;
    // cin >> t;
    for(long int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 5168
#include <stdio.h>

int minimum(int, int);

int main(){
    int n, m, a, b[100000], i, j;

    scanf("%d %d", &n, &m);

    for(i=0; i<=n; i++){
        b[i] = -1;
    }

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

    b[0] = 1;

    if(b[1] < 0)
        b[1] = 1;

    for(i=2; i<=n; i++){
        if(b[i] < 0)
            b[i] = (b[i-1] + b[i-2]) % 1000000007;
    }

    printf("%d\n", b[n]);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <unordered_map>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
using namespace std;

typedef long long ll;

int main(void)
{
	const int infity = 1e4;

	int n, x, y;
	cin >> n >> x >> y;

	x -= 1;
	y -= 1;

	vector<vector<int>> dist(n, vector<int>(n, infity));

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			dist[i][j] = abs(j - i);
		}
	}
	dist[x][y] = 1;
	
	/*for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			printf("%5d ", dist[i][j]);
		}
		printf("\n");
	}*/


	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			dist[i][j] = min(dist[i][j], dist[i][x] + dist[x][j]);
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			dist[i][j] = min(dist[i][j], dist[i][y] + dist[y][j]);
		}
	}

	vector<int> lut(n, 0);

	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			lut[dist[i][j]]++;
		}
	}

	for (int i = 1; i < n; i++)
	{
		cout << lut[i] << endl;
	}



	return 0;
}

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(16);

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

    map<string, int> polls;
    for (auto &&x : s)
    {
        polls[x] += 1;
    }

    int max_poll_count = 0;
    for (auto &&x : polls)
    {
        max_poll_count = max(x.second, max_poll_count);
    }

    for (auto &&x : polls)
    {
        if (x.second == max_poll_count)
            cout << x.first << endl;
    }
}


Measured memory_bytes: 25472
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")
    };
}

use std::cmp::min;
fn main() {
    input!{
        n: u64,
        a: u64,
        b: u64,
    }
    println!("{}", min(n * a, b));
}


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

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

    vector<string> s(N);
    for (int i = 0; i < N; i++){
        cin >> s.at(i);
    }

    int M;
    cin >> M;

    vector<string> t(M);
    for (int i = 0; i < M; i++){
        cin >> t.at(i);
    }

    map<string, int> mp;
    for(int i = 0; i < N; i++){
        mp[s.at(i)]++;
    }

    for(int i = 0; i < M; i++){
        mp[t.at(i)]--;
    }

    int ans;
    //string anskey;
    for(auto i = mp.begin(); i != mp.end(); i++){
        if(ans < i->second){
            ans = i->second;
            //anskey = i->first;
        }
    }

    //cout << anskey << endl;
    cout << ans << endl;

    return 0;
}

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

using namespace std;

bool Check(const char, const char);

int main(){
  int i, count;
  string s;

  cin >> s;

  for(i=0, count=0; i<s.size()/2;++i){
    if(!Check(s[i], s[s.size()-i-1])) ++count;
  }
  if(s.size()%2 == 1 && s[s.size()/2] != 'i' && s[s.size()/2] != 'w')
    ++count;

  cout << count << endl;
  return 0;
}

bool Check(const char a, const char b){
  if((a == 'i' && b == 'i')||(a == 'w' && b == 'w')||
     (a == '(' && b == ')')||(a == ')' && b == '(')) return true;
  return false;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> mochi(N);
    for (int i=0; i < N; i++){
        cin >> mochi.at(i);
    }

    sort(mochi.begin(), mochi.end());
    int steps = 1;
    for (int i = 0; i < N; i++){
        if (i != 0){
            if (mochi.at(i-1) != mochi.at(i)){
                steps++;
            }
        } 
    }
    cout << steps << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;
int main(){
    double R;
    cin >> R;
    cout << 2*R*3.14159265;
}

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

#define ll long long int
#define hell 998244353
#define vi vector <ll>
#define pb push_back
#define pii pair<ll,ll>
#define vii vector <pii>
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define sep(i,a,b)  for(ll i=a-1;i>=b;i--)
#define inf (ll)(1e16)

using namespace std;

void solve(){
    int n;
    cin>>n;
    int dp[n+1][3];
    memset(dp,0,sizeof dp);
    rep(i,1,n+1)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 1408
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();
		if(a>b){
			long z = a;
			a = b;
			b = z;
		}
		if(b>c){
			long z = c;
			c = b;
			b = z;
		}
		if(a>b){
			long z = a;
			a = b;
			b = z;
		}
		long ans = 0;
		if(a%2==0||b%2==0||c%2==0){
			ans = 0;
		} else {
			ans = a * b;
		}
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 8788
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;
//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
	int n;
	cin >> n;
	int ans = 1;
	map<int,int> cnt;
	for(int i =0;i<n;i++){
		int a;
		cin >> a;
		cnt[a]++;
		if(cnt[a]>1)
			ans = 0;
	}
	cout << (ans?"YES":"NO") << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 12972
r1, c1, r2, c2 = map(int, input().split())
mod = 10 ** 9 + 7

fac = [1]
for i in range(1, r2 + c2 + 10) :
  fac.append(fac[-1] * i % mod)
inv = [pow(fac[-1], mod - 2, mod)]
for i in range(r2 + c2 + 9, 0, -1) :
  inv.append(inv[-1] * i % mod)
inv = inv[::-1]

def comb(n, r) :
  return fac[n] * inv[n-r] * inv[r] % mod

def g(x, y) :
  return comb(x + y, y)

ret = g(r2+1, c2+1) - g(r2+1, c1) - g(r1, c2+1) + g(r1, c1)
ret %= mod

print(ret)

Measured memory_bytes: 142592
N = int(input())
a = map(int, input().split())

cnt = 0;
prev = -1
aa = []
for ai in a:
    if ai != prev:
        aa.append(cnt)
        cnt = 1
    else:
        cnt += 1
    prev = ai

aa.append(cnt)

ans = 0
for aai in aa:
    ans += aai // 2

print(ans)


Measured memory_bytes: 3316
/* ex5_4
    fmuacshai */
#include <stdio.h>

#define SIZE 80

int main(void){
    //配列の定義
    char string[SIZE];
    //ポインタの定義
    char *ptr;
    //配列の定義と初期化
    int number[SIZE]={0};
    //ポインタの定義
    int *sequence;
    //答えanswerと文字数カウントcount、for文で使うiを定義
    int answer=0,count=0,i;
    //文字列の入力
    scanf("%s",string);
    //ポインタと配列を対応
    ptr=&string[0];
    sequence=&number[1];
    //NULLが出るまで
    while(*ptr){
        //A,T,G,Cだったら
        if(*ptr=='A'||*ptr=='T'||*ptr=='G'||*ptr=='C'){
            *sequence=*(sequence-1)+1;
        //それ以外
        }else{
            *sequence=0;
        }
        ptr++;
        sequence++;
        count++;
    }
    //sequenceの位置を戻す
    sequence=sequence-count;
    //文字数分チェック
    for(i=0;i<count;i++){
        //sequence内で最大のものをanswerに
        if(*sequence>answer){
            answer=*sequence;
        }
        sequence++;
    }
    //出力
    printf("%d\n",answer);
    return 0;
}


Measured memory_bytes: 1728
def main():
    N = int(input())

    c = [[0 for _ in range(10)] for _ in range(10)]

    for n in range(1, N + 1):
        str_n = str(n)
        top = int(str_n[0])
        bottom = int(str_n[-1])

        c[top][bottom] += 1

    ans = 0
    for i in range(10):
        for j in range(10):
            ans += c[i][j] * c[j][i]

    print(ans)


main()


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

using ll = long long;

int main() {
	ll a, b; cin >> a >> b;

	if ((a % 2LL) != (b % 2LL)) { cout << "IMPOSSIBLE" << endl; }
	else { cout << (a + b) / 2LL << endl; }
}


Measured memory_bytes: 256
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [N] = r.nn()

    return Math.ceil(N / 2)
  }

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map(line => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}


Measured memory_bytes: 7372
#include <stdio.h>
#include <string.h>
int main(){
  char s[11];
  scanf("%s", s);
  if (strcmp(s, "hi") == 0 || strcmp(s, "hihi") == 0 || strcmp(s, "hihihi") == 0 || strcmp(s, "hihihihi") == 0 || strcmp(s, "hihihihihi") == 0) {
    puts("Yes");
    return 0;
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,k;
ll a[200005], b[200005];
int main(){
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] += a[i-1];
    }
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
        b[i] += b[i-1];
    }
    int R = m;
    int ans = 0;
    for (int i = 0; i <= n; i++){
        while (R >= 0 && a[i] + b[R] > k) R--;
        //printf("%d %d\n",i,R);
		if (a[i] + b[R] <= k) ans = max(ans,i+R);
    }
    printf("%d",ans);
}


Measured memory_bytes: 6872
N = int(input())

s = [None for _ in range(N)]

for i in range(N):
  s[i] = input()

s.sort()

max_list = []
max_v = 1

count = 1
prev = s[0]


for i in range(1, N):
  # print(s[i], prev, count)
  if s[i] == prev:
    count += 1
  else:
    if max_v == count:
      max_list.append(prev)
    elif max_v < count:
      max_list = [prev]
      max_v = count
    count = 1
    prev = s[i]


if max_v == count:
  max_list.append(prev)
elif max_v < count:
  max_list = [prev]
  max_v = count

for k in max_list:
  print(k)


Measured memory_bytes: 80788
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/

int H, W;
char field[110][110];

int hi[4] = { -1,0,0,1 };
int wi[4] = { 0,-1,1,0 };

void del(int h, int w, char c)
{
	field[h][w] = '.';

	for (int i = 0; i < 4; i++)
	{
		if (field[max(min(h + hi[i], H - 1), 0)][max(min(w + wi[i], W - 1), 0)] == c)
			del(max(min(h + hi[i], H - 1), 0), max(min(w + wi[i], W - 1), 0), c);
	}
}

int main()
{	
	while (true)
	{
		cin >> H >> W;
		if (H == 0 && W == 0) break;

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

		int ans = 0;

		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (field[i][j] != '.')
				{
					del(i, j, field[i][j]);
					ans++;
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}



Measured memory_bytes: 3564
N=int(input())
A=list(map(int,input().split()))

from collections import Counter
A_=Counter(A)

A_key=list(A_.keys())
A_key.sort()

ans=0
for k in A_key:
    if k > A_[k]:
        ans += A_[k]
    else:
        ans += A_[k]-k
print(ans)

Measured memory_bytes: 101020
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int A,B;
	cin>>A>>B;
	int ans = A+B;
	ans = max(ans,A-B);
	ans = max(ans,A*B);
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
from fractions import*
n,m,*a=map(int,open(0).read().split())
s=1
d=set()
for i in a:
  i//=2
  s*=i//gcd(s,i)
  t=0
  while i%2<1:
    t+=1
    i//=2
  d|={t}
print((0--(m//s)//2)*(len(d)<2))

Measured memory_bytes: 96952
#include <algorithm>
#include <climits>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
typedef pair<long long, long long> P;
using ll = long long;

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

    int N;
    cin >> N;
    unordered_map<ll, ll> map;
    ll tmp, sum = 0, ans = 0;

    map[0]++;
    rep (i, N) {
        cin >> tmp;
        sum += tmp;
        map[sum]++;
    }
    repall (i, map)
        ans += i.second * (i.second - 1) / 2;
    print(ans);
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


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

typedef long long ll;
int main() {
	char x;
	cin >> x;
	if (isupper(x)){
		cout << "A" << endl;
	}else if (islower(x)){
		cout << "a" << endl;
	}
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>

int main()
{
	std::string s, l, r;
	int n, h;
	for (;;) {
		std::cin >> s;
		if(s[0] == '-') break;
		std::cin >> n;
		for (int i=0; i!=n; ++i) {
			std::cin >> h;
			l = s.substr(0, h);
			r = s.substr(h, s.size()-h);
			s = r + l;
		}
		std::cout << s << '\n';
	}
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	map<char,int> mp;
	int n; cin>>n;
	char ch;
	while(n--)
	{
		cin>>ch;
		mp[ch]++;
	}
	if(sz(mp)==4) cout<<"Four\n";
	else cout<<"Three\n";
	return 0;
}


















Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

signed main(){
	int n,k;
	cin>>n>>k;
	vector<int> l(n);
	rep(i,n) cin>>l[i];
	sort(l.rbegin(),l.rend());
	int ans=0;
	rep(i,k) ans+=l[i];
	cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=2e5;
int main ()
{
    int n,a,b;cin>>n;
    if(n==1){
        cout<<"Hello World\n";
    }
    else {
        cin >> a >> b;
        cout<<a+b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256