akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

bool isLeap(int y)
{
	if(y%400==0)	return true;
	if(y%100==0)	return false;
	if(y%4==0)		return true;
	return false;
}

int NumberOfDays(int y,int m,int d)
{
	int num=0;
	int mon[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	if(isLeap(y))	mon[2]++;

	for(int i=1;i<y;i++)	num+=isLeap(i)?366:365;
	for(int i=1;i<m;i++)	num+=mon[i];
	num+=d-1;

	return num;
}

int main()
{
	int y1,m1,d1,y2,m2,d2;
	while(cin>>y1>>m1>>d1>>y2>>m2>>d2){
		if(!(~y1&&~m1&&~d1&&~y2&&~m2&&~d2))	break;
		cout<<NumberOfDays(y2,m2,d2)-NumberOfDays(y1,m1,d1)<<endl;
	}
	return 0;
}

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

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

int main(){
  int n;
  cin >> n;
  vector<int> r(n);
  rep(i,n)cin >>r[i];
  int maxv = -2e9;
  int minv = r[0];
  rep1(i,n){
    maxv = max(maxv,r[i]-minv);
    minv = min(minv,r[i]);
  }
  cout << maxv << endl;
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>v(n+1);
	for(int i=1;i<=n;++i){
		int k=i;
		for(int j=2;j<=n;++j){
			while(k%j==0){
				++v.at(j);
				k/=j;
			}
		}
	}
	const int mod=1e9+7;
	int ans=1;
	for(auto&&i:v){
		if(i!=0)ans=1LL*ans*(i+1)%mod;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define int long long
#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int nof(int n) {
	int ans = 0;
	for (int i = 2;i <= n;i *= 2) {
		ans += n / i;
	}
	return ans;
}

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

	int nn = nof(N);

	int sub;
	for (int i = 1;i <= N;i *= 2) {
		if (nn > nof(i) + nof(N - i)) {
			cout << i << endl;
			return 0;
		}
		sub = i;
	}

	cout << sub*2 << endl;
	return 0;
}

Measured memory_bytes: 3112
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	var num_data int
	num_data, _ = strconv.Atoi(s) // num_data contains data num.

	var targets []int
	for i := 0; i < num_data; i++ {
		if sc.Scan() {
			n, _ := strconv.Atoi(sc.Text())
			targets = append(targets, n)
		}
	}
	sort.Ints(targets)
	answer := targets[len(targets)-1] / 2
	for x:=0; x < len(targets) - 1; x++{
		answer = answer + targets[x]
	}
	fmt.Println(answer)
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
 int a,i;
 string b[100];
 cin>>a;
 for (i=0;i<a;i++)
 {
     cin>>b[i];
 }
 for(i=a-1;i>=1;i--)
 cout<<b[i]<< " ";
 cout<<b[0]<<endl;
}


Measured memory_bytes: 3160
# include<iostream>

using namespace std;
int main() {
	int a, b = 0;
	while (1) {
		cin >> b >> a;
		if (a == 0 && b == 0) {
			break;
		}
		for (int it = 0; it < a; it++) {
			cout << "#";
		}
		cout << endl;
		for (int i = 1; i < b - 1; i++) {
			cout << "#";
			for (int it = 1; it < a - 1; it++) {
				cout << ".";
			}
			cout << "#";
			cout << endl;
		}
		for (int it = 0; it < a; it++) {
			cout << "#";
		}
		cout << endl << endl;
	}
	return 0;
}

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

int main(){
  string s,t;
  cin>>s>>t;
  
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<int>());
  int ans;
  ans = s.compare(t);
  
  if(ans<0){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Point{
	int[] x;
	Point(int[] a){
	this.x = a;
	}

}


public class Main {

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

		int N = sc.nextInt();
		int M = sc.nextInt();

		int[][] S = new int[M][N+1];

		for(int i = 0 ; i < M ; i ++){
			int k = sc.nextInt();
			for(int j = 0 ; j < k ; j++){
				S[i][j] = sc.nextInt();
			}
		}

		int[] P = new int[M];
		for(int i = 0 ; i < M ; i++){
			P[i] = sc.nextInt();
		}


		sc.close();

		int aans = (int)Math.pow(2, N);
		String denkyu;
		String ar = "%0" + N + "d";

		int count = 0;
		int a = 0;
		int ans = 0;
		for(int i = 0 ; i < aans ; i++){
			denkyu = String.format(ar ,Integer.parseInt(Integer.toBinaryString(i)));
			//System.out.println(denkyu);



			for(int j = 0 ; j < M ; j++){
				for(int k = 0 ; k < N ; k++){
					if(S[j][k] ==0){
						break;
					}
					//System.out.println("S : " + S[j][k]);
					a += Integer.parseInt(String.valueOf(denkyu).substring(S[j][k]-1,S[j][k]));

					}
				//System.out.println("a : " + a);
				if(a%2 == P[j]){
					count++;
				}
				a = 0;
			}
			//System.out.println(count);
			if(count == M){
				ans++;
			}
			count = 0;
		}
		System.out.println(ans);
	}

}

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

