akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

int main(){
  int a,b;
  cin >>a >> b;
  cout << (a-1)*(b-1) << endl;
  return 0;
}


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

int main() {
  int w,h,n,x,y,a; 
  cin>>w>>h>>n;
  int v1=0,v2=w,v3=0,v4=h;
  rep(i,n){
    cin>>x>>y>>a;
    if(a==1){v1=max(v1,x);}
    if(a==2){v2=min(v2,x);}
    if(a==3){v3=max(v3,y);}
    if(a==4){v4=min(v4,y);}
  }
  int p=max(0,v2-v1);
  int q=max(0,v4-v3);
  cout<<p*q;
}

Measured memory_bytes: 256
/*
	- 20.3.2
	B - Frog 2
	Atcoder-Educational DP Contest-B - Frog 2
	20.3.2-Atcoder-Educational DP Contest-B - Frog 2- 
	- 
	-
	- 
*/
#include <bits/stdc++.h>
using namespace std;
int f[100010],h[100010];
int n,k;

int main()
{
	cin>>n>>k>>h[1];
	f[1]=0;
	for (int i=2;i<=n;++i)
	{
		cin>>h[i];
		f[i]=2e9;
		for (int j=max(i-k,1);j<i;++j)
			f[i]=min(f[i],f[j]+abs(h[i]-h[j]));
	}
	cout<<f[n]<<endl;
	return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if( a+b == c or b+c == a or c+a == b ){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
bool vis[100005];
vector<int> g[100005];
vector<int> path1,path2;
void dfs(int x)
{
	vis[x]=1;
	path1.push_back(x);
	for(int i=0;i<g[x].size();i++)
		if(!vis[g[x][i]])
		{
			dfs(g[x][i]);
			return;
		}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1);
	path2=path1;
	path1.clear();
	dfs(1);
	cout<<path1.size()+path2.size()-1<<endl;
	for(int i=path1.size()-1;i>=0;i--)
		cout<<path1[i]<<' ';
	for(int i=1;i<path2.size();i++)
		cout<<path2[i]<<' ';
	cout<<endl;
	return 0;
}

Measured memory_bytes: 10104
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX = 5;
pair<int, int> s[5 + 1];

vector<char> nums(5);

void itoa(int a, int len) {
    int pos = 0;
    while (a > 0) {
        nums[pos++] = a % 10;
        a /= 10;
    }

    reverse(nums.begin(), nums.begin() + len);
}

int main() {

    int n, m;
    cin >> n >> m;
    for (int j = 1; j <= m; ++j) {
        cin >> s[j].first >> s[j].second;
    }

    for (int i = 0; i < 1e3; ++i) {
        int len = 1;
        if (i >= 10) len++;
        if (i >= 100) len++;

        if (len != n) {
            continue;
        }

        itoa(i, len);
        int find = true;
        for (int j = 1; j <= m; ++j) {
            if (nums[s[j].first - 1] != s[j].second) {
                find = false;
            }
        }

        if (find) {
            cout << i;
            return 0;
        }
    }

    cout << -1;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
int N,T,S;
int dp[3001];
int main() {
	cin >> N >> T >> S;
	for(int i=0;i<N;i++){
		int A,B;
		cin >> A >> B;
		for(int j=T;j>=B;j--){
			if(j-B<S&&S<j){
				continue;
			}
			dp[j]=max(dp[j],dp[j-B]+A);
		}
		for(int j=1;j<=T;j++){
			dp[j]=max(dp[j],dp[j-1]);
		}
	}
	cout << dp[T] << endl;
}

Measured memory_bytes: 1176
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    rep(i,n) cout<<s[i]<<t[i];
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>

using namespace std;

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

#define INF 1000000

int main(){
	while(1){
		int n,m=0;
		cin>>n;
		if(n==0)break;
		
		int cost[10][10]={0};
		rep(i,10)rep(j,10)cost[i][j]=INF;
		
		rep(i,n){
			int a,b,c;
			cin>>a>>b>>c;
			cost[a][b]=c;
			cost[b][a]=c;
			
			m=max(max(a,b),m);
		}
		
		
		int dp[10][10][10]={0};
		
		rep(i,10){
			rep(j,10){
				dp[0][i][j] = cost[i][j];
				dp[0][i][j] = min( dp[0][i][j],  cost[i][0] + cost[0][j]);
			}
		}
		
		reps(k,1,10){
			rep(i,10){
				rep(j,10){
					dp[k][i][j] = min(dp[k-1][i][j], dp[k-1][i][k] + dp[k-1][k][j]);
				}
			}
		}
		
		
		int maxp = -1;
		int maxsum = INF;
		
		rep(i,m+1){
			int ssum = 0;
			rep(j,m+1){
				if(i==j)continue;
				ssum += dp[9][i][j];
			}
			
			if(maxsum > ssum){
				maxsum = ssum;
				maxp = i;
			}
		}
		
		printf("%d %d\n",maxp,maxsum);
	}
}

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

int main() {
  long long A, B, C;
  cin >> A >> B >> C;
  if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
    cout << 0 << endl;
  } else {
    cout << min(min(A * B, B * C), C * A) << endl;
  }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)

	x, y := readInt(), readInt()

	for a := 0; a <= 100; a++ {
		for b := 0; b <= 100; b++ {
			if a+b == x && 2*a+4*b == y {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 1760
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

    	int result = 0;
    	for(int i = 0;i<predict.length();i++) {
    		char predictChar = predict.charAt(i);
    		if(predictChar == actual.charAt(i)) {
    			result++;
    		}
    	}

    	System.out.println(result);
    }
}

Measured memory_bytes: 21972
#include <stdio.h>
#include <math.h>

int
main(void)
{
	double a, b, c;
	double s, l, h, rad;
	double p[2];

	scanf("%lf%lf%lf", &a, &b, &c);

	rad = M_PI * c / 180.0;

	p[0] = b * cos(rad);
	p[1] = b * sin(rad);
	h = p[1];
	s = a * h * 0.5;
	l = sqrt(pow(a - p[0], 2) + pow(p[1], 2)) + a + b;

	printf("%lf\n%lf\n%lf\n", s, l, h);

	return 0;
}



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

using namespace std;
typedef long long ll;

struct jie
{
    int x,t,c;
}mp[500005];
struct jie1
{
    int v,d,c;
}a[500005];
int d[500005],us[500005],head[500005],cnt,n,c[500005],f[500005][12];
void add(int x,int y,int c)
{
    cnt++;
    mp[cnt].x=y;
    mp[cnt].c=c;
    mp[cnt].t=head[x];
    head[x]=cnt;
}
void dfs(int u,int d,int l,int co)
{
    if(d>l||f[u][l-d]==1) return ;
    for(int j=0;j<=l-d;j++)
    {
        f[u][j]=1;
    }
    if(c[u]==0)
    {
        c[u]=co;
    }
    int i;
    for(i=head[u];i!=-1;i=mp[i].t)
    {
        int v=mp[i].x;
        dfs(v,d+1,l,co);
    }
    return ;
}
int main()
{
    int m,i;
    cnt=1;
    memset(head,-1,sizeof(head));
    scanf("%d %d",&n,&m);
    for(i=1;i<=m;i++)
    {
        int u,v;
        scanf("%d %d",&u,&v);
        add(u,v,1);
        add(v,u,1);
    }
    int T;
    scanf("%d",&T);
    for(i=1;i<=T;i++)
    {
        scanf("%d %d %d",&a[i].v,&a[i].d,&a[i].c);
    }
    for(i=T;i>=1;i--)
    {
        dfs(a[i].v,0,a[i].d,a[i].c);
    }
    for(i=1;i<=n;i++)
    {
        printf("%d\n",c[i]);
    }
    return 0;
}


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

#define irep(i,n)  for(int i=0;i<(n);i++)
#define irepy(i,n) for(int i=1;i<=(n);i++)
#define jrep(j,n)  for(int j=0;i<(n);j++)
#define jrepy(j,n) for(int j=1;i<=(n);j++)

int main(){
  int n;
  cin >> n;
  int hoge=0;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(i*j == n){
	hoge=1;

      }
    }
  }
  if(hoge==0){
    cout<<"No"<<endl;
  }
  else cout<<"Yes"<<endl;

  return 0;


}


