akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    bool lose = true;
    rep(i, n) if (a[i] % 2 == 1) lose = false;

    cout << (lose ? "second" : "first") << '\n';
}


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

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define endl '\n'
typedef long long li;
const int N = 1e5 + 10;
int n;
int a[N];
int dp[N];
li solve(int i){

	if(i>=n-1)
		return 0;
	if(dp[i]!=-1)
		return dp[i];
	int p = abs(a[i]-a[i+1]) + solve(i+1);
	int q = INT_MAX;
	if(n-i>2){

		q = abs(a[i]-a[i+2]) + solve(i+2);
	}
	return dp[i] = min(p,q);
}
int main(){
	cin>>n;
	for(int i = 0 ; i < n ; ++i)
		cin>>a[i];
	memset(dp,-1,sizeof(dp));
	cout<<solve(0)<<endl;
}

Measured memory_bytes: 4096
require 'prime'
loop do
  n, p = gets.split.map(&:to_i)
  break if n == -1
  p Prime.each.lazy.drop_while{ |e| e <= n }.take(p).to_a.repeated_combination(2).to_a.map{ |a| a.reduce(:+) }.sort[p-1]
end

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

int main()
{
	string s;

	cin >> s;

	if (s == "Sunny")cout << "Cloudy" << endl;
	if (s == "Cloudy")cout << "Rainy" << endl;
	if (s == "Rainy")cout << "Sunny" << endl;

	return 0;
}

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

using namespace std;
const double PI=3.14159265358979323846;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))


int main() {

	int S, W;

	cin >> S >> W;

	string ans = "safe";
	if (S <= W) ans = "unsafe";
	
	cout << ans << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(void){
  char s[100000]={0};
  int count=0;

  int i;
 
scanf("%s",s);
 for(i=0;i<=100000;i++){
if(s[i]=='1'&&i%2!=0){
count++;
}
   if(s[i]=='0'&&i%2==0){
count++;
}

 
 if(s[i]=='\0'){
 break;
 }
 
 }
  if(count*2<i){
  printf("%d",count);
  }else{
  printf("%d",i-count);
  }
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    long long a[10010], b[10010];
    long long sum_a = 0, sum_b = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum_a += a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
        sum_b += b[i];
    }
    if (sum_a > sum_b) {
        puts("No");
        return 0;
    }
    long long needs = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] < b[i]) {
            needs += (b[i] - a[i] + 1) / 2;
        }
    }
    if (needs <= sum_b - sum_a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 384
#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 pb push_back
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;
  cin >> n;

  vi a(n);
  rep(i, 0, n) cin >> a[i];

  vi pos, neg;
  int zero = 0;
  rep(i, 0, n){
    if(a[i] > 0){
      pos.pb(a[i]);
    }else if(a[i] < 0){
      neg.pb(a[i]);
    }else{
      zero++;
    }
  }

  int ansx;
  vector<pii> ans;
  if(pos.size() > 0 and neg.size() > 0){
    int tmp = neg[0];
    rep(i, 1, pos.size()){
      ans.pb({tmp, pos[i]});
      tmp -= pos[i];
    }

    int tmp2 = pos[0];
    rep(i, 1, neg.size()){
     ans.pb({tmp2, neg[i]}); 
     tmp2 -= neg[i];
    }

    rep(i, 0, zero){
      ans.pb({tmp2, 0});
    }

    ans.pb({tmp2, tmp});
    ansx = tmp2 - tmp;

  }else if(pos.size() > 0 and neg.size() == 0){
    rep(i, 0, zero) pos.pb(0);
    sort(all(pos));
    int tmp = pos[0];
    rep(i, 1, pos.size()-1){
      ans.pb({tmp, pos[i]});
      tmp -= pos[i];
    }
    ans.pb({pos[n-1], tmp});
    ansx = pos[n-1]-tmp;
  }else if(pos.size() == 0 and neg.size() > 0){
    rep(i, 0, zero) neg.pb(0); 
    sort(all(neg));
    reverse(all(neg));
    int tmp = neg[0];
    rep(i, 1, neg.size()){
      ans.pb({tmp, neg[i]});
      tmp -= neg[i];
    }
    ansx = tmp;
  }else{
    rep(i, 0, n-1){
      ans.pb({0, 0});
    }
    ansx = 0;
  }

  cout << ansx << endl;
  rep(i, 0, n-1){
    cout << ans[i].first << " " << ans[i].second << endl;
  }

  return 0;
}