//const int r=1e9+7;
int main(){

string s;
cin>>s;
string t;
cin>>t;

ll n=t.size();
ll m=s.size();
ll ans=INT_MAX;
for(int i=0;i<=m-n;i++){
     int a=i;
     int k=0;
for(int j=0;j<n;j++){
   if(t[j]==s[a]){
      k++;
   }
   a++;
}
ans=min(ans,n-k);
}

cout<<ans;

return 0;
}


Measured memory_bytes: 3536
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define NMAX 100005
#define MOD (int)(1e9+7)

using namespace std;

long long N,ans=1,dp[NMAX];
vector<int > p;

int main(){
	scanf("%lld",&N);
	for (int i = 0; i < N; ++i)
	{
		scanf("%lld",&dp[i]);
	}
	for (int i = 0; i < N; ++i)
	{
		int k = p.size()+1;
		if(dp[i] >= 2*k-1){
			p.push_back(dp[i]);
			ans *= (k);
		}else{
			ans = ans * (k);
		}
		ans = ans % MOD;
	}
	printf("%lld\n",ans);

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i) ;}
  
  int alice =0;
  int bob =0;
  
  for(int i=0; i<(N/2)+1; i++){
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    alice += vec.at(0);
    vec.at(0) = 0;
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    bob += vec.at(0);
    vec.at(0) = 0;}
  cout << alice-bob << endl;
}


Measured memory_bytes: 256
n=int(input())
string=[]
ang=0
charcou=[[0]*26 for i in [1]*n]
for c in range(n):
    string.append(input())
    for d in range(10):
        charcou[c][ord(string[c][d])-97]+=1
charcou.sort()
c=0
while c<n-1:
    comb=1
    while charcou[c]==charcou[c+1]:
        comb+=1
        c+=1
        if c>=n-1:
            break
    if comb!=1:
        ang+=int(comb*(comb-1)/2)
    c+=1
print(ang)

Measured memory_bytes: 39524
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/3 22:02:32
File Name     :main.cpp
************************************************ */
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include<random>
#include<ctime>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 1e9
#define bug puts("--------------")
const ll N = 2e5 + 10;
const ll mod = 1e9 + 7;
const int Max_n = 1e6 + 10;
using namespace std;
map<string,int> hap;
int main(){
    int n;
    cin >> n;
    int M = 0;
    while(n --){
        string s;
        cin >> s;
        hap[s] ++;
        M = max(M,hap[s]);
    }
    for(auto p = hap.begin();p!=hap.end();++p){
        if(p->second == M) cout<<p->first<<endl;
    }
}

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

using namespace std;

int A[100100]; 