Measured memory_bytes: 256
A, B, C = input().split()
A, B, C = [int(A), int(B), int(C)]
K = int(input())

for i in range(K):
    if(B >= C or A >= C):
        C = C * 2
    elif(A >= B):
        B = B * 2
    else:
        C = C * 2

if(C > B > A):
    print("Yes")
else:
    print("No")


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

int main(){
    string w,t;
    cin >> w;
    int sum=0;
    int flg;
    while(1){
        flg=1;
        cin >> t;
        if(t=="END_OF_TEXT") break;
        if(w.size()==t.size()){
            for(int i=0; i<w.size(); i++){
                if( (t[i]!=w[i]) && (t[i]!=toupper(w[i])) ) {
                    flg=-1;
                    break;
                }
            }
            if(flg==1) sum++;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3200
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)
#define RFOR(it,c) for(__typeof((c).rbegin())it=(c).rbegin(); it!=(c).rend();++it)
#define exist(c, v) (find((c).begin(), (c).end(), (v)) != (c).end())

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
	return os;
}

const int MAX_N = 1 << 17;

int n;
long long dat[2 * MAX_N - 1];

void init(int n_) {
	n = 1;
	while(n < n_)
		n *= 2;

	fill(dat, dat + 2 * n - 1, 0);
}

void update(int k, long long a) {
	k += n - 1;
	dat[k] = a;

	while(k > 0) {
		k = (k - 1) / 2;
		dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
	}
}

long long query(int a, int b, int k = 0, int l = 0, int r = n) {
	if(r <= a || b <= l)
		return 0;

	if(a <= l && r <= b) {
		return dat[k];
	}
	else {
		long long vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		long long vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return max(vl, vr);
	}
}


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

	int m;
	cin >> m;

	init(m);

	long long mx = 0;
	for(int i = 0; i < m; ++i) {
		int w;
		cin >> w;

		long long tmp = query(1, w) + w;
		update(w, tmp);
		chmax(mx, tmp);
	}

	cout << ((1ll + m) * m / 2ll - mx) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 3240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// 52????????????????????????
		int[][] cards = new int[4][13];

		Scanner in = new Scanner(System.in);
		int all_num = in.nextInt();

		// ?????????????????????????????????????´?
		for(int i = 0; i < all_num; i++){

			String mark = in.next();
			int num = in.nextInt();

			if(mark.equals("S")){

				cards[0][num - 1] = 1;

			}else if(mark.equals("H")) {

				cards[1][num - 1] = 1;

			}else if(mark.equals("C")) {

				cards[2][num - 1] = 1;

			}else if(mark.equals("D")) {

				cards[3][num - 1] = 1;
			}
		}

		// ????????¨?????????????????????????????????
		char[] marks = {'S', 'H', 'C', 'D'};

		// ???????????????????????§?¶????????????????????????????
		for(int i = 0; i < 4; i++) {

			for(int j = 0; j < 13; j++) {

				if(cards[i][j] == 0){

					System.out.println(marks[i] + " " + (j + 1));

				}
			}
		}
	}
}

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