Measured memory_bytes: 5872
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val k = sc.nextInt()
    val n = sc.nextInt()
    if (k % 2 == 0) {
        val a = Array(n) { k }
        a[0] = k / 2
        println(a.joinToString(" "))
    } else {
        val que = ArrayDeque<Int>()
        for (i in 0 until n) {
            que.addFirst((k + 1) / 2)
            if (i % 2 == 1) {
                val v = que.pollLast()
                if (v != 1) {
                    que.addLast(v - 1)
                    while (que.count() != i + 1) {
                        que.addLast(k)
                    }
                }
            }
        }
        println(que.joinToString(" "))
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

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

bool solve(string in){
	string rev_in = in;
	reverse(rev_in.begin(), rev_in.end());
	if (in == rev_in)	return true;
	else return false;
}

int main(){
	string in;
	int count = 0;
	while (cin >> in, !cin.eof()){
		if (solve(in))	count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1192
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      if(b+c > a) System.out.println(b+c-a);
      else System.out.println(0);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;

long long i,n,s,m;

int main()
{
    scanf("%d%d",&n,&m);
    if (abs(n-m)>1)
    {
        printf("0");
    }
    else
    {
        s=1;
        for (i=1;i<=min(n,m);i++)
        {
            s=(s*i)%1000000007;
        }
        if (n==m)
        {
            s=(((s*s)%1000000007)*2)%1000000007;
        }
        else
        {
            s=(((s*s)%1000000007)*max(n,m))%1000000007;
        }
        printf("%lld",s);
    }
}

Measured memory_bytes: 256
from functools import reduce
p = 1000000007  #ここを変える
ccache = []
inv_ccache = []
def powmod(a, n):
    global p
    res = 1
    tmp=a
    while n>0:
        if n & 1 == 1:
            res = (res * tmp) % p
        n=n//2
        tmp = tmp * tmp % p
    return res
def invmod(n):
    return powmod(n, p - 2)
def cmod(n, r):
    global p
    global ccache
    global inv_ccache
    if len(ccache) == 0:
      ccache.append(1)
      inv_ccache.append(1)
      for i in range(210000):
        ccache.append(ccache[i]*(i+1)%p)
        inv_ccache.append(invmod(ccache[i+1]))
    if r > n or r < 0:
        return 0
    if r > n // 2:
        return cmod(n, n - r)
    return ccache[n]*inv_ccache[r]%p*inv_ccache[n-r]%p
 
n = int(input())
adj_of = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    adj_of[a - 1].append(b - 1)
    adj_of[b - 1].append(a - 1)
stack = [(0, -1)] # root, excludee
course = []
while len(stack) > 0:
    popped = stack.pop()
    course.append(popped)
    for adj in adj_of[popped[0]]:
        if adj != popped[1]:
            stack.append((adj, popped[0]))
sizes = [{} for _ in range(n)] #size, pattern_num
pattern_nums = [{} for _ in range(n)]
for step in reversed(course):
    size = 1
    pattern_num = 1
    for adj in adj_of[step[0]]:
        if adj != step[1]:
            size += sizes[adj][step[0]]
            pattern_num *= pattern_nums[adj][step[0]] * cmod(size - 1, sizes[adj][step[0]]) % p
            pattern_num %= p
    sizes[step[0]][step[1]] = size
    pattern_nums[step[0]][step[1]] = pattern_num
 
#print(course)
#print(sizes)
#print(pattern_nums)
 
ans = [None] * n
for step in course:
    if step[0] == 0:
        ans[0] = pattern_nums[0][-1]
        continue
    #ans[step[0]] = pattern_nums[step[0]][step[1]] * pattern_nums[step[1]][step[0]]\
    #             * cmod(sizes[step[0]][step[1]] + sizes[step[1]][step[0]], sizes[step[0]][step[1]]) % p
    pattern_nums_step1_step0 = ans[step[1]] * invmod(cmod(n - 1, sizes[step[0]][step[1]]) % p * pattern_nums[step[0]][step[1]]) % p
    ans[step[0]] = pattern_nums[step[0]][step[1]] * pattern_nums_step1_step0 % p\
                 * cmod(n - 1, sizes[step[0]][step[1]] - 1) % p
 
for a in ans:
    print(a)


Measured memory_bytes: 212392
N,K=map(int,input().split())
S=[list(map(int,input().split())) for _ in range(K)]

NUM=998244353
dp=[0]*(N+1)
dp[1]=1
sums=[0]*(N+1)
sums[1]=1
for i in range(2,N+1):
    for s in S:
        _l,_r=i-s[0],i-s[1]-1
        if _l<0:
            continue
        elif _r<0:
            _r=0
        dp[i]+=sums[_l]-sums[_r]
        dp[i]%=NUM
    sums[i]=dp[i]+sums[i-1]
    sums[i]%=NUM

print(dp[N])


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

const int N = 305;
typedef long long LL;

LL f[N][N][N], mod = 998244353, ans;
int n, m, last, cnt, a[N], sum[N];
char s[N];

int main() {
	cin>>(s + 1)>>m;
	n = strlen(s + 1);
	m = min(m, n);
	for(int i = 1; i <= n; i++) 
		if(s[i] == '0') a[++cnt] = i - last - 1, last = i;
	if(last != n)
		a[++cnt] = n - last;
	for(int i = cnt; i; i--)
		sum[i] = sum[i + 1] + a[i];
	f[cnt + 1][0][0] = 1;
	for(int i = cnt; i; i--)
		for(int j = 0; j <= m && j <= sum[i]; j++)
			for(int k = 0; k <= j; k++) {
				f[i][j][k] = f[i + 1][j][k];
				for(int p = 1; p <= a[i] && p <= j; p++)
					f[i][j][k] = (f[i][j][k] + f[i + 1][j - p][k - p])%mod;
				for(int p = 1; p <= j - k; p++)
					f[i][j][k] = (f[i][j][k] + f[i + 1][j][k + p])%mod;
			}
	for(int i = 0; i <= m; i++)
		ans = (ans + f[1][i][0])%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 31380
from fractions import gcd
A,B=map(int,input().split())
x=gcd(A,B)
prime=set()
prime.add(1)
for i in range(2,int(x**0.5)+1):
    while x%i==0:
        prime.add(i)
        x//=i
if x!=1:
    prime.add(x)
print(len(prime))

Measured memory_bytes: 5432
#include <iostream>
#include <string>
#include <cstdlib>
#include <bits/stdc++.h>
#include <algorithm>
#include <cctype>
using namespace std ;

int main(){
    int a = 0  ;
    for (int i = 0; i < 3; i++)
    {int temp = 0 ;
    cin >> temp ;
        a += temp ;

    }
    if(a == 17) cout << "YES" ;
    else cout << "NO" ;
    return  0 ;
    }

    


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

int main(){
  std::string n;
  std::cin >> n;

  if(n[0] != n[1] && n[1] != n[2] && n[2] != n[3])
    std::cout << "Good\n";
  else std::cout << "Bad\n";

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  vector<int> a(n);
  map<int, int> mp;
  for(int i=0;i<n;i++){
    cin>>a[i];
    mp[a[i]]++;
  }
  sort(a.begin(), a.end());
  int ans=1;
  for(int i=0;i<n;i++){
    ans=max(ans, mp[a[i]-1]+mp[a[i]]+mp[a[i]+1]);
  }
  cout<<ans<<endl;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];a[i]--;
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(a[a[i]] == i) ans++;
    }
    cout << ans/2 << endl;

    return 0;
}


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

int main(){
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int count = 0;
  for(int i = 0; i <= A; i++){
    for(int j = 0; j <= B; j++){
      for(int k = 0; k <= C; k++){
        int tmp = 500 * i + 100 * j + 50 * k;
        if(tmp == X) count++;
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3628
from sys import stdin
import fractions

N, M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) // 2 for x in stdin.readline().rstrip().split()]
ans = 0
g = 1

for i in range(len(A)):
    g = g * A[i] // fractions.gcd(g % A[i], A[i])
    if g > M:
        print(0)
        exit()

for i in range(len(A)):
    if (g // A[i]) % 2 == 0:
        print(0)
        exit()

ans = M // g
if ans % 2 == 0:
    print(ans // 2)
else:
    print((ans + 1) // 2)


Measured memory_bytes: 89580
/*
 Author: Alokit Kumar 
 */
 #include<bits/stdc++.h>
 using namespace std;
 #define int long long
 int32_t main()
 {
   int n,k,d,i,j,l,x,s=0;
   cin>>n>>k;map<int,int> m;
   for(i=1;i<=k;i++)
   {
     cin>>l;
     for(j=1;j<=l;j++)
     {
       cin>>x;
        m[x]++;
     }
   }
   for(i=1;i<=n;i++)
   {
     if(m.count(i))
       ;
     else
        s++;
   }
   cout<<s;
   return 0;
 }

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

using namespace std;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;

    cin >> n;
    vector<int> a(n);
    vector<int> whpos(n);

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

    set<int> curborder;

    curborder.insert(-1);
    curborder.insert(n);
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        auto rit = curborder.upper_bound(whpos[i]);

        long long r = *rit;
        long long l = *(--rit);
        ans += (i + 1) * (whpos[i] - l) * (r - whpos[i]);
        curborder.insert(whpos[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
int n, m, a, b, c, dp[4096];
int main() {
    cin >> n >> m;
    int s = (1 << n);
    dp[0] = 0;
    for(int i = 1; i < s; i++) dp[i] = 1e9;
    while(m--) {
        cin >> a >> b;
        int t = 0;
        while(b--) {
            cin >> c;
            t |= (1 << --c);
        }
        for(int i = 0; i < s; i++) {
            if(dp[i] != 1e9) dp[i | t] = min(dp[i | t], dp[i] + a);
        }
    }
    cout << (dp[s-1] == 1e9 ? -1 : dp[s-1]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int k, x;
  cin >> k >> x;

  for (int i = x-k+1; i <= x+k-1; i++) {
    cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,p;
    cin>>n>>m>>p;
    vector <vector <ll> > ed(m,vi());
    for(ll i=0;i<m;i++)
    {
        ll x,y,c;
        cin>>x>>y>>c;
        x--;
        y--;
        ed[i].pb(x);
        ed[i].pb(y);
        ed[i].pb(p-c);
    }
    vi dis(n,99999999999ll);
    dis[0]=0;
    ll high=99999999999ll;
    for(ll i=0;i<2*n;i++)
    {
        for(ll j=0;j<m;j++)
        {
            if(dis[ed[j][0]]==99999999999ll)
                continue;
            if(dis[ed[j][0]]+ed[j][2]<dis[ed[j][1]])
            {
                if(i>=n-1 )
                    dis[ed[j][1]]=-1*high;
                else
                    dis[ed[j][1]]=ed[j][2]+dis[ed[j][0]];
            }
        }
    }
    bool po=1;
    if(po)
    {
        ll x=-1*dis[n-1];
        if(x<0)
        {
            x=0;
        }
        if(x==high)
            x=-1;
        cout<<x<<endl;
    }
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<T> ReadVec1(int N) {
    vector<T> vec(N);
    for(int i = 0; i < N; i++)
        vec[i] = In<T>();
    return move(vec);
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(j, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int main() { 
    int N = In<int>();
    vector<int> h = ReadVec1<int>(N);
    vector<int> dp(N);
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for(int n = 2; n < N; n++){
        dp[n] = min(dp[n-2] + abs(h[n - 2] - h[n]), dp[n-1] + abs(h[n - 1] - h[n]));
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long ull;
const double EPS= (1e-9);
using namespace std;
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=4000+9;
string s;
int arr[N][4];
int rng(int a,int b,int f){

  return arr[b][f]-(a==0?0:arr[a-1][f]);
}
int main(){
    GO();

    int n;
    cin>>n>>s;
    int c1=0,c2=0,c3=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R') c1++;
        else if(s[i]=='G') c2++;
        else
            c3++;

        arr[i][0]=c1;
        arr[i][1]=c2;
        arr[i][2]=c3;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){

            if(s[i]==s[j]) continue;
            int fl=0;
            if(s[i]!='R'&&s[j]!='R') fl=0;
            else if(s[i]!='G'&&s[j]!='G') fl=1;
            else
                fl=2;
            int ds= (j-i);
            ans+= rng(j+1,n-1,fl)-(j+ds<n&&rng(j+ds,j+ds,fl)==1?1:0);

        }
    }
    cout<<ans<<"\n";

}




























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

using namespace std;

int solve(vector<int>& h, int l, int r) {
    int min = 100;
    for (int i = l; i < r; i++) {
        if (min > h[i]) {
            min = h[i];
        }
    }

    for (int i = l; i < r; i++) {
        h[i] -= min;
    }

    int cnt = min;
    for (int i = l; i < r; i++) {
        if (h[i] > 0) {
            for (int j = i + 1; j <= r; j++) {
                if (j == r || h[j] == 0) {
                    cnt += solve(h, i, j);
                    i = j - 1;
                    break;
                }
            }
        }
    }

    return cnt;
}

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

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

    cout << solve(h, 0, n) << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    int A,B; cin >> A >> B;

    if(B%A == 0) cout << B/A << endl;
    else cout << B/A + 1 << endl;

    return 0;

}


Measured memory_bytes: 3160
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 

 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    int x = sc.nextInt();
    int[] nums = new int[n];
    for(int i = 0; i < n; i++){
      nums[i] = Math.abs(sc.nextInt() - x);
    }

    int ans = nums[0];

    for(int i = 1; i < n; i++){
      ans = gcd(ans, nums[i]);
    }

    System.out.println(ans);

   
 
  }
  static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

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

int main() {
    long long N;
    cin >> N;
    long long minA = N;
    for (long long A = 2; A * A <= N; ++A){
        if (N % A == 0) minA = N / A;
    }
    int k = 0;
    for (; minA; minA/=10) ++k;
    cout << k;
    return 0;
}

Measured memory_bytes: 256
import math

people_count = int(input())
day_count_and_leave_count = input()
day_count = int(day_count_and_leave_count.split()[0])
leave_count = int(day_count_and_leave_count.split()[1])
interval_date_list=[]
for x in range(0,people_count):
	interval_date_list.append(int(input()))

choco_count = 0
for interval_date in interval_date_list:
	choco_count += 1
	choco_count += math.floor((day_count - 1) / interval_date)
choco_count += leave_count
print(choco_count)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	std::cin >> N;
	ll ans = 1;
	vll cnt(N+1,1);
	repeq(k, 2, N) {
		for (ll i = k; i <= N; i += k) {
			cnt[i]++;
		}
		ans += k * cnt[k];
	}

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


Measured memory_bytes: 81400
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int A = cin.nextint;
        int B = cin.nextint;
        int K = cin.nextint;
        for (int i = A; i < Math.Min(A + K, B + 1); i++)
        {
            WriteLine(i);
        }
        for (int i = Math.Max(A + K, B - K + 1); i <= B; i++)
        {
            WriteLine(i);
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

lst = [list(map(int, input().split())) for _ in range(N)]

lst.sort()
price = 0


for A, B in lst:
    if M == 0:
        break
    for i in range(B):
        price += A
        M -= 1
        if M == 0:
            break

print(price)   

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

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................
static int g=2;
static int f(int[] a, int[] b){
	if(a[0]+a[1]>=g&&b[0]+b[1]>=g){
		return a[0]-b[0];
	}
	return b[0]+b[1]-a[0]-a[1];
}
   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  	int[] a=int_arr();
	        		  	int x=a[0],y=a[1];boolean b=false;
	        		  	for(int i=0;i<=x;i++){
	        		  		if((y-i*2)%4==0&&((y-i*2)/4==x-i)){
	        		  			out.write("Yes");b=true;
	        		  			break;
	        		  		}

	        		  	}
	        		  	if(!b){out.write("No");}
                      out.flush();
	        		 
	}
}
	       
	          



	
  





	
  





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

const int N = 100005;

int n;
int a[N], b[N];

int main(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        b[a[i]] = i;
    }
    for (int i = 1; i <= n; i++){
        cout << b[i] << ' ';
    }
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
#define SIZE 200005
#define M 2019;
ll arr[SIZE];
string str;
map<ll,ll> m;
ll power(ll a,ll b){
	if(b==0)
		return 1;
	ll p=power(a,b/2);
	p=(p*p)%M;
	if(b%2==0){
		return p;
	}
	else{
		return (p*a)%M;
	}
}
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>str;
	ll num=0;
	for(ll i=str.size()-1;i>=0;--i){
		num=(str[i]-'0')*power(10,str.size()-i-1)+num;
		num=num%M;
		arr[i]=num;
		//cout<<i<<" "<<arr[i]<<endl;
	}
	m[0]=1;
	ll ans=0;
	for(ll i=0;i<str.size();++i){
		if(m.find(arr[i])==m.end()){
			m[arr[i]]=1;
		}
		else{
			ans+=m[arr[i]];
			m[arr[i]]++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5308
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    int n=s.size();
    s=s.c_str();
    int ans1=0;
    int count=0;
    while(true){
        if(s[count]!='0'){
            ans1++;
        }
        if(count==n-1) break;
        count++;
        if(s[count]!='1'){
            ans1++;
        }
        if(count==n-1) break;
        count++;
    }
    count=0;
    int ans2=0;
    while(true){   
        if(s[count]!='1'){
            ans2++;
        }
        if(count==n-1) break;
        count++;
        if(s[count]!='0'){
            ans2++;
        }
        if(count==n-1) break;
        count++;
    }
    int ans=min(ans1,ans2);
    cout <<ans<< "\n";
}

Measured memory_bytes: 512
// ref. https://www.hamayanhamayan.com/entry/2019/01/12/154729

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << 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; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

const ll MAX_S = 2e4 + 5; // maximum of s+w

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<ll> w(n), s(n), v(n);
  rep(i, n) {
    cin >> w[i] >> s[i] >> v[i];
  }

  vector<ll> ord; // order
  rep(i, n) { ord.push_back(i); }
  sort(all(ord), [&](ll a, ll b) {
    return min(s[a], s[b]-w[a]) > min(s[b], s[a]-w[b]);
  });

  // dp[i][j] .. using [0, i), total amount is j.
  vector<vector<ll>> dp(n+1, vector<ll>(MAX_S));
  rep(i, n) rep(tot, MAX_S) {
    ll a = ord[i];
    chmax(dp[i+1][tot], dp[i][tot]);
    if (tot <= s[a]) {
      chmax(dp[i+1][tot+w[a]], dp[i][tot] + v[a]);
    }
  }
  ll ans = 0;
  rep(i, MAX_S) { chmax(ans, dp[n][i]); }
  cout << ans << endl;
}


Measured memory_bytes: 160640
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007
    #define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
    #define GCD(m,n) __gcd(m,n)
    #define LCM(m,n) m*(n/GCD(m,n))
    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {
        int l,r,k=2019;
        cin>>l>>r;
        int a=l/k,b=r/k;
        if(a!=b) return cout<<0,0;
        a=l%k;b=r%k;
        int ans=10000000;
        for(int i=a;i<=b;i++){
            for(int j=i+1;j<=b;j++)
            {
                int temp=(i*j)%k;
                ans=min(ans,temp);
            }         
     }
     cout<<ans;
        }
        
    signed main()
    {   
        asdf
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

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

int n = 0;

int dfs(int step) {
	if (step == n) return 1;
	if (step > n) return 0;
	return dfs(step+1) + dfs(step+2) + dfs(step+3);
}

int GetYears(int c) {
	int days = c / 10;
	if (c % 10 != 0) days++;
	int years = days / 365;
	if (days % 365 != 0) years++;
	return years;
}

int main() {
	for(;;) {
		cin >> n;
		if (n == 0) break;
		cout << GetYears(dfs(0)) << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
#include<iostream>
using namespace std;
long long n,srx[101];
int i;
long long lgx(long long n)
{
    if(srx[n])
    return srx[n];
    if(n>0)
    srx[n]=lgx(n-1)*2+2;
}
int main()
{
    cin>>n;
    srx[0]=2;
    lgx(n);
    cout<<srx[n]<<endl;
    return 0;
}

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

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

    if(a == 25){
        cout << "Christmas" << endl;
    }else if(a == 24){
        cout << "Christmas Eve" << endl;
    }else if(a == 23){
        cout << "Christmas Eve Eve" << endl;
    }else{
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
c=Counter(a)
ans,nokori=0,0
c=sorted(c.items(),reverse=True)
for k,v in c:
  cnt=min((v+nokori)//2,n)
  n-=cnt
  ans+=int(k)*cnt
  nokori=(v+nokori)%2
print(ans)

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

long euclidean_gcd(long a, long b) {
  if(a < b) return euclidean_gcd(b, a);
  while(b!=0){
      long k=b;
      b = a%b;
      a=k;
  }
  return a;
}

int main(){
    long K;cin>>K;
    long sum=0;
    for(long i=1;i<=K;i++){
        for(long j=1;j<=K;j++){
            for(long k=1;k<=K;k++){
                long p = euclidean_gcd(i,j);
                long q = euclidean_gcd(p,k);
                sum+=q;
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3592
import math

H, W = list(map(int, input().split()))

if((H==1)or(W==1)) :
  print(1)
  exit()

if((H%2==0) or (W%2==0)) :
  print(int(H*W/2))
else :
  print(int((H+1)*W/2-math.floor((W-1)/2)))

Measured memory_bytes: 3060
import math
a,b,h,m = map(int,input().split())
min = 60*h + m

hour =  min * 0.5
minute = m * 6
open = abs(hour-minute)

if open > 180:
    open = 360 - open 

cos = math.cos(math.radians(open))
cc = a**2 + b**2 - 2 * a * b * cos
c = math.sqrt(cc)

print(c)


Measured memory_bytes: 9436
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    vector<vector<int>> A(3,vector<int>(3));
    rep(i,3){
        rep(j,3){
            cin >> A[i][j];
        }
    }
    int n; cin >> n;
    vector<int> b(n);
    rep(i,n) cin >> b[i];
    int a[3][3];
    rep(i,n){
        rep(j,3){
            rep(k,3){
                if (A[j][k] == b[i]) a[j][k] = 1;
            }
        }
    }
    bool res = false;
    rep(i,3){
        if (a[i][0] == 1 && a[i][1] == 1 && a[i][2] == 1 ){
            res = true;
        }
    }
    if (a[0][0] == 1 && a[1][0] == 1 && a[2][0] == 1 ){
            res = true;
        }
    if (a[0][1] == 1 && a[1][1] == 1 && a[2][1] == 1 ){
            res = true;
        }
    if (a[0][2] == 1 && a[1][2] == 1 && a[2][2] == 1 ){
            res = true;
        }
    if (a[0][0] == 1 && a[1][1] == 1 && a[1][1] == 1 ){
            res = true;
        }
    if (a[2][0] == 1 && a[1][1] == 1 && a[0][2] == 1 ){
            res = true;
        }
    
    if (res) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define display(v) for (auto x : v) cout << x << ", "
#define dbg(x) cout << (#x) << " = " << (x) << "\n"
#define dbgp(x) cout << (#x) << " = {" << (x.first) << ", " << (x.second) << "}\n";
#define print(x) cout << (#x) << " = [ ";display(x); cout << "]\n"
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;


int main()
{
	fastio;

	int n, d;
	cin >> n >> d;
	vector <int> v[n];
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < d; j++)
		{
			int temp;
			cin >> temp;
			v[i].pb(temp);
		}
	}
	int ans = 0;
	set <int> st;
	for (int i = 0; i < 1000; i++)
		st.insert(i * i);
	//cout << "here";
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			int temp = 0;
			for (int k = 0; k < d; k++)
				temp += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]);
			if (st.find(temp) !=st.end())
				ans++;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
	string s;
    ll k;
    cin>>s>>k;
    set<ll>st;
    vector<ll>v;
    ll ans=0;
    rep(i,s.size())st.insert(s[i]);
    if(st.size()==1)cout<<(s.size()*k)/2<<"\n";
    else {
        rep(i,s.size()-1){
            ll cnt=1;
            while(i<s.size()-1&&s[i]==s[i+1]){
                ++i;++cnt;
            }
            ans+=cnt/2;
            v.pb(cnt);
        }
        ans*=k;
        if(s.front()==s.back())ans+=(k-1)*((v.front()+v.back())/2-v.front()/2-v.back()/2);
        //先頭と末尾を合わせたものから先頭と末尾だけのものそれぞれを引いて、先頭と末尾を合わせて生まれる連続する文字を数える
        cout<<ans<<"\n";
    }
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
const int mo=1e9+7;
int fac[200001],x;
int pow(int x,int n){
	int t=1,y=x;
	while (n){
		if (n&1) t=1ll*t*y%mo;
		y=1ll*y*y%mo;
		n>>=1;
	}
	return t;
}
int main(){
	int h,w,a,b,i,j,m,ans=0;
	scanf("%d%d%d%d",&h,&w,&a,&b);
	m=h+w;
	fac[0]=1;
	for (i=1;i<=m;++i) fac[i]=1ll*fac[i-1]*i%mo;
	for (i=b+1;i<=w;++i){
		x=1ll*fac[h-a+i-2]*pow(1ll*fac[i-1]*fac[h-a-1]%mo,mo-2)%mo;
		x=1ll*fac[a+w-i-1]*pow(1ll*fac[a-1]*fac[w-i]%mo,mo-2)%mo*x%mo;
		ans=(ans+x)%mo;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    string s,t;cin >> s >> t;
    int mi = inf;
    rep(i, s.size()-t.size()+1) {
        string k = s.substr(i, t.size());
        int count = 0;
        rep(j, t.size()) {
            if(t[j]!=k[j]) count++;
        }
        chmin(mi,count);
        // cout << k << endl;
    }
    cout << mi << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector <double> A(N);
    for (int i=0; i<N; i++) cin >> A.at(i);
    double bo=0;
    for (int i=0; i<N; i++) bo += pow(A.at(i),-1);
    cout << pow(bo,-1);
}

Measured memory_bytes: 256