akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int dp[5050][5050];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	string S;
	cin >> N >> S;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = i+1; j <= N; j++) {
			if (S[i - 1] == S[j - 1]) {
				if(j-i > dp[i-1][j-1])dp[i][j] = dp[i-1][j-1]+1;
				else dp[i][j] = dp[i-1][j-1];
			}
			else dp[i][j] = 0;
			ans = max(ans,dp[i][j]);
		}
	}
	puts(ans);
	return 0;
}

Measured memory_bytes: 98560
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <stack>
#include <unordered_map>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 1000005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int a, b, c;
    map<int, int> mpp;
    scanf("%d%d%d", &a, &b, &c);
    mpp[a]++, mpp[b]++, mpp[c]++;
    if (mpp.size() == 2) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

const int DESIGN_SIZE = 4;
const int MAX_RANK = 13;

void inputPossesionCards(bool[DESIGN_SIZE][MAX_RANK], const int&);
void outputMissingCards(bool[DESIGN_SIZE][MAX_RANK]);
int design2Number(const char&);
char number2Design(const int&);

int main(){
	bool boolPossesion[DESIGN_SIZE][MAX_RANK] = {}; //falseで初期化
	int numOfCards;

	std::cin >> numOfCards;
	
	inputPossesionCards(boolPossesion, numOfCards);
	outputMissingCards(boolPossesion);
	return 0;
}

void inputPossesionCards(bool boolPossesion[DESIGN_SIZE][MAX_RANK], const int& numOfCards){
	for (int i = 0; i < numOfCards; i++){
		char cardDesign;
		int cardRank;
		int designNumber;

		std::cin >> cardDesign >> cardRank;
		
		designNumber = design2Number(cardDesign);
		boolPossesion[designNumber][cardRank - 1] = true;
	}
}

void outputMissingCards(bool boolPossesion[DESIGN_SIZE][MAX_RANK]){
	for (int designIndex = 0; designIndex < DESIGN_SIZE; designIndex++){
		for (int RankIndex = 0; RankIndex < MAX_RANK; RankIndex++){
			if (!boolPossesion[designIndex][RankIndex]){
				char cardDesign = number2Design(designIndex);
				std::cout << cardDesign << " " << RankIndex + 1 << std::endl;
			}
		}
	}
}

int design2Number(const char& cardDesign){
	switch (cardDesign){
	case 'S':
		return 0;
	case 'H':
		return 1;
	case 'C':
		return 2;
	case 'D':
		return 3;
	}
}

char number2Design(const int& designNumber){
	switch (designNumber){
	case 0:
		return 'S';
	case 1:
		return 'H';
	case 2:
		return 'C';
	case 3:
		return 'D';
	}
}


Measured memory_bytes: 3100
#include<stdio.h>
#include<iostream>
using namespace std;

int bubbleSort(int a[],int n){
	int flag = 1, j, i, m = 0;
	while(flag){
		flag = 0;
		for(j = n-1;j > 0;j--){
			if(a[j] < a[j-1]){
				i = a[j];
				a[j] = a[j-1];
				a[j-1] = i;
				m++;
				flag = 1;
			}
		}
	}
	return m;
} 