int main(){
  int n;
  cin >> n;
  P c[n];
  rep(i,n) {
    cin >> c[i].first;
    c[i].second = i;
  }
  sort(c,c+n,greater<P>());
  vector<vector<ll>> dp(n+1,vector<ll>(n+1,-INF));
  dp[0][0] = 0;
  rep(i,n) {
    rep(j,n) {
      dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+c[i].first*abs(c[i].second-j));
      dp[i+1][j] = max(dp[i+1][j],dp[i][j]+c[i].first*abs(c[i].second-(n-1-i+j)));
    }
  }
  ll ans = 0;
  rep(i,n+1) ans = max(ans,dp[n][i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 34684
a=int(input())
b=int(input())
if (a==1 and b==2) or (a==2 and b==1):
    print(3)
if (a==1 and b==3) or (a==3 and b==1):
    print(2)
if (a==2 and b==3) or (a==3 and b==2):
    print(1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<int> c(n-1), s(n-1), f(n-1);
    rep(i, n-1) cin >> c[i] >> s[i] >> f[i];
    rep(i, n) {
        if (i==n-1) {
            cout << 0 << endl;
            continue;
        }
        int now = i;
        int time = 0;
        while (now<n-1) {
            int t = max(s[now], ((time-1)/f[now]+1)*f[now]);
            time = t + c[now];
            now++;
        }
        cout << time << endl;
    }

    return 0;
}


Measured memory_bytes: 3664
N=int(input())
W=input().split()
a=[]
for T in range(1,N+1):
    sum1=0
    sum2=0
    for i in range(0,T):
        sum1+=int(W[i])
    for i in range(T,N):
        sum2+=int(W[i])
    a.append(abs(sum1-sum2))
print(min(a))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 1100000;

int n, f[N], num[N];
char s[N];

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

int main() {
	read(n);
	for (R int i = 1; i <= n; ++i) {
		num[i] = num[i - 1];
		int tmp = i;
		while (~tmp & 1) tmp >>= 1, ++num[i];
	}
	scanf("%s", s + 1);
	int flag = 0;
	for (R int i = 1; i < n; ++i) {
		f[i] = abs(s[i] - s[i + 1]);
		flag |= f[i] == 1;
	}
	int ans = 0;
	if (!flag) flag = 2;
	for (R int i = 1; i < n; ++i)
		if (f[i] == flag && !(num[n - 2] - num[i - 1] - num[n - i - 1]))
			ans ^= flag;
	cout << ans << endl;
	return 0;
}

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

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

    sort(a.begin(), a.end(), greater<int>());
    long long int l1 = 0, l2 = 0;
    int i = 1;
    for(; i < n; i++){
        if(a[i-1] == a[i]){
            l1 = a[i];
            i += 2;
            break;
        }
    }
    for(; i < n; i++){
        if(a[i-1] == a[i]){
            l2 = a[i];
            break;
        }
    }
    cout << l1*l2 << endl;
    return 0;
}

Measured memory_bytes: 3768
import sys
sys.setrecursionlimit(5000)

dx = [1, 0, -1]
dy = [1, 0, -1]

def dfs(area, x, y):
    area[x][y] = 0
    for i in dx:
        for j in dy:
            next_x = x + i
            next_y = y + j
            if area[next_x][next_y] == 1:
                dfs(area, next_x, next_y)

def solver(w, h):
    ans = 0
    area = [[0]*(w+2)]
    for i in range(h):
        area.append([0]+list(map(int, input().split()))+[0])
    area.append([0]*(w+2))

    for i in range(1, h+1):
        for j in range(1, w+1):
            if area[i][j] == 1:
                ans += 1
                dfs(area, i, j)
    return ans

while True:
    w, h = map(int, input().split())
    if w == h == 0:
        break
    print(solver(w, h))


Measured memory_bytes: 8236
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int P = sc.nextInt();
		sc.close();
		System.out.println((A*3+P)/2);

	}
}