int main()
{
	int n,s,ma=0;
	scanf("%d%d",&n,&s);
	for(int i=0;i<n;i++)
		scanf("%d",&A[i]);
	int ans=INT_MAX,S=0,l=0,r=-1;
	while(true)
	{
		while(r<n&&S<s)
			S+=A[++r];
		//printf("%d %d %d\n",r,l,S);
		if(r>=n) break;
		while(S>=s)
		{
			ans=min(ans,r-l+1);
			S-=A[l++];
		}
	}
	if(ans==INT_MAX) ans=0;
	//if(ma>=s) ans=1;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3600
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int A1 = 0, A2 = 0, A3 = 0;
	scanf("%d %d %d", &A1, &A2, &A3);
	if (22 <= (A1+A2+A3)) {
		printf("bust\n");
	} else {
		printf("win\n");
	}

    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007
int ANS[210000];

int main()
{
	int N;
	cin >> N;
	vec(A)
		pb(A,0)
	fx(N) {
		vecp(A)
	}

	int M = 0;
	for (int x = N / 2 + 1; x <= N;x++) {
		if (A.at(x)==1) {
			ANS[x] = 1;
			M++;
		}
	}

	for (int x = N / 2; x > 0;x--) {
		int i = 2;
		int sum = 0;
		while (x*i<=N) {
			sum += ANS[x*i];
			i++;
		}

		if (sum%2!=A.at(x)) {
			ANS[x] = 1;
		}
		M += ANS[x];
	}
	ce(M)
		fx(N) {
		if (ANS[x + 1] == 1) {
			cout << x + 1 << ' ';
		}
	}
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int mod = 1e9+7;

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

    if(n == 0)
    {
        cout << x << endl;
        return 0;
    }

    int p[n];
    rep(i, n) cin >> p[i];
    sort(p, p+n);
    auto it1 = lower_bound(p, p+n, x);

    int tmp=*it1, tmpl=*it1, tmpr=*it1;

    while(tmp >= 1 && tmp <= 100)
    {
        if(!binary_search(p, p+n, tmp)) break;

        if(abs(x-tmpl) >= abs(tmpr-x))
        {
            tmpr--;
            tmp = tmpr;
        }
        else
        {
            tmpl++;
            tmp = tmpl;
        }
    }

    cout << tmp << endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N;
  cin >> N;
  string S1, S2;
  cin >> S1 >> S2;
  long long ans = 3;
  if(S1[0] != S2[0]) ans *= 2;
  if(S1.size() > 1 && S1[0] == S2[0] && S1[1] == S2[1]) ans *=2;
  for(int i = 1; i < S1.size()-1; i++){
    if(S1[i] == S1[i+1]){
      if(S1[i-1] != S2[i-1]){
        ans*= 3;
      } else{
        ans *= 2;
      }
    } else if(S1[i] == S2[i] && S1[i+1] == S2[i+1]){
      ans *= 2;
    }
    ans %= 1000000007;
  }
  cout << ans <<endl;
}


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

using namespace std;
int main() {
  int n;
  cin >> n;
  int h[n] = {0};
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  int maxH = 0;
  int result = 0;
  for (int i = 0; i < n; i++) {
    maxH = max(maxH, h[i]);
    if (h[i] >= maxH) ++result;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func main() {
	io := NewIo()
	defer io.Flush()

	A := io.NextInt()
	B := io.NextInt()

	total := 0
	if B > A {
		total += B
		B--
	} else {
		total += A
		A--
	}

	if B > A {
		total += B
		B--
	} else {
		total += A
		A--
	}

	io.PrintLn(total)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  ll value, x = v.at(n-1), i = -1;
  rep(j, n-1) {
    if (v.at(j) <= x) {
      i++;
      swap(v.at(i), v.at(j));
    }
  }
  swap(v.at(i+1), v.at(n-1));
  value = i+1;
  rep(i, n) {
    if (i) {
      if (i == value) {
        cout << ' ' << '[' << v.at(i) << ']';
      } else {
        cout << ' ' << v.at(i);
      }
    } else {
      if (i == value) {
        cout << '[' << v.at(i) << ']';
      } else {
        cout << v.at(i);
      }
    }
  }
  cout << endl;
}


Measured memory_bytes: 3556
def main():
    NOT_DET = 0
    SMALLER = 1

    s = input()
    n = len(s)  # 桁数

    k = int(input())

    dp = [[[0] * 2 for _ in range(k + 1)] for _ in range(n + 1)]
    # dp[上から何桁決めたか][0でない数字の個数][smaller=1]
    dp[0][0][0] = 1

    for i, ci in enumerate(s):
        for j in range(k + 1):
            dp[i + 1][j][SMALLER] = (
                    dp[i][j][SMALLER]
                    + dp[i][j][NOT_DET] * (1 if ci != '0' else 0)
                    + (dp[i][j - 1][SMALLER] if j > 0 else 0) * 9
                    + (dp[i][j - 1][NOT_DET] if j > 0 else 0) * max(0, int(ci) - 1)
            )

            dp[i + 1][j][NOT_DET] = dp[i][j][NOT_DET] if ci == '0' else (
                dp[i][j - 1][NOT_DET] if j > 0 else 0)

    print(sum(dp[n][k]))


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

int main(){
  string s;
  cin >> s;
  string table = "abcdefghijklmnopqrstuvwxyz";
  vector<int>  b(26);
  
  int i;
  for(i = 0 ; i < s.size() ; i++)	b.at( s.at(i) - 97 )++;
  
  int count = 0;
  for(i = 0 ; i < 26 ; i++){
    if( b.at(i) == 0){
    cout << table.at(i) << endl;
    break;
    }
  	if( i == 25 )	cout << "None" << endl;
  }
}

Measured memory_bytes: 512
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest088-B
#  TODO https://atcoder.jp/contests/abc088/tasks/abc088_b
def calcAlice(cardList):
	cardMany = len(cardList)
	alicePoint = 0
	checkRange = range(0,cardMany,+2)
	for i in checkRange:
		alicePoint = alicePoint + cardList[i]
	return alicePoint

def calcBob(cardList):
	cardMany = len(cardList)
	bobPoint = 0
	checkRange = range(1,cardMany,+2)
	for i in checkRange:
		bobPoint = bobPoint + cardList[i]
	return bobPoint

def  diffTwoScore(allCards,cardsNumberGivenList):
	cardNumberSortedList=sorted(cardsNumberGivenList,reverse=True)
	getScoreForAlice = calcAlice(cardNumberSortedList)
	getScoreForBob = calcBob(cardNumberSortedList)
	diffPoint = getScoreForAlice - getScoreForBob
	answer = diffPoint
	return answer


if __name__ == '__main__':
	N = int(input().strip())
	cardsNumberRawList = list(map(int,input().strip().split(' ')))
	solution=diffTwoScore(N,cardsNumberRawList)
	print("{}".format(solution))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int W,H,N,a,x,y;
  cin>>W>>H>>N;
  pair<int,int>max=make_pair(W,H),min=make_pair(0,0);
  for(int i=0;i<N;i++){
    cin>>x>>y>>a;
    if(a==1)if(min.first<x)min.first=x;
    if(a==2)if(max.first>x)max.first=x;
    if(a==3)if(min.second<y)min.second=y;
    if(a==4)if(max.second>y)max.second=y;
  }
  if(max.first>min.first&&max.second>min.second)cout<<(max.first-min.first)*(max.second-min.second)<<endl;
  else cout<<"0"<<endl;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    cout << fixed << setprecision(15);

    string s, t;
    double n,m,x,y;
    cin >>  n;



    cout << n*2*M_PI    << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;

  int X;
  priority_queue<int> A;
  for(int i=0;i<N;i++){
    cin>>X;
    A.push(X);
  }
 for(int i=0;i<(N/2)-1;i++){
   A.pop();
 }
 int B,C;
 B=A.top();
 A.pop();
 C=A.top();
 cout<<B-C;
}

    
  
  


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (1){
		c -= b;
		if (c <= 0){
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if (a <= 0){
			cout << "No" << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll a,b,c,k,sum =0;
	cin>>a>>b>>c>>k;
	if(a<=k)
	{
	sum += a;
	k = k-a;
    }
	else 
	{
		sum += k;
		cout<<sum<<endl;
		return 0;
	}
	if(b<=k)
	{
		k = k-b;
	}
	else
	{
		cout<<sum<<endl;
		return 0;
	}
	if(k!=0)
	{
		sum = sum-k;
		cout<<sum<<endl;
		return 0;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3648
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int a,b;

main(){
	cin>>a>>b;
	if(a<=5)dump(0);
	else if(a>=13)dump(b);
	else dump(b/2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define setNil(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
#define setNegINF(x) memset((x),192,sizeof(x)) //NegINF=-INF-1
#define setNeg1(x) memset((x),255,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=1005;
int n,x[N],y[N];
vector<ll> d;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i]>>y[i];
		if(((abs(x[i])+abs(y[i]))&1)!=((abs(x[1])+abs(y[1]))&1)){
			cout<<"-1\n";
			return 0;
		}
	}
	for(int i=31;~i;i--)d.push_back(1ll<<i);
	if(!(abs(x[1])+abs(y[1])&1))d.push_back(1);
	cout<<d.size()<<endl;
	for(int i=0;i<d.size();i++)cout<<d[i]<<' ';
	cout<<endl;
	for(int i=1;i<=n;i++){
		ll cx=x[i],cy=y[i];
		for(int j=0;j<d.size();j++){
			if(abs(cx)>abs(cy)){
				if(cx>0){
					cout<<'R';
					cx-=d[j];
				}
				else{
					cout<<'L';
					cx+=d[j];
				}
			}
			else{
				if(cy>0){
					cout<<'U';
					cy-=d[j];
				}
				else{
					cout<<'D';
					cy+=d[j];
				}
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
ABC = [list(map(int, input().split())) for i in range(N)]

ABC.append([0,0,0])

dp = []
for i in range(N+1):
  dp.append([0,0,0])

for i in range(N):
  for j in range(3):
    for k in range(3):
      if j != k:
        dp[i+1][k] = max(dp[ i + 1 ][ k ], dp[ i ][ j ] + ABC[ i ][ k ])

print(max(dp[N][0],dp[N][1],dp[N][2]))

Measured memory_bytes: 76760
a,b = map(int , raw_input().split())
"""
print a,b

x + y = a
2x + 4y = b 

y = a - x
2x + 4a - 4x = b

y = a - x
-2x = b - 4a
"""

x = (4*a - b)/2
y = a - x

print 'Yes' if x + y == a and 2*x + 4 * y == b and x >= 0 and y>=0 else 'No'

Measured memory_bytes: 64180
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
  int n; cin >> n;
  int ab = 0, a = 0, b = 0, cnt = 0;
  
  REP(i, n){
    string s; cin >> s;
    if(s[0] == 'B' && s[s.length()-1] == 'A'){
      ab++;
    }
    else if(s[0] == 'B'){
      b++;
    }
    else if(s[s.length()-1] == 'A'){
      a++;
    }

    REP(j, s.length()-1){
      if(s[j] == 'A' && s[j+1] == 'B') cnt++;
    }
  }

  if(ab > 0){
    cnt += ab-1;
    if(a > 0) cnt += 1, a -= 1;
    if(b > 0) cnt += 1, b -= 1;
    if(a > 0 && b > 0) cnt += min(a, b);
  } else {
    cnt += min(a, b);
  }
  
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

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

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

vector<long long> common_divisors(long long a, long long b) {
    long long n = gcd(a, b);
    vector<long long> ans;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (n / i == i) {
                ans.push_back(i);
            }
            else {
                ans.push_back(n / i);
                ans.push_back(i);
            }
        }
    }
    return ans;
}

int main() {
    int n, k;
    cin >> n >> k;
    priority_queue<int> Q;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        Q.push(x);
    }
    while (k--) {
        int x = Q.top();
        Q.pop();
        Q.push(x / 2);
    }
    long long sum = 0;
    while (!Q.empty()) {
        sum += Q.top();
        Q.pop();
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3836
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

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

            String ss=br.readLine();
            int n=ss.length();
            String sk=ss.substring(0,(n-1)/2);
            String ks=ss.substring((n+3)/2 -1);
            //System.out.println(ss+" "+sk+" "+ks);
            if(isPal(ss) && isPal(sk) && isPal(ks)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }




        }catch(Exception e){
            System.out.println("kkkk");
        }
    }
    static boolean isPal(String s){
        for(int i=0;i<s.length()/2;i++){
            if(s.charAt(i)!=s.charAt(s.length()-i-1)){
                return false;
            }
        }
        return true;
    }
    static class pair{
        int a,b;
        public pair(int a,int b){
            this.a=a;
            this.b=b;
        }
    }
}

Measured memory_bytes: 21204
fun main(args:Array<String>) {
    val (n,m,c) = readLine()!!.split(" ").map { it.toInt() }
    val b = readLine()!!.split(" ").map { it.toInt() }
    val ans = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }.count { a->(0 until m).map { a[it]*b[it] }.sum() + c > 0 }
    println(ans)
}

Measured memory_bytes: 38348
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

pair<int, int> E[400001];
int ne[400001], H[100001], D[100001];
bool dame, vi[100001];
void dfs(int p, int mae, int d) {
	D[p] = d;
	vi[p] = true;
	for (int i = H[p]; i; i = ne[i]) {
		int n = E[i].first;
		if (n != mae) {
			if (vi[n]) {
				if (D[n] != d + E[i].second) dame = true;
			}
			else dfs(n, p, d + E[i].second);
		}
	}
}

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


	int N = getint(), M = getint();
	rep(i, M) {
		int l = getint(), r = getint(), d = getint();
		E[i + i + 1] = mp(r, d);
		ne[i + i + 1] = H[l];
		H[l] = i + i + 1;
		E[i + i + 2] = mp(l, -d);
		ne[i + i + 2] = H[r];
		H[r] = i + i + 2;
	}

	rep1(i, N) {
		if (!vi[i]) {
			dfs(i, 0, 0);
		}
	}

	if (dame) co("No");
	else co("Yes");

	Would you please return 0;
}

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

#define ll long long

using namespace std;
 
void solve() {
    string s, t;
    cin >> s >> t;

    int n = s.size(), m = t.size();
    vector<vector<int>> dp(n, vector<int>(m, -1));

    function<int(int, int)> calc_dp = [&] (int i, int j) {
        if (i < 0 || j < 0) {
            return 0;
        }
        if (dp[i][j] != -1) {
            return dp[i][j];
        }

        if (s[i] == t[j]) {
            dp[i][j] = 1 + calc_dp(i-1, j-1);
        } else {
            dp[i][j] = max(calc_dp(i-1, j), calc_dp(i, j-1));
        }

        return dp[i][j];
    };
    int sz = calc_dp(n-1, m-1);
    string ans(sz, '-');

    int index = sz-1;
    for (int i = n-1, j = m-1; i >= 0 && j >= 0; ) {
        if (s[i] == t[j]) {
            ans[index] = s[i];
            --i; --j; --index;
        } else if (i > 0 && dp[i-1][j] > dp[i][j-1]) {
            --i;
        } else {
            --j;
        }
    }

    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}


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

typedef long long ll;
const int N = 1e5 + 100, M = 2200;

ll n, ans, a[N];
bool prime[N];
vector<ll> vec;
map<ll, ll> cnt, b, ok;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	fill(prime + 2, prime + N, true);
	for (int i = 2; i < N; i++)
		if(prime[i]) {
			for (int j = i << 1; j < N; j += i)
				prime[j] = false;
			if(i < M)
				vec.push_back(i);
			ok[1LL * i * i] = i;
		}
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ll help = 1, HELP = 1;
		for (ll x: vec) {
			int cnt = 0;
			while(a[i] % x == 0)
				a[i] /= x, cnt++;
			if(cnt % 3 == 1)
				HELP *= x, help *= x * x;
			else if(cnt % 3 == 2)
				help *= x, HELP *= x * x;
		}
		cnt[a[i] * HELP]++;
		if(ok[a[i]])
			help *= ok[a[i]];
		else
			help *= a[i] * a[i];
		b[a[i] * HELP] = help;
		b[help] = a[i] * HELP;
		cnt[b[a[i] * HELP]] += 0;
	}
	for (auto p: cnt)
		if(p.first == 1)
			ans += (p.second > 0);
		else if(p.first < b[p.first])
			ans += max(p.second, cnt[b[p.first]]);
	cout << ans;
	return 0;
}

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

namespace AtCoderBeginnerContest164
{
	class Program
	{
		static void Main(string[] args)
		{
			var inputs = ReadIntArray();

			Console.WriteLine(inputs[0] <= inputs[1] ? "unsafe" : "safe");
		}

		public static int ReadInt()
			=> int.Parse(Console.ReadLine());

		public static int[] ReadIntArray()
			=> Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

		public static long ReadLong()
			=> long.Parse(Console.ReadLine());

		public static long[] ReadLongArray()
			=> Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

		public static string ReadString()
			=> Console.ReadLine();

		public static string[] ReadStringArray()
			=> Console.ReadLine().Split();
	}
}


Measured memory_bytes: 28304
#include<bits/stdc++.h>
using namespace std;
int main()
{
  vector<string>pq;
  
  int c0 = 0;
  int c1= 0;
  int c2 = 0;
  int c3 = 0;
 long long int n;
  cin>>n;
  for(int i = 0;i<n;i++)
  {
    string c;
    cin>>c;
    pq.push_back(c);
  }
  for(int i = 0;i<n;i++)
  {
    if( pq[i] == "AC")
      c0++;
    else if(pq[i] == "WA")
      c1++;
    else if(pq[i] == "TLE")
      c2++;
    else if(pq[i] == "RE")
      c3++;
  }
  cout<<"AC"<<' '<<"x"<<' '<<c0<<endl;
  cout<<"WA"<<' '<<"x"<<' '<<c1<<endl;
  cout<<"TLE"<<' '<<"x"<<' '<<c2<<endl;
  cout<<"RE"<<' '<<"x"<<' '<<c3<<endl;
  return 0;
}

Measured memory_bytes: 7436
IDENTIFICATION DIVISION.
PROGRAM-ID. A-Task.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP      PIC X(100).
01 TSK-COST.
   03 T-C   PIC 9(3) OCCURS 3 DEPENDING ON CNT.
01 CNT      PIC 9(1) VALUE 3.

01 OUT-COST PIC ZZ9.
 
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO T-C(1) T-C(2) T-C(3).
 
  SORT T-C DESCENDING KEY T-C.
  COMPUTE OUT-COST = T-C(1) - T-C(3).
  DISPLAY OUT-COST.
 
MAIN-EXIT.
  STOP RUN.

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    string s;
    cin >> s;
    string h = "hi";
    if(s.size() % 2 == 1) {
        cout << "No";
        return 0;
    }
    for(int i = 0; i < s.size(); i += 2) {
        if(s[i] == 'h' && s[i + 1] == 'i') continue;
        cout << "No";
        return 0;
    }
    cout << "Yes";

    return 0;
}

Measured memory_bytes: 256
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    A, B = i2nn()
    if A >= 13:
        print(B)
    elif A >= 6:
        print(B // 2)
    else:
        print(0)

main()


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


int main(){
   string s,t;cin>>s>>t;
   int n=s.length();
   int r=t.length();
   char initial=t[0];
//////////
   bool sa=false;
   for(int i=n-r;i>=0;--i){
      bool ok =false;
      if(s[i]==initial || s[i]=='?'){
         bool ok = true;
         for(int j=0;j<r;++j){
            if(s[i+j]!=t[j] && s[i+j]!='?'){
               ok=false;
            }
         }
      if(ok){
         for(int j=0;j<r;++j){
            s[i+j]=t[j];
         }
         sa = true;
         break;
      }
      }
   }
   rep(i,n){
      if(s[i]=='?') s[i]='a';
   }
   if(sa)cout<<s<<endl;
   else cout<<"UNRESTORABLE"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

class UnionFind
{
public:
    UnionFind(){};
    ~UnionFind(){};
    void init(int num_entries) {
        num_entries_ = num_entries;
        par_.resize(num_entries_);
        rank_.resize(num_entries_, 0);
        REP(i, num_entries_) par_[i] = i;
    }
    int find(int x) {
        if (par_[x] == x) return x;
        else return par_[x] = find(par_[x]);
    }
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return;
        if (rank_[x] < rank_[y]) par_[x] = y;
        else {
            par_[y] = x;
            if (rank_[x] == rank_[y]) rank_[x]++;
        }
    }
    bool same(int x, int y) { return find(x) == find(y); }
private:
    int num_entries_;
    std::vector<int> par_;
    std::vector<int> rank_;
};

int main(void)
{
    cin.sync_with_stdio(false);
    int H, W;
    cin >> H >> W;

    vector<string> cells(H);
    REP(h, H) cin >> cells[h];

    UnionFind uf;
    uf.init(H * W);

    REP(h, H) {
        REP(w, W) {
            int idx = h * W + w;
            if (w != W - 1) {
                if (cells[h][w] != cells[h][w+1]) {
                    uf.unite(idx, idx + 1);
                }
            }
            if (h != H - 1) {
                if (cells[h][w] != cells[h+1][w]) {
                    uf.unite(idx, idx + W);
                }
            }
        }
    }

    // id, <'#'(black), '.'(white)>
    map<int, pair<ll, ll>> cnt;
    REP(h, H) {
        REP(w, W) {
            int idx = h * W + w;
            int id = uf.find(idx);
            if (cells[h][w] == '#') {
                cnt[id].first++;
            } else {
                cnt[id].second++;
            }
        }
    }
    ll ans = 0;
    for(auto kv: cnt) {
        auto id = kv.first;
        auto black = kv.second.first;
        auto white = kv.second.second;
        ans += black * white;
        // cout << kv.first << "," << kv.second << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10240
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    ll N;
    in(N);
    N--;

    string ans;

    do
    {
        int num = N % 26;

        ans += ('a' + num);

        N /= 26;
        N--;
    } while (N >= 0);

    reverse(all(ans));

    outl(ans);

    return 0;
} 

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

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

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

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  char field[h][w];
  int d[h][w];
  n++;
  P goals[n];
  rep(i,h) rep(j,w) {
    cin >> field[i][j];
    if (field[i][j] == 'S') {
      goals[0] = P(i, j);
    } else if (field[i][j] != '.' && field[i][j] != 'X') {
      goals[field[i][j]-'0'] = P(i, j);
    }
  }

  int ans = 0;
  for (int i=0; i<n-1; i++) {
    rep(x,h) rep(y,w) d[x][y] = -1;

    queue<P> que;
    que.push(goals[i]);
    d[goals[i].first][goals[i].second] = 0;

    //    printf("[*] start: %d %d\t goal: %d %d\n", goals[i].first, goals[i].second, goals[i+1].first, goals[i+1].second);

    while (!que.empty()) {
      P xy = que.front(); que.pop();
      if (goals[i+1].first == xy.first && goals[i+1].second == xy.second) {
	ans += d[xy.first][xy.second];
	break;
      }
      
      //      printf("   [*] d[%d][%d]: %d\n", xy.first, xy.second, d[xy.first][xy.second]);
  
      rep(j,4) {
        int nx = xy.first + dx[j];
        int ny = xy.second + dy[j];
  
        if (nx < 0 || h <= nx) continue;
        if (ny < 0 || w <= ny) continue;
        if (field[nx][ny] == 'X') continue;
	if (d[nx][ny] != -1) continue;
	que.push(P(nx, ny));
	d[nx][ny] = d[xy.first][xy.second] + 1;
	//	printf("      [*] d[%d][%d]: %d\n", nx, ny, d[nx][ny]);
      }
    }
  }

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



Measured memory_bytes: 7996
#include<stdio.h>
int main(){
int W,H,x,y,r;
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	if(x-r<0||y-r<0||H<y+r||W<x+r){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

struct Edge {
    int from, to, c;
};

vector<Edge> edges;

LL dis[2505];

LL INF = 99999999999999;

bool vis[2506];

void dfs(int x) {
    vis[x] = true;
    for (auto e : edges) {
        if (e.to == x && !vis[e.from]) {
            dfs(e.from);
        }
    }
}

int main() {
    int n, m, p;
    cin >> n >> m >> p;
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        edges.push_back({a, b, -(c-p)});
    }
    dfs(n);
    for (int i = 1; i <= n; i++) {
        dis[i] = INF;
    }
    dis[1] = 0;
    bool better;
    for (int i = 0; i <= n; i++) {
        better = false;
        for (auto e: edges) {
            if (vis[e.from] && vis[e.to] && dis[e.from] != INF && dis[e.from] + e.c < dis[e.to]) {
                dis[e.to] = dis[e.from] + e.c;
                better = true;
            }
        }
    }
    // 負環
    if (better) {
        printf("-1\n");
    } else {
        printf("%lld\n", max(0ll, -dis[n]));
    }
}


Measured memory_bytes: 3948
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <string.h>
#include <cmath>

using namespace std;
#define ll long long int

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll n,m,a,b;
	cin>>n>>m;
	vector<ll> v[n+1];
	for (int i = 0; i < m; ++i)
	{
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);		
	}
	// for (int i = 1; i <= n; ++i)
	// {
	// 	for (int j = 0; j < v[i].size(); ++j)
	// 	{
	// 		cout<<v[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	ll h[n+1]={0},dist=0;
	bool reach[n+1]={false};
	queue<ll> q;
	q.push(1);
	h[1]=0;
	reach[1]=true;
	while(!q.empty()){
		ll temp=q.front();
		// cout<<temp<<" "<<endl;

		for (int i = 0; i < v[temp].size(); ++i)
		{
			if(reach[v[temp][i]]==false){
				q.push(v[temp][i]);
				h[v[temp][i]]=temp;
				reach[v[temp][i]]=true;			
			}
		}
		q.pop();
		// dist++;
	}
	// for (int i = 1; i <=n; ++i)
	// {
	// 	cout<<reach[i]<<" ";
	// }
	// cout<<endl;
	// for (int i = 1; i <=n; ++i)
	// {
	// 	cout<<h[i]<<" ";
	// }
	// cout<<endl;
	for (int i = 1; i <= n; ++i)
	{
		if(reach[i]==false){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for (int i = 2; i <=n; ++i)
	{
		cout<<h[i]<<endl;
	}

	return 0;
}


Measured memory_bytes: 13132
#include <iostream>     // std::cin, std::cout
#include <iomanip>      // std::get_money
using namespace std;                            
int main ()
{
//	#ifndef ONLINE_JUDGE
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
//	#endif
	int a;
	cin>>a;
	int c=0;
	for(int i=0;i<a;i++)
	{
	 	int x;cin>>x;if(x!=i+1)c++; 	
	}	
	if(c>2)
	cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;
int main()
{
	int N, K;
	int A[10000];

	cin >> N >> K;

	int Ans;

	if ((N - 1) % (K - 1) == 0) {
		Ans = (N - 1) / (K - 1);
	}
	else Ans = (N-1) / (K - 1) + 1;

	cout << Ans;

	return 0;
}

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

using namespace std;

string s;
int ans; 
int main()
{
	cin >> s;
	for(int i = 0; i < s.size(); i++)
	{
		ans += (s[i] - '0');
	}
	if(ans % 9 == 0)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];

int32_t  main(){
	IOS;
  string a,b,c;cin>>a>>b>>c;
  cout<<a[0]<<b[0]<<c[0]<<endl;

  return 0;
}



Measured memory_bytes: 256