int main(){
	int n, a[101], i, m = 0;
	
	while(scanf("%d",&n) != EOF){
		for(i = 0;i < n;i++)
			scanf("%d",&a[i]);
		m = bubbleSort(a,n);
		printf("%d",a[0]);
		for(i = 1;i < n;i++)
			printf(" %d",a[i]);
		printf("\n");
		printf("%d\n",m);	
	}
	
	return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#if ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif
#define REP(i, k, n) for (signed long long int i = (signed long long int)(k); i < (signed long long int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (signed long long int i = (signed long long int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) std::sort(all(x))
#define REV(x) std::reverse(all(x))
#define UNIQUE(x) x.erase(std::unique(all(x)), x.end());
#define MAX(x) *std::max_element(all(x))
#define MIN(x) *std::min_element(all(x))
#define LOWitr(x, n) std::lower_bound(all(x), n)
#define UPRitr(x, n) std::upper_bound(all(x), n)
#define cii(x) int x; std::cin >> x
#define cill(x) signed long long int x; std::cin >> x
#define cis(x) std::string x; std::cin >> x
#define co(x) std::cout << x << "\n"
#define pb push_back
#define mp std::make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) if(DEBUG) std::cout<<#x<<" : "<<(x)<<"\n"
template<class T>using V = std::vector<T>;
template<class T>using VV = std::vector<std::vector<T>>;
template<class T>using Q = std::queue<T>;
template<class T>using PQ = std::priority_queue<T>;
template<class T,class U>using P = std::pair<T, U>;
template<class T,class U>using M = std::map<T, U>;
template<class T,class U>using UM = std::unordered_map<T, U>;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T>inline void vcin(T &v){for(auto&& i : v) std::cin >> i;}
template<class T>inline void dumpv(const T& v, std::ostream& os = std::cout){
    if(DEBUG){
        os<<"{";
        std::for_each(all(v),[&os](typename T::value_type p){os<<p<<',';});
        os<<"}\n";
    }
}
using std::cin;
using std::cout;
using std::string;
using std::min;
using std::next_permutation;
using LL = signed long long int;
using VL = V<LL>;
using VVL = V<VL>;
const int INF = INT_MAX, MOD = 1e9 + 7;
const LL LLINF = LLONG_MAX;
const double PI = M_PI;

void Main(){
    cis(s);
    string ans = s.substr(0, 3);
    co(ans);
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

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

class UnionFind {
	vector<int>par, high;
public:
	vector<int>size;
	UnionFind(int n) {
		par = high = vector<int>(n);
		size = vector<int>(n, 1);
		for (int i = 0; i < n; i++)par[i] = i;
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (high[x] > high[y]) {
			par[y] = x;
			size[x] += size[y];
		}
		else {
			par[x] = y;
			size[y] += size[x];
			if (high[x] == high[y])high[y]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};
map<int, int>E[200000];
int main() {
	int n, k, l; scanf("%d%d%d", &n, &k, &l);
	UnionFind road(n), rail(n);
	rep(i, k) {
		int p, q; scanf("%d%d", &p, &q); p--; q--;
		road.unite(p, q);
	}
	rep(i, l) {
		int r, s; scanf("%d%d", &r, &s); r--; s--;
		rail.unite(r, s);
	}
	rep(i, n) {
		E[road.find(i)][rail.find(i)]++;
	}
	rep(i, n) {
		int r = road.find(i), s = rail.find(i);
		printf("%d", E[r][s]);
		if (i == n - 1)printf("\n");
		else printf(" ");
	}
}

Measured memory_bytes: 23168
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int, int>;

int main()
{
    const int INF = 1001001001;
    int ans = INF;
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> cList = vector<int>(n);
    int a[n][m];

    rep(i, n)
    {
        cin >> cList[i];
        rep(j, m)
        {
            cin >> a[i][j];
        }
    }

    rep(s, (1 << n))
    {
        int cost = 0;
        vector<int> d = vector<int>(m);
        rep(i, n)
        {
            if (s & (1 << i))
            {
                cost += cList[i];
                rep(j, m)
                {
                    d[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        rep(j, m)
        {
            if (d[j] < x)
            {
                ok = false;
            }
        }
        if (ok)
        {
            ans = min(ans, cost);
        }
    }
    if (ans == INF)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << ans << endl;
    }
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

signed main()
{   
    gearup;
    string s,t; cin >> s >> t;
    ll res =0;
    rep(i,3){
        if(s[i] == t[i])res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
c = 0
d = 0
for i in range(1,X):
    if i in A:
        c += 1
for j in range(X+1,N):
    if j in A:
        d += 1
        
print(min(c,d))



Measured memory_bytes: 9140
#!/usr/bin/env ruby
DEBUG = false
n, y = STDIN.readline().split(' ').map(&:to_i)
MONEY = [10_000, 5_000, 1_000]
def sum(array)
  array.inject(0){|sum, i| sum += i}
end
def calc(c)
  sum(MONEY.zip(c).map{|m, n| m * n})
end
# def make_combination(n, kinds)
#   if kinds == 1
#     [[n]]
#   else
#     (0..n).map{|i| make_combination(n-i, kinds-1).map{|a| [i] + a }}.flatten(1)
#   end
# end
# make_combination(3, 3){|c| puts "#{c},"}
# check = make_combination(n, 3).find{|c| calc(c) == y}
# r = check || [-1, -1, -1]
# puts "#{r.join(' ')}"
# def make_combination(n, kinds)
#   if block_given?
#     (0..n).map{|i| make_combination(n-i, kinds-1).map{|a| [i] + a }}.flatten(1).map{|c| yield c}
#   else
#     if kinds == 1
#       [[n]]
#     else
#       (0..n).map{|i| make_combination(n-i, kinds-1).map{|a| [i] + a }}.flatten(1)
#     end
#   end
# end
# def check(n, y)
#   make_combination(n, 3) do |c|
#     return c if calc(c) == y
#   end
#   [-1, -1, -1]
# end
# def make_combination(n, kinds)
#   if block_given?
#     (0..n).map{|i| make_combination(n-i, kinds-1).map{|a| [i] + a }}.flatten(1).map{|c| yield c}
#   else
#     if kinds == 1
#       [[n]]
#     else
#       (0..n).map{|i| make_combination(n-i, kinds-1).map{|a| [i] + a }}.flatten(1)
#     end
#   end
# end
# def check(n, y)
#   make_combination(n, 3) do |c|
#     return c if calc(c) == y
#   end
#   [-1, -1, -1]
# end

def check(n, y, index, pre)
  if index == MONEY.length - 1
    selected_money = MONEY[index] * n
    puts "n:#{n}, y:#{y}, index:#{index},  pre:#{pre}, selected_money:#{selected_money}" if DEBUG
    return pre + [n] if selected_money == y
  else 
    for i in 0..n do
      selected_money = MONEY[index] * i
      puts "n:#{n}, y:#{y}, index:#{index}, i:#{i}, pre:#{pre}, selected_money:#{selected_money}" if DEBUG
      break if selected_money > y
      c = check(n-i, y-selected_money, index+1, pre+[i])
      return c if c
    end
    nil
  end
end
puts "#{(check(n, y, 0, []) || [-1, -1, -1]).join(' ')}"


Measured memory_bytes: 3836
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class279
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var C = new int[N][];
            for (int i = 0; i < N; i++) C[i] = new int[3];
            int[] count = new int[3];
            for(int i = 0; i < N; i++)
            {
                if (S[i] == 'R') count[0]++;
                else if (S[i] == 'G') count[1]++;
                else count[2]++;

                Array.Copy(count, C[i], 3);
            }

            long ans = 0;
            for(int k = N - 1; k >= 2; k--)
            {
                for(int j = k - 1; j >= 1; j--)
                {
                    if (S[k] == S[j]) continue;
                    int r = 2 * j - k;
                    if (S[k] != 'R' && S[j] != 'R')
                    {
                        ans += C[j - 1][0];
                        if (r >= 0)
                            if (S[r] == 'R') ans--;
                    }
                    else if (S[k] != 'G' && S[j] != 'G')
                    {
                        ans += C[j - 1][1];
                        if (r >= 0)
                            if (S[r] == 'G') ans--;
                    }
                    else
                    {
                        ans += C[j - 1][2];
                        if (r >= 0)
                            if (S[r] == 'B') ans--;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27556
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
#define FOR(__I,__N) for (int __I = 0; __I < __N; ++__I)

typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;
typedef double db;
typedef long double ldb;

const int INF = 0x3f3f3f3f;
const int64 INF64 = 0x3f3f3f3f3f3f3f3fLL;

const int MAX_len = 1000000;
const int MOD = 1000000007;


char str[MAX_len+1];

int pow(int64 a,int64 b,int m){
    a %= m;
    int ret = 1;
    while(b){
        if(b&1) ret = ret*a%m;
        a = a*a%m;
        b >>= 1;
    }
    return ret;
}

int inv(int64 a,int p){
    return pow(a,p-2,p);
}

int fact[MAX_len*2+1];
int p25[MAX_len*2+1];

int calc(int a,int b){
    assert(a >= b);
    int ret = 1;
    ret = (int64)ret*fact[a]%MOD;
    ret = (int64)ret*inv(fact[b],MOD)%MOD;
    ret = (int64)ret*inv(fact[a-b],MOD)%MOD;
    ret = (int64)ret*p25[a-b]%MOD;
    assert(ret >= 0);
    assert(ret < MOD);
    return ret;
}

int solve(int K){
    int len = strlen(str);
    fact[0] = p25[0] = 1;
    FOR(i,K+len)    fact[i+1] = (int64)fact[i]*(i+1)%MOD;
    FOR(i,K+len)        p25[i+1] = (int64)p25[i]*(25LL)%MOD;


    //f[0][0] = 1;
    //FOR(i,K+len){
        //FOR(j,len){
            //f[i+1][j] = (f[i+1][j]+25LL*f[i][j]%MOD)%MOD;
            //f[i+1][j+1] = (f[i][j]+f[i+1][j+1])%MOD;
        //}
    //}

    int ret = pow(26LL,K+len,MOD);
    for (int j = 0; j < len; ++j){
        //ret -= f[K+len][j];
        ret -= calc(K+len,j);
        if(ret < 0)    ret += MOD;
    }

    return ret;
}



int main(){
    int K;
    cin >> K >> str;
    int ans = solve(K);
    printf("%d\n",ans);
}



Measured memory_bytes: 20240
#include <iostream>
#include <string>
#include <map>

std::map<std::string, int> rem;

void solve() {
  int max_count = 0;
  for (const auto& a : rem) {
    if (a.second > max_count) {
      max_count = a.second;
    }
  }
  for (const auto& a : rem) {
    if (a.second == max_count) {
      std::cout << a.first << std::endl;
    }
  }
}

int main() {
  int n;
  std::cin >> n;
  std::string s;
  for (int i = 0; i < n; ++i) {
    std::cin >> s;
    ++rem[s];
  }
  solve();
  return 0;
}


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

int N;
double p[3000];
double dp[3000][3000];

double f (int i, int c)
{
	if (i == N) return (c > N/2) ? 1.0 : 0.0;

	if (dp[i][c] != -1) return dp[i][c];

	return dp[i][c] = (p[i] * f(i+1, c+1)) + ((1 - p[i]) * f(i+1, c));
}

int main()
{
	ios::sync_with_stdio(false);

	cin >> N;
	for (int i = 0; i < N; ++i)
		cin >> p[i];

	for (int i = 0; i < 3000; ++i)
		for (int j = 0; j < 3000; ++j)
			dp[i][j] = -1;
		
	cout << setprecision(10) << f(0, 0) << endl;

	return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string S; cin >> S;
    int N = S.size() - 2;

    ll sum = 0;
    for (int bit = 0; bit < 1 << N + 1; bit++) {
//        printf("%0X\n", bit);
        int b = bit | (int)(pow(2,N+1));
        int cur = 0;
        int len = 1;
        while (b > 0) {
            if (b & 1) {
                ll a =stol(S.substr(cur, len));
//                printf ("cur %d len %d a %ld sum %ld\n", cur, len, a, sum);
                sum += a;
                cur += len;
                len = 1;
            } else {
                len++;
            }
            b >>= 1;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
public class Main{
	public static void main(String args[]){
    double r,ans1,ans2;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    try{
      String line = reader.readLine();
        r = Double.parseDouble(line);
		}catch(Exception e){
      r = 0;
    }
    ans1 = r * r * Math.PI;
    BigDecimal x = new BigDecimal(ans1);
    x = x.setScale(6, RoundingMode.HALF_UP);
    ans2 = 2 * r * Math.PI;
    BigDecimal y = new BigDecimal(ans2);
    y = y.setScale(6, RoundingMode.HALF_UP);
		System.out.println(x + " " + y);
	}
}


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

#define int long long

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, k;
	cin >> n >> k;
	map<int, int> mp;
	for(int i = 0; i < k; i++) {
		int x; cin >> x;
		while(x--) {
			int y; cin >> y;
			mp[y]++;
		}
	}

	cout << (n - mp.size()) << '\n';
				
	return 0;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define show(x) cout<<#x<<" "<<x<<" ";
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
const int MSIZE = 2e5+5;
const int MOD = 1e9+7;

typedef vector<vector<ll>> vec;

vec mul(vec &A, vec & B,int n) {
    vec C(n,vector<ll>(n,0));
    f(i,0,n-1)  f(j,0,n-1)   f(k,0,n-1) {
        C[i][j]+=(A[i][k]*B[k][j])%MOD;
        C[i][j]%=MOD;
    }
    return C;
} 

vec pow_mat(vec &A, ll k) {
    if(k==1)    return A;
    int n = A.size();
    vec B = pow_mat(A,k/2);
    B = mul(B,B,n);
    if(k%2) B = mul(B,A,n);
    return B;
}


int main(){

    FIO
    int n; cin>>n;
    ll k; cin>>k;

    vec mat(n,vector<ll>(n));
    f(i,0,n-1) f(j,0,n-1) cin>>mat[i][j];

    vec res = pow_mat(mat,k);
    ll ans = 0;
    f(i,0,n-1)   f(j,0,n-1)  {
        ans+=res[i][j];  
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;

}
    


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

int main(){
  int H,N;
  cin>>H>>N;
  int sum=0;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    sum+=a;
  }
  if(sum<H){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
    
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n),q(3);
    int ans = 0;
    for(int i=0;i<n;i++){
        cin >> p.at(i);
    }
    for(int i=1;i<n-1;i++){
        int s = p.at(i);
        q.at(0) = p.at(i-1);
        q.at(1) = p.at(i);
        q.at(2) = p.at(i+1);
        sort(q.begin(),q.end());
        if(s==q.at(1)){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def solve(A, B, K):
    if K <= A:
        print(A - K, B)
    elif K - A <= B:
        print(0, B - (K - A))
    else:
        print(0, 0)

if __name__ == "__main__":
    A, B, K = map(int, input().split())
    solve(A, B, K)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(int i=a; i<n; i++)
#define loop(i,a,n)	for(int i=a; i>=n; i--)

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

	int a,b;
	cin>>a>>b;
	if(a<10)
	{
		int c=(100)*(10-a);
		cout<<c+b; return 0;
	}
	cout<<b;
	
	return 0;	
}

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

#define mp make_pair
#define pb push_back
#define f first
#define s second

using namespace std;

typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
typedef map<int,int> mii;
typedef unordered_map<int,int> umii;
typedef queue<int> qi;



int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	
	ll n, m; cin >> n >> m;
	cout << n*(n-1)/2 + m*(m-1)/2 << '\n';
		
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  if (N%2==1){
    cout << "No" <<endl;
    return 0;
  }
  string str;
  cin >>str;
  int leng=str.size();
  string check=str.substr(0,leng/2);
  string check2=str.substr(leng/2,leng/2);
  if (check==check2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		String aabc=" ";
		int m;
		int sum;

		for (;!aabc.equals("-");){
			aabc = sc.next();
			if (aabc.equals("-")) break;

			char array[]= aabc.toCharArray();
			sum=0;
			m= sc.nextInt();

			for (int i=0;i<m;++i){
				sum = sum+ sc.nextInt();
			}
			for (int i=0;i<array.length;++i){
				System.out.print(array[(sum+i)%(array.length)]);
			}
			System.out.println();

		}


	}

}


Measured memory_bytes: 26404
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# 文字列を一文字ずつのリストに代入 test は['t', 'e', 's', 't']
s = list(input())
answer = 0
on = 0
for i in s:
    if i=='A' or i=='C' or i=='G' or i=='T':
        on += 1
        answer = max(answer, on)
    else:
        on = 0

print(answer)



Measured memory_bytes: 20696
#define taskname "test"

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long lli;
typedef pair<int, int> pii;
const int maxn = 1e5 + 5;
int n;
pii piles[maxn];

lli ans[maxn];

void read_input()
{
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> piles[i].first;
        piles[i].second = i;
    }
    sort(piles + 1, piles + n + 1, [](const pii&p, const pii&q)
         {
             return p.first > q.first;
         });
    piles[n + 1] = pii(0, 0);
}

void solve()
{
    int i = 1;
    int min_id = maxn;
    while(i <= n)
    {
        min_id = min(min_id, piles[i].second);
        int j = i + 1;
        while(j <= n && piles[j].first == piles[i].first)
        {
            min_id = min(min_id, piles[j].second);
            ++j;
        }
        int temp = piles[i].first - piles[j].first;
        ans[min_id] += temp * 1LL * (j - 1);
        i = j;
    }

    for(int i = 1; i <= n; ++i)
        cout << ans[i] << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}


Measured memory_bytes: 2688
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 200005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}
/*
int mod[MAX];
int first[2019];
vector<int> possible;
void pre() {
	memset(first, -1, sizeof first);
	int i;
	int x = 10;
	for(i=1;i<MAX;i++) {
		if(first[x] == -1) {
			first[x] = i;
		}
		x = (x*10) % 2019;
	}
	
	for(i=1;i<2019;i++) {
		if(first[i] != -1) possible.PB(i);
	}
}
*/
vector<int> mods[2019];
int main() {
	string s;
	int i, j;
	//pre();
	cin>>s;
	
	LL ans = 0;
	int r = 0;
	int x = 1;
	int freq[2019] = {0};
	for(i=s.length()-1;i>=0;i--) {
		r = (r + x*(s[i]-'0')) % 2019;
		x = (x*10)%2019;
		freq[r]++; 
	}
	
	
	for(i=1;i<2019;i++) {
		ans = ans + (freq[i]*(freq[i]-1))/2;
	}
	
	ans = ans + (freq[0]*(freq[0]+1))/2;
	
	cout<<ans<<endl;
	
    return 0;
}



Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <set>
#include <map>
using namespace std;


class S {
public:
  set<int> s;
};

int main() {
  map<string, S> data;
  set<string> word;
  string str;
  int page;
  while(cin >> str >> page) {
    word.insert(str);
    data[str].s.insert(page);
  }
  set<string>::iterator it = word.begin();
  while(it != word.end()) {
    cout << *it << endl;
    set<int>::iterator it2 = data[*it].s.begin();
    bool first = true;
    while(it2 != data[*it].s.end()) {
      if(first) first = false;
      else      cout << ' ';
      cout << *it2;
      it2++;
    }
    cout << endl;
    it++;
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using lll = long long;
using ull = unsigned long long;
using namespace std;



int main(){
  lll ii,jj,kk;
  long a;
  string s;
  cin >> a;
  cin >> s;
  if(a>=3200){
    cout << s << endl;
  }
  else{
    cout << "red" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

int main(){
    ll a,b,c; cin >> a >> b >> c;
    if((a*100+b*10+c)%4==0) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <numeric>
#include <queue>
#include <set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  ll n;
  cin >> n;
  vector<ll> h(n);
  REP(i, n)
  {
    cin >> h[i];
  }
  h[0]--;
  for (ll i = 1; i < n; i++)
  {
    if (h[i] > h[i - 1])
    {
      h[i]--;
    }
  }
  for (ll i = 1; i < n; i++)
  {
    if (h[i] < h[i - 1])
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lld long double
#define w(x) ll x;cin>>x;while(x--)
#define mod 1000000007
#define speed ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;

int main(){
    speed;
    unordered_map<string,int> mp;
    w(n){
        string s;   cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<'\n';
    cout<<"WA x "<<mp["WA"]<<'\n';
    cout<<"TLE x "<<mp["TLE"]<<'\n';
    cout<<"RE x "<<mp["RE"]<<'\n';
    return 0;
}

Measured memory_bytes: 3632
n = int(input())
aaa = list(map(int, input().split()))

if 1 not in aaa:
    print(-1)
    exit()

i = 0
a = 1
while True:
    try:
        j = aaa.index(a, i)
    except ValueError:
        break
    i = j + 1
    a += 1

print(n - a + 1)


Measured memory_bytes: 24872
#include <iostream>
#include <set>
#include <vector>
#include <map>
using namespace std;
 
#define int long long
#define rep(i, a) for (int i = 0; i < (a); i++)
#define repd(i, a) for (int i = (a)-1; i >= 0; i--)
#define reps(i, a, j) for (int i = (j); i < (a); i++)
#define deb(x) cout << #x << " " << x << endl;
#define debs(x) cout << #x << " " << x << " ";
#define deba(x) for (auto _i:x) cout << _i << " "; cout << endl;
#define ms(a) memset(a,0,sizeof(a));
#define mp make_pair
#define eb emplace_back
#define FastOpen freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pii pair < int , int >
//int power(int x,int p){if(p==0)return 1;if(p==1)return x;if(p%2)return x*power(x,p-1);int y=power(x,p/2);return y*y;}
/*
*/

//const int inf = 1e9 +7;
void solve() {
    int n,w; cin >> n >> w;
    int dp[n][w+1],res = 0;
    ms(dp);
    rep(i,n) {
        int curw,v; cin >> curw >> v;
        if (i == 0) {
            if (curw <= w) dp[i][curw] = v;
            continue;
        }
        rep(j,w+1) {
            dp[i][j] = max(dp[i-1][j],dp[i][j]);
            if (j-curw >= 0 && (j==curw || dp[i-1][j-curw]) )dp[i][j] = max(dp[i-1][j],dp[i-1][j-curw] + v);
        }
    }
    rep(i,w+1) res = max(res,dp[n-1][i]);
    cout << res << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    FastOpen
    int t; t=1;
    while (t--) solve();
}





Measured memory_bytes: 81236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	string s;cin>>s;
	int n=s.size(),wnt=0;
	ll ans=0;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='W') wnt++;
		else ans+=(ll)wnt;
	}
	cout<<ans<<"\n";
}

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

int main() {
  int H, W;
  cin >> H >> W;
  for (int i=0; i<W+2; i++) {
    cout << "#";
  }
  cout << endl;
  string str;
  for (int i=0; i<H; i++) {
    cin >> str;
    cout << "#" << str << "#" << endl;
  }
  for (int i=0; i<W+2; i++) {
    cout << "#";
  }
} 

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

using namespace std;

int main()
{
	int res, l, r, i, j;
	cin>>l>>r;
	res = 2019;
	for (i=l; i<r; i++)
		for (j=i+1; j<=r; j++)
		{
			res = min(res, (i % 2019) * (j % 2019) % 2019);
			if (res == 0)
			{
				cout<<res<<endl;
				return 0;
			}
		}
	cout<<res<<endl;	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


signed main() {
	int n, k, maxn = 0;
	vector<int>L, R;
	int m;

	cin >> n >> m;

	int maxl = 0, minr = 9999999;

	for (int i = 0; i < m; i++) {
		int num1, num2;
		cin >> num1 >> num2;
		L.push_back(num1 );
		R.push_back(num2 );

		maxl = max(maxl, num1 );
		minr = min(minr, num2 );
	}

	int ans = minr - maxl + 1;

	if (ans > 0) {
		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}

/*
	bool flag[100005];
	bool gflag[100005];
	memset(flag, false, sizeof(flag));
	memset(gflag, true, sizeof(gflag));

	for (int i = 1; i <= m; i++) {
		bool tflag[100005];
		memset(tflag, false, sizeof(tflag));

		for (int j = L[i - 1]; j <= R[i - 1]; j++) {
			tflag[j] = true;
		}

		if (i == 1) {
			gflag = tflag;
		}
	}
*/







	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 1276
#include <stdio.h>

#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, color[101], d[101], f[101],time, a[101][101];  

void visit(int u){
  int i;
  color[u]=GRAY;
  d[u]=++time;
  for(i=0; i<n; i++){
    if(a[u][i]==0)continue;
    if(color[i]==WHITE)visit(i);
  }
  color[u] = BLACK;
  f[u]=++time;
}

void dfs(){
  int i;
  for(i=0; i<n; i++){
    color[i]=WHITE;
  }
  time=0;
  for(i=0; i<n; i++){
    if(color[i]==WHITE)visit(i);
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  
}
  
  

int main(){
  int i, j, k,u, v;

  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    scanf("%d %d",&u,&k);
    for(j=0; j<k; j++){
      scanf("%d", &v);
      a[u-1][v-1]=1;
    }
  }

  dfs();
  return 0;
}

Measured memory_bytes: 636
S = list(input())
T = list(input())

ans = -1
ansS = []
if len(S) < len(T):
    ans = -1
else:
    for i in range(len(S) - len(T) + 1):
        ans = 1
        for j in range(len(T)):
            #print(S[i + j], T[j])
            if S[i + j] != T[j] and S[i + j] != "?":
                ans = -1
                break
        if ans == 1:
            thisS = S[:i] + T + S[i + len(T):]
            for j in range(len(S)):
                if thisS[j] == "?":
                    thisS[j] = "a"
            ansS.append(thisS)

if len(ansS) == 0:
    print("UNRESTORABLE")
else:
    ansS.sort()
    for i in ansS[0]:
        print(i, end = "")
    print()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#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 all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define INF 1e9
typedef long long ll;

int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int vis[11];
int check(int n)
{
	while(n)
	{
		if(vis[n%10]==1)
			return 0;
		n/=10;
	}
	return 1;
}
int main()
{
	int n,k;
	int x;
	scanf("%d%d",&n,&k);

        for(int i=0;i<k;i++)
	    {
		   cin>>x;
		   vis[x]=1;
	    }
	    for(int i=n;i>0;i++)
	    {
		   if(check(i))
		   {
                       cout<<i<<endl;
                        return 0;

                   }
	    }


	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int IsPrime(int);

int main(){
  int n,i,c=0;
  scanf("%d",&n);
  int moto[n];
  for(i = 0; i < n; i++){
    scanf("%d",&moto[i]);
  }
  for(i = 0; i < n; i++){
    if(IsPrime(moto[i])){
      c++;
    }
  }
  printf("%d\n",c);
  return 0;
}

int IsPrime(int num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}



Measured memory_bytes: 2128
package main

import (
	"fmt"
)

func main() {
	var N, K, Q int
	fmt.Scanf("%d", &N)
	fmt.Scanf("%d", &K)
	fmt.Scanf("%d", &Q)

	answers := make([]int, N)
	var n int
	for i := 0; i < Q; i++ {
		fmt.Scanf("%d", &n)
		answers[n-1]++
	}

	//fmt.Println("%v", answers)
	for i := 0; i < N; i++ {
		if K-(Q-answers[i]) > 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

Measured memory_bytes: 5888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC113 {
	class ABC113_B {
		private const double SUBRATE = 0.006;
		private static int _N, _T, _A;
		private static Dictionary<int, double> _Hi = new Dictionary<int, double>() { };

		static void Main(string[] args) {
			_N = int.Parse(Console.ReadLine());
			var line = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
			_T = line[0]; _A = line[1];
			foreach (var item in Console.ReadLine().Split(' ').Select((v, ix) => new { v, ix }))
				_Hi[item.ix+1] = Math.Abs(_A - (_T - int.Parse(item.v) * SUBRATE) );

			var SortedHi = _Hi.OrderBy(s => s.Value);
			Console.WriteLine(SortedHi.First().Key);
		}
	}
}


Measured memory_bytes: 13908
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n, x, y, a, b, aa, bb, ans;
int main(){
	int i;
	cin >> n >> x >> y;
	a=b=x+y;
	aa=bb=x-y;
	n--;
	while(n--){
		cin >> x >> y;
		a=min(a,x+y);
		b=max(b,x+y);
		aa=min(aa,x-y);
		bb=max(bb,x-y);
	}
	ans=max(b-a,bb-aa);
	cout << ans << endl; 
	return 0;
}

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

using namespace std;
typedef long long ll;

const int N=200005;

struct node{
	ll v[26];
	node(bool f=0){if(f)memset(v,0,26<<3);}
	ll&operator[](char c){return v[c-'a'];}
	node friend operator+(const node&a,const node&b){
		node c=a;
		for(int i=0;i<26;i++)c.v[i]+=b.v[i];
		return c;
	}
	node friend operator-(const node&a,const node&b){
		node c=a;
		for(int i=0;i<26;i++)c.v[i]-=b.v[i];
		return c;
	}
	node friend operator*(const node&a,ll b){
		node c=a;
		for(int i=0;i<26;i++)c.v[i]*=b;
		return c;
	}
	void print(){
		for(int i=0;i<26;i++)
			printf("%lld%c",v[i]," \n"[i==25]);
	}
}ch[N];

char S[N];
ll l,r,f[105];
int n,fail[N],m,k;
node g[105];

void mk(){
	g[0]=ch[m];f[0]=m;
	g[1]=ch[n];f[1]=n;
	for(k=2;(g[k]=g[k-1]+g[k-2],f[k]=f[k-1]+f[k-2])<=r;k++);
}
node chk1(ll len){
	if(len<=n)return ch[len];
	node ret=ch[n];len-=n;
	ret=ret+ch[m]*(len/m)+ch[len%m];
	return ret;
}
node chk2(ll len){
	node ret(true);
	for(int i=k;i>=1;i--)
		if(len>=f[i])ret=ret+g[i],len-=f[i];
	ret=ret+ch[len];len=0;
	return ret;
}

int main(){
	scanf("%s",S+1);
	n=strlen(S+1)>>1;
	scanf("%lld%lld",&l,&r);
	fail[1]=0;ch[1][S[1]]++;
	for(int i=2;i<=n;i++){
		int p=fail[i-1];
		while(p&&S[p+1]!=S[i])p=fail[p];
		fail[i]=p+(S[p+1]==S[i]);
		ch[i]=ch[i-1];ch[i][S[i]]++;
	}
	m=n-fail[n];
	if(n%m==0)(chk1(r)-chk1(l-1)).print();
	else mk(),(chk2(r)-chk2(l-1)).print();
	return 0;
}

Measured memory_bytes: 22400
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        n: usize,
        s: Chars,
    }
    let (mut r, mut g, mut b): (u64, u64, u64) = (0, 0, 0);
    for c in &s {
        match c {
            'R' => { r += 1; },
            'G' => { g += 1; },
             _ => { b += 1; },
        }
    }
    let mut ans = r * g * b;
    if n < 3 {
        println!("0");
        return;
    }
    for i in 0..(n - 2) {
        for j in 1..(n - i) {
            if i + 2 * j < n {
                if s[i] != s[i + j] && s[i + j] != s[i + 2 * j] && s[i + 2 * j] != s[i] { ans -= 1; }
            } else {
                break;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2208
#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;

const int inf = INT_MAX;
int* d;
int n=1;

void initRMQ(int n) {
    for(int i=0; i<2*n-1; i++) d[i] = inf;
}

void update(int k, int a) {
    k += n-1;
    d[k] = a;
    while(k > 0) {
        k = (k-1)/2;
        d[k] = min(d[k*2+1], d[k*2+2]);
    }
}

int query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return inf;
    if(a <= l && r <= b) return d[k];

    return min(query(a,b,k*2+1,l,(l+r)/2), query(a,b,k*2+2,(l+r)/2,r));
}

int findMin(int a, int b) {
    return query(a, b+1, 0, 0, n);
}

int main() {
    int q, com, x, y, n_;
    cin >> n_ >> q;
    while(n < n_) n *= 2;
    d = new int[2*n-1];
    initRMQ(n);

    for(int i=0; i<q; i++) {
        cin >> com >> x >> y;
        if(com) cout << findMin(x,y) << endl;
        else update(x,y);
    }

    delete[] d;
    return 0;
}



Measured memory_bytes: 3840
#include <iostream>
    #include <stdio.h>
    #include<vector>
    #include<map>
    #include <algorithm>
     
    using namespace std;
     
    unsigned int getPow2(unsigned int num) { //i以上で最小の2のべき乗数を返す
        int i = 0;
        while(1) {
            num >>= 1;
            if(num <= 0) break;
            i++;
        }
        return 1 << i+1;
    }
     
    int main(int, char**) {
        unsigned int N, A;
        map<unsigned int, unsigned int> A_map; //値,個数
        vector<unsigned int> A_vector;
        unsigned int max_odd_index = 0, max_even_index = 0;
        int num_pow2 = 0;
        cin >> N;
        A_vector.reserve(N);
        for(int i = 0; i< N ; i++) {
            cin >> A;
            A_map[A]++;
            A_vector.push_back(A);
        }
        sort(A_vector.begin(), A_vector.end(), greater<int>());
        //ペア探し
        for(int i = 0; i < N; i++) {
            if(A_map[A_vector[i]]==0) continue;
            A_map[A_vector[i]]--;
            if (A_map[getPow2(A_vector[i])-A_vector[i]]!=0) {
                A_map[getPow2(A_vector[i])-A_vector[i]]--;
                num_pow2++;
            }
        }
        cout << num_pow2 << endl;
        return 0;
    }

Measured memory_bytes: 19712
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    printf("%d\n", n*n*3);


    
    return 0;
}



Measured memory_bytes: 128
#include<stdio.h>

int main(){
  char s[5];
  scanf("%s", s);
  for (int i = 0; i < 3; i++) {
    if (s[i] == s[i+1]){
      printf("Bad\n");
      return 0;
    }
  }
  printf("Good\n");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

	double n;
	vector<double> a;
	while(cin >> n) a.push_back(n);
	double maxa = *max_element(all(a));
	double mina = *min_element(all(a));
	fcout << maxa - mina << endl;
	return 0;
}


Measured memory_bytes: 3272
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())

def F(list_):
    if list_ and int("".join(map(str, list_))) > N:
        return
    
    if 3 in list_ and 5 in list_ and 7 in list_:
        yield 1
    
    for v in [3, 5, 7]:
        list_.append(v)
        yield from F(list_)
        list_.pop()
    return

ans = sum(F([]))
print(ans)

Measured memory_bytes: 3064
import sys

def main():
    input = sys.stdin.readline
    M, D = map(int, input().split())
    cnt = 0
    for m in range(1, M+1):
        for d in range(1, D+1):
            d1 = d % 10
            d10 = d // 10
            if min(d1, d10) < 2:
                continue
            if d1 * d10 == m:
                cnt += 1

    return cnt


if __name__ == '__main__':
    print(main())


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

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

    sort(p.begin(), p.end());
    int ans = 0;
    for(int i=0; i<k; i++) ans += p[i];

    cout << ans << endl;
}

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

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.test();
    }
    
    int n;
    private void test() {
        Scanner input = new Scanner(System.in);
        n = input.nextInt();
        int[][] us = new int[n+1][n+1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                int v = input.nextInt();
                us[i][j] = v == -1 ? Integer.MAX_VALUE : v;
            }
            us[i][i] = 0;
        }
        
        int[] f = new int[n+1];
        f[1] = 1;
        int t = calc(us, f);
        System.out.println(t);
    }
    int calc(int[][] us, int[] f) {
        int a = 0;
        int v = Integer.MAX_VALUE;
        for (int i = 1; i <= n; i++) {
            if (f[i] == 1) {
                for (int j = 1; j <= n; j++) {
                    if (i != j && f[j] != 1 && us[i][j] < v) {
                        a = j;
                        v = us[i][j];
                    }
                }
            }
        }
        f[a] = 1;
        if (f[0] == 1) return 0;
        return v + calc(us, f);
    }
}

class Scanner {
    BufferedReader r;
    StreamTokenizer st;
    
    public Scanner(InputStream in) {
        r = new BufferedReader(new InputStreamReader(in));
        st = new StreamTokenizer(r);
    }
    
    public String next() {
        nextToken();
        return st.sval;
    }
    
    public Integer nextInt() {
        nextToken();
        return (int)st.nval;
    }
    
    private int nextToken() {
        int token = st.TT_EOF;
        try {
            token = st.nextToken();
        } catch (IOException e) {
        }
        return token;
    }
}

Measured memory_bytes: 25008