Measured memory_bytes: 23764
declare function require(x: string): any;
// const input: string = require('fs').readFileSync('./input.txt', 'utf8')
const input = require('fs').readFileSync('/dev/stdin', 'utf8')
const secondWord: string = input.split(" ")[1]

console.log("A" + secondWord.slice(0, 1) + "C")

Measured memory_bytes: 7372
#include<stdio.h>
#include<string.h>
int main(void){
    int A,B,C,D;
    char S[3];
    scanf("%d %d %d",&A,&B,&C);
    if(A+B<C){
        printf("No");
    }else{
        printf("Yes");
    }
    return 0;
}

Measured memory_bytes: 128
//2017-02-18 20:10
//2017-02-18 20:30
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;

const int MaxN = 2e5;
int n, a[MaxN + 5];
char s[MaxN + 5];

void Print(int a[])
{
	for (int i = 1; i <= n; i++)
		if (a[i] == 1) printf("S");
			else printf("W");
	printf("\n");
}

bool Judge(char ch, int x)
{
	if (x == 1) return ch == 'o';
	else return ch == 'x';
}

bool Check(int a[])
{
	for (int i = 2; i <= n - 2; i++) 
		if (Judge(s[i - 1], a[i])) a[i + 1] = a[i - 1]; else a[i + 1] = 1 - a[i - 1];
	if (Judge(s[n - 2], a[n - 1]) && a[n - 2] != a[n]) return false;
	if (!Judge(s[n - 2], a[n - 1]) && a[n - 2] == a[n]) return false;
	if (Judge(s[n - 1], a[n]) && a[n - 1] != a[1]) return false;
	if (!Judge(s[n - 1], a[n]) && a[n - 1] == a[1]) return false;
	return true;
}

void Solve()
{
	scanf("%s", s);
	for (int i = 0; i <= 1; i++) {
		a[1] = i;
		if (!Judge(s[0], a[1])) {
			a[n] = 1; a[2] = 0;
			if (Check(a)) {Print(a); return;}
			a[n] = 0; a[2] = 1;
			if (Check(a)) {Print(a); return;}
		}
		else {
			a[n] = 1; a[2] = 1;
			if (Check(a)) {Print(a); return;}
			a[n] = 0; a[2] = 0;
			if (Check(a)) {Print(a); return;}
		}
	}
	printf("-1\n");
}

int main()
{
	while (~scanf("%d", &n)) {
		Solve();
	}
	return 0;
}

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


int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int, int>> arr(n);
    for (auto &el: arr) cin >> el.first;
    for (auto &el: arr) cin >> el.second;

    sort(arr.begin(), arr.end(), [](pair<int, int> a, pair<int, int> b) {
        int x = a.first - a.second;
        int y = b.first - b.second;
        return x > y;
    });

    int x = 0, y = 0;
    for (auto el: arr) {
        if (el.first <= el.second) break;
        x += el.first;
        y += el.second;
    }

    cout << x - y << endl;
    return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

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

  vi a(2*n);
  rep(i, 0, 2*n){
    a[i] = ((s[i] == 'B') + (i%2 == 0)) % 2;
  }

  int ans = 1, cnt = 0;
  rep(i, 0, 2*n){
    if(a[i]){
      (ans *= cnt) %= mod;
      cnt--;
    }else{
      cnt++;
    }
  }

  if(cnt) ans = 0;

  rep(i, 1, n+1) (ans *= i) %= mod;

  cout << ans << endl;
  
//  rep(i, 0, 2*n) cout << a[i] << " ";
//  cout << endl;

  return 0;
}


Measured memory_bytes: 2180
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  vector<ll> oi,io;
  ll N,K,ma=-1;
  string S;
  ll T=0;
  cin >> N >> K >> S;
  rep(i,N){
    if(i==0){
      T=ctoi(S[i]);
      oi.push_back(0);
    }
    else if(T==1 && S[i]=='0'){
      io.push_back(i);
      T=0;
    }
    else if(T==0 && S[i]=='1'){
      oi.push_back(i);
      T=1;
    }
    if(i==N-1){
      io.push_back(i+1);
    }
  }
  T=0;
  if(S[0]=='1'){
    T=1;
  }
  ll X=io.size();
  if(X+1-K-T<=0){
    cout << N << endl;
    return 0;
  }
  rep(i,X+1-K-T){
    if(ma<io[i+K-1+T]-oi[i]){
      ma=io[i+K-1+T]-oi[i];
    }
  }
  cout << ma << endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,n2,index = 0,key;
    cin >> n;
    int a[n];
    for (int i = 0;i < n;++i) {
        cin >> a[i];
    }
    cin >> n2;
    for(int i = 0;i < n2;++i){
        cin >> key;
        while(1){
            if(a[index++] == key){
                break;
            }
            else if(a[index] > key || index + 1 > n){
                cout << "0" << endl;
                return 0;
            }
        }
    }
    cout << "1" << endl;
}


