akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

ll MOD=1e9+7, dp[1<<21], a[21][21], n;

ll solve(ll mask){
  if(mask+1 == (1<<n)) return 1;
  ll &r = dp[mask];
  if(r >= 0) return r;
  bitset<3> b(mask);
  int pos = __builtin_popcount(mask);
  r = 0;
  fore(i,0,n) if(!(mask&(1<<i)) && a[pos][i]) r= (r+solve(mask|(1<<i)))%MOD;
  return r;
}

int main(){FIN;
  memset(dp,-1,sizeof(dp));
  cin >> n;
  fore(i,0,n) fore(j,0,n) cin >> a[i][j];
  cout << solve(0) << endl;
}

Measured memory_bytes: 16640
use std::io::stdin;

fn main(){
    let mut a = String::new();
    stdin().read_line(&mut a).unwrap();
    let a: usize = a.trim().parse().unwrap();

    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let s = s.trim();

    println!("{}", if a < 3200 { "red" } else { s });
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define min(a, b) ((a) < (b) ? (a) : (b))

int cmpint(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int main(void) {
    int n;
    scanf("%d", &n);
    int x[n];
    for(int i = 0; i < n; i++) {
        scanf("%d", &x[i]);
    }
    qsort(x, n, sizeof(int), cmpint);
    int min = x[0];
    int max = x[n-1];
    int ans = 0;
    int base = INT_MAX;
    for(; min <= max; ++min) {
        for(int i = 0; i < n; i++) {
            ans += (min - x[i]) * (min - x[i]);
        }
        base = min(base, ans);
        ans = 0;
    }
    printf("%d\n",base);
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
				if(n==0)
					return;
			int a[]=new int[n+1];
			int ans=0;
			for(int i=0;i<=n;i++)
				a[i]=in.nextInt();
			
			for(int i=0;i<=n;i++)
			{
				boolean judge=false;
				for(int j=0;j<=n-2;j++)
				{
					int x=j+2;
					int y=j+1;
					int z=j;
						if(x==i)
						{
							x++;
						}
						else if(y==i)
						{
							x++;
							y++;
						}
						else if(z==i)
						{
							x++;
							y++;
							z++;
						}
						if(x==a.length)
							break;
					if(a[x]-a[y]==a[y]-a[z])
						judge=true;
					else
					{
						judge=false;
						break;
					}
				}
				if(judge)
				{
					ans=i;
					break;
				}
			}
			System.out.println(a[ans]);
		}
	}
}

Measured memory_bytes: 35460
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func generatePrefixFunctionCache(pattern string) []int {
	m := len(pattern)

	cache := make([]int, m+1)
	cache[0] = 0
	cache[1] = 0

	k := 0
	for q := 2; q <= m; q++ {
		for k > 0 && pattern[k] != pattern[q-1] {
			k = cache[k]
		}
		if pattern[k] == pattern[q-1] {
			k++
		}
		cache[q] = k
	}

	return cache
}

// Knuth–Morris–Pratt algorithm
func KMPMatch(text, pattern string) {
	piCache := generatePrefixFunctionCache(pattern)
	// fmt.Println(piCache)

	sizeText := len(text)
	sizePattern := len(pattern)

	stdoutBuffer := []string{}

	q := 0
	for i := 0; i < sizeText; i++ {
		for q > 0 && pattern[q] != text[i] {
			q = piCache[q]
		}
		if pattern[q] == text[i] {
			q++
		}

		// fmt.Println("q:", q, ", sizePattern:", sizePattern)
		if q == sizePattern {
			// fmt.Println(i - sizePattern + 1)
			stdoutBuffer = append(stdoutBuffer, strconv.Itoa(i-sizePattern+1))
			if len(stdoutBuffer) > 1000 {
				fmt.Println(strings.Join(stdoutBuffer, "\n"))
				stdoutBuffer = []string{}
			}
			q = piCache[q]
		}
	}
	if len(stdoutBuffer) > 0 {
		fmt.Println(strings.Join(stdoutBuffer, "\n"))
	}
}

func main() {
	var t, p string
	fmt.Scan(&t)
	fmt.Scan(&p)

	KMPMatch(t, p)
}



Measured memory_bytes: 7200
#include <iostream>

using namespace std;