Measured memory_bytes: 3944
def abc109_d():
    h, w = (int(x) for x in input().split())
    grid = [[int(x) for x in input().split()] for _ in range(h)]

    move = []
    rest = []
    for i in range(h):
        pick = False
        for j in range(w):
            v = grid[i][j]
            if pick:
                if v%2:
                    pick = False
                else:
                    if j < w-1: move.append((i+1, j+1, i+1, j+2))
            else:
                if v%2:
                    pick = True
                    if j < w-1: move.append((i+1, j+1, i+1, j+2))
        rest.append(pick)

    pick = False
    for i, v in enumerate(rest):
        if pick:
            if v:
                pick = False
            else:
                if i < h-1: move.append((i+1, w, i+2, w))
        else:
            if v%2:
                pick = True
                if i < h-1: move.append((i+1, w, i+2, w))

    print(len(move))
    for mv in move:
        print(*mv, sep=' ')

if __name__ == '__main__':
    abc109_d()

Measured memory_bytes: 30552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(18);
  long double l;
  cin >> l;
  cout << (long double)((l * l * l) / 27.0) << '\n';
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, x, y, i, j, res;
	cin >> n >> x >> y;
	x--;
	y--;
	vector<int> dist(n);

	for ( i = 0 ; i < n ; i++ ) {
		for ( j = i + 1 ; j < n ; j++ ) {
			if ( j <= x || i >= y )
				dist[j - i]++;
			else
				dist[min(j-i, abs(x-i) + abs(y-j) + 1)]++;
		}
	}
	for ( i = 1 ; i < n ; i++ ) {
		std::cout << dist[i] << std::endl;
	}
	/*
	for ( i = 0 ; i < n ; i++ ) {
		for ( j = 0 ; i + j < n ; j++ ) {
			graph[i][i+j] = j;
			graph[i + j][i] = j;
		}
	}
	graph[x][y] = 1;
	graph[y][x] = 1;

	for ( i = x ; i < y ; i++ ) {
		graph[x][i] = min(i - x, graph[x][i]);
		graph[i][x] = min(i - x, graph[i][x]);
	}

	for ( i = y ; i > x ; i-- ) {
		graph[y][i] = min(y - i, graph[y][i]);
		graph[i][y] = min(y - i, graph[i][y]);
	}

	for ( auto l : graph ) {
		for ( auto v : l ) {
			std::cout << v << " ";
		}
		std::cout << std::endl;
	}

	for ( i = 1 ; i < n ; i++ ) {
		int bef, in, aft, sbef, sin;
		bef = x - i;
		in = y - x - i + 1;
		aft = n - y - i + 1;
		sbef = 
		res = max(bef, 0) + max(in, 0) + max(aft, 0) + max(sbef, 0) + max(sin, 0);
		std::cout << sbef << " " << sin << " " << aft << " = " << res << std::endl;
	}
	*/

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  string s;
  cin>>s;
  if(s.size()==2){
    if(s[0]==s[1]){
      cout<<1<<" "<<2;
    }
    else cout<<-1<<" "<<-1;
    return 0;
  }

  for (int i = 0; i < s.size()-1; ++i)
  {
    if(s[i]==s[i+1]){
      if(i!=s.size()-2){
        cout<<i+1<<" "<<i+3;
        return 0;
      }
      else {
        cout<<i<<" "<<i+2;
        return 0;
      }
    }
    if(i>s.size()-3) continue;
    if(s[i]==s[i+2]){
      cout<<i+1<<" "<<i+3;
      return 0;
    }
  }
  cout<<-1<<" "<<-1;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define PB push_back
#define ll long long
#define pii pair<LL,LL>
#define MEM(x,y) memset(x,y,sizeof(x))
#define bug(x) cout<<"debug "#x" is "<<x<<endl;
#define FIO ios::sync_with_stdio(false);
#define ALL(x) x.begin(),x.end()
#define LOG 20
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)
const int maxn=2e5+10;

char str[20];
int main()
{
	cin>>str;
	bool flag=false;
	for(int i=0;i<strlen(str);i+=2)
	{
		if(str[i]=='h'&&str[i+1]=='i')
			flag=true;
		else
			flag=false;
	}
	if(flag)
		puts("Yes");
	else
		puts("No");
	return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int cnt = 0;
    rep(i, n) {
        if (a[i] <= 0) ++cnt;
    }
    ll sum = 0;
    rep(i, n) sum += abs(a[i]);
    if (cnt%2==1) {
        int m = INF;
        rep(i, n) m = min(m, abs(a[i]));
        sum -= 2 * m;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 640
N = int(input())
a = [int(input()) for i in range(N)]

now = 0
count = 0
checked = [-1] * N

while checked[now] == -1 and now != 1:
    checked[now] = 1
    now = a[now] - 1
    count += 1
if now == 1:
    print(count)
else:
    print(-1)


Measured memory_bytes: 51032
#include <iostream>

using namespace std;

int main(){
    int W,H,x,y,r;
    cin >>W;
    cin >>H;
    cin >>x;
    cin >>y;
    cin >>r;
    if(y>=r && y<=H-r && r<=x && x<=W-r){
        cout<<"Yes"<<endl;
    }
    
    //if(x>=r && x<W-r && r<=y && r<=H-r){
        //cout<<"Yes"<<endl;
    //}
    else{
        cout<<"No"<<endl;
    }
}


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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        int a = ReadInt();
        string s = Read();
        if(a>=3200)
        {
            return s;
        }
        return "red";
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11092
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;

#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define Rep(i, a, b) for (int (i) = (a) - 1; (i) < (b); (i)++)
#define REP(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define Sort(a, len, cmp) sort(a + 1, a + len + 1, cmp)
#define ass(a, sum) memset(a, sum, sizeof(a))

#define ls ((rt) << 1)
#define rs ((rt) << 1 | 1)
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define ENDL cout << endl
#define SZ(x) ((int)x.size())

typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> Vi ;
typedef pair <int, int> Pii ;
typedef pair <ll, ll> Pll ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
typedef map <ll, ll> mll ;

const int N = 100010 ;
const double eps = 1e-8 ;
const int iinf = INT_MAX ;
const ll linf = 2e18 ;
const double dinf = 1e30 ;
const int MOD = 1000000007 ;

inline int read(){
    int X = 0,w = 0 ;
	char ch = 0;
    while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
    while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
    return w ? -X : X;
}

void write(int x){
     if(x < 0) putchar('-'),x = -x;
     if(x > 9) write(x / 10);
     putchar(x%10 + '0');
}

void print(int x) {
	cout << x << endl ;
	exit(0) ;
}

void PRINT(string x) {
	 cout << x << endl ;
	 exit(0) ;
}

void douout(double x){
	 printf("%lf\n", x + 0.0000000001) ;
}


ll dp[101][8] ;
int p[] = {1, 1, 2, 3, 5, 8, 13, 21} ;
int h, w, k ;
int main(){
	cin >> h >> w >> k ;
	dp[0][0] = 1 ;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if (j)(dp[i + 1][j - 1] += dp[i][j] * p[j - 1] * p[w - j - 1]) %= MOD ;
			(dp[i + 1][j] += dp[i][j] * p[j] * p[w - j - 1]) %= MOD ;
			if (j < w - 1) (dp[i + 1][j + 1] += dp[i][j] * p[j] * p[w - j - 2]) %= MOD ;
		}
	}
	cout << dp[h][k - 1] << endl ;
}

/*
写代码时请注意：
	1.是否要开Long Long？数组边界处理好了么？
	2.实数精度有没有处理？
	3.特殊情况处理好了么？
	4.做一些总比不做好。
思考提醒：
	1.最大值和最小值问题可不可以用二分答案？
	2.有没有贪心策略？否则能不能dp？
*/


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

int main(){
  int s,w;
  cin>>s>>w;
  if(s<=w)cout<<"unsafe"<<endl;
  else cout<<"safe"<<endl;
  return 0;  
}

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

using namespace std;

const int mod = 1e9 + 7;

int add(int a, int b) {
  return a + b - mod * (a + b >= mod);
}

int mul(int a, int b) {
  return int(1ll * a * b % mod);
}

int power(int a, int x) {
  if (x == 0) {
    return 1;
  }
  return mul(power(mul(a, a), x >> 1), (x & 1 ? a : 1));
}

int divide(int a, int b) {
  return mul(a, power(b, mod - 2));
}

int sub(int a, int b) {
  return a - b + mod * (a < b);
}

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

  int n;
  cin >> n;
  int cnt[3] = {0};
  int ans = 1;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    bool was = false;
    int kek = 0;
    for (int j = 0; j < 3; ++j) {
      if (x == cnt[j]) {
        if (!was) {
          ++cnt[j];
          was = true;
        } else {
          kek = add(kek, ans);
        }
      }
    }
    if (!was) {
      cout << 0;
      return 0;
    }
    ans = add(ans, kek);
  }
  cout << ans;

  return 0;
}

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

using namespace std;

int main()
{
    int n, k; cin >> n >> k;
    vector<int> v;

    while (n > 0) {
        v.push_back(n % k);
        n /= k;
    }

    cout << v.size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll A;
    double B;
    cin >> A >> B;
    ll ans = floor(100 * (B + 1e-10));
    ans *= A;
    ans /= 100;
    cout << ans << endl;
}

Measured memory_bytes: 3844
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
const int MAXN = 2e5 + 10;
int a[MAXN], b[MAXN];