int main()
{   int A,B;
    cin>>A;
    cin>>B;
    int sum,multi,subtract;
    sum=A+B;
    multi=A*B;
    subtract=A-B;
    if(sum>=multi && sum>=subtract){
        cout<<sum;
    }
    else if ((multi>=sum) &&( multi>=subtract )){
        cout<<multi;
    }
    else if(subtract>multi && subtract>sum){
        cout<<subtract;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    N, K = inpl()
    D = []
    As = []
    for _ in range(K):
        D.append(int(input()))
        As.append(inpl())
    ans = [0] * (N + 1)
    ans[0] = 1
    for A in As:
        for a in A:
            ans[a] += 1
    print(ans.count(0))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9228
D,G = map(int,input().split())
PC = [0]+[list(map(int,input().split()))for i in range(D)]

def f(p,c):
    if p==0:
        return 10**9
    m=min(c//(p*100),PC[p][0])
    s=100*p*m
    if m==PC[p][0]:
        s+=PC[p][1]
    if s<c:
        m+=f(p-1,c-s)
    return min(m,f(p-1,c))

print(f(D,G))

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#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 long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

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

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

	int d[10][10];
	memset(d,0,sizeof(d));

	for (int i = 1; i <= n ; i++){
		if(i%10==0)continue;
		string s=to_string(i);
		d[s[0]-'0'][i%10]++;
	}

	int ans=0;
	for (int i = 1; i < 10; i++){
		for (int j = 1; j < 10; j++){
			ans+= d[i][j]*d[j][i];
		}
	}

	cout<<ans<<endl;

	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    vector<int> v(4);
    for(int i = 0; i < 4; i++){
        cin >> v[i];
    }
    int ans[4] = {1, 4, 7, 9};
    sort(v.begin(), v.end());
    for(int i = 0; i < 4; i++){
        if(ans[i] != v[i]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	string s;
	cin >> s;
	if(s[0] == s[1] and s[1] == s[2] and s[2] == 'R') cout << 3;
	else if((s[0] == s[1] and s[0] == 'R') || (s[1] == s[2] and s[1] == 'R')) cout << 2 ;
	else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') cout << 1;
	else cout << 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv,  digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag; vll D; vll path; vector<string> A; ll magic = 0; vpll list; vl C; vl Ans; ll num = 0;
//***********//
void dfs(ll now) {
	stack<ll> S;
	S.push(now);
	flag[now] = 1;
	while (!S.empty()) {
		ll u = S.top();
		S.pop();
		Ans[u] = C[num];
		if (u != 0) ans += C[num];
		for (ll i = 0; i < path[u].size(); i++) {
			ll v = path[u][i];
			if (flag[v] == 0) {
				num++;
				dfs(v);
			}
		}
	}
}
int main() {
	cin >> N;
	vpll P(N - 1);
	vpll enter(N);
	path.resize(N);
	flag.resize(N);
	C.resize(N);
	Ans.resize(N);
	for (i = 0; i < N; i++) {
		enter[i] = mp(0, i);
	}
	for (i = 0; i < N - 1; i++) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	for (i = 0; i < N; i++) {
		cin >> C[i];
	}
	sort(C.begin(), C.end());
	reverse(C.begin(), C.end());
	dfs(0);
	cout << ans << endl;
	for (i = 0; i < N; i++) {
		cout << Ans[i] << " ";
	}
}

Measured memory_bytes: 9344
import Control.Applicative
import Control.Monad
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Set (Set)
import qualified Data.Set as S

main :: IO ()
main = do
  n <- readLn
  solve <$> replicateM n B.getLine >>= print

solve :: [ByteString] -> Int
solve bs = S.size $ foldl' f S.empty bs
  where
    f st s = S.insert s st


Measured memory_bytes: 65136
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, m; scanf("%d%d", &n, &m);
	std::vector<bool> used(m, true);
	for(int i = 0; i < n; i++) {
		int k; scanf("%d", &k);
		std::set<int> st;
		
		while(k--) {
			int a; scanf("%d", &a);
			st.insert(a - 1);
		}
		for(int j = 0; j < m; j++) {
			if(st.count(j)) continue;
			used[j] = false;
		}
	}
	int ans = 0;
	for(auto v: used) ans += v;
	printf("%d\n", ans);
	return 0;
}


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

void eratosthenes(vector<bool> &prime, int N){
    prime[0] = prime[1] = 0;
    rep(i,N){
        if(prime[i]){
            for(int j = i + i; j < N; j+=i){
                prime[j] = 0;
            }
        }
    }
}

int main(){
  long long N,preN;
  int maxp;
  cin >> N;
  preN = N;
  if(N == 1){
    cout << 0;
    return 0;
  }
  queue<pair<long long ,long long>> que;
  maxp = sqrt(N)+1;
  vector<bool> prime(maxp,true);
  eratosthenes(prime, maxp);
  for(int i=0; i<maxp; i++){
    if(prime[i]){
      long long count = 0;
      while(N%(long long)i == 0){
        count++;
        N /= (long long)i;
      }
      que.push(make_pair(i, count));
    }
  }
  if(preN == N){
    cout << 1;
    return 0;
  }
  if(N != 1){
    que.push(make_pair(N, 1));
  }
  int ans = 0;
  while(que.size()){
    pair<long long, long long> tmp = que.front();
    que.pop();
    long long c = tmp.second;
    for(int i=0; i<1000; i++){
      if(2*c < i*(i+1)){
        ans += i-1;
        break;
      }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 5044
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;

namespace Primary
{

int n, head[3010], to[6010], next[6010], tot = 1, w[3010];
bool win[3010];

inline void add_edge(int u, int v)
{
	to[++tot] = v;
	next[tot] = head[u];
	head[u] = tot;
}

bool dfs(int u, int pre)
{
	win[u] = false;
	for (int c = head[u], v; c; c = next[c])
	{
		v = to[c];
		if (v == pre || w[u] <= w[v]) continue;
		dfs(v, u);
		if (!win[v])
		{
			win[u] = true;
			break;
		}
	}
}

void main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", w + i);
	for (int i = 1, u, v; i < n; ++i)
	{
		scanf("%d%d", &u, &v);
		add_edge(u, v), add_edge(v, u);
	}
	for (int i = 1; i <= n; ++i)
	{
		dfs(i, 0);
		if (win[i]) printf("%d ", i);
	}
}

}

int main()
{
	Primary::main();
	return 0;
}

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

using namespace std;


#define PI 3.14159265
#define int long long

const int mod = 1e9 + 7;


main(){


	int n, m;

	cin >> n >> m;

	vector <int> k(m), p(m);

	vector < vector <int> > s(m);


	for(int i = 0; i < m; i++){
		cin >> k[i];

		s[i].resize(k[i]);
		for(int j = 0; j < k[i]; j++){
			cin >> s[i][j];
			s[i][j]--;
		}
	}


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


	int ans = 0;

	for(int i = 0; i < (1 << n); i++){
		bitset <10> x(i);
		int total = 0;
		for(int j = 0; j < m; j++){
			int current = 0;
			for(int &to : s[j]){
				if(x[to]){
					current++;
				}
			}

			if(current % 2 == p[j]) total++;
		}

		if(total == m) ans++;
	}


	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

ll n;


int main() {
	
	cin >> n;

	ll x = n, y = 1;
	for(ll i = (ll)sqrt(n); i > 0; i--)
	{
		if (n % i == 0)
		{
			x = n / i;
			y = i;
			break;
		}
	}
	cout << x + y - 2;

	return 0;
}


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

int main(){
    int N;
    std::cin >> N;
    int cnt500 = N / 500;
    N -= cnt500 * 500;
    int cnt5 = N/ 5;
    std::cout << 1000 * cnt500 + 5 * cnt5 << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main ()
{
	ll n,count=0,arr[100000];
	cin>>n;
	for(ll i=1;i<=n;i++)
		cin >> arr[i];
	for (ll i=1;i<=n;i++)
	{
		if (arr[i]==i)
		{
			count++;
			if (i==n)
				swap(arr[i],arr[i-1]);
			else
				swap(arr[i],arr[i+1]);
		}
	}
	cout<<count;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

#define debug(x) cout << #x << ": " << x << endl;
#define ll long long
#define mod 1000000007

#define COMMENT

// inverse modulo 2
ll imod2 = mod/2 + 1;

ll imod2p[1<<20];

int N, x, y;
vector<int> g[1<<20];

ll ans = 0;

void update_ans(int x) {
  ll q1 = (1-imod2p[x]+mod)%mod;
  ll q2 = (1-imod2p[N-x]+mod)%mod;

  ans = (ans + (q1*q2)%mod)%mod;
}

int dfs(int s, int p) {
  int nc = 1;
  for(auto node : g[s]) {
    if(node != p) {
      int qq = dfs(node, s);
      update_ans(qq);
        // debug(qq);
      nc += qq;
    }
  }

  return nc;
}

int main() {

//  freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  cin>>N;
  for(int i=1;i<N;i++) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  imod2p[0] = 1;
  for(int i = 1;i <= N;i++) {
    imod2p[i] = (imod2p[i-1]*imod2)%mod;
  }

  dfs(1, -1);

  // debug(ans);
  ans = (mod + ans + 1 - (N*imod2)%mod)%mod;
  ans = (mod+ans - imod2p[N])%mod;

  cout << ans << endl;

  // cout<<3*imod2p[3];
  return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	LL n;
	cin >> n;
	VS s(n);
	cin >> s;
	map<string,LL> mp;
	for (int i = 0; i < n; i++) {
		SORT(s[i]);
		mp[s[i]]++;
	}
	LL ans = 0;
	for (auto&& var : mp) {
		ans += (var.second)*(var.second-1)/2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16640
n = int(input())
a= list(map(int, input().split()))
MOD = 10**9 + 7

ans = 1
cnt = 1
pos = 1
for i in range(n):
    ans *= cnt
    ans %= MOD
    if a[i] < pos:
        continue
    pos += 2
    cnt += 1
print(ans)

Measured memory_bytes: 62704
N = int(input())
AAA = map(int,input().split())
AA = list(AAA)
AA.sort()
mini = 10**7
x = AA[-1]
for i in range(AA[0],x+1):
  total = 0
  for j in AA:
    total += (j-i)**2
  if total < mini:
    mini = total
print(mini)

Measured memory_bytes: 9144
import std.stdio;
import std.conv;
import std.array;

void main()
{
    int N = readln.split[0].to!int;
    auto reader = readln.split;
    int[] a = new int[N];
    for(uint i = 0; i < N; i++){
        a[i] = reader[i].to!int;
    }

    int cnt = 0;
    for(uint i = 0; i < N; i++){
        if (a[i] != i + 1) cnt++;
    }

    if (cnt == 0 || cnt == 2){
        writeln("YES");
    } else {
        writeln("NO");
    }
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[]A = new int[N];
		string[] str = Console.ReadLine().Split();
		for(var i=0;i<N-1;i++){
			int a1 = int.Parse(str[i]);
			A[a1-1]++;
		}
		for(var i=0;i<N;i++){
			Console.WriteLine(A[i]);
		}
	}
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
constexpr long long MOD2 = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;


int main() {
    ll S; cin >> S;
    ll a, b, c, d; // want : |ad-bc| = S;
    a = (ll)1e9;
    d = min(S / a + 1, a);
    b = 1;
    c = a * d - S;

    cout << 0 << " " <<  0 << " " << a << " " << b << " "
         << c << " " << d << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
} 
P a[114514];
P b[114514];
P c[114514];
P d[214514];
signed main(){
	ic(n) ic(m)
	ic(x) ic(y) ic(z)
	rep(0,i,x)cin>>a[i].f;
	rep(0,i,x)a[i].s=1;
	rep(0,i,y)cin>>b[i].f;
	rep(0,i,y)b[i].s=2;
	rep(0,i,z)cin>>c[i].f;
	rep(0,i,z)c[i].s=3;
	rep(0,i,x)d[i].f=a[i].f;
	rep(0,i,x)d[i].s=a[i].s;
	rep(0,i,y)d[i+x].f=b[i].f;
	rep(0,i,y)d[i+x].s=b[i].s;
	rep(0,i,z)d[i+x+y].f=c[i].f;
	rep(0,i,z)d[i+x+y].s=c[i].s;
	sort(d,d+x+y+z);
	reverse(d,d+x+y+z);
	int ans=0;
	int nn=n;
	int mm=m;
	int goukei=n+m;
	rep(0,i,x+y+z){
		if(goukei>0){
			if(d[i].s==1&&nn>0){
				ans+=d[i].f;
				nn-=1;
				goukei-=1;
			}
			if(d[i].s==2&&mm>0){
				ans+=d[i].f;
				mm-=1;
				goukei-=1;
			}
			if(d[i].s==3){
				ans+=d[i].f;
				goukei-=1;
			}			
		}
		else{
			c(ans)
			return 0;
		}		
	}	
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int D;
    cin >> D;
    ll c[26];
    rep(i, 26) cin >> c[i];
    ll s[D][26];
    rep(i, D){
        rep(j, 26) cin >> s[i][j];
    }
    int pre[26];
    fill(pre, pre+26, -1);
    rep(i, D){
        ld tmp[26];
        rep(j, 26){
            tmp[j] = s[i][j] + c[j]*(i-pre[j])*((ld)(D-i)/(ld)(26));
        }
        int res = -1;
        ld m = -INF;
        rep(j, 26){
            if(chmax(m, tmp[j])) res = j;
        }
        pre[res] = i;
        cout << res+1 << endl;
    }
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 201000

vi bucket_sizes;
int N;
string S;
ll ans;
ll MOD = 998244353;
ll mem[MAXN];
ll mod2[MAXN];
string rep, con, opp;

int main(){
	cin>>N>>S;
	for (int i=3;i<=N;i+=2)if (!(N%i)){
		bucket_sizes.pb(N/i);
	}
	// for (auto i : bucket_sizes)cout<<i<<' ';cout<<'\n';
	reverse(ALL(bucket_sizes));

	ll m = 1;
	ans = 1;
	for (int i=N-1;i>=0;--i){
		if(S[i] == '1'){ans += m; ans %= MOD;}
		mod2[N-1-i] = m;
		m = (m*2)%MOD;
	}
	ans = ans*(2*N)%MOD;

	for (auto bsiz : bucket_sizes){
		ll offset = 0;
		for (auto j:bucket_sizes)if(bsiz%j == 0){offset += mem[j];offset %= MOD;}
		// cout<<bsiz<<' '<<offset<<'\n';
		ll s = 0;
		rep = con = opp = "";

		for (int j=0;j<bsiz;++j){
			if (S[bsiz - 1 - j] == '1'){
				s += mod2[j];
				s %= MOD;
			}
			rep += S[j];
			opp += ('0' + '1' - S[j]);
		}

		// cout<<s<<'\n'; // Number of things that work from 0 to id-1
		// Must construct if its equal
		int in = 0;
		while (SZ(con) < N){
			if (in)for (auto i : opp)con += (i);
			else for (auto i : rep)con += (i);
			in = 1 - in;
		}
		if (con <= S)++s;
		s = (s+MOD-offset)%MOD;
		// cout<<"Discount "<<bsiz<<' '<<s<<'\n';
		ans = (ans + MOD - (s * (2*N - 2*bsiz))%MOD)%MOD;
		mem[bsiz] = s;
	}
	
	cout<<ans;
}

Measured memory_bytes: 2776
# -*- coding: utf-8 -*-
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, M = map(int, input().split())
An = list(map(int, input().split()))

Cn = [0]*(N+1)

for i,Ai in enumerate(An):
    if i == 0:
        Cn[i+1] = Ai
    else:
        Cn[i+1] = Cn[i] + Ai

# def func(n):
#     if n <= 1:
#         return 1
#     else:
#         tmp = 1
#         for i in range(2,n+1):
#             tmp = tmp * i
#         return tmp

mod = {}
for i in range(N+1):
    if Cn[i]%M in mod:
        mod[Cn[i]%M] += 1
    else:
        mod[Cn[i]%M] = 1

ans = 0
for val in mod.values():
    if val <= 1:
        continue
    elif val == 2:
        ans += 1
    else:
        # tmp = func(val) / (func(2) * func(val - 2))
        tmp = combinations_count(val,2)
        ans += int(tmp)

print(ans)


Measured memory_bytes: 16540
H,W = map(int,input().split())
M = [""]*H
r = [False]*H
c = [False]*W

for i in range(H):
  M[i]=input()

for i in range(H):
  for j in range(W):
    if M[i][j]=="#":
      r[i]=True
      c[j]=True
      
for i in range(H):
  if r[i]:
    for j in range(W):
      if c[j]:
        print(M[i][j],end="")
    print()
    


Measured memory_bytes: 9224
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define int long long
#define m_k make_pair
using namespace std;
int n,m;
signed main()
{
	scanf("%lld%lld",&n,&m);
	printf("%lld\n",(1ll<<m)*(100ll*(n-m)+1900ll*m));
}

Measured memory_bytes: 3816
#include<iostream>
using namespace std;
void plus1(int *x,int *y,int *count){
  *x += 1;
  *y += 1;
  *count += 1;
}
void plus2(int *x,int *count){
  *x += 2;
  *count += 1;
}
int main(){
  int a,b,c;
  int count = 0;
  int max,mid,min;
  cin >> a >> b >> c;
  if(a>b){
    max = a;
    min = b;
  }else{
    max = b;
    min = a;
  }
  if(c>max){
    mid = max;
    max = c;
  }else if(c>min){
    mid = c;
  }else{
    mid = min;
    min = c;
  }


  while(max - mid >1){
    plus2(&mid,&count);
  }
  while(mid - min >1){
    plus2(&min,&count);
  }
  while(max - min >1){
    plus2(&min,&count);
  }
  if(max == mid && mid == min){

  }else if(max == min){
    plus1(&max,&min,&count);
    plus2(&mid,&count);
  }else if(mid == min){
    plus1(&mid,&min,&count);
  }else if(max == mid){
    plus1(&max,&mid,&count);
    plus2(&min,&count);
  }
  // cout << max << " " << mid << " " << min <<endl;
  // cout << count << endl;
  if(count >=(3 * max - (a+b+c))/2){
    cout << (3 * max - (a+b+c))/2<< endl;
  }else{
    cout << count << endl;
  }
  // (3 * max - (a + b + c))/2
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
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;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int i,n,k,ans=1;
	cin>>n>>k;
	for(i=0;i<n;i++){
		ans=min(ans*2,ans+k);
	}
	cout<<ans<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int x,y;
    for (;;){
        scanf("%d %d",&x,&y);
        if(x == 0 && y==0){
            break;
        }
        
        if(x>y){
        printf("%d %d\n",y,x);
        }else if (y>=x) printf("%d %d\n",x,y);
    }
    
    return 0;
}


Measured memory_bytes: 2680
#include <iostream>
#define LMAX 1005
#define MOD 1000000007

using namespace std;

int m[LMAX][LMAX];
int ans[LMAX][LMAX];
int n, em;
char c;

int main()
{
    cin>>n>>em;
    for (int i=1; i<=n; ++i)
    {
        for (int j=1; j<=em; ++j)
        {
            cin>>c;
            if (c == '.')
            {
                m[i][j] = 1;
            }
            else
            {
                m[i][j] = 2;
            }
        }
    }
    ans[1][0] = 1;
    for (int i=1; i<=n; ++i)
    {
        for (int j=1; j<=em; ++j)
        {
            if (m[i][j] == 2)
            {
                continue;
            }
            ans[i][j] = (ans[i-1][j] + ans[i][j-1]) % MOD;
        }
    }

    cout<<ans[n][em]<<'\n';
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
    #define rep(i,n) for(ll i=0;i<(n);++i)
    #define all(a) (a).begin(),(a).end()
    #define dunk(a) cout << (a) << "/n"
    #define rall(a) (a).rbegin(),(a).rend()
    const int INF = 2e9;
    using namespace std;
    using Graph = vector<vector<int>>;
    typedef pair<int,int> P;
    typedef long long ll;
     
    int main(){
    	string s;
    	cin >> s;
    	reverse(s.begin(),s.end());
    	string divide[4] = {"maerd","resare","esare","remaerd"};
    	rep(i,s.size()){
    		bool ok = false;
    		rep(j,4){
    			if(s.substr(i, divide[j].size()) == divide[j]){
    				ok = true;
    				i += divide[j].size() - 1;
    			}
    		}
    		if(!ok){
    			cout << "NO" << endl;
    			return 0;
    		}
    	}
    	cout << "YES" << endl;
        return 0;
    }

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using Int = __int128_t;
Int abs128(Int val){return val<0?-val:val;}

ostream &operator<<(ostream &os,Int val){
  if(ostream::sentry(os)){
    __uint128_t tmp=abs128(val);
    char buf[64];
    char *d=end(buf);
    do{
      --d;
      *d=char(tmp%10+'0');
      tmp/=10;
    }while(tmp);
    if(val<0) *--d='-';
    Int len=end(buf)-d;
    if(os.rdbuf()->sputn(d,len)!=len){
      os.setstate(ios_base::badbit);
    }
  }
  return os;
}

istream &operator>>(istream &is,Int &val){
  string s;
  is>>s;
  val=0;
  for(Int i=0;i<(Int)s.size();i++)
    if(isdigit(s[i])) val=val*10+s[i]-'0';
  if(s[0]=='-') val*=-1;
  return is;
}

signed main(){
  Int n,q;
  cin>>n>>q;
  auto par=[&](Int x){
    if(x<=n+1) return Int(1);
    Int s=1,p=1;
    while(s+p<=x){
      s+=p;
      p*=n;
    }
    //cout<<x<<" "<<s-(p/n)+(x-s)/n<<endl;
    return s-(p/n)+(x-s)/n;
  };
  for(Int i=0;i<q;i++){
    Int u,v;
    cin>>u>>v;
    if(n==1) cout<<min(u,v)<<endl;
    else{
      while(u&&u!=v){
	if(u<v) swap(u,v);
	u=par(u);
      }
      cout<<u<<endl;
    }
  }
  return 0;
}


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

int main(){
	int a,b;
	char op;

	while(1){
	cin >> a >> op >> b;
		if(op == '?')break;
		else if(op == '+') cout << a + b << endl;
		else if(op == '-') cout << a - b << endl;
		else if(op == '*') cout << a * b << endl;
		else if(op == '/') cout << a / b << endl;
	}

	return 0;
}

Measured memory_bytes: 3080
main(){
  int n,a,b,c;
  scanf("%d",&n);
  while(n>0)
    {
      n--;
      scanf("%d %d %d",&a,&b,&c);
      a=a*a;
      b=b*b;
      c=c*c;
      if(a+b==c)
	printf("YES\n");
      else if(a+c==b)
	printf("YES\n");
      else if(b+c==a)
	printf("YES\n");
      else
	printf("NO\n");
    }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define PI acos(-1.0)
#define mod 1000000007
#define matrixDimension 50
using namespace std;
struct matrix
{
    ll mat[matrixDimension][matrixDimension];
    matrix()
    {
        memset(mat, 0, sizeof mat);
    }
};
matrix operator*(matrix x, matrix y)
{
    matrix ans;
    for(int i=0; i<matrixDimension; i++)
    {
        for(int j=0; j<matrixDimension; j++)
        {
            for(int k=0; k<matrixDimension; k++)
            {
                ans.mat[i][j]=(ans.mat[i][j]+(x.mat[i][k]*y.mat[k][j])%mod)%mod;
            }
        }
    }
    return ans;
}
matrix I;
matrix matrix_exponential(matrix M, ll x)
{
    matrix ans=I;
    while(x>0)
    {
        if(x%2)
            ans=ans*M;
        M=M*M;
        x/=2;
    }
    return ans;
}
void createIndentity()
{
    for(int i=0; i<matrixDimension; i++)
        I.mat[i][i]=1;
}

int main()
{
    createIndentity();
    ll n, m;
    cin>>n>>m;
    matrix M;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
            cin>>M.mat[i][j];
            //scanf("%d", &M.mat[i][j]);
    }
    M=matrix_exponential(M, m);
    ll ans=0;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            ans=(ans+M.mat[i][j])%mod;
        }
    }
    cout<<ans<<endl;
  //  printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384
import sys
import collections as coun
sys.setrecursionlimit(10000000)
s=input()
n=len(s)
def mod10(x):
    return (10**(x%224))%2019
dp=[-1]*n
tmp=0
for i in reversed(range(n)):
    if i==n-1:
        dp[i]=int(s[i])
    else:
        dp[i]=(dp[i+1]+int(s[i])*pow(10,n-1-i,2019))%2019

#print(dp)
p=-1
for i in range(len(dp)-1):
    if dp[i]==dp[i+1]:
        dp[i]=p
        p=p-1

#print(dp)

c=coun.Counter(dp)
sum=0
for v in c.values():
    sum+=v*(v-1)//2
#print(sum)
for i in dp:
    if i==0:
        sum+=1
#print(sum)
if dp[-1]==0:
    sum=sum-1
print(sum)

Measured memory_bytes: 16640
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
int main(){
int n;
cin>>n;
vector<ll> a(n);
ll zero=0,two_pro=0,four_pro=0;
for(int i=0;i<n;i++){
    cin>>a.at(i);
    ll cnt=0;
    while(a.at(i)%2==0){
        a.at(i)/=2;
        cnt++;
        if(cnt==2)break;
    }
    if(cnt==0)zero++;
    else if(cnt>1)four_pro++;
    else two_pro++;
}
//0 4 2  2  2  2  2 4 0 4 2  2  2 2  4 0
if(two_pro>0)zero++;
if(zero-four_pro<2)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

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

using namespace std;

#ifdef Lin1043
    #define DEBUG(msg, ...) printf("(%s #%d) " msg, __FUNCTION__, __LINE__, __VA_ARGS__)
    #define massert(...) assert(...)
#else
    #define DEBUG(...)
    #define massert(...)
#endif

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

struct iopener
{
    iopener()
    {
#ifdef Lin1043
        freopen("./in" , "r" , stdin);
#endif
    }
} iop;

typedef long long LL;

template<typename T>inline bool chkmin(T &x , const T &y) { return x > y ? (x = y , 1) : 0; }
template<typename T>inline bool chkmax(T &x , const T &y) { return x < y ? (x = y , 1) : 0; }

template<typename T>inline T read(T &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c)) x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

LL A[4];

int main()
{
    rep(i , 1 , 3) read(A[i]);
    rep(i , 1 , 3) if(A[i] % 2 == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    LL Ans = A[1] * A[2];
    rep(i , 1 , 3)
        rep(j , i + 1 , 3)
        {
            chkmin(Ans , A[i] * A[j]);
        }
    cout << Ans << endl;
    return 0;
}



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

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

  int ans = 0;
  int tem = 0;

  for (int i = 1; i < N; i++) {
     if (vec.at(i - 1) >= vec.at(i)) {
       tem ++;
     }
     else {
       tem = 0;
     }
     ans = max(ans, tem);
   }
   
   cout << ans << endl;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

ll p(ll b, ll e){
	ll ans = 1;
	for(int i = 1; i <= e; i++)
		ans *= b;
	return ans;
}

void solve(){
	ll n, sum = 0, d = 1, atual = 1;
	cin >> n;
	while(true){
		ll v = p(26, d);
		if(v + sum >= n){
			n-=sum;
			break;
		}
		sum += v, d++;
	}
	string ans;
	while((ll)sz(ans) < d){
		ll sum = 0;
		for(ll i = 1; i <= 26; i++){
			ll value = i * p(26, d-atual);
			//cout << ans << " " << i << " " <<(char)(i + 96) <<" " << value <<" " << n << endl;
			if(value >= n or i == 26){
				ans += char(i+96);
				n -= sum;
				atual++;
				break;
			}
			sum = value;
		}
	}
	cout << ans << endl;
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


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

const int mod = 1e9 + 7, n = 3;
struct Matrix {
    int64_t a[n][n]{};
    Matrix operator*(const Matrix& o) {
        Matrix res;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    res.a[i][k] = (res.a[i][k] + a[i][j] * o.a[j][k]) % mod;
                }
            }   
        }
        return res;
    }
};

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int s, ans = 0;
    cin >> s;
    if (s > 2) {
        Matrix x, y;
        for (int i = 0; i < n; i++) 
            x.a[i][i] = 1;
        y.a[0][0] = y.a[2][0] = 1;
        y.a[0][1] = y.a[1][2] = 1;
        s -= 3;
        while (s) {
            if (s & 1) x = x * y;
            y = y * y;
            s >>= 1;
        }
        ans = x.a[0][0];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3588
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

int S[110000];

int main(){
    int N,C;
    cin>>N>>C;
    vector<P> V[32];
    for(int i=0;i<N;i++){
        int s,t,c;
        cin>>s>>t>>c;
        V[c].push_back(P(s,t));
    }
    for(int i=1;i<=C;i++){
        sort(V[i].begin(),V[i].end());
        for(int j=0;j<(int)V[i].size();){
            int s=V[i][j].first,e=V[i][j].second;
            j++;
            while(j<(int)V[i].size() && e==V[i][j].first){
                e=V[i][j].second; j++;
            }
            S[s]++; S[e+1]--;
        }
    }
    int ans=0;
    for(int i=1;i<=100000;i++){
        S[i]+=S[i-1];
        ans=max(ans,S[i]);
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 1920
#include <iostream>
#include <stdio.h>
#include<bits/stdc++.h>
#define ll long long
#define read freopen("input/test (4).txt","r",stdin)
#define write freopen("output/test (4).txt","w",stdout)
#define fr first
#define sc second
#include <sstream>
#define ii pair < int , int >
#define mp make_pair
using namespace std;
string s;
int len;
int memo[200001];
int solve(int i)
{

    if(i == len)
        return 1;
    int &ret = memo[i];
    if(ret != -1)
        return ret;
    if(i+5 > len)
        return 0;
    int x1 = 0,x2 = 0 , x3 = 0 , x4 = 0;
    if(s[i] == 'd'&&s[i+1] == 'r' && s[i+2] == 'e'&&s[i+3] == 'a' && s[i+4] == 'm')
    {
        x1 = solve(i+5);
        if(i+7 <= len && s[i+5] == 'e' && s[i+6] == 'r')
        x2 = solve(i+7);
    }
    if(s[i] == 'e'&&s[i+1] == 'r' && s[i+2] == 'a'&&s[i+3] == 's' && s[i+4] == 'e')
    {
        x3 = solve(i+5);
        if(i+6 <= len && s[i+5] == 'r')
        x4 = solve(i+6);
    }
    return ret = max(max(x1,x2),max(x3,x4));
}
int main()
{
  cin>>s;
  memset(memo,-1,sizeof(memo));
  len = s.length();
  int R = solve(0);
  if(R == 1)
    cout<<"YES";
  else
    cout<<"NO";
}


Measured memory_bytes: 2304
import sys
input = sys.stdin.readline
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    A = list(map(int, input().split()))
    zeros = [0] * 60
    ones = [0] * 60
    for a in A:
        for i, c in enumerate(bin(a)[2:].zfill(60)):
            if c == '0':
                zeros[59 - i] += 1
            else:
                ones[59 - i] += 1
    ans = 0
    for i in range(60):
        ans += zeros[i] * ones[i] * (2 ** i)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 123132
from collections import defaultdict


def main():
    S = input()
    while True:
        change = False
        for x in "dreamer", "eraser", "dream", "erase":
            if x == S[-len(x):]:
                S = S[:-len(x)]
                change = True
                break
        if not change:
            break

    print("YES" if S == "" else "NO")


if __name__ == '__main__':
    main()


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

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> A;
    int sum = 0;
    for(int i = 0; i < N; i++){
        int t;
        cin >> t;
        sum += t;
        A.push_back(t);
    }

    std::sort(A.begin(), A.end(), std::greater<>());

    float max = (float)sum / (float)(4 * M);
    bool success = true;
    for(int i = 0; i < M; i++) {
       if(A[i] < max) {
           success = false;
           break;
       } 
    }

    if(success) {
        cout << "Yes" << endl;
    }
    else { 
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 888
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    int[] h = new int[N];

    for (int i = 0; i < N; i++) {
      h[i] = sc.nextInt();
    }

    sc.close();

    int count = 0;
  
    for (int i = 0; i < N; i++) {
      if (K <= h[i]) {
        count++;
      }
    }
    
    System.out.println(count);
    
  }

}

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

const ll MAX = 300005;
const ll INF = 1001001001;
const ll MOD = 998244353;

ll N, A, B, K, ans=0, tmp=0;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(){
    COMinit();
    cin >> N >> A >> B >> K;
    for(int i=0;i<=N;i++) {
        tmp = K-A*i;
        if(tmp%B!=0) continue;
        tmp /= B;
        if(tmp>N) continue;
        ans += COM(N,i)*COM(N,tmp);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10668
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>

using namespace std;
typedef long long ll;

int main(){

    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(i % 2 == 0) cout << s[i];
    }
    cout << endl;

}

Measured memory_bytes: 512
#include <stdio.h>
#include <limits.h>
#define Max INT_MAX
#define Min INT_MIN

int main(void)
{
  int n;
  int i;
  int R[200000];
  int max=Min;
  int min=Max;
  int dif;

  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%d",&R[i]);
    dif = R[i] - min;
    if(dif>max)max=dif;
    if(R[i]<min)
    {
      min = R[i];
    }

  }
  printf("%d\n",max);

  return 0;
}

Measured memory_bytes: 1376