void solve(int n, int k) {
  if (k == 0) return;
  memset(b, 0, sizeof(b));
  for (int i = 1; i <= n; i++) {
    int x = max(1, i-a[i]);
    int y = min(n, i+a[i]);
    b[x] += 1;
    b[y+1] -= 1;
  }
  bool flag = false;
  for (int i = 1; i <= n; i++) {
    b[i] += b[i-1];
    if (a[i] != b[i]) {
      flag = true;
      a[i] = b[i];
    }
  }
  if (flag) solve(n, k-1);

}





int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  int n, k; cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  solve(n, k);
  for (int i = 1; i <= n; i++) {
    cout << a[i];
    if (i == n) cout << "\n";
    else cout << " ";
  }







/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


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

 int main() {
 int n;
 string s;
 cin >> n >> s;
 int ans = 0;
 for(int i = 0; i <= n - 3; i++) {
 if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
 }
 cout << ans << endl;
 return 0;
 }


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int N;
  string S;
  cin >> N >> S;
  int total = N;
  for (int j = 0; j < N - 1; ++j) {
    
    if (S[j] == S[j + 1]) { 
      total -= 1;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
  int n, m, d=0;
  cin >> n >> m;
  int a;
  for(int i=0; i<m; i++){
    cin >> a;
    d+=a;
  }
  if(d<=n) cout << n-d;
  else cout << "-1";
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin>>str;
  int alfa[26]={0};
  for(int i=0;i<str.size();i++){
    if(alfa[str[i]-'a']==0)
      alfa[str[i]-'a']=1;
    else{
      cout<<"no"<<endl;
      return 0;
    }
  }
  cout<<"yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ld long double
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    h = h * 60 + m;
    ld ha = (h % 720) / 2.0, ma = (h % 60) * 6.0;
    ld dif = abs(ha - ma);
    dif = min(dif, 360.0 - dif);
    dif *= acos(-1) / 180.0;
    ld c = a * a + b * b - 2 * a * b * cos(dif);
    cout << setprecision(12) << sqrt(c) << endl;
}

Measured memory_bytes: 4092
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
	int a,b,c;
	char t;
	cin >> a >> t >> b >> t >> c;
	if(a>2019||(a==2019&&b>4)||(b==4&&a==2019&&c>30)) puts("TBD");
	else puts("Heisei");
	return 0;
}

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

const int ANTENNA_NUM = 5;

int main() {
  int p[ANTENNA_NUM];
  int k;
  for (int i = 0; i < ANTENNA_NUM; i++) {
    scanf("%d", &p[i]);
  }
  scanf("%d", &k);

  bool can_communicate = true;
  for (int i = 0; i < ANTENNA_NUM; i++) {
    for (int j = i + 1; j < ANTENNA_NUM; j++) {
      if (p[j] - p[i] > k) can_communicate = false;
    }
  }

  if (can_communicate) {
    printf("Yay!");
  } else {
    printf(":(");
  }
  return 0;
}


Measured memory_bytes: 256
n,c=map(int,input().split())
pro=[]
for i in range(c):
    pro.append([])
for i in range(n):
    s,t,c_0=map(int,input().split())
    pro[c_0-1].append((s,t))
Pro=[]
for i in range(c):
    pro[i].sort(reverse=True)
    if pro[i]==[]:
        continue
    pre=pro[i].pop()
    while pro[i]!=[]:
        now=pro[i].pop()
        if pre[1]==now[0]:
            pre=(pre[0],now[1])
        else:
            Pro.append(pre)
            pre=now
    Pro.append(pre)
import heapq
heapq.heapify(Pro)
Used=[]
heapq.heapify(Used)
now=heapq.heappop(Pro)
heapq.heappush(Used,now[1])
ans=1
while len(Pro)!=0:
    now=heapq.heappop(Pro)
    near=heapq.heappop(Used)
    if near<now[0]:
        heapq.heappush(Used,now[1])
    else:
        ans+=1
        heapq.heappush(Used,now[1])
        heapq.heappush(Used,near)
print(ans)


Measured memory_bytes: 93272
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main() {
	long long N, M;
	string S, T;

	cin >> N >> M;
	cin >> S >> T;

	long long a = max(N, M), b = min(N, M), tmp;
	long long x = a * b, r = a % b;
	if (a<b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	long long NM = x / b;

	vector<int> S_place(N), T_place(M), Com;
	vector<string> Com_S, Com_T;
	for (int i = 0; i < N; ++i) {
		S_place[i] = (i * NM / N);
	}
	for (int i = 0; i < M; ++i) {
		T_place[i] = (i * NM / M);
	}
	for (int i = 0; i < M; ++i) {
		if (S_place[0] == T_place[i]) {
			S_place.erase(S_place.begin());
			Com.push_back(T_place[i]);
		}
		else if (S_place[0] > T_place[i]) {
		}
		else {
			S_place.erase(S_place.begin());
			i--;
		}
		if (S_place.size() == 0) {
			break;
		}
	}

	for (int i = 0; i < Com.size(); ++i) {
		if (S[Com[i] * N / NM] != T[Com[i] * M / NM]) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << NM << endl;

	return 0;
}

Measured memory_bytes: 1280
input = raw_input

s = input()

first = True
out = 0
renzoku = 0
for c in s:
    if c == "R":
        if first:
            renzoku = 1
            first = False
        elif fc == "S":
            renzoku = 1
        else:
            renzoku += 1
    else:
        out = max(out, renzoku)
        renzoku = 0
    fc = c

if renzoku != 0:
    out = max(out, renzoku)
print(out)

Measured memory_bytes: 64216
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define forn(i,a,b) for (ll i = a; i <= b; i ++ )
#define mod(n,k) (((n%k)+k)%k)
using namespace std;
typedef long long ll;

ll N, bs, ans;
char s[MAX];

int main()
{
    optimiza_io
    cin >> N;
    forn( i , 1 , N ) {
        cin >> s[i];
        if( s[i] == 'B' )
            bs++;
    }
    
    forn( r , 1 , N ) {
        if( s[r] != 'R' )
            continue;
        forn( g , 1 , N ) {
            if( s[g] != 'G' )
                continue;
            ans += bs;
            if( abs( r - g ) % 2 == 0 && s[min( r , g ) + abs( r - g ) / 2] == 'B' )
                ans--;
            if( min( r , g ) - abs( r - g ) > 0 && s[min( r , g ) - abs( r - g )] == 'B' )
                ans--;
            if( max( r , g ) + abs( r - g ) <= N && s[max( r , g ) + abs( r - g )] == 'B' )
                ans--;
        }
    }
    cout << ans;
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 3636
s = gets.chomp

a = b = 0
s.chars.each_with_index do |c, i|
  if i.even?
    a += 1 if c == '0'
    b += 1 if c == '1'
  elsif i.odd?
    a += 1 if c == '1'
    b += 1 if c == '0'
  end
end

puts [a, b].min

Measured memory_bytes: 9468
def main():
    n, *a = map(int, open(0).read().split())
    if n == 1:
        print(1)
        return

    m = max(a) + 1
    l = [0] * m
    for i in a:
        for j in range(i, m, i):
            l[j] += 2
        l[i] -= 1

    ans = l.count(1)
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  
  int A,B,a,b,c,d,e,S;
  
  cin >> A >> B;
  S=0;
  
  for (int i = A; i < B+1; i++) {
    
    a=i/10000;
    b=(i-10000*a)/1000;
    c=(i-10000*a-1000*b)/100;
    d=(i-10000*a-1000*b-100*c)/10;
    e=(i-10000*a-1000*b-100*c-10*d);

    if (a==e && b==d) {
      S++;
    }
  }
 cout << S << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  int a[2010];
  int b[2010]={0};
  rep(i,n){
    cin>>a[i];
    b[a[i]]++;
  }
  int cnt=0;
  rep(i,n){
    repi(j,i+1,n){
      if(a[i]>a[j]) cnt++;
      cnt%=MOD;
    }
  }
  int cnt2=0;
  int sum=n;
  rep(i,2010){
    cnt2+=(sum-b[i])*b[i];
    cnt2%=MOD;
    sum-=b[i];
  }
  
  int ans=cnt*k;
  ans%=MOD;
  int bb=((k-1)*k);
  bb/=2;
  bb%=MOD;
  cnt2*=bb;
  cnt2%=MOD;
  ans+=cnt2;
  ans%=MOD;
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }


signed main()
{
    int r,D,x; cin>>r>>D>>x;
    for(int i=0;i<10;i++){
        int ans=r*x-D;
        cout<<ans<<endl;
        x=ans;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
const int maxn=1000005;
#define all(x) (x).begin(),(x).end()
using namespace std;
void solve() {
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;++i) cin>>arr[i];
    int cnt=0;
    for(int i=0;i<n;++i)
    {
        for(int j=i+1;j<n;++j)
        {
            for(int k=j+1;k<n;++k)
            {
                if(arr[i]+arr[j]>arr[k] and arr[j]+arr[k]>arr[i] and arr[i]+arr[k]>arr[j] and arr[i]!=arr[j] and arr[j]!=arr[k] and arr[i]!=arr[k]) {
                    //cout<<i+1<<" "<<j+1<<" "<<k+1<<"\n";
                    cnt++;
                }
            }
        }
    }
    cout<<cnt<<"\n";


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

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> broken(n+1);
    rep(i,m) {
      int a;
      cin >> a;
      broken[a] = 1;
    }
    vector<int> dp(n+2);
    dp[n] = 1;
    int mod = 1e9 + 7;
    for (int i = n-1; i >= 0; i--) {
      if (broken[i]) continue;
      dp[i] = (dp[i+1] + dp[i+2])%mod;
    }
    cout << dp[0] << endl;
    return 0;
}

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

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

    ll ans = n * (n - 1) / 2;